Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 0C69C633074 for ; Tue, 8 Dec 2009 21:12:18 -0400 (AST) 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 91714-06 for ; Wed, 9 Dec 2009 01:12:10 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from leary.csoft.net (leary.csoft.net [205.205.214.5]) by mail.postgresql.org (Postfix) with ESMTP id 8FF616328FC for ; Tue, 8 Dec 2009 21:12:10 -0400 (AST) Received: by leary.csoft.net (Postfix, from userid 1112) id 438D0A30D; Tue, 8 Dec 2009 20:12:08 -0500 (EST) Date: Tue, 8 Dec 2009 20:12:08 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Tom Lane cc: "j.random.programmer" , pgsql-jdbc@postgresql.org Subject: Re: Bug in metadata.getColumns()/ORDINAL_POSITION In-Reply-To: <23750.1171742505@sss.pgh.pa.us> Message-ID: References: <616596.40210.qm@web32005.mail.mud.yahoo.com> <23750.1171742505@sss.pgh.pa.us> User-Agent: Alpine 2.00 (BSO 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII 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: 200912/8 X-Sequence-Number: 20089 On Sat, 17 Feb 2007, Tom Lane wrote: > "j.random.programmer" writes: >> This is a quick followup to my earlier post. Upon >> further >> testing, this bug reliably and reproducably happens >> when an "alter table" command is used on the database. > > So the problem is that it's returning pg_attribute.attnum without any > consideration for earlier dropped columns. Not sure how expensive it'd > be to get the current logical column number, though --- at a minimum one > would have to select all the table's pg_attribute rows :-( > I've fixed this in CVS when running against 8.4 and later servers by using the row_number window function as was suggested elsewhere: http://archives.postgresql.org/pgsql-general/2009-11/msg01067.php Kris Jurka