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

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


The following commit(s) were added to refs/heads/main by this push:
     new f65bf625d21 Fix RUN_GTEST/RUN_GBENCH leak into pax.so build
f65bf625d21 is described below

commit f65bf625d215143e63516342030d4d16867689eb
Author: zhangyue <[email protected]>
AuthorDate: Mon Mar 2 14:38:04 2026 +0800

    Fix RUN_GTEST/RUN_GBENCH leak into pax.so build
    
    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.
---
 contrib/pax_storage/src/cpp/cmake/pax.cmake | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/pax_storage/src/cpp/cmake/pax.cmake 
b/contrib/pax_storage/src/cpp/cmake/pax.cmake
index 528b4e8cafc..83f79f3f002 100644
--- a/contrib/pax_storage/src/cpp/cmake/pax.cmake
+++ b/contrib/pax_storage/src/cpp/cmake/pax.cmake
@@ -223,7 +223,6 @@ add_custom_command(TARGET pax POST_BUILD
 
 if (BUILD_GTEST)
   add_subdirectory(contrib/googletest)
-  ADD_DEFINITIONS(-DRUN_GTEST)
   file(GLOB test_case_sources
     pax_gtest_helper.cc
     pax_gtest.cc
@@ -231,6 +230,7 @@ if (BUILD_GTEST)
     ${CMAKE_CURRENT_SOURCE_DIR}/*/*/*_test.cc)
 
   add_executable(test_main ${pax_target_src} ${test_case_sources})
+  target_compile_definitions(test_main PRIVATE RUN_GTEST)
   add_dependencies(test_main ${pax_target_dependencies} gtest gmock)
   target_include_directories(test_main PUBLIC ${pax_target_include} 
${CMAKE_CURRENT_SOURCE_DIR} ${gtest_SOURCE_DIR}/include contrib/cpp-stub/src/ 
contrib/cpp-stub/src_linux/)
 
@@ -240,13 +240,13 @@ endif(BUILD_GTEST)
 
 if(BUILD_GBENCH)
   add_subdirectory(contrib/googlebench)
-  ADD_DEFINITIONS(-DRUN_GBENCH)
   file(GLOB bench_sources
       pax_gbench.cc
       ${CMAKE_CURRENT_SOURCE_DIR}/*/*_bench.cc
       ${CMAKE_CURRENT_SOURCE_DIR}/*/*/*_bench.cc)
 
     add_executable(bench_main ${pax_target_src} ${bench_sources})
+    target_compile_definitions(bench_main PRIVATE RUN_GBENCH)
     add_dependencies(bench_main ${pax_target_dependencies} gtest gmock)
     target_include_directories(bench_main PUBLIC ${pax_target_include} 
${CMAKE_CURRENT_SOURCE_DIR} contrib/googlebench/include contrib/cpp-stub/src/ 
contrib/cpp-stub/src_linux/)
     link_directories(contrib/googlebench/src)


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

Reply via email to