cdr_pgsql cel_pgsql res_config_pgsql: compatibility with PostgreSQL 12

PostgreSQL 12 finally removed column adsrc from table pg_catalog.pg_attrdef
(column default values), which has been deprecated since version 8.0.
Since then, the official/correct/supported way to retrieve the column
default value from the catalog is function pg_catalog.pg_get_expr().

This change breaks compatibility with pre-8.0 PostgreSQL servers,
but has reached end-of-support more than a decade ago.
cdr_pgsql and res_config_pgsql still have support for pre-7.3
servers, but cleaning that up is perhaps a topic for a major release,
not this bugfix.

ASTERISK-28571

Change-Id: I834cb3addf1937e19e87ede140bdd16cea531ebe
This commit is contained in:
Christoph Moench-Tegeder
2019-10-08 20:40:30 +02:00
committed by George Joseph
parent 84d3434ad3
commit 52ade18420
3 changed files with 3 additions and 3 deletions

View File

@@ -597,7 +597,7 @@ static int process_my_load_module(struct ast_config *cfg)
PQescapeStringConn(conn, schemaname, schema, lenschema, NULL);
snprintf(sqlcmd, sizeof(sqlcmd),
"SELECT a.attname, t.typname, a.attlen, a.attnotnull, d.adsrc, a.atttypmod "
"SELECT a.attname, t.typname, a.attlen, a.attnotnull, pg_catalog.pg_get_expr(d.adbin, d.adrelid) adsrc, a.atttypmod "
"FROM (((pg_catalog.pg_class c INNER JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace "
"AND c.relname = '%s' AND n.nspname = %s%s%s) "
"INNER JOIN pg_catalog.pg_attribute a ON ("