Re: Re: BUG #8633: Assigning to a variable named "current_time" gives wrong output

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: David Johnston <polobo(at)yahoo(dot)com>
Cc: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Re: BUG #8633: Assigning to a variable named "current_time" gives wrong output
Date: 2013-11-28 11:46:45
Message-ID: CAFj8pRCwXmdjtqEiPjG3JixN52UVx2+GW-rXTpsWPELk9CXHKA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

2013/11/27 David Johnston <polobo(at)yahoo(dot)com>

> Tom Lane-2 wrote
> > David Johnston <
>
> > polobo@
>
> > > writes:
> >> bricklen wrote
> >>> I don't think this is a bug, "current_time" is a reserved word. See
> >>>
> http://www.postgresql.org/docs/current/static/sql-keywords-appendix.html
> >
> >> Agreed; though I am curious why this does not throw an error during the
> >> declaration or assignment. A spurious parser error would be welcomed
> >> compared to silently ignoring the requested action.
> >
> > Well, it's not "ignoring the action", it's just that the keyword meaning
> > now takes precedence in expressions. We changed that in 9.0 I believe.
> >
> > We could possibly throw an error if you use a SQL reserved word in a
> > declaration without double-quoting it. That wouldn't be a complete fix,
> > because if you did that and then forgot to double-quote the name in
> > expressions, it'd still do the wrong thing. But this might at least
> > help you remember you need to do that.
> >
> > I think though that at one time it was considered a feature that we
> > didn't insist on double-quoting plpgsql variable names unnecessarily.
> > Don't know if changing this would be a net improvement for everyone.
>
> If we had done this when all of the other pl/pgsql variable-name changes
> were put in place that would have been nice but to do it stand-alone
> definitely has a higher hurdle to clear.
>
> At this point I'd rather leave this to a linter / static-analyzer rather
> than affect existing code unconditionally.
>

this tool exists https://github.com/okbob/plpgsql_lint and should be
enhanced for your issue

Regards

Pavel

>
> David J.
>
>
>
>
> --
> View this message in context:
> http://postgresql.1045698.n5.nabble.com/BUG-8633-Assigning-to-a-variable-named-current-time-gives-wrong-output-tp5780601p5780626.html
> Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.
>
>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
>

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2013-11-28 16:10:12 Re: BUG #8632: file "pg_subtrans/CEC0" doesn't exist, reading as zeroes
Previous Message Alvaro Herrera 2013-11-28 11:22:17 Re: BUG #8434: Why does dead lock occur many times ?