Skip to content

Commit 4b0a7eb

Browse files
committed
update duckdb, apply patches, move to extension ci tools
1 parent d5d6265 commit 4b0a7eb

13 files changed

+121
-125
lines changed

.clang-tidy

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
Checks: '-*,clang-diagnostic-*,bugprone-*,performance-*,google-explicit-constructor,google-build-using-namespace,google-runtime-int,misc-definitions-in-headers,modernize-use-nullptr,modernize-use-override,-bugprone-macro-parentheses,readability-braces-around-statements,-bugprone-branch-clone,readability-identifier-naming,hicpp-exception-baseclass,misc-throw-by-value-catch-by-reference,-bugprone-signed-char-misuse,-bugprone-misplaced-widening-cast,-bugprone-sizeof-expression,-bugprone-easily-swappable-parameters,google-global-names-in-headers,llvm-header-guard,misc-definitions-in-headers,modernize-use-emplace,modernize-use-bool-literals,-performance-inefficient-string-concatenation,-performance-no-int-to-ptr,readability-container-size-empty,cppcoreguidelines-pro-type-cstyle-cast,-llvm-header-guard,-performance-enum-size,cppcoreguidelines-pro-type-const-cast,cppcoreguidelines-avoid-non-const-global-variables,cppcoreguidelines-interfaces-global-init,cppcoreguidelines-slicing,cppcoreguidelines-rvalue-reference-param-not-moved,cppcoreguidelines-virtual-class-destructor,-readability-identifier-naming,-bugprone-exception-escape,-bugprone-unused-local-non-trivial-variable,-bugprone-empty-catch'
2+
WarningsAsErrors: '*'
3+
HeaderFilterRegex: 'src/include/duckdb/.*'
4+
FormatStyle: none
5+
CheckOptions:
6+
- key: readability-identifier-naming.ClassCase
7+
value: CamelCase
8+
- key: readability-identifier-naming.EnumCase
9+
value: CamelCase
10+
- key: readability-identifier-naming.TypedefCase
11+
value: lower_case
12+
- key: readability-identifier-naming.TypedefSuffix
13+
value: _t
14+
- key: readability-identifier-naming.FunctionCase
15+
value: CamelCase
16+
- key: readability-identifier-naming.MemberCase
17+
value: lower_case
18+
- key: readability-identifier-naming.ParameterCase
19+
value: lower_case
20+
- key: readability-identifier-naming.ConstantCase
21+
value: aNy_CasE
22+
- key: readability-identifier-naming.ConstantParameterCase
23+
value: lower_case
24+
- key: readability-identifier-naming.NamespaceCase
25+
value: lower_case
26+
- key: readability-identifier-naming.MacroDefinitionCase
27+
value: UPPER_CASE
28+
- key: readability-identifier-naming.StaticConstantCase
29+
value: UPPER_CASE
30+
- key: readability-identifier-naming.ConstantMemberCase
31+
value: aNy_CasE
32+
- key: readability-identifier-naming.StaticVariableCase
33+
value: UPPER_CASE
34+
- key: readability-identifier-naming.ClassConstantCase
35+
value: UPPER_CASE
36+
- key: readability-identifier-naming.EnumConstantCase
37+
value: UPPER_CASE
38+
- key: readability-identifier-naming.ConstexprVariableCase
39+
value: aNy_CasE
40+
- key: readability-identifier-naming.StaticConstantCase
41+
value: UPPER_CASE
42+
- key: readability-identifier-naming.TemplateTemplateParameterCase
43+
value: UPPER_CASE
44+
- key: readability-identifier-naming.TypeTemplateParameterCase
45+
value: UPPER_CASE
46+
- key: readability-identifier-naming.VariableCase
47+
value: lower_case
48+
- key: modernize-use-emplace.SmartPointers
49+
value: '::duckdb::shared_ptr;::duckdb::unique_ptr;::std::auto_ptr;::duckdb::weak_ptr'
50+
- key: cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreUnnamedParams
51+
value: true
52+

.github/workflows/MainDistributionPipeline.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,20 @@ concurrency:
1414
jobs:
1515
duckdb-stable-build:
1616
name: Build extension binaries
17-
uses: duckdb/extension-ci-tools/.github/workflows/_extension_distribution.yml@v1.1.0
17+
uses: duckdb/extension-ci-tools/.github/workflows/_extension_distribution.yml@main
1818
with:
1919
duckdb_version: main
2020
extension_name: sqlite_scanner
21+
ci_tools_version: main
2122

2223
duckdb-stable-deploy:
2324
name: Deploy extension binaries
2425
needs: duckdb-stable-build
25-
uses: duckdb/extension-ci-tools/.github/workflows/_extension_deploy.yml@v1.1.0
26+
uses: duckdb/extension-ci-tools/.github/workflows/_extension_deploy.yml@main
2627
secrets: inherit
2728
with:
2829
duckdb_version: main
2930
extension_name: sqlite_scanner
31+
ci_tools_version: main
3032
deploy_latest: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' }}
3133
deploy_versioned: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' }}

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
path = duckdb
33
url = https://github.com/duckdb/duckdb
44
branch = main
5+
[submodule "extension-ci-tools"]
6+
path = extension-ci-tools
7+
url = https://github.com/duckdb/extension-ci-tools.git

Makefile

+12-107
Original file line numberDiff line numberDiff line change
@@ -1,120 +1,25 @@
1-
.PHONY: all clean format debug release duckdb_debug duckdb_release pull update wasm_mvp wasm_eh wasm_threads
2-
3-
all: release
4-
5-
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
6-
PROJ_DIR := $(dir $(MKFILE_PATH))
7-
8-
TEST_PATH="/test/unittest"
9-
DUCKDB_PATH="/duckdb"
10-
11-
DUCKDB_SRCDIR ?= "./duckdb/"
12-
13-
# For non-MinGW windows the path is slightly different
14-
ifeq ($(OS),Windows_NT)
15-
ifneq ($(CXX),g++)
16-
TEST_PATH="/test/Release/unittest.exe"
17-
DUCKDB_PATH="/Release/duckdb.exe"
18-
endif
19-
endif
20-
21-
#### OSX config
22-
OSX_BUILD_FLAG=
23-
ifneq (${OSX_BUILD_ARCH}, "")
24-
OSX_BUILD_FLAG=-DOSX_BUILD_ARCH=${OSX_BUILD_ARCH}
25-
endif
26-
27-
#### VCPKG config
28-
VCPKG_TOOLCHAIN_PATH?=
29-
ifneq ("${VCPKG_TOOLCHAIN_PATH}", "")
30-
TOOLCHAIN_FLAGS:=${TOOLCHAIN_FLAGS} -DVCPKG_MANIFEST_DIR='${PROJ_DIR}' -DVCPKG_BUILD=1 -DCMAKE_TOOLCHAIN_FILE='${VCPKG_TOOLCHAIN_PATH}'
31-
endif
32-
ifneq ("${VCPKG_TARGET_TRIPLET}", "")
33-
TOOLCHAIN_FLAGS:=${TOOLCHAIN_FLAGS} -DVCPKG_TARGET_TRIPLET='${VCPKG_TARGET_TRIPLET}'
34-
endif
35-
36-
#### Enable Ninja as generator
37-
ifeq ($(GEN),ninja)
38-
GENERATOR=-G "Ninja" -DFORCE_COLORED_OUTPUT=1
39-
endif
1+
PROJ_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
402

3+
# Configuration of extension
414
EXT_NAME=sqlite_scanner
5+
EXT_CONFIG=${PROJ_DIR}extension_config.cmake
426

43-
#### Configuration for this extension
44-
EXTENSION_NAME=SQLITE_SCANNER
45-
EXTENSION_FLAGS=\
46-
-DDUCKDB_EXTENSION_NAMES="${EXT_NAME}" \
47-
-DDUCKDB_EXTENSION_${EXTENSION_NAME}_PATH="$(PROJ_DIR)" \
48-
-DDUCKDB_EXTENSION_${EXTENSION_NAME}_SHOULD_LINK=0 \
49-
-DDUCKDB_EXTENSION_${EXTENSION_NAME}_LOAD_TESTS=1 \
50-
-DDUCKDB_EXTENSION_${EXTENSION_NAME}_INCLUDE_PATH="$(PROJ_DIR)src/include" \
51-
-DDUCKDB_EXTENSION_${EXTENSION_NAME}_TEST_PATH=$(PROJ_DIR)test \
52-
53-
BUILD_FLAGS=-DEXTENSION_STATIC_BUILD=1 -DBUILD_EXTENSIONS="tpch" ${OSX_BUILD_FLAG} -DDUCKDB_EXPLICIT_PLATFORM='${DUCKDB_PLATFORM}'
54-
55-
ifeq ($(DUCKDB_PLATFORM_RTOOLS),1)
56-
BUILD_FLAGS:=${BUILD_FLAGS} -DCMAKE_CXX_FLAGS="-DDUCKDB_PLATFORM_RTOOLS=1"
57-
endif
7+
# Include the Makefile from extension-ci-tools
8+
include extension-ci-tools/makefiles/duckdb_extension.Makefile
589

59-
CLIENT_FLAGS :=
60-
pull:
61-
git submodule init
62-
git submodule update --recursive --remote
63-
64-
clean:
65-
rm -rf build
66-
cd duckdb && make clean
67-
68-
# Main build
69-
debug:
70-
mkdir -p build/debug && \
71-
cmake $(GENERATOR) $(FORCE_COLOR) $(EXTENSION_FLAGS) ${CLIENT_FLAGS} -DEXTENSION_STATIC_BUILD=1 -DCMAKE_BUILD_TYPE=Debug ${BUILD_FLAGS} -S ./duckdb/ -B build/debug && \
72-
cmake --build build/debug --config Debug
73-
74-
release:
75-
mkdir -p build/release && \
76-
cmake $(GENERATOR) $(FORCE_COLOR) $(EXTENSION_FLAGS) ${CLIENT_FLAGS} -DEXTENSION_STATIC_BUILD=1 -DCMAKE_BUILD_TYPE=Release ${BUILD_FLAGS} -S ./duckdb/ -B build/release && \
77-
cmake --build build/release --config Release
7810

11+
# Setup the sqlite3 tpch database
7912
data/db/tpch.db: release
8013
command -v sqlite3 || (command -v brew && brew install sqlite) || (command -v choco && choco install sqlite -y) || (command -v apt-get && apt-get install -y sqlite3) || echo "no sqlite3"
8114
./build/release/$(DUCKDB_PATH) < data/sql/tpch-export.duckdb || tree ./build/release || echo "neither tree not duck"
8215
sqlite3 data/db/tpch.db < data/sql/tpch-create.sqlite
8316

84-
# Main tests
85-
test: test_release
86-
test_release: release data/db/tpch.db
17+
# Override the test target implementations from the duckdb_extension.Makefile
18+
test_release_internal: data/db/tpch.db
8719
SQLITE_TPCH_GENERATED=1 ./build/release/$(TEST_PATH) "$(PROJ_DIR)test/*"
88-
test_debug: debug data/db/tpch.db
89-
SQLITE_TPCH_GENERATED=1 ./build/debug/$(TEST_PATH) "$(PROJ_DIR)test/*"
90-
91-
format:
92-
cp duckdb/.clang-format .
93-
find src/ -iname *.hpp -o -iname *.cpp | xargs clang-format --sort-includes=0 -style=file -i
94-
cmake-format -i CMakeLists.txt
95-
rm .clang-format
9620

97-
update:
98-
git submodule update --remote --merge
99-
100-
VCPKG_EMSDK_FLAGS=-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=$(EMSDK)/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake
101-
WASM_COMPILE_TIME_COMMON_FLAGS=-DWASM_LOADABLE_EXTENSIONS=1 -DBUILD_EXTENSIONS_ONLY=1 -DSKIP_EXTENSIONS="parquet;json" $(VCPKG_EMSDK_FLAGS)
102-
WASM_CXX_MVP_FLAGS=
103-
WASM_CXX_EH_FLAGS=$(WASM_CXX_MVP_FLAGS) -fwasm-exceptions -DWEBDB_FAST_EXCEPTIONS=1
104-
WASM_CXX_THREADS_FLAGS=$(WASM_COMPILE_TIME_EH_FLAGS) -DWITH_WASM_THREADS=1 -DWITH_WASM_SIMD=1 -DWITH_WASM_BULK_MEMORY=1 -pthread
105-
WASM_LINK_TIME_FLAGS=-O3 -sSIDE_MODULE=2 -sEXPORTED_FUNCTIONS="_${EXT_NAME}_version,_${EXT_NAME}_init"
106-
107-
wasm_mvp:
108-
mkdir -p build/wasm_mvp
109-
emcmake cmake $(GENERATOR) $(EXTENSION_FLAGS) $(WASM_COMPILE_TIME_COMMON_FLAGS) -Bbuild/wasm_mvp -DCMAKE_CXX_FLAGS="$(WASM_CXX_MVP_FLAGS)" -S $(DUCKDB_SRCDIR) -DDUCKDB_EXPLICIT_PLATFORM=wasm_mvp -DDUCKDB_CUSTOM_PLATFORM=wasm_mvp
110-
emmake make -j8 -Cbuild/wasm_mvp
111-
112-
wasm_eh:
113-
mkdir -p build/wasm_eh
114-
emcmake cmake $(GENERATOR) $(EXTENSION_FLAGS) $(WASM_COMPILE_TIME_COMMON_FLAGS) -Bbuild/wasm_eh -DCMAKE_CXX_FLAGS="$(WASM_CXX_EH_FLAGS)" -S $(DUCKDB_SRCDIR) -DDUCKDB_EXPLICIT_PLATFORM=wasm_eh -DDUCKDB_CUSTOM_PLATFORM=wasm_eh
115-
emmake make -j8 -Cbuild/wasm_eh
21+
test_debug_internal: data/db/tpch.db
22+
SQLITE_TPCH_GENERATED=1 ./build/debug/$(TEST_PATH) "$(PROJ_DIR)test/*"
11623

117-
wasm_threads:
118-
mkdir -p ./build/wasm_threads
119-
emcmake cmake $(GENERATOR) $(EXTENSION_FLAGS) $(WASM_COMPILE_TIME_COMMON_FLAGS) -Bbuild/wasm_threads -DCMAKE_CXX_FLAGS="$(WASM_CXX_THREADS_FLAGS)" -S $(DUCKDB_SRCDIR) -DDUCKDB_EXPLICIT_PLATFORM=wasm_threads -DDUCKDB_CUSTOM_PLATFORM=wasm_threads
120-
emmake make -j8 -Cbuild/wasm_threads
24+
test_reldebug_internal: data/db/tpch.db
25+
SQLITE_TPCH_GENERATED=1 ./build/reldebug/$(TEST_PATH) "$(PROJ_DIR)test/*"

duckdb

Submodule duckdb updated 3705 files

extension-ci-tools

Submodule extension-ci-tools added at 4317e39

extension_config.cmake

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# This file is included by DuckDB's build system. It specifies which extension to load
2+
3+
# Extension from this repo
4+
duckdb_extension_load(sqlite_scanner
5+
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}
6+
LOAD_TESTS
7+
)
8+
9+
# Any extra extensions that should be built
10+
# e.g.: duckdb_extension_load(json)
11+
duckdb_extension_load(tpch)

src/include/sqlite_scanner.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace duckdb {
1515
class SQLiteDB;
16+
class TableCatalogEntry;
1617

1718
struct SqliteBindData : public TableFunctionData {
1819
string file_name;
@@ -26,6 +27,8 @@ struct SqliteBindData : public TableFunctionData {
2627

2728
optional_idx rows_per_group = 122880;
2829
SQLiteDB *global_db;
30+
31+
optional_ptr<TableCatalogEntry> table;
2932
};
3033

3134
class SqliteScanFunction : public TableFunction {

src/sqlite_db.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ SQLiteDB SQLiteDB::Open(const string &path, const SQLiteOpenOptions &options, bo
4949
// default busy time-out of 5 seconds
5050
if (options.busy_timeout > 0) {
5151
if (options.busy_timeout > NumericLimits<int>::Maximum()) {
52-
throw std::runtime_error("busy_timeout out of range - must be within valid range for type int");
52+
throw std::runtime_error("busy_timeout out of range - must be within "
53+
"valid range for type int");
5354
}
5455
rc = sqlite3_busy_timeout(result.db, int(options.busy_timeout));
5556
if (rc != SQLITE_OK) {

src/sqlite_scanner.cpp

+24-12
Original file line numberDiff line numberDiff line change
@@ -274,19 +274,20 @@ static void SqliteScan(ClientContext &context, TableFunctionInput &data, DataChu
274274
FlatVector::GetData<date_t>(out_vec)[out_idx] =
275275
Date::FromCString((const char *)sqlite3_value_text(val), sqlite3_value_bytes(val));
276276
} else {
277-
throw NotImplementedException(
278-
"Unimplemented SQLite type for column of type DATE\n* SET sqlite_all_varchar=true to "
279-
"load all columns as VARCHAR and skip type conversions");
277+
throw NotImplementedException("Unimplemented SQLite type for column of type DATE\n* SET "
278+
"sqlite_all_varchar=true to "
279+
"load all columns as VARCHAR and skip type conversions");
280280
}
281281
break;
282282
case LogicalTypeId::TIMESTAMP:
283283
// SQLite does not have a timestamp type - but it has "conventions"
284284
// See https://www.sqlite.org/lang_datefunc.html
285285
// The conventions are:
286286
// A text string that is an ISO 8601 date/time value
287-
// The number of days including fractional days since -4713-11-24 12:00:00
288-
// The number of seconds including fractional seconds since 1970-01-01 00:00:00
289-
// for now we only support ISO-8601 and unix timestamps
287+
// The number of days including fractional days since -4713-11-24
288+
// 12:00:00 The number of seconds including fractional seconds since
289+
// 1970-01-01 00:00:00 for now we only support ISO-8601 and unix
290+
// timestamps
290291
if (sqlite_column_type == SQLITE_INTEGER) {
291292
// unix timestamp
292293
FlatVector::GetData<timestamp_t>(out_vec)[out_idx] = ConvertTimestampInteger(val);
@@ -297,9 +298,9 @@ static void SqliteScan(ClientContext &context, TableFunctionInput &data, DataChu
297298
FlatVector::GetData<timestamp_t>(out_vec)[out_idx] =
298299
Timestamp::FromCString((const char *)sqlite3_value_text(val), sqlite3_value_bytes(val));
299300
} else {
300-
throw NotImplementedException(
301-
"Unimplemented SQLite type for column of type TIMESTAMP\n* SET sqlite_all_varchar=true to "
302-
"load all columns as VARCHAR and skip type conversions");
301+
throw NotImplementedException("Unimplemented SQLite type for column of type TIMESTAMP\n* SET "
302+
"sqlite_all_varchar=true to "
303+
"load all columns as VARCHAR and skip type conversions");
303304
}
304305
break;
305306
case LogicalTypeId::BLOB:
@@ -315,10 +316,20 @@ static void SqliteScan(ClientContext &context, TableFunctionInput &data, DataChu
315316
}
316317
}
317318

318-
static string SqliteToString(const FunctionData *bind_data_p) {
319-
D_ASSERT(bind_data_p);
319+
static InsertionOrderPreservingMap<string> SqliteToString(TableFunctionToStringInput &input) {
320+
D_ASSERT(input.bind_data);
321+
InsertionOrderPreservingMap<string> result;
322+
auto &bind_data = input.bind_data->Cast<SqliteBindData>();
323+
result["Table"] = bind_data.table_name;
324+
result["File"] = bind_data.file_name;
325+
return result;
326+
}
327+
328+
BindInfo SqliteBindInfo(const optional_ptr<FunctionData> bind_data_p) {
329+
BindInfo info(ScanType::EXTERNAL);
320330
auto &bind_data = bind_data_p->Cast<SqliteBindData>();
321-
return StringUtil::Format("%s:%s", bind_data.file_name, bind_data.table_name);
331+
info.table = bind_data.table;
332+
return info;
322333
}
323334

324335
/*
@@ -338,6 +349,7 @@ SqliteScanFunction::SqliteScanFunction()
338349
SqliteInitGlobalState, SqliteInitLocalState) {
339350
cardinality = SqliteCardinality;
340351
to_string = SqliteToString;
352+
get_bind_info = SqliteBindInfo;
341353
projection_pushdown = true;
342354
}
343355

src/sqlite_stmt.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ void SQLiteStatement::CheckTypeMatches(const SqliteBindData &bind_data, sqlite3_
6969
auto message = "Invalid type in column \"" + column_name + "\": column was declared as " +
7070
SQLiteUtils::TypeToString(expected_type) + ", found \"" + value_as_text + "\" of type \"" +
7171
SQLiteUtils::TypeToString(sqlite_column_type) + "\" instead.";
72-
message += "\n* SET sqlite_all_varchar=true to load all columns as VARCHAR and skip type conversions";
72+
message += "\n* SET sqlite_all_varchar=true to load all columns as VARCHAR "
73+
"and skip type conversions";
7374
throw Exception(ExceptionType::MISMATCH_TYPE, message);
7475
}
7576
}
@@ -80,7 +81,8 @@ void SQLiteStatement::CheckTypeIsFloatOrInteger(sqlite3_value *val, int sqlite_c
8081
auto value_as_text = string((const char *)sqlite3_value_text(val));
8182
auto message = "Invalid type in column \"" + column_name + "\": expected float or integer, found \"" +
8283
value_as_text + "\" of type \"" + SQLiteUtils::TypeToString(sqlite_column_type) + "\" instead.";
83-
message += "\n* SET sqlite_all_varchar=true to load all columns as VARCHAR and skip type conversions";
84+
message += "\n* SET sqlite_all_varchar=true to load all columns as VARCHAR "
85+
"and skip type conversions";
8486
throw Exception(ExceptionType::MISMATCH_TYPE, message);
8587
}
8688
}

src/storage/sqlite_table_entry.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ TableFunction SQLiteTableEntry::GetScanFunction(ClientContext &context, unique_p
4444
result->global_db = &db;
4545
result->rows_per_group = optional_idx();
4646
}
47+
result->table = this;
4748

4849
bind_data = std::move(result);
4950
return static_cast<TableFunction>(SqliteScanFunction());

vcpkg.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"dependencies": []
3+
}

0 commit comments

Comments
 (0)