Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Off-by-one error in dict_put_impl and x-sparql-maxrows header not being sent for construct queries #939 #940

Open
wants to merge 2 commits into
base: develop/7
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions libsrc/Wi/sparql_io.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3227,7 +3227,7 @@ create procedure WS.WS."/!sparql/" (inout path varchar, inout params any, inout
{
declare query, full_query, format, should_sponge, debug, log_debug_info, def_qry varchar;
declare dflt_graphs, named_graphs, using_graphs, using_named_graphs any;
declare paramctr, paramcount, qry_params, maxrows, can_sponge, start_time integer;
declare paramctr, paramcount, qry_params, maxrows, can_sponge, start_time, nresults integer;
declare ses, content any;
declare def_max, add_http_headers, hard_timeout, timeout, client_supports_partial_res, sp_ini, soap_ver int;
declare http_meth, content_type, ini_dflt_graph, get_user, jsonp_callback varchar;
Expand Down Expand Up @@ -3912,7 +3912,15 @@ again:
start_time := msec_time();
exec ( concat ('sparql {', full_query, '\n}'), state, msg, qry_params, vector ('max_rows', maxrows, 'use_cache', 1), metas, rset);
commit work;
if (isvector (rset) and length (rset) = maxrows)
nresults := -1;
if (isvector (rset)) nresults := length (rset);
-- for construct queries, the results are a bit deeper
if (
(1 = nresults) and
(1 = length (rset[0])) and
(__tag of dictionary reference = __tag (rset[0][0]))
) nresults := dict_size (rset[0][0]);
if (nresults > -1 and nresults >= maxrows)
http_header (http_header_get () || sprintf ('X-SPARQL-MaxRows: %d\r\n', maxrows));
-- dbg_obj_princ ('exec metas=', metas, ', state=', state, ', msg=', msg);
if (state = '00000')
Expand Down
2 changes: 1 addition & 1 deletion libsrc/Wi/xslt.c
Original file line number Diff line number Diff line change
Expand Up @@ -3587,7 +3587,7 @@ dict_put_impl (id_hash_iterator_t *hit, caddr_t key, caddr_t val, int signal_uns
}
}
if ((0 < ht->ht_dict_max_entries) &&
((ht->ht_inserts - ht->ht_deletes) > ht->ht_dict_max_entries) )
((ht->ht_inserts - ht->ht_deletes) >= ht->ht_dict_max_entries) )
goto skip_insertion; /* see below */
if ((0 < ht->ht_dict_max_mem_in_use) &&
(ht->ht_dict_mem_in_use > ht->ht_dict_max_mem_in_use) )
Expand Down