[Asterisk-code-review] res_config_odbc: Preserve empty strings returned by the database (asterisk[master])
Friendly Automation
asteriskteam at digium.com
Wed Feb 5 10:40:22 CST 2020
Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/13712 )
Change subject: res_config_odbc: Preserve empty strings returned by the database
......................................................................
res_config_odbc: Preserve empty strings returned by the database
When res_config_odbc (and perhaps other realtime backends) reads a SQL
NULL from the database, it coalesces the value to the empty string
which prevents it from being returned to the realtime core.
However, if it instead reads the empty string from the database, it
needs a way to encode that fact without having the value omitted
entirely. It does this by changing the value to a string with a single
space. The realtime code in main/config.c recognizes this special case
and _turns the string back into the empty string_ before passing it to
realtime API consumers.
For all of this to work, we need to ensure that we actually pass the
single-space-string back to the realtime core, which is currently
failing because we are trimming the value before checking its
content. So instead we now special case the single-space-string case
so that empty values are returned properly.
ASTERISK-28719 #close
Reported by: EDV O-TON
Change-Id: I673ed8c31ad037aa224e80c78c7a1dc4e4a4e3de
---
M res/res_config_odbc.c
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Joshua Colp: Looks good to me, but someone else must approve
Benjamin Keith Ford: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Friendly Automation: Approved for Submit
diff --git a/res/res_config_odbc.c b/res/res_config_odbc.c
index fd0078f..45bb214 100644
--- a/res/res_config_odbc.c
+++ b/res/res_config_odbc.c
@@ -303,7 +303,7 @@
} else {
while (stringp) {
chunk = strsep(&stringp, ";");
- if (!ast_strlen_zero(ast_strip(chunk))) {
+ if (!strcmp(chunk, " ") || !ast_strlen_zero(ast_strip(chunk))) {
if (strchr(chunk, '^')) {
decode_chunk(chunk);
}
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/13712
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I673ed8c31ad037aa224e80c78c7a1dc4e4a4e3de
Gerrit-Change-Number: 13712
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200205/9ec2e6e3/attachment.html>
More information about the asterisk-code-review
mailing list