Re: Why do OLD and NEW have special internal names?

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Why do OLD and NEW have special internal names?
Date: 2009-11-06 01:03:25
Message-ID: 603c8f070911051703m7593c301md64523dbde717365@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Nov 5, 2009 at 4:33 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> So I was testing the next step of plpgsql modification, namely actually
> letting the parser hooks do something, and it promptly blew up in
> trigger functions, like so:
>
> + ERROR:  OLD used in query that is not in a rule
> + LINE 1: SELECT  OLD
> +                 ^
> + QUERY:  SELECT  OLD
> + CONTEXT:  SQL statement in PL/PgSQL function "trigger_data" near line 35
>
> The reason is that because plpgsql is no longer translating references
> to its names into Params before letting the core parser see them, the
> kluge in gram.y that changes "OLD" to "*OLD*" and "NEW" to "*NEW*"
> kicks in, or actually decides to throw an error instead of kicking in.
>
> I am wondering what is the point at all of having that kluge.  It
> certainly doesn't manage to make OLD/NEW not act like reserved words,
> in fact rather more the opposite, as shown here.  If we just made those
> names be ordinary table alias names in rule queries, wouldn't things
> work as well or better?
>
> BTW, this brings up another point, which is that up to now it's often
> been possible to use plpgsql variable names that conflict with
> core-parser reserved words, so long as you didn't need to use the
> reserved word with its special meaning.  That will stop working when
> this patch goes in.  Doesn't bother me any, but if anyone thinks it's
> a serious problem, speak now.

Any keyword or just fully reserved keywords?

...Robert

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2009-11-06 01:10:19 Re: AFTER triggers & RETURN
Previous Message Itagaki Takahiro 2009-11-06 00:19:35 Re: Typed tables