Re: potential bug in trigger with boolean params

From: Andreas Joseph Krogh <andreak(at)officenet(dot)no>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: potential bug in trigger with boolean params
Date: 2011-05-11 09:29:30
Message-ID: 24249614.350.1305106170514.JavaMail.on@prod2
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

<p>P&aring; onsdag 11. mai 2011 kl 11:30:51 skrev <strong>Szymon Guz</strong> &lt;<a href="mailto:mabewlun(at)gmail(dot)com">mabewlun(at)gmail(dot)com</a>&gt;:</p>
<blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> <br />
<br />
<div class="gmail_quote">On 11 May 2011 11:01, Andreas Joseph Krogh <span dir="ltr">&lt;<a href="mailto:andreak(at)officenet(dot)no">andreak(at)officenet(dot)no</a>&gt;</span> wrote:<br />
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> P&aring; onsdag 11. mai 2011 kl 10:56:19 skrev &lt;<a href="mailto:tv(at)fuzzy(dot)cz">tv(at)fuzzy(dot)cz</a>&gt;:<br />
<div>
<div>&nbsp;</div>
<div class="h5">&gt; &gt; Hi,<br />
&gt; &gt; I was trying to create a trigger with parameters. I've found a potential<br />
&gt; &gt; bug<br />
&gt; &gt; when the param is boolean.<br />
&gt; &gt;<br />
&gt; &gt; Here is code replicating the bug:<br />
&gt; &gt;<br />
&gt; &gt; CREATE TABLE x(x TEXT);<br />
&gt; &gt;<br />
&gt; &gt; CREATE OR REPLACE FUNCTION trigger_x() RETURNS TRIGGER AS $$<br />
&gt; &gt; BEGIN<br />
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; RETURN NEW;<br />
&gt; &gt; END; $$ LANGUAGE PLPGSQL;<br />
&gt; &gt;<br />
&gt; &gt; CREATE TRIGGER trig_x_text BEFORE INSERT ON x FOR EACH ROW EXECUTE<br />
&gt; &gt; PROCEDURE<br />
&gt; &gt; trigger_x('text');<br />
&gt; &gt; CREATE TRIGGER trig_x_int BEFORE INSERT ON x FOR EACH ROW EXECUTE<br />
&gt; &gt; PROCEDURE<br />
&gt; &gt; trigger_x(10);<br />
&gt; &gt; CREATE TRIGGER trig_x_float BEFORE INSERT ON x FOR EACH ROW EXECUTE<br />
&gt; &gt; PROCEDURE trigger_x(42.0);<br />
&gt; &gt; CREATE TRIGGER trig_x_bool BEFORE INSERT ON x FOR EACH ROW EXECUTE<br />
&gt; &gt; PROCEDURE<br />
&gt; &gt; trigger_x(true);<br />
&gt; &gt;<br />
&gt; &gt; ERROR: &nbsp;syntax error at or near &quot;true&quot;<br />
&gt; &gt; LINE 1: ... INSERT ON x FOR EACH ROW EXECUTE PROCEDURE trigger_x(true);<br />
&gt;<br />
&gt; The docs clearly state what the valid values are and the literal 'true' is<br />
&gt; not one of them (TRUE is). See this:<br />
&gt;<br />
&gt; <a target="_blank" href="http://www.postgresql.org/docs/9.0/interactive/datatype-boolean.html">http://www.postgresql.org/docs/9.0/interactive/datatype-boolean.html</a><br />
</div>
</div>
What are you trying to accomplish? &quot;CREATE OR REPLACE FUNCTION trigger_x()&quot; does not declare any formal-parameters, so calling it with arguments doesn't make sense. I'm surprised creating the other triggers didn't produce an error stating &quot;No function defined with the name trigger_ix and the given argument-type&quot;.<br />
<br />
</blockquote>
<div>&nbsp;</div>
<div>That's how you define trigger function. Later you can use params when defining trigger.</div>
</div>
</blockquote>
<p>Pardon my ignorance:-)<br />
<br />
<span style="font-family: monospace; font-size: 10px;">--<br />
Andreas Joseph Krogh &lt;andreak(at)officenet(dot)no&gt;<br />
Senior Software Developer / CTO<br />
Public key: http://home.officenet.no/~andreak/public_key.asc<br />
------------------------+---------------------------------------------+<br />
OfficeNet AS&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | The most difficult thing in the world is to |<br />
Rosenholmveien 25&nbsp; &nbsp; &nbsp; &nbsp;| know how to do a thing and to watch&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br />
1414 Troll&aring;sen&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | somebody else doing it wrong, without&nbsp; &nbsp; &nbsp; &nbsp;|<br />
NORWAY&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | comment.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<br />
Org.nr: NO 981 479 076&nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br />
Tlf:&nbsp; &nbsp; +47 24 15 38 90 |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br />
Fax:&nbsp; &nbsp; +47 24 15 38 91 |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br />
Mobile: +47 909&nbsp; 56 963 |&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br />
------------------------+---------------------------------------------+<br />
</span></p>
>From pgsql-hackers-owner(at)postgresql(dot)org Wed May 11 06:51:00 2011
Received: from maia.hub.org (maia-2.hub.org [200.46.204.251])
by mail.postgresql.org (Postfix) with ESMTP id E65541337B47
for <pgsql-hackers-postgresql(dot)org(at)mail(dot)postgresql(dot)org>; Wed, 11 May 2011 06:50:59 -0300 (ADT)
Received: from mail.postgresql.org ([200.46.204.86])
by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024)
with ESMTP id 01606-05-2
for <pgsql-hackers-postgresql(dot)org(at)mail(dot)postgresql(dot)org>;
Wed, 11 May 2011 09:50:42 +0000 (UTC)
X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6
Received: from exprod7og115.obsmtp.com (exprod7og115.obsmtp.com [64.18.2.217])
by mail.postgresql.org (Postfix) with ESMTP id 7CF7A1337BBB
for <pgsql-hackers(at)postgresql(dot)org>; Wed, 11 May 2011 06:50:41 -0300 (ADT)
Received: from mail-ey0-f181.google.com ([209.85.215.181]) (using TLSv1) by exprod7ob115.postini.com ([64.18.6.12]) with SMTP
ID DSNKTcpb8Vg949PvnYB3Ayl45TPvvxtkYYKn(at)postini(dot)com; Wed, 11 May 2011 02:50:42 PDT
Received: by eyh5 with SMTP id 5so102603eyh.26
for <pgsql-hackers(at)postgresql(dot)org>; Wed, 11 May 2011 02:50:40 -0700 (PDT)
Received: by 10.213.25.82 with SMTP id y18mr134026ebb.76.1305107439750;
Wed, 11 May 2011 02:50:39 -0700 (PDT)
Received: from [192.168.1.183] (dsl-hkibrasgw2-ff7ac300-240.dhcp.inet.fi [88.195.122.240])
by mx.google.com with ESMTPS id y9sm4966885eeh.8.2011.05.11.02.50.37
(version=TLSv1/SSLv3 cipher=OTHER);
Wed, 11 May 2011 02:50:38 -0700 (PDT)
Message-ID: <4DCA5BEC(dot)2020805(at)enterprisedb(dot)com>
Date: Wed, 11 May 2011 12:50:36 +0300
From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; fi-FI; rv:1.9.1.16) Gecko/20110307 Icedove/3.0.11
MIME-Version: 1.0
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
CC: Robert Haas <robertmhaas(at)gmail(dot)com>,
Jaime Casanova <jaime(at)2ndquadrant(dot)com>,
pgsql-hackers(at)postgresql(dot)org
Subject: Re: time-delayed standbys
References: <BANLkTi==TTzHDqWzwJDjmOf__8YuA7L1jw(at)mail(dot)gmail(dot)com> <BANLkTikHcD8H=iS=xZCTnyNAYMbDu3Tj1Q(at)mail(dot)gmail(dot)com> <BANLkTinfrgsVK_8o9+mw6kWRcC4BxiR4jw(at)mail(dot)gmail(dot)com> <BANLkTimDUswEE5nAjr31DQ=6GxRPU758kQ(at)mail(dot)gmail(dot)com>
In-Reply-To: <BANLkTimDUswEE5nAjr31DQ=6GxRPU758kQ(at)mail(dot)gmail(dot)com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Virus-Scanned: Maia Mailguard 1.0.1
X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9
X-Spam-Level:
X-Archive-Number: 201105/623
X-Sequence-Number: 187657

On 11.05.2011 08:29, Fujii Masao wrote:
> On Sat, May 7, 2011 at 10:48 PM, Robert Haas<robertmhaas(at)gmail(dot)com> wrote:
>> I was able to reproduce something very like this in unpatched master,
>> just by letting recovery pause at a named restore point, and then
>> resuming it.
>
> I was able to reproduce the same problem even in 9.0. When the standby
> reaches the recovery target, it always tries to end the recovery even
> though walreceiver is still running, which causes the problem. This seems
> to be an oversight in streaming replication. I should have considered how
> the standby should work when recovery_target is specified.
>
> What about the attached patch? Which stops walreceiver instead of
> emitting PANIC there only if we've reached the recovery target.

I think we can just always call ShutdownWalRcv(). It should be gone if
the server was promoted while streaming, but that's just an
implementation detail of what the promotion code does. There's no hard
reason why it shouldn't be running at that point anymore, as long as we
kill it before going any further.

Committed a patch to do that.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

Attachment Content-Type Size
unknown_filename text/html 8.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Szymon Guz 2011-05-11 09:30:51 Re: potential bug in trigger with boolean params
Previous Message Andres Freund 2011-05-11 09:29:07 Re: potential bug in trigger with boolean params