[Home]

Summary:ASTERISK-02242: res_config_odbc doesn't load full context if id aren't continous (extensions.conf)
Reporter:marlow (marlow)Labels:
Date Opened:2004-08-20 01:49:43Date Closed:2011-06-07 14:10:32
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) res_config_stmt[1].txt
Description:If extensions.conf is handled through res_config_odbc asterisk
will only load a context until the id jumps more than one. Everything after that (for this context) is ignored. The select (select * from ast_config where filename='extensions.conf' and commented=0 order by filename,cat_metric desc,var_metric asc,id) does provide them all.

****** ADDITIONAL INFORMATION ******

Sample:
id  cat_metric  var_metric  commented  filename  category var_name var_val
86   3   0   0   extensions.conf   outbound-fallback   exten   _1NXXNXXXXXX,1,Dial(IAX2/user@trunk-us/${EXTEN})
87   3   0   0   extensions.conf   outbound-fallback   exten   _44Z.,1,Dial(IAX2/user@trunk-uk/0${EXTEN:2})
90   3   0   0   extensions.conf   outbound-fallback   exten   _XXX.,1,Dial(Zap/g1/00${EXTEN})

Take the data given above, it will only load the lines with ID 86 and 87.
var_val of line 90 and 87 can be switched, line 90 will still be the one not to be loaded.
The reason why the number not may be continous is that other contexts, data for other configuration files etc. could have been added in the meanwhile and since id is a autonum field, it just counts up.
Comments:By: Brian West (bkw918) 2004-08-20 10:27:11

dont forget to set your var metric also

By: Anthony Minessale (anthm) 2004-08-20 21:22:42

DoH!

edit the src and change the sql st
from....
order by filename,cat_metric desc,var_metric asc,id)
to...
order by filename,cat_metric desc,var_metric asc,var_name,var_val,id)
see if that works.

By: pfn (pfn) 2004-08-21 15:27:20

I did the following on postgresql and was unable to reproduce the issue.  Perhaps this is a bug with mysql (I don't know which db you're using)?  Maybe anthm's updated query fixes this?

asterisk=# select * from ast_config where category = 'luuhan' and filename = 'extensions.conf';
 id  | cat_metric | var_metric | commented |    filename     | category | ...
------+------------+------------+-----------+-----------------+----------+-------
1970 |         21 |          0 |         0 | extensions.conf | luuhan   | exten    | _XXX.,1,Dial(Zap/g1/00${EXTEN})
4004 |         21 |          2 |         0 | extensions.conf | luuhan   | exten    | 100,3,Congestion
4003 |         21 |          1 |         0 | extensions.conf | luuhan   | exten    | 100,2,Dial(SIP/100&SIP/fonality/15103012295,60,t)
4002 |         21 |          0 |         0 | extensions.conf | luuhan   | exten    | 100,1,Monitor(wav49,luuhan-${TIMESTAMP},m)
(4 rows)

Resulted in the following after an extensions reload:

[ Context 'luuhan' created by 'pbx_config' ]
 '100' =>          1. Monitor(wav49|luuhan-${TIMESTAMP}|m)       [pbx_config]
                   2. Dial(SIP/100&SIP/fonality/15103012295|60|t) [pbx_config]
                   3. Congestion()                               [pbx_config]
 '_XXX.' =>        1. Dial(Zap/g1/00${EXTEN})                    [pbx_config]

edited on: 08-21-04 15:28

By: marlow (marlow) 2004-08-21 16:26:58

pfn: it's mysql and as we discussed this on irc:

i get the following output on reload:
-- Registered extension context 'outbound-fallback'
 -- Added extension '_44Z.' priority 1 to outbound-fallback
 -- Added extension '_XXX.' priority 1 to outbound-fallback
 -- Registered extension context 'inbound-did'
a couple of lines later with other extensions:
 Aug 21 22:11:20 WARNING[376855]: pbx.c:2882 ast_context_create: Tried to register context 'outbound-fallback', already in use

The reason for this problem is my interpretation of cat_metric and var_metric.
I did not increase these values every time i added a new category or value, but only if i wanted to force a certain order.

That resultet in the error mentioned .. i'm updating all cat and var metrics now and test that again.

By: marlow (marlow) 2004-08-21 17:58:28

ok .. giving every category it's unique cat metric fixes the problem.

So either the query should also order on "category" or the documentation needs to get better. Better is both. The last one i'll give a shot at the wiki and in the hitchhikers guide.

By: Brian West (bkw918) 2004-08-22 00:01:44

well category=context and yes they should have their own id per category/context

By: pfn (pfn) 2004-08-23 14:37:25

Ok, I'm attaching a diff, changing the order by to include ordering by category after cat_metric.  This will catch the case where cat_metric is not different per category.  There is already code there to detect changing cat_metrics for creating categories, so a category name with sequential cat_metrics will not be affected.

Additionally, changing the the * to individual column names, because select * is evil, mmkay?  (It is particularly bad if the column order in the table definition is not the same as expected by select */bindcol functions)

By: Anthony Minessale (anthm) 2004-08-23 15:18:44

fixed sql st to be more forgiving
read the thread for explanation of the issue