This is an automated email from the ASF dual-hosted git repository.

maxyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit f4c7f1c37df6d215588d48c04895bae72ccec66e
Author: Ekta Khanna <[email protected]>
AuthorDate: Fri Sep 16 14:52:14 2022 -0700

    Address FIXMEs in gpdbwrappers.cpp file (#14104)
    
    * Remove FIXME for signature change
    
    As there are other functions that also take in Node as an input, its
    better to keep it as is instead of changing the signature and breaking
    something not captured as ICW.
    
    * Remove dead code
    
    This commit was to address the FIXME that removes CountLeafPartTables().
    On looking at the call hierarchy CountLeafPartTables() was called by
    RetrieveNumChildPartitions() -> GenerateStatsForSystemCols() ->
    RetrieveColStats() for attno < 0 (system columns). Since we do not
    extract/use the stats on system columns, the entire call stack is not
    used code. This commit removes this part of the code altogether.
    
    It also previously called RelPartIsNone() call to which was removed,
    thus removing this function too.
    
    This commit also removes FIXME for collation.
---
 src/backend/gpopt/gpdbwrappers.cpp                 |  29 ------
 .../gpopt/translate/CTranslatorRelcacheToDXL.cpp   | 116 ---------------------
 src/include/gpopt/gpdbwrappers.h                   |   8 --
 .../gpopt/translate/CTranslatorRelcacheToDXL.h     |  10 --
 4 files changed, 163 deletions(-)

diff --git a/src/backend/gpopt/gpdbwrappers.cpp 
b/src/backend/gpopt/gpdbwrappers.cpp
index fabc1c7adb..fb5654b727 100644
--- a/src/backend/gpopt/gpdbwrappers.cpp
+++ b/src/backend/gpopt/gpdbwrappers.cpp
@@ -1990,15 +1990,6 @@ gpdb::RelPartIsInterior
 }
 #endif
 
-bool
-gpdb::RelPartIsNone(Oid relid)
-{
-       // FIXME: this is left unused for now. But when it's used, we also need 
to
-       // check for whether relid is a partition of another table
-       pg_unreachable();
-       return !RelIsPartitioned(relid);
-}
-
 bool
 gpdb::HasSubclassSlow(Oid rel_oid)
 {
@@ -2144,7 +2135,6 @@ gpdb::CreateForeignScanForExternalTable(Oid rel_oid, 
Index scanrelid,
        return nullptr;
 }
 
-// GPDB_12_MERGE_FIXME: Change signature to take in Expr instead of Node
 TargetEntry *
 gpdb::FindFirstMatchingMemberInTargetList(Node *node, List *targetlist)
 {
@@ -2561,25 +2551,6 @@ gpdb::InjectFaultInOptTasks(const char *fault_name)
 }
 #endif
 
-/* GPDB_12_MERGE_FIXME: dead code now? */
-#if 0
-gpos::ULONG
-gpdb::CountLeafPartTables
-       (
-       Oid rel_oid
-       )
-{
-       GP_WRAP_START;
-       {
-               /* catalog tables: pg_partition, pg_partition_rules */
-               return countLeafPartTables(rel_oid);
-       }
-       GP_WRAP_END;
-
-       return 0;
-}
-#endif
-
 /*
  * To detect changes to catalog tables that require resetting the Metadata
  * Cache, we use the normal PostgreSQL catalog cache invalidation mechanism.
diff --git a/src/backend/gpopt/translate/CTranslatorRelcacheToDXL.cpp 
b/src/backend/gpopt/translate/CTranslatorRelcacheToDXL.cpp
index 6558df6cc7..62e08fe08b 100644
--- a/src/backend/gpopt/translate/CTranslatorRelcacheToDXL.cpp
+++ b/src/backend/gpopt/translate/CTranslatorRelcacheToDXL.cpp
@@ -1722,14 +1722,6 @@ CTranslatorRelcacheToDXL::RetrieveColStats(CMemoryPool 
*mp,
 
        CDXLBucketArray *dxl_stats_bucket_array = GPOS_NEW(mp) 
CDXLBucketArray(mp);
 
-       if (0 > attno)
-       {
-               mdid_col_stats->AddRef();
-               return GenerateStatsForSystemCols(mp, rel_oid, mdid_col_stats,
-                                                                               
  md_colname, att_type, attno,
-                                                                               
  dxl_stats_bucket_array, num_rows);
-       }
-
        // extract out histogram and mcv information from pg_statistic
        HeapTuple stats_tup = gpdb::GetAttStats(rel_oid, attno);
 
@@ -1920,114 +1912,6 @@ CTranslatorRelcacheToDXL::RetrieveColStats(CMemoryPool 
*mp,
 }
 
 
-//---------------------------------------------------------------------------
-//      @function:
-//              CTranslatorRelcacheToDXL::GenerateStatsForSystemCols
-//
-//      @doc:
-//              Generate statistics for the system level columns
-//
-//---------------------------------------------------------------------------
-CDXLColStats *
-CTranslatorRelcacheToDXL::GenerateStatsForSystemCols(
-       CMemoryPool *mp, OID rel_oid, CMDIdColStats *mdid_col_stats,
-       CMDName *md_colname, OID att_type, AttrNumber attno,
-       CDXLBucketArray *dxl_stats_bucket_array, CDouble num_rows)
-{
-       GPOS_ASSERT(nullptr != mdid_col_stats);
-       GPOS_ASSERT(nullptr != md_colname);
-       GPOS_ASSERT(InvalidOid != att_type);
-       GPOS_ASSERT(0 > attno);
-       GPOS_ASSERT(nullptr != dxl_stats_bucket_array);
-
-       CMDIdGPDB *mdid_atttype = GPOS_NEW(mp) CMDIdGPDB(att_type);
-       IMDType *md_type = RetrieveType(mp, mdid_atttype);
-       GPOS_ASSERT(md_type->IsFixedLength());
-
-       BOOL is_col_stats_missing = true;
-       CDouble null_freq(0.0);
-       CDouble width(md_type->Length());
-       CDouble distinct_remaining(0.0);
-       CDouble freq_remaining(0.0);
-
-       if (CStatistics::MinRows <= num_rows)
-       {
-               switch (attno)
-               {
-                       case GpSegmentIdAttributeNumber:  // gp_segment_id
-                       {
-                               is_col_stats_missing = false;
-                               freq_remaining = CDouble(1.0);
-                               distinct_remaining = 
CDouble(gpdb::GetGPSegmentCount());
-                               break;
-                       }
-                       case TableOidAttributeNumber:  // tableoid
-                       {
-                               is_col_stats_missing = false;
-                               freq_remaining = CDouble(1.0);
-                               distinct_remaining =
-                                       
CDouble(RetrieveNumChildPartitions(rel_oid));
-                               break;
-                       }
-                       case SelfItemPointerAttributeNumber:  // ctid
-                       {
-                               is_col_stats_missing = false;
-                               freq_remaining = CDouble(1.0);
-                               distinct_remaining = num_rows;
-                               break;
-                       }
-                       default:
-                               break;
-               }
-       }
-
-       // cleanup
-       mdid_atttype->Release();
-       md_type->Release();
-
-       return GPOS_NEW(mp) CDXLColStats(
-               mp, mdid_col_stats, md_colname, width, null_freq, 
distinct_remaining,
-               freq_remaining, dxl_stats_bucket_array, is_col_stats_missing);
-}
-
-
-//---------------------------------------------------------------------------
-//     @function:
-//     CTranslatorRelcacheToDXL::RetrieveNumChildPartitions
-//
-//  @doc:
-//      For non-leaf partition tables return the number of child partitions
-//      else return 1
-//
-//---------------------------------------------------------------------------
-ULONG
-CTranslatorRelcacheToDXL::RetrieveNumChildPartitions(OID rel_oid)
-{
-       GPOS_ASSERT(InvalidOid != rel_oid);
-
-       ULONG num_part_tables = gpos::ulong_max;
-       if (!gpdb::RelIsPartitioned(rel_oid))
-       {
-               // not a partitioned table
-               num_part_tables = 1;
-       }
-#if 0
-       else if (gpdb::IsLeafPartition(rel_oid))
-       {
-           // leaf partition
-           num_part_tables = 1;
-       }
-       else
-       {
-           num_part_tables = gpdb::CountLeafPartTables(rel_oid);
-       }
-       GPOS_ASSERT(gpos::ulong_max != num_part_tables);
-#endif
-
-       return num_part_tables;
-}
-
-
 //---------------------------------------------------------------------------
 //     @function:
 //             CTranslatorRelcacheToDXL::RetrieveCast
diff --git a/src/include/gpopt/gpdbwrappers.h b/src/include/gpopt/gpdbwrappers.h
index 8608f4c218..625ff71dc2 100644
--- a/src/include/gpopt/gpdbwrappers.h
+++ b/src/include/gpopt/gpdbwrappers.h
@@ -554,9 +554,6 @@ bool RelIsPartitioned(Oid relid);
 
 bool IndexIsPartitioned(Oid relid);
 
-// check whether table with the given oid is a regular table and not part of a 
partitioned table
-bool RelPartIsNone(Oid relid);
-
 // check whether a relation is inherited
 bool HasSubclassSlow(Oid rel_oid);
 
@@ -715,11 +712,6 @@ Node *EvalConstExpressions(Node *node);
 FaultInjectorType_e InjectFaultInOptTasks(const char *fault_name);
 #endif
 
-#if 0
-       // return the number of leaf partition for a given table oid
-       gpos::ULONG CountLeafPartTables(Oid oidRelation);
-#endif
-
 // Does the metadata cache need to be reset (because of a catalog
 // table has been changed?)
 bool MDCacheNeedsReset(void);
diff --git a/src/include/gpopt/translate/CTranslatorRelcacheToDXL.h 
b/src/include/gpopt/translate/CTranslatorRelcacheToDXL.h
index f7e1069cae..563e217a44 100644
--- a/src/include/gpopt/translate/CTranslatorRelcacheToDXL.h
+++ b/src/include/gpopt/translate/CTranslatorRelcacheToDXL.h
@@ -312,16 +312,6 @@ private:
        static IMdIdArray *RetrieveRelDistributionOpFamilies(CMemoryPool *mp,
                                                                                
                                 GpPolicy *policy);
 
-       // for non-leaf partition tables return the number of child partitions
-       // else return 1
-       static ULONG RetrieveNumChildPartitions(OID rel_oid);
-
-       // generate statistics for the system level columns
-       static CDXLColStats *GenerateStatsForSystemCols(
-               CMemoryPool *mp, OID rel_oid, CMDIdColStats *mdid_col_stats,
-               CMDName *md_colname, OID att_type, AttrNumber attrnum,
-               CDXLBucketArray *dxl_stats_bucket_array, CDouble rows);
-
        static IMdIdArray *RetrieveIndexPartitions(CMemoryPool *mp, OID 
rel_oid);
 
        static IMDRelation::Erelstoragetype 
RetrieveStorageTypeForPartitionedTable(


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to