Vitals:

Postgres 9.6 on Windows 7

by way of NpgSql C# library (v4.0.30319)



DOC BUG:
I'm curious if PostgreSQL's own special columns should be included on the 
"Reserved Words" list.  This might be obvious to those familiar with the inner 
working of Postgres, for us that are more application level developers this may 
not be as obvious..  Easy to know the core sql tokens are reserved such as 
"select, min, like, from, and others..." are all reserved.  The issue was 
encountered when trying to create a table with cmax as a column name.   
Following the instructions on filing bugs I searched the main site and 
eventually found it is documented but not clearly.  Found that cmax is a system 
column reserved by Postgres.  At first when i got the error specifically this 
one:


Npgsql.PostgresException (0x80004005): 42701: column name "cmax" conflicts with 
a system column name

My first step was to google "Postgres Reserved Words"   will eventually get you 
to Appendix C in the doc but not mention about any system columns, url for help 
page:

<https://www.postgresql.org/docs/9.6/static/sql-keywords-appendix.html>https://www.postgresql.org/docs/9.6/static/sql-keywords-appendix.html

title on page shows (This page in other versions: 
9.2<https://www.postgresql.org/docs/9.2/static/ddl-system-columns.html> / 
9.3<https://www.postgresql.org/docs/9.3/static/ddl-system-columns.html> / 
9.4<https://www.postgresql.org/docs/9.4/static/ddl-system-columns.html> / 
9.5<https://www.postgresql.org/docs/9.5/static/ddl-system-columns.html> / 
current (9.6) )

It wasn't until i looked at the process to open a bug, did it get to the main 
Postgres site and searched for cmax.  Searching on the Postgres site, bingo, I 
found cmax instead is a system column.  So it seems at first to be a 
documentation bug that Postgres's own reserved column names are not put in the 
"Reserved Words" list.


Change Request:


Got me thinking what the convention use to be in C starting out 30 years ago, 
should work good in Postgres as well?  Most all C compilers would prefix 
variables or items within system  struct that were considered system/reserved 
with an underscores or two.  This worked great before C++ which brought classes 
and namespaces to assist in scoping.  This practice worked well to prevent name 
collisions between users code the compiler itself should work nicely in 
Postgres too.  Finally if this convention is adapted there could be one generic 
note in the docs saying "User columns should never being with an underscore."  
This convention worked well for C before C++ exists, should work good for 
Postgres too?

Thanks for your consideration.

dan d:)

Reply via email to