Skip to content

sql: input set contains unknown columns in DO block #159793

@cockroach-teamcity

Description

@cockroach-teamcity

Reduced repro:

CREATE TABLE table_1 (k INT PRIMARY KEY);

DO $$
DECLARE
  decl OIDVECTOR;
BEGIN
  WHILE true LOOP
  CONTINUE WHEN false;
  WITH cte (col) AS
    (
      SELECT * FROM (VALUES (false))
    UNION
      SELECT * FROM (VALUES ((NOT true) AND false), (false))
    UNION ALL
      SELECT * FROM (VALUES (NULL::BOOL IN (SELECT true FROM table_1 AS t1)))
    )
    SELECT decl FROM cte WHERE col INTO decl;
  END LOOP;
END;
$$;;

needs crdb-test binary to hit

ERROR: internal error: input set contains unknown columns
SQLSTATE: XX000
DETAIL: stack trace:
pkg/sql/opt/colset.go:207: TranslateColSetStrict()
pkg/sql/opt/norm/prune_cols_funcs.go:777: NeededColMapLeft()
bazel-out/darwin_arm64-fastbuild/bin/pkg/sql/opt/norm/factory.og.go:2637: ConstructProject()
bazel-out/darwin_arm64-fastbuild/bin/pkg/sql/opt/norm/factory.og.go:1961: ConstructProject()
bazel-out/darwin_arm64-fastbuild/bin/pkg/sql/opt/norm/factory.og.go:24194: Replace()
pkg/sql/opt/norm/with_funcs.go:63: func1()
pkg/sql/opt/norm/with_funcs.go:66: InlineWith()
bazel-out/darwin_arm64-fastbuild/bin/pkg/sql/opt/norm/factory.og.go:13053: ConstructWith()
pkg/sql/opt/optbuilder/with.go:95: buildWiths()
pkg/sql/opt/optbuilder/builder.go:322: buildStmtAtRootWithScope()
pkg/sql/opt/optbuilder/plpgsql.go:2473: buildSQLStatement()
pkg/sql/opt/optbuilder/plpgsql.go:969: buildPLpgSQLStatements()
pkg/sql/opt/optbuilder/plpgsql.go:2309: appendPlpgSQLStmts()
pkg/sql/opt/optbuilder/plpgsql.go:757: buildPLpgSQLStatements()
pkg/sql/opt/optbuilder/plpgsql.go:918: buildPLpgSQLStatements()
pkg/sql/opt/optbuilder/plpgsql.go:762: buildPLpgSQLStatements()
pkg/sql/opt/optbuilder/plpgsql.go:2309: appendPlpgSQLStmts()
pkg/sql/opt/optbuilder/plpgsql.go:824: buildPLpgSQLStatements()
pkg/sql/opt/optbuilder/plpgsql.go:853: buildPLpgSQLStatements()
pkg/sql/opt/optbuilder/plpgsql.go:581: buildBlock()
pkg/sql/opt/optbuilder/plpgsql.go:445: buildRootBlock()
pkg/sql/opt/optbuilder/routine.go:932: buildPLpgSQLDoBody()
pkg/sql/opt/optbuilder/routine.go:894: buildDo()
pkg/sql/opt/optbuilder/builder.go:418: buildStmt()
pkg/sql/opt/optbuilder/builder.go:320: buildStmtAtRootWithScope()
pkg/sql/opt/optbuilder/builder.go:296: buildStmtAtRoot()
pkg/sql/opt/optbuilder/builder.go:275: Build()
pkg/sql/plan_opt.go:945: buildExecMemo()
pkg/sql/plan_opt.go:328: makeOptimizerPlanInternal()
pkg/sql/plan_opt.go:308: makeOptimizerPlan()
pkg/sql/conn_executor_exec.go:3246: makeExecPlan()
pkg/sql/conn_executor_exec.go:2827: dispatchToExecutionEngine()

sql/tests.TestRandomSyntaxSQLSmith failed with artifacts on release-26.1 @ 6340124c80f76cfc2928223bb06572598d97bd82:

Jira issue: CRDB-58026

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-test-failureBroken test (automatically or manually discovered).O-robotOriginated from a bot.P-3Issues/test failures with no fix SLAT-sql-queriesSQL Queries Teambranch-release-26.1Used to mark GA and release blockers, technical advisories, and bugs for 26.1target-release-26.2.0v26.2.0-prerelease

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions