From corochoone@gmail.com Tue Jun 2 11:28:29 2026 Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 98B6963335A for ; Sun, 4 Apr 2010 10:01:40 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 36363-01 for ; Sun, 4 Apr 2010 13:01:29 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-gx0-f214.google.com (mail-gx0-f214.google.com [209.85.217.214]) by mail.postgresql.org (Postfix) with ESMTP id 0C497632CB8 for ; Sun, 4 Apr 2010 10:01:29 -0300 (ADT) Received: by gxk6 with SMTP id 6so3651184gxk.14 for ; Sun, 04 Apr 2010 06:01:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:received:message-id :subject:from:to:content-type; bh=mmVNcbFEm7Uh9SqPG2duh05IOkG2TIOYcENB7EhqP3k=; b=q3y74DIcRhMGu780XXHpn1AKP0PHLH6pYviNl1WkcZTVuPQ4MHczrliERkvhNjt6j1 JfNjcNKoYjO4bdLVsVKRbUaDyl8pYBVyxZOkZNh4h84Y2IxmqhPIYp2y8sJQneQuARz8 2Sb2dGpwyalx6vmBo+qDj0hvAalQaSTsc6EiM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=KZdyVX0dXwFvcjoYIxUYArI+aCbwHDxZkqFgLhSBeFq3hFSnON3Txc5iKeTc29dqJf aFe5WrJOK85hj3VjKDSsQ2O4IEApCcqXLkBGTUAQNo04iFmWxmSTJO73tGTmc4E5jMKt 4XtZGGAuae+IEImGIg2S3D6LkI8UaMKldlTNU= MIME-Version: 1.0 Received: by 10.100.34.12 with HTTP; Sun, 4 Apr 2010 06:01:28 -0700 (PDT) Date: Sun, 4 Apr 2010 17:01:28 +0400 Received: by 10.101.78.16 with SMTP id f16mr11072099anl.17.1270386088145; Sun, 04 Apr 2010 06:01:28 -0700 (PDT) Message-ID: Subject: Undocumented trick in SELECT? From: =?KOI8-R?B?98nL1M/SIPfJ08zPws/Lz9c=?= To: PostgreSQL-documentation Content-Type: multipart/alternative; boundary=001636ed6b1d82f251048368cf92 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.739 tagged_above=-10 required=5 tests=BAYES_20=-0.74, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 201004/24 X-Sequence-Number: 5423 --001636ed6b1d82f251048368cf92 Content-Type: text/plain; charset=ISO-8859-1 I'm sorry, but I have not found such construction into documentation: SELECT tablename FROM tablename; http://www.postgresql.org/docs/8.4/static/queries-overview.html say: [WITH with_queries] SELECT select_list FROM table_expression [sort_specification] http://www.postgresql.org/docs/8.4/static/queries-select-lists.html say: "The select list determines which columns of the intermediate table are actually output." But, table name is not a column. Reproduce: tmp=# create table tmp(id SERIAL, name VARCHAR(10)); NOTICE: CREATE TABLE will create implicit sequence "tmp_id_seq" for serial column "tmp.id" CREATE TABLE tmp=# insert into tmp (name) values('John'); INSERT 0 1 tmp=# insert into tmp (name) values('Pol'); INSERT 0 1 tmp=# insert into tmp (name) values('Martin'); INSERT 0 1 tmp=# select tmp from tmp; tmp ------------ (1,John) (2,Pol) (3,Martin) (3 rows) What is this? Is this undocumented or am I bad looked in the documentation? With best wishes, Victor Vislobokov St.Peterburg. Russia --001636ed6b1d82f251048368cf92 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I'm sorry, but I have not found such construction into documentation:
SELECT tablename FROM tablename;

http://www.postgresql.org/docs/8.4/static/queries-overview.html
say:

[WITH with_queries] SELECT select_list F= ROM table_expression [sort_specification]

say:
"The select list determines which columns of the i= ntermediate table are actually output."

But, = table name is not a column.

Reproduce:

tmp=3D# create table tmp(id SERIAL, name VARCHAR(10));<= /div>
NOTICE: =A0CREATE TABLE will create implicit sequence "tmp_i= d_seq" for serial column "tmp.id&qu= ot;
CREATE TABLE
tmp=3D# insert into tmp (name) values('John= ');
INSERT 0 1
tmp=3D# insert into tmp (name) value= s('Pol');
INSERT 0 1
tmp=3D# insert into tmp (n= ame) values('Martin');
INSERT 0 1
tmp=3D# select tmp from tmp;
=A0=A0 =A0= tmp =A0 =A0=A0
------------
=A0(1,John)
=A0(2= ,Pol)
=A0(3,Martin)
(3 rows)

=
What is this? Is =A0this undocumented or am I bad looked in the docume= ntation?

With best wishes,
Victor Vislobokov
St.Peterburg. Russia

--001636ed6b1d82f251048368cf92-- From tgl@sss.pgh.pa.us Tue Jun 2 11:28:29 2026 Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 569B0632588 for ; Sun, 4 Apr 2010 13:26:30 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 99682-04 for ; Sun, 4 Apr 2010 16:26:19 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id C12B86324CD for ; Sun, 4 Apr 2010 13:26:19 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o34GQHFH012679; Sun, 4 Apr 2010 12:26:18 -0400 (EDT) To: =?KOI8-R?B?98nL1M/SIPfJ08zPws/Lz9c=?= cc: PostgreSQL-documentation Subject: Re: Undocumented trick in SELECT? In-reply-to: References: Comments: In-reply-to =?KOI8-R?B?98nL1M/SIPfJ08zPws/Lz9c=?= message dated "Sun, 04 Apr 2010 17:01:28 +0400" Date: Sun, 04 Apr 2010 12:26:17 -0400 Message-ID: <12678.1270398377@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201004/25 X-Sequence-Number: 5424 =?KOI8-R?B?98nL1M/SIPfJ08zPws/Lz9c=?= writes: > I'm sorry, but I have not found such construction into documentation: > SELECT tablename FROM tablename; It's a whole-row variable. These aren't terribly well documented but you can find descriptions of them in places. It's not standard SQL --- I think we inherited it from PostQUEL and kept it because functions on composite types don't work very well without composite variables. regards, tom lane