public inbox for [email protected]  
help / color / mirror / Atom feed
Reserved word "date" in tutorial example
2+ messages / 2 participants
[nested] [flat]

* Reserved word "date" in tutorial example
@ 2013-05-21 14:19 Greg Smith <[email protected]>
  2014-01-11 18:27 ` Re: Reserved word "date" in tutorial example Bruce Momjian <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Greg Smith @ 2013-05-21 14:19 UTC (permalink / raw)
  To: pgsql-docs

doc/src/sgml/query.sgml includes a tutorial example with this definition:

CREATE TABLE weather (
...
     date            date
);

The fact that "date" is used for both the column name and the type is 
highlighted by two later comments:

   (Yes, the column of type date is also named date.  This might be 
convenient or confusing--you choose.)

   type names are not key words in the syntax, except where required to 
support special cases in the SQL standard.

But as a documentation comment submitted recently points out, "date" 
*is* a reserved word in the SQL spec: 
http://www.postgresql.org/docs/current/interactive/sql-keywords-appendix.html 
, just not in PostgreSQL.  That makes using it as a column name in an 
example an odd choice for a tutorial.  The example is using the 
ambiguity to point out where the line between what is and isn't legal is 
at, and maybe that's a feature instead of a bug.

There are a few approaches that could improve on this:

-Keep all of that, but expand the description to link to "SQL Key 
Words"--right now "SQL standard" doesn't go to that section--and say 
this might be a reserved word in other SQL implementations.  This is the 
smallest useful improvement.

-Change the name of the column and remove the two related descriptions.  
This will lose the lesson about where the parser's line is at.

-Do both:  move this example of parser trivia somewhere else, but remove 
it from the tutorial material by using a non-reserved column name there.

-- 
Greg Smith   2ndQuadrant US    [email protected]   Baltimore, MD
PostgreSQL Training, Services, and 24x7 Support www.2ndQuadrant.com




-- 
Sent via pgsql-docs mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs



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

* Re: Reserved word "date" in tutorial example
  2013-05-21 14:19 Reserved word "date" in tutorial example Greg Smith <[email protected]>
@ 2014-01-11 18:27 ` Bruce Momjian <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Bruce Momjian @ 2014-01-11 18:27 UTC (permalink / raw)
  To: Greg Smith <[email protected]>; +Cc: pgsql-docs

On Tue, May 21, 2013 at 10:19:45AM -0400, Greg Smith wrote:
> doc/src/sgml/query.sgml includes a tutorial example with this definition:
> 
> CREATE TABLE weather (
> ...
>     date            date
> );
> 
> The fact that "date" is used for both the column name and the type
> is highlighted by two later comments:
> 
>   (Yes, the column of type date is also named date.  This might be
> convenient or confusing--you choose.)
> 
>   type names are not key words in the syntax, except where required
> to support special cases in the SQL standard.
> 
> But as a documentation comment submitted recently points out, "date"
> *is* a reserved word in the SQL spec: http://www.postgresql.org/docs/current/interactive/sql-keywords-appendix.html
> , just not in PostgreSQL.  That makes using it as a column name in
> an example an odd choice for a tutorial.  The example is using the
> ambiguity to point out where the line between what is and isn't
> legal is at, and maybe that's a feature instead of a bug.
> 
> There are a few approaches that could improve on this:
> 
> -Keep all of that, but expand the description to link to "SQL Key
> Words"--right now "SQL standard" doesn't go to that section--and say
> this might be a reserved word in other SQL implementations.  This is
> the smallest useful improvement.
> 
> -Change the name of the column and remove the two related
> descriptions.  This will lose the lesson about where the parser's
> line is at.
> 
> -Do both:  move this example of parser trivia somewhere else, but
> remove it from the tutorial material by using a non-reserved column
> name there.

I reviewed this report and I can't see adding details to a tutorial
about the fact that other databases might use "date" as a reserved word.
I also can't see that renaming the field really add much.

-- 
  Bruce Momjian  <[email protected]>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + Everyone has their own god. +


-- 
Sent via pgsql-docs mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs




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


end of thread, other threads:[~2014-01-11 18:27 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-05-21 14:19 Reserved word "date" in tutorial example Greg Smith <[email protected]>
2014-01-11 18:27 ` Bruce Momjian <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox