Skip Menu |
 

This queue is for tickets about the DBD-Pg CPAN distribution.

Report information
The Basics
Id: 30924
Status: resolved
Priority: 0/
Queue: DBD-Pg

People
Owner: Nobody in particular
Requestors: nigel [...] catalyst.net.nz
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: 2.0.0



Subject: column_info returns the wrong default value for sequences under certain conditions
Date: Fri, 23 Nov 2007 12:44:25 +1300
To: bug-DBD-Pg [...] rt.cpan.org
From: Nigel McNie <nigel [...] catalyst.net.nz>
Download (untitled) / with headers
text/plain 1.1k
I have come across an problem in the way DBD::Pg retrieves column information for use with the column_info method of DBI. In postgres 8.1 and 8.2, the 'adsrc' column of the pg_attrdef table contains the default value for the column when it was created, but the 'adbin' column is the only one updated if the column is changed. This behaviour is most noticable when you change a sequence name, as per the following: http://paste.dollyfish.net.nz/5faf65 Note how postgres itself has strangely called the sequence_name the original name in the final query. That is a separate issue, probably solved in postgres 8.3 with the new ALTER SEQUENCE statement, although I have not verified this. Anyhow, the upshot is that DBD::Pg should probably look at the adbin column to try and get the default for the column rather than the adsrc column. Postgres version: PostgreSQL 8.1.8 on i486-pc-linux-gnu, compiled by GCC cc (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21) Perl version: This is perl, v5.8.8 built for i486-linux-gnu-thread-multi DBD::Pg version: 1.49-2 from debian. System: Linux pg81 2.6.22.070809 #1 Thu Aug 9 14:15:40 NZST 2007 i686 GNU/Linux -- Regards, Nigel McNie Catalyst IT Ltd. DDI: +64 4 803 2203
Download signature.asc
application/pgp-signature 189b

Message body not shown because it is not plain text.

From: SAMV [...] cpan.org
Download (untitled) / with headers
text/plain 978b
On Thu Nov 22 18:45:06 2007, nigel@catalyst.net.nz wrote: Show quoted text
> > In postgres 8.1 and 8.2, the 'adsrc' column of the pg_attrdef table > contains the default value for the column when it was created, but the > 'adbin' column is the only one updated if the column is changed. This > behaviour is most noticable when you change a sequence name, as per the > following:
Note: actually neither are updated. The adbin works because it (well, actually the expression it refers to) uses the OID of the object. Show quoted text
> Anyhow, the upshot is that DBD::Pg should probably look at the adbin
column Show quoted text
> to try and get the default for the column rather than the adsrc column.
Yes, on versions that support it there is a pg_catalog.pg_expr() function that (aiui) deparses an expression into a string. It would be a good idea to move towards it, as the Pg developers have not expressed an interest in making the various 'source' columns automatically update when the backing expressions change. Sam.
Thanks, fixed in r10484 if you wish to test it out. Will be part of the next release.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.