Skip to content

refactor(mdb): use SQLExecDirect for infer_schema (simpler than prepare+execute)#89

Merged
lewiszlw merged 2 commits into
masterfrom
refactor/mdb-infer-schema-safe-prepare
Jun 22, 2026
Merged

refactor(mdb): use SQLExecDirect for infer_schema (simpler than prepare+execute)#89
lewiszlw merged 2 commits into
masterfrom
refactor/mdb-infer-schema-safe-prepare

Conversation

@lewiszlw

Copy link
Copy Markdown
Member

Summary

Replace the prepare + execute two-step approach in MdbConnection::infer_schema with a single SQLExecDirect call — matching the pattern already used in the query/table-listing paths.

Rationale

  • SQLExecDirect is one ODBC call instead of two (prepare + execute)
  • mdbtools doesn't need SQLPrepare for one-off schema queries — exec_direct returns the result set immediately
  • The SQL_ATTR_PARAMSET_SIZE limitation only blocks odbc-api's safe conn.execute() wrapper; manual exec_direct works fine

Changes

  • mod.rs: use preallocate → exec_direct → CursorImpl in infer_schema
  • schema.rs: revert build_remote_schema to accept CursorImpl<StatementImpl> (needed by exec_direct cursor)

lewiszlw added 2 commits June 22, 2026 11:32
…_schema

mdbtools does not support SQL_ATTR_PARAMSET_SIZE so odbc-api's safe
conn.execute() fails with HY092. Use SQLExecDirect directly (one ODBC
call instead of two: prepare + execute). Metadata is collected from the
cursor after exec_direct.
…pattern

Replace the manual preallocate + unsafe exec_direct + unsafe CursorImpl
with odbc-api's safe conn.execute(&sql, (), None). This is the same
pattern used by the DM connection — zero unsafe blocks.
@lewiszlw lewiszlw force-pushed the refactor/mdb-infer-schema-safe-prepare branch from b15231b to 060f5d8 Compare June 22, 2026 03:33
@lewiszlw lewiszlw merged commit 381fc00 into master Jun 22, 2026
5 of 6 checks passed
@lewiszlw lewiszlw deleted the refactor/mdb-infer-schema-safe-prepare branch June 22, 2026 05:46
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