Examples and contrib ports
Complete extensions built with gopgext, including ports of PostgreSQL’s contrib modules.
contrib/ holds ports of PostgreSQL’s contrib modules, written only with
the public gopgext packages (see contrib/README.md); examples/ shows
features. The contrib ports derive from PostgreSQL’s code and regression
tests, so they also keep the
PostgreSQL License.
| Project | Shows |
|---|---|
examples/hello | the gopgext init template |
examples/types | every type mapping, NULLs, arrays, sets, composite types, uuid, record results with column definition lists, arrays of extension-defined types, polymorphic functions, errors, panics, GC under load |
examples/inventory | SPI queries and error handling, settings, logging, nested calls, cancellation, sql/ files |
examples/textutil | the standard library: regexp, encoding/json, crypto/sha256, Unicode |
examples/numbers_fdw | a foreign data wrapper with gopgext/fdw: pushdown, required conditions, joins, IMPORT FOREIGN SCHEMA, user mappings (offline) |
contrib/pg_stat_statements | a port of pg_stat_statements 1.12 with gopgext/hooks and gopgext/shmem: passes upstream’s PostgreSQL 18 regression suite unmodified |
contrib/auto_explain | a port of auto_explain with gopgext/hooks (instrumentation, EXPLAIN output): passes upstream’s tests (its TAP test as SQL) on 14 and 18 and logs the same plans as the C original |
contrib/passwordcheck | a port of passwordcheck with gopgext/auth: passes upstream’s regression test |
contrib/auth_delay | a port of auth_delay with gopgext/auth: delays failed logins |
contrib/pgcrypto | a port of pgcrypto 1.4 with the standard library: digests, HMAC, crypt/gen_salt (DES, extended DES, MD5, bcrypt, SHA-256/512 crypt), encrypt/decrypt (AES, Blowfish, DES, 3DES, CAST5), OpenPGP symmetric and public-key encryption, armor; passes upstream’s regression tests on 14 and 18 and matches the C original (see its README) |
contrib/isn | a port of PostgreSQL’s contrib/isn: 8 data types with upstream’s SQL (operators, btree/hash operator classes, casts) over Go input/output functions; passes the upstream regression test and matches the C original on 100,000 inputs |
contrib/hstore | a port of hstore 1.8: upstream’s binary format, I/O, operators, records (populate_record, #=, hstore(record)) with the composite APIs of gopgext/pg, JSON, btree/hash/GiST (siglen)/GIN operator classes, subscripting with gopgext/subscript; passes upstream’s regression tests on 14 and 18 and matches the C original (see its README) |
contrib/citext | a port of citext 1.8 with collation-aware lowercasing and comparison (pg.Collation, pg.ToLower, pg.CompareStrings): passes upstream’s regression tests on 14 and 18 |
contrib/cube | a port of cube 1.5: the cube type (upstream’s binary layout, text and binary I/O), a hand-written parser matching Bison’s errors, btree and GiST operator classes with k-NN (<->, <#>, <=>, ~> on an int4 query); passes upstream’s regression tests on 14 and 18 and matches the C original |
contrib/earthdistance | a port of earthdistance 1.2 (requires = 'cube', -requires): the earth domain over cube and <@> on the built-in point (pg.Point); passes upstream’s regression test on 14 and 18 |
contrib/seg | a port of seg 1.4: a 12-byte fixed-size type (//gopgext:type over [12]byte) with significant digits, its parser and GiST operator class; passes upstream’s regression tests on 14 and 18 and matches the C original |
contrib/fuzzystrmatch | a port of PostgreSQL’s contrib/fuzzystrmatch: passes the upstream regression tests and matches the C original on 100,000 strings (see its README) |
contrib/dict_int | a port of PostgreSQL’s contrib/dict_int with gopgext/tsearch: passes the upstream regression test on 14 and 18 and matches the C original |
contrib/dict_xsyn | a port of PostgreSQL’s contrib/dict_xsyn with gopgext/tsearch (rules files in tsearch_data/): passes the upstream regression test on 14 and 18 and matches the C original |
contrib/unaccent | a port of PostgreSQL’s contrib/unaccent 1.1 with gopgext/tsearch: the dictionary, unaccent() and unaccent.rules; passes the upstream regression test on 14 and 18 and matches the C original on 100,000 strings |
contrib/tablefunc | a port of tablefunc 1.0 with pg.Record results: crosstab (all variants), connectby, normal_rand; passes upstream’s PostgreSQL 18 regression test on 14 and 18, matches the C original |
contrib/uuid-ossp | a port of uuid-ossp 1.1 with pg.UUID: versions 1, 3, 4 and 5, nil and namespace UUIDs; passes upstream’s regression test, matches the C original |
contrib/tsm_system_rows, contrib/tsm_system_time | ports of the SYSTEM_ROWS and SYSTEM_TIME TABLESAMPLE methods with gopgext/tablesample; pass upstream’s regression tests on 14 and 18 |
examples/vector | the core of pgvector with //gopgext:type: the vector type (same format), vector(n) typmod, text and binary I/O, distances and operators, btree operator class, casts, avg/sum, and an IVFFlat index access method with gopgext/am (k-means lists, probes, L2/inner product/cosine operator classes) |
examples/geo | a small PostGIS: a shape type (WKT points, line strings, polygons), measurements, rows and tables (OUT parameters, RETURNS TABLE), bounding box operators, exact distance, and a GiST index with gopgext/gist (&&, ~, @, k-NN ORDER BY <-> with recheck) |
examples/trgm | a small pg_trgm with gopgext/gin: similarity, show_trgm, % with a threshold setting, GIN indexes for %/LIKE/ILIKE (trigrams, recheck, triConsistent) and word prefixes (^@@, partial-match keys) |
examples/quadtree | an SP-GiST quadtree with gopgext/spgist: pt/rect types, ~=, <@, k-NN ORDER BY <-> (traversal values carry each node’s region), index-only scans |
examples/eventlog | BRIN operator classes with gopgext/brin: a min/max summary for a timestamp type over int64 and a Bloom filter for a name type over string; index results match sequential scans through inserts, (de)summarization, VACUUM and REINDEX |
examples/triggers | trigger functions with gopgext/trigger: BEFORE row changes (typmods, domains), skipping rows, returning the old row, AFTER and statement-level auditing, TRUNCATE, INSTEAD OF on a view, changed columns, event triggers |
contrib/tcn, contrib/lo, contrib/autoinc, contrib/insert_username, contrib/moddatetime, contrib/refint | ports of PostgreSQL’s trigger modules with gopgext/trigger: pass upstream’s regression tests (lo, autoinc, refint; tcn’s isolation spec) on 14 and 18 |
examples/textsearch | a text search parser (words, numbers, #tags) and a compound-word dictionary template with gopgext/tsearch: variants, prefix lexemes, stop words, a tsearch_data/ file, headlines, calling dictionaries from Go |
examples/stats | aggregates with Go states (gopgext/agg): median (parallel: combine, serialize), percentile, mode_of; selectivity estimators in Go (gopgext/selectivity) from MCVs, histograms and distinct counts |
Each has a test.sql; make pgtest PG_CONFIG=... builds and installs them
(and the failure-mode fixtures in test/fixtures) and runs them in a
throwaway cluster, then again with the extensions in
shared_preload_libraries.