MFH: r514159

Fix CDR with PostgreSQL 12

PR:		241116
Submitted by:	cmt

Approved by:	ports-secteam (miwi)
This commit is contained in:
Guido Falsi 2019-10-09 17:46:57 +00:00
parent 7cf151548a
commit bcb75f0991
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/branches/2019Q4/; revision=514177
2 changed files with 12 additions and 0 deletions

View File

@ -2,6 +2,7 @@
PORTNAME= asterisk
PORTVERSION= 16.5.1
PORTREVISION= 1
CATEGORIES= net
MASTER_SITES= https://downloads.asterisk.org/pub/telephony/%SUBDIR%/:DEFAULT,g729
MASTER_SITE_SUBDIR= asterisk/ \

View File

@ -0,0 +1,11 @@
--- cdr/cdr_pgsql.c.orig 2019-10-06 21:08:37 UTC
+++ cdr/cdr_pgsql.c
@@ -707,7 +707,7 @@ static int config_module(int reload)
schemaname = ast_alloca(strlen(tmp_schemaname) * 2 + 1);
PQescapeStringConn(conn, schemaname, tmp_schemaname, strlen(tmp_schemaname), NULL);
- snprintf(sqlcmd, sizeof(sqlcmd), "SELECT a.attname, t.typname, a.attlen, a.attnotnull, d.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 (NOT a.attisdropped) AND a.attnum > 0 AND a.attrelid = c.oid) INNER JOIN pg_catalog.pg_type t ON t.oid = a.atttypid) LEFT OUTER JOIN pg_attrdef d ON a.atthasdef AND d.adrelid = a.attrelid AND d.adnum = a.attnum ORDER BY n.nspname, c.relname, attnum",
+ snprintf(sqlcmd, sizeof(sqlcmd), "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 (NOT a.attisdropped) AND a.attnum > 0 AND a.attrelid = c.oid) INNER JOIN pg_catalog.pg_type t ON t.oid = a.atttypid) LEFT OUTER JOIN pg_attrdef d ON a.atthasdef AND d.adrelid = a.attrelid AND d.adnum = a.attnum ORDER BY n.nspname, c.relname, attnum",
tablename,
ast_strlen_zero(schemaname) ? "" : "'", ast_strlen_zero(schemaname) ? "current_schema()" : schemaname, ast_strlen_zero(schemaname) ? "" : "'");
} else {