@@ -709,7 +709,7 @@ CREATE TABLE crdb_internal.pg_catalog_table_is_implemented (
709709 name STRING NOT NULL,
710710 implemented BOOL
711711)` ,
712- generator : func (ctx context.Context , p * planner , dbDesc catalog.DatabaseDescriptor , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
712+ generator : func (ctx context.Context , p * planner , dbDesc catalog.DatabaseDescriptor , _ int64 , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
713713 row := make (tree.Datums , 2 )
714714 worker := func (ctx context.Context , pusher rowPusher ) error {
715715 addDesc := func (table * virtualDefEntry , dbName tree.Datum , scName string ) error {
@@ -3852,7 +3852,7 @@ CREATE TABLE crdb_internal.table_columns (
38523852 hidden BOOL NOT NULL
38533853)
38543854` ,
3855- generator : func (ctx context.Context , p * planner , dbContext catalog.DatabaseDescriptor , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
3855+ generator : func (ctx context.Context , p * planner , dbContext catalog.DatabaseDescriptor , _ int64 , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
38563856 const numDatums = 8
38573857 row := make (tree.Datums , numDatums )
38583858 worker := func (ctx context.Context , pusher rowPusher ) error {
@@ -3921,7 +3921,7 @@ CREATE TABLE crdb_internal.table_indexes (
39213921 create_statement STRING NOT NULL
39223922)
39233923` ,
3924- generator : func (ctx context.Context , p * planner , dbContext catalog.DatabaseDescriptor , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
3924+ generator : func (ctx context.Context , p * planner , dbContext catalog.DatabaseDescriptor , _ int64 , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
39253925 primary := tree .NewDString ("primary" )
39263926 secondary := tree .NewDString ("secondary" )
39273927 const numDatums = 13
@@ -4490,7 +4490,7 @@ CREATE TABLE crdb_internal.ranges_no_leases (
44904490)
44914491` ,
44924492 resultColumns : colinfo .RangesNoLeases ,
4493- generator : func (ctx context.Context , p * planner , _ catalog.DatabaseDescriptor , _ * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
4493+ generator : func (ctx context.Context , p * planner , _ catalog.DatabaseDescriptor , limit int64 , _ * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
44944494 hasAdmin , err := p .HasAdminRole (ctx )
44954495 if err != nil {
44964496 return nil , nil , err
@@ -4525,7 +4525,11 @@ CREATE TABLE crdb_internal.ranges_no_leases (
45254525 }
45264526
45274527 execCfg := p .ExecCfg ()
4528- rangeDescIterator , err := execCfg .RangeDescIteratorFactory .NewIterator (ctx , execCfg .Codec .TenantSpan ())
4528+ pageSize := int64 (128 )
4529+ if limit > 0 {
4530+ pageSize = min (limit , pageSize )
4531+ }
4532+ rangeDescIterator , err := execCfg .RangeDescIteratorFactory .NewLazyIterator (ctx , execCfg .Codec .TenantSpan (), int (pageSize ))
45294533 if err != nil {
45304534 return nil , nil , err
45314535 }
@@ -5429,7 +5433,7 @@ CREATE TABLE crdb_internal.partitions (
54295433 subzone_id INT -- references a subzone id in the crdb_internal.zones table
54305434)
54315435 ` ,
5432- generator : func (ctx context.Context , p * planner , dbContext catalog.DatabaseDescriptor , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
5436+ generator : func (ctx context.Context , p * planner , dbContext catalog.DatabaseDescriptor , _ int64 , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
54335437 dbName := ""
54345438 if dbContext != nil {
54355439 dbName = dbContext .GetName ()
@@ -6875,7 +6879,7 @@ CREATE TABLE crdb_internal.index_usage_statistics (
68756879 total_reads INT NOT NULL,
68766880 last_read TIMESTAMPTZ
68776881);` ,
6878- generator : func (ctx context.Context , p * planner , dbContext catalog.DatabaseDescriptor , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
6882+ generator : func (ctx context.Context , p * planner , dbContext catalog.DatabaseDescriptor , _ int64 , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
68796883 // Perform RPC Fanout.
68806884 stats , err :=
68816885 p .extendedEvalCtx .SQLStatusServer .IndexUsageStatistics (ctx , & serverpb.IndexUsageStatisticsRequest {})
@@ -6940,7 +6944,7 @@ CREATE TABLE crdb_internal.cluster_statement_statistics (
69406944 aggregation_interval INTERVAL NOT NULL,
69416945 index_recommendations STRING[] NOT NULL
69426946);` ,
6943- generator : func (ctx context.Context , p * planner , db catalog.DatabaseDescriptor , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
6947+ generator : func (ctx context.Context , p * planner , db catalog.DatabaseDescriptor , _ int64 , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
69446948 // TODO(azhng): we want to eventually implement memory accounting within the
69456949 // RPC handlers. See #69032.
69466950 acc := p .Mon ().MakeBoundAccount ()
@@ -7371,7 +7375,7 @@ CREATE TABLE crdb_internal.cluster_transaction_statistics (
73717375 statistics JSONB NOT NULL,
73727376 aggregation_interval INTERVAL NOT NULL
73737377);` ,
7374- generator : func (ctx context.Context , p * planner , db catalog.DatabaseDescriptor , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
7378+ generator : func (ctx context.Context , p * planner , db catalog.DatabaseDescriptor , _ int64 , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
73757379 // TODO(azhng): we want to eventually implement memory accounting within the
73767380 // RPC handlers. See #69032.
73777381 acc := p .Mon ().MakeBoundAccount ()
@@ -7692,7 +7696,7 @@ CREATE TABLE crdb_internal.transaction_contention_events (
76927696 index_name STRING,
76937697 contention_type STRING NOT NULL
76947698);` ,
7695- generator : func (ctx context.Context , p * planner , db catalog.DatabaseDescriptor , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
7699+ generator : func (ctx context.Context , p * planner , db catalog.DatabaseDescriptor , _ int64 , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
76967700 // Check permission first before making RPC fanout.
76977701 // If a user has VIEWACTIVITYREDACTED role option but the user does not
76987702 // have the ADMIN role option, then the contending key should be redacted.
@@ -7971,8 +7975,8 @@ type clusterLocksFilters struct {
79717975
79727976func genClusterLocksGenerator (
79737977 filters clusterLocksFilters ,
7974- ) func (ctx context.Context , p * planner , db catalog.DatabaseDescriptor , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
7975- return func (ctx context.Context , p * planner , _ catalog.DatabaseDescriptor , _ * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
7978+ ) func (ctx context.Context , p * planner , db catalog.DatabaseDescriptor , _ int64 , stopper * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
7979+ return func (ctx context.Context , p * planner , _ catalog.DatabaseDescriptor , _ int64 , _ * stop.Stopper ) (virtualTableGenerator , cleanupFunc , error ) {
79767980 hasAdmin , err := p .HasAdminRole (ctx )
79777981 if err != nil {
79787982 return nil , nil , err
@@ -8235,7 +8239,7 @@ func populateClusterLocksWithFilter(
82358239) (matched bool , err error ) {
82368240 var rowGenerator virtualTableGenerator
82378241 generator := genClusterLocksGenerator (filters )
8238- rowGenerator , _ , err = generator (ctx , p , db , nil /* stopper */ )
8242+ rowGenerator , _ , err = generator (ctx , p , db , 0 /* limit */ , nil /* stopper */ )
82398243 if err != nil {
82408244 return false , err
82418245 }
0 commit comments