[Asterisk-code-review] res_config_odbc: set empty extended field as a single whitespace (...asterisk[16])
George Joseph
asteriskteam at digium.com
Tue Mar 26 08:48:12 CDT 2019
George Joseph has submitted this change and it was merged. ( https://gerrit.asterisk.org/c/asterisk/+/11163 )
Change subject: res_config_odbc: set empty extended field as a single whitespace
......................................................................
res_config_odbc: set empty extended field as a single whitespace
If Realtime @ variable value is NULL or empty or contains only whitespaces
then when we try to retrieve it using PJSIP_ENDPOINT we get WARNING
pjsip_endpoint_function_read: Unknown property @my_var for PJSIP endpoint.
And the variable is missing in the result of CLI pjsip show endpoint.
This patch keeps empty sorcery extended field.
ASTERISK-28341 #close
Change-Id: I221fccc04cbfa2be17ce971f64ae0e74e465eea0
---
M res/res_config_odbc.c
1 file changed, 45 insertions(+), 21 deletions(-)
Approvals:
Sean Bright: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved; Approved for Submit
diff --git a/res/res_config_odbc.c b/res/res_config_odbc.c
index 09eff21..fd0078f 100644
--- a/res/res_config_odbc.c
+++ b/res/res_config_odbc.c
@@ -287,19 +287,34 @@
}
stringp = ast_str_buffer(rowdata);
- while (stringp) {
- chunk = strsep(&stringp, ";");
- if (!ast_strlen_zero(ast_strip(chunk))) {
- if (strchr(chunk, '^')) {
- decode_chunk(chunk);
+ if (!strncmp(coltitle, "@", 1)) {
+ /* The '@' prefix indicates it's a sorcery extended field.
+ * Because ast_load_realtime_fields eliminates empty entries and makes blank (single whitespace)
+ * entries empty and keeps them, the empty or NULL values are encoded
+ * as a string containing a single whitespace. */
+ if (prev) {
+ prev->next = ast_variable_new(coltitle, S_OR(stringp," "), "");
+ if (prev->next) {
+ prev = prev->next;
}
- if (prev) {
- prev->next = ast_variable_new(coltitle, chunk, "");
- if (prev->next) {
- prev = prev->next;
+ } else {
+ prev = var = ast_variable_new(coltitle, S_OR(stringp," "), "");
+ }
+ } else {
+ while (stringp) {
+ chunk = strsep(&stringp, ";");
+ if (!ast_strlen_zero(ast_strip(chunk))) {
+ if (strchr(chunk, '^')) {
+ decode_chunk(chunk);
}
- } else {
- prev = var = ast_variable_new(coltitle, chunk, "");
+ if (prev) {
+ prev->next = ast_variable_new(coltitle, chunk, "");
+ if (prev->next) {
+ prev = prev->next;
+ }
+ } else {
+ prev = var = ast_variable_new(coltitle, chunk, "");
+ }
}
}
}
@@ -451,17 +466,26 @@
goto next_sql_fetch;
}
stringp = ast_str_buffer(rowdata);
- while (stringp) {
- chunk = strsep(&stringp, ";");
- if (!ast_strlen_zero(ast_strip(chunk))) {
- if (strchr(chunk, '^')) {
- decode_chunk(chunk);
+ if (!strncmp(coltitle, "@", 1)) {
+ /* The '@' prefix indicates it's a sorcery extended field.
+ * Because ast_load_realtime_fields eliminates empty entries and makes blank (single whitespace)
+ * entries empty and keeps them, the empty or NULL values are encoded
+ * as a string containing a single whitespace. */
+ var = ast_variable_new(coltitle, S_OR(stringp," "), "");
+ ast_variable_append(cat, var);
+ } else {
+ while (stringp) {
+ chunk = strsep(&stringp, ";");
+ if (!ast_strlen_zero(ast_strip(chunk))) {
+ if (strchr(chunk, '^')) {
+ decode_chunk(chunk);
+ }
+ if (!strcmp(initfield, coltitle)) {
+ ast_category_rename(cat, chunk);
+ }
+ var = ast_variable_new(coltitle, chunk, "");
+ ast_variable_append(cat, var);
}
- if (!strcmp(initfield, coltitle)) {
- ast_category_rename(cat, chunk);
- }
- var = ast_variable_new(coltitle, chunk, "");
- ast_variable_append(cat, var);
}
}
}
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/11163
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I221fccc04cbfa2be17ce971f64ae0e74e465eea0
Gerrit-Change-Number: 11163
Gerrit-PatchSet: 3
Gerrit-Owner: Alexei Gradinari <alex2grad at gmail.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Sean Bright <sean.bright at gmail.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190326/159b9098/attachment.html>
More information about the asterisk-code-review
mailing list