std: support prepared SELECT/DDL via database/sql; add examples/tests
Implement driver-side prepared statements for non-INSERT queries in the database/sql compatibility layer.
Changes:
-
Introduce stdStmt and wire it into PrepareContext for non-INSERT statements
-
Implement StmtQueryContext/StmtExecContext using underlying connection
-
Preserve INSERT behavior via stdBatch (Exec-only)
-
Add example examples/std/prepared.go and run it in examples suite
-
Add tests: prepared select, USE + prepared select, and merged funds temp test
-
Remove temporary test file; fix minor linter warning in clickhouse_std.go
Rationale:
- Restores database/sql compatibility for prepared read queries (e.g., Stmt.QueryContext) while keeping batch INSERT semantics
Summary
Checklist
Delete items not relevant to your PR:
- [x] Unit and integration tests covering the common scenarios were added
- [x] A human-readable description of the changes was provided to include in CHANGELOG
- [ ] For significant changes, documentation in https://github.com/ClickHouse/clickhouse-docs was updated with further explanations or tutorials
@theboringhumane thanks for the contribution. can you take care of the failing test cases?
code: 62, message: Syntax error: failed at position 58 (end of query) (line 3, col 5): . Expected one of: token, Dot, OpeningRoundBracket, FROM INFILE, SETTINGS, VALUES, FORMAT, SELECT, WITH
@theboringhumane thanks for the contribution. can you take care of the failing test cases?
code: 62, message: Syntax error: failed at position 58 (end of query) (line 3, col 5): . Expected one of: token, Dot, OpeningRoundBracket, FROM INFILE, SETTINGS, VALUES, FORMAT, SELECT, WITH
I'll take care of that. No sweat.