6.0.0-git
2019-12-12

[#14964] Postgresql12 dropped adsrc
Summary Postgresql12 dropped adsrc
Queue Components
Type Bug
State Unconfirmed
Priority 1. Low
Owners
Requester christian.ehrhardt (at) canonical (dot) com
Created 2019-11-14 (28 days ago)
Due
Updated 2019-11-20 (22 days ago)
Assigned
Resolved
Milestone
Patch No

History
2019-11-20 23:34:21 mail (at) webthatworks (dot) it Comment #3 Reply to this comment
I opened a pull request on github with a patch that should solve the 
problem, it's there waiting for some love.

[Show Quoted Text - 26 lines]
2019-11-17 22:12:53 mail (at) webthatworks (dot) it Comment #2 Reply to this comment
I can confirm that bug.

I'm trying to fix it and I'll submit a patch ASAP on github.

I've talked with the postgresql guys and it seems that that column has 
been deprecated for a long time and it even risked to contain stale 
data.

They have suggested me to use pg_get_expr(adbin,adrelid), but on 
overall the current queries that use adsrc are a bit fragile and could 
use information_schema rather than interrogating pg specific columns 
and massaging strings.

Currently I've some tentative code but I'm not able to replicate 
EXACTLY the return of one of the queries.
namely original query return eg.

nextval('public.horde_alarms_id_seq'::regclass)

while mine returns

nextval('horde_alarms_id_seq'::regclass)

I'm going to subscribe to horde dev mailing list and propose some 
patch on github ASAP

2019-11-14 12:44:53 christian (dot) ehrhardt (at) canonical (dot) com Comment #1
Type ⇒ Bug
State ⇒ Unconfirmed
Priority ⇒ 1. Low
Summary ⇒ Postgresql12 dropped adsrc
Queue ⇒ Components
Milestone ⇒
Patch ⇒ No
Reply to this comment
Hi,
the DB component still makes use of "adsrc".

This is a postgresql feature [1] that was deprecated for years and is 
now gone. [1] also contains a hint how it should be used.

This is still in some Horde code:
$ grep -Hrn adsrc *
lib/Horde/Db/Adapter/Postgresql/Schema.php:361:                 
$row['attname'], $row['adsrc'], $row['format_type'], 
!(boolean)$row['attnotnull']);
lib/Horde/Db/Adapter/Postgresql/Schema.php:391:            SELECT 
a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
lib/Horde/Db/Adapter/Postgresql/Schema.php:1136:                WHEN 
split_part(def.adsrc, '''', 2) ~ '.' THEN
lib/Horde/Db/Adapter/Postgresql/Schema.php:1137:                   
substr(split_part(def.adsrc, '''', 2),
lib/Horde/Db/Adapter/Postgresql/Schema.php:1138:                       
   strpos(split_part(def.adsrc, '''', 2), '.')+1)
lib/Horde/Db/Adapter/Postgresql/Schema.php:1139:                ELSE 
split_part(def.adsrc, '''', 2)
lib/Horde/Db/Adapter/Postgresql/Schema.php:1147:              AND 
def.adsrc ~* 'nextval'";

Which leads to errors like the following (on test):
There were 12 errors:

1) Horde_Db_Adapter_Pdo_PgsqlTest::testColumns
Horde_Db_Exception: SQLSTATE[42703]: Undefined column: 7 ERROR:   
column d.adsrc does not exist
LINE 2: ... a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a...
                                                              ^

/tmp/autopkgtest.uUKdVj/build.XmB/src/Horde_Db-2.4.0/lib/Horde/Db/Adapter/Pdo/Base.php:237
/tmp/autopkgtest.uUKdVj/build.XmB/src/Horde_Db-2.4.0/lib/Horde/Db/Adapter/Pdo/Base.php:109
/tmp/autopkgtest.uUKdVj/build.XmB/src/Horde_Db-2.4.0/lib/Horde/Db/Adapter/Base/Schema.php:166
/tmp/autopkgtest.uUKdVj/build.XmB/src/Horde_Db-2.4.0/lib/Horde/Db/Adapter/Postgresql/Schema.php:385
/tmp/autopkgtest.uUKdVj/build.XmB/src/Horde_Db-2.4.0/lib/Horde/Db/Adapter/Postgresql/Schema.php:347
/tmp/autopkgtest.uUKdVj/build.XmB/src/Horde_Db-2.4.0/lib/Horde/Db/Adapter/Base.php:274
/tmp/autopkgtest.uUKdVj/build.XmB/src/Horde_Db-2.4.0/test/Horde/Db/Adapter/TestBase.php:519
/tmp/autopkgtest.uUKdVj/build.XmB/src/Horde_Db-2.4.0/test/Horde/Db/Adapter/Pdo/PgsqlTest.php:159

Caused by
PDOException: SQLSTATE[42703]: Undefined column: 7 ERROR:  column 
d.adsrc does not exist
LINE 2: ... a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a...
...

[1]: https://www.postgresql.org/docs/8.3/catalog-pg-attrdef.html

Saved Queries