Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions hash_set.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "c.h"
#include "common/int.h"
#include "pg_set.h"
#include "varatt.h"
#define EXPANDED_CAPACITY(capacity_) (capacity_ * 2)
Expand Down Expand Up @@ -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 *
Expand Down
1 change: 1 addition & 0 deletions pg_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -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));
5 changes: 2 additions & 3 deletions pg_set_gist.c
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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);
}