Skip to content
Snippets Groups Projects
Commit b6574768 authored by Arseniy Volynets's avatar Arseniy Volynets :boy_tone5:
Browse files

fix: vtable max rows limit not applied

- We didn't apply vtable max rows value
when executing local sql. We tried to lookup
it in the execute options hashmap and took
the default value instead, though it was
not stored in the hashmap.
parent 18f4db0d
No related branches found
No related tags found
1 merge request!1414sbroad import
......@@ -137,6 +137,16 @@ option_queries.test_vtable_max_rows_on_storage = function()
r, err = api:call("sbroad.execute", { query_str .. [[ option(vtable_max_rows = 6) ]] })
t.assert_equals(err, nil)
t.assert_equals(r, { row_count = 6 })
query_str = [[delete from "testing_space" ]]
_, err = api:call("sbroad.execute", { query_str .. [[option(vtable_max_rows = 1) ]] })
-- we can't test whole error message
-- because on different storages there will be different amount
t.assert_str_contains(err, [[Exceeded maximum number of rows (1) in virtual table]])
r, err = api:call("sbroad.execute", { query_str .. [[ option(vtable_max_rows = 12) ]] })
t.assert_equals(err, nil)
t.assert_equals(r, { row_count = 12 })
end
option_queries.test_vtable_max_rows_insert_values = function()
......
......@@ -1294,7 +1294,7 @@ impl RequiredPlanInfo for QueryInfo<'_> {
}
fn vtable_max_rows(&self) -> u64 {
self.required.options.execute_options.vtable_max_rows()
self.required.options.vtable_max_rows
}
fn extract_data(&mut self) -> EncodedTables {
......@@ -1342,7 +1342,7 @@ impl RequiredPlanInfo for EncodedQueryInfo<'_> {
}
fn vtable_max_rows(&self) -> u64 {
self.required.options.execute_options.vtable_max_rows()
self.required.options.vtable_max_rows
}
fn extract_data(&mut self) -> EncodedTables {
......
......@@ -154,8 +154,7 @@ fn repack_data(
let rows = rmpv::ext::from_value::<Vec<rmpv::Value>>(data).expect("failed to decode DQL data");
if rows.len() as u64 > max_rows {
return Err(SbroadError::UnexpectedNumberOfValues(format_smolstr!(
"expected at most {} rows, got {}",
max_rows,
"Exceeded maximum number of rows ({max_rows}) in virtual table: {}",
rows.len()
)));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment