mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-13 00:04:53 +00:00
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
This commit is contained in:
@@ -287,19 +287,34 @@ static struct ast_variable *realtime_odbc(const char *database, const char *tabl
|
|||||||
}
|
}
|
||||||
|
|
||||||
stringp = ast_str_buffer(rowdata);
|
stringp = ast_str_buffer(rowdata);
|
||||||
while (stringp) {
|
if (!strncmp(coltitle, "@", 1)) {
|
||||||
chunk = strsep(&stringp, ";");
|
/* The '@' prefix indicates it's a sorcery extended field.
|
||||||
if (!ast_strlen_zero(ast_strip(chunk))) {
|
* Because ast_load_realtime_fields eliminates empty entries and makes blank (single whitespace)
|
||||||
if (strchr(chunk, '^')) {
|
* entries empty and keeps them, the empty or NULL values are encoded
|
||||||
decode_chunk(chunk);
|
* 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) {
|
} else {
|
||||||
prev->next = ast_variable_new(coltitle, chunk, "");
|
prev = var = ast_variable_new(coltitle, S_OR(stringp," "), "");
|
||||||
if (prev->next) {
|
}
|
||||||
prev = prev->next;
|
} else {
|
||||||
|
while (stringp) {
|
||||||
|
chunk = strsep(&stringp, ";");
|
||||||
|
if (!ast_strlen_zero(ast_strip(chunk))) {
|
||||||
|
if (strchr(chunk, '^')) {
|
||||||
|
decode_chunk(chunk);
|
||||||
|
}
|
||||||
|
if (prev) {
|
||||||
|
prev->next = ast_variable_new(coltitle, chunk, "");
|
||||||
|
if (prev->next) {
|
||||||
|
prev = prev->next;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
prev = var = ast_variable_new(coltitle, chunk, "");
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
prev = var = ast_variable_new(coltitle, chunk, "");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -451,17 +466,26 @@ static struct ast_config *realtime_multi_odbc(const char *database, const char *
|
|||||||
goto next_sql_fetch;
|
goto next_sql_fetch;
|
||||||
}
|
}
|
||||||
stringp = ast_str_buffer(rowdata);
|
stringp = ast_str_buffer(rowdata);
|
||||||
while (stringp) {
|
if (!strncmp(coltitle, "@", 1)) {
|
||||||
chunk = strsep(&stringp, ";");
|
/* The '@' prefix indicates it's a sorcery extended field.
|
||||||
if (!ast_strlen_zero(ast_strip(chunk))) {
|
* Because ast_load_realtime_fields eliminates empty entries and makes blank (single whitespace)
|
||||||
if (strchr(chunk, '^')) {
|
* entries empty and keeps them, the empty or NULL values are encoded
|
||||||
decode_chunk(chunk);
|
* 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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user