Skip to content

Commit 832e5f2

Browse files
craig[bot]fqazirafiss
committed
107233: sql: TestRandomSyntaxFunctions fix flakes r=fqazi a=fqazi Previously, this test could flake due to the following: 1. The timeout is used for specific functions, so moving to a resettable timeout is beneficial, which allows these to be extended as long as connections make progress 2. Panics inside crdb_internal.tenant_span_stats due to nil pointer dereferences. Fixes: cockroachdb#99182 Fixes: cockroachdb#107237 107358: sql: handle mixed-case for pg_get_serial_sequence r=rafiss a=rafiss fixes cockroachdb#107234 Release note (bug fix): The pg_get_serial_sequence builtin function can now handle mixed-case names correctly. Co-authored-by: Faizan Qazi <[email protected]> Co-authored-by: Rafi Shamim <[email protected]>
3 parents 4a6fb8c + b81f3de + d771ace commit 832e5f2

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

pkg/sql/logictest/testdata/logic_test/serial

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,18 @@ create table serial_2 ("capITALS" SERIAL)
245245
query T
246246
SELECT pg_get_serial_sequence('serial_2', 'capITALS')
247247
----
248-
public.serial_2_capITALS_seq
248+
public."serial_2_capITALS_seq"
249+
250+
statement ok
251+
create schema "schema-hyphen"
252+
253+
statement ok
254+
create table "schema-hyphen"."Serial_3" ("capITALS" SERIAL)
255+
256+
query T
257+
SELECT pg_get_serial_sequence('"schema-hyphen"."Serial_3"', 'capITALS')
258+
----
259+
"schema-hyphen"."Serial_3_capITALS_seq"
249260

250261
statement ok
251262
INSERT INTO serial (a, b) VALUES (0, 2), (DEFAULT, DEFAULT), (DEFAULT, 3)

pkg/sql/sem/builtins/generator_builtins.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3314,7 +3314,7 @@ func makeSpanStatsGenerator(
33143314
spans := make([]roachpb.Span, 0, argSpans.Len())
33153315
for _, span := range argSpans.Array {
33163316
s := tree.MustBeDTuple(span)
3317-
if s.D[0] == tree.DNull || s.D[1] == tree.DNull {
3317+
if len(s.D) != 2 || s.D[0] == tree.DNull || s.D[1] == tree.DNull {
33183318
continue
33193319
}
33203320
startKey := roachpb.Key(tree.MustBeDBytes(s.D[0]))

pkg/sql/sem/builtins/pg_builtins.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ var pgBuiltins = map[string]builtinDefinition{
849849
return tree.DNull, nil
850850
}
851851
res.ExplicitCatalog = false
852-
return tree.NewDString(fmt.Sprintf(`%s.%s`, res.Schema(), res.Object())), nil
852+
return tree.NewDString(fmt.Sprintf(`%s.%s`, res.SchemaName.String(), res.ObjectName.String())), nil
853853
},
854854
Info: "Returns the name of the sequence used by the given column_name in the table table_name.",
855855
Volatility: volatility.Stable,

pkg/sql/tests/rsg_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,8 @@ func TestRandomSyntaxFunctions(t *testing.T) {
352352
continue
353353
case "crdb_internal.reset_sql_stats",
354354
"crdb_internal.check_consistency",
355-
"crdb_internal.request_statement_bundle":
355+
"crdb_internal.request_statement_bundle",
356+
"crdb_internal.reset_activity_tables":
356357
// Skipped due to long execution time.
357358
continue
358359
}
@@ -414,7 +415,11 @@ func TestRandomSyntaxFunctions(t *testing.T) {
414415
limit = " LIMIT 100"
415416
}
416417
s := fmt.Sprintf("SELECT %s(%s) %s", nb.name, strings.Join(args, ", "), limit)
417-
return db.exec(t, ctx, s)
418+
// Use a re-settable timeout since in concurrent scenario some operations may
419+
// involve schema changes like truncates. In general this should make
420+
// this test more resilient as the timeouts are reset as long progress
421+
// is made on *some* connection.
422+
return db.execWithResettableTimeout(t, ctx, s, *flagRSGExecTimeout, *flagRSGGoRoutines)
418423
})
419424
}
420425

0 commit comments

Comments
 (0)