Re: 7.0b3 pl/pgsql, ERROR: CURRENT used in non-rule query

Started by Bruce Momjianalmost 26 years ago1 messageshackers
Jump to latest
#1Bruce Momjian
bruce@momjian.us

Ed Loehr <eloehr@austin.rr.com> writes:

20000407.15:56:50.404 [8388] query: INSERT INTO time_report ( person_id,
... ) SELECT old.person_id, ... newAct.activity_id, ... FROM time_report
old, activity oldAct, activity newAct WHERE oldAct.contract_id = $1 AND
newAct.contract_id = $2 AND newAct.ref_number = oldAct.ref_number
20000407.15:56:50.404 [8388] ERROR: CURRENT used in non-rule query

I see my error: "old" is reserved for triggered functions...the error
message about "CURRENT" is a bit misleading, even so.

Oh ... that's a hoot. The code thinks that the keyword is CURRENT.
Someone apparently changed their minds at some point about the spelling
of the keyword, and implemented the change by modifying the entry in
keywords.c and nowhere else!

{"of", OF},
{"offset", OFFSET},
{"oids", OIDS},
{"old", CURRENT}, <====================== blech
{"on", ON},
{"only", ONLY},

This leads to such interesting misbehaviors as

regression=# select 'old' as old, 'older' as older;
current | older
---------+-------
old | older
(1 row)

(what was that column label again?)

This isn't a showstopper kind of bug, but it probably oughta be fixed.

OK, I have made the required internal changes. However, to enable older
rules to be loaded, I had to map CURRENT to OLD, so we still have this
weird behavior, it is just now on CURRENT instead of OLD. We can remove
that hack in a few releases. Comment has been added to keyword.c just
above the entry.

The error message will also print correctly now.

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026