-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
66 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |