Skip to content

Commit 66eedec

Browse files
zhangwenchao-123my-ship-it
authored andcommitted
Fix analyze paritioned table in somecase will coredump.
Fix leaf_parts_analyzed will return false directly without execute analyze when reltuples is 0 and relpages is 0 that means the table is an empty partition table. Authored-by: Zhang Wenchao <zhangwenchao@apache.org>
1 parent b32042d commit 66eedec

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/backend/commands/analyzeutils.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,9 +1252,10 @@ leaf_parts_analyzed(Oid attrelid, Oid relid_exclude, List *va_cols, int elevel)
12521252
continue;
12531253

12541254
float4 relTuples = get_rel_reltuples(partRelid);
1255+
int32 relpages = get_rel_relpages(partRelid);
12551256

12561257
/* Partition is not analyzed */
1257-
if (relTuples < 0.0)
1258+
if (relTuples < 0.0 || (relTuples == 0.0 && relpages == 0))
12581259
{
12591260
if (relid_exclude == InvalidOid)
12601261
ereport(elevel,

0 commit comments

Comments
 (0)