Skip to content

fix(common): a checked SQL statement runs read-only, with timeout and result limit - #205

Merged
stbischof merged 1 commit into
eclipse-daanse:mainfrom
stbischof:fix/sql-query-safety
Dec 1, 2026
Merged

stbischof merged 1 commit into
eclipse-daanse:mainfrom
stbischof:fix/sql-query-safety

Conversation

@stbischof

Copy link
Copy Markdown
Contributor

A SQL statement checked by the guard now runs as the guard expects:

  • The connection is read-only while the statement runs. The result set SqlQuery.execute() returns closes its statement and connection with itself and gives the connection back with the read-only flag it had; a connection the caller closed first is left alone, and a failure while setting up releases everything.
  • The statement gets a timeout of its own, apart from the query timeout of MDX: the setting sqlQueryTimeout, 20 seconds unless set, 0 for none. A setting that is no whole number of seconds, or is negative, is refused.
  • A result larger than the result limit fails at the row after the limit rather than returning less.
  • The functions a SQL statement may call come from the setting sqlGuardFunctions, by default the aggregates and concat.

SqlQueryImplTest covers read-only, timeout, the order of closing, the result limit and the release on failure; ConnectionBaseParseSqlTest the settings.

… result limit

The result set SqlQuery.execute() returns closes its statement and connection with
itself and gives the connection back with the read-only flag it had. The statement
gets a timeout of its own, apart from the query timeout of MDX: the setting
sqlQueryTimeout, 20 seconds unless set, 0 for none. A result larger than the
result limit fails rather than returning less. The functions a SQL statement may
call come from the setting sqlGuardFunctions, by default the aggregates and concat.

Signed-off-by: Stefan Bischof <stbischof@bipolis.org>
@stbischof
stbischof force-pushed the fix/sql-query-safety branch from fa2fe63 to 75ffd76 Compare December 1, 2026 17:16
@stbischof
stbischof merged commit 71fb986 into eclipse-daanse:main Dec 1, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant