Skip to content

sql: pg_statistic_ext crashes with statistics with no names #93430

@jordanlewis

Description

@jordanlewis

The following sequence of commands crashes the DB on 22.2:

CREATE TABLE a(a) AS generate_series(1,100);
ANALYZE a;
SELECT * FROM pg_statistic_ext
demo@127.0.0.1:26257/defaultdb> create table a (a) as select generate_series(1,100);                                                                                                                      CREATE TABLE AS                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               Time: 18ms total (execution 18ms / network 0ms)                                                                                                                                                                                                                                                                                                                                                                     demo@127.0.0.1:26257/defaultdb> analyze a;                                                                                                                                                                ANALYZE                                                                                                                                                                                                   

Time: 15ms total (execution 15ms / network 0ms)

demo@127.0.0.1:26257/defaultdb> select * from pg_statistic_ext;
*
* ERROR: a panic has occurred!
* expected *DString, found tree.dNull
* (1) attached stack trace
*   -- stack trace:
*   | runtime.gopanic
*   |   GOROOT/src/runtime/panic.go:884
*   | [...repeated from below...]
* Wraps: (2) assertion failure
* Wraps: (3) attached stack trace
*   -- stack trace:
*   | github.com/cockroachdb/cockroach/pkg/sql/sem/tree.MustBeDString
*   |   github.com/cockroachdb/cockroach/pkg/sql/sem/tree/datum.go:1228
*   | github.com/cockroachdb/cockroach/pkg/sql.glob..func244
*   |   github.com/cockroachdb/cockroach/pkg/sql/pg_catalog.go:3431
*   | github.com/cockroachdb/cockroach/pkg/sql.(*virtualDefEntry).getPlanInfo.func1.1
*   |   github.com/cockroachdb/cockroach/pkg/sql/virtual_schema.go:572
*   | github.com/cockroachdb/cockroach/pkg/sql.setupGenerator.func3
*   |   github.com/cockroachdb/cockroach/pkg/sql/virtual_table.go:127
*   | github.com/cockroachdb/cockroach/pkg/util/stop.(*Stopper).RunAsyncTaskEx.func2
*   |   github.com/cockroachdb/cockroach/pkg/util/stop/stopper.go:489
*   | runtime.goexit
*   |   GOROOT/src/runtime/asm_amd64.s:1594
* Wraps: (4) expected *DString, found tree.dNull
* Error types: (1) *withstack.withStack (2) *assert.withAssertionFailure (3) *withstack.withStack (4) *errutil.leafError
* ```

Jira issue: CRDB-22397




Epic CRDB-23454

Metadata

Metadata

Assignees

Labels

C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.O-pg-regressOriginated from the pg_regress test suite.S-2-temp-unavailabilityTemp crashes or other availability problems. Can be worked around or resolved by restarting.T-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)backport-22.2.x

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions