Skip to content

Fix RUN_GTEST/RUN_GBENCH leak into pax.so build#1591

Open
zhangyue1818 wants to merge 1 commit intoapache:mainfrom
zhangyue1818:pax_gtest_leak
Open

Fix RUN_GTEST/RUN_GBENCH leak into pax.so build#1591
zhangyue1818 wants to merge 1 commit intoapache:mainfrom
zhangyue1818:pax_gtest_leak

Conversation

@zhangyue1818
Copy link
Contributor

ADD_DEFINITIONS(-DRUN_GTEST) and ADD_DEFINITIONS(-DRUN_GBENCH) are directory-scoped CMake commands that apply to ALL targets, including the production pax shared library. This caused test- only macros to be defined in production builds.

In pax_porc_adpater.cc, the leaked RUN_GTEST activates:

expect_hdr = rel_tuple_desc_->attrs[index].attlen == -1 &&
             rel_tuple_desc_->attrs[index].attbyval == false;

#ifdef RUN_GTEST
expect_hdr = false;
#endif

This forces expect_hdr to false in production, skipping the stripping of PostgreSQL varlena headers from dictionary entries. As a result, dictionary-encoded string columns return garbled data (varlena header bytes are included as part of the string content).

Replace ADD_DEFINITIONS with target_compile_definitions scoped to test_main and bench_main targets only, so RUN_GTEST and RUN_GBENCH are no longer defined when building pax.so.

Fixes #ISSUE_Number

What does this PR do?

Type of Change

  • Bug fix (non-breaking change)
  • New feature (non-breaking change)
  • Breaking change (fix or feature with breaking changes)
  • Documentation update

Breaking Changes

Test Plan

  • Unit tests added/updated
  • Integration tests added/updated
  • Passed make installcheck
  • Passed make -C src/test installcheck-cbdb-parallel

Impact

Performance:

User-facing changes:

Dependencies:

Checklist

Additional Context

CI Skip Instructions


ADD_DEFINITIONS(-DRUN_GTEST) and ADD_DEFINITIONS(-DRUN_GBENCH)
are directory-scoped CMake commands that apply to ALL targets,
including the production pax shared library. This caused test-
only macros to be defined in production builds.

In pax_porc_adpater.cc, the leaked RUN_GTEST activates:

    expect_hdr = rel_tuple_desc_->attrs[index].attlen == -1 &&
                 rel_tuple_desc_->attrs[index].attbyval == false;

    #ifdef RUN_GTEST
    expect_hdr = false;
    #endif

This forces expect_hdr to false in production, skipping the
stripping of PostgreSQL varlena headers from dictionary
entries. As a result, dictionary-encoded string columns
return garbled data (varlena header bytes are included as
part of the string content).

Replace ADD_DEFINITIONS with target_compile_definitions
scoped to test_main and bench_main targets only, so
RUN_GTEST and RUN_GBENCH are no longer defined when
building pax.so.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants