On Tue, 24 Mar 2009 15:54:21 +0100, I wrote:

> When was pg_get_expr() created? Between 7.4 and 8.0 it seems¹, so maybe
> a conditional is necessary?

Attached is a patch that uses pg_get_expr() for 8.0+ and adsrc
otherwise.


  Best regards,

    Adam

-- 
                                                          Adam Sjøgren
                                                    [email protected]

diff --git a/Pg.pm b/Pg.pm
index 0e9ba91..022d53a 100644
--- a/Pg.pm
+++ b/Pg.pm
@@ -433,6 +433,8 @@ use 5.006001;
 
 		my $remarks = 'pg_catalog.col_description(a.attrelid, a.attnum)';
 
+		my $column_def = $dbh->{pg_server_version}>=80000 ? 'pg_catalog.pg_get_expr(af.adbin, af.adrelid)' : 'af.adsrc';
+
 		my $col_info_sql = qq!
 			SELECT
 				NULL::text AS "TABLE_CAT"
@@ -447,7 +449,7 @@ use 5.006001;
 				, NULL::text AS "NUM_PREC_RADIX"
 				, CASE a.attnotnull WHEN 't' THEN 0 ELSE 1 END AS "NULLABLE"
 				, $remarks AS "REMARKS"
-				, af.adsrc AS "COLUMN_DEF"
+				, $column_def AS "COLUMN_DEF"
 				, NULL::text AS "SQL_DATA_TYPE"
 				, NULL::text AS "SQL_DATETIME_SUB"
 				, NULL::text AS "CHAR_OCTET_LENGTH"

Reply via email to