Skip to content

[Bug]: Planner mock pads composite primary key names with empty entries #29636

Closed

Description

@XuPeng-SH

Is there an existing issue for the same bug?

  • I have checked the existing issues. Searches for MockCompilerContext/primary key and mock/composite key found no matching report.

Branch Name

main; reproduced in the local #29629 worktree during #29249 fixture QA.

Commit ID

ce2a22a contains the same defective composite-key construction. Runtime reproduction uses d6b921d plus the explicit-owner migration and an independent regression.

Other Environment Information

Go 1.26.4, local Linux; GOMAXPROCS=2, serialized Go package tests. No database/server or large data is needed.

Actual Behavior

The planner mock constructs composite primary-key Names by allocating a length-N slice and then appending N names. Resolving tpch.lineitem returns ["", "", "l_orderkey", "l_linenumber"], rather than the two declared keys. The scalar nation control passes. A focused regression fails at the exact Names equality assertion before the fix.

Expected Behavior

The mock metadata supplied to real planner consumers contains exactly the declared primary-key names in declaration order. The lineitem key includes nonadjacent source columns 0 and 3.

Steps to Reproduce

  1. Construct a MockCompilerContext (with nil process on test: make process fixture resource ownership explicit #29629; the original main constructor needs only the boolean).
  2. Resolve tpch.lineitem.
  3. Compare table.Pkey.Names with the independent literal []string{"l_orderkey", "l_linenumber"}.
  4. Use tpch.nation as the single-key control: []string{"n_nationkey"}.

Focused test: mo-cgo-test -p=1 -parallel=1 -count=1 -run '^TestMockCompilerContextPrimaryKeyMetadata$' ./pkg/sql/plan.

Additional information

Fix at the existing schema-to-TableDef owner by filling the preallocated Names slice, rather than adding an alternate metadata path. Also retire mock computation/filling of PrimaryKeyDef.Cols: proto/plan.proto explicitly marks it currently unused, DeepCopyPrimaryKeyDef does not preserve it, and repository-wide consumer search finds no runtime reader. This report concerns test-fixture metadata quality; no production data corruption or quantified query slowdown is claimed. Consolidate the fix and regression into #29629 under #29249 / #29627.

Activity

  1. added
    kind/bug
    on Oct 5, 2026
  2. self-assigned this
    on Oct 5, 2026
  3. added a commit that references this issue on Oct 6, 2026
    c659910
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions