Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id CCE899FA4D3 for ; Wed, 31 Jan 2007 04:30:02 -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 17051-05 for ; Wed, 31 Jan 2007 04:29:59 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.227]) by postgresql.org (Postfix) with ESMTP id 2B0CA9FA59C for ; Wed, 31 Jan 2007 04:29:59 -0400 (AST) Received: by nz-out-0506.google.com with SMTP id i11so130753nzh for ; Wed, 31 Jan 2007 00:29:55 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:mime-version:to:message-id:content-type:from:subject:date:x-mailer; b=O0/wdkYuoSKZdjgvciRcPFd8yTE7GRHVJCBboSDaP8GU54r7oxAHkEkl1kPLYw/a3xzLnTs57um0xUUNwGI/5mq+jVPQP8UCX3gqoOR/E1XnwnTGK9kmmP++UH9t6yEGhd53WIK0ghLtBYPOL3s/RUfqoCDuGsfVRWatZIrpDx0= Received: by 10.35.62.1 with SMTP id p1mr1072341pyk.1170232195898; Wed, 31 Jan 2007 00:29:55 -0800 (PST) Received: from ?172.16.12.223? ( [12.192.18.226]) by mx.google.com with ESMTP id f57sm698810pyh.2007.01.31.00.29.54; Wed, 31 Jan 2007 00:29:54 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v752.3) To: pgsql-jdbc@postgresql.org Message-Id: <1C85230A-C17D-4601-B84E-6F43176C5D6D@gmail.com> Content-Type: multipart/mixed; boundary=Apple-Mail-1-798947245 From: Jeffrey Cox Subject: getProcedureColumns Date: Wed, 31 Jan 2007 03:29:51 -0500 X-Mailer: Apple Mail (2.752.3) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/188 X-Sequence-Number: 16553 --Apple-Mail-1-798947245 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Hi, I been working with metadata on stored procedures and discovered that I can't get parameter names via getProcedureColumns. So i checked out the source and took a look at the method. Seems that for column names, a $ is appended to the arg type count. I guess I don't know if there is a reason that the actual parameter names are not used, or its just low on the TODO list. I went ahead and updated the method return column names as stored in procargnames of pg_catalog.pg_proc. I have attached a patch. I honestly don't know if this is the correct mechanism to handle this (I poped into #postgres and was told to attach a patch to an email to this list), so just point me in the right direction if need be (either on how to submit the patch, or why making this change is stupid). Jeff --Apple-Mail-1-798947245 Content-Transfer-Encoding: 7bit Content-Type: text/rtf; x-unix-mode=0644; x-mac-hide-extension=yes; name=postgres-jdbc-patch.rtf Content-Disposition: attachment; filename=postgres-jdbc-patch.rtf Index: org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java =================================================================== RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java,v retrieving revision 1.33 diff -u -r1.33 AbstractJdbc2DatabaseMetaData.java --- org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java 1 Dec 2006 08:53:45 -0000 1.33 +++ org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java 31 Jan 2007 08:15:35 -0000 @@ -1724,9 +1724,15 @@ String sql; if (connection.haveMinimumServerVersion("7.3")) { - sql = "SELECT n.nspname,p.proname,p.prorettype,p.proargtypes, t.typtype,t.typrelid " + + sql = "SELECT n.nspname,p.proname,p.prorettype,p.proargtypes, "; + + if(connection.haveMinimumCompatibleVersion("8.0")) + sql += "p.proargnames,"; + + sql += "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)) { sql += " AND n.nspname LIKE '" + escapeQuotes(schemaPattern) + "' "; @@ -1758,13 +1764,18 @@ String returnTypeType = rs.getString("typtype"); int returnTypeRelid = rs.getInt("typrelid"); String strArgTypes = rs.getString("proargtypes"); + String strArgNames[] = null; + Array argNamesArray = rs.getArray("proargnames"); + if(argNamesArray != null) + strArgNames = (String[])argNamesArray.getArray(); 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. if (!returnTypeType.equals("c")) { @@ -1793,7 +1804,14 @@ tuple[0] = null; tuple[1] = schema; tuple[2] = procedureName; - tuple[3] = connection.encodeString("$" + (i + 1)); + if(strArgNames != null) + { + tuple[3] = connection.encodeString(strArgNames[i]); + } + else + { + 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)); --Apple-Mail-1-798947245--