pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
info is a reserved word?
5+ messages / 3 participants
[nested] [flat]

* info is a reserved word?
@ 2006-01-13 01:14 John DeSoi <desoi@pgedit.com>
  2006-01-13 01:29 ` Re: info is a reserved word? Michael Fuhr <mike@fuhr.org>
  0 siblings, 1 reply; 5+ messages in thread

From: John DeSoi @ 2006-01-13 01:14 UTC (permalink / raw)
  To: pgsql-sql

I have two identical functions below, the only difference is I  
declared my variable name to be 'info' instead of 'stuff'. I could  
not find anywhere in the docs that 'info' has any special meaning.  
Did I miss it?

create type my_info as (
	a text,
	b text
);


-- this works
create or replace function my_stuff ()
returns my_info as $$
declare
	stuff my_info;
begin
	stuff.a := 'hi';
	stuff.b := 'there';
	return stuff;
end;
$$ language plpgsql;


create or replace function my_stuff ()
returns my_info as $$
declare
	info my_info;
begin
	info.a := 'hi';
	info.b := 'there';
	return info;
end;
$$ language plpgsql;

Evaluating this definition gives:

psql:16: ERROR:  syntax error at or near "info" at character 71
psql:16: LINE 4:  info my_info;
psql:16:          ^

pg 8.1.1, OS X 10.4.3



John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: info is a reserved word?
  2006-01-13 01:14 info is a reserved word? John DeSoi <desoi@pgedit.com>
@ 2006-01-13 01:29 ` Michael Fuhr <mike@fuhr.org>
  2006-01-13 04:21   ` Re: info is a reserved word? Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 5+ messages in thread

From: Michael Fuhr @ 2006-01-13 01:29 UTC (permalink / raw)
  To: John DeSoi <desoi@pgedit.com>; +Cc: pgsql-sql

On Thu, Jan 12, 2006 at 08:14:42PM -0500, John DeSoi wrote:
> I have two identical functions below, the only difference is I  
> declared my variable name to be 'info' instead of 'stuff'. I could  
> not find anywhere in the docs that 'info' has any special meaning.  

'info' only seems special in PL/pgSQL, presumably because it's one
of the possible RAISE levels.  You should also get an error if you
try 'exception', 'warning', etc.

-- 
Michael Fuhr



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: info is a reserved word?
  2006-01-13 01:14 info is a reserved word? John DeSoi <desoi@pgedit.com>
  2006-01-13 01:29 ` Re: info is a reserved word? Michael Fuhr <mike@fuhr.org>
@ 2006-01-13 04:21   ` Tom Lane <tgl@sss.pgh.pa.us>
  2006-01-13 04:57     ` Re: info is a reserved word? Michael Fuhr <mike@fuhr.org>
  0 siblings, 1 reply; 5+ messages in thread

From: Tom Lane @ 2006-01-13 04:21 UTC (permalink / raw)
  To: Michael Fuhr <mike@fuhr.org>; +Cc: John DeSoi <desoi@pgedit.com>; pgsql-sql

Michael Fuhr <mike@fuhr.org> writes:
> 'info' only seems special in PL/pgSQL, presumably because it's one
> of the possible RAISE levels.  You should also get an error if you
> try 'exception', 'warning', etc.

plpgsql is not very good about reserving words "minimally", ie, not
treating a word as a keyword outside the context where the keyword
is meaningful.

This could probably be fixed, or at least greatly reduced, with some
flex/bison hacking.  Anyone up for it?

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: info is a reserved word?
  2006-01-13 01:14 info is a reserved word? John DeSoi <desoi@pgedit.com>
  2006-01-13 01:29 ` Re: info is a reserved word? Michael Fuhr <mike@fuhr.org>
  2006-01-13 04:21   ` Re: info is a reserved word? Tom Lane <tgl@sss.pgh.pa.us>
@ 2006-01-13 04:57     ` Michael Fuhr <mike@fuhr.org>
  2006-01-13 05:10       ` Re: [SQL] info is a reserved word? Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 5+ messages in thread

From: Michael Fuhr @ 2006-01-13 04:57 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: John DeSoi <desoi@pgedit.com>; pgsql-sql

On Thu, Jan 12, 2006 at 11:21:28PM -0500, Tom Lane wrote:
> plpgsql is not very good about reserving words "minimally", ie, not
> treating a word as a keyword outside the context where the keyword
> is meaningful.
> 
> This could probably be fixed, or at least greatly reduced, with some
> flex/bison hacking.  Anyone up for it?

Possibly.  Would it involve much more than what the main parser's
grammar does with unreserved_keyword and friends?  I suppose this
ought to move to pgsql-hackers.

-- 
Michael Fuhr



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: [SQL] info is a reserved word?
  2006-01-13 01:14 info is a reserved word? John DeSoi <desoi@pgedit.com>
  2006-01-13 01:29 ` Re: info is a reserved word? Michael Fuhr <mike@fuhr.org>
  2006-01-13 04:21   ` Re: info is a reserved word? Tom Lane <tgl@sss.pgh.pa.us>
  2006-01-13 04:57     ` Re: info is a reserved word? Michael Fuhr <mike@fuhr.org>
@ 2006-01-13 05:10       ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2006-01-13 05:10 UTC (permalink / raw)
  To: Michael Fuhr <mike@fuhr.org>; +Cc: John DeSoi <desoi@pgedit.com>; pgsql-hackers@postgreSQL.org

[ moved to -hackers ]

Michael Fuhr <mike@fuhr.org> writes:
> On Thu, Jan 12, 2006 at 11:21:28PM -0500, Tom Lane wrote:
>> plpgsql is not very good about reserving words "minimally", ie, not
>> treating a word as a keyword outside the context where the keyword
>> is meaningful.
>> 
>> This could probably be fixed, or at least greatly reduced, with some
>> flex/bison hacking.  Anyone up for it?

> Possibly.  Would it involve much more than what the main parser's
> grammar does with unreserved_keyword and friends?  I suppose this
> ought to move to pgsql-hackers.

The keyword-classification tactic would be one approach.  For the
specific case of the RAISE severity codes, I'd be inclined to eliminate
all those "keywords" entirely and let them be lexed/parsed as simple
identifiers --- there's no strong reason not to do strcmp's for specific
identifiers at the point where we're building a raise_level value.
There are probably some other methods that might apply in other places.
But in any case it's a fairly self-contained problem; you don't need
any vast knowledge of Postgres internals to tackle it, just some
understanding of the flex and bison tools.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2006-01-13 05:10 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-01-13 01:14 info is a reserved word? John DeSoi <desoi@pgedit.com>
2006-01-13 01:29 ` Michael Fuhr <mike@fuhr.org>
2006-01-13 04:21   ` Tom Lane <tgl@sss.pgh.pa.us>
2006-01-13 04:57     ` Michael Fuhr <mike@fuhr.org>
2006-01-13 05:10       ` Tom Lane <tgl@sss.pgh.pa.us>

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