summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-08-07 14:54:53 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-08-07 14:54:53 +0100
commit043e80725dbacdae4c9589e2558f4b33faf5776a (patch)
treef8208bdc181e952105e3ed7344b8e8256f0cce60
parentf7e05d2cca6f179a2f3f44175de2b7810458ae25 (diff)
downloadrspamd-043e80725dbacdae4c9589e2558f4b33faf5776a.tar.gz
rspamd-043e80725dbacdae4c9589e2558f4b33faf5776a.zip
[Minor] Fix various issues with the clickhouse support
-rw-r--r--lualib/lua_clickhouse.lua3
-rw-r--r--src/plugins/lua/clickhouse.lua14
2 files changed, 10 insertions, 7 deletions
diff --git a/lualib/lua_clickhouse.lua b/lualib/lua_clickhouse.lua
index 4be2c430f..37c9ebb7a 100644
--- a/lualib/lua_clickhouse.lua
+++ b/lualib/lua_clickhouse.lua
@@ -243,9 +243,10 @@ exports.insert = function (upstream, settings, params, query, rows,
http_params.no_ssl_verify = settings.no_ssl_verify
http_params.user = settings.user
http_params.password = settings.password
+ http_params.method = 'POST'
http_params.body = {table.concat(fun.totable(fun.map(function(row)
return row_to_tsv(row)
- end), rows), '\n'), '\n'}
+ end, rows)), '\n'), '\n'}
http_params.log_obj = params.task or params.config
if not http_params.url then
diff --git a/src/plugins/lua/clickhouse.lua b/src/plugins/lua/clickhouse.lua
index 3eebd5b5d..b54c1a216 100644
--- a/src/plugins/lua/clickhouse.lua
+++ b/src/plugins/lua/clickhouse.lua
@@ -181,7 +181,7 @@ local function clickhouse_main_row(tname)
'ListId',
'Digest'
}
- local elt = string.format('INSERT INTO %s (%s) VALUES ',
+ local elt = string.format('INSERT INTO %s (%s) ',
tname, table.concat(fields, ','))
return elt
@@ -196,7 +196,7 @@ local function clickhouse_attachments_row(tname)
'Attachments.Length',
'Attachments.Digest',
}
- local elt = string.format('INSERT INTO %s (%s) VALUES ',
+ local elt = string.format('INSERT INTO %s (%s) ',
tname, table.concat(attachement_fields, ','))
return elt
end
@@ -208,7 +208,7 @@ local function clickhouse_urls_row(tname)
'Urls.Tld',
'Urls.Url',
}
- local elt = string.format('INSERT INTO %s (%s) VALUES ',
+ local elt = string.format('INSERT INTO %s (%s) ',
tname, table.concat(urls_fields, ','))
return elt
end
@@ -219,7 +219,7 @@ local function clickhouse_emails_row(tname)
'Digest',
'Emails',
}
- local elt = string.format('INSERT INTO %s (%s) VALUES ',
+ local elt = string.format('INSERT INTO %s (%s) ',
tname, table.concat(emails_fields, ','))
return elt
end
@@ -232,7 +232,7 @@ local function clickhouse_symbols_row(tname)
'Symbols.Scores',
'Symbols.Options',
}
- local elt = string.format('INSERT INTO %s (%s) VALUES ',
+ local elt = string.format('INSERT INTO %s (%s) ',
tname, table.concat(symbols_fields, ','))
return elt
end
@@ -245,7 +245,7 @@ local function clickhouse_asn_row(tname)
'Country',
'IPNet',
}
- local elt = string.format('INSERT INTO %s (%s) VALUES ',
+ local elt = string.format('INSERT INTO %s (%s) ',
tname, table.concat(asn_fields, ','))
return elt
end
@@ -293,6 +293,7 @@ local function clickhouse_send_data(task)
local ch_params = {
task = task,
}
+
local ret = lua_clickhouse.insert(upstream, settings, ch_params,
query, tbl,
gen_success_cb(what, #tbl),
@@ -657,6 +658,7 @@ local function clickhouse_collect(task)
end
nrows = nrows + 1
+ rspamd_logger.debugm(N, task, "add clickhouse row %s / %s", nrows, settings.limit)
if nrows > settings['limit'] then
clickhouse_send_data(task)