Skip to content

refactor(mdb): remove dummy bind_col from list_tables_sync#93

Merged
lewiszlw merged 4 commits into
masterfrom
refactor/mdb-list-tables-safe
Jun 22, 2026
Merged

refactor(mdb): remove dummy bind_col from list_tables_sync#93
lewiszlw merged 4 commits into
masterfrom
refactor/mdb-list-tables-safe

Conversation

@lewiszlw

Copy link
Copy Markdown
Member

Summary

移除 list_tables_sync 中的 dummy bind_col 绕过方案(12 行删除),2 个 unsafe 减少为 1 个。

Remaining unsafe

unsafe { CursorImpl::new(stmt) } 无法避免 — odbc-api 没有为 SQLTables 等目录函数提供安全封装。Connection 只有 execute()prepare(),没有 tables()

Current state

项目 unsafe 分布(全部在 mdb/mod.rs):

  • infer_schema: 0 unsafe ✅
  • query: 0 unsafe ✅
  • fetch_table_row_count: 0 unsafe ✅
  • list_tables_sync: 1 unsafe(CursorImpl::new,无法消除)

lewiszlw added 4 commits June 22, 2026 14:38
The dummy column bind was a workaround for mdbtools 1.0.x requiring
SQLBindCol before SQLFetch. With the safe conn.execute() refactoring
in query and fetch_table_row_count, try the same approach here: remove
the dummy bind and use cursor.next_row() directly after SQLTables.

The single remaining unsafe (CursorImpl::new) is unavoidable — odbc-api
does not provide a safe wrapper for catalog functions like SQLTables.
…ysObjects

Replace the ODBC catalog function SQLTables (which requires unsafe
CursorImpl::new) with a direct conn.execute() query to MSysObjects.
This eliminates the last unsafe block in the MDB module — zero unsafe
in the entire remote-table source now.

MSysObjects.Type values: 1=local table, 4=linked ODBC, 5=query/view,
6=linked table.
@lewiszlw lewiszlw merged commit e9ab61d into master Jun 22, 2026
3 checks passed
@lewiszlw lewiszlw deleted the refactor/mdb-list-tables-safe branch June 22, 2026 07:05
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