res_sorcery_realtime: fix bug when successful UPDATE is treated as failed

If the SQL UPDATE statement changes nothing then SQLRowCount returns 0.
This value should be treated as success.
But the function sorcery_realtime_update treats it as failed.

This bug was found using stress tests on PJSIP.
If there are 2 consecutive SIP REGISTER requests with the same contact data
during 1 second then res_pjsip_registrar adds contact location on 1st request
and tries to update contact location on 2nd.
The update fails and res_pjsip_registrar even removes correct contact location.

The test "object_update_uncreated" was removed from test_sorcery_realtime.c
because it's now a valid situation.

This patch also adds missing debug of extra SQL parameter.

ASTERISK-26172 #close

Change-Id: I05a7f3051455336c9dda29efc229decf86071303
This commit is contained in:
Alexei Gradinari
2016-07-04 17:38:57 -04:00
parent 9e10aa8496
commit c832f100d9
3 changed files with 2 additions and 38 deletions

View File

@@ -137,6 +137,7 @@ static SQLHSTMT custom_prepare(struct odbc_obj *obj, void *data)
if (!ast_strlen_zero(cps->extra)) {
const char *newval = cps->extra;
ast_debug(1, "Parameter %d = '%s'\n", x, newval);
if (strchr(newval, ';') || strchr(newval, '^')) {
ENCODE_CHUNK(encodebuf, newval);
ast_string_field_set(cps, encoding[x], encodebuf);