Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 4896F2E3893 for ; Wed, 12 Dec 2007 04:01:25 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 07529-09 for ; Wed, 12 Dec 2007 04:01:20 -0400 (AST) Received: from www01.kensystem.com (www01.kensystem.com [72.19.170.120]) by postgresql.org (Postfix) with ESMTP id C30612E3891 for ; Wed, 12 Dec 2007 04:01:21 -0400 (AST) Received: from 192.168.0.3 by www01.kensystem.com (SMTPD); id s20071212010116.48051; Wed, 12 Dec 2007 01:01:16 Message-ID: <475F954C.707@kensystem.com> Date: Wed, 12 Dec 2007 01:01:16 -0700 From: Ken Johanson User-Agent: Thunderbird 1.5.0.13 (Windows/20070809) MIME-Version: 1.0 To: pgsql-general@postgresql.org Subject: Re: RETURNING clause: how to specifiy column indexes? References: <22a9f7570703301215y44a937d0r5faa706bad7948c@mail.gmail.com> <4610AA0C.30608@ejurka.com> <47579D44.6060005@kensystem.com> <47579FBE.1070503@kensystem.com> <475F7766.2040005@kensystem.com> <12796.1197439644@sss.pgh.pa.us> <13400.1197442863@sss.pgh.pa.us> In-Reply-To: <13400.1197442863@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/709 X-Sequence-Number: 125452 Tom Lane wrote: > Kris Jurka writes: >> I think the expectation is that: > >> CREATE TABLE t(a int, b int); >> INSERT INTO t(b,a) VALUES (1,2) RETURNING *; > >> will return 1,2 instead of 2,1 as it does now. > > Hmm ... I see your point, but on what grounds could one argue that > a "*" targetlist here should return something different from what > "SELECT * FROM t" would return? > > I'd say that an app that wants that should write > > INSERT INTO t(b,a) VALUES (1,2) RETURNING b,a; > > which is surely not that hard if you've got the code to produce > the "(b,a)" part. > > In any case it's not clear this is the same thing Ken is complaining > about ... > I am only seeking to have the columns returned in the order they appear naturally. JDBC says "This array contains the indexes of the columns in the target table that contain the auto-generated keys that should be made available." For the record I was not "complaining", only citing in advance the fact that while some consider selecting the keys by index to be dubious, it nonetheless must be done because an API requires it. Casting my question into a complaint is another topic.