[Home]

Summary:ASTERISK-21794: CLI command 'realtime update2' syntax failure when using according to usage help
Reporter:Cedric BASSAGET (rico29)Labels:
Date Opened:2013-05-20 10:20:31Date Closed:2020-01-17 08:34:21.000-0600
Priority:MinorRegression?
Status:Closed/CompleteComponents:Resources/res_realtime
Versions:1.8.21.0 13.18.4 Frequency of
Occurrence
Constant
Related
Issues:
Environment:kernel 2.6.32-279.22.1.el6.centos.plus.x86_64 #1 SMP Wed Feb 6 05:16:56 UTC 2013 x86_64 x86_64 x86_64 GNU/LinuxAttachments:
Description:It seems it's not possible to reset a field from a mysql database to its default value or to {{NULL}} value with update2 :

CLI> realtime update2 sippeers name 100 deny "NULL" <- writes "NULL" as string in the field
CLI> realtime update2 sippeers name 100 deny NULL <- writes NULL as string in the field
CLI> realtime update2 sippeers name 100 deny DEFAULT <- writes DEFAULT as string in the field
Comments:By: Rusty Newton (rnewton) 2013-05-21 18:02:16.345-0500

I've not used this command before, but..

{noformat}
ubuntu*CLI> core show help realtime update2
Usage: realtime update2 <family> <colmatch> <valuematch> [... <colmatch5> <valuematch5>] NULL <colupdate> <newvalue>
  Update a single variable, requiring one or more fields to match using the
  RealTime driver.  You must supply a family name, a column to update, a new
  value, and at least one column and value to match.
  Ex: realtime update sippeers name bobsphone ipaddr 127.0.0.1 NULL port 4343
  will execute SQL as
  UPDATE sippeers SET port='4343' WHERE name='bobsphone' and ipaddr='127.0.0.1'
{noformat}

According to the usage you should be doing:

CLI> realtime update2 sippeers name 100 NULL deny NULL

What happens when you try it that way?

Hit 'Send Back' when you respond. Thanks!

By: Cedric BASSAGET (rico29) 2013-05-22 03:21:25.784-0500

Hi Rusty,

It gives me a syntax error :
{noformat}
*CLI> realtime update2 sippeers name 100.ocetest NULL deny NULL
Usage: realtime update2 <family> <colmatch> <valuematch> [... <colmatch5> <valuematch5>] NULL <colupdate> <newvalue>
  Update a single variable, requiring one or more fields to match using the
  RealTime driver.  You must supply a family name, a column to update, a new
  value, and at least one column and value to match.
  Ex: realtime update sippeers name bobsphone ipaddr 127.0.0.1 NULL port 4343
  will execute SQL as
  UPDATE sippeers SET port='4343' WHERE name='bobsphone' and ipaddr='127.0.0.1'
{noformat}


By: Rusty Newton (rnewton) 2013-05-22 18:54:13.886-0500

Well it looks like a dev needs to look into the syntax failure and then also look at the code to see if its expected that you can't write the NULL or DEFAULT values using update2. The documentation doesn't tell us. This may be undefined behavior.

Acknowledging this and setting to open.

By: Friendly Automation (friendly-automation) 2020-01-17 08:34:23.085-0600

Change 13593 merged by Friendly Automation:
res_realtime: Fix 'realtime update2' argument handling

[https://gerrit.asterisk.org/c/asterisk/+/13593|https://gerrit.asterisk.org/c/asterisk/+/13593]

By: Friendly Automation (friendly-automation) 2020-01-17 08:37:31.245-0600

Change 13626 merged by Joshua Colp:
res_realtime: Fix 'realtime update2' argument handling

[https://gerrit.asterisk.org/c/asterisk/+/13626|https://gerrit.asterisk.org/c/asterisk/+/13626]

By: Friendly Automation (friendly-automation) 2020-01-17 08:54:18.906-0600

Change 13627 merged by Joshua Colp:
res_realtime: Fix 'realtime update2' argument handling

[https://gerrit.asterisk.org/c/asterisk/+/13627|https://gerrit.asterisk.org/c/asterisk/+/13627]

By: Friendly Automation (friendly-automation) 2020-01-17 09:20:52.857-0600

Change 13628 merged by George Joseph:
res_realtime: Fix 'realtime update2' argument handling

[https://gerrit.asterisk.org/c/asterisk/+/13628|https://gerrit.asterisk.org/c/asterisk/+/13628]