X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 09A3032A1D1 for ; Thu, 30 Sep 2004 06:06:19 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 22378-08 for ; Thu, 30 Sep 2004 05:06:09 +0000 (GMT) Received: from smtp6.poczta.onet.pl (smtp6.poczta.onet.pl [213.180.130.36]) by svr1.postgresql.org (Postfix) with ESMTP id 4C12632A1CE for ; Thu, 30 Sep 2004 06:06:08 +0100 (BST) Received: from bj210.internetdsl.tpnet.pl ([80.53.193.210]:15756 "EHLO pyszny-j.rydnet") by ps6.test.onet.pl with ESMTP id ; Thu, 30 Sep 2004 07:05:55 +0200 Subject: Re: Auto-increment serial (Postgresql JDBC driver w/ From: "Jaroslaw J. Pyszny" To: Kris Jurka Cc: pg@fastcrypt.com, pgsql-jdbc In-Reply-To: <1096385869.15887.11.camel@lx.siec> References: <1095725344.10857.107.camel@lx.siec> <1095794747.18680.23.camel@lx.siec> <1095798675.1557.122.camel@localhost.localdomain> <1095807031.1556.129.camel@localhost.localdomain> <1095880271.22986.37.camel@lx.siec> <1095908898.30959.5.camel@lx.siec> <1096385869.15887.11.camel@lx.siec> Content-Type: multipart/mixed; boundary="=-RYnlAEDGtnAYkn5cNk4u" Message-Id: <1096520753.28730.4.camel@lx.siec> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.3 (1.4.3-9.1.aur.2) Date: 30 Sep 2004 07:05:54 +0200 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200409/204 X-Sequence-Number: 11094 --=-RYnlAEDGtnAYkn5cNk4u Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 8bit W li¶cie z wto, 28-09-2004, godz. 17:37, Jaroslaw J. Pyszny pisze: Hi, 3rd patch: (getColumns returns serial or bigserial) What do you think about it? Jarek -- 8 \\|||// Jarosław J. Pyszny b (o|o) Linux admin/devel ("Vitae,non scholae,discimus") i --\_/-- Linux user: #96704 (http://counter.li.org) t =->computers - let me know if you want to get rid of it <-= --=-RYnlAEDGtnAYkn5cNk4u Content-Disposition: attachment; filename=jdbc_autoincrement3.patch Content-Type: text/x-patch; name=jdbc_autoincrement3.patch; charset=iso-8859-2 Content-Transfer-Encoding: 7bit diff -crN pgjdbc-30.09/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java pgjdbc.ai/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java *** pgjdbc-30.09/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java 2004-08-11 12:34:39.000000000 +0200 --- pgjdbc.ai/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java 2004-09-30 06:58:03.000000000 +0200 *************** *** 2342,2347 **** --- 2342,2360 ---- String pgType = connection.getPGType(typeOid); tuple[5] = connection.encodeString(pgType); // Type name + String defval = rs.getString("adsrc"); + + if ( defval != null ) { + if ( pgType.equals("int4") ) { + if (defval.indexOf("nextval(") != -1) + tuple[5] = connection.encodeString("serial"); // Type name == serial + } + else if ( pgType.equals("int8") ) { + if (defval.indexOf("nextval(") != -1) + tuple[5] = connection.encodeString("bigserial"); // Type name == bigserial + } + } + // by default no decimal_digits // if the type is numeric or decimal we will // overwrite later. *************** *** 3501,3506 **** --- 3514,3520 ---- byte b9[] = connection.encodeString("9"); byte b10[] = connection.encodeString("10"); byte bf[] = connection.encodeString("f"); + byte bt[] = connection.encodeString("t"); byte bnn[] = connection.encodeString(Integer.toString(java.sql.DatabaseMetaData.typeNoNulls)); byte bts[] = connection.encodeString(Integer.toString(java.sql.DatabaseMetaData.typeSearchable)); *************** *** 3516,3527 **** tuple[8] = bts; tuple[9] = bf; // false for now - it's signed tuple[10] = bf; // false for now - must handle money ! tuple[11] = bf; // false for now - handle autoincrement // 12 - LOCAL_TYPE_NAME is null // 13 & 14 ? // 15 & 16 are unused so we return null tuple[17] = b10; // everything is base 10 v.addElement(tuple); } rs.close(); --- 3530,3559 ---- tuple[8] = bts; tuple[9] = bf; // false for now - it's signed tuple[10] = bf; // false for now - must handle money ! tuple[11] = bf; // false - it isn't autoincrement ! // 12 - LOCAL_TYPE_NAME is null // 13 & 14 ? // 15 & 16 are unused so we return null tuple[17] = b10; // everything is base 10 v.addElement(tuple); + + // add pseudo-type serial, bigserial + if ( typname.equals("int4") ) { + byte[][] tuple1 = (byte[][])tuple.clone(); + + tuple1[0] = connection.encodeString("serial"); + tuple1[11] = bt; + v.addElement(tuple1); + } + else if ( typname.equals("int8") ) { + byte[][] tuple1 = (byte[][])tuple.clone(); + + tuple1[0] = connection.encodeString("bigserial"); + tuple1[11] = bt; + v.addElement(tuple1); + } + } rs.close(); --=-RYnlAEDGtnAYkn5cNk4u--