pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kris Jurka <books@ejurka.com>
To: j.random.programmer <javadesigner@yahoo.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Bug with duplicate column names via JDBC MetaData (ORDINAL_POSITION)
Date: Tue, 21 Apr 2009 02:37:04 -0400 (EDT)
Message-ID: <Pine.BSO.4.64.0904210233230.17043@leary.csoft.net> (raw)
In-Reply-To: <171323.40102.qm@web31106.mail.mud.yahoo.com>
References: <171323.40102.qm@web31106.mail.mud.yahoo.com>



On Mon, 20 Apr 2009, j.random.programmer wrote:

> While using JDBC MetaData for my O/R tool, I've come across this
> bug recently;
>
> When getting JDBC Meta data, the column numbers for the
> following 2 columns, via ('ORDINAL_POSITION') of the 2
> columns are IDENTICAL:
>
> [1]
> colname=dictname, colnum=1, sqltype=12, typename=name, colsize=2147483647, nullable=false, isAutoIncrement=false, remarks=null, hasRemarks=false, isPK=false, fkdata=null]
>  --and--
> [2]
> colname=dict_name, colnum=1, sqltype=12, typename=text, colsize=2147483647, nullable=false, isAutoIncrement=false, remarks=null, hasRemarks=false, isPK=false, fkdata=null]
> -------------------------------------------------------------
>
> Note, "dict_name" does not show up via the \d pg_ts_dict
> output above but this, possibly extraneous column, does
> show up in the JDBC MetaData.

Without showing the calls you're making it's not completely clear what 
your ORM tool is doing.  The attached test case of just getColumns has no 
problems.

One thing to be careful of when using DatabaseMetaData is that the table 
names are really table name patterns, so you may in fact have a pgftsedict 
table that is also matching the pg_ts_dict pattern.

Kris Jurka

Attachments:

MDts.java (text/plain, 1.0K) download import java.sql.*; public class MDts { public static void main(String args[]) throws Exception { Class.forName("org.postgresql.Driver"); Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5844/jurka","jurka",""); DatabaseMetaData dbmd = conn.getMetaData(); ResultSet rs = dbmd.getColumns("%", "%", "pg_ts_dict", "%"); printResultSet(rs); conn.close(); } /** * Print a ResultSet to System.out. * This is useful for debugging tests. */ public static void printResultSet(ResultSet rs) throws SQLException { ResultSetMetaData rsmd = rs.getMetaData(); for (int i = 1; i <= rsmd.getColumnCount(); i++) { if (i != 1) { System.out.print(", "); } System.out.print(rsmd.getColumnName(i)); } System.out.println(); while (rs.next()) { for (int i = 1; i <= rsmd.getColumnCount(); i++) { if (i != 1) { System.out.print(", "); } System.out.print(rs.getString(i)); } System.out.println(); } } }

view thread (7+ messages)  latest in thread

Message-ID: <Pine.BSO.4.64.0904210233230.17043@leary.csoft.net>
Permalink:  ../Pine.BSO.4.64.0904210233230.17043@leary.csoft.net/
Also on:    postgresql.org/message-id/Pine.BSO.4.64.0904210233230.17043@leary.csoft.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: books@ejurka.com, javadesigner@yahoo.com
  Subject: Re: Bug with duplicate column names via JDBC MetaData (ORDINAL_POSITION)
  In-Reply-To: <Pine.BSO.4.64.0904210233230.17043@leary.csoft.net>
  References: <171323.40102.qm@web31106.mail.mud.yahoo.com> <Pine.BSO.4.64.0904210233230.17043@leary.csoft.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox