Skip to content

Commit 35119cd

Browse files
committed
Adding possibility to activate SQL_NO_CACHE in SELECT statements
1 parent 53d7de3 commit 35119cd

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

debug-blind.lua

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,27 @@
1616
-- You should have received a copy of the GNU General Public License
1717
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
1818

19+
use_sql_no_cache = 0
20+
21+
function nocache(query)
22+
local word = string.upper(string.sub(query,1,6))
23+
if ( word == "SELECT" ) then
24+
query = "SELECT SQL_NO_CACHE" .. query:sub(7)
25+
end
26+
return query
27+
end
28+
1929
transaction_counter = 0
2030

2131
function read_query( packet )
2232
if packet:byte() ~= proxy.COM_QUERY then
2333
return
2434
end
25-
proxy.queries:append(1, string.char(proxy.COM_QUERY) .. packet:sub(2), {resultset_is_needed = true})
35+
local query = packet:sub(2)
36+
if ( use_sql_no_cache == 1 ) then
37+
query = nocache(query)
38+
end
39+
proxy.queries:append(1, string.char(proxy.COM_QUERY) .. query, {resultset_is_needed = true})
2640

2741
return proxy.PROXY_SEND_QUERY
2842
end

debug.lua

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,27 @@
1616
-- You should have received a copy of the GNU General Public License
1717
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
1818

19+
use_sql_no_cache = 0
20+
21+
function nocache(query)
22+
local word = string.upper(string.sub(query,1,6))
23+
if ( word == "SELECT" ) then
24+
query = "SELECT SQL_NO_CACHE" .. query:sub(7)
25+
end
26+
return query
27+
end
28+
1929
transaction_counter = 0
2030

2131
function read_query( packet )
2232
if packet:byte() ~= proxy.COM_QUERY then
2333
return
2434
end
25-
proxy.queries:append(1, string.char(proxy.COM_QUERY) .. packet:sub(2), {resultset_is_needed = true})
35+
local query = packet:sub(2)
36+
if ( use_sql_no_cache == 1 ) then
37+
query = nocache(query)
38+
end
39+
proxy.queries:append(1, string.char(proxy.COM_QUERY) .. query, {resultset_is_needed = true})
2640

2741
return proxy.PROXY_SEND_QUERY
2842
end

0 commit comments

Comments
 (0)