Skip to content

Commit

Permalink
fix: CI, add empty vcpkg.json, and update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
euiko committed Nov 5, 2024
1 parent b2e3c51 commit b35cd29
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 25 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/ExtensionTemplate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# this workflow will be removed when scripts/bootstrap-template.py is run
#
name: Extension Template
on: [push, pull_request,repository_dispatch]
on: [push, pull_request, repository_dispatch]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || '' }}-${{ github.base_ref || '' }}-${{ github.ref != 'refs/heads/main' || github.sha }}
cancel-in-progress: true
Expand All @@ -17,10 +17,10 @@ jobs:
strategy:
matrix:
# Add commits/tags to build against other DuckDB versions
duckdb_version: [ '<submodule_version>' ]
duckdb_version: ["<submodule_version>"]
env:
VCPKG_TOOLCHAIN_PATH: ${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake
VCPKG_TARGET_TRIPLET: 'x64-linux'
VCPKG_TARGET_TRIPLET: "x64-linux"
GEN: ninja
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
defaults:
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: 'true'
submodules: "recursive"

- name: Checkout DuckDB to version
if: ${{ matrix.duckdb_version != '<submodule_version>'}}
Expand Down Expand Up @@ -82,11 +82,11 @@ jobs:
strategy:
matrix:
# Add commits/tags to build against other DuckDB versions
duckdb_version: [ '<submodule_version>']
duckdb_version: ["<submodule_version>"]
env:
VCPKG_TOOLCHAIN_PATH: ${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake
VCPKG_TARGET_TRIPLET: 'x64-osx'
OSX_BUILD_ARCH: 'x86_64'
VCPKG_TARGET_TRIPLET: "x64-osx"
OSX_BUILD_ARCH: "x86_64"
GEN: ninja
defaults:
run:
Expand All @@ -96,14 +96,14 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: 'true'
submodules: "recursive"

- name: Install Ninja
run: brew install ninja

- uses: actions/setup-python@v2
with:
python-version: '3.11'
python-version: "3.11"

- name: Checkout DuckDB to version
if: ${{ matrix.duckdb_version != '<submodule_version>'}}
Expand Down Expand Up @@ -135,10 +135,10 @@ jobs:
strategy:
matrix:
# Add commits/tags to build against other DuckDB versions
duckdb_version: [ '<submodule_version>' ]
duckdb_version: ["<submodule_version>"]
env:
VCPKG_TOOLCHAIN_PATH: ${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake
VCPKG_TARGET_TRIPLET: 'x64-windows-static-md'
VCPKG_TARGET_TRIPLET: "x64-windows-static-md"
defaults:
run:
shell: bash
Expand All @@ -147,11 +147,11 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: 'true'
submodules: "recursive"

- uses: actions/setup-python@v2
with:
python-version: '3.11'
python-version: "3.11"

- name: Checkout DuckDB to version
# Add commits/tags to build against other DuckDB versions
Expand All @@ -175,4 +175,4 @@ jobs:
- name: Test extension
run: |
build/release/test/Release/unittest.exe
build/release/test/Release/unittest.exe
16 changes: 14 additions & 2 deletions src/duckdb_pgwire_extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,25 @@ inline void PgIsInRecovery(DataChunk &args, ExpressionState &state,
result.SetValue(0, false);
}

inline void QuackScalarFun(DataChunk &args, ExpressionState &state, Vector &result) {
auto &name_vector = args.data[0];
UnaryExecutor::Execute<string_t, string_t>(
name_vector, result, args.size(),
[&](string_t name) {
return StringVector::AddString(result, "Quack "+name.GetString()+" 🐥");;
});
}

static void LoadInternal(DatabaseInstance &instance) {
// Register a scalar function
auto pg_is_in_recovery_scalar_function = ScalarFunction(
"pg_is_in_recovery", {}, LogicalType::BOOLEAN, PgIsInRecovery);
ExtensionUtil::RegisterFunction(instance,
pg_is_in_recovery_scalar_function);

auto quack_scalar_function = ScalarFunction("quack", {LogicalType::VARCHAR}, LogicalType::VARCHAR, QuackScalarFun);
ExtensionUtil::RegisterFunction(instance, quack_scalar_function);

std::thread([&instance]() mutable { start_server(instance); }).detach();
}

Expand All @@ -209,12 +221,12 @@ std::string DuckdbPgwireExtension::Name() { return "duckdb_pgwire"; }

extern "C" {

DUCKDB_EXTENSION_API void quack_init(duckdb::DatabaseInstance &db) {
DUCKDB_EXTENSION_API void duckdb_pgwire_init(duckdb::DatabaseInstance &db) {
duckdb::DuckDB db_wrapper(db);
db_wrapper.LoadExtension<duckdb::DuckdbPgwireExtension>();
}

DUCKDB_EXTENSION_API const char *quack_version() {
DUCKDB_EXTENSION_API const char *duckdb_pgwire_version() {
return duckdb::DuckDB::LibraryVersion();
}
}
Expand Down
13 changes: 4 additions & 9 deletions test/sql/quack.test → test/sql/duckdb_pgwire.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# name: test/sql/quack.test
# description: test quack extension
# group: [quack]
# name: test/sql/duckdb_pgwire.test
# description: test duckdb_pgwire extension
# group: [duckdb_pgwire]

# Before we load the extension, this will fail
statement error
Expand All @@ -9,15 +9,10 @@ SELECT quack('Sam');
Catalog Error: Scalar Function with name quack does not exist!

# Require statement will ensure this test is run with this extension loaded
require quack
require duckdb_pgwire

# Confirm the extension works
query I
SELECT quack('Sam');
----
Quack Sam 🐥

query I
SELECT quack_openssl_version('Michael') ILIKE 'Quack Michael, my linked OpenSSL version is OpenSSL%';
----
true
3 changes: 3 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"dependencies": []
}

0 comments on commit b35cd29

Please sign in to comment.