Skip to content

[Feature Request]: Prepared statement support for publication management and inspection #16543

Description

@ck89119

Is there an existing issue for the same feature request?

  • I have checked the existing issues.

Is your feature request related to a problem?

Publication statements have inconsistent prepared-statement support. The original request covered ALTER PUBLICATION; the scope is expanded to match PR #29386 and complete the related publication management and inspection paths.

Frontend-handled statements need a valid PREPARE carrier and frontend execution rather than engine compilation. Publication SHOW statements also need consistent result metadata during preparation and execution.

Describe the feature you would like

Support SQL PREPARE / EXECUTE and MySQL binary-protocol prepared statements for:

  • CREATE PUBLICATION
  • ALTER PUBLICATION
  • DROP PUBLICATION
  • SHOW PUBLICATIONS, including literal LIKE patterns and the supported SHOW PUBLICATIONS LIKE ? string-pattern binding
  • SHOW PUBLICATION COVERAGE

Preserve and regression-test the existing SHOW CREATE PUBLICATION query path; this is not a newly introduced implementation for that statement.

Expected behavior:

  1. PREPARE must not create, alter, or drop a publication.
  2. EXECUTE must use the existing handlers, authorization, and current publication state, including repeated execution and errors after deletion or access revocation.
  3. Publication SHOW statements must expose consistent column names, counts, and wire types at PREPARE and execution, including empty results.
  4. SHOW results must remain compatible with save_query_result and RESULT_SCAN after wire metadata normalization.
  5. Prepared statements must remain usable after an execution error when the underlying publication state becomes valid again.

Describe implementation you have considered

  • Reuse the existing frontend-only prepared-statement path for the five statements listed above.
  • Share publication SHOW result schemas between preparation and execution instead of maintaining separate metadata definitions.
  • Recognize text BLOB-family wire metadata as internal TEXT when materializing saved frontend results, without treating binary BLOBs as TEXT.
  • Bind a single string parameter for SHOW PUBLICATIONS LIKE ? during prepared execution; reject unbound, non-string or otherwise invalid patterns without corrupting the prepared handle. Other nonliteral LIKE expressions are not implied to be supported.
  • Add planner/frontend/protocol unit tests and publication SQL regression coverage.

Documentation, Adoption, Use Case, Migration Strategy

This scope enables applications to prepare publication management and inspection statements without changing publication management semantics. SHOW PUBLICATIONS LIKE ? is a narrow supported parameter-marker case, not a general promise that publication names, account names, identifiers, or arbitrary publication statement fields accept ?.

Out of scope:

  • Parameter markers for publication identifiers or other unlisted statement fields.
  • Subscription-management statement support.
  • Changes to authorization rules, catalog/storage formats, or unrelated publication behavior.

Additional information

Implementation PR: #29386. The expanded scope includes the result-metadata and saved-result compatibility work required by prepared publication SHOW statements, not only the original ALTER PUBLICATION entry point.

The current main also supports the narrow SHOW PUBLICATIONS LIKE ? path, covered by pkg/frontend/prepared_publication_parameter_test.go and test/distributed/cases/publication_subscription/prepare_publication.sql. This corrects the earlier out-of-scope wording; it does not expand support to arbitrary placeholders.

Activity

  1. added this to the 1.3.0 milestone on Jun 3, 2024
  2. modified the milestones: 2.0.0, 2.0.1 on Oct 23, 2024
  3. allengaoo commented on Nov 4, 2024

    @allengaoo

    suggest delay this one to 2.1.0

  4. modified the milestones: 2.0.1, 2.1.0 on Nov 4, 2024
  5. modified the milestones: 2.1.0, Backlog on Mar 27, 2025
  6. added theissue type on Apr 25, 2025
  7. added a commit that references this issue on Sep 26, 2026
    9c79a6e
  8. changed the title [-][Feature Request]: Prepared statement support for `alter publication`[/-] [+][Feature Request]: Prepared statement support for publication management and inspection[/+] on Sep 26, 2026
  9. Ariznawlll commented on Oct 3, 2026

    @Ariznawlll
    Collaborator

    测试版本

    • 分支:main
    • 实际复测 commit:529ee099e32ed8c38d2806043bf1516ab0345e45
    • 部署方式:本地 MatrixOne,分别通过 SQL PREPARE/EXECUTE 与 MySQL binary-protocol prepared statement 连接执行
    • 测试日期:2026-10-03

    原问题验证

    SQL PREPARE/EXECUTE 和 MySQL 二进制 prepared 路径均验证了 CREATE / ALTER / DROP PUBLICATION、SHOW PUBLICATIONS、SHOW CREATE PUBLICATION、SHOW PUBLICATION COVERAGE。PREPARE 本身未创建、修改或删除 publication;EXECUTE 使用当前对象状态和权限。SHOW 空结果与有结果时均保持相同的 8 列名称和 wire types;save_query_result 后的 RESULT_SCAN 可读取结果。

    正常路径覆盖

    1. 上述管理与检查语句在 SQL 和 binary prepared 两种协议路径下均执行正确;重复 EXECUTE 后对象状态与查询结果一致。
    2. 当前 main 还支持窄范围的 SHOW PUBLICATIONS LIKE ? 字符串参数绑定;这与 issue 正文此前写的“不支持参数化 LIKE”不一致,正文已同步更正,不将此支持外推到 publication 标识符或任意参数标记。

    边界与错误路径覆盖

    1. 删除 publication 后重执行原 prepared handle,按当前对象状态报错;重新创建后原 handle 可以再次成功执行。
    2. 撤销账户访问权限后,已准备语句被拒绝;恢复授权后同一 handle 再次成功,说明权限在 EXECUTE 时重新检查,而不是固化 PREPARE 时状态。
    3. SHOW PUBLICATIONS LIKE ? 的缺失绑定及不合适的类型被拒绝;错误后再以有效字符串参数执行,handle 仍可用。该窄范围参数合同见定向 UT。

    白盒验证

    本轮以 SQL 与真实 binary-protocol 黑盒结果为主;已合入的 frontend UT 检查参数绑定、wire metadata、错误后的 handle 复用与执行时权限。没有新增故障注入。

    回归测试

    修复 #29386 已合入;publication prepared BVT及参数绑定 UT覆盖对象生命周期、LIKE 参数、授权和结果元数据。此问题不由数据规模触发,不新增 big-data 用例。

    测试证据

    上述 BVT、UT 文件及已合入的 #29386;本轮 SQL/binary 协议复测结果如上。自测试 commit 至当前官方 main,publication 专属回归与参数绑定测试文件未变更。

    测试结论

    测试通过。

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

Metadata

Metadata

Assignees

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions