Thread: Version-aware psql?

Version-aware psql?

From
David Fetter
Date:
Kind people,

I've been digging through the CVS code and trying to figure out the
best approach to making one psql that "does the right thing" for
different versions of the back-end.  This has come up in a real
situation already, where the dev box is 7.3.3 and the production box
is (Yikes!) 7.2.1.  Connecting from the 7.3.3 side results in a lot of
stuff like this:

Password:
ERROR:  parser: parse error at or near "."
Welcome to psql 7.3.3, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms      \h for help with SQL commands      \? for help on internal slash commands
    \g or terminate with semicolon to execute query      \q to quit
 

template1=> \dt
ERROR:  parser: parse error at or near "."
template1=>

Luckily, it works (so far) ok going from 7.2.1 -> 7.3.3, though.

So which files need consideration to make this reasonably seamless?
Are they all in src/bin/psql, or are there others elsewhere that
should know?

I'm wondering if maybe the Right Thing(TM) might be for all
connections to return (optionally?) the version number, but that seems
like a giant project with many backward-compatibility snags attached.

TIA for any tips, hints or pointers on this :)

Cheers,
D
-- 
David Fetter david@fetter.org http://fetter.org/
phone: +1 510 893 6100    cell: +1 415 235 3778


Re: Version-aware psql?

From
"Christopher Kings-Lynne"
Date:
> I'm wondering if maybe the Right Thing(TM) might be for all
> connections to return (optionally?) the version number, but that seems
> like a giant project with many backward-compatibility snags attached.

I think it would be for psql to check the connection version and then load a
shared library containing the implementation of all its functions for that
particular database version...

Chris



Re: Version-aware psql?

From
Tom Lane
Date:
David Fetter <david@fetter.org> writes:
> I'm wondering if maybe the Right Thing(TM) might be for all
> connections to return (optionally?) the version number, but that seems
> like a giant project with many backward-compatibility snags attached.

Already done, see PQparameterStatus at
http://developer.postgresql.org/docs/postgres/libpq-status.html
        regards, tom lane