pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedPL/pgSQL evaluation order
2+ messages / 1 participants
[nested] [flat]
* PL/pgSQL evaluation order
@ 2000-08-03 15:30 Mark Volpe <volpe.mark@epamail.epa.gov>
0 siblings, 0 replies; 2+ messages in thread
From: Mark Volpe @ 2000-08-03 15:30 UTC (permalink / raw)
To: pgsql-sql
Hi,
I have trigger function with the statement:
IF TG_OP=''INSERT'' OR NEW.ip!=OLD.ip THEN
expecting the TG_OP=''INSERT'' to be evaluated
first, and if true, proceed with the body.
But it gets evaluated as the result of an INSERT
statement, I get a (rather strangly worded) error:
ERROR: record old is unassigned yet
which means that the second statement is still being
evaluated even though the first is true. Assuming
that this is the result of the parser/planner messing
with that statement, is there a way to force evaluation
order without having to go:
IF TG_OP=''INSERT'' THEN
<body>
ELSE
IF NEW.OP!=OLD.ip THEN
<repeat body>
END IF;
END IF;
Thanks,
Mark
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: PL/pgSQL evaluation order
@ 2000-08-03 21:52 Mark Volpe <volpe.mark@epamail.epa.gov>
0 siblings, 0 replies; 2+ messages in thread
From: Mark Volpe @ 2000-08-03 21:52 UTC (permalink / raw)
To: Jan Wieck <janwieck@Yahoo.com>; +Cc: pgsql-sql
Doesn't seem like a bad idea. I did find a better workaround, though -
cond:=TG_OP=''INSERT'';
IF cond=FALSE THEN
cond:=NEW.ip!=OLD.ip;
END IF;
IF cond=TRUE ...
so it won't kill me. Anyway, I've been totally impressed with the 7.0 release.
I'm building the EPA IP address registration system on top of it. My favorite
feature is the support for REFERENCES (though I had to hack the code a bit to
get around a permissions problem).
Thanks,
Mark
Jan Wieck wrote:
>
> Maybe we should change the treatment of unassigned rowtype
> values that any reference to it holds the NULL value?
>
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2000-08-03 21:52 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-08-03 15:30 PL/pgSQL evaluation order Mark Volpe <volpe.mark@epamail.epa.gov>
2000-08-03 21:52 Re: PL/pgSQL evaluation order Mark Volpe <volpe.mark@epamail.epa.gov>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox