On Oct 14, 2008, at 08:33, David E. Wheeler wrote:

Well, the C version I borrowed from dumpitils seems to work great. Any reason I shouldn't stay with that?

Also, here's a simpler SQL version, for those following along at home:

create or replace function pg_version_num() returns int language
SQL as $$
    SELECT SUM(
(string_to_array(current_setting('server_version'), '.')) [i]::int
        * CASE i WHEN 1 THEN 10000 WHEN 2 THEN 100 ELSE 1 end
    )::int FROM generate_series(1, 3) AS gen(i);
$$;
CREATE FUNCTION

There must be a way to get string_to_array() to evaluate only once, yes?

Best,

David


--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to