Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column adsrc does not exist in PostgreSQL 12 #562

Closed
maniamadrid opened this issue Nov 18, 2019 · 4 comments
Closed

Column adsrc does not exist in PostgreSQL 12 #562

maniamadrid opened this issue Nov 18, 2019 · 4 comments
Labels
bug pgsql PostgreSQL (Tier 1)
Milestone

Comments

@maniamadrid
Copy link

Problem with d.adsrc in var $metaDefaultsSQL in files ../drivers/adodb-pdo_pgsql.inc.php and ../drivers/adodb-postgres64.inc.php for postgre 12

@dregad dregad added bug pgsql PostgreSQL (Tier 1) labels Nov 18, 2019
@dregad
Copy link
Member

dregad commented Nov 18, 2019

Which is expected, since PostgreSQL 12 release notes says:

Remove obsolete pg_attrdef.adsrc column (Peter Eisentraut)

It turns out that this column has been marked as obsolete since Postgres 8.0- The user manual recommends to use pg_get_expr(adbin, adrelid) to display the default value.

@dregad dregad changed the title Problem with d.adsrc as def in var $metaDefaultsSQL Column adsrc does not exist in PostgreSQL 12 Nov 18, 2019
@dregad
Copy link
Member

dregad commented Nov 18, 2019

@maniamadrid I don't have access to a pgsql instance at the moment. Would you be able to confirm, whether the following patch fixes the issue ?

diff --git a/drivers/adodb-postgres64.inc.php b/drivers/adodb-postgres64.inc.php
index bec7528b..1a5e1e3c 100644
--- a/drivers/adodb-postgres64.inc.php
+++ b/drivers/adodb-postgres64.inc.php
@@ -105,7 +105,7 @@ class ADODB_postgres64 extends ADOConnection{
        var $_genIDSQL = "SELECT NEXTVAL('%s')";
        var $_genSeqSQL = "CREATE SEQUENCE %s START %s";
        var $_dropSeqSQL = "DROP SEQUENCE %s";
-       var $metaDefaultsSQL = "SELECT d.adnum as num, d.adsrc as def from pg_attrdef d, pg_class c where d.adrelid=c.oid and c.relname='%s' order by d.adnum";
+       var $metaDefaultsSQL = "SELECT d.adnum as num, pg_get_expr(d.adbin, d.adrelid) as def from pg_attrdef d, pg_class c where d.adrelid=c.oid and c.relname='%s' order by d.adnum";
        var $random = 'random()';               /// random function
        var $autoRollback = true; // apparently pgsql does not autorollback properly before php 4.3.4
                                                        // http://bugs.php.net/bug.php?id=25404

@maniamadrid
Copy link
Author

maniamadrid commented Nov 20, 2019

@maniamadrid I don't have access to a pgsql instance at the moment. Would you be able to confirm, whether the following patch fixes the issue ?

diff --git a/drivers/adodb-postgres64.inc.php b/drivers/adodb-postgres64.inc.php
index bec7528b..1a5e1e3c 100644
--- a/drivers/adodb-postgres64.inc.php
+++ b/drivers/adodb-postgres64.inc.php
@@ -105,7 +105,7 @@ class ADODB_postgres64 extends ADOConnection{
        var $_genIDSQL = "SELECT NEXTVAL('%s')";
        var $_genSeqSQL = "CREATE SEQUENCE %s START %s";
        var $_dropSeqSQL = "DROP SEQUENCE %s";
-       var $metaDefaultsSQL = "SELECT d.adnum as num, d.adsrc as def from pg_attrdef d, pg_class c where d.adrelid=c.oid and c.relname='%s' order by d.adnum";
+       var $metaDefaultsSQL = "SELECT d.adnum as num, pg_get_expr(d.adbin, d.adrelid) as def from pg_attrdef d, pg_class c where d.adrelid=c.oid and c.relname='%s' order by d.adnum";
        var $random = 'random()';               /// random function
        var $autoRollback = true; // apparently pgsql does not autorollback properly before php 4.3.4
                                                        // http://bugs.php.net/bug.php?id=25404

i have tried your hotfix and the problem solved. Thank you for your fast response.

@dregad
Copy link
Member

dregad commented Nov 21, 2019

Thanks for testing and confirmation. I'll integrate the patch in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug pgsql PostgreSQL (Tier 1)
Projects
None yet
Development

No branches or pull requests

2 participants