<p>George Joseph <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/11163">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Sean Bright: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved; Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_config_odbc: set empty extended field as a single whitespace<br><br>If Realtime @ variable value is NULL or empty or contains only whitespaces<br>then when we try to retrieve it using PJSIP_ENDPOINT we get WARNING<br>pjsip_endpoint_function_read: Unknown property @my_var for PJSIP endpoint.<br>And the variable is missing in the result of CLI pjsip show endpoint.<br><br>This patch keeps empty sorcery extended field.<br><br>ASTERISK-28341 #close<br><br>Change-Id: I221fccc04cbfa2be17ce971f64ae0e74e465eea0<br>---<br>M res/res_config_odbc.c<br>1 file changed, 45 insertions(+), 21 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_config_odbc.c b/res/res_config_odbc.c</span><br><span>index 09eff21..fd0078f 100644</span><br><span>--- a/res/res_config_odbc.c</span><br><span>+++ b/res/res_config_odbc.c</span><br><span>@@ -287,19 +287,34 @@</span><br><span> }</span><br><span> </span><br><span> stringp = ast_str_buffer(rowdata);</span><br><span style="color: hsl(0, 100%, 40%);">- while (stringp) {</span><br><span style="color: hsl(0, 100%, 40%);">- chunk = strsep(&stringp, ";");</span><br><span style="color: hsl(0, 100%, 40%);">- if (!ast_strlen_zero(ast_strip(chunk))) {</span><br><span style="color: hsl(0, 100%, 40%);">- if (strchr(chunk, '^')) {</span><br><span style="color: hsl(0, 100%, 40%);">- decode_chunk(chunk);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!strncmp(coltitle, "@", 1)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* The '@' prefix indicates it's a sorcery extended field.</span><br><span style="color: hsl(120, 100%, 40%);">+ * Because ast_load_realtime_fields eliminates empty entries and makes blank (single whitespace)</span><br><span style="color: hsl(120, 100%, 40%);">+ * entries empty and keeps them, the empty or NULL values are encoded</span><br><span style="color: hsl(120, 100%, 40%);">+ * as a string containing a single whitespace. */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (prev) {</span><br><span style="color: hsl(120, 100%, 40%);">+ prev->next = ast_variable_new(coltitle, S_OR(stringp," "), "");</span><br><span style="color: hsl(120, 100%, 40%);">+ if (prev->next) {</span><br><span style="color: hsl(120, 100%, 40%);">+ prev = prev->next;</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">- if (prev) {</span><br><span style="color: hsl(0, 100%, 40%);">- prev->next = ast_variable_new(coltitle, chunk, "");</span><br><span style="color: hsl(0, 100%, 40%);">- if (prev->next) {</span><br><span style="color: hsl(0, 100%, 40%);">- prev = prev->next;</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ prev = var = ast_variable_new(coltitle, S_OR(stringp," "), "");</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ while (stringp) {</span><br><span style="color: hsl(120, 100%, 40%);">+ chunk = strsep(&stringp, ";");</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_strlen_zero(ast_strip(chunk))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (strchr(chunk, '^')) {</span><br><span style="color: hsl(120, 100%, 40%);">+ decode_chunk(chunk);</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">- } else {</span><br><span style="color: hsl(0, 100%, 40%);">- prev = var = ast_variable_new(coltitle, chunk, "");</span><br><span style="color: hsl(120, 100%, 40%);">+ if (prev) {</span><br><span style="color: hsl(120, 100%, 40%);">+ prev->next = ast_variable_new(coltitle, chunk, "");</span><br><span style="color: hsl(120, 100%, 40%);">+ if (prev->next) {</span><br><span style="color: hsl(120, 100%, 40%);">+ prev = prev->next;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ prev = var = ast_variable_new(coltitle, chunk, "");</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> }</span><br><span> }</span><br><span> }</span><br><span>@@ -451,17 +466,26 @@</span><br><span> goto next_sql_fetch;</span><br><span> }</span><br><span> stringp = ast_str_buffer(rowdata);</span><br><span style="color: hsl(0, 100%, 40%);">- while (stringp) {</span><br><span style="color: hsl(0, 100%, 40%);">- chunk = strsep(&stringp, ";");</span><br><span style="color: hsl(0, 100%, 40%);">- if (!ast_strlen_zero(ast_strip(chunk))) {</span><br><span style="color: hsl(0, 100%, 40%);">- if (strchr(chunk, '^')) {</span><br><span style="color: hsl(0, 100%, 40%);">- decode_chunk(chunk);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!strncmp(coltitle, "@", 1)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* The '@' prefix indicates it's a sorcery extended field.</span><br><span style="color: hsl(120, 100%, 40%);">+ * Because ast_load_realtime_fields eliminates empty entries and makes blank (single whitespace)</span><br><span style="color: hsl(120, 100%, 40%);">+ * entries empty and keeps them, the empty or NULL values are encoded</span><br><span style="color: hsl(120, 100%, 40%);">+ * as a string containing a single whitespace. */</span><br><span style="color: hsl(120, 100%, 40%);">+ var = ast_variable_new(coltitle, S_OR(stringp," "), "");</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_variable_append(cat, var);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ while (stringp) {</span><br><span style="color: hsl(120, 100%, 40%);">+ chunk = strsep(&stringp, ";");</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_strlen_zero(ast_strip(chunk))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (strchr(chunk, '^')) {</span><br><span style="color: hsl(120, 100%, 40%);">+ decode_chunk(chunk);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!strcmp(initfield, coltitle)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_category_rename(cat, chunk);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ var = ast_variable_new(coltitle, chunk, "");</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_variable_append(cat, var);</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">- if (!strcmp(initfield, coltitle)) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_category_rename(cat, chunk);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- var = ast_variable_new(coltitle, chunk, "");</span><br><span style="color: hsl(0, 100%, 40%);">- ast_variable_append(cat, var);</span><br><span> }</span><br><span> }</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/11163">change 11163</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/11163"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: I221fccc04cbfa2be17ce971f64ae0e74e465eea0 </div>
<div style="display:none"> Gerrit-Change-Number: 11163 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: Alexei Gradinari <alex2grad@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>