pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dean Gibson (DB Administrator) <postgresql@ultimeth.com>
To: pgsql-sql@postgresql.org
Subject: SQL gotcha
Date: Mon, 14 Feb 2011 15:29:25 -0800
Message-ID: <4D59BAD5.4090306@ultimeth.com> (raw)

As you all know, when you specify an alias for a table or column name, 
the keyword "AS" is usually optional.  I personally like to always 
include the "AS" keyword, if for no other reason than readability, and I 
presume that always using "AS" might catch some syntactic errors as well.

However, recently I ran across a statement where the optionality of the 
"AS" keyword caused me some grief:

    SELECT ... FROM aaa LEFFT JOIN bbb WHERE ...

Note the (unintentional) misspelling of the keyword "LEFT".  PostgreSQL 
took "LEFFT" to be an alias for table "aaa" and silently accepted the 
statement;  naturally I did not get the results I expected !!

If PostgreSQL had an option to always require the "AS", that would have 
caught this error.  Is there any interest in PostgreSQL having any 
"pedantic"-type options, like many C/C++ compilers do?

-- 
Mail to my list address MUST be sent via the mailing list.
All other mail to my list address will bounce.

view thread (2+ messages)  latest in thread

Message-ID: <4D59BAD5.4090306@ultimeth.com>
Permalink:  ../4D59BAD5.4090306@ultimeth.com/
Also on:    postgresql.org/message-id/4D59BAD5.4090306@ultimeth.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: postgresql@ultimeth.com
  Subject: Re: SQL gotcha
  In-Reply-To: <4D59BAD5.4090306@ultimeth.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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