pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Richard Huxton <dev@archonet.com>
Cc: arnaud.listes@codata.eu
Cc: pgsql-odbc@postgresql.org
Subject: Re: [GENERAL] 'default nextval()' loses schema-qualification in dump ?
Date: Thu, 08 Jul 2010 17:13:47 -0400
Message-ID: <11224.1278623627@sss.pgh.pa.us> (raw)
In-Reply-To: <4C342FA5.3050105@archonet.com>
References: <4C32FF36.8030604@codata.eu>
	<27289.1278426134@sss.pgh.pa.us>
	<4C334593.7030300@codata.eu>
	<28564.1278429458@sss.pgh.pa.us>
	<4C342318.7040502@codata.eu>
	<4C342FA5.3050105@archonet.com>

Richard Huxton <dev@archonet.com> writes:
> If you start psql with the "-E" option and do \d myschema.mytable you'll 
> be able to see how it gets the sequence-name. About half-way down the 
> list of queries it runs you'll see a reference to pg_get_expr(...) - 
> that turns an internal representation into a useful usable one.

> I don't know why psqlODBC isn't using that. The function has been around 
> for a while. Hmm - it's present back in 7.4 although it's not used in \d 
> - that does reference adsrc directly.

> Just grabbed the source download for the latest version and it still 
> looks like it's using adsrc (I just searched for that and pg_get_expr). 
> There should probably be a change in info.c around line 2091 to add a 
> check for a recent version of PG (8+) and use pg_get_expr. Check on the 
> odbc mailing-list - there may be an updated version available for you to 
> test.

Seems like psqlODBC shouldn't be fetching the default value at all, or
at least should not be trying to turn around and pass it back to the
server (if that's what's really happening).  It would be far easier and
safer to omit the target column from the INSERT statement, or write
DEFAULT if that's inconvenient.  Even if you collect the correct
expression by using pg_get_expr(), what if someone ALTERs the default
while you're connected?

I'm suspicious that this coding technique is a hangover from back when
you couldn't write "insert into foo values(default, default)", which is
to say PG 7.2 or before.

			regards, tom lane



view thread (13+ messages)  latest in thread

Message-ID: <11224.1278623627@sss.pgh.pa.us>
Permalink:  ../11224.1278623627@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/11224.1278623627@sss.pgh.pa.us

 · 

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-odbc@postgresql.org
  Cc: tgl@sss.pgh.pa.us, dev@archonet.com, arnaud.listes@codata.eu
  Subject: Re: [GENERAL] 'default nextval()' loses schema-qualification in dump ?
  In-Reply-To: <11224.1278623627@sss.pgh.pa.us>
  References: <4C32FF36.8030604@codata.eu> <27289.1278426134@sss.pgh.pa.us> <4C334593.7030300@codata.eu> <28564.1278429458@sss.pgh.pa.us> <4C342318.7040502@codata.eu> <4C342FA5.3050105@archonet.com> <11224.1278623627@sss.pgh.pa.us>

* 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