Compare commits

..

18 Commits

Author SHA1 Message Date
Andrew Kane
9250ddce87 Test 2026-01-14 07:20:35 -08:00
Andrew Kane
bb431d531a Test 2026-01-14 07:15:51 -08:00
Andrew Kane
2821648051 Test 2026-01-14 07:06:53 -08:00
Andrew Kane
e583329be6 Test 2026-01-14 06:47:01 -08:00
Andrew Kane
9d4fbeb7df Test 2026-01-14 06:46:15 -08:00
Andrew Kane
eab825ae21 Test 2026-01-14 06:44:18 -08:00
Andrew Kane
0d2ef735e5 Test 2026-01-14 06:41:42 -08:00
Andrew Kane
1697c9f6d0 Test 2026-01-14 06:37:23 -08:00
Andrew Kane
77814eb0ee Test 2026-01-14 06:36:16 -08:00
Andrew Kane
1a381ffdcd Test 2026-01-14 06:35:12 -08:00
Andrew Kane
250d453f8c Test 2026-01-14 06:34:37 -08:00
Andrew Kane
498c23aa0c Test Alpine 2026-01-14 06:33:55 -08:00
Andrew Kane
f09ef49dbf Test Alpine 2026-01-14 06:31:49 -08:00
Jack Huang
544686feb1 Add RISC-V64 architecture support in Makefile (#948) 2026-01-14 06:11:58 -08:00
Andrew Kane
1a8ebb1129 Updated license year [skip ci] 2026-01-05 13:01:58 -08:00
Andrew Kane
aca89aec73 Switched to scanner_isspace for Postgres 17+ - resolves #942 2026-01-05 12:54:04 -08:00
Andrew Kane
c9875f5150 Simplified test case - resolves #943 2026-01-05 12:42:14 -08:00
Andrew Kane
df2c3d301f Added link to pgvector-cobol [skip ci] 2025-12-13 11:33:35 -08:00
20 changed files with 177 additions and 261 deletions

View File

@@ -1,70 +1,70 @@
name: build
on: [push, pull_request]
jobs:
ubuntu:
runs-on: ${{ matrix.os }}
if: ${{ !startsWith(github.ref_name, 'mac') && !startsWith(github.ref_name, 'windows') }}
strategy:
fail-fast: false
matrix:
include:
- postgres: 19
os: ubuntu-24.04
- postgres: 18
os: ubuntu-24.04
- postgres: 17
os: ubuntu-24.04
- postgres: 16
os: ubuntu-24.04-arm
- postgres: 15
os: ubuntu-22.04
- postgres: 14
os: ubuntu-22.04-arm
- postgres: 13
os: ubuntu-22.04
steps:
- uses: actions/checkout@v5
- uses: ankane/setup-postgres@v1
with:
postgres-version: ${{ matrix.postgres }}
dev-files: true
- run: make
env:
PG_CFLAGS: -DUSE_ASSERT_CHECKING -Wall -Wextra -Werror -Wno-unused-parameter -Wno-sign-compare ${{ matrix.postgres >= 18 && '-Wno-missing-field-initializers' || '' }}
- run: |
export PG_CONFIG=`which pg_config`
sudo --preserve-env=PG_CONFIG make install
- run: make installcheck
- if: ${{ failure() }}
run: cat regression.diffs
# ubuntu:
# runs-on: ${{ matrix.os }}
# if: ${{ !startsWith(github.ref_name, 'mac') && !startsWith(github.ref_name, 'windows') }}
# strategy:
# fail-fast: false
# matrix:
# include:
# - postgres: 19
# os: ubuntu-24.04
# - postgres: 18
# os: ubuntu-24.04
# - postgres: 17
# os: ubuntu-24.04
# - postgres: 16
# os: ubuntu-24.04-arm
# - postgres: 15
# os: ubuntu-22.04
# - postgres: 14
# os: ubuntu-22.04-arm
# - postgres: 13
# os: ubuntu-22.04
# steps:
# - uses: actions/checkout@v5
# - uses: ankane/setup-postgres@v1
# with:
# postgres-version: ${{ matrix.postgres }}
# dev-files: true
# - run: make
# env:
# PG_CFLAGS: -DUSE_ASSERT_CHECKING -Wall -Wextra -Werror -Wno-unused-parameter -Wno-sign-compare ${{ matrix.postgres >= 18 && '-Wno-missing-field-initializers' || '' }}
# - run: |
# export PG_CONFIG=`which pg_config`
# sudo --preserve-env=PG_CONFIG make install
# - run: make installcheck
# - if: ${{ failure() }}
# run: cat regression.diffs
# - run: |
# sudo apt-get update
# sudo apt-get install libipc-run-perl
# - run: make prove_installcheck
mac:
runs-on: ${{ matrix.os }}
if: ${{ !startsWith(github.ref_name, 'windows') }}
strategy:
fail-fast: false
matrix:
include:
- postgres: 18
os: macos-26
- postgres: 14
os: macos-15-intel
steps:
- uses: actions/checkout@v5
- uses: ankane/setup-postgres@v1
with:
postgres-version: ${{ matrix.postgres }}
- run: make
env:
PG_CFLAGS: -DUSE_ASSERT_CHECKING -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unknown-warning-option ${{ matrix.postgres >= 18 && '-Wno-missing-field-initializers' || '' }}
- run: make install
- run: make installcheck
- if: ${{ failure() }}
run: cat regression.diffs
# Homebrew Postgres does not enable TAP tests, so need to download
# mac:
# runs-on: ${{ matrix.os }}
# if: ${{ !startsWith(github.ref_name, 'windows') }}
# strategy:
# fail-fast: false
# matrix:
# include:
# - postgres: 18
# os: macos-26
# - postgres: 14
# os: macos-15-intel
# steps:
# - uses: actions/checkout@v5
# - uses: ankane/setup-postgres@v1
# with:
# postgres-version: ${{ matrix.postgres }}
# - run: make
# env:
# PG_CFLAGS: -DUSE_ASSERT_CHECKING -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unknown-warning-option ${{ matrix.postgres >= 18 && '-Wno-missing-field-initializers' || '' }}
# - run: make install
# - run: make installcheck
# - if: ${{ failure() }}
# run: cat regression.diffs
# # Homebrew Postgres does not enable TAP tests, so need to download
# - run: |
# brew install cpanm
# cpanm --notest IPC::Run
@@ -80,30 +80,64 @@ jobs:
# env:
# LLVM_VERSION: ${{ matrix.os == 'macos-26' && 20 || 18 }}
# PG_CFLAGS: -DUSE_ASSERT_CHECKING
windows:
runs-on: ${{ matrix.os }}
if: ${{ !startsWith(github.ref_name, 'mac') }}
strategy:
fail-fast: false
matrix:
include:
- postgres: 17
os: windows-2025
- postgres: 14
os: windows-2022
# windows:
# runs-on: ${{ matrix.os }}
# if: ${{ !startsWith(github.ref_name, 'mac') }}
# strategy:
# fail-fast: false
# matrix:
# include:
# - postgres: 17
# os: windows-2025
# - postgres: 14
# os: windows-2022
# steps:
# - uses: actions/checkout@v5
# - uses: ankane/setup-postgres@v1
# with:
# postgres-version: ${{ matrix.postgres }}
# - run: |
# call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" && ^
# nmake /NOLOGO /F Makefile.win && ^
# nmake /NOLOGO /F Makefile.win install && ^
# nmake /NOLOGO /F Makefile.win installcheck ${{ matrix.postgres != 17 && 'PG_REGRESS=$(PGROOT)\bin\pg_regress' || '' }} && ^
# nmake /NOLOGO /F Makefile.win clean && ^
# nmake /NOLOGO /F Makefile.win uninstall
# shell: cmd
# - if: ${{ failure() }}
# run: cat regression.diffs
i386:
if: ${{ !startsWith(github.ref_name, 'mac') && !startsWith(github.ref_name, 'windows') }}
runs-on: ubuntu-latest
container:
image: alpine:3.23
options: --platform linux/386
steps:
- uses: actions/checkout@v5
- uses: ankane/setup-postgres@v1
with:
postgres-version: ${{ matrix.postgres }}
- run: apk add --update build-base git openrc perl perl-ipc-run perl-test-harness-utils postgresql18 postgresql18-dev
- run: mkdir /run/openrc && touch /run/openrc/softlevel && rc-update add postgresql && rc-service postgresql start
- run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" && ^
nmake /NOLOGO /F Makefile.win && ^
nmake /NOLOGO /F Makefile.win install && ^
nmake /NOLOGO /F Makefile.win installcheck ${{ matrix.postgres != 17 && 'PG_REGRESS=$(PGROOT)\bin\pg_regress' || '' }} && ^
nmake /NOLOGO /F Makefile.win clean && ^
nmake /NOLOGO /F Makefile.win uninstall
shell: cmd
git clone https://github.com/${{ github.repository }}.git pgvector
cd pgvector
git fetch origin ${{ github.ref }}
git reset --hard FETCH_HEAD
make
make install
chown -R postgres .
su postgres -c "make installcheck"
su postgres -c "make prove_installcheck"
env:
PG_CFLAGS: -DUSE_ASSERT_CHECKING -Wall -Wextra -Werror -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers
- if: ${{ failure() }}
run: cat regression.diffs
run: cat pgvector/regression.diffs
# valgrind:
# if: ${{ !startsWith(github.ref_name, 'mac') && !startsWith(github.ref_name, 'windows') }}
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v5
# - uses: ankane/setup-postgres-valgrind@v1
# with:
# postgres-version: 18
# check-ub: yes
# - run: make OPTFLAGS=""
# - run: sudo --preserve-env=PG_CONFIG make install
# - run: make installcheck

View File

@@ -1,4 +1,4 @@
Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
Portions Copyright (c) 1994, The Regents of the University of California

View File

@@ -27,6 +27,11 @@ ifneq ($(filter ppc64%, $(shell uname -m)), )
OPTFLAGS =
endif
# RISC-V64 doesn't support -march=native
ifeq ($(shell uname -m), riscv64)
OPTFLAGS =
endif
# For auto-vectorization:
# - GCC (needs -ftree-vectorize OR -O3) - https://gcc.gnu.org/projects/tree-ssa/vectorization.html
# - Clang (could use pragma instead) - https://llvm.org/docs/Vectorizers.html

View File

@@ -776,6 +776,7 @@ Algol | [pgvector-algol](https://github.com/pgvector/pgvector-algol)
C | [pgvector-c](https://github.com/pgvector/pgvector-c)
C++ | [pgvector-cpp](https://github.com/pgvector/pgvector-cpp)
C#, F#, Visual Basic | [pgvector-dotnet](https://github.com/pgvector/pgvector-dotnet)
COBOL | [pgvector-cobol](https://github.com/pgvector/pgvector-cobol)
Crystal | [pgvector-crystal](https://github.com/pgvector/pgvector-crystal)
D | [pgvector-d](https://github.com/pgvector/pgvector-d)
Dart | [pgvector-dart](https://github.com/pgvector/pgvector-dart)

View File

@@ -23,6 +23,10 @@
#include "varatt.h"
#endif
#if PG_VERSION_NUM >= 170000
#include "parser/scansup.h"
#endif
#define STATE_DIMS(x) (ARR_DIMS(x)[0] - 1)
#define CreateStateDatums(dim) palloc(sizeof(Datum) * (dim + 1))
@@ -133,9 +137,9 @@ InitHalfVector(int dim)
return result;
}
/*
* Check for whitespace, since array_isspace() is static
*/
#if PG_VERSION_NUM >= 170000
#define halfvec_isspace(ch) scanner_isspace(ch)
#else
static inline bool
halfvec_isspace(char ch)
{
@@ -148,6 +152,7 @@ halfvec_isspace(char ch)
return true;
return false;
}
#endif
/*
* Check state array

View File

@@ -12,11 +12,7 @@
#include "fmgr.h"
#include "hnsw.h"
#include "miscadmin.h"
#include "nodes/nodes.h"
#include "nodes/pathnodes.h"
#include "nodes/pg_list.h"
#include "storage/lockdefs.h"
#include "storage/shmem.h"
#include "utils/float.h"
#include "utils/guc.h"
#include "utils/relcache.h"

View File

@@ -47,36 +47,16 @@
#include "catalog/index.h"
#include "catalog/pg_type_d.h"
#include "commands/progress.h"
#include "common/relpath.h"
#include "hnsw.h"
#include "miscadmin.h"
#include "nodes/execnodes.h"
#include "optimizer/optimizer.h"
#include "storage/block.h"
#include "storage/buf.h"
#include "storage/bufmgr.h"
#include "storage/bufpage.h"
#include "storage/condition_variable.h"
#include "storage/dsm.h"
#include "storage/itemid.h"
#include "storage/itemptr.h"
#include "storage/lockdefs.h"
#include "storage/lwlock.h"
#include "storage/off.h"
#include "storage/shm_toc.h"
#include "storage/shmem.h"
#include "storage/spin.h"
#include "tcop/tcopprot.h"
#include "utils/datum.h"
#include "utils/memutils.h"
#include "utils/rel.h"
#include "utils/relcache.h"
#include "utils/snapmgr.h"
#include "utils/snapshot.h"
#if PG_VERSION_NUM < 190000
#include "storage/item.h"
#endif
#if PG_VERSION_NUM >= 160000
#include "varatt.h"
@@ -90,11 +70,6 @@
#if PG_VERSION_NUM >= 140000
#include "utils/backend_status.h"
#endif
#if PG_VERSION_NUM >= 170000
#include "utils/wait_event_types.h"
#elif PG_VERSION_NUM >= 140000
#include "utils/wait_event.h"
#endif

View File

@@ -2,26 +2,13 @@
#include "access/genam.h"
#include "access/generic_xlog.h"
#include "common/relpath.h"
#include "hnsw.h"
#include "nodes/execnodes.h"
#include "storage/block.h"
#include "storage/buf.h"
#include "storage/bufmgr.h"
#include "storage/bufpage.h"
#include "storage/itemid.h"
#include "storage/itemptr.h"
#include "storage/lmgr.h"
#include "storage/lockdefs.h"
#include "storage/off.h"
#include "utils/datum.h"
#include "utils/memutils.h"
#include "utils/rel.h"
#include "utils/relcache.h"
#if PG_VERSION_NUM < 190000
#include "storage/item.h"
#endif
#if PG_VERSION_NUM >= 160000
#include "varatt.h"

View File

@@ -2,16 +2,12 @@
#include "access/genam.h"
#include "access/relscan.h"
#include "access/sdir.h"
#include "access/skey.h"
#include "hnsw.h"
#include "lib/pairingheap.h"
#include "miscadmin.h"
#include "nodes/pg_list.h"
#include "pgstat.h"
#include "storage/itemptr.h"
#include "storage/lmgr.h"
#include "storage/lockdefs.h"
#include "utils/float.h"
#include "utils/memutils.h"
#include "utils/relcache.h"

View File

@@ -5,24 +5,16 @@
#include "access/genam.h"
#include "access/generic_xlog.h"
#include "common/hashfn.h"
#include "common/relpath.h"
#include "fmgr.h"
#include "hnsw.h"
#include "lib/pairingheap.h"
#include "nodes/pg_list.h"
#include "port/atomics.h"
#include "sparsevec.h"
#include "storage/block.h"
#include "storage/buf.h"
#include "storage/bufmgr.h"
#include "storage/bufpage.h"
#include "storage/itemptr.h"
#include "storage/lwlock.h"
#include "storage/off.h"
#include "utils/datum.h"
#include "utils/memdebug.h"
#include "utils/rel.h"
#include "utils/relcache.h"
#include "vector.h"
#if PG_VERSION_NUM >= 160000

View File

@@ -3,24 +3,12 @@
#include "access/genam.h"
#include "access/generic_xlog.h"
#include "commands/vacuum.h"
#include "common/relpath.h"
#include "hnsw.h"
#include "nodes/pg_list.h"
#include "storage/block.h"
#include "storage/buf.h"
#include "storage/bufmgr.h"
#include "storage/bufpage.h"
#include "storage/itemptr.h"
#include "storage/lmgr.h"
#include "storage/lockdefs.h"
#include "storage/off.h"
#include "utils/memutils.h"
#include "utils/rel.h"
#include "utils/relcache.h"
#if PG_VERSION_NUM < 190000
#include "storage/item.h"
#endif
#if PG_VERSION_NUM >= 160000
#include "varatt.h"

View File

@@ -2,7 +2,6 @@
#include <float.h>
#include "access/attnum.h"
#include "access/genam.h"
#include "access/generic_xlog.h"
#include "access/itup.h"
@@ -17,38 +16,19 @@
#include "catalog/pg_operator_d.h"
#include "catalog/pg_type_d.h"
#include "commands/progress.h"
#include "common/relpath.h"
#include "executor/tuptable.h"
#include "fmgr.h"
#include "ivfflat.h"
#include "miscadmin.h"
#include "nodes/execnodes.h"
#include "optimizer/optimizer.h"
#include "storage/block.h"
#include "storage/buf.h"
#include "storage/bufmgr.h"
#include "storage/bufpage.h"
#include "storage/condition_variable.h"
#include "storage/dsm.h"
#include "storage/itemptr.h"
#include "storage/lockdefs.h"
#include "storage/off.h"
#include "storage/shm_toc.h"
#include "storage/shmem.h"
#include "storage/spin.h"
#include "tcop/tcopprot.h"
#include "utils/memutils.h"
#include "utils/rel.h"
#include "utils/relcache.h"
#include "utils/sampling.h"
#include "utils/snapmgr.h"
#include "utils/snapshot.h"
#include "utils/tuplesort.h"
#if PG_VERSION_NUM < 190000
#include "storage/item.h"
#endif
#if PG_VERSION_NUM >= 160000
#include "varatt.h"
#endif
@@ -61,11 +41,6 @@
#if PG_VERSION_NUM >= 140000
#include "utils/backend_status.h"
#endif
#if PG_VERSION_NUM >= 170000
#include "utils/wait_event_types.h"
#elif PG_VERSION_NUM >= 140000
#include "utils/wait_event.h"
#endif

View File

@@ -9,10 +9,7 @@
#include "commands/vacuum.h"
#include "fmgr.h"
#include "ivfflat.h"
#include "nodes/nodes.h"
#include "nodes/pathnodes.h"
#include "nodes/pg_list.h"
#include "storage/lockdefs.h"
#include "utils/float.h"
#include "utils/guc.h"
#include "utils/relcache.h"

View File

@@ -5,26 +5,13 @@
#include "access/genam.h"
#include "access/generic_xlog.h"
#include "access/itup.h"
#include "common/relpath.h"
#include "fmgr.h"
#include "ivfflat.h"
#include "nodes/execnodes.h"
#include "storage/block.h"
#include "storage/buf.h"
#include "storage/bufmgr.h"
#include "storage/bufpage.h"
#include "storage/itemid.h"
#include "storage/itemptr.h"
#include "storage/lmgr.h"
#include "storage/lockdefs.h"
#include "storage/off.h"
#include "utils/memutils.h"
#include "utils/rel.h"
#include "utils/relcache.h"
#if PG_VERSION_NUM < 190000
#include "storage/item.h"
#endif
/*
* Find the list that minimizes the distance function

View File

@@ -2,32 +2,20 @@
#include <float.h>
#include "access/attnum.h"
#include "access/genam.h"
#include "access/itup.h"
#include "access/relscan.h"
#include "access/sdir.h"
#include "access/skey.h"
#include "access/tupdesc.h"
#include "catalog/pg_operator_d.h"
#include "catalog/pg_type_d.h"
#include "common/relpath.h"
#include "executor/tuptable.h"
#include "fmgr.h"
#include "lib/pairingheap.h"
#include "ivfflat.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "storage/block.h"
#include "storage/buf.h"
#include "storage/bufmgr.h"
#include "storage/bufpage.h"
#include "storage/itemid.h"
#include "storage/itemptr.h"
#include "storage/off.h"
#include "utils/memutils.h"
#include "utils/rel.h"
#include "utils/relcache.h"
#include "utils/snapmgr.h"
#include "utils/tuplesort.h"

View File

@@ -2,15 +2,11 @@
#include "access/genam.h"
#include "access/generic_xlog.h"
#include "common/relpath.h"
#include "fmgr.h"
#include "halfutils.h"
#include "halfvec.h"
#include "ivfflat.h"
#include "storage/block.h"
#include "storage/buf.h"
#include "storage/bufmgr.h"
#include "storage/bufpage.h"
#include "utils/relcache.h"
#include "utils/varbit.h"
#include "vector.h"

View File

@@ -4,14 +4,8 @@
#include "access/generic_xlog.h"
#include "access/itup.h"
#include "commands/vacuum.h"
#include "common/relpath.h"
#include "ivfflat.h"
#include "storage/block.h"
#include "storage/buf.h"
#include "storage/bufmgr.h"
#include "storage/bufpage.h"
#include "storage/itemptr.h"
#include "storage/off.h"
#include "utils/relcache.h"
#if PG_VERSION_NUM >= 180000

View File

@@ -22,6 +22,10 @@
#include "varatt.h"
#endif
#if PG_VERSION_NUM >= 170000
#include "parser/scansup.h"
#endif
typedef struct SparseInputElement
{
int32 index;
@@ -155,9 +159,9 @@ InitSparseVector(int dim, int nnz)
return result;
}
/*
* Check for whitespace, since array_isspace() is static
*/
#if PG_VERSION_NUM >= 170000
#define sparsevec_isspace(ch) scanner_isspace(ch)
#else
static inline bool
sparsevec_isspace(char ch)
{
@@ -170,6 +174,7 @@ sparsevec_isspace(char ch)
return true;
return false;
}
#endif
/*
* Compare indices

View File

@@ -26,6 +26,10 @@
#include "varatt.h"
#endif
#if PG_VERSION_NUM >= 170000
#include "parser/scansup.h"
#endif
#define STATE_DIMS(x) (ARR_DIMS(x)[0] - 1)
#define CreateStateDatums(dim) palloc(sizeof(Datum) * (dim + 1))
@@ -129,9 +133,9 @@ InitVector(int dim)
return result;
}
/*
* Check for whitespace, since array_isspace() is static
*/
#if PG_VERSION_NUM >= 170000
#define vector_isspace(ch) scanner_isspace(ch)
#else
static inline bool
vector_isspace(char ch)
{
@@ -144,6 +148,7 @@ vector_isspace(char ch)
return true;
return false;
}
#endif
/*
* Check state array

View File

@@ -16,21 +16,12 @@ $node->safe_psql("postgres",
"INSERT INTO tst SELECT i, ARRAY[random(), random(), random()] FROM generate_series(1, 100000) i;"
);
# Check each index type
my @operators = ("<->", "<#>", "<=>");
my @opclasses = ("vector_l2_ops", "vector_ip_ops", "vector_cosine_ops");
# Add index
$node->safe_psql("postgres", "CREATE INDEX ON tst USING ivfflat (v vector_l2_ops);");
for my $i (0 .. $#operators)
# Test 100% recall
for (1 .. 20)
{
my $operator = $operators[$i];
my $opclass = $opclasses[$i];
# Add index
$node->safe_psql("postgres", "CREATE INDEX ON tst USING ivfflat (v $opclass);");
# Test 100% recall
for (1 .. 20)
{
my $id = int(rand() * 100000);
my $query = $node->safe_psql("postgres", "SELECT v FROM tst WHERE i = $id;");
my $res = $node->safe_psql("postgres", qq(
@@ -38,7 +29,6 @@ for my $i (0 .. $#operators)
SELECT v FROM tst ORDER BY v <-> '$query' LIMIT 1;
));
is($res, $query);
}
}
done_testing();