[asterisk-bugs] [Asterisk 0016000]: [patch] Schema problem with res_pgsql

Asterisk Bug Tracker noreply at bugs.digium.com
Sat Oct 3 16:28:38 CDT 2009


A NOTE has been added to this issue. 
====================================================================== 
https://issues.asterisk.org/view.php?id=16000 
====================================================================== 
Reported By:                jamicque
Assigned To:                
====================================================================== 
Project:                    Asterisk
Issue ID:                   16000
Category:                   Resources/res_config_pgsql
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     feedback
Asterisk Version:           1.6.1.6 
JIRA:                        
Regression:                 No 
SVN Branch (only for SVN checkouts, not tarball releases): N/A 
SVN Revision (number only!):  
Request Review:              
====================================================================== 
Date Submitted:             2009-10-01 06:37 CDT
Last Modified:              2009-10-03 16:28 CDT
====================================================================== 
Summary:                    [patch] Schema problem with res_pgsql
Description: 
When you are using reltime with pgsql, asterisk on every connect check the
table and it's columns. 
For example it's made by querry (for meetme):

SELECT a.attname, t.typname, a.attlen, a.attnotnull, d.adsrc, a.atttypmod
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 =
'meetme' ORDER BY c.relname, attnum

The problem is that it does not check the schema. If you have two
different schemas and in every one table meetme, in result Asterisk will
try to insert double statements into one table, which will result in an
error.


======================================================================
Relationships       ID      Summary
----------------------------------------------------------------------
has duplicate       0016001 schema problem
====================================================================== 

---------------------------------------------------------------------- 
 (0111821) jamicque (reporter) - 2009-10-03 16:28
 https://issues.asterisk.org/view.php?id=16000#c111821 
---------------------------------------------------------------------- 
I report the thing you wanted:
query on start:
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 = 'cdr' AND n.nspname = current_schema())
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

result:
in file startup.res

I thing the ticket can be closed. 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2009-10-03 16:28 jamicque       Note Added: 0111821                          
======================================================================




More information about the asterisk-bugs mailing list