diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..102095e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,71 @@ +name: build +on: + workflow_dispatch: + push: + branches: + - master + tags: + - "!*" # Do not execute on tags + paths: + - "**/*.c" + - "**/*.h" + - "**/*.sql" + - data/** + - expected/** + - .clangd-format + - .github/workflows/** + - Makefile + - "*.control" + pull_request: + paths: + - "**/*.c" + - "**/*.h" + - "**/*.sql" + - data/** + - expected/** + - .clangd-format + - .github/workflows/** + - Makefile + - "*.control" + branches: + - "**" +env: + PGPORT: 5432 + PGUSER: postgres + PGDATABASE: postgres + PGPASSWORD: postgres + PGHOST: localhost + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Update repositories + run: sudo apt -y install wget ca-certificates && + wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - && + sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list' && + sudo apt-get --purge remove postgresql && + sudo apt update + + - name: Install postgres + run: sudo apt install -y postgresql-16 libpq-dev clang-format postgresql-server-dev-16 + + - name: Start Postgres + run: sudo systemctl restart postgresql && sleep 5 + + - name: Set password + run: sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'postgres';" + + - name: Read Postgres version + run: sudo -u postgres psql -c "SELECT version();" + + - name: Install + run: sudo make install + + - name: Format check + run: find . -iname '*.h' -o -iname '*.c' | xargs clang-format --dry-run --Werror + + - name: Run tests + run: make installcheck || (cat regression.diffs && exit -1) diff --git a/README.md b/README.md index 15bb32f..c1f1203 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![build](https://github.com/carlosganzerla/pg_set/actions/workflows/ci.yml/badge.svg)](https://github.com/carlosganzerla/pg_set/actions/workflows/ci.yml) + # `pg_set` This extensions adds integer sets to PostgreSQL. It provides a new data type diff --git a/hash_set.c b/hash_set.c index 2de1db9..d8ba3ab 100644 --- a/hash_set.c +++ b/hash_set.c @@ -1,5 +1,4 @@ #include "c.h" -#include "common/int.h" #include "pg_set.h" #include "varatt.h" #define EXPANDED_CAPACITY(capacity_) (capacity_ * 2) @@ -92,7 +91,7 @@ pg_set_element_cmp(const void *p1, const void *p2) PgSetElement v1 = *((const PgSetElement *) p1); PgSetElement v2 = *((const PgSetElement *) p2); - return pg_cmp_s32(v1, v2); + return CMP(v1, v2); } PgSet * diff --git a/pg_set.h b/pg_set.h index 8121996..221d207 100644 --- a/pg_set.h +++ b/pg_set.h @@ -79,3 +79,4 @@ ArrayType *cast_to_array(PgSet *args); #define PgSetEqualsStrategyNumber 6 #define PgSetSubsetStrategyNumber 7 #define PgSetContainsStrategyNumber 13 +#define CMP(a, b) ((a > b) - (a < b)); diff --git a/pg_set_gist.c b/pg_set_gist.c index 94de372..5d3dd23 100644 --- a/pg_set_gist.c +++ b/pg_set_gist.c @@ -1,7 +1,6 @@ #include "postgres.h" #include "access/gist.h" #include "access/reloptions.h" -#include "common/int.h" #include "fmgr.h" #include "pg_set.h" #include "port/pg_bitutils.h" @@ -682,6 +681,6 @@ calc_penalty(GistPgSet *left, GistPgSet *right, uint32 masklen) static int comparecost(const void *a, const void *b) { - return pg_cmp_s32(((const GistSplitCost *) a)->cost, - ((const GistSplitCost *) b)->cost); + return CMP(((const GistSplitCost *) a)->cost, + ((const GistSplitCost *) b)->cost); }