[Home]

Summary:ASTERISK-15858: [patch] Fix query with double backslash in string literals and stop log warnings
Reporter:Humberto Figuera (korihor)Labels:
Date Opened:2010-03-22 21:49:10Date Closed:2017-02-21 06:18:38.000-0600
Priority:TrivialRegression?No
Status:Closed/CompleteComponents:Resources/res_config_pgsql
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) res_config_pgsql.c.patch
Description:The function realtime_multi_pgsql use "LIKE '\\_%'" when look for a pattern on realtime dialplan, that is a no standard use for "\\" in literal strings.

This causes the postgresql logfile to be filled with a lot of warnings.

The correct is use "LIKE E'\\_%'".

This patch too set a more consistent level of verbosity for a log entry.

****** ADDITIONAL INFORMATION ******

Asterisk 1.6.2.6
PostgreSQL 8.3.9
Comments:By: Rob Gagnon (rgagnon) 2011-04-18 11:20:54

The compiler will change "\\_%" into "\_%" which PGSQL will see as:

a literal underscore with the % matching character following it.  This is the intent of the calling routine to find something that starts with the underscore character in that field.

As far as the logging goes, do the other res_config modules also log not found information as DEBUG, instead of WARNING?



By: Humberto Figuera (korihor) 2011-04-18 11:57:32

http://www.postgresql.org/docs/8.4/static/release-8-1.html

"Currently PostgreSQL processes a backslash in a string literal as introducing a special escape sequence, e.g. \n or \010. While this allows easy entry of special values, it is nonstandard and makes porting of applications from other databases more difficult. For this reason, the PostgreSQL project is planning to remove the special meaning of backslashes in strings. For backward compatibility and for users who want special backslash processing, a new string syntax has been created. This new string syntax is formed by writing an E immediately preceding the single quote that starts the string, e.g. E'hi\n'. While this release does not change the handling of backslashes in strings, it does add new configuration parameters to help users migrate applications for future releases"

By: Rob Gagnon (rgagnon) 2011-04-18 12:00:30

This might now mean a new configuration value would have to be put into asterisk so users can indicate the version of postgresql in use, so that asterisk can then know if it is to use the old, or new format.

I would imagine that having the leading "E" in the strings under older pgsql implementations would break for them.

By: Humberto Figuera (korihor) 2011-04-18 12:03:57

the reason for E'' is that c-style escapes (such as \n) in strings does not comply with the SQL standard, and  PostgreSQL project is planning to remove the special meaning of backslashes in strings



By: Humberto Figuera (korihor) 2011-04-18 12:14:09

Who uses a version older than 8.2? ;)

By: Friendly Automation (friendly-automation) 2017-02-21 06:18:39.188-0600

Change 4978 merged by zuul:
realtime: Fix LIKE escaping in SQL backends

[https://gerrit.asterisk.org/4978|https://gerrit.asterisk.org/4978]

By: Friendly Automation (friendly-automation) 2017-02-21 06:18:42.100-0600

Change 4979 merged by zuul:
realtime: Fix LIKE escaping in SQL backends

[https://gerrit.asterisk.org/4979|https://gerrit.asterisk.org/4979]

By: Friendly Automation (friendly-automation) 2017-02-21 06:27:33.349-0600

Change 4980 merged by zuul:
realtime: Fix LIKE escaping in SQL backends

[https://gerrit.asterisk.org/4980|https://gerrit.asterisk.org/4980]