GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(duckdb): report an annotated statement that cannot be converted by xen0l · Pull Request #4662 · sqlc-dev/sqlc

Conversation

@xen0l

@xen0l xen0l commented Oct 24, 2026

Copy link
Copy Markdown

Fixes #4656

Problem

The DuckDB parser skipped every statement that converted to ast.TODO. The span of a statement includes the comments before it, so the -- name: annotation was lost with the statement. sqlc generate exited 0, printed nothing, and generated no method for it.

Change

In internal/engine/duckdb/parse.go:

  • Keep skipping a statement that has no query annotation (INSTALL, LOAD and SET in a schema file).
  • Return an error for a statement that has one: query <name>: statement is not supported by the duckdb engine. The error points at the annotation line.
  • A malformed annotation on such a statement is reported with the annotation parser's own message. (No test covers this path.)

The parser now reads its input once (io.ReadAll) so that the statement offsets index the text.

Tests

New end-to-end cases (sqlc analyze --dialect duckdb):

  • analyze_unsupported_statement/duckdb: an annotated COPY after a valid query. Must fail, stderr.txt committed. It fails without the change (exit 0, JSON for one query) and passes with it.
  • analyze_skipped_schema_statements/duckdb: control. INSTALL, LOAD and SET in the schema file stay skipped. It passes with and without the change.

go test ./internal/endtoend -run TestReplay/base: 971 pass, 58 skip, 0 fail before; 973 pass, 58 skip, 0 fail after. The only difference is the two new cases.
go test ./internal/engine/... ./internal/core/... ./internal/compiler/... ./internal/codegen/... ./internal/cmd/... ./internal/metadata/... ./internal/sql/...: all ok.

Not run: the managed-db context, --tags=examples, and the internal/goldeneye checks.

Notes

The same check does not cover an unsupported expression inside a statement that converts (it is still typed as unknown). Changing that would alter how every unsupported expression is treated, so I left it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@xen0l
fix(duckdb): report an annotated statement that cannot be converted
2d5ffd3
The DuckDB parser skipped every statement that converted to ast.TODO. The
span of a statement includes the comments before it, so a "-- name:"
annotation was lost with the statement. sqlc generate exited 0, printed
nothing and generated no method for it.

Keep skipping a statement that has no query annotation (INSTALL, LOAD
and SET in a schema file). Return an error for a statement that has one,
and point it at the annotation.

Adds analyze_unsupported_statement and a control case,
analyze_skipped_schema_statements.
@xen0l

xen0l commented Nov 10, 2026

Copy link
Copy Markdown
Author

@kyleconroy Could you review this fix for #4656 when you have time, please? Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

duckdb: a named statement that the converter cannot handle is dropped without an error

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@xen0l
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.