Search Postgresql Archives

Unexpected result from selecting an aliased but non-existing column called "name"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

I was wondering where some spurious information in a query was
coming from - it looked like something was inserting all the
values of a table row as a comma-separated list.

It turns out I was attempting to reference a non-existent column
called (literally) "name", which instead of throwing an error produces
the aforementioned list. This only seems to happen with "name", and
only if it is referenced with the table name or alias.


To reproduce:

  test=> CREATE table xx(id int, val text);
  CREATE TABLE
  test=> INSERT INTO xx values(1,'hello world');
  INSERT 0 1
  test=> SELECT name FROM xx;
  ERROR:  column "name" does not exist
  LINE 1: SELECT name FROM xx;

  test=> SELECT xx.name from xx;
         name
  -------------------
   (1,"hello world")
  (1 row)

  test=> SELECT xx.foobar FROM xx;
  ERROR:  column xx.foobar does not exist
  LINE 1: SELECT xx.foobar FROM xx;


Reproducible on 8.4.1 and 8.4.2; does not work in 8.3.1
(old test version I happen to have hanging around).


Questions:
- is this a feature?
- and if so, where is it documented?
  (given that the key word in this is "name", this is a tricky one
   to research).


Thanks for any pointers.


Ian Barwick

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux