Skip to content

Commit d120e43

Browse files
committed
Fix: if tableam implement relation_acquire_sample_rows, then just use it
1 parent 768801c commit d120e43

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/backend/commands/analyze.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,15 @@ analyze_rel_internal(Oid relid, RangeVar *relation,
355355
onerel->rd_rel->relkind == RELKIND_MATVIEW ||
356356
onerel->rd_rel->relkind == RELKIND_DIRECTORY_TABLE)
357357
{
358+
/* Regular table, so we'll use the regular row acquisition function */
359+
if (onerel->rd_tableam)
360+
acquirefunc = onerel->rd_tableam->relation_acquire_sample_rows;
358361
/*
359362
* If the TableAmRoutine's gp_acquire_sample_rows_func if NULL, we use
360363
* gp_acquire_sample_rows_func as default.
361364
*/
362-
acquirefunc = gp_acquire_sample_rows_func;
365+
if (acquirefunc == NULL)
366+
acquirefunc = gp_acquire_sample_rows_func;
363367

364368
/* Also get regular table's size */
365369
relpages = AcquireNumberOfBlocks(onerel);
@@ -2079,8 +2083,16 @@ acquire_inherited_sample_rows(Relation onerel, int elevel,
20792083
childrel->rd_rel->relkind == RELKIND_MATVIEW ||
20802084
childrel->rd_rel->relkind == RELKIND_DIRECTORY_TABLE)
20812085
{
2082-
/* use relation_acquire_sample_rows as default. */
2083-
acquirefunc = gp_acquire_sample_rows_func;
2086+
/* Regular table, so use the regular row acquisition function */
2087+
if (childrel->rd_tableam)
2088+
acquirefunc = childrel->rd_tableam->relation_acquire_sample_rows;
2089+
2090+
/*
2091+
* If the TableAmRoutine's relation_acquire_sample_rows if NULL, we use
2092+
* relation_acquire_sample_rows as default.
2093+
*/
2094+
if (acquirefunc == NULL)
2095+
acquirefunc = gp_acquire_sample_rows_func;
20842096

20852097
relpages = AcquireNumberOfBlocks(childrel);
20862098
}

0 commit comments

Comments
 (0)