Skip to content

Commit eb5c16b

Browse files
zhangyue1818gfphoenix78
authored andcommitted
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.
1 parent cce58a8 commit eb5c16b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

contrib/pax_storage/src/cpp/cmake/pax.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,14 @@ add_custom_command(TARGET pax POST_BUILD
223223

224224
if (BUILD_GTEST)
225225
add_subdirectory(contrib/googletest)
226-
ADD_DEFINITIONS(-DRUN_GTEST)
227226
file(GLOB test_case_sources
228227
pax_gtest_helper.cc
229228
pax_gtest.cc
230229
${CMAKE_CURRENT_SOURCE_DIR}/*/*_test.cc
231230
${CMAKE_CURRENT_SOURCE_DIR}/*/*/*_test.cc)
232231

233232
add_executable(test_main ${pax_target_src} ${test_case_sources})
233+
target_compile_definitions(test_main PRIVATE RUN_GTEST)
234234
add_dependencies(test_main ${pax_target_dependencies} gtest gmock)
235235
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/)
236236

@@ -240,13 +240,13 @@ endif(BUILD_GTEST)
240240

241241
if(BUILD_GBENCH)
242242
add_subdirectory(contrib/googlebench)
243-
ADD_DEFINITIONS(-DRUN_GBENCH)
244243
file(GLOB bench_sources
245244
pax_gbench.cc
246245
${CMAKE_CURRENT_SOURCE_DIR}/*/*_bench.cc
247246
${CMAKE_CURRENT_SOURCE_DIR}/*/*/*_bench.cc)
248247

249248
add_executable(bench_main ${pax_target_src} ${bench_sources})
249+
target_compile_definitions(bench_main PRIVATE RUN_GBENCH)
250250
add_dependencies(bench_main ${pax_target_dependencies} gtest gmock)
251251
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/)
252252
link_directories(contrib/googlebench/src)

0 commit comments

Comments
 (0)