pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dickson S. Guedes <listas@guedesoft.net>
To: pgsql-jdbc <pgsql-jdbc@postgresql.org>
Subject: Renaming sequence auto generated by SERIAL type don't update pg_attrdef
Date: Mon, 09 Mar 2009 22:55:19 -0300
Message-ID: <1236650119.6410.73.camel@guedes-laptop> (raw)

Hi all,

Reproduced in 8.3.6.

postgres=# CREATE TABLE test (a serial);
NOTICE:  CREATE TABLE will create implicit sequence "test_a_seq" for
serial column "test.a"
CREATE TABLE
postgres=# \d test
                        Tabela "public.test"
 Coluna |  Tipo   |                  Modificadores                   
--------+---------+--------------------------------------------------
 a      | integer | not null default nextval('test_a_seq'::regclass)

postgres=# ALTER SEQUENCE test_a_seq RENAME TO seq_test_another;
ALTER SEQUENCE
postgres=# \d test 
                           Tabela "public.test"
 Coluna |  Tipo   |
Modificadores                      
--------+---------+--------------------------------------------------------
 a      | integer | not null default
nextval('seq_test_another'::regclass)

postgres=# \x
postgres=#
postgres=# -- A sample select used by JDBC Driver for PostgreSQL
postgres=#
postgres=# SELECT n.nspname, c.relname, a.attname, a.atttypid,
 a.attnotnull, a.atttypmod, a.attlen, a.attnum,  def.adsrc,
 dsc.description,  t.typbasetype, t.typtype  
postgres-# FROM     pg_catalog.pg_namespace n  
postgres-# JOIN     pg_catalog.pg_class c ON (c.relnamespace = n.oid)  
postgres-# JOIN     pg_catalog.pg_attribute a ON (a.attrelid=c.oid)  
postgres-# JOIN     pg_catalog.pg_type t ON (a.atttypid = t.oid)  
postgres-# LEFT JOIN pg_catalog.pg_attrdef def ON
(a.attrelid=def.adrelid AND a.attnum = def.adnum)  
postgres-# LEFT JOIN pg_catalog.pg_description dsc ON (c.oid=dsc.objoid
AND a.attnum = dsc.objsubid)  
postgres-# LEFT JOIN pg_catalog.pg_class dc ON (dc.oid=dsc.classoid AND
dc.relname='pg_class')  
postgres-# LEFT JOIN pg_catalog.pg_namespace dn ON
(dc.relnamespace=dn.oid AND dn.nspname='pg_catalog')  
postgres-# WHERE 
postgres-#     a.attnum > 0 AND 
postgres-#     NOT a.attisdropped  AND 
postgres-#     n.nspname LIKE 'public'  AND 
postgres-#     c.relname LIKE 'test'  AND 
postgres-#     a.attname LIKE '%'  
postgres-# ORDER BY nspname,relname,attnum 
postgres-# ;
-[ RECORD 1 ]--------------------------------
nspname     | public
relname     | test
attname     | a
atttypid    | 23
attnotnull  | t
atttypmod   | -1
attlen      | 4
attnum      | 1
adsrc       | nextval('test_a_seq'::regclass)
description | 
typbasetype | 0
typtype     | b


Shouldn't the JDBC driver use another query instead that, since docs
alerts[1] to this problem?

[1]
http://www.postgresql.org/docs/current/static/catalog-pg-attrdef.html

Regards,
-- 
Dickson S. Guedes 
mail/xmpp: guedes@guedesoft.net - skype: guediz
http://guedesoft.net - http://planeta.postgresql.org.br





view thread (10+ messages)  latest in thread

Message-ID: <1236650119.6410.73.camel@guedes-laptop>
Permalink:  ../1236650119.6410.73.camel@guedes-laptop/
Also on:    postgresql.org/message-id/1236650119.6410.73.camel@guedes-laptop

 · 

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: listas@guedesoft.net
  Subject: Re: Renaming sequence auto generated by SERIAL type don't update pg_attrdef
  In-Reply-To: <1236650119.6410.73.camel@guedes-laptop>
  References: <1236650119.6410.73.camel@guedes-laptop>

* 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