pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedAssignments in PL/pgSQL
5+ messages / 4 participants
[nested] [flat]
* Assignments in PL/pgSQL
@ 2002-09-13 10:43 Michael Paesold <mpaesold@gmx.at>
2002-09-13 17:51 ` Re: Assignments in PL/pgSQL Josh Berkus <josh@agliodbs.com>
0 siblings, 1 reply; 5+ messages in thread
From: Michael Paesold @ 2002-09-13 10:43 UTC (permalink / raw)
To: pgsql-sql
Hi all,
although this is not really SQL, but PL/pgSQL, I hope this is the right
place to ask.
I have written a complex triggers. It works very well. Just now I have
realized that I have used the = operater for variable assignments, instead
of the := operater. To my suprise, there was no error or warning, and the
store procedure works very well!
e.g.
NEW.someval = rec.someother;
works as well as
NEW.someval := rec.someother;
Can you confirm that both are valid? Can someone explain this?
And is it safe to use the former syntax?
Best Regards,
Michael Paesold
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Assignments in PL/pgSQL
2002-09-13 10:43 Assignments in PL/pgSQL Michael Paesold <mpaesold@gmx.at>
@ 2002-09-13 17:51 ` Josh Berkus <josh@agliodbs.com>
2002-09-13 18:04 ` Re: Assignments in PL/pgSQL Jan Wieck <JanWieck@Yahoo.com>
2002-09-13 18:04 ` Re: Assignments in PL/pgSQL Joe Conway <mail@joeconway.com>
0 siblings, 2 replies; 5+ messages in thread
From: Josh Berkus @ 2002-09-13 17:51 UTC (permalink / raw)
To: Michael Paesold <mpaesold@gmx.at>; pgsql-sql
Michael,
> although this is not really SQL, but PL/pgSQL, I hope this is the right
> place to ask.
This is the right place.
> I have written a complex triggers. It works very well. Just now I have
> realized that I have used the = operater for variable assignments, instead
> of the := operater. To my suprise, there was no error or warning, and the
> store procedure works very well!
>
> e.g.
> NEW.someval = rec.someother;
> works as well as
> NEW.someval := rec.someother;
>
> Can you confirm that both are valid? Can someone explain this?
> And is it safe to use the former syntax?
I'm very surprised, too. The "=" syntax is not per spec; my guess is,
somebody coded in compatibility for DB conversion purposes and left it there.
Jan? Tom?
--
-Josh Berkus
Aglio Database Solutions
San Francisco
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Assignments in PL/pgSQL
2002-09-13 10:43 Assignments in PL/pgSQL Michael Paesold <mpaesold@gmx.at>
2002-09-13 17:51 ` Re: Assignments in PL/pgSQL Josh Berkus <josh@agliodbs.com>
@ 2002-09-13 18:04 ` Jan Wieck <JanWieck@Yahoo.com>
2002-09-13 18:10 ` Re: Assignments in PL/pgSQL Josh Berkus <josh@agliodbs.com>
1 sibling, 1 reply; 5+ messages in thread
From: Jan Wieck @ 2002-09-13 18:04 UTC (permalink / raw)
To: josh@agliodbs.com; +Cc: Michael Paesold <mpaesold@gmx.at>; pgsql-sql
Josh Berkus wrote:
>
> Michael,
>
> > although this is not really SQL, but PL/pgSQL, I hope this is the right
> > place to ask.
>
> This is the right place.
>
> > I have written a complex triggers. It works very well. Just now I have
> > realized that I have used the = operater for variable assignments, instead
> > of the := operater. To my suprise, there was no error or warning, and the
> > store procedure works very well!
> >
> > e.g.
> > NEW.someval = rec.someother;
> > works as well as
> > NEW.someval := rec.someother;
> >
> > Can you confirm that both are valid? Can someone explain this?
> > And is it safe to use the former syntax?
>
> I'm very surprised, too. The "=" syntax is not per spec; my guess is,
> somebody coded in compatibility for DB conversion purposes and left it there.
> Jan? Tom?
Er ... I don't recall completely, maybe it was more compatibility
to my own lazyness ;-/ (typing a colon means Shift-and-semicolon
... that's 2 saved keystrokes per assignment ... what do you
think where I save all the keystrokes I need to write email like
this?).
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being
right. #
# Let's break this rule - forgive
me. #
#==================================================
JanWieck@Yahoo.com #
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Assignments in PL/pgSQL
2002-09-13 10:43 Assignments in PL/pgSQL Michael Paesold <mpaesold@gmx.at>
2002-09-13 17:51 ` Re: Assignments in PL/pgSQL Josh Berkus <josh@agliodbs.com>
2002-09-13 18:04 ` Re: Assignments in PL/pgSQL Jan Wieck <JanWieck@Yahoo.com>
@ 2002-09-13 18:10 ` Josh Berkus <josh@agliodbs.com>
0 siblings, 0 replies; 5+ messages in thread
From: Josh Berkus @ 2002-09-13 18:10 UTC (permalink / raw)
To: Jan Wieck <JanWieck@Yahoo.com>; pgsql-sql
Jan,
> Er ... I don't recall completely, maybe it was more compatibility
> to my own lazyness ;-/ (typing a colon means Shift-and-semicolon
> ... that's 2 saved keystrokes per assignment ... what do you
> think where I save all the keystrokes I need to write email like
> this?).
Hmmm. Well, as long as it doesn't cause any problems, why not keep it?
Surely if it caused bugs, we'd have heard by now.
--
-Josh Berkus
Aglio Database Solutions
San Francisco
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Assignments in PL/pgSQL
2002-09-13 10:43 Assignments in PL/pgSQL Michael Paesold <mpaesold@gmx.at>
2002-09-13 17:51 ` Re: Assignments in PL/pgSQL Josh Berkus <josh@agliodbs.com>
@ 2002-09-13 18:04 ` Joe Conway <mail@joeconway.com>
1 sibling, 0 replies; 5+ messages in thread
From: Joe Conway @ 2002-09-13 18:04 UTC (permalink / raw)
To: josh@agliodbs.com; +Cc: Michael Paesold <mpaesold@gmx.at>; pgsql-sql
Josh Berkus wrote:
> I'm very surprised, too. The "=" syntax is not per spec; my guess is,
> somebody coded in compatibility for DB conversion purposes and left it there.
> Jan? Tom?
>
I also noticed this the other day while messing with the plpgsql lexer:
/* ----------
* The keyword rules
* ----------
*/
:= { return K_ASSIGN; }
= { return K_ASSIGN; }
This code goes back to the original scan.l from 1998. I'm guessing it has
always worked, but was never documented -- but I've been known to be wrong
sometimes ;-). Hopefully Jan will chime in.
Joe
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2002-09-13 18:10 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-09-13 10:43 Assignments in PL/pgSQL Michael Paesold <mpaesold@gmx.at>
2002-09-13 17:51 ` Josh Berkus <josh@agliodbs.com>
2002-09-13 18:04 ` Jan Wieck <JanWieck@Yahoo.com>
2002-09-13 18:10 ` Josh Berkus <josh@agliodbs.com>
2002-09-13 18:04 ` Joe Conway <mail@joeconway.com>
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