pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jaroslaw J. Pyszny <arghil@poczta.onet.pl>
To: Kris Jurka <books@ejurka.com>
Cc: pg@fastcrypt.com
Cc: pgsql-jdbc <pgsql-jdbc@postgresql.org>
Subject: Re: Auto-increment serial (Postgresql JDBC driver w/
Date: 30 Sep 2004 07:05:54 +0200
Message-ID: <1096520753.28730.4.camel@lx.siec> (raw)
In-Reply-To: <1096385869.15887.11.camel@lx.siec>
References: <1095725344.10857.107.camel@lx.siec>
	<Pine.BSO.4.56.0409202046080.9396@leary.csoft.net>
	<1095794747.18680.23.camel@lx.siec>
	<1095798675.1557.122.camel@localhost.localdomain>
	<1095807031.1556.129.camel@localhost.localdomain>
	<1095880271.22986.37.camel@lx.siec>
	<Pine.BSO.4.56.0409221454160.32134@leary.csoft.net>
	<1095908898.30959.5.camel@lx.siec>
	<Pine.BSO.4.56.0409230028320.28320@leary.csoft.net>
	<1096385869.15887.11.camel@lx.siec>

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 <arghil@poczta.onet.pl>
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 <-=

Attachments:

jdbc_autoincrement3.patch (text/x-patch, 2.8K) download 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();

view thread (13+ messages)  latest in thread

Message-ID: <1096520753.28730.4.camel@lx.siec>
Permalink:  ../1096520753.28730.4.camel@lx.siec/
Also on:    postgresql.org/message-id/1096520753.28730.4.camel@lx.siec

 ·  · 

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: arghil@poczta.onet.pl, books@ejurka.com, pg@fastcrypt.com
  Subject: Re: Auto-increment serial (Postgresql JDBC driver w/
  In-Reply-To: <1096520753.28730.4.camel@lx.siec>
  References: <1095725344.10857.107.camel@lx.siec> <Pine.BSO.4.56.0409202046080.9396@leary.csoft.net> <1095794747.18680.23.camel@lx.siec> <1095798675.1557.122.camel@localhost.localdomain> <1095807031.1556.129.camel@localhost.localdomain> <1095880271.22986.37.camel@lx.siec> <Pine.BSO.4.56.0409221454160.32134@leary.csoft.net> <1095908898.30959.5.camel@lx.siec> <Pine.BSO.4.56.0409230028320.28320@leary.csoft.net> <1096385869.15887.11.camel@lx.siec> <1096520753.28730.4.camel@lx.siec>

* 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