[Home]

Summary:ASTERISK-28571: cdr_pgsql: accesses obsolete (and finally removed) column
Reporter:Christoph Moench-Tegeder (cmt@burggraben.net)Labels:patch
Date Opened:2019-10-07 08:54:06Date Closed:2019-10-14 06:30:04
Priority:MinorRegression?No
Status:Closed/CompleteComponents:CDR/cdr_pgsql
Versions:GIT 16.6.0 Frequency of
Occurrence
Frequent
Related
Issues:
Environment:PostgreSQL server version: 12.0 affects all Asterisk versions (including git master branch)Attachments:( 0) cdr_pgsql_pg_get_expr.diff
Description:In cdr/cdr_pgsql.c function config_module() discovers the configured cdr table's schema. The SQL statement in there accesses pg_catalog.pg_attrdef.adsrc - a column which has been obsolete sind PostgreSQL 8.0 (released January 2005) and finally removed in PostgreSQL 12 (released Oct 3rd 2019).

Initialization of the cdr_pgsql module against a PostgreSQL 12 server fails with message
 cdr_pgsql.c: Failed to query database columns: ERROR:  column d.adsrc does not exist
and no CDRs will be logged.

Fortunately, the same information which once was stored in adsrc is accessable via column adbin and function pg_catalog.pg_get_expr, which is the recommended way since PostgreSQL 8.0. I'll attach a patch.
Using that patch, cdr_pgsql initializes fine again and I get my CDRs logged to the database as with older PostgreSQL versions.

See:
https://www.postgresql.org/docs/8.0/catalog-pg-attrdef.html
https://www.postgresql.org/docs/12/catalog-pg-attrdef.html
https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=fe5038236c6b99d48c2faa2247b5cec9703add2a
https://www.postgresql.org/docs/11/functions-info.html#FUNCTIONS-INFO-CATALOG-TABLE

On a side note, there's code supporting very old PostgreSQL releases in cdr_pgsql ("before version 7.3", which is end-of-life for over a decade) which I do not touch in this issue but should perhaps removed.

See: https://www.postgresql.org/support/versioning/
Comments:By: Asterisk Team (asteriskteam) 2019-10-07 08:54:07.097-0500

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

Please note that once your issue enters an open state it has been accepted. As Asterisk is an open source project there is no guarantee or timeframe on when your issue will be looked into. If you need expedient resolution you will need to find and pay a suitable developer. Asking for an update on your issue will not yield any progress on it and will not result in a response. All updates are posted to the issue when they occur.

By: Christoph Moench-Tegeder (cmt@burggraben.net) 2019-10-07 09:10:45.617-0500

Read column defaults via pg_get_expr(adbin)

This is the recommended way of reading the column default since PostgreSQL 8.0 and the only official way since PostgreSQL 12.

By: Benjamin Keith Ford (bford) 2019-10-07 14:42:09.441-0500

[~cmt@burggraben.net] were you planning on submitting a patch to Gerrit [1] for this? If you're unsure on the process for it, information can be found here [2].

[1]: https://gerrit.asterisk.org/q/status:open
[2]: https://wiki.asterisk.org/wiki/display/AST/Gerrit+Usage

By: Christoph Moench-Tegeder (cmt@burggraben.net) 2019-10-08 10:11:00.191-0500

I had to wait for the License Agreement to pass your legal department. If Guido doesn't beat me to it, I'll try my luck with Gerrit later today or tomorrow. For the time being, see the attachment.
I'm propably not the first to say this, but getting this patch through to you is much more work than fixing the problem in the first place.

By: Sean Bright (seanbright) 2019-10-08 10:20:11.038-0500

[~cmt@burggraben.net], does the same problem exist in {{cel_pgsql.c}} and/or {{res_config_pgsql.c}}?

By: Sean Bright (seanbright) 2019-10-08 10:27:19.283-0500

[~cmt@burggraben.net], you don't _have_ to go through Gerrit with your patch. Someone else can pick up the patch from here and run with it. Because the PostgreSQL modules are all extended (community) supported, going through Gerrit yourself will ensure that it gets eyes on it more quickly.

By: Christoph Moench-Tegeder (cmt@burggraben.net) 2019-10-08 10:50:33.815-0500

[~seanbright] yes, in both, now that you mention it. That looks like quite some code duplication (including suport for pre-7.3-postgresql)... anyways, grep doesn't show more (other than cdr_pgsql.c, cel_pgsql.c, res_config_pgsql.c) references to adsrc.
I'll update the patch when I get arround to gerrit.

By: Christoph Moench-Tegeder (cmt@burggraben.net) 2019-10-08 14:32:23.236-0500

Fine, there we are. cel_pgsql.c had changes to the SQL somewhere between 13 and 15, I hope I handled the merge conflicts when cherrypicking In a way that works with your process (hence 4 reviews, should've skipped 13, that would've made things easier).

By: Sean Bright (seanbright) 2019-10-08 14:49:16.288-0500

[~cmt@burggraben.net], thanks. You can abandon [this one|https://gerrit.asterisk.org/c/asterisk/+/13024] as 15 is no longer supported. I cherry picked to 17 as well.

By: Christoph Moench-Tegeder (cmt@burggraben.net) 2019-10-08 15:00:54.713-0500

I did check on https://www.asterisk.org/downloads/asterisk/all-asterisk-versions and that looked like 15 was still available. I should have clicked one link further.

By: Sean Bright (seanbright) 2019-10-08 15:03:52.789-0500

Yeah. Looks like that page needs updating. Sorry about that.

By: Richard Mudgett (rmudgett) 2019-10-08 15:08:51.162-0500

15 Just went EOL last week.
https://wiki.asterisk.org/wiki/display/AST/Asterisk+Versions

By: Joshua C. Colp (jcolp) 2019-10-08 15:12:27.119-0500

I've disabled the standard releases pane. It'll reappear once Asterisk 17 is released and contain only 17.

By: Friendly Automation (friendly-automation) 2019-10-14 06:30:06.085-0500

Change 13026 merged by Friendly Automation:
cdr_pgsql cel_pgsql res_config_pgsql: compatibility with PostgreSQL 12

[https://gerrit.asterisk.org/c/asterisk/+/13026|https://gerrit.asterisk.org/c/asterisk/+/13026]

By: Friendly Automation (friendly-automation) 2019-10-14 06:31:38.984-0500

Change 13023 merged by Joshua Colp:
cdr_pgsql cel_pgsql res_config_pgsql: compatibility with PostgreSQL 12

[https://gerrit.asterisk.org/c/asterisk/+/13023|https://gerrit.asterisk.org/c/asterisk/+/13023]

By: Friendly Automation (friendly-automation) 2019-10-14 06:32:09.228-0500

Change 13025 merged by Friendly Automation:
cdr_pgsql cel_pgsql res_config_pgsql: compatibility with PostgreSQL 12

[https://gerrit.asterisk.org/c/asterisk/+/13025|https://gerrit.asterisk.org/c/asterisk/+/13025]

By: Friendly Automation (friendly-automation) 2019-10-14 06:32:30.721-0500

Change 13027 merged by Friendly Automation:
cdr_pgsql cel_pgsql res_config_pgsql: compatibility with PostgreSQL 12

[https://gerrit.asterisk.org/c/asterisk/+/13027|https://gerrit.asterisk.org/c/asterisk/+/13027]