提交 28d15c6e 编写于 作者: J Jesse Zhang

Remove debug-only private fields in release builds

We have a bunch of classes with private fields that are used only in
debug builds, some of them are probably opportunities for complete
removal. This is exposed by an upcoming commit that enforces the use of
"=delete" and "=default" throughout the codebase.

I've attempted to solve this by adding the GPOS_ASSERTS_ONLY attribute,
but GCC doesn't like that, throwing errors like the following:

In file included from ../src/backend/gporca/libgpos/include/gpos/common/clibwrapper.h:22,
                 from ../src/backend/gporca/libgpos/include/gpos/error/CMessage.h:21,
                 from ../src/backend/gporca/libgpos/include/gpos/error/CMessageTable.h:14,
                 from ../src/backend/gporca/libgpos/include/gpos/error/CMessageRepository.h:14,
                 from ../src/backend/gporca/libgpos/src/_api.cpp:15:
../src/backend/gporca/libgpos/include/gpos/attributes.h:15:43: error: ‘unused’ attribute ignored [-Werror=attributes]
   15 | #define GPOS_UNUSED __attribute__((unused))
      |                                           ^
../src/backend/gporca/libgpos/include/gpos/attributes.h:21:27: note: in expansion of macro ‘GPOS_UNUSED’
   21 | #define GPOS_ASSERTS_ONLY GPOS_UNUSED
      |                           ^~~~~~~~~~~
../src/backend/gporca/libgpos/include/gpos/memory/CAutoMemoryPool.h:56:31: note: in expansion of macro ‘GPOS_ASSERTS_ONLY’
   56 |  ELeakCheck m_leak_check_type GPOS_ASSERTS_ONLY;
      |                               ^~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors

So we're back to the good ol' #ifdef GPOS_DEBUG.

This is the first of a pair of manual changes. In the immediately
following commit I'll remove the remaining (unconditionally) unused
private fields.
上级 aee5f16d
......@@ -50,8 +50,10 @@ using namespace gpos;
class CQueryContext
{
private:
#ifdef GPOS_DEBUG
// memory pool
CMemoryPool *m_mp;
#endif
// required plan properties in optimizer's produced plan
CReqdPropPlan *m_prpp;
......
......@@ -71,8 +71,10 @@ public:
ShtCC;
private:
#ifdef GPOS_DEBUG
// memory pool
CMemoryPool *m_mp;
#endif
// definition of context hash table accessor
typedef CSyncHashtableAccessByKey<CCostContext, // entry
......@@ -182,7 +184,10 @@ private:
//private dummy ctor; used for creating invalid gexpr
CGroupExpression()
: m_mp(NULL),
:
#ifdef GPOS_DEBUG
m_mp(NULL),
#endif
m_id(GPOPT_INVALID_GEXPR_ID),
m_pop(NULL),
m_pdrgpgroup(NULL),
......
......@@ -33,7 +33,10 @@ using namespace gpopt;
CQueryContext::CQueryContext(CMemoryPool *mp, CExpression *pexpr,
CReqdPropPlan *prpp, CColRefArray *colref_array,
CMDNameArray *pdrgpmdname, BOOL fDeriveStats)
: m_mp(mp),
:
#ifdef GPOS_DEBUG
m_mp(mp),
#endif
m_prpp(prpp),
m_pdrgpcr(colref_array),
m_pdrgpcrSystemCols(NULL),
......
......@@ -50,7 +50,10 @@ CGroupExpression::CGroupExpression(CMemoryPool *mp, COperator *pop,
CXform::EXformId exfid,
CGroupExpression *pgexprOrigin,
BOOL fIntermediate)
: m_mp(mp),
:
#ifdef GPOS_DEBUG
m_mp(mp),
#endif
m_id(GPOPT_INVALID_GEXPR_ID),
m_pgexprDuplicate(NULL),
m_pop(pop),
......
......@@ -55,8 +55,10 @@ private:
// memory pool to protect
CMemoryPool *m_mp;
#ifdef GPOS_DEBUG
// type of leak check to perform
ELeakCheck m_leak_check_type;
#endif
public:
// ctor
......
......@@ -38,8 +38,10 @@ using namespace gpos;
// the CMemoryPoolManager global instance
//
//---------------------------------------------------------------------------
CAutoMemoryPool::CAutoMemoryPool(ELeakCheck leak_check_type)
CAutoMemoryPool::CAutoMemoryPool(ELeakCheck leak_check_type GPOS_ASSERTS_ONLY)
#ifdef GPOS_DEBUG
: m_leak_check_type(leak_check_type)
#endif
{
m_mp = CMemoryPoolManager::GetMemoryPoolMgr()->CreateMemoryPool();
}
......
......@@ -71,8 +71,10 @@ private:
// is this a fixed-length type
BOOL m_is_fixed_length;
#ifdef GPOS_DEBUG
// type length in number of bytes for fixed-length types, 0 otherwise
ULONG m_length;
#endif
// is type passed by value or by reference
BOOL m_is_passed_by_value;
......
......@@ -48,21 +48,23 @@ using namespace gpmd;
//---------------------------------------------------------------------------
CMDTypeGenericGPDB::CMDTypeGenericGPDB(
CMemoryPool *mp, IMDId *mdid, CMDName *mdname, BOOL is_redistributable,
BOOL is_fixed_length, ULONG length, BOOL is_passed_by_value,
IMDId *mdid_distr_opfamily, IMDId *mdid_legacy_distr_opfamily,
IMDId *mdid_op_eq, IMDId *mdid_op_neq, IMDId *mdid_op_lt,
IMDId *mdid_op_leq, IMDId *mdid_op_gt, IMDId *mdid_op_geq,
IMDId *mdid_op_cmp, IMDId *mdid_op_min, IMDId *mdid_op_max,
IMDId *mdid_op_avg, IMDId *mdid_op_sum, IMDId *mdid_op_count,
BOOL is_hashable, BOOL is_merge_joinable, BOOL is_composite_type,
BOOL is_text_related, IMDId *mdid_base_relation, IMDId *mdid_type_array,
INT gpdb_length)
BOOL is_fixed_length, ULONG length GPOS_ASSERTS_ONLY,
BOOL is_passed_by_value, IMDId *mdid_distr_opfamily,
IMDId *mdid_legacy_distr_opfamily, IMDId *mdid_op_eq, IMDId *mdid_op_neq,
IMDId *mdid_op_lt, IMDId *mdid_op_leq, IMDId *mdid_op_gt,
IMDId *mdid_op_geq, IMDId *mdid_op_cmp, IMDId *mdid_op_min,
IMDId *mdid_op_max, IMDId *mdid_op_avg, IMDId *mdid_op_sum,
IMDId *mdid_op_count, BOOL is_hashable, BOOL is_merge_joinable,
BOOL is_composite_type, BOOL is_text_related, IMDId *mdid_base_relation,
IMDId *mdid_type_array, INT gpdb_length)
: m_mp(mp),
m_mdid(mdid),
m_mdname(mdname),
m_is_redistributable(is_redistributable),
m_is_fixed_length(is_fixed_length),
#ifdef GPOS_DEBUG
m_length(length),
#endif
m_is_passed_by_value(is_passed_by_value),
m_distr_opfamily(mdid_distr_opfamily),
m_legacy_distr_opfamily(mdid_legacy_distr_opfamily),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册