# Post-SQLFix: Property-Guided Repair of LLM-Generated SQL with Runtime Verification

DevFeed: [Post-SQLFix: Property-Guided Repair of LLM-Generated SQL with Runtime Verification](<https://devfeed.tech/articles/post-sqlfix-property-guided-repair-of-llm-generated-sql-with-runtime-verification-112677.md>)

Original publisher: [Read original article](<https://arxiv.org/abs/2610.41472>)

Author: Zhihao Guo, Zonghan Wu, Yilei Shao, Haizhou Du, Nan Tang, Xiao Cheng, Huan Huo

Published: 2026-11-02T05:00:00Z

Content type: article

Language: en

Sources: [arXiv: Software Engineering](<https://devfeed.tech/sources/arxiv-software-engineering.md>)

Topics: [text2sql](<https://devfeed.tech/topics/text2sql.md>), [AI for SQL query generation](<https://devfeed.tech/topics/ai-for-sql-query-generation.md>), [SQL](<https://devfeed.tech/topics/sql.md>), [Large Language Model](<https://devfeed.tech/topics/llm.md>), [typesafety](<https://devfeed.tech/topics/typesafety.md>)

Tags: [analyzer](<https://devfeed.tech/tags/analyzer.md>), [benchmarks](<https://devfeed.tech/tags/benchmarks.md>), [context](<https://devfeed.tech/tags/context.md>), [contracts](<https://devfeed.tech/tags/contracts.md>), [cs-se](<https://devfeed.tech/tags/cs-se.md>), [diagnostics](<https://devfeed.tech/tags/diagnostics.md>), [evaluation](<https://devfeed.tech/tags/evaluation.md>), [execution](<https://devfeed.tech/tags/execution.md>), [framework](<https://devfeed.tech/tags/framework.md>), [identifier](<https://devfeed.tech/tags/identifier.md>), [improvements](<https://devfeed.tech/tags/improvements.md>), [invariants](<https://devfeed.tech/tags/invariants.md>), [language](<https://devfeed.tech/tags/language.md>), [language-models](<https://devfeed.tech/tags/language-models.md>), [large-language-models](<https://devfeed.tech/tags/large-language-models.md>), [layers](<https://devfeed.tech/tags/layers.md>), [llm](<https://devfeed.tech/tags/llm.md>), [repair](<https://devfeed.tech/tags/repair.md>), [runtime](<https://devfeed.tech/tags/runtime.md>), [sql](<https://devfeed.tech/tags/sql.md>), [verification](<https://devfeed.tech/tags/verification.md>)

## AI overview

Post-SQLFix repairs LLM-generated SQL using property-guided analysis and runtime checks instead of relying solely on execution-error messages. It canonicalizes queries into a dialect-aware Canonical Query Structure, checks syntax, structural rules, and context-sensitive semantics, then gives schema-aware diagnostics to guide repair proposals. A verify-before-apply monitor accepts changes only when they reduce violations, preserve resolved violations, and meet operator contracts; guarantees are limited to declared rules and contracts, and a finite retry budget ensures termination. Across BIRD, Spider, and Mini-Dev (over 3,000 instances, three SQL dialects, six model configurations), it resolved 77.8% of execution errors left unrepaired by execution feedback, with less than half the repair iterations and 30% fewer tokens. No accepted transition introduced a statically detectable structural regression in the evaluation; reported accuracy gains reached 11.6 percentage points.

## Source excerpt

arXiv:2610.41472v1 Announce Type: new Abstract: Large Language Models (LLMs) for Text-to-SQL frequently generate queries with syntax errors, invalid identifier references, or violations of SQL scoping and typing rules. Repairing these errors is a program correctness problem, yet existing approaches rely on Execution Feedback (EF), whose symptom-level, dialect-specific error messages force the LLM to speculate on root causes. We identify an Arbitration Paradox in this paradigm: the system relies on unverified models both to propose repairs and to make the final judgment on whether those repairs satisfy the required properties. We resolve this paradox by reformulating Text-to-SQL repair as property-guided program repair. Our framework, Post-SQLFix, canonicalizes SQL into a dialect-aware Canonical Query Structure (CQS) and validates it through a hierarchical static analyzer with three stratified property layers (Syntactic, Context-Free Structural, Context-Sensitive Semantic). The analyzer produces precise, schema-aware violation diagnostics to guide the LLM's repair proposals. A Verify-Before-Apply Temporal Monitor then accepts only repairs that reduce the violation count, do not reintroduce resolved violations, and satisfy the operator contracts. These runtime invariants are bounded by the declared rule family and operator contracts, while a finite retry budget ensures halting. On three established benchmarks (BIRD, Spider, Mini-Dev) spanning over 3,000 evaluation instances, three SQL dialects (SQLite, MySQL, PostgreSQL), and six model configurations, Post-SQLFix resolves 77.8% of the execution errors that EF leaves unrepaired, while requiring less than half as many repair iterations and 30% fewer tokens. Crucially, accepted transitions under the monitor introduce no statically detectable structural regressions in our evaluation, translating checked repair fidelity into absolute accuracy improvements of up to +11.6 percentage points.