commit 340d2e5: [Minor] Clickhouse: Fix text returns
Vsevolod Stakhov
vsevolod at highsecure.ru
Thu Nov 26 14:35:07 UTC 2020
Author: Vsevolod Stakhov
Date: 2020-11-26 14:32:42 +0000
URL: https://github.com/rspamd/rspamd/commit/340d2e50d3fed6514a26566612534c384a008f4c (HEAD -> master)
[Minor] Clickhouse: Fix text returns
---
lualib/lua_clickhouse.lua | 7 +++++--
src/plugins/lua/clickhouse.lua | 2 +-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/lualib/lua_clickhouse.lua b/lualib/lua_clickhouse.lua
index e532cd643..4e20229b0 100644
--- a/lualib/lua_clickhouse.lua
+++ b/lualib/lua_clickhouse.lua
@@ -74,10 +74,13 @@ end
local function row_to_tsv(row)
for i,elt in ipairs(row) do
- if type(elt) == 'table' then
+ local t = type(elt)
+ if t == 'table' then
row[i] = '[' .. array_to_string(elt) .. ']'
- elseif type(elt) == 'number' then
+ elseif t == 'number' then
row[i] = ch_number(elt)
+ elseif t == 'userdata' then
+ row[i] = clickhouse_quote(tostring(elt))
else
row[i] = clickhouse_quote(elt)
end
diff --git a/src/plugins/lua/clickhouse.lua b/src/plugins/lua/clickhouse.lua
index c9d0c71cc..3ee4eeb73 100644
--- a/src/plugins/lua/clickhouse.lua
+++ b/src/plugins/lua/clickhouse.lua
@@ -851,10 +851,10 @@ local function clickhouse_collect(task)
table.insert(custom_rows[k], lua_clickhouse.row_to_tsv(rule.get_row(task)))
end
- nrows = nrows + 1
local tsv_row = lua_clickhouse.row_to_tsv(row)
used_memory = used_memory + #tsv_row
data_rows[#data_rows + 1] = tsv_row
+ nrows = nrows + 1
lua_util.debugm(N, task,
"add clickhouse row %s / %s; used memory: %s / %s",
nrows, settings.limits.max_rows,
More information about the Commits
mailing list