Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Finding database version from handle?

by erix (Vicar)
on Jul 22, 2010 at 10:05 UTC ( #850812=note: print w/ replies, xml ) Need Help??


in reply to Finding database version from handle?

Querying PostgreSQL, timtowtdi:

-- versions 7.4 thru 9: # select substring(version() from E'^PostgreSQL (\\S+)') ; substring ----------- 8.4.4 (1 row) -- versions 7.4 thru 9: # select current_setting('server_version'); current_setting ----------------- 8.4.4 (1 row) -- versions 8.2 thru 9: # select current_setting('server_version_num'); current_setting ----------------- 80404 (1 row)

DBIx-Version looks unmaintained, but maybe it has some useful examples.

(update) There is info in DBD::Pg attributes as well:

perl -MDBI -e'my$dbh=DBI->connect("dbi:Pg:"); print $dbh->{pg_server_v +ersion}, "\n"'; 80404

Then, the 2008 SQL standard prescribes a SQL_IMPLEMENTATION_INFO view which (in postgres) has this information:

select implementation_info_name, character_value from information_schema.sql_implementation_info where implementation_info_name ~ 'DBMS'; implementation_info_name | character_value --------------------------+----------------- DBMS NAME | PostgreSQL DBMS VERSION | 08.04.0004 (2 rows)

I seem to remember that, alas, this latter solution (although standard and therefore in principle the 'best') is not very widely available.


Comment on Re: Finding database version from handle?
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://850812]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2015-07-07 04:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (87 votes), past polls