<p>Christoph Moench-Tegeder has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/13025">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">cdr_pgsql cel_pgsql res_config_pgsql: compatibility with PostgreSQL 12<br><br>PostgreSQL 12 finally removed column adsrc from table pg_catalog.pg_attrdef<br>(column default values), which has been deprecated since version 8.0.<br>Since then, the official/correct/supported way to retrieve the column<br>default value from the catalog is function pg_catalog.pg_get_expr().<br><br>This change breaks compatibility with pre-8.0 PostgreSQL servers,<br>but has reached end-of-support more than a decade ago.<br>cdr_pgsql and res_config_pgsql still have support for pre-7.3<br>servers, but cleaning that up is perhaps a topic for a major release,<br>not this bugfix.<br><br>Change-Id: I834cb3addf1937e19e87ede140bdd16cea531ebe<br>---<br>M cdr/cdr_pgsql.c<br>M cel/cel_pgsql.c<br>M res/res_config_pgsql.c<br>3 files changed, 3 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/25/13025/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/cdr/cdr_pgsql.c b/cdr/cdr_pgsql.c</span><br><span>index 1a3f9d6..56d2c6d 100644</span><br><span>--- a/cdr/cdr_pgsql.c</span><br><span>+++ b/cdr/cdr_pgsql.c</span><br><span>@@ -707,7 +707,7 @@</span><br><span> schemaname = ast_alloca(strlen(tmp_schemaname) * 2 + 1);</span><br><span> PQescapeStringConn(conn, schemaname, tmp_schemaname, strlen(tmp_schemaname), NULL);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- 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",</span><br><span style="color: hsl(120, 100%, 40%);">+ 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",</span><br><span> tablename,</span><br><span> ast_strlen_zero(schemaname) ? "" : "'", ast_strlen_zero(schemaname) ? "current_schema()" : schemaname, ast_strlen_zero(schemaname) ? "" : "'");</span><br><span> } else {</span><br><span>diff --git a/cel/cel_pgsql.c b/cel/cel_pgsql.c</span><br><span>index 77dd46a..4accd56 100644</span><br><span>--- a/cel/cel_pgsql.c</span><br><span>+++ b/cel/cel_pgsql.c</span><br><span>@@ -597,7 +597,7 @@</span><br><span> PQescapeStringConn(conn, schemaname, schema, lenschema, NULL);</span><br><span> </span><br><span> snprintf(sqlcmd, sizeof(sqlcmd),</span><br><span style="color: hsl(0, 100%, 40%);">- "SELECT a.attname, t.typname, a.attlen, a.attnotnull, d.adsrc, a.atttypmod "</span><br><span style="color: hsl(120, 100%, 40%);">+ "SELECT a.attname, t.typname, a.attlen, a.attnotnull, pg_catalog.pg_get_expr(d.adbin, d.adrelid) adsrc, a.atttypmod "</span><br><span> "FROM (((pg_catalog.pg_class c INNER JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace "</span><br><span> "AND c.relname = '%s' AND n.nspname = %s%s%s) "</span><br><span> "INNER JOIN pg_catalog.pg_attribute a ON ("</span><br><span>diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c</span><br><span>index c8660fb..63eabf8 100644</span><br><span>--- a/res/res_config_pgsql.c</span><br><span>+++ b/res/res_config_pgsql.c</span><br><span>@@ -292,7 +292,7 @@</span><br><span> schemaname = ast_alloca(strlen(tmp_schemaname) * 2 + 1);</span><br><span> PQescapeStringConn(pgsqlConn, schemaname, tmp_schemaname, strlen(tmp_schemaname), NULL);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- ast_str_set(&sql, 0, "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",</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_str_set(&sql, 0, "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",</span><br><span> tablename,</span><br><span> ast_strlen_zero(schemaname) ? "" : "'", ast_strlen_zero(schemaname) ? "current_schema()" : schemaname, ast_strlen_zero(schemaname) ? "" : "'");</span><br><span> } else {</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/13025">change 13025</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/13025"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: I834cb3addf1937e19e87ede140bdd16cea531ebe </div>
<div style="display:none"> Gerrit-Change-Number: 13025 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Christoph Moench-Tegeder <cmt@burggraben.net> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>