Skip to content

Commit 3e870df

Browse files
committed
builtins: add more builtins to DistsqlBlocklist
While adding a builtin for a test, I noticed that a neighboring builtin that accessed `evalctx.Planner` was not marked with `DistsqlBlocklist`. Then I noticed that many more functions accessing Planner were not marked with `DistsqlBlocklist`. I tried to ignore it, but I could not. Hence this yak-shave. Epic: None Release note: None
1 parent be2cc31 commit 3e870df

File tree

4 files changed

+117
-54
lines changed

4 files changed

+117
-54
lines changed

pkg/sql/sem/builtins/builtins.go

Lines changed: 57 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4439,7 +4439,8 @@ value if you rely on the HLC for accuracy.`,
44394439

44404440
"oidvectortypes": makeBuiltin(
44414441
tree.FunctionProperties{
4442-
Category: builtinconstants.CategoryCompatibility,
4442+
Category: builtinconstants.CategoryCompatibility,
4443+
DistsqlBlocklist: true, // applicable only on the gateway
44434444
},
44444445
tree.Overload{
44454446
Types: tree.ParamTypes{
@@ -4631,7 +4632,10 @@ value if you rely on the HLC for accuracy.`,
46314632
}),
46324633

46334634
"crdb_internal.read_file": makeBuiltin(
4634-
tree.FunctionProperties{Category: builtinconstants.CategorySystemInfo},
4635+
tree.FunctionProperties{
4636+
Category: builtinconstants.CategorySystemInfo,
4637+
DistsqlBlocklist: true, // applicable only on the gateway
4638+
},
46354639
tree.Overload{
46364640
Types: tree.ParamTypes{
46374641
{Name: "uri", Typ: types.String},
@@ -4647,7 +4651,10 @@ value if you rely on the HLC for accuracy.`,
46474651
}),
46484652

46494653
"crdb_internal.write_file": makeBuiltin(
4650-
tree.FunctionProperties{Category: builtinconstants.CategorySystemInfo},
4654+
tree.FunctionProperties{
4655+
Category: builtinconstants.CategorySystemInfo,
4656+
DistsqlBlocklist: true, // applicable only on the gateway
4657+
},
46514658
tree.Overload{
46524659
Types: tree.ParamTypes{
46534660
{Name: "data", Typ: types.Bytes},
@@ -7805,7 +7812,8 @@ table's zone configuration this will return NULL.`,
78057812
// for table %d"
78067813
"crdb_internal.force_delete_table_data": makeBuiltin(
78077814
tree.FunctionProperties{
7808-
Category: builtinconstants.CategorySystemRepair,
7815+
Category: builtinconstants.CategorySystemRepair,
7816+
DistsqlBlocklist: true, // applicable only on the gateway
78097817
},
78107818
tree.Overload{
78117819
Types: tree.ParamTypes{{Name: "id", Typ: types.Int}},
@@ -7826,7 +7834,8 @@ table's zone configuration this will return NULL.`,
78267834

78277835
"crdb_internal.serialize_session": makeBuiltin(
78287836
tree.FunctionProperties{
7829-
Category: builtinconstants.CategorySystemInfo,
7837+
Category: builtinconstants.CategorySystemInfo,
7838+
DistsqlBlocklist: true, // applicable only on the gateway
78307839
},
78317840
tree.Overload{
78327841
Types: tree.ParamTypes{},
@@ -7841,7 +7850,8 @@ table's zone configuration this will return NULL.`,
78417850

78427851
"crdb_internal.deserialize_session": makeBuiltin(
78437852
tree.FunctionProperties{
7844-
Category: builtinconstants.CategorySystemInfo,
7853+
Category: builtinconstants.CategorySystemInfo,
7854+
DistsqlBlocklist: true, // applicable only on the gateway
78457855
},
78467856
tree.Overload{
78477857
Types: tree.ParamTypes{{Name: "session", Typ: types.Bytes}},
@@ -7857,7 +7867,8 @@ table's zone configuration this will return NULL.`,
78577867

78587868
"crdb_internal.create_session_revival_token": makeBuiltin(
78597869
tree.FunctionProperties{
7860-
Category: builtinconstants.CategorySystemInfo,
7870+
Category: builtinconstants.CategorySystemInfo,
7871+
DistsqlBlocklist: true, // applicable only on the gateway
78617872
},
78627873
tree.Overload{
78637874
Types: tree.ParamTypes{},
@@ -7871,7 +7882,8 @@ table's zone configuration this will return NULL.`,
78717882
),
78727883
"crdb_internal.validate_session_revival_token": makeBuiltin(
78737884
tree.FunctionProperties{
7874-
Category: builtinconstants.CategorySystemInfo,
7885+
Category: builtinconstants.CategorySystemInfo,
7886+
DistsqlBlocklist: true, // applicable only on the gateway
78757887
},
78767888
tree.Overload{
78777889
Types: tree.ParamTypes{{Name: "token", Typ: types.Bytes}},
@@ -7887,7 +7899,8 @@ table's zone configuration this will return NULL.`,
78877899

78887900
"crdb_internal.validate_ttl_scheduled_jobs": makeBuiltin(
78897901
tree.FunctionProperties{
7890-
Category: builtinconstants.CategorySystemInfo,
7902+
Category: builtinconstants.CategorySystemInfo,
7903+
DistsqlBlocklist: true, // applicable only on the gateway
78917904
},
78927905
tree.Overload{
78937906
Types: tree.ParamTypes{},
@@ -7907,7 +7920,8 @@ table's zone configuration this will return NULL.`,
79077920

79087921
"crdb_internal.repair_ttl_table_scheduled_job": makeBuiltin(
79097922
tree.FunctionProperties{
7910-
Category: builtinconstants.CategorySystemInfo,
7923+
Category: builtinconstants.CategorySystemInfo,
7924+
DistsqlBlocklist: true, // applicable only on the gateway
79117925
},
79127926
tree.Overload{
79137927
Types: tree.ParamTypes{{Name: "oid", Typ: types.Oid}},
@@ -8007,7 +8021,8 @@ table's zone configuration this will return NULL.`,
80078021

80088022
"crdb_internal.revalidate_unique_constraints_in_all_tables": makeBuiltin(
80098023
tree.FunctionProperties{
8010-
Category: builtinconstants.CategorySystemInfo,
8024+
Category: builtinconstants.CategorySystemInfo,
8025+
DistsqlBlocklist: true, // applicable only on the gateway
80118026
},
80128027
tree.Overload{
80138028
Types: tree.ParamTypes{},
@@ -8429,7 +8444,8 @@ specified store on the node it's run from. One of 'mvccGC', 'merge', 'split',
84298444
),
84308445
"crdb_internal.fingerprint": makeBuiltin(
84318446
tree.FunctionProperties{
8432-
Category: builtinconstants.CategorySystemInfo,
8447+
Category: builtinconstants.CategorySystemInfo,
8448+
DistsqlBlocklist: true, // applicable only on the gateway
84338449
},
84348450
tree.Overload{
84358451
// If the second arg is set to true, this overload allows the caller to
@@ -9015,8 +9031,9 @@ specified store on the node it's run from. One of 'mvccGC', 'merge', 'split',
90159031
},
90169032
),
90179033
"crdb_internal.plpgsql_gen_cursor_name": makeBuiltin(tree.FunctionProperties{
9018-
Category: builtinconstants.CategoryIDGeneration,
9019-
Undocumented: true,
9034+
Category: builtinconstants.CategoryIDGeneration,
9035+
Undocumented: true,
9036+
DistsqlBlocklist: true, // applicable only on the gateway
90209037
},
90219038
tree.Overload{
90229039
Types: tree.ParamTypes{
@@ -9036,8 +9053,9 @@ specified store on the node it's run from. One of 'mvccGC', 'merge', 'split',
90369053
},
90379054
),
90389055
"crdb_internal.plpgsql_close": makeBuiltin(tree.FunctionProperties{
9039-
Category: builtinconstants.CategoryString,
9040-
Undocumented: true,
9056+
Category: builtinconstants.CategoryString,
9057+
Undocumented: true,
9058+
DistsqlBlocklist: true, // applicable only on the gateway
90419059
},
90429060
tree.Overload{
90439061
Types: tree.ParamTypes{{Name: "name", Typ: types.RefCursor}},
@@ -9056,8 +9074,9 @@ specified store on the node it's run from. One of 'mvccGC', 'merge', 'split',
90569074
},
90579075
),
90589076
"crdb_internal.plpgsql_fetch": makeBuiltin(tree.FunctionProperties{
9059-
Category: builtinconstants.CategoryString,
9060-
Undocumented: true,
9077+
Category: builtinconstants.CategoryString,
9078+
Undocumented: true,
9079+
DistsqlBlocklist: true, // applicable only on the gateway
90619080
},
90629081
tree.Overload{
90639082
Types: tree.ParamTypes{
@@ -9112,8 +9131,9 @@ specified store on the node it's run from. One of 'mvccGC', 'merge', 'split',
91129131
),
91139132
"crdb_internal.protect_mvcc_history": makeBuiltin(
91149133
tree.FunctionProperties{
9115-
Category: builtinconstants.CategoryClusterReplication,
9116-
Undocumented: true,
9134+
Category: builtinconstants.CategoryClusterReplication,
9135+
Undocumented: true,
9136+
DistsqlBlocklist: true, // applicable only on the gateway
91179137
},
91189138
tree.Overload{
91199139
Types: tree.ParamTypes{
@@ -9150,8 +9170,9 @@ specified store on the node it's run from. One of 'mvccGC', 'merge', 'split',
91509170
),
91519171
"crdb_internal.extend_mvcc_history_protection": makeBuiltin(
91529172
tree.FunctionProperties{
9153-
Category: builtinconstants.CategoryClusterReplication,
9154-
Undocumented: true,
9173+
Category: builtinconstants.CategoryClusterReplication,
9174+
Undocumented: true,
9175+
DistsqlBlocklist: true, // applicable only on the gateway
91559176
},
91569177
tree.Overload{
91579178
Types: tree.ParamTypes{
@@ -9174,8 +9195,9 @@ specified store on the node it's run from. One of 'mvccGC', 'merge', 'split',
91749195
),
91759196
"crdb_internal.clear_query_plan_cache": makeBuiltin(
91769197
tree.FunctionProperties{
9177-
Category: builtinconstants.CategorySystemRepair,
9178-
Undocumented: true,
9198+
Category: builtinconstants.CategorySystemRepair,
9199+
Undocumented: true,
9200+
DistsqlBlocklist: true, // applicable only on the gateway
91799201
},
91809202
tree.Overload{
91819203
Types: tree.ParamTypes{},
@@ -9190,8 +9212,9 @@ specified store on the node it's run from. One of 'mvccGC', 'merge', 'split',
91909212
),
91919213
"crdb_internal.clear_table_stats_cache": makeBuiltin(
91929214
tree.FunctionProperties{
9193-
Category: builtinconstants.CategorySystemRepair,
9194-
Undocumented: true,
9215+
Category: builtinconstants.CategorySystemRepair,
9216+
Undocumented: true,
9217+
DistsqlBlocklist: true, // applicable only on the gateway
91959218
},
91969219
tree.Overload{
91979220
Types: tree.ParamTypes{},
@@ -9221,7 +9244,11 @@ WHERE object_id = table_descriptor_id
92219244
Language: tree.RoutineLangSQL,
92229245
},
92239246
),
9224-
"crdb_internal.type_is_indexable": makeBuiltin(defProps(),
9247+
"crdb_internal.type_is_indexable": makeBuiltin(
9248+
tree.FunctionProperties{
9249+
Category: builtinconstants.CategorySystemInfo,
9250+
DistsqlBlocklist: true, // applicable only on the gateway
9251+
},
92259252
tree.Overload{
92269253
Types: tree.ParamTypes{{Name: "oid", Typ: types.Oid}},
92279254
ReturnType: tree.FixedReturnType(types.Bool),
@@ -9244,8 +9271,9 @@ WHERE object_id = table_descriptor_id
92449271
),
92459272
"crdb_internal.backup_compaction": makeBuiltin(
92469273
tree.FunctionProperties{
9247-
Undocumented: true,
9248-
ReturnLabels: []string{"job_id"},
9274+
Undocumented: true,
9275+
DistsqlBlocklist: true, // applicable only on the gateway
9276+
ReturnLabels: []string{"job_id"},
92499277
},
92509278
tree.Overload{
92519279
Types: tree.ParamTypes{

pkg/sql/sem/builtins/generator_builtins.go

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,11 @@ var generators = map[string]builtinDefinition{
140140
volatility.Stable,
141141
),
142142
),
143-
"crdb_internal.scan": makeBuiltin(genProps(),
143+
"crdb_internal.scan": makeBuiltin(
144+
tree.FunctionProperties{
145+
Category: builtinconstants.CategoryGenerator,
146+
DistsqlBlocklist: true, // applicable only on the gateway
147+
},
144148
makeGeneratorOverload(
145149
tree.ParamTypes{
146150
{Name: "start_key", Typ: types.Bytes},
@@ -296,7 +300,11 @@ var generators = map[string]builtinDefinition{
296300
),
297301
),
298302

299-
"workload_index_recs": makeBuiltin(genProps(),
303+
"workload_index_recs": makeBuiltin(
304+
tree.FunctionProperties{
305+
Category: builtinconstants.CategoryGenerator,
306+
DistsqlBlocklist: true, // applicable only on the gateway
307+
},
300308
makeGeneratorOverload(
301309
tree.ParamTypes{},
302310
WorkloadIndexRecsGeneratorType,
@@ -501,7 +509,8 @@ var generators = map[string]builtinDefinition{
501509

502510
"crdb_internal.list_sql_keys_in_range": makeBuiltin(
503511
tree.FunctionProperties{
504-
Category: builtinconstants.CategorySystemInfo,
512+
Category: builtinconstants.CategorySystemInfo,
513+
DistsqlBlocklist: true, // applicable only on the gateway
505514
},
506515
makeGeneratorOverload(
507516
tree.ParamTypes{
@@ -516,7 +525,8 @@ var generators = map[string]builtinDefinition{
516525

517526
"crdb_internal.payloads_for_span": makeBuiltin(
518527
tree.FunctionProperties{
519-
Category: builtinconstants.CategorySystemInfo,
528+
Category: builtinconstants.CategorySystemInfo,
529+
DistsqlBlocklist: true, // applicable only on the gateway
520530
},
521531
makeGeneratorOverload(
522532
tree.ParamTypes{
@@ -530,7 +540,8 @@ var generators = map[string]builtinDefinition{
530540
),
531541
"crdb_internal.payloads_for_trace": makeBuiltin(
532542
tree.FunctionProperties{
533-
Category: builtinconstants.CategorySystemInfo,
543+
Category: builtinconstants.CategorySystemInfo,
544+
DistsqlBlocklist: true, // applicable only on the gateway
534545
},
535546
makeGeneratorOverload(
536547
tree.ParamTypes{
@@ -543,7 +554,10 @@ var generators = map[string]builtinDefinition{
543554
),
544555
),
545556
"crdb_internal.show_create_all_schemas": makeBuiltin(
546-
tree.FunctionProperties{},
557+
tree.FunctionProperties{
558+
Category: builtinconstants.CategorySystemInfo,
559+
DistsqlBlocklist: true, // applicable only on the gateway
560+
},
547561
makeGeneratorOverload(
548562
tree.ParamTypes{
549563
{Name: "database_name", Typ: types.String},
@@ -557,7 +571,10 @@ The output can be used to recreate a database.'
557571
),
558572
),
559573
"crdb_internal.show_create_all_tables": makeBuiltin(
560-
tree.FunctionProperties{},
574+
tree.FunctionProperties{
575+
Category: builtinconstants.CategorySystemInfo,
576+
DistsqlBlocklist: true, // applicable only on the gateway
577+
},
561578
makeGeneratorOverload(
562579
tree.ParamTypes{
563580
{Name: "database_name", Typ: types.String},
@@ -588,7 +605,10 @@ The output can be used to recreate a database.'
588605
),
589606
),
590607
"crdb_internal.show_create_all_types": makeBuiltin(
591-
tree.FunctionProperties{},
608+
tree.FunctionProperties{
609+
Category: builtinconstants.CategorySystemInfo,
610+
DistsqlBlocklist: true, // applicable only on the gateway
611+
},
592612
makeGeneratorOverload(
593613
tree.ParamTypes{
594614
{Name: "database_name", Typ: types.String},
@@ -614,7 +634,10 @@ The output can be used to recreate a database.'
614634
),
615635
),
616636
"crdb_internal.decode_plan_gist": makeBuiltin(
617-
tree.FunctionProperties{},
637+
tree.FunctionProperties{
638+
Category: builtinconstants.CategorySystemInfo,
639+
DistsqlBlocklist: true, // applicable only on the gateway
640+
},
618641
makeGeneratorOverload(
619642
tree.ParamTypes{
620643
{Name: "gist", Typ: types.String},
@@ -627,7 +650,9 @@ The output can be used to recreate a database.'
627650
),
628651
),
629652
"crdb_internal.decode_external_plan_gist": makeBuiltin(
630-
tree.FunctionProperties{},
653+
tree.FunctionProperties{
654+
DistsqlBlocklist: true, // applicable only on the gateway
655+
},
631656
makeGeneratorOverload(
632657
tree.ParamTypes{
633658
{Name: "gist", Typ: types.String},
@@ -677,7 +702,11 @@ The last argument is a JSONB object containing the following optional fields:
677702
volatility.Volatile,
678703
),
679704
),
680-
"crdb_internal.tenant_span_stats": makeBuiltin(genProps(),
705+
"crdb_internal.tenant_span_stats": makeBuiltin(
706+
tree.FunctionProperties{
707+
Category: builtinconstants.CategoryGenerator,
708+
DistsqlBlocklist: true, // applicable only on the gateway
709+
},
681710
// This overload defines a built-in that returns the range count,
682711
// approximate disk size, live range bytes, total range bytes,
683712
// and live range byte percentage for all tables that belong to the
@@ -735,7 +764,8 @@ The last argument is a JSONB object containing the following optional fields:
735764
),
736765
"crdb_internal.sstable_metrics": makeBuiltin(
737766
tree.FunctionProperties{
738-
Category: builtinconstants.CategorySystemInfo,
767+
Category: builtinconstants.CategorySystemInfo,
768+
DistsqlBlocklist: true, // applicable only on the gateway
739769
},
740770
makeGeneratorOverload(
741771
tree.ParamTypes{
@@ -752,7 +782,8 @@ The last argument is a JSONB object containing the following optional fields:
752782
),
753783
"crdb_internal.scan_storage_internal_keys": makeBuiltin(
754784
tree.FunctionProperties{
755-
Category: builtinconstants.CategorySystemInfo,
785+
Category: builtinconstants.CategorySystemInfo,
786+
DistsqlBlocklist: true, // applicable only on the gateway
756787
},
757788
makeGeneratorOverload(
758789
tree.ParamTypes{
@@ -782,8 +813,9 @@ The last argument is a JSONB object containing the following optional fields:
782813
),
783814
"crdb_internal.execute_internally": makeBuiltin(
784815
tree.FunctionProperties{
785-
Undocumented: true,
786-
Category: builtinconstants.CategoryGenerator,
816+
Undocumented: true,
817+
Category: builtinconstants.CategoryGenerator,
818+
DistsqlBlocklist: true, // applicable only on the gateway
787819
},
788820
makeInternallyExecutedQueryGeneratorOverload(false /* withSessionBound */, false /* withOverrides */, false /* withTxn */),
789821
makeInternallyExecutedQueryGeneratorOverload(true /* withSessionBound */, false /* withOverrides */, false /* withTxn */),

0 commit comments

Comments
 (0)