On Monday 09 December 2002 17:03, Tom Lane wrote:
(B> Ian Barwick <[EMAIL PROTECTED]> writes:
(B> > To avoid voodoo with PostgreSQL version numbers
(B> > a check is made whether pg_relcheck exists and
(B> > the appropriate query (either 7.3 or pre 7.3)
(B> > executed.
(B>
(B> I would think that looking at version number (select version())
(B> would be a much cleaner approach. Or do you think that direct
(B> examination of pg_class is a version-independent operation?
(B
(BNo, but I was hoping it will remain stable for long enough
(Bfor what is basically a temporary work around until a revised version of
(BDBD::Pg can be produced. It doesn't make any more assumptions
(Babout pg_class than are made elsewhere in the current Pg.pm.
(B
(B> This inquiry into pg_relcheck's existence is already arguably wrong
(B> in 7.3 (since it's not taking account of which schema pg_relcheck
(B> might be found in) and it can only go downhill in future versions.
(B
(BDoh. Knew I had to be missing something obvious. (Of course,
(Banyone using current DBD::Pg with 7.3 as is will have to take
(Bextra care with system tables and schema namespaces anyway.)
(B
(BSo out with the candle wax and pins ;-). Am I right
(Bin thinking that the string returned by SELECT version()
(Bstarts with the word "PostgreSQL" followed by:
(B a space;
(B a single digit indicating the major version number;
(B a full stop / decimal point;
(B a single digit indicating the minor version number;
(Band either "interim release" number (e.g. ".1" in the case of 7.3.1), or
(B"devel", "rc1" etc. ?
(BAnd that this has been true since 6.x and will continue for the forseeable
(Bfuture (i.e. far far longer than the intended lifespan of attached patch)?
(B
(B
(BIan Barwick
([EMAIL PROTECTED]
(B
(BAttached: revised patch
619c619,629
(B< my ($constraint) = $dbh->selectrow_array("select rcsrc from pg_relcheck where rcname = '${table}_$col_name'");
(B---
(B> # Note: as of PostgreSQL 7.3 pg_relcheck has been replaced
(B> # by pg_constraint. To maintain compatibility, check
(B> # version number and execute appropriate query.
(B>
(B> my ($version) = $dbh->selectrow_array("SELECT version()");
(B> $version =~ /^PostgreSQL (\d)\.(\d)/;
(B>
(B> my $con_query = $1.$2 < 73
(B> ? "SELECT rcsrc FROM pg_relcheck WHERE rcname = '${table}_$col_name'"
(B> : "SELECT consrc FROM pg_catalog.pg_constraint WHERE contype = 'c' AND conname = '${table}_$col_name'";
(B> my ($constraint) = $dbh->selectrow_array($con_query);