diff options
author | Ted Trask <ttrask01@yahoo.com> | 2013-02-07 15:26:50 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2013-02-07 15:26:50 +0000 |
commit | 01ad30acf330d433f7f53cb0c13cf5f9eec596a9 (patch) | |
tree | 169038f634eafec466e555568854b25f43682c47 | |
parent | 39aff4fa37a6af7bfad8f5e0b2ebd192bf40c008 (diff) | |
download | acf-kamailio-01ad30acf330d433f7f53cb0c13cf5f9eec596a9.tar.bz2 acf-kamailio-01ad30acf330d433f7f53cb0c13cf5f9eec596a9.tar.xz |
Revert "Added postgres version check to determine if should escape backslash or not"
This reverts commit d98358c9c05802e79a8185e466c14a42aebd2c22.
-rw-r--r-- | kamailio-model.lua | 59 |
1 files changed, 22 insertions, 37 deletions
diff --git a/kamailio-model.lua b/kamailio-model.lua index be19643..944627c 100644 --- a/kamailio-model.lua +++ b/kamailio-model.lua @@ -16,7 +16,6 @@ local kamctlrc_file = "/etc/kamailio/kamctlrc" local env local con local DBENGINE -local escapebackslash = false -- ################################################################################ -- DATABASE FUNCTIONS @@ -32,34 +31,9 @@ end -- Escape special characters in sql statements local escape = function(sql) sql = sql or "" - if escapebackslash then - sql = string.gsub(sql, "\\", "\\\\") - end return string.gsub(sql, "'", "''") end -local runsqlcommand = function(sql) -logevent(sql) - assert(con:execute(sql)) -end - -local getselectresponse = function(sql) - local retval = {} -logevent(sql) - local cur = assert (con:execute(sql)) - local row = cur:fetch ({}, "a") - while row do - local tmp = {} - for name,val in pairs(row) do - tmp[name] = val - end - retval[#retval + 1] = tmp - row = cur:fetch (row, "a") - end - cur:close() - return retval -end - local databaseconnect = function() if not con then -- parse the kamctlrc file @@ -87,17 +61,6 @@ local databaseconnect = function() -- connect to data source con = assert(env:connect(config.DBNAME or "openser", config.DBRWUSER or "openser", config.DBRWPW or "openserrw", config.DBHOST, config.DBPORT)) - - -- Check the version for any special functionality - if DBENGINE == "PGSQL" then - local out = getselectresponse("SELECT version()") - local version = string.match(out[1].version, "([%d%.]+)") - local versionnum = tonumber(string.match(version, "%d+%.%d+")) - if versionnum < 9.1 then - escapebackslash = true - end - end - return true end return false @@ -114,6 +77,28 @@ local databasedisconnect = function() end end +local runsqlcommand = function(sql) +logevent(sql) + assert(con:execute(sql)) +end + +local getselectresponse = function(sql) + local retval = {} +logevent(sql) + local cur = assert (con:execute(sql)) + local row = cur:fetch ({}, "a") + while row do + local tmp = {} + for name,val in pairs(row) do + tmp[name] = val + end + retval[#retval + 1] = tmp + row = cur:fetch (row, "a") + end + cur:close() + return retval +end + local listtables = function() local result = {} if DBENGINE == "PGSQL" then |