Fix CDR with PostgreSQL 12

PR:		241116
Submitted by:	cmt
MFH:		2019Q4
This commit is contained in:
Guido Falsi 2019-10-09 14:27:30 +00:00
parent f62b08eb61
commit 5168e302d2
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=514158
2 changed files with 12 additions and 0 deletions

View File

@ -2,6 +2,7 @@
PORTNAME= asterisk
PORTVERSION= 13.28.1
PORTRREVISION= 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 {