This reverts commit a3a2fbaec6.
Reason for revert: There is a lot of code that relies on the broken
behavior that this fixes.
Change-Id: I410c395a0168acbdaf89e616e3cb5e1312d190cb
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
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
Rather than calling ast_odbc_find_table() in the prepare callback, call
it beforehand and pass it in to the callback to avoid the need for a
second connection.
ASTERISK-28166 #close
Change-Id: I6f8a0b9990d636fd6bc1a92ed70f7050d2436202
When Asterisk is connected and used with a database the response
time of the database can cause problems in Asterisk if it is long.
Normally the only way to see this problem would be to retrieve a
backtrace from Asterisk and examine where things are blocked, or
examine the database to see if there is any indication of a
problem.
This change adds some basic query logging to make it easier to
investigate such a problem. When logging is enabled res_odbc will
now keep track of the number of queries executed, as well as the
query that has taken the longest time to execute. There is also
an option which will cause a WARNING message to be output if a
query takes longer than a configurable amount of time to execute.
This makes it easier and clearer for users that their database may
be experiencing a problem that could impact Asterisk.
ASTERISK-28277
Change-Id: I173cf4928b10754478a6a8c27dfa96ede0f058a6
On SQL error there is not diagnostic information about this error.
There is only
WARNING res_odbc.c: SQL Execute error -1!
The function ast_odbc_print_errors calls a SQLGetDiagField to get the number
of available diagnostic records, but the SQLGetDiagField returns 0.
However SQLGetDiagRec could return one diagnostic records in this case.
Looking at many example of getting diagnostics error information
I found out that the best way it's to use only SQLGetDiagRec
while it returns SQL_SUCCESS.
Also this patch adds calls of ast_odbc_print_errors on SQL_ERROR
to res_config_odbc.
ASTERISK-28065 #close
Change-Id: Iba5ae5470ac49ecd911dd084effbe9efac68ccc1
* acl (named_acl.c)
* cdr
* cel
* ccss
* dnsmgr
* dsp
* enum
* extconfig (config.c)
* features
* http
* indications
* logger
* manager
* plc
* sounds
* udptl
These modules are now loaded at appropriate time by the module loader.
Unlike loadable modules these use AST_MODULE_LOAD_FAILURE on error so
the module loader will abort startup on failure of these modules.
Some of these modules are still initialized or shutdown from outside the
module loader. logger.c is initialized very early and shutdown very
late, manager.c is initialized by the module loader but is shutdown by
the Asterisk core (too much uses it without holding references).
Change-Id: I371a9a45064f20026c492623ea8062d02a1ab97f
All of the realtime backends create artificial ast_categorys to pass
back into the core as query results. These categories have no filename
or line number information associated with them and the backends differ
slightly on how they create them. So create a couple helper macros to
help make things more consistent.
Also updated the call sites to remove redundant error messages about
memory allocation failure.
Note that res_config_ldap sets the category filename to the 'table name'
but that is not read by anything in the core, so I've dropped it.
Change-Id: I3a1fd91e0c807dea1ce3b643b0a6fe5be9002897
ASTERISK_REGISTER_FILE no longer has any purpose so this commit removes
all traces of it.
Previously exported symbols removed:
* __ast_register_file
* __ast_unregister_file
* ast_complete_source_filename
This also removes the mtx_prof static variable that was declared when
MTX_PROFILE was enabled. This variable was only used in lock.c so it
is now initialized in that file only.
ASTERISK-26480 #close
Change-Id: I1074af07d71f9e159c48ef36631aa432c86f9966
Creating ODBC SQL queries resulted in queries too large to fit into the
supplied buffer. The resulting truncated buffer contained an invalid SQL
query.
* Made SQL query generation code use a thread storage buffer that can
increase in size as needed.
* Fixed bad multi-line warning messages.
ASTERISK-26263 #close
Reported by: Jeppe Ryskov Larsen
Change-Id: I23f3cdd43c2dac80bed3ded4dd77d18cb17f21ae
If the SQL UPDATE statement changes nothing then SQLRowCount returns 0.
This value should be treated as success.
But the function sorcery_realtime_update treats it as failed.
This bug was found using stress tests on PJSIP.
If there are 2 consecutive SIP REGISTER requests with the same contact data
during 1 second then res_pjsip_registrar adds contact location on 1st request
and tries to update contact location on 2nd.
The update fails and res_pjsip_registrar even removes correct contact location.
The test "object_update_uncreated" was removed from test_sorcery_realtime.c
because it's now a valid situation.
This patch also adds missing debug of extra SQL parameter.
ASTERISK-26172 #close
Change-Id: I05a7f3051455336c9dda29efc229decf86071303
Git does not support the ability to replace a token with a version
string during check-in. While it does have support for replacing a
token on clone, this is somewhat sub-optimal: the token is replaced
with the object hash, which is not particularly easy for human
consumption. What's more, in practice, the source file version was often
not terribly useful. Generally, when triaging bugs, the overall version
of Asterisk is far more useful than an individual SVN version of a file. As a
result, this patch removes Asterisk's support for showing source file
versions.
Specifically, it does the following:
* Rename ASTERISK_FILE_VERSION macro to ASTERISK_REGISTER_FILE, and
remove passing the version in with the macro. Other facilities
than 'core show file version' make use of the file names, such as
setting a debug level only on a specific file. As such, the act of
registering source files with the Asterisk core still has use. The
macro rename now reflects the new macro purpose.
* main/asterisk:
- Refactor the file_version structure to reflect that it no longer
tracks a version field.
- Remove the "core show file version" CLI command. Without the file
version, it is no longer useful.
- Remove the ast_file_version_find function. The file version is no
longer tracked.
- Rename ast_register_file_version/ast_unregister_file_version to
ast_register_file/ast_unregister_file, respectively.
* main/manager: Remove value from the Version key of the ModuleCheck
Action. The actual key itself has not been removed, as doing so would
absolutely constitute a backwards incompatible change. However, since
the file version is no longer tracked, there is no need to attempt to
include it in the Version key.
* UPGRADE: Add notes for:
- Modification to the ModuleCheck AMI Action
- Removal of the "core show file version" CLI command
Change-Id: I6cf0ff280e1668bf4957dc21f32a5ff43444a40e
When escaping backslashes with MySQL, the proper way to escape the characters
in a LIKE clause is to escape the '\' four times, i.e., '\\\\'. To quote the
MySQL manual:
"Because MySQL uses C escape syntax in strings (for example, “\n” to represent
a newline character), you must double any “\” that you use in LIKE strings.
For example, to search for “\n”, specify it as “\\n”. To search for “\”,
specify it as “\\\\”; this is because the backslashes are stripped once by the
parser and again when the pattern match is made, leaving a single backslash to
be matched against."
ASTERISK-24808 #close
Reported by: Javier Acosta
patches:
res_config_odbc.diff uploaded by Javier Acosta (License 6690)
........
Merged revisions 432720 from http://svn.asterisk.org/svn/asterisk/branches/11
........
Merged revisions 432721 from http://svn.asterisk.org/svn/asterisk/branches/13
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432722 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This patch addresses some aesthetic issues in Asterisk. These are all just
minor tweaks to improve the look of the CLI when used in a variety of
settings. Specifically:
* A number of chatty verbose messages were removed or demoted to DEBUG
messages. Verbose messages with a verbosity level of 5 or higher were -
if kept as verbose messages - demoted to level 4. Several messages
that were emitted at verbose level 3 were demoted to 4, as announcement
of dialplan applications being executed occur at level 3 (and so the
effects of those applications should generally be less).
* Some verbose messages that only appear when their respective 'debug'
options are enabled were bumped up to always be displayed.
* Prefix/timestamping of verbose messages were moved to the verboser
handlers. This was done to prevent duplication of prefixes when the
timestamp option (-T) is used with the CLI.
* Verbose magic is removed from messages before being emitted to
non-verboser handlers. This prevents the magic in multi-line verbose
messages (such as SIP debug traces or the output of DumpChan) from
being written to files.
* _Slightly_ better support for the "light background" option (-W) was
added. This includes using ast_term_quit in the output of XML
documentation help, as well as changing the "Asterisk Ready" prompt to
bright green on the default background (which stands a better chance of
being displayed properly than bright white).
Review: https://reviewboard.asterisk.org/r/3547/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@414798 65c4cc65-6c06-0410-ace0-fbb531ad65f3
The ODBC realtime driver uses ^NN parameter encoding to cope with the
special meaning of the semi-colon. A semi-colon in a field is
interpreted as if the key was supplied twice, something which isn't
otherwise possible with fixed database columns. E.g. allow=alaw;ulaw
is parsed as allow=alaw and allow=ulaw. A literal semi-colon is
rewritten to ^3B when stored in the database.
The module uses a stringfield to efficiently store the encoded
parameters. However, this stringfield wasn't always freed in some
off-nominal cases.
Commit r413241 fixed initialization so the encoding for INSERT and
DELETE queries wouldn't crash. (Only SELECTs and UPDATEs worked
apparently.) But that commit forgot the frees. This change cleans
that up.
Review: https://reviewboard.asterisk.org/r/3555/
........
Merged revisions 414564 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 414565 from http://svn.asterisk.org/svn/asterisk/branches/11
........
Merged revisions 414566 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@414567 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This patch fixes setting nullable integer columns to NULL instead of an empty
string, which fails for PostgreSQL, for example. The current code is supposed
to do so, but the check is broken. The patch also allows the first column in
the list to be a nullable integer.
Also, the check for existence of a mandatory column checked for the first
column in the list instead of the key field lookup column. This patch fixes
that issue as well.
Finally, the compatibility option allow_empty_string_in_nontext, which was
added to previous revisions to allow for some database backends with certain
schemas to function, has been removed.
Review: https://reviewboard.asterisk.org/r/3335
ASTERISK-23459 #close
ASTERISK-23351 #close
(closes issue ASTERISK-23459)
Reported by: zvision
patches:
res_config_odbc.diff uploaded by zvision (License 5755)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@411515 65c4cc65-6c06-0410-ace0-fbb531ad65f3
After the merge of support for the realtime sorcery module, extensions that
contained a pattern were not being found through odbc realtime. It was tracked
down to this one line that was advancing to the next variable list before it
should have been. The removal of this one line fixes this.
Tested this fix on my machine.
Received confirmation that this is the right fix from file on IRC.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@388375 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This change does the following:
1. Adds the sorcery realtime module
2. Adds unit tests for the sorcery realtime module
3. Changes the realtime core to use an ast_variable list instead of variadic arguments
4. Changes all realtime drivers to accept an ast_variable list
Review: https://reviewboard.asterisk.org/r/2424/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@386731 65c4cc65-6c06-0410-ace0-fbb531ad65f3
A number of va_copy operations weren't matched with a corresponding va_end in res_config_odbc. Also, there was a potential for va_end to be invoked twice on the same va_arg in utils, which would mean invoking va_end on an undefined variable... which is bad.
va_end is removed from various functions in config_pgsql and config_curl since they aren't making their own copy. The invokers of those functions are responsible for calling va_end on them.
(issue ASTERISK-19451)
Reported by: Walter Doekes
Review: https://reviewboard.asterisk.org/r/1848/
........
Merged revisions 362354 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 362357 from http://svn.asterisk.org/svn/asterisk/branches/10
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@362363 65c4cc65-6c06-0410-ace0-fbb531ad65f3
https://origsvn.digium.com/svn/asterisk/branches/10
................
r334230 | tilghman | 2011-09-01 12:30:19 -0500 (Thu, 01 Sep 2011) | 25 lines
Merged revisions 334229 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
........
r334229 | tilghman | 2011-09-01 12:28:09 -0500 (Thu, 01 Sep 2011) | 18 lines
Create a local alias for ast_odbc_clear_cache.
As a function pointer, the reference has to be resolved at load time
irrespective of the RTLD_LAZY flag. Creating a local alias solves
this problem, because the structure is initialized with that local
function pointer, while the actual function can remain lazily linked
until runtime.
The reason why this is important is because we lazily load function
references during the module loading process, in order to obtain
priority values for each module, ensuring that modules are loaded in
the correct order. Previous to this change, when this module was
initially loaded, the module loader would emit a symbol resolution
error, because of the above requirement.
Closes ASTERISK-18399 (reported by Mikael Carlsson, fix suggested by
Walter Doekes, patch by me)
........
................
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@334231 65c4cc65-6c06-0410-ace0-fbb531ad65f3
https://origsvn.digium.com/svn/asterisk/branches/1.8
........
r326689 | jrose | 2011-07-07 11:04:51 -0500 (Thu, 07 Jul 2011) | 10 lines
res_odbc patch by tilghman to fix integers with null values
Addresses some improper sql statements in res_odbc that would cause an update to fail on
realtime peers due to trying to set as "(NULL)" rather than an actual NULL.
(closes issue #1922STERISK-17791)
Reported by: marcelloceschia
Patches:
20110505__issue19223.diff.txt uploaded by tilghman (license 14)
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@326694 65c4cc65-6c06-0410-ace0-fbb531ad65f3
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r277568 | tilghman | 2010-07-16 16:54:29 -0500 (Fri, 16 Jul 2010) | 8 lines
Since we split values at the semicolon, we should store values with a semicolon as an encoded value.
(closes issue #17369)
Reported by: gkservice
Patches:
20100625__issue17369.diff.txt uploaded by tilghman (license 14)
Tested by: tilghman
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@277773 65c4cc65-6c06-0410-ace0-fbb531ad65f3
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r182808 | kpfleming | 2009-03-17 20:55:22 -0500 (Tue, 17 Mar 2009) | 5 lines
Improve the build system to *properly* remove unnecessary symbols from the runtime global namespace. Along the way, change the prefixes on some internal-only API calls to use a common prefix.
With these changes, for a module to export symbols into the global namespace, it must have *both* the AST_MODFLAG_GLOBAL_SYMBOLS flag and a linker script that allows the linker to leave the symbols exposed in the module's .so file (see res_odbc.exports for an example).
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@182826 65c4cc65-6c06-0410-ace0-fbb531ad65f3