[Home]

Summary:ASTERISK-01558: dbget does not jump to pri n+101 for keys not found
Reporter:rich (rich)Labels:
Date Opened:2004-05-07 18:10:57Date Closed:2011-06-07 14:10:13
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:according to the documentation at
http://www.voip-info.org/wiki-Asterisk+cmd+DBget

[dbget] "Always returns 0. If the requested key is not found, jumps to priority n+101 if available."

Here's a patch that implements that behavior.

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

cvs diff -ub app_agi.c
Index: app_agi.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_agi.c,v
retrieving revision 1.38
diff -u -b -u -b -r1.38 app_agi.c
--- app_agi.c   4 May 2004 19:11:25 -0000       1.38
+++ app_agi.c   7 May 2004 21:55:28 -0000
@@ -829,11 +829,13 @@
       if (argc != 4)
               return RESULT_SHOWUSAGE;
       res = ast_db_get(argv[2], argv[3], tmp, sizeof(tmp));
-       if (res)
+       if (res) {
                       fdprintf(agi->fd, "200 result=0\n");
-       else
+                        chan->priority += 100;
+       } else {
                       fdprintf(agi->fd, "200 result=1 (%s)\n", tmp);

+       }
       return RESULT_SUCCESS;
}
Comments:By: Brian West (bkw918) 2004-05-07 18:11:25

Attach the diff -u please

By: Brian West (bkw918) 2004-05-07 18:13:31

-- Executing DBget("SIP/10-018e", "test=TEST/TEST") in new stack
   -- DBget: varname=test, family=TEST, key=TEST
   -- DBget: Value not found in database.
   -- Executing NoOp("SIP/10-018e", "We did go n+101") in new stack


Yes it does work right there.

By: Brian West (bkw918) 2004-05-07 18:15:39

exten => 1000,1,DBGet(test=TEST/TEST)
exten => 1000,102,NoOp,We did go n+101

By: rich (rich) 2004-05-07 18:24:26

Ack, I should have tested it before submitting.  Sorry... Here's a revised patch that's been tested successfully.


cvs diff -ub app_agi.c
Index: app_agi.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_agi.c,v
retrieving revision 1.38
diff -u -b -u -b -r1.38 app_agi.c
--- app_agi.c   4 May 2004 19:11:25 -0000       1.38
+++ app_agi.c   7 May 2004 22:18:22 -0000
@@ -829,11 +829,14 @@
       if (argc != 4)
               return RESULT_SHOWUSAGE;
       res = ast_db_get(argv[2], argv[3], tmp, sizeof(tmp));
-       if (res)
+       if (res) {
                       fdprintf(agi->fd, "200 result=0\n");
-       else
+                       if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid))
+                               chan->priority += 100;
+       } else {
                       fdprintf(agi->fd, "200 result=1 (%s)\n", tmp);

+       }
       return RESULT_SUCCESS;
}

By: twisted (twisted) 2004-05-07 19:36:15

Okay.. let me spell it out.  WE NEED A DIFF -U FILE, not just pasted text. Also, dbget DOES jump to n+101 here... ran a test equivalent to bkw's, and it worked fine.

By: rich (rich) 2004-05-07 20:34:33

OK, yes, it does jumpt to n+101.  Sorry for the needless report.  I hope I can submit something more useful next time.  Please feel free to close this!