Skip to content

sql: internal error: expected *DJSON, found tree.dNull #70663

@cockroach-teamcity

Description

@cockroach-teamcity

sql/tests.TestRandomSyntaxSQLSmith failed with artifacts on master @ 85b1e92455eb2795043d71e5766b1b56dab308f2:

Random syntax error:

    rsg_test.go:779: Crash detected: server panic: pq: internal error: no volatility for cast tuple[]::tuple{oid}[]

Query:

        WITH
        	with_22092 (col_133678) AS (SELECT * FROM (VALUES (4124365893:::OID)) AS tab_53995 (col_133678)),
        	with_22093 (col_133680)
        		AS (
        			SELECT
        				*
        			FROM
        				(
        					VALUES
        						(
        							(
        								SELECT
        									ARRAY[(3094316761:::OID,)] AS col_133679
        								FROM
        									defaultdb.public.seed@[0] AS tab_53996
        								WHERE
        									false
        								ORDER BY
        									tab_53996._float8 DESC
        								LIMIT
        									1:::INT8
        							)
        						),
        						(ARRAY[(2507092097:::OID,),(0:::OID,),(756558269:::OID,)]),
        						(NULL),
        						(NULL),
        						(ARRAY[(963988552:::OID,),(NULL,)])
        				)
        					AS tab_53997 (col_133680)
        			EXCEPT
        				SELECT
        					*
        				FROM
        					(
        						VALUES
        							(ARRAY[]:::RECORD[]),
        							(NULL),
        							(ARRAY[(2900487383:::OID,)]),
        							(ARRAY[]:::RECORD[]),
        							(
        								ARRAY[(688555135:::OID,),(1531852639:::OID,),(179303289:::OID,),(1651224142:::OID,),(3924272170:::OID,)]
        							),
        							(ARRAY[(679193880:::OID,),(2446968155:::OID,),(3423303889:::OID,),(3663959049:::OID,)])
        					)
        						AS tab_53998 (col_133681)
        		),
        	with_22094 (col_133682, col_133683)
        		AS (
        			SELECT
        				*
        			FROM
        				(
        					VALUES
        						(3464715034:::OID, (-27553):::INT8),
        						(597561778:::OID, 29341:::INT8),
        						(
        							NULL,
        							CASE
        							WHEN false THEN 24700:::INT8
        							ELSE st_zmflag('010300000001000000040000000C461DB58577F0C1DA17FE0BCCE6E8C1A0BC3DCDB9FDF14100F6ADBD85849641424D3B954FC7F041AA06B4425AC801420C461DB58577F0C1DA17FE0BCCE6E8C1':::GEOMETRY::GEOMETRY)::INT2
        							END
        						)
        				)
        					AS tab_53999 (col_133682, col_133683)
        		)
        SELECT
        	ARRAY[(465901049:::OID,),(2680064326:::OID,),(2732701715:::OID,),(0:::OID,),(NULL,)] AS col_133684
        FROM
        	with_22093 AS cte_ref_6356
        ORDER BY
        	cte_ref_6356.col_133680 DESC
        LIMIT
        	51:::INT8;

Schema:

    rsg_test.go:596: To reproduce, use schema:
    rsg_test.go:598: 
        		SET CLUSTER SETTING sql.stats.automatic_collection.enabled = false;
        		SET CLUSTER SETTING sql.stats.histogram_collection.enabled = false;
        		SET CLUSTER SETTING sql.defaults.interleaved_tables.enabled = true;
        	CREATE TABLE table1 (col1_0 REGCLASS NOT NULL, col1_1 INTERVAL NOT NULL, col1_2 FLOAT4, col1_3 BOOL, col1_4 INET NOT NULL, col1_5 BOOL, col1_6 TIMESTAMPTZ NULL, col1_7 VARCHAR, col1_8 "char", col1_9 TIME NULL, col1_10 REGCLASS, col1_11 REGNAMESPACE NOT NULL, col1_12 REGTYPE NOT NULL, col1_13 STRING NOT NULL, PRIMARY KEY (col1_1, col1_0 ASC, col1_13 ASC, col1_11 ASC), col1_14 STRING NULL AS (lower(CAST(col1_9 AS STRING))) STORED, col1_15 STRING NOT NULL AS (lower(CAST(col1_4 AS STRING))) STORED, col1_16 STRING NULL AS (CASE WHEN col1_6 IS NULL THEN e'\x0b_[]Z':::STRING ELSE e'o1!w.\x06\'':::STRING END) STORED, col1_17 STRING NOT NULL AS (lower(col1_13)) STORED, UNIQUE (col1_12, lower(CAST(col1_10 AS STRING)) DESC, col1_13 ASC, col1_4 DESC, col1_3 DESC, col1_7) STORING (col1_5, col1_6, col1_9, col1_15, col1_16), INDEX (col1_15 DESC, col1_9 DESC, col1_1, col1_16 DESC), UNIQUE (col1_3 DESC, col1_4 ASC, col1_11 ASC, col1_13) WHERE ((NOT table1.col1_5) AND (table1.col1_16 = e'\x00':::STRING)) AND (table1.col1_6 != '0001-01-01 00:00:00+00:00':::TIMESTAMPTZ), INDEX (col1_14 ASC, col1_8, col1_12, col1_10, col1_13, col1_6, col1_11 DESC, col1_3 ASC, col1_0 DESC, col1_1 DESC, col1_9 DESC, col1_17 DESC, col1_7, col1_5 ASC, lower(col1_13)), INDEX (col1_10 ASC, col1_11, lower(col1_8) ASC, col1_9 ASC, col1_15 ASC, col1_7, col1_4 DESC, col1_8 ASC) STORING (col1_3, col1_6), INDEX (lower(CAST(col1_4 AS STRING)), col1_1) WHERE (((((((((((table1.col1_13 < e'\x00':::STRING) AND (table1.col1_14 = e'\'':::STRING)) OR (table1.col1_8 != '':::STRING)) OR (table1.col1_7 > '"':::STRING)) OR (table1.col1_6 < '-2000-01-01 00:00:00+00:00':::TIMESTAMPTZ)) AND (table1.col1_9 != '24:00:00':::TIME)) AND table1.col1_3) OR table1.col1_5) OR (table1.col1_17 < e'\'':::STRING)) OR (table1.col1_15 = '"':::STRING)) OR (table1.col1_16 > 'X':::STRING)) OR (table1.col1_2 <= (-1.0):::FLOAT8), FAMILY (col1_15), FAMILY (col1_1), FAMILY (col1_8), FAMILY (col1_4), FAMILY (col1_6), FAMILY (col1_9), FAMILY (col1_16, col1_12, col1_3), FAMILY (col1_11), FAMILY (col1_10), FAMILY (col1_13), FAMILY (col1_5), FAMILY (col1_0, col1_7, col1_17), FAMILY (col1_14, col1_2));
        CREATE TABLE table2 (col2_0 TIMESTAMP NOT NULL, col2_1 "char" NOT NULL, col2_2 INT4 NULL, col2_3 DECIMAL NULL, col2_4 TIMESTAMP NULL, col2_5 TIMESTAMPTZ NOT NULL, col2_6 JSONB NULL, col2_7 GEOGRAPHY, col2_8 OID NULL, col2_9 INTERVAL, col2_10 CHAR, col2_11 JSONB NOT NULL, col2_12 REGPROC NOT NULL, col2_13 BOX2D, col2_14 STRING NOT NULL AS (lower(CAST(col2_11 AS STRING))) STORED, col2_15 STRING AS (lower(CAST(col2_13 AS STRING))) STORED, col2_16 STRING AS (lower(CAST(col2_9 AS STRING))) VIRTUAL, col2_17 STRING NULL AS (lower(CAST(col2_4 AS STRING))) VIRTUAL, INVERTED INDEX (lower(CAST(col2_4 AS STRING)) ASC, col2_7 ASC) WHERE ((((((table2.col2_16 != '"':::STRING) AND (table2.col2_0 <= '-4713-11-24 00:00:00':::TIMESTAMP)) OR (table2.col2_3 >= 1:::DECIMAL)) OR (table2.col2_15 < e'\'':::STRING)) OR (table2.col2_17 < e'\'':::STRING)) OR (table2.col2_14 > e'\U00002603':::STRING)) OR (table2.col2_2 > 32767:::INT8), INVERTED INDEX (col2_2 ASC, col2_13 ASC, col2_0, col2_16 DESC, col2_14 DESC, col2_17, col2_6), INDEX (col2_0 DESC, col2_15, col2_10) STORING (col2_6, col2_7, col2_8, col2_11, col2_13), INDEX (col2_9 ASC, col2_17 DESC, col2_4) STORING (col2_0, col2_1, col2_7, col2_8, col2_13, col2_15), UNIQUE (col2_1));
        ALTER TABLE table1 INJECT STATISTICS e'[{"columns": ["col1_1"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 22562549847, "histo_col_type": "", "name": "__auto__", "null_count": 0, "row_count": 40000000000}, {"columns": ["col1_3"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 10216676632, "histo_col_type": "BOOL", "name": "__auto__", "null_count": 28333621757, "row_count": 40000000000}, {"columns": ["col1_10"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 23987689115, "histo_col_type": "", "name": "__auto__", "null_count": 345568252, "row_count": 40000000000}, {"columns": ["col1_13"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 35865044636, "histo_col_type": "", "name": "__auto__", "null_count": 0, "row_count": 40000000000}, {"columns": ["col1_14"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 28329492234, "histo_buckets": [{"distinct_range": 0, "num_eq": 4000000000, "num_range": 0, "upper_bound": "\\u0004\\"\\u00076%\\u000eI\\u0019"}], "histo_col_type": "STRING", "name": "__auto__", "null_count": 28248949204, "row_count": 40000000000}, {"columns": ["col1_17"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 12528488310, "histo_col_type": "", "name": "__auto__", "null_count": 0, "row_count": 40000000000}, {"columns": ["col1_8"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 15254941066, "histo_col_type": "", "name": "__auto__", "null_count": 17486921938, "row_count": 40000000000}, {"columns": ["col1_12"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 26630349385, "histo_buckets": [{"distinct_range": 0, "num_eq": 60000000, "num_range": 0, "upper_bound": "667044820"}, {"distinct_range": 0, "num_eq": 7000000000, "num_range": 4866614328731078000, "upper_bound": "2200577172"}, {"distinct_range": 0, "num_eq": 519076667440719499, "num_range": 3293998195691230240, "upper_bound": "2295102778"}], "histo_col_type": "REGTYPE", "name": "__auto__", "null_count": 0, "row_count": 40000000000}, {"columns": ["col1_15"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 31896697078, "histo_buckets": [{"distinct_range": 0, "num_eq": 6877082480766721361, "num_range": 0, "upper_bound": "8"}, {"distinct_range": 2461841112996175400, "num_eq": 8000000000, "num_range": 8684946611454311432, "upper_bound": "[R\'[R"}], "histo_col_type": "STRING", "name": "__auto__", "null_count": 0, "row_count": 40000000000}, {"columns": ["col1_0"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 17436258137, "histo_col_type": "", "name": "__auto__", "null_count": 0, "row_count": 40000000000}, {"columns": ["col1_2"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 1919843317, "histo_col_type": "", "name": "__auto__", "null_count": 6299160867, "row_count": 40000000000}, {"columns": ["col1_6"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 30596887379, "histo_col_type": "", "name": "__auto__", "null_count": 2849031256, "row_count": 40000000000}, {"columns": ["col1_7"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 32678022664, "histo_col_type": "", "name": "__auto__", "null_count": 25742861133, "row_count": 40000000000}, {"columns": ["col1_11"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 22921931641, "histo_col_type": "", "name": "__auto__", "null_count": 0, "row_count": 40000000000}, {"columns": ["col1_16"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 7545001956, "histo_col_type": "", "name": "__auto__", "null_count": 11928157338, "row_count": 40000000000}, {"columns": ["col1_4"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 24165820087, "histo_col_type": "", "name": "__auto__", "null_count": 0, "row_count": 40000000000}, {"columns": ["col1_5"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 8215157302, "histo_col_type": "", "name": "__auto__", "null_count": 10546979335, "row_count": 40000000000}, {"columns": ["col1_9"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 31283284314, "histo_col_type": "", "name": "__auto__", "null_count": 16125694728, "row_count": 40000000000}]':::JSONB;
        ALTER TABLE table2 INJECT STATISTICS '[{"columns": ["col2_6"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 430729251, "histo_col_type": "", "name": "__auto__", "null_count": 319573150, "row_count": 1000000000}, {"columns": ["col2_8"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 837566359, "histo_col_type": "", "name": "__auto__", "null_count": 740110857, "row_count": 1000000000}, {"columns": ["col2_10"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 383234667, "histo_col_type": "", "name": "__auto__", "null_count": 920689037, "row_count": 1000000000}, {"columns": ["col2_14"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 940776773, "histo_col_type": "", "name": "__auto__", "null_count": 0, "row_count": 1000000000}, {"columns": ["col2_15"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 787588083, "histo_col_type": "", "name": "__auto__", "null_count": 252103127, "row_count": 1000000000}, {"columns": ["col2_3"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 369522606, "histo_col_type": "", "name": "__auto__", "null_count": 561397213, "row_count": 1000000000}, {"columns": ["col2_2"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 417236283, "histo_buckets": [{"distinct_range": 0, "num_eq": 80000, "num_range": 0, "upper_bound": "-1254998480"}, {"distinct_range": 0, "num_eq": 5199263274049500917, "num_range": 100000000000, "upper_bound": "-126191361"}, {"distinct_range": 0, "num_eq": 600000, "num_range": 3210704078850259710, "upper_bound": "-9216801"}, {"distinct_range": 0, "num_eq": 1831799124136122947, "num_range": 2631528938018814614, "upper_bound": "0"}, {"distinct_range": 0, "num_eq": 900, "num_range": 80000000000, "upper_bound": "435718893"}, {"distinct_range": 0, "num_eq": 40000000000, "num_range": 0, "upper_bound": "1015546728"}, {"distinct_range": 0, "num_eq": 500000000, "num_range": 0, "upper_bound": "1144000714"}, {"distinct_range": 193005156.3151001, "num_eq": 2932598944005359114, "num_range": 200000000, "upper_bound": "1543410312"}], "histo_col_type": "INT4", "name": "__auto__", "null_count": 353958909, "row_count": 1000000000}, {"columns": ["col2_1"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 288455059, "histo_col_type": "", "name": "__auto__", "null_count": 0, "row_count": 1000000000}, {"columns": ["col2_4"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 292647693, "histo_col_type": "", "name": "__auto__", "null_count": 353101567, "row_count": 1000000000}, {"columns": ["col2_9"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 489401842, "histo_buckets": [{"distinct_range": 0, "num_eq": 10000, "num_range": 0, "upper_bound": "-48 years -6 mons -938 days -09:50:48.335596"}], "histo_col_type": "INTERVAL", "name": "__auto__", "null_count": 370733233, "row_count": 1000000000}, {"columns": ["col2_12"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 223357411, "histo_col_type": "", "name": "__auto__", "null_count": 0, "row_count": 1000000000}, {"columns": ["col2_17"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 969544295, "histo_col_type": "", "name": "__auto__", "null_count": 479510289, "row_count": 1000000000}, {"columns": ["col2_0"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 179111433, "histo_buckets": [{"distinct_range": 0, "num_eq": 8348843158999976916, "num_range": 0, "upper_bound": "1997-09-16 14:46:49.000555"}, {"distinct_range": 2487418476919924000, "num_eq": 8000, "num_range": 5349587970574729688, "upper_bound": "2017-01-01 18:00:48.000792"}, {"distinct_range": 1596387952549213400, "num_eq": 8000, "num_range": 1596387952549213488, "upper_bound": "2031-04-26 12:28:06.000631"}], "histo_col_type": "TIMESTAMP", "name": "__auto__", "null_count": 0, "row_count": 1000000000}, {"columns": ["col2_7"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 103040275, "histo_col_type": "", "name": "__auto__", "null_count": 878425215, "row_count": 1000000000}, {"columns": ["col2_11"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 687047136, "histo_col_type": "", "name": "__auto__", "null_count": 0, "row_count": 1000000000}, {"columns": ["col2_13"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 888961344, "histo_col_type": "", "name": "__auto__", "null_count": 84780854, "row_count": 1000000000}, {"columns": ["col2_16"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 587184099, "histo_col_type": "", "name": "__auto__", "null_count": 756888632, "row_count": 1000000000}, {"columns": ["col2_5"], "created_at": "2000-01-01 00:00:00+00:00", "distinct_count": 807619097, "histo_col_type": "", "name": "__auto__", "null_count": 0, "row_count": 1000000000}]':::JSONB;
        ALTER TABLE table1 ADD FOREIGN KEY (col1_8) REFERENCES table2 (col2_1) ON DELETE CASCADE;
        CREATE TYPE rand_typ_0 AS ENUM ('c', 'pxgn', 'yyea', 'zrr', 'zhce');
        ;
    rsg_test.go:598: 
        CREATE TYPE greeting AS ENUM ('hello', 'howdy', 'hi', 'good day', 'morning');
        CREATE TABLE IF NOT EXISTS seed AS
        	SELECT
        		g::INT2 AS _int2,
        		g::INT4 AS _int4,
        		g::INT8 AS _int8,
        		g::FLOAT4 AS _float4,
        		g::FLOAT8 AS _float8,
        		'2001-01-01'::DATE + g AS _date,
        		'2001-01-01'::TIMESTAMP + g * '1 day'::INTERVAL AS _timestamp,
        		'2001-01-01'::TIMESTAMPTZ + g * '1 day'::INTERVAL AS _timestamptz,
        		g * '1 day'::INTERVAL AS _interval,
        		g % 2 = 1 AS _bool,
        		g::DECIMAL AS _decimal,
        		g::STRING AS _string,
        		g::STRING::BYTES AS _bytes,
        		substring('00000000-0000-0000-0000-' || g::STRING || '00000000000', 1, 36)::UUID AS _uuid,
        		'0.0.0.0'::INET + g AS _inet,
        		g::STRING::JSONB AS _jsonb,
        		enum_range('hello'::greeting)[g] as _enum
        	FROM
        		generate_series(1, 5) AS g;
        
        INSERT INTO seed DEFAULT VALUES;
        CREATE INDEX on seed (_int8, _float8, _date);
        CREATE INVERTED INDEX on seed (_jsonb);
        ;
    rsg_test.go:600: 
    rsg_test.go:601: -- test log scope end --
test logs left over in: /go/src/github.com/cockroachdb/cockroach/artifacts/logTestRandomSyntaxSQLSmith238858753
--- FAIL: TestRandomSyntaxSQLSmith (300.90s)
Reproduce

To reproduce, try:

make stressrace TESTS=TestRandomSyntaxSQLSmith PKG=./pkg/sql/tests TESTTIMEOUT=5m STRESSFLAGS='-timeout 5m' 2>&1

Same failure on other branches

Internal log

mjibson marked as alumn{us/a}; resolving to rafiss instead

/cc @cockroachdb/sql-experience rafiss

This test on roachdash | Improve this report!

Jira issue: CRDB-10164

Metadata

Metadata

Assignees

Labels

C-test-failureBroken test (automatically or manually discovered).O-robotOriginated from a bot.T-sql-queriesSQL Queries Teambranch-masterFailures and bugs on the master branch.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions