Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 08D779FB374 for ; Sat, 17 Feb 2007 03:54:22 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 35747-09 for ; Sat, 17 Feb 2007 03:54:17 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from web32015.mail.mud.yahoo.com (web32015.mail.mud.yahoo.com [68.142.207.112]) by postgresql.org (Postfix) with SMTP id 8681D9FB34E for ; Sat, 17 Feb 2007 03:54:17 -0400 (AST) Received: (qmail 5988 invoked by uid 60001); 17 Feb 2007 07:54:16 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=hFmI+OkT1u3kYRU0is7ZRNzzaNFnTBDSFhRVQwT3HMX5Grg8nUxjiLJPeXNCe+c9fcmttXrIfSJbi9meUy6zZW8+e0IOywknM9YoLLAWjVVSigTKg+S/i8N2s0PCxrZbOEzoebXEhGu4S5/MaK4x097EtmXywOwSN8BnOCI/2Ms=; X-YMail-OSG: msa_K8cVM1kxJ3lZFySO5_W89Oe9b3vs.5jtTzd6qIa7ps2kXER3IAZQ3cGqsq6a5nZ3jEXOt6FBnup3ly.EYj3JC5q4GScEFLB9En_Slefis7r.5jOtaEaPsnRqoEf_QQd2lX9egQ2rL3I- Received: from [71.242.22.36] by web32015.mail.mud.yahoo.com via HTTP; Fri, 16 Feb 2007 23:54:16 PST Date: Fri, 16 Feb 2007 23:54:16 -0800 (PST) From: "j.random.programmer" Subject: Bug in metadata.getColumns()/ORDINAL_POSITION To: pgsql-jdbc@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <421136.5291.qm@web32015.mail.mud.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=2.615 tagged_above=0 required=5 tests=BAYES_20, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, DNS_FROM_RFC_WHOIS X-Spam-Level: ** X-Archive-Number: 200702/81 X-Sequence-Number: 16637 Hi: This is using postgres 8.2.x and the latest 8.2-504 JDBC driver. I have a table, defined like so: test=# \d queue_stat; Table "public.queue_stat" Column | Type | Modifiers ------------------------------------------------------- queue_stat_id | bigint | not null default nextval ('queue_stat_queue_stat_id_seq'::regclass) start_time | timestamp without time zone | finish_time | timestamp without time zone | processing_error | text | status | character varying(24) | fullpath_scan_dir | character varying(255) | ======================================== Note, there are 6 columns defined, total in the table. This snippet of code: ------------------------------------------------------- String columnpattern = "%"; //all columns ResultSet rs = md.getColumns( catalogname, schemaname, tablename, columnpattern); QueryUtil.ensureScrollable(rs); rs.beforeFirst(); while (rs.next()) { String colname = rs.getString ("COLUMN_NAME"); int datatype = rs.getInt ("DATA_TYPE"); String typename = rs.getString ("TYPE_NAME"); int colsize = rs.getInt ("COLUMN_SIZE"); int nullable = rs.getInt ("NULLABLE"); String remarks = rs.getString ("REMARKS"); int colnum = rs.getInt ("ORDINAL_POSITION"); -------------------------------------------------- gives me information about each column. I need the ordinal position because I have written a O/R tool that uses the ordinal position returned by the database meta data to generate methods like: result_set.getString(1) etc. Here's the bug. For the above table (queue_stat), I get (via my o/r tool): INFO 1 >>>> Processing table: queue_stat [colname=queue_stat_id, colnum=1, typename=bigserial] [colname=start_time, colnum=2, typename=timestamp] [colname=finish_time, colnum=3, typename=timestamp] [colname=processing_error, colnum=5, typename=text] [colname=status, colnum=6, typename=varchar] [colname=fullpath_scan_dir, colnum=7, typename=varchar] NOTE, THE COLNUM (via ("ORDINAL_POSITION")) returns: 1, 2, 3, 5, 6, 7 This is WRONG. It should be: 1, 2, 3, 4, 5, 6 Of course, this results in all sorts of problems when the tool tries to say: result_set.getString(7) So in a nutshell: there seems to be a bug in: ResultSet rs = md.getColumns( catalogname, schemaname, tablename, columnpattern); as far as the: "ORDINAL_POSITION" column is concerned. This is a pretty serious bug for any O/R tool. I have not encountered this problem before, so something must have changed, either in the database or in the driver. Very weird... Best regards, --j ____________________________________________________________________________________ Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com