pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kris Jurka <books@ejurka.com>
To: Jeffrey Cox <namredips@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: getProcedureColumns
Date: Wed, 28 Feb 2007 02:44:25 -0500 (EST)
Message-ID: <Pine.BSO.4.64.0702280240160.9224@leary.csoft.net> (raw)
In-Reply-To: <CC7F861E-B729-47E7-BD82-A552100A8F21@gmail.com>
References: <1C85230A-C17D-4601-B84E-6F43176C5D6D@gmail.com>
	<Pine.BSO.4.64.0701311619160.27765@leary2.csoft.net>
	<53951298-D245-4EB2-9C3E-EA05A48C77BA@gmail.com>
	<Pine.BSO.4.64.0701311846100.18318@leary2.csoft.net>
	<1D8F84DE-26E9-4C88-B6F4-A7A74B85DE5C@gmail.com>
	<Pine.BSO.4.64.0702140133500.4318@leary.csoft.net>
	<3599D18B-946A-461B-9429-89E0A4868345@gmail.com>
	<Pine.BSO.4.64.0702141026340.23853@leary.csoft.net>
	<110D999D-C0C2-47D8-8905-56B3CA04ED45@gmail.com>
	<Pine.BSO.4.64.0702141243080.3571@leary.csoft.net>
	<CC7F861E-B729-47E7-BD82-A552100A8F21@gmail.com>



On Wed, 14 Feb 2007, Jeffrey Cox wrote:

> I know it's a pain, but I will test it... I just need to get the all the 
> servers up and running. It might take me some time to get them up and going, 
> but shouldn't be to troubling.

Here's a patch that I based off of yours.  For 8.1 code we need to look at 
proallargtypes instead of just proargtypes to get the correct output 
types.  I haven't really tested it, but it looks correct.  Any progress on 
setting up test cases for different server versions?

Kris Jurka

Attachments:

getproccol.patch (text/plain, 8.8K) download ? .build.local.properties.swp ? build.local.properties ? getproccol.patch Index: org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java,v retrieving revision 1.33 diff -c -r1.33 AbstractJdbc2DatabaseMetaData.java *** org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java 1 Dec 2006 08:53:45 -0000 1.33 --- org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java 28 Feb 2007 07:39:43 -0000 *************** *** 1724,1731 **** String sql; if (connection.haveMinimumServerVersion("7.3")) { ! sql = "SELECT n.nspname,p.proname,p.prorettype,p.proargtypes, t.typtype,t.typrelid " + ! " FROM pg_catalog.pg_proc p,pg_catalog.pg_namespace n, pg_catalog.pg_type t " + " WHERE p.pronamespace=n.oid AND p.prorettype=t.oid "; if (schemaPattern != null && !"".equals(schemaPattern)) { --- 1724,1739 ---- String sql; if (connection.haveMinimumServerVersion("7.3")) { ! sql = "SELECT n.nspname,p.proname,p.prorettype,p.proargtypes, t.typtype,t.typrelid "; ! ! if (connection.haveMinimumServerVersion("8.1")) ! sql += ", p.proargnames, p.proargmodes, p.proallargtypes "; ! else if (connection.haveMinimumServerVersion("8.0")) ! sql += ", p.proargnames, NULL AS proargmodes, NULL AS proallargtypes "; ! else ! sql += ", NULL AS proargnames, NULL AS proargmodes, NULL AS proallargtypes "; ! ! sql += " FROM pg_catalog.pg_proc p, pg_catalog.pg_namespace n, pg_catalog.pg_type t " + " WHERE p.pronamespace=n.oid AND p.prorettype=t.oid "; if (schemaPattern != null && !"".equals(schemaPattern)) { *************** *** 1739,1745 **** } else { ! sql = "SELECT NULL AS nspname,p.proname,p.prorettype,p.proargtypes, t.typtype,t.typrelid " + " FROM pg_proc p,pg_type t " + " WHERE p.prorettype=t.oid "; if (procedureNamePattern != null) --- 1747,1753 ---- } else { ! sql = "SELECT NULL AS nspname,p.proname,p.prorettype,p.proargtypes,t.typtype,t.typrelid, NULL AS proargnames, NULL AS proargmodes, NULL AS proallargtypes " + " FROM pg_proc p,pg_type t " + " WHERE p.prorettype=t.oid "; if (procedureNamePattern != null) *************** *** 1757,1768 **** int returnType = rs.getInt("prorettype"); String returnTypeType = rs.getString("typtype"); int returnTypeRelid = rs.getInt("typrelid"); String strArgTypes = rs.getString("proargtypes"); StringTokenizer st = new StringTokenizer(strArgTypes); Vector argTypes = new Vector(); while (st.hasMoreTokens()) { ! argTypes.addElement(new Integer(st.nextToken())); } // decide if we are returning a single column result. --- 1765,1796 ---- int returnType = rs.getInt("prorettype"); String returnTypeType = rs.getString("typtype"); int returnTypeRelid = rs.getInt("typrelid"); + String strArgTypes = rs.getString("proargtypes"); StringTokenizer st = new StringTokenizer(strArgTypes); Vector argTypes = new Vector(); while (st.hasMoreTokens()) { ! argTypes.addElement(new Long(st.nextToken())); ! } ! ! String argNames[] = null; ! Array argNamesArray = rs.getArray("proargnames"); ! if (argNamesArray != null) ! argNames = (String[])argNamesArray.getArray(); ! ! String argModes[] = null; ! Array argModesArray = rs.getArray("proargmodes"); ! if (argModesArray != null) ! argModes = (String[])argModesArray.getArray(); ! ! int numArgs = argTypes.size(); ! ! long allArgTypes[] = null; ! Array allArgTypesArray = rs.getArray("proallargtypes"); ! if (allArgTypesArray != null) { ! allArgTypes = (long[])allArgTypesArray.getArray(); ! numArgs = allArgTypes.length; } // decide if we are returning a single column result. *************** *** 1786,1807 **** } // Add a row for each argument. ! for (int i = 0; i < argTypes.size(); i++) { - int argOid = ((Integer)argTypes.elementAt(i)).intValue(); byte[][] tuple = new byte[13][]; tuple[0] = null; tuple[1] = schema; tuple[2] = procedureName; ! tuple[3] = connection.encodeString("$" + (i + 1)); ! tuple[4] = connection.encodeString(Integer.toString(java.sql.DatabaseMetaData.procedureColumnIn)); tuple[5] = connection.encodeString(Integer.toString(connection.getSQLType(argOid))); tuple[6] = connection.encodeString(connection.getPGType(argOid)); tuple[7] = null; tuple[8] = null; tuple[9] = null; tuple[10] = null; ! tuple[11] = connection.encodeString(Integer.toString(java.sql.DatabaseMetaData.procedureNullableUnknown)); tuple[12] = null; v.addElement(tuple); } --- 1814,1852 ---- } // Add a row for each argument. ! for (int i = 0; i < numArgs; i++) { byte[][] tuple = new byte[13][]; tuple[0] = null; tuple[1] = schema; tuple[2] = procedureName; ! ! if (argNames != null) ! tuple[3] = connection.encodeString(argNames[i]); ! else ! tuple[3] = connection.encodeString("$" + (i + 1)); ! ! int columnMode = DatabaseMetaData.procedureColumnIn; ! if (argModes != null && argModes[i].equals("o")) ! columnMode = DatabaseMetaData.procedureColumnOut; ! else if (argModes != null && argModes[i].equals("b")) ! columnMode = DatabaseMetaData.procedureColumnInOut; ! ! tuple[4] = connection.encodeString(Integer.toString(columnMode)); ! ! int argOid; ! if (allArgTypes != null) ! argOid = (int)allArgTypes[i]; ! else ! argOid = ((Long)argTypes.elementAt(i)).intValue(); ! tuple[5] = connection.encodeString(Integer.toString(connection.getSQLType(argOid))); tuple[6] = connection.encodeString(connection.getPGType(argOid)); tuple[7] = null; tuple[8] = null; tuple[9] = null; tuple[10] = null; ! tuple[11] = connection.encodeString(Integer.toString(DatabaseMetaData.procedureNullableUnknown)); tuple[12] = null; v.addElement(tuple); } *************** *** 1830,1835 **** --- 1875,1881 ---- tuple[12] = null; v.addElement(tuple); } + columnrs.close(); } } rs.close(); Index: org/postgresql/jdbc2/TypeInfoCache.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/jdbc2/TypeInfoCache.java,v retrieving revision 1.7 diff -c -r1.7 TypeInfoCache.java *** org/postgresql/jdbc2/TypeInfoCache.java 19 Feb 2007 05:57:53 -0000 1.7 --- org/postgresql/jdbc2/TypeInfoCache.java 28 Feb 2007 07:39:43 -0000 *************** *** 57,62 **** --- 57,63 ---- {"numeric", new Integer(Oid.NUMERIC), new Integer(Types.NUMERIC), "java.math.BigDecimal"}, {"float4", new Integer(Oid.FLOAT4), new Integer(Types.REAL), "java.lang.Float"}, {"float8", new Integer(Oid.FLOAT8), new Integer(Types.DOUBLE), "java.lang.Double"}, + {"char", new Integer(Oid.CHAR), new Integer(Types.CHAR), "java.lang.String"}, {"bpchar", new Integer(Oid.BPCHAR), new Integer(Types.CHAR), "java.lang.String"}, {"varchar", new Integer(Oid.VARCHAR), new Integer(Types.VARCHAR), "java.lang.String"}, {"text", new Integer(Oid.TEXT), new Integer(Types.VARCHAR), "java.lang.String"},

view thread (21+ messages)  latest in thread

Message-ID: <Pine.BSO.4.64.0702280240160.9224@leary.csoft.net>
Permalink:  ../Pine.BSO.4.64.0702280240160.9224@leary.csoft.net/
Also on:    postgresql.org/message-id/Pine.BSO.4.64.0702280240160.9224@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, namredips@gmail.com
  Subject: Re: getProcedureColumns
  In-Reply-To: <Pine.BSO.4.64.0702280240160.9224@leary.csoft.net>
  References: <1C85230A-C17D-4601-B84E-6F43176C5D6D@gmail.com> <Pine.BSO.4.64.0701311619160.27765@leary2.csoft.net> <53951298-D245-4EB2-9C3E-EA05A48C77BA@gmail.com> <Pine.BSO.4.64.0701311846100.18318@leary2.csoft.net> <1D8F84DE-26E9-4C88-B6F4-A7A74B85DE5C@gmail.com> <Pine.BSO.4.64.0702140133500.4318@leary.csoft.net> <3599D18B-946A-461B-9429-89E0A4868345@gmail.com> <Pine.BSO.4.64.0702141026340.23853@leary.csoft.net> <110D999D-C0C2-47D8-8905-56B3CA04ED45@gmail.com> <Pine.BSO.4.64.0702141243080.3571@leary.csoft.net> <CC7F861E-B729-47E7-BD82-A552100A8F21@gmail.com> <Pine.BSO.4.64.0702280240160.9224@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