Copilot commented on code in PR #4773:
URL: https://github.com/apache/arrow-adbc/pull/4773#discussion_r3977041097
##########
c/driver/sqlite/statement_reader.c:
##########
@@ -343,6 +343,25 @@ AdbcStatusCode InternalAdbcSqliteBinderBindNext(struct
AdbcSqliteBinder* binder,
binder->param_indices[i] =
sqlite3_bind_parameter_index(stmt, binder->schema.children[i]->name);
if (binder->param_indices[i] == 0) {
+ // Accept names without a prefix when the match is unique. Exact names
+ // above retain precedence and their existing behavior.
+ for (int parameter = 1; parameter <=
sqlite3_bind_parameter_count(stmt);
+ parameter++) {
+ const char* name = sqlite3_bind_parameter_name(stmt, parameter);
+ if (name != NULL && (name[0] == ':' || name[0] == '@' || name[0] ==
'$') &&
+ strcmp(name + 1, binder->schema.children[i]->name) == 0) {
+ if (binder->param_indices[i] != 0) {
+ binder->param_indices[0] = 0;
+ InternalAdbcSetError(error, "ambiguous parameter `%s`; include
its prefix",
+ binder->schema.children[i]->name);
+ return ADBC_STATUS_INVALID_ARGUMENT;
+ }
+ binder->param_indices[i] = parameter;
Review Comment:
Distinct input names can resolve to the same SQLite index without detection.
For example, `SELECT :a, @b` with `{"a": 1, ":a": 2}` passes the
parameter-count check, then both fields bind index 1 and leave `@b` as NULL.
Validate that each resolved index is unique (or otherwise reject an alias when
its exact name is also supplied) so missing parameters cannot be silently
accepted.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]