Skip to content

mcp: check TABLE, CTE-shadowed and ID-form references in catalog query validation - #40522

Merged
bobbyiliev merged 1 commit into
MaterializeInc:mainfrom
bobbyiliev:mcp-catalog-query-refs
Nov 6, 2026
Merged

bobbyiliev merged 1 commit into
MaterializeInc:mainfrom
bobbyiliev:mcp-catalog-query-refs

Conversation

@bobbyiliev

@bobbyiliev bobbyiliev commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

query_system_catalog validation missed three ways to name a user object: TABLE t, a schema-qualified name that matches a CTE (WITH t AS (...) SELECT * FROM public.t), and ID-form names ([u1 AS mz_catalog.mz_tables]), which resolve by ID and ignore the name. This collects TABLE references, only lets CTE names shadow unqualified names, and rejects ID-form names. It also accepts valid TABLE and WITH MUTUALLY RECURSIVE catalog queries that were rejected before. Based on #40384.

Tests: two unit tests in mcp.rs and five cases in testdata/mcp/developer.

Co-authored-by: Alex Gercog [email protected]

@playb0t

playb0t commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

This PR includes three changes from #40384: collecting TABLE references, limiting the CTE exemption to unqualified names, and registering mutually recursive bindings before visiting their definitions. I opened #40384 at @jasonhernandez's invitation. Before this merges, please add the co-author trailer:

Co-authored-by: Alex Gercog <[email protected]>

@jasonhernandez jasonhernandez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make sure @playb0t has coauthor credits on this bugfix

@bobbyiliev
bobbyiliev force-pushed the mcp-catalog-query-refs branch from aa18a12 to 57713f5 Compare November 6, 2026 09:47
@bobbyiliev

Copy link
Copy Markdown
Contributor Author

Thanks, added the co-author trailer to the commit and the PR body.

@bobbyiliev
bobbyiliev requested review from jasonhernandez and removed request for jasonhernandez November 6, 2026 17:04

@jasonhernandez jasonhernandez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @playb0t and @bobbyiliev!

@bobbyiliev
bobbyiliev merged commit 89e06c5 into MaterializeInc:main Nov 6, 2026
82 checks passed
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.

4 participants