Skip to content

Commit

Permalink
rename to pg_stringtheory
Browse files Browse the repository at this point in the history
  • Loading branch information
wuputah committed Jan 22, 2024
1 parent 6c56df7 commit 805e530
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 58 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Aequitas Build and Test
name: pg_stringtheory Build and Test
on:
push:
pull_request:
Expand All @@ -12,7 +12,7 @@ jobs:

steps:
- name: Test details
run: echo Build and test Aequitas on ${{ matrix.os }} with PostgreSQL ${{ matrix.version }} branch
run: echo Build and test pg_stringtheory on ${{ matrix.os }} with PostgreSQL ${{ matrix.version }} branch

- name: Checkout and build PostgreSQL code
run: |
Expand All @@ -34,21 +34,21 @@ jobs:
./pg_ctl -D data -l logfile start
popd
- name: Checkout aequitas extension code
- name: Checkout pg_stringtheory extension code
uses: actions/checkout@v4
with:
path: aequitas
path: stringtheory

- name: Build and test aequitas extension
- name: Build and test pg_stringtheory extension
id: regression-tests
run: |
export PATH="${PWD}/postgres/inst/bin:$PATH"
pushd aequitas
pushd stringtheory
make install
make installcheck
popd
- name: Print regression.diffs if regression tests failed
if: failure() && steps.regression-tests.outcome != 'success'
run: |
cat aequitas/regression.diffs
cat stringtheory/regression.diffs
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
SRCS = src/text.cpp
OBJS = $(subst .cpp,.o, $(SRCS))

MODULE_big = aequitas
MODULE_big = stringtheory

PG_CPPFLAGS = -O3 -std=c++17 -I src/sse

Expand All @@ -19,9 +19,9 @@ ifeq ($(UNAME_S),x86_64)
PG_CPPFLAGS += -msse4.2
endif

EXTENSION = aequitas
DATA = aequitas--1.0.0.sql
PGFILEDESC = "Aequitas - tools for testing equality"
EXTENSION = stringtheory
DATA = stringtheory--1.0.0.sql
PGFILEDESC = "stringtheory - tools for testing equality"

PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Aequitas - Text Comparison for PostgreSQL
# pg_stringtheory - Text Comparison for PostgreSQL

Aequitas is an extension for PostgreSQL that provides string comparisons using SSE4.2 on x86_64 platforms, and SWAR64 on aarch64 and arm64 platforms.
pg_stringtheory is an extension for PostgreSQL that provides string comparisons using SSE4.2 on x86_64 platforms, and SWAR64 on aarch64 and arm64 platforms.

## Usage

After installation:

```sql
CREATE EXTENSION aequitas;
CREATE EXTENSION stringtheory;
```

This will create a `schema` called aequitas that contains the comparison functions:
This will create a schema called `stringtheory` that contains the comparison functions:

`aequitas.equals(a TEXT, b TEXT)` - returns `BOOLEAN`, `true` if there is an exact match, and `false` if there is not.
`stringtheory.equals(a TEXT, b TEXT)` - returns `BOOLEAN`, `true` if there is an exact match, and `false` if there is not.

`aequitas.strstr(haystack TEXT, needle TEXT)` - returns `INTEGER`, the position of where the needle is found in the haystack, or `-1` if it is not found.
`stringtheory.strstr(haystack TEXT, needle TEXT)` - returns `INTEGER`, the position of where the needle is found in the haystack, or `-1` if it is not found.
19 changes: 9 additions & 10 deletions expected/equality.out
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
CREATE EXTENSION aequitas;
CREATE EXTENSION stringtheory;
-- no match
SELECT aequitas.equals('hello', 'world');
equals
SELECT stringtheory.equals('hello', 'world');
equals
--------
f
(1 row)

-- match
SELECT aequitas.equals('hello', 'hello');
equals
SELECT stringtheory.equals('hello', 'hello');
equals
--------
t
(1 row)

-- match on a 16 byte boundary
SELECT aequitas.equals('1234567890123456', '1234567890123456');
equals
SELECT stringtheory.equals('1234567890123456', '1234567890123456');
equals
--------
t
(1 row)

-- no match when partial
SELECT aequitas.equals('123456', '12345');
equals
SELECT stringtheory.equals('123456', '12345');
equals
--------
f
(1 row)

29 changes: 14 additions & 15 deletions expected/strstr.out
Original file line number Diff line number Diff line change
@@ -1,44 +1,43 @@
CREATE EXTENSION aequitas;
ERROR: extension "aequitas" already exists
CREATE EXTENSION stringtheory;
ERROR: extension "stringtheory" already exists
-- no match
SELECT aequitas.strstr('hello', 'world');
strstr
SELECT stringtheory.strstr('hello', 'world');
strstr
--------
-1
(1 row)

-- match with 0
SELECT aequitas.strstr('hello', 'hello');
strstr
SELECT stringtheory.strstr('hello', 'hello');
strstr
--------
0
(1 row)

-- match on a 16 byte boundary
SELECT aequitas.strstr('1234567890123456', '1234567890123456');
strstr
SELECT stringtheory.strstr('1234567890123456', '1234567890123456');
strstr
--------
0
(1 row)

-- match when partial
SELECT aequitas.strstr('123456', '12345');
strstr
SELECT stringtheory.strstr('123456', '12345');
strstr
--------
0
(1 row)

-- needle found in haystack
SELECT aequitas.strstr('hello world', 'ello');
strstr
SELECT stringtheory.strstr('hello world', 'ello');
strstr
--------
1
(1 row)

-- haystack in needle not found
SELECT aequitas.strstr('ello', 'hello world');
strstr
SELECT stringtheory.strstr('ello', 'hello world');
strstr
--------
-1
(1 row)

14 changes: 9 additions & 5 deletions sql/equality.sql
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
CREATE EXTENSION aequitas;
CREATE EXTENSION stringtheory;

-- no match
SELECT aequitas.equals('hello', 'world');
SELECT
stringtheory.equals('hello', 'world');

-- match
SELECT aequitas.equals('hello', 'hello');
SELECT
stringtheory.equals('hello', 'hello');

-- match on a 16 byte boundary
SELECT aequitas.equals('1234567890123456', '1234567890123456');
SELECT
stringtheory.equals('1234567890123456', '1234567890123456');

-- no match when partial
SELECT aequitas.equals('123456', '12345');
SELECT
stringtheory.equals('123456', '12345');
20 changes: 13 additions & 7 deletions sql/strstr.sql
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
CREATE EXTENSION aequitas;
CREATE EXTENSION stringtheory;

-- no match
SELECT aequitas.strstr('hello', 'world');
SELECT
stringtheory.strstr('hello', 'world');

-- match with 0
SELECT aequitas.strstr('hello', 'hello');
SELECT
stringtheory.strstr('hello', 'hello');

-- match on a 16 byte boundary
SELECT aequitas.strstr('1234567890123456', '1234567890123456');
SELECT
stringtheory.strstr('1234567890123456', '1234567890123456');

-- match when partial
SELECT aequitas.strstr('123456', '12345');
SELECT
stringtheory.strstr('123456', '12345');

-- needle found in haystack
SELECT aequitas.strstr('hello world', 'ello');
SELECT
stringtheory.strstr('hello world', 'ello');

-- haystack in needle not found
SELECT aequitas.strstr('ello', 'hello world');
SELECT
stringtheory.strstr('ello', 'hello world');
6 changes: 3 additions & 3 deletions aequitas--1.0.0.sql → stringtheory--1.0.0.sql
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
CREATE SCHEMA IF NOT EXISTS aequitas;
CREATE SCHEMA IF NOT EXISTS stringtheory;

CREATE OR REPLACE FUNCTION aequitas.strstr(left TEXT, right TEXT)
CREATE OR REPLACE FUNCTION stringtheory.strstr(left TEXT, right TEXT)
RETURNS INTEGER
AS 'MODULE_PATHNAME', 'pg_strstr'
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;

CREATE OR REPLACE FUNCTION aequitas.equals(left TEXT, right TEXT)
CREATE OR REPLACE FUNCTION stringtheory.equals(left TEXT, right TEXT)
RETURNS BOOLEAN
AS 'MODULE_PATHNAME', 'pg_equals'
LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;
2 changes: 1 addition & 1 deletion aequitas.control → stringtheory.control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# compare extension
comment = 'tools for comparing strings'
default_version = '1.0.0'
module_pathname = '$libdir/aequitas'
module_pathname = '$libdir/stringtheory'
relocatable = true

0 comments on commit 805e530

Please sign in to comment.