The pg_query DropBehavior enum currently lives as a bare `type DropBehavior uint` —
callers that compare against the wire values have to write magic numbers
(`stmt.Behavior == 2` for CASCADE). Add named constants matching pganalyze/pg_query_go's
DropBehavior enum so usage sites can read `stmt.Behavior == ast.DropBehaviorCascade`
instead, and survive a future pg_query enum reshuffle without silently miscompiling.
No behavior change — just constants. Existing code that compares to integer literals
continues to work; this is purely additive.
Follow-up to the review on sqlc-dev#4419 (which currently uses `Behavior == 2` literal):
happy to apply the same rename in that PR's diff once it lands, or in a separate
sweep PR depending on what the maintainers prefer.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds named DropBehavior constants to internal/sql/ast/drop_behavior.go. No behavior change — purely additive.
Why
internal/sql/ast currently has:
The numeric values come from pganalyze/pg_query_go's DropBehavior enum, but they are nowhere named on the sqlc side. Callers comparing against the wire value have to write stmt.Behavior == 2 for CASCADE — a magic number that's invisible to grep and silently miscompiles if pg_query reshuffles the enum.
This PR adds:
Comments at the top of the file document where the values come from so future contributors don't have to chase the pg_query source.
What does NOT change
Context
This is the follow-up I offered in a review note on #4419. That PR uses stmt.Behavior == 2 in internal/sql/catalog/table.go. Once the constants land, refactoring those use-sites to stmt.Behavior == ast.DropBehaviorCascade is a 1-line change — happy to bundle into #4419 (if maintainers prefer one PR) or send as a separate sweep PR after #4419 merges. Both work; I have no preference.