Skip to content

Redesign prepared parameters: planner reads the typed parameter batch; remove ParamValue string-conversion #33082

Done

Description

@fengttt

Summary

Redesign how the planner receives prepared-statement parameters. The typed parameter batch from #33011 should be the single source of truth. plan.ParamValue (Value any plus StringConversionKind) and its string-conversion branches should go.

Background

One EXECUTE currently carries each parameter in three representations:

  1. The TEXT transport vector. Protocol values and user variables are rendered to text.
  2. The typed parameter batch, added in refactor(vector): remove prepareParamKind from Vector; carry prepared parameters as typed values (#33007) #33011. One row per parameter, in its source SQL type, read by ParamExpressionExecutor.
  3. paramVals []any of plan.ParamValue. Read by the planner: ResetParamRefRule, prepared binding, field types, pagination and so on. It carries Value any (a string for COM_STMT_EXECUTE, native Go types for user variables) and a StringConversionKind that tells consumers how to undo the stringification.

The consumers of (3) branch on what Value holds: about 70 ParamValue unwrap sites across 14 files, each followed by type switches on Value. A large part of the prepared-parameter compatibility history lives in those branches.

Proposal

Non-goals and cautions

  • No zero-copy strings into storage that is reused in place. Parameter values can outlive an execution: plan literals, specialized-plan caches, binding keys, warning and error text, remote plan serialization, CTAS semantic params. If an allocation-free string is needed, copy into a per-execution buffer that is replaced, never overwritten (the same class as the QuickBytesToStr retention bugs).
  • The allocation win over the interim fix (pointer storage for ParamValue, separate PR) is small. The motivation is correctness and simplicity: one source of truth and no string-conversion machinery.

Acceptance

  • Unit tests and test/distributed/cases/prepare BVT pass unchanged.
  • sysbench ps-mode=auto (random_points, random_ranges, nopk_random_points, point_select) is no slower than the interim fix, measured with an ABBA ordering.

Related: #33007, #33011, #33076, #33081.

Activity

  1. self-assigned this
    on Nov 23, 2026
  2. added theissue type on Nov 23, 2026
  3. fengttt commented on Nov 23, 2026

    @fengttt
    ContributorAuthor

    Suggested by Claude. It seems to be reasonable design.

  4. fengttt commented on Nov 23, 2026

    @fengttt
    ContributorAuthor

    The interim fix (pointer storage for planner paramVals) is #33083, stacked on #33081.

  5. fengttt commented on Nov 23, 2026

    @fengttt
    ContributorAuthor

    Stage 1 (COM_STMT integer/float/Boolean parameters as native values; integer/float/Boolean string re-interpretation removed) is #33091, stacked on #33083 → #33081. Next: stage 2 (DECIMAL/temporal onto the binding), stage 3 (PrepareParamKind → type predicates).

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions