Skip to content

feat(ws): add statement SQL reconstruction - #376

Open
openexw wants to merge 3 commits into
taosdata:mainfrom
openexw:feat/stmt-tosql
Open

openexw wants to merge 3 commits into
taosdata:mainfrom
openexw:feat/stmt-tosql

Conversation

@openexw

@openexw openexw commented Sep 21, 2026

Copy link
Copy Markdown

Summary

  • Add ws/unified.Stmt.ToSQL() to reconstruct executable SQL from stmt2 data bound after Prepare.
  • Support parameterized queries, fixed-table inserts, and dynamic subtable inserts using insert into ? using ... tags(...) values(...).
  • Support multi-table and multi-row inserts, tags, string escaping, NULL, VARBINARY/BLOB, and DECIMAL serialization; return an
    explicit error for GEOMETRY.
  • Keep ToSQL() non-destructive so callers may still invoke Exec() afterward.
  • Add table-driven unit tests for valid SQL, statement state errors, invalid bound data, invalid SQL templates, and SQL length
    limits.

Test Plan

  • go test ./ws/unified -run '^TestStmtToSQL' -count=1

Notes

  • ToSQL() supports only the new Bind API. Deprecated compatibility binding APIs do not preserve the original stmt2 types
    and return an explicit error.
  • SQL reconstruction reuses the existing common.InterpolateParams implementation; this change only adds the adapter from
    stmt2 column-oriented bind data to row-oriented VALUES tuples.

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