Skip to content

Commit

Permalink
Fix DB version call (#2466)
Browse files Browse the repository at this point in the history
* Fix DB version call

* Rename var

* Remove TO_STRING

* Define KUZU_VERSION as an extern global

Since it's set using a compile definition, we want to avoid that definition being required to include the header

---------

Co-authored-by: Benjamin Winger <bmw@disroot.org>
  • Loading branch information
mewim and benjaminwinger committed Nov 20, 2023
1 parent bf50060 commit 072c256
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ function(add_kuzu_api_test TEST_NAME)
endfunction()

add_definitions(-DKUZU_ROOT_DIRECTORY="${PROJECT_SOURCE_DIR}")
add_definitions(-DKUZU_STORAGE_VERSION="${CMAKE_PROJECT_VERSION}")
add_definitions(-DKUZU_CMAKE_VERSION="${CMAKE_PROJECT_VERSION}")

include_directories(src/include)
include_directories(third_party/antlr4_cypher/include)
Expand Down
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_compile_definitions(KUZU_CMAKE_VERSION=v${CMAKE_PROJECT_VERSION})
# Avoid the import annotation when building on windows
# Really this should be set per target,
# but the targets are split among many files and only the object files are linked against here
Expand Down
1 change: 1 addition & 0 deletions src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ add_subdirectory(vector)

add_library(kuzu_common
OBJECT
constants.cpp
expression_type.cpp
file_utils.cpp
in_mem_overflow_buffer.cpp
Expand Down
6 changes: 6 additions & 0 deletions src/common/constants.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace kuzu {
namespace common {

const char* KUZU_VERSION = KUZU_CMAKE_VERSION;
}
} // namespace kuzu
4 changes: 1 addition & 3 deletions src/include/common/constants.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#pragma once

#define TO_STRING(ARG) #ARG

#include <cstdint>

namespace kuzu {
namespace common {

constexpr char KUZU_VERSION[] = TO_STRING(KUZU_CMAKE_VERSION);
extern const char* KUZU_VERSION;

constexpr uint64_t DEFAULT_VECTOR_CAPACITY_LOG_2 = 11;
constexpr uint64_t DEFAULT_VECTOR_CAPACITY = (uint64_t)1 << DEFAULT_VECTOR_CAPACITY_LOG_2;
Expand Down
6 changes: 3 additions & 3 deletions src/storage/storage_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ namespace storage {

storage_version_t StorageVersionInfo::getStorageVersion() {
auto storageVersionInfo = getStorageVersionInfo();
if (!storageVersionInfo.contains(KUZU_STORAGE_VERSION)) {
// If the current KUZU_STORAGE_VERSION is not in the map,
if (!storageVersionInfo.contains(KUZU_CMAKE_VERSION)) {
// If the current KUZU_CMAKE_VERSION is not in the map,
// then we must run the newest version of kuzu
// LCOV_EXCL_START
storage_version_t maxVersion = 0;
Expand All @@ -16,7 +16,7 @@ storage_version_t StorageVersionInfo::getStorageVersion() {
return maxVersion;
// LCOV_EXCL_STOP
}
return storageVersionInfo.at(KUZU_STORAGE_VERSION);
return storageVersionInfo.at(KUZU_CMAKE_VERSION);
}

} // namespace storage
Expand Down

0 comments on commit 072c256

Please sign in to comment.