Douglas Garstang
2006-Nov-02 09:46 UTC
[asterisk-users] Static Realtime Select from Database
I did an ngrep trace of what Asterisk realtime static does when it queries the database. Here's what I saw SELECT category, var_name, var_val, cat_metric FROM rt_pbx1_sip_vw WHERE filename='sip.conf' and commented=0 ORDER BY filename, cat_metric desc, var_metric asc, category, var_name, var_val, id; Firstly, why does it order in DESCENDING order by cat_metric? Shouldn't it be ASCENDING order? The docs imply that you use cat_metric to specify the order that you want your contexts to appear. If Asterisk sorts in descending order, they will be reversed! Also, is cat_metric really required? For example, in the following set of data, rows for dundipbx1 are separated by rows for other contexts. Is Asterisk smart enough to know it has to combine this data into the one context? I realise that var_metric is useful in situations like deny/permit. +-----------+----------------+--------------------------+------------+ | category | var_name | var_val | cat_metric | +-----------+----------------+--------------------------+------------+ | dundipbx1 | context | syst_DUNDiPhoneMap | 0 | | dundipbx1 | deny | 0.0.0.0/0.0.0.0 | 0 | | dundipbx1 | secret | XXXXXXXXXXXXX | 0 | | dundipbx1 | type | user | 0 | | dundipbx1 | username | dundipbx1 | 0 | | dundipbx2 | deny | 0.0.0.0/0.0.0.0 | 0 | | dundipbx2 | fromuser | dundipbx2 | 0 | | dundipbx2 | host | pbx2.ipt.XXX.com | 0 | | dundipbx2 | secret | FBoAsFz3S8hFQ | 0 | | dundipbx2 | type | peer | 0 | | dundipbx2 | username | dundipbx2 | 0 | | dundipbx3 | deny | 0.0.0.0/0.0.0.0 | 0 | | dundipbx3 | fromuser | dundipbx3 | 0 | | dundipbx3 | host | pbx3.ipt.XXX.com | 0 | | dundipbx3 | permit | xxx.yyy.142.201 | 0 | | dundipbx3 | permit | xxx.yyy.142.203 | 0 | | dundipbx3 | permit | xxx.yyy.142.204 | 0 | | dundipbx3 | secret | XXXXXXXXXXXXX | 0 | | dundipbx3 | type | peer | 0 | | dundipbx3 | username | dundipbx3 | 0 | | general | allowguest | no | 0 | | general | autodomain | no | 0 | | general | bindaddr | xxx.yyy.142.203 | 0 | | general | bindport | 5060 | 0 | | dundipbx1 | permit | xxx.yyy.142.204 | 0 | | dundipbx2 | permit | xxx.yyy.142.203 | 0 | | general | allow | ulaw | 0 | +-----------+----------------+--------------------------+------------+ 81 rows in set (0.00 sec)