Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XA1Oc-0005ku-NB for pgsql-bugs@arkaria.postgresql.org; Wed, 23 Jul 2014 18:36:10 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XA1Oc-0004zi-5W for pgsql-bugs@arkaria.postgresql.org; Wed, 23 Jul 2014 18:36:10 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XA1Ob-0004za-3l for pgsql-bugs@postgresql.org; Wed, 23 Jul 2014 18:36:09 +0000 Received: from sam.nabble.com ([216.139.236.26]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1XA1OX-0007tS-HQ for pgsql-bugs@postgresql.org; Wed, 23 Jul 2014 18:36:07 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1XA1OW-0008Oi-Dc for pgsql-bugs@postgresql.org; Wed, 23 Jul 2014 11:36:04 -0700 Date: Wed, 23 Jul 2014 11:36:04 -0700 (PDT) From: David G Johnston To: pgsql-bugs@postgresql.org Message-ID: <1406140564415-5812568.post@n5.nabble.com> In-Reply-To: References: Subject: Re: syntax error WITH ORDINALITY MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: 0.8 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Simon Riggs wrote > postgres=# select * from unnest(ARRAY[1,2,3]) with ordinality; > > unnest | ordinality > --------+------------ > 1 | 1 > 2 | 2 > 3 | 3 > > postgres=# select unnest(ARRAY[1,2,3]) with ordinality; > > ERROR: syntax error at or near "ordinality" > LINE 1: select unnest(ARRAY[1,2,3]) with ordinality; > > though this works > > postgres=# select unnest(ARRAY[1,2,3]); > > unnest > -------- > 1 > 2 > 3 > > The manual > http://www.postgresql.org/docs/devel/static/queries-table-expressions.html#QUERIES-TABLEFUNCTIONS > says > "Columns returned by table functions can be included in SELECT, JOIN, > or WHERE clauses in the same manner as columns of a table, view, or > subquery." > There is no qualification of that for WITH ORDINALITY, nor an example A function used in the select-list of a query does not constitute a "table expression" and so is not covered by this particular section of the documentation.