aboutsummaryrefslogtreecommitdiffstats
path: root/cdr
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-12-15 18:09:58 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-12-15 18:09:58 +0000
commit9b133b4c0b65cc32100bc566a0d6cb6f10a3b8f5 (patch)
treef2f954aeb56895ed543c5f1cbe9a9e23d3869cad /cdr
parentaa28d155ac09a671f5973e672ee2ae6243ef6fc0 (diff)
When querying for the structure of the CDR table, remove the schema, if it
exists. (Closes issue #14058) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@164349 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'cdr')
-rw-r--r--cdr/cdr_pgsql.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/cdr/cdr_pgsql.c b/cdr/cdr_pgsql.c
index 34ba9dd0c..5e8e48673 100644
--- a/cdr/cdr_pgsql.c
+++ b/cdr/cdr_pgsql.c
@@ -469,12 +469,20 @@ static int config_module(int reload)
if (PQstatus(conn) != CONNECTION_BAD) {
char sqlcmd[512];
char *fname, *ftype, *flen, *fnotnull, *fdef;
+ char *tableptr;
int i, rows;
ast_debug(1, "Successfully connected to PostgreSQL database.\n");
connected = 1;
+ /* Remove any schema name from the table */
+ if ((tableptr = strrchr(table, '.'))) {
+ tableptr++;
+ } else {
+ tableptr = table;
+ }
+
/* Query the columns */
- snprintf(sqlcmd, sizeof(sqlcmd), "select a.attname, t.typname, a.attlen, a.attnotnull, d.adsrc from pg_class c, pg_type t, pg_attribute a left outer join pg_attrdef d on a.atthasdef and d.adrelid = a.attrelid and d.adnum = a.attnum where c.oid = a.attrelid and a.atttypid = t.oid and (a.attnum > 0) and c.relname = '%s' order by c.relname, attnum", table);
+ snprintf(sqlcmd, sizeof(sqlcmd), "select a.attname, t.typname, a.attlen, a.attnotnull, d.adsrc from pg_class c, pg_type t, pg_attribute a left outer join pg_attrdef d on a.atthasdef and d.adrelid = a.attrelid and d.adnum = a.attnum where c.oid = a.attrelid and a.atttypid = t.oid and (a.attnum > 0) and c.relname = '%s' order by c.relname, attnum", tableptr);
result = PQexec(conn, sqlcmd);
if (PQresultStatus(result) != PGRES_TUPLES_OK) {
pgerror = PQresultErrorMessage(result);