diff --git a/README.md b/README.md index 2e27272..6f828d4 100644 --- a/README.md +++ b/README.md @@ -19,5 +19,6 @@ Building blocks for the following big data project use cases are supported in th - [Flink / Spark](https://hub.docker.com/r/qpod/bigdata) - [Kafka](https://hub.docker.com/r/qpod/kafka) -- [Elasticsearch](https://hub.docker.com/r/qpod/elasticsearch) +- [Postgresql with Extensions](https://hub.docker.com/r/qpod/postgres-ext): including pgvector, age, and [many others](https://github.com/QPod/lab-data/blob/main/docker_postgres/rootfs/opt/utils/install_list_pgext.tpl.apt) - [GreenplumDB](https://hub.docker.com/r/qpod/greenplum) +- [Elasticsearch](https://hub.docker.com/r/qpod/elasticsearch) diff --git a/docker_greenplum/example/gpdb-single-node/docker-compose.yml b/docker_greenplum/example/gpdb-single-node/docker-compose.yml index 475924c..825f7d9 100644 --- a/docker_greenplum/example/gpdb-single-node/docker-compose.yml +++ b/docker_greenplum/example/gpdb-single-node/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3" - networks: greenplum: ipam: diff --git a/docker_greenplum/example/gpdb-single-vm/docker-compose.yml b/docker_greenplum/example/gpdb-single-vm/docker-compose.yml index 00ff4fd..51fb051 100644 --- a/docker_greenplum/example/gpdb-single-vm/docker-compose.yml +++ b/docker_greenplum/example/gpdb-single-vm/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3" - networks: greenplum: ipam: diff --git a/docker_kafka_confluent/example/kafka-standalone-bitnami/docker-compose.yml b/docker_kafka_confluent/example/kafka-standalone-bitnami/docker-compose.yml index 6b4c533..8135aa1 100644 --- a/docker_kafka_confluent/example/kafka-standalone-bitnami/docker-compose.yml +++ b/docker_kafka_confluent/example/kafka-standalone-bitnami/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3" - # Standalone kraft mode, ref: https://github.com/bitnami/containers/tree/main/bitnami/kafka#kafka-without-zookeeper-kraft # Note: the volume folder read/write permission is required for uid 1001 and gid 1000. use the command below for debug: # `KAFKA_DATA_DIR="/data/database/kafka-bitnami/broker" && mkdir -pv $KAFKA_DATA_DIR && chmod -R ugo+rws $KAFKA_DATA_DIR` diff --git a/docker_kafka_confluent/example/kafka-standalone-confluent/docker-compose.yml b/docker_kafka_confluent/example/kafka-standalone-confluent/docker-compose.yml index f0d90f5..344c507 100644 --- a/docker_kafka_confluent/example/kafka-standalone-confluent/docker-compose.yml +++ b/docker_kafka_confluent/example/kafka-standalone-confluent/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3' - ## Standalone kraft mode - confluent kafka: https://github.com/confluentinc/cp-all-in-one/blob/7.3.0-post/cp-all-in-one-kraft/docker-compose.yml # Note: the volume folder read/write permission is required for uid 1001 and gid 1000. use the command below for debug: # `KAFKA_DATA_DIR="/data/database/kafka-bitnami/broker" && mkdir -pv $KAFKA_DATA_DIR && chmod -R ugo+rws $KAFKA_DATA_DIR` diff --git a/docker_postgres/README.md b/docker_postgres/README.md index 0690968..dca97f0 100644 --- a/docker_postgres/README.md +++ b/docker_postgres/README.md @@ -3,21 +3,28 @@ ## Debug ```shell -BUILDKIT_PROGRESS=plain docker build -t postgres-ext -f ./postgres-ext.Dockerfile --build-arg BASE_NAMESPACE=qpod0dev . - -IMG="qpod0dev/postgres-ext" +BUILDKIT_PROGRESS=plain \ +docker build -t qpod0dev/postgres-ext -f ./postgres-ext.Dockerfile --build-arg BASE_NAMESPACE=qpod0dev . +( docker rm db-postgres || true ) docker run -d \ --name db-postgres \ -p 5432:5432 \ -e POSTGRES_PASSWORD=pg-password \ - $IMG + qpod0dev/postgres-ext docker exec -it db-postgres bash -ls -alh /usr/share/postgresql/15/extension/*.control +ls -alh /usr/share/postgresql/${PG_MAJOR}/extension/*.control ``` +## Reference + +- article: https://mp.weixin.qq.com/s/CduvvvuUDjqNtvKA1OblAQ +- code: https://github.com/digoal/postgresql_docker_builder/blob/main/pg14_amd64/1.sh + +## List of Extensions + ```sql SELECT extname AS name, extversion AS ver FROM pg_extension ORDER BY extname; @@ -25,174 +32,143 @@ FROM pg_extension ORDER BY extname; SELECT name, default_version AS ver, comment FROM pg_available_extensions ORDER BY name; - -CREATE OR REPLACE PROCEDURE enable_all_extensions() -LANGUAGE plpgsql -AS $$ -DECLARE - extension_name TEXT; -BEGIN - FOR extension_name IN - SELECT name FROM pg_available_extensions - WHERE name NOT IN (SELECT extname AS name FROM pg_extension) - ORDER BY name - LOOP - BEGIN - EXECUTE format('CREATE EXTENSION IF NOT EXISTS %I', extension_name); - EXCEPTION WHEN OTHERS THEN - -- Optionally log the error or do nothing to continue with the next extension - RAISE NOTICE 'Failed to create extension %: %', extension_name, SQLERRM; - END; - END LOOP; -END; -$$; - -CREATE EXTENSION "hstore"; -CALL enable_all_extensions(); - SELECT name, default_version AS ver FROM pg_available_extensions WHERE name NOT IN (SELECT extname AS name FROM pg_extension) ORDER BY name; ``` -## Reference - -- article: https://mp.weixin.qq.com/s/CduvvvuUDjqNtvKA1OblAQ -- code: https://github.com/digoal/postgresql_docker_builder/blob/main/pg14_amd64/1.sh - -## List of Extensions - | name | ver | comment | |--------------------------------|--------|-----------------------------------------------------------------------------------------------------------------------| | address_standardizer | 3.4.2 | Used to parse an address into constituent elements. Generally used to support geocoding address normalization step. | | address_standardizer-3 | 3.4.2 | Used to parse an address into constituent elements. Generally used to support geocoding address normalization step. | -| address_standardizer_data_us | 3.4.2 | Address Standardizer US dataset example | -| address_standardizer_data_us-3 | 3.4.2 | Address Standardizer US dataset example | -| adminpack | 2.1 | administrative functions for PostgreSQL | -| amcheck | 1.3 | functions for verifying relation integrity | -| autoinc | 1 | functions for autoincrementing fields | -| bloom | 1 | bloom access method - signature file based index | -| btree_gin | 1.3 | support for indexing common datatypes in GIN | -| btree_gist | 1.7 | support for indexing common datatypes in GiST | -| citext | 1.6 | data type for case-insensitive character strings | -| citus | 12.1-1 | Citus distributed database | -| citus_columnar | 11.3-1 | Citus Columnar extension | -| credcheck | 2.6.0 | credcheck - postgresql plain text credential checker | -| cube | 1.5 | data type for multidimensional cubes | -| dblink | 1.2 | connect to other PostgreSQL databases from within a database | -| decoderbufs | 0.1.0 | Logical decoding plugin that delivers WAL stream changes using a Protocol Buffer format | -| dict_int | 1 | text search dictionary template for integers | -| dict_xsyn | 1 | text search dictionary template for extended synonym processing | -| earthdistance | 1.1 | calculate great-circle distances on the surface of the Earth | -| extra_window_functions | 1 | | -| file_fdw | 1 | foreign-data wrapper for flat file access | -| first_last_agg | 0.1.4 | first() and last() aggregate functions | -| fuzzystrmatch | 1.1 | determine similarities and distance between strings | -| hll | 2.18 | type for storing hyperloglog data | -| hstore | 1.8 | data type for storing sets of (key, value) pairs | -| hstore_pllua | 1 | Hstore transform for Lua | -| hstore_plluau | 1 | Hstore transform for untrusted Lua | -| hstore_plpython3u | 1 | transform between hstore and plpython3u | -| hypopg | 1.4.0 | Hypothetical indexes for PostgreSQL | -| icu_ext | 1.8 | Access ICU functions | -| insert_username | 1 | functions for tracking who changed a table | -| intagg | 1.1 | integer aggregator and enumerator (obsolete) | -| intarray | 1.5 | functions, operators, and index support for 1-D arrays of integers | -| ip4r | 2.4 | | -| isn | 1.2 | data types for international product numbering standards | -| jsonb_plpython3u | 1 | transform between jsonb and plpython3u | -| jsquery | 1.1 | data type for jsonb inspection | -| lo | 1.1 | Large Object maintenance | -| ltree | 1.2 | data type for hierarchical tree-like structures | -| ltree_plpython3u | 1 | transform between ltree and plpython3u | -| mimeo | 1.5.1 | Extension for specialized, per-table replication between PostgreSQL instances | -| moddatetime | 1 | functions for tracking last modification time | -| mysql_fdw | 1.2 | Foreign data wrapper for querying a MySQL server | -| ogr_fdw | 1.1 | foreign-data wrapper for GIS data access | -| old_snapshot | 1 | utilities in support of old_snapshot_threshold | -| oracle_fdw | 1.2 | foreign data wrapper for Oracle access | -| orafce | 4.9 | Functions and operators that emulate a subset of functions and packages from the Oracle RDBMS | -| pageinspect | 1.11 | inspect the contents of database pages at a low level | -| pg_buffercache | 1.3 | examine the shared buffer cache | -| pg_cron | 1.6 | Job scheduler for PostgreSQL | -| pg_dirtyread | 2 | Read dead but unvacuumed rows from table | -| pg_freespacemap | 1.2 | examine the free space map (FSM) | -| pg_graphql | 1.4.0 | pg_graphql: GraphQL support | -| pg_net | 0.7.3 | Async HTTP | -| pg_partman | 5.0.1 | Extension to manage partitioned tables by time or ID | -| pg_prewarm | 1.2 | prewarm relation data | -| pg_qualstats | 2.1.0 | An extension collecting statistics about quals | -| pg_rational | 0.0.1 | bigint fractions | -| pg_repack | 1.5.0 | Reorganize tables in PostgreSQL databases with minimal locks | -| pg_show_plans | 2 | show query plans of all currently running SQL statements | -| pg_similarity | 1 | support similarity queries | -| pg_sphere | 1.4.2 | spherical objects with useful functions, operators and index support | -| pg_squeeze | 1.6 | A tool to remove unused space from a relation. | -| pg_stat_kcache | 2.2.3 | Kernel statistics gathering | -| pg_stat_statements | 1.1 | track planning and execution statistics of all SQL statements executed | -| pg_surgery | 1 | extension to perform surgery on a damaged relation | -| pg_trgm | 1.6 | text similarity measurement and index searching based on trigrams | -| pg_visibility | 1.2 | examine the visibility map (VM) and page-level visibility info | -| pg_wait_sampling | 1.1 | sampling based statistics of wait events | -| pg_walinspect | 1 | functions to inspect contents of PostgreSQL Write-Ahead Log | -| pgagent | 4.2 | A PostgreSQL job scheduler | -| pgaudit | 1.7 | provides auditing functionality | -| pgautofailover | 2.1 | pg_auto_failover | -| pgcrypto | 1.3 | cryptographic functions | -| pgfincore | 1.3.1 | examine and manage the os buffer cache | -| pgmemcache | 2.3.0 | memcached interface | -| pgmp | 1.1 | Multiple Precision Arithmetic extension | -| pgpool_adm | 1.4 | Administrative functions for pgPool | -| pgpool_recovery | 1.4 | recovery functions for pgpool-II for V4.3 | -| pgpool_regclass | 1 | replacement for regclass | -| pgrouting | 3.6.2 | pgRouting Extension | -| pgrowlocks | 1.2 | show row-level locking information | -| pgstattuple | 1.5 | show tuple-level statistics | -| pldbgapi | 1.1 | server-side support for debugging PL/pgSQL functions | -| pljava | 1.6.7 | PL/Java procedural language (https://tada.github.io/pljava/) | -| pllua | 2 | Lua as a procedural language | -| plluau | 2 | Lua as an untrusted procedural language | -| plpgsql | 1 | PL/pgSQL procedural language | -| plpgsql_check | 2.7 | extended check for plpgsql functions | -| plprofiler | 4.2 | server-side support for profiling PL/pgSQL functions | -| plproxy | 2.11.0 | Database partitioning implemented as procedural language d | -| plpython3u | 1 | PL/Python3U untrusted procedural language | -| plr | 8.4.6 | load R interpreter and execute R script from within a database | -| pointcloud | 1.2.5 | data type for lidar point clouds | -| pointcloud_postgis | 1.2.5 | integration for pointcloud LIDAR data and PostGIS geometry data | -| postgis | 3.4.2 | PostGIS geometry and geography spatial types and functions | -| postgis-3 | 3.4.2 | PostGIS geometry and geography spatial types and functions | -| postgis_raster | 3.4.2 | PostGIS raster types and functions | -| postgis_raster-3 | 3.4.2 | PostGIS raster types and functions | -| postgis_sfcgal | 3.4.2 | PostGIS SFCGAL functions | -| postgis_sfcgal-3 | 3.4.2 | PostGIS SFCGAL functions | -| postgis_tiger_geocoder | 3.4.2 | PostGIS tiger geocoder and reverse geocoder | -| postgis_tiger_geocoder-3 | 3.4.2 | PostGIS tiger geocoder and reverse geocoder | -| postgis_topology | 3.4.2 | PostGIS topology spatial types and functions | -| postgis_topology-3 | 3.4.2 | PostGIS topology spatial types and functions | -| postgres_fdw | 1.1 | foreign-data wrapper for remote PostgreSQL servers | -| powa | 4.2.2 | PostgreSQL Workload Analyser-core | -| pre_prepare | 0.4 | Pre Prepare your Statement server side | -| prefix | 1.2.0 | Prefix Range module for PostgreSQL | -| prioritize | 1 | get and set the priority of PostgreSQL backends | -| q3c | 2.0.1 | q3c sky indexing plugin | -| rdkit | 4.3.0 | Cheminformatics functionality for PostgreSQL. | -| refint | 1 | functions for implementing referential integrity (obsolete) | -| rum | 1.3 | RUM index access method | -| seg | 1.4 | data type for representing line segments or floating-point intervals | -| sslinfo | 1.2 | information about SSL certificates | -| table_log | 0.6.1 | Module to log changes on tables | -| tablefunc | 1 | functions that manipulate whole tables, including crosstab | -| tcn | 1 | Triggered change notifications | -| tdigest | 1.4.1 | Provides tdigest aggregate function. | -| tds_fdw | 2.0.3 | Foreign data wrapper for querying a TDS database (Sybase or Microsoft SQL Server) | -| timescaledb | 2.14.2 | Enables scalable inserts and complex queries for time-series data (Community Edition) | -| toastinfo | 1 | show details on toasted datums | -| tsm_system_rows | 1 | TABLESAMPLE method which accepts number of rows as a limit | -| tsm_system_time | 1 | TABLESAMPLE method which accepts time in milliseconds as a limit | -| unaccent | 1.1 | text search dictionary that removes accents | -| unit | 7 | SI units extension | -| uuid-ossp | 1.1 | generate universally unique identifiers (UUIDs) | -| vector | 0.6.2 | vector data type and ivfflat and hnsw access methods | -| xml2 | 1.1 | XPath querying and XSLT | +| address_standardizer_data_us | 3.4.2 | Address Standardizer US dataset example | +| address_standardizer_data_us-3 | 3.4.2 | Address Standardizer US dataset example | +| adminpack | 2.1 | administrative functions for PostgreSQL | +| age | 1.5.0 | AGE database extension | +| amcheck | 1.3 | functions for verifying relation integrity | +| autoinc | 1 | functions for autoincrementing fields | +| bloom | 1 | bloom access method - signature file based index | +| btree_gin | 1.3 | support for indexing common datatypes in GIN | +| btree_gist | 1.7 | support for indexing common datatypes in GiST | +| citext | 1.6 | data type for case-insensitive character strings | +| citus | 12.1-1 | Citus distributed database | +| citus_columnar | 11.3-1 | Citus Columnar extension | +| credcheck | 2.6.0 | credcheck - postgresql plain text credential checker | +| cube | 1.5 | data type for multidimensional cubes | +| dblink | 1.2 | connect to other PostgreSQL databases from within a database | +| decoderbufs | 0.1.0 | Logical decoding plugin that delivers WAL stream changes using a Protocol Buffer format | +| dict_int | 1 | text search dictionary template for integers | +| dict_xsyn | 1 | text search dictionary template for extended synonym processing | +| earthdistance | 1.1 | calculate great-circle distances on the surface of the Earth | +| extra_window_functions | 1 | | +| file_fdw | 1 | foreign-data wrapper for flat file access | +| first_last_agg | 0.1.4 | first() and last() aggregate functions | +| fuzzystrmatch | 1.1 | determine similarities and distance between strings | +| hll | 2.18 | type for storing hyperloglog data | +| hstore | 1.8 | data type for storing sets of (key, value) pairs | +| hstore_pllua | 1 | Hstore transform for Lua | +| hstore_plluau | 1 | Hstore transform for untrusted Lua | +| hstore_plpython3u | 1 | transform between hstore and plpython3u | +| hypopg | 1.4.0 | Hypothetical indexes for PostgreSQL | +| icu_ext | 1.8 | Access ICU functions | +| insert_username | 1 | functions for tracking who changed a table | +| intagg | 1.1 | integer aggregator and enumerator (obsolete) | +| intarray | 1.5 | functions, operators, and index support for 1-D arrays of integers | +| ip4r | 2.4 | | +| isn | 1.2 | data types for international product numbering standards | +| jsonb_plpython3u | 1 | transform between jsonb and plpython3u | +| jsquery | 1.1 | data type for jsonb inspection | +| lo | 1.1 | Large Object maintenance | +| ltree | 1.2 | data type for hierarchical tree-like structures | +| ltree_plpython3u | 1 | transform between ltree and plpython3u | +| mimeo | 1.5.1 | Extension for specialized, per-table replication between PostgreSQL instances | +| moddatetime | 1 | functions for tracking last modification time | +| mysql_fdw | 1.2 | Foreign data wrapper for querying a MySQL server | +| ogr_fdw | 1.1 | foreign-data wrapper for GIS data access | +| old_snapshot | 1 | utilities in support of old_snapshot_threshold | +| oracle_fdw | 1.2 | foreign data wrapper for Oracle access | +| orafce | 4.9 | Functions and operators that emulate a subset of functions and packages from the Oracle RDBMS | +| pageinspect | 1.11 | inspect the contents of database pages at a low level | +| pg_buffercache | 1.3 | examine the shared buffer cache | +| pg_cron | 1.6 | Job scheduler for PostgreSQL | +| pg_dirtyread | 2 | Read dead but unvacuumed rows from table | +| pg_freespacemap | 1.2 | examine the free space map (FSM) | +| pg_graphql | 1.4.0 | pg_graphql: GraphQL support | +| pg_net | 0.7.3 | Async HTTP | +| pg_partman | 5.0.1 | Extension to manage partitioned tables by time or ID | +| pg_prewarm | 1.2 | prewarm relation data | +| pg_qualstats | 2.1.0 | An extension collecting statistics about quals | +| pg_rational | 0.0.1 | bigint fractions | +| pg_repack | 1.5.0 | Reorganize tables in PostgreSQL databases with minimal locks | +| pg_show_plans | 2 | show query plans of all currently running SQL statements | +| pg_similarity | 1 | support similarity queries | +| pg_sphere | 1.4.2 | spherical objects with useful functions, operators and index support | +| pg_squeeze | 1.6 | A tool to remove unused space from a relation. | +| pg_stat_kcache | 2.2.3 | Kernel statistics gathering | +| pg_stat_statements | 1.1 | track planning and execution statistics of all SQL statements executed | +| pg_surgery | 1 | extension to perform surgery on a damaged relation | +| pg_trgm | 1.6 | text similarity measurement and index searching based on trigrams | +| pg_visibility | 1.2 | examine the visibility map (VM) and page-level visibility info | +| pg_wait_sampling | 1.1 | sampling based statistics of wait events | +| pg_walinspect | 1 | functions to inspect contents of PostgreSQL Write-Ahead Log | +| pgagent | 4.2 | A PostgreSQL job scheduler | +| pgaudit | 1.7 | provides auditing functionality | +| pgautofailover | 2.1 | pg_auto_failover | +| pgcrypto | 1.3 | cryptographic functions | +| pgfincore | 1.3.1 | examine and manage the os buffer cache | +| pgmemcache | 2.3.0 | memcached interface | +| pgmp | 1.1 | Multiple Precision Arithmetic extension | +| pgpool_adm | 1.4 | Administrative functions for pgPool | +| pgpool_recovery | 1.4 | recovery functions for pgpool-II for V4.3 | +| pgpool_regclass | 1 | replacement for regclass | +| pgrouting | 3.6.2 | pgRouting Extension | +| pgrowlocks | 1.2 | show row-level locking information | +| pgstattuple | 1.5 | show tuple-level statistics | +| pldbgapi | 1.1 | server-side support for debugging PL/pgSQL functions | +| pljava | 1.6.7 | PL/Java procedural language (https://tada.github.io/pljava/) | +| pllua | 2 | Lua as a procedural language | +| plluau | 2 | Lua as an untrusted procedural language | +| plpgsql | 1 | PL/pgSQL procedural language | +| plpgsql_check | 2.7 | extended check for plpgsql functions | +| plprofiler | 4.2 | server-side support for profiling PL/pgSQL functions | +| plproxy | 2.11.0 | Database partitioning implemented as procedural language d | +| plpython3u | 1 | PL/Python3U untrusted procedural language | +| plr | 8.4.6 | load R interpreter and execute R script from within a database | +| pointcloud | 1.2.5 | data type for lidar point clouds | +| pointcloud_postgis | 1.2.5 | integration for pointcloud LIDAR data and PostGIS geometry data | +| postgis | 3.4.2 | PostGIS geometry and geography spatial types and functions | +| postgis-3 | 3.4.2 | PostGIS geometry and geography spatial types and functions | +| postgis_raster | 3.4.2 | PostGIS raster types and functions | +| postgis_raster-3 | 3.4.2 | PostGIS raster types and functions | +| postgis_sfcgal | 3.4.2 | PostGIS SFCGAL functions | +| postgis_sfcgal-3 | 3.4.2 | PostGIS SFCGAL functions | +| postgis_tiger_geocoder | 3.4.2 | PostGIS tiger geocoder and reverse geocoder | +| postgis_tiger_geocoder-3 | 3.4.2 | PostGIS tiger geocoder and reverse geocoder | +| postgis_topology | 3.4.2 | PostGIS topology spatial types and functions | +| postgis_topology-3 | 3.4.2 | PostGIS topology spatial types and functions | +| postgres_fdw | 1.1 | foreign-data wrapper for remote PostgreSQL servers | +| powa | 4.2.2 | PostgreSQL Workload Analyser-core | +| pre_prepare | 0.4 | Pre Prepare your Statement server side | +| prefix | 1.2.0 | Prefix Range module for PostgreSQL | +| prioritize | 1 | get and set the priority of PostgreSQL backends | +| q3c | 2.0.1 | q3c sky indexing plugin | +| rdkit | 4.3.0 | Cheminformatics functionality for PostgreSQL. | +| refint | 1 | functions for implementing referential integrity (obsolete) | +| rum | 1.3 | RUM index access method | +| seg | 1.4 | data type for representing line segments or floating-point intervals | +| sslinfo | 1.2 | information about SSL certificates | +| table_log | 0.6.1 | Module to log changes on tables | +| tablefunc | 1 | functions that manipulate whole tables, including crosstab | +| tcn | 1 | Triggered change notifications | +| tdigest | 1.4.1 | Provides tdigest aggregate function. | +| tds_fdw | 2.0.3 | Foreign data wrapper for querying a TDS database (Sybase or Microsoft SQL Server) | +| timescaledb | 2.14.2 | Enables scalable inserts and complex queries for time-series data (Community Edition) | +| toastinfo | 1 | show details on toasted datums | +| tsm_system_rows | 1 | TABLESAMPLE method which accepts number of rows as a limit | +| tsm_system_time | 1 | TABLESAMPLE method which accepts time in milliseconds as a limit | +| unaccent | 1.1 | text search dictionary that removes accents | +| unit | 7 | SI units extension | +| uuid-ossp | 1.1 | generate universally unique identifiers (UUIDs) | +| vector | 0.6.2 | vector data type and ivfflat and hnsw access methods | +| xml2 | 1.1 | XPath querying and XSLT | diff --git a/docker_postgres/demo/docker-compose.yml b/docker_postgres/demo/docker-compose.yml new file mode 100644 index 0000000..128b970 --- /dev/null +++ b/docker_postgres/demo/docker-compose.yml @@ -0,0 +1,26 @@ +services: + db-postgres: + # su postgres && psql -d casdoor -U pg-casdoor-username + image: qpod0dev/postgres-ext + container_name: db-postgres + environment: + POSTGRES_DB: postgres + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + + svc-jupyter: + image: quay.io/jupyter/minimal-notebook + depends_on: + - db-postgres + container_name: dev-jupyter + hostname: jupyter + user: root + environment: + NB_USER: root + NB_UID: 0 + NB_GID: 0 + ports: + - 8888:8888 + volumes: + - "./:/home/root/work" + command: ["start-notebook.py", "--allow-root"] diff --git a/docker_postgres/demo/test-apache-age.ipynb b/docker_postgres/demo/test-apache-age.ipynb new file mode 100644 index 0000000..99d0190 --- /dev/null +++ b/docker_postgres/demo/test-apache-age.ipynb @@ -0,0 +1,106 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "0e5737ed-ad83-4902-b551-ddd413f13475", + "metadata": {}, + "source": [ + "# Example - Using Python to connect to PG Apache AGE\n", + "\n", + "- reference: https://age.apache.org/getstarted/quickstart\n", + "- to install `apache-age-python`, code compile is currently required:\n", + "\n", + "```shell\n", + "sudo apt-get -y install gcc libpq-dev \"postgresql-client-${VER_PG}\"\n", + "```" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c0fa8e36-c263-4f95-b715-670ee760167d", + "metadata": {}, + "outputs": [], + "source": [ + "! pip install apache-age-python" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1700acf5-8cc6-495a-ab7d-44115cdc7b94", + "metadata": {}, + "outputs": [], + "source": [ + "import age\n", + "import psycopg2" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "dac7a486-6fc8-43f5-88f9-ed57d507becb", + "metadata": {}, + "outputs": [], + "source": [ + "conn = psycopg2.connect(host=\"db-postgres\", port=\"5432\", dbname=\"postgres\", user=\"postgres\", password=\"postgres\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "759fe54a-7897-4eaa-a304-ff9d084c0704", + "metadata": {}, + "outputs": [], + "source": [ + "DSN = \"host=db-postgres port=5432 dbname=postgres user=postgres password=postgres\"\n", + "TEST_GRAPH_NAME = 'agens'\n", + "\n", + "conn = age.connect(dsn=DSN, graph=TEST_GRAPH_NAME)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "56c19b14-aaa5-4d73-b049-88f51fb983e6", + "metadata": {}, + "outputs": [], + "source": [ + "cursor = conn.execCypher(\"CREATE (n:Person {name: %s, title: 'Developer'}) RETURN n\", params=('Andy',))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "affae3fa-bad0-4685-a05b-fb689287fce3", + "metadata": {}, + "outputs": [], + "source": [ + "from age.models import Vertex\n", + "for row in cursor:\n", + " print(\"Vertex: %s , Type: %s \" % (Vertex, type(row[0])))" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.8" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/docker_postgres/demo/test-pgvector.ipynb b/docker_postgres/demo/test-pgvector.ipynb new file mode 100644 index 0000000..1828787 --- /dev/null +++ b/docker_postgres/demo/test-pgvector.ipynb @@ -0,0 +1,163 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "0e5737ed-ad83-4902-b551-ddd413f13475", + "metadata": {}, + "source": [ + "# Example - Using Python to connect to PG vector\n", + "\n", + "https://github.com/pgvector/pgvector-python/blob/master/examples/openai_embeddings.py" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c0fa8e36-c263-4f95-b715-670ee760167d", + "metadata": {}, + "outputs": [], + "source": [ + "! pip install psycopg[binary] pgvector" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1700acf5-8cc6-495a-ab7d-44115cdc7b94", + "metadata": {}, + "outputs": [], + "source": [ + "from pgvector.psycopg import register_vector\n", + "import psycopg" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "dac7a486-6fc8-43f5-88f9-ed57d507becb", + "metadata": {}, + "outputs": [], + "source": [ + "conn = psycopg.connect(\n", + " conninfo='postgresql://postgres:postgres@db-postgres/postgres',\n", + " autocommit=True\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9e399b5c-e11b-4fd9-b430-7774d2bb8457", + "metadata": {}, + "outputs": [], + "source": [ + "conn.execute('CREATE EXTENSION IF NOT EXISTS vector')\n", + "register_vector(conn)\n", + "conn.execute('DROP TABLE IF EXISTS documents')\n", + "conn.execute('CREATE TABLE documents (id bigserial PRIMARY KEY, content text, embedding vector(1536))')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "36c139e8", + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "\n", + "def get_embeddings(inputs: list):\n", + " dimensions = 1536\n", + " embeddings = [np.random.rand(dimensions) for _ in inputs]\n", + " return embeddings\n", + "\n", + "# The real code should by something like:\n", + "# from openai import OpenAI\n", + "# OPENAI_API_KEY=\"*\"\n", + "# client = OpenAI(api_key=OPENAI_API_KEY)\n", + "# response = client.embeddings.create(input=input, model='text-embedding-3-small')\n", + "# embeddings = [v.embedding for v in response.data]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b52db809-d008-448a-99bd-9db57dc35218", + "metadata": {}, + "outputs": [], + "source": [ + "inputs = [\n", + " 'The dog is barking',\n", + " 'The cat is purring',\n", + " 'The bear is growling'\n", + "]\n", + "\n", + "embeddings = get_embeddings(inputs)" + ] + }, + { + "cell_type": "markdown", + "id": "dff8234a-4bf2-4abc-8d3f-68a233225792", + "metadata": {}, + "source": [ + "## Insert doc contents and embeddings into DB table" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b507cff0-dae1-42ea-b71b-c8f230474cb0", + "metadata": {}, + "outputs": [], + "source": [ + "for content, embedding in zip(inputs, embeddings):\n", + " conn.execute('INSERT INTO documents (content, embedding) VALUES (%s, %s)', (content, embedding))" + ] + }, + { + "cell_type": "markdown", + "id": "c7b240ae-1d24-45a7-b96a-de89f50f0c14", + "metadata": {}, + "source": [ + "## Query DB table using embedding" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "65391dfc", + "metadata": {}, + "outputs": [], + "source": [ + "document_id = 1\n", + "neighbors = conn.execute(\n", + " 'SELECT content FROM documents WHERE id != %(id)s ORDER BY embedding <=> (SELECT embedding FROM documents WHERE id = %(id)s) LIMIT 5',\n", + " {'id': document_id}\n", + ").fetchall()\n", + "for neighbor in neighbors:\n", + " print(neighbor[0])" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.8" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/docker_postgres/postgres-ext.Dockerfile b/docker_postgres/postgres-ext.Dockerfile index d79f4d2..3866f54 100644 --- a/docker_postgres/postgres-ext.Dockerfile +++ b/docker_postgres/postgres-ext.Dockerfile @@ -9,14 +9,14 @@ LABEL maintainer="haobibo@gmail.com" COPY rootfs / RUN set -x && . /opt/utils/script-utils.sh && . /opt/utils/script-setup-pg_ext_mirror.sh \ + ## Generate a package list based on PG_MAJOR version && apt-get update && apt-get install -y gettext \ && envsubst < /opt/utils/install_list_pgext.tpl.apt > /opt/utils/install_list_pgext.apt \ && rm -rf /opt/utils/install_list_pgext.tpl.apt \ - && echo "To install PG extensions: $(cat /opt/utils/install_list_pgext.apt)" \ - && install_apt /opt/utils/install_list_pgext.apt \ + ## Install extensions && . /opt/utils/script-setup-pg_ext.sh \ - && ls -alh /usr/share/postgresql/*/extension/*.control | sort \ - && echo "include_dir='./conf.d'" >> /var/lib/postgresql/data/postgresql.conf \ + ## Hack: fix system python / conda python + && cp -rf /opt/conda/lib/python3.11/platform.py.bak /opt/conda/lib/python3.11/platform.py \ && echo "Clean up" && list_installed_packages && install__clean USER postgres diff --git a/docker_postgres/rootfs/docker-entrypoint-initdb.d/00-extensions-prepare.sql b/docker_postgres/rootfs/docker-entrypoint-initdb.d/00-extensions-prepare.sql new file mode 100644 index 0000000..7c56035 --- /dev/null +++ b/docker_postgres/rootfs/docker-entrypoint-initdb.d/00-extensions-prepare.sql @@ -0,0 +1,23 @@ +CREATE OR REPLACE PROCEDURE enable_all_extensions() +LANGUAGE plpgsql +AS $$ +DECLARE + extension_name TEXT; +BEGIN + FOR extension_name IN + SELECT name FROM pg_available_extensions + WHERE name NOT IN (SELECT extname AS name FROM pg_extension) + ORDER BY name + LOOP + BEGIN + EXECUTE format('CREATE EXTENSION IF NOT EXISTS %I', extension_name); + EXCEPTION WHEN OTHERS THEN + -- Optionally log the error or do nothing to continue with the next extension + RAISE NOTICE 'Failed to create extension %: %', extension_name, SQLERRM; + END; + END LOOP; +END; +$$; + +CREATE EXTENSION "hstore"; +-- CALL enable_all_extensions(); diff --git a/docker_postgres/rootfs/docker-entrypoint-initdb.d/01-init-db.sh b/docker_postgres/rootfs/docker-entrypoint-initdb.d/01-init-db.sh new file mode 100644 index 0000000..ef39b89 --- /dev/null +++ b/docker_postgres/rootfs/docker-entrypoint-initdb.d/01-init-db.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -Eeo pipefail + +printenv | sort + +ls -alh /usr/share/postgresql/${PG_MAJOR}/extension/*.control + +mkdir -pv ${PGDATA}/conf.d +echo "include_dir='./conf.d'" >> ${PGDATA}/postgresql.conf +sudo mv /opt/utils/pg-ext.conf ${PGDATA}/conf.d/ + +cat ${PGDATA}/conf.d/* +tail ${PGDATA}/postgresql.conf + + +# https://github.com/docker-library/postgres/blob/master/docker-entrypoint.sh +# form: docker-entrypoint.sh +docker_temp_server_stop +docker_temp_server_start + +psql -v ON_ERROR_STOP=0 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL + CALL enable_all_extensions(); + SELECT extname AS name, extversion AS ver FROM pg_extension ORDER BY extname; +EOSQL diff --git a/docker_postgres/rootfs/opt/conda/lib/python3.11/platform.py.bak b/docker_postgres/rootfs/opt/conda/lib/python3.11/platform.py.bak new file mode 100755 index 0000000..1e81143 --- /dev/null +++ b/docker_postgres/rootfs/opt/conda/lib/python3.11/platform.py.bak @@ -0,0 +1,1330 @@ +#!/usr/bin/env python3 + +""" This module tries to retrieve as much platform-identifying data as + possible. It makes this information available via function APIs. + + If called from the command line, it prints the platform + information concatenated as single string to stdout. The output + format is usable as part of a filename. + +""" +# This module is maintained by Marc-Andre Lemburg . +# If you find problems, please submit bug reports/patches via the +# Python bug tracker (http://bugs.python.org) and assign them to "lemburg". +# +# Still needed: +# * support for MS-DOS (PythonDX ?) +# * support for Amiga and other still unsupported platforms running Python +# * support for additional Linux distributions +# +# Many thanks to all those who helped adding platform-specific +# checks (in no particular order): +# +# Charles G Waldman, David Arnold, Gordon McMillan, Ben Darnell, +# Jeff Bauer, Cliff Crawford, Ivan Van Laningham, Josef +# Betancourt, Randall Hopper, Karl Putland, John Farrell, Greg +# Andruk, Just van Rossum, Thomas Heller, Mark R. Levinson, Mark +# Hammond, Bill Tutt, Hans Nowak, Uwe Zessin (OpenVMS support), +# Colin Kong, Trent Mick, Guido van Rossum, Anthony Baxter, Steve +# Dower +# +# History: +# +# +# +# 1.0.8 - changed Windows support to read version from kernel32.dll +# 1.0.7 - added DEV_NULL +# 1.0.6 - added linux_distribution() +# 1.0.5 - fixed Java support to allow running the module on Jython +# 1.0.4 - added IronPython support +# 1.0.3 - added normalization of Windows system name +# 1.0.2 - added more Windows support +# 1.0.1 - reformatted to make doc.py happy +# 1.0.0 - reformatted a bit and checked into Python CVS +# 0.8.0 - added sys.version parser and various new access +# APIs (python_version(), python_compiler(), etc.) +# 0.7.2 - fixed architecture() to use sizeof(pointer) where available +# 0.7.1 - added support for Caldera OpenLinux +# 0.7.0 - some fixes for WinCE; untabified the source file +# 0.6.2 - support for OpenVMS - requires version 1.5.2-V006 or higher and +# vms_lib.getsyi() configured +# 0.6.1 - added code to prevent 'uname -p' on platforms which are +# known not to support it +# 0.6.0 - fixed win32_ver() to hopefully work on Win95,98,NT and Win2k; +# did some cleanup of the interfaces - some APIs have changed +# 0.5.5 - fixed another type in the MacOS code... should have +# used more coffee today ;-) +# 0.5.4 - fixed a few typos in the MacOS code +# 0.5.3 - added experimental MacOS support; added better popen() +# workarounds in _syscmd_ver() -- still not 100% elegant +# though +# 0.5.2 - fixed uname() to return '' instead of 'unknown' in all +# return values (the system uname command tends to return +# 'unknown' instead of just leaving the field empty) +# 0.5.1 - included code for slackware dist; added exception handlers +# to cover up situations where platforms don't have os.popen +# (e.g. Mac) or fail on socket.gethostname(); fixed libc +# detection RE +# 0.5.0 - changed the API names referring to system commands to *syscmd*; +# added java_ver(); made syscmd_ver() a private +# API (was system_ver() in previous versions) -- use uname() +# instead; extended the win32_ver() to also return processor +# type information +# 0.4.0 - added win32_ver() and modified the platform() output for WinXX +# 0.3.4 - fixed a bug in _follow_symlinks() +# 0.3.3 - fixed popen() and "file" command invocation bugs +# 0.3.2 - added architecture() API and support for it in platform() +# 0.3.1 - fixed syscmd_ver() RE to support Windows NT +# 0.3.0 - added system alias support +# 0.2.3 - removed 'wince' again... oh well. +# 0.2.2 - added 'wince' to syscmd_ver() supported platforms +# 0.2.1 - added cache logic and changed the platform string format +# 0.2.0 - changed the API to use functions instead of module globals +# since some action take too long to be run on module import +# 0.1.0 - first release +# +# You can always get the latest version of this module at: +# +# http://www.egenix.com/files/python/platform.py +# +# If that URL should fail, try contacting the author. + +__copyright__ = """ + Copyright (c) 1999-2000, Marc-Andre Lemburg; mailto:mal@lemburg.com + Copyright (c) 2000-2010, eGenix.com Software GmbH; mailto:info@egenix.com + + Permission to use, copy, modify, and distribute this software and its + documentation for any purpose and without fee or royalty is hereby granted, + provided that the above copyright notice appear in all copies and that + both that copyright notice and this permission notice appear in + supporting documentation or portions thereof, including modifications, + that you make. + + EGENIX.COM SOFTWARE GMBH DISCLAIMS ALL WARRANTIES WITH REGARD TO + THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, + INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING + FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + WITH THE USE OR PERFORMANCE OF THIS SOFTWARE ! + +""" + +__version__ = '1.0.8' + +import collections +import os +import re +import sys +import functools +import itertools + +### Globals & Constants + +# Helper for comparing two version number strings. +# Based on the description of the PHP's version_compare(): +# http://php.net/manual/en/function.version-compare.php + +_ver_stages = { + # any string not found in this dict, will get 0 assigned + 'dev': 10, + 'alpha': 20, 'a': 20, + 'beta': 30, 'b': 30, + 'c': 40, + 'RC': 50, 'rc': 50, + # number, will get 100 assigned + 'pl': 200, 'p': 200, +} + +_component_re = re.compile(r'([0-9]+|[._+-])') + +def _comparable_version(version): + result = [] + for v in _component_re.split(version): + if v not in '._+-': + try: + v = int(v, 10) + t = 100 + except ValueError: + t = _ver_stages.get(v, 0) + result.extend((t, v)) + return result + +### Platform specific APIs + +_libc_search = re.compile(b'(__libc_init)' + b'|' + b'(GLIBC_([0-9.]+))' + b'|' + br'(libc(_\w+)?\.so(?:\.(\d[0-9.]*))?)', re.ASCII) + +def libc_ver(executable=None, lib='', version='', chunksize=16384): + + """ Tries to determine the libc version that the file executable + (which defaults to the Python interpreter) is linked against. + + Returns a tuple of strings (lib,version) which default to the + given parameters in case the lookup fails. + + Note that the function has intimate knowledge of how different + libc versions add symbols to the executable and thus is probably + only usable for executables compiled using gcc. + + The file is read and scanned in chunks of chunksize bytes. + + """ + if not executable: + try: + ver = os.confstr('CS_GNU_LIBC_VERSION') + # parse 'glibc 2.28' as ('glibc', '2.28') + parts = ver.split(maxsplit=1) + if len(parts) == 2: + return tuple(parts) + except (AttributeError, ValueError, OSError): + # os.confstr() or CS_GNU_LIBC_VERSION value not available + pass + + executable = sys.executable + + if not executable: + # sys.executable is not set. + return lib, version + + V = _comparable_version + # We use os.path.realpath() + # here to work around problems with Cygwin not being + # able to open symlinks for reading + executable = os.path.realpath(executable) + with open(executable, 'rb') as f: + binary = f.read(chunksize) + pos = 0 + while pos < len(binary): + if b'libc' in binary or b'GLIBC' in binary: + m = _libc_search.search(binary, pos) + else: + m = None + if not m or m.end() == len(binary): + chunk = f.read(chunksize) + if chunk: + binary = binary[max(pos, len(binary) - 1000):] + chunk + pos = 0 + continue + if not m: + break + libcinit, glibc, glibcversion, so, threads, soversion = [ + s.decode('latin1') if s is not None else s + for s in m.groups()] + if libcinit and not lib: + lib = 'libc' + elif glibc: + if lib != 'glibc': + lib = 'glibc' + version = glibcversion + elif V(glibcversion) > V(version): + version = glibcversion + elif so: + if lib != 'glibc': + lib = 'libc' + if soversion and (not version or V(soversion) > V(version)): + version = soversion + if threads and version[-len(threads):] != threads: + version = version + threads + pos = m.end() + return lib, version + +def _norm_version(version, build=''): + + """ Normalize the version and build strings and return a single + version string using the format major.minor.build (or patchlevel). + """ + l = version.split('.') + if build: + l.append(build) + try: + strings = list(map(str, map(int, l))) + except ValueError: + strings = l + version = '.'.join(strings[:3]) + return version + +_ver_output = re.compile(r'(?:([\w ]+) ([\w.]+) ' + r'.*' + r'\[.* ([\d.]+)\])') + +# Examples of VER command output: +# +# Windows 2000: Microsoft Windows 2000 [Version 5.00.2195] +# Windows XP: Microsoft Windows XP [Version 5.1.2600] +# Windows Vista: Microsoft Windows [Version 6.0.6002] +# +# Note that the "Version" string gets localized on different +# Windows versions. + +def _syscmd_ver(system='', release='', version='', + + supported_platforms=('win32', 'win16', 'dos')): + + """ Tries to figure out the OS version used and returns + a tuple (system, release, version). + + It uses the "ver" shell command for this which is known + to exists on Windows, DOS. XXX Others too ? + + In case this fails, the given parameters are used as + defaults. + + """ + if sys.platform not in supported_platforms: + return system, release, version + + # Try some common cmd strings + import subprocess + for cmd in ('ver', 'command /c ver', 'cmd /c ver'): + try: + info = subprocess.check_output(cmd, + stdin=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + text=True, + encoding="locale", + shell=True) + except (OSError, subprocess.CalledProcessError) as why: + #print('Command %s failed: %s' % (cmd, why)) + continue + else: + break + else: + return system, release, version + + # Parse the output + info = info.strip() + m = _ver_output.match(info) + if m is not None: + system, release, version = m.groups() + # Strip trailing dots from version and release + if release[-1] == '.': + release = release[:-1] + if version[-1] == '.': + version = version[:-1] + # Normalize the version and build strings (eliminating additional + # zeros) + version = _norm_version(version) + return system, release, version + +_WIN32_CLIENT_RELEASES = { + (5, 0): "2000", + (5, 1): "XP", + # Strictly, 5.2 client is XP 64-bit, but platform.py historically + # has always called it 2003 Server + (5, 2): "2003Server", + (5, None): "post2003", + + (6, 0): "Vista", + (6, 1): "7", + (6, 2): "8", + (6, 3): "8.1", + (6, None): "post8.1", + + (10, 0): "10", + (10, None): "post10", +} + +# Server release name lookup will default to client names if necessary +_WIN32_SERVER_RELEASES = { + (5, 2): "2003Server", + + (6, 0): "2008Server", + (6, 1): "2008ServerR2", + (6, 2): "2012Server", + (6, 3): "2012ServerR2", + (6, None): "post2012ServerR2", +} + +def win32_is_iot(): + return win32_edition() in ('IoTUAP', 'NanoServer', 'WindowsCoreHeadless', 'IoTEdgeOS') + +def win32_edition(): + try: + try: + import winreg + except ImportError: + import _winreg as winreg + except ImportError: + pass + else: + try: + cvkey = r'SOFTWARE\Microsoft\Windows NT\CurrentVersion' + with winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE, cvkey) as key: + return winreg.QueryValueEx(key, 'EditionId')[0] + except OSError: + pass + + return None + +def win32_ver(release='', version='', csd='', ptype=''): + try: + from sys import getwindowsversion + except ImportError: + return release, version, csd, ptype + + winver = getwindowsversion() + try: + major, minor, build = map(int, _syscmd_ver()[2].split('.')) + except ValueError: + major, minor, build = winver.platform_version or winver[:3] + version = '{0}.{1}.{2}'.format(major, minor, build) + + release = (_WIN32_CLIENT_RELEASES.get((major, minor)) or + _WIN32_CLIENT_RELEASES.get((major, None)) or + release) + + # getwindowsversion() reflect the compatibility mode Python is + # running under, and so the service pack value is only going to be + # valid if the versions match. + if winver[:2] == (major, minor): + try: + csd = 'SP{}'.format(winver.service_pack_major) + except AttributeError: + if csd[:13] == 'Service Pack ': + csd = 'SP' + csd[13:] + + # VER_NT_SERVER = 3 + if getattr(winver, 'product_type', None) == 3: + release = (_WIN32_SERVER_RELEASES.get((major, minor)) or + _WIN32_SERVER_RELEASES.get((major, None)) or + release) + + try: + try: + import winreg + except ImportError: + import _winreg as winreg + except ImportError: + pass + else: + try: + cvkey = r'SOFTWARE\Microsoft\Windows NT\CurrentVersion' + with winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE, cvkey) as key: + ptype = winreg.QueryValueEx(key, 'CurrentType')[0] + except OSError: + pass + + return release, version, csd, ptype + + +def _mac_ver_xml(): + fn = '/System/Library/CoreServices/SystemVersion.plist' + if not os.path.exists(fn): + if 'SDKROOT' in os.environ: + fn = os.environ['SDKROOT'] + fn + if not os.path.exists(fn): + return None + else: + return None + + try: + import plistlib + except ImportError: + return None + + with open(fn, 'rb') as f: + pl = plistlib.load(f) + release = pl['ProductVersion'] + versioninfo = ('', '', '') + machine = os.uname().machine + if machine in ('ppc', 'Power Macintosh'): + # Canonical name + machine = 'PowerPC' + + return release, versioninfo, machine + + +def mac_ver(release='', versioninfo=('', '', ''), machine=''): + + """ Get macOS version information and return it as tuple (release, + versioninfo, machine) with versioninfo being a tuple (version, + dev_stage, non_release_version). + + Entries which cannot be determined are set to the parameter values + which default to ''. All tuple entries are strings. + """ + + # First try reading the information from an XML file which should + # always be present + info = _mac_ver_xml() + if info is not None: + return info + + # If that also doesn't work return the default values + return release, versioninfo, machine + +def _java_getprop(name, default): + + from java.lang import System + try: + value = System.getProperty(name) + if value is None: + return default + return value + except AttributeError: + return default + +def java_ver(release='', vendor='', vminfo=('', '', ''), osinfo=('', '', '')): + + """ Version interface for Jython. + + Returns a tuple (release, vendor, vminfo, osinfo) with vminfo being + a tuple (vm_name, vm_release, vm_vendor) and osinfo being a + tuple (os_name, os_version, os_arch). + + Values which cannot be determined are set to the defaults + given as parameters (which all default to ''). + + """ + # Import the needed APIs + try: + import java.lang + except ImportError: + return release, vendor, vminfo, osinfo + + vendor = _java_getprop('java.vendor', vendor) + release = _java_getprop('java.version', release) + vm_name, vm_release, vm_vendor = vminfo + vm_name = _java_getprop('java.vm.name', vm_name) + vm_vendor = _java_getprop('java.vm.vendor', vm_vendor) + vm_release = _java_getprop('java.vm.version', vm_release) + vminfo = vm_name, vm_release, vm_vendor + os_name, os_version, os_arch = osinfo + os_arch = _java_getprop('java.os.arch', os_arch) + os_name = _java_getprop('java.os.name', os_name) + os_version = _java_getprop('java.os.version', os_version) + osinfo = os_name, os_version, os_arch + + return release, vendor, vminfo, osinfo + +### System name aliasing + +def system_alias(system, release, version): + + """ Returns (system, release, version) aliased to common + marketing names used for some systems. + + It also does some reordering of the information in some cases + where it would otherwise cause confusion. + + """ + if system == 'SunOS': + # Sun's OS + if release < '5': + # These releases use the old name SunOS + return system, release, version + # Modify release (marketing release = SunOS release - 3) + l = release.split('.') + if l: + try: + major = int(l[0]) + except ValueError: + pass + else: + major = major - 3 + l[0] = str(major) + release = '.'.join(l) + if release < '6': + system = 'Solaris' + else: + # XXX Whatever the new SunOS marketing name is... + system = 'Solaris' + + elif system in ('win32', 'win16'): + # In case one of the other tricks + system = 'Windows' + + # bpo-35516: Don't replace Darwin with macOS since input release and + # version arguments can be different than the currently running version. + + return system, release, version + +### Various internal helpers + +def _platform(*args): + + """ Helper to format the platform string in a filename + compatible format e.g. "system-version-machine". + """ + # Format the platform string + platform = '-'.join(x.strip() for x in filter(len, args)) + + # Cleanup some possible filename obstacles... + platform = platform.replace(' ', '_') + platform = platform.replace('/', '-') + platform = platform.replace('\\', '-') + platform = platform.replace(':', '-') + platform = platform.replace(';', '-') + platform = platform.replace('"', '-') + platform = platform.replace('(', '-') + platform = platform.replace(')', '-') + + # No need to report 'unknown' information... + platform = platform.replace('unknown', '') + + # Fold '--'s and remove trailing '-' + while 1: + cleaned = platform.replace('--', '-') + if cleaned == platform: + break + platform = cleaned + while platform[-1] == '-': + platform = platform[:-1] + + return platform + +def _node(default=''): + + """ Helper to determine the node name of this machine. + """ + try: + import socket + except ImportError: + # No sockets... + return default + try: + return socket.gethostname() + except OSError: + # Still not working... + return default + +def _follow_symlinks(filepath): + + """ In case filepath is a symlink, follow it until a + real file is reached. + """ + filepath = os.path.abspath(filepath) + while os.path.islink(filepath): + filepath = os.path.normpath( + os.path.join(os.path.dirname(filepath), os.readlink(filepath))) + return filepath + + +def _syscmd_file(target, default=''): + + """ Interface to the system's file command. + + The function uses the -b option of the file command to have it + omit the filename in its output. Follow the symlinks. It returns + default in case the command should fail. + + """ + if sys.platform in ('dos', 'win32', 'win16'): + # XXX Others too ? + return default + + try: + import subprocess + except ImportError: + return default + target = _follow_symlinks(target) + # "file" output is locale dependent: force the usage of the C locale + # to get deterministic behavior. + env = dict(os.environ, LC_ALL='C') + try: + # -b: do not prepend filenames to output lines (brief mode) + output = subprocess.check_output(['file', '-b', target], + stderr=subprocess.DEVNULL, + env=env) + except (OSError, subprocess.CalledProcessError): + return default + if not output: + return default + # With the C locale, the output should be mostly ASCII-compatible. + # Decode from Latin-1 to prevent Unicode decode error. + return output.decode('latin-1') + +### Information about the used architecture + +# Default values for architecture; non-empty strings override the +# defaults given as parameters +_default_architecture = { + 'win32': ('', 'WindowsPE'), + 'win16': ('', 'Windows'), + 'dos': ('', 'MSDOS'), +} + +def architecture(executable=sys.executable, bits='', linkage=''): + + """ Queries the given executable (defaults to the Python interpreter + binary) for various architecture information. + + Returns a tuple (bits, linkage) which contains information about + the bit architecture and the linkage format used for the + executable. Both values are returned as strings. + + Values that cannot be determined are returned as given by the + parameter presets. If bits is given as '', the sizeof(pointer) + (or sizeof(long) on Python version < 1.5.2) is used as + indicator for the supported pointer size. + + The function relies on the system's "file" command to do the + actual work. This is available on most if not all Unix + platforms. On some non-Unix platforms where the "file" command + does not exist and the executable is set to the Python interpreter + binary defaults from _default_architecture are used. + + """ + # Use the sizeof(pointer) as default number of bits if nothing + # else is given as default. + if not bits: + import struct + size = struct.calcsize('P') + bits = str(size * 8) + 'bit' + + # Get data from the 'file' system command + if executable: + fileout = _syscmd_file(executable, '') + else: + fileout = '' + + if not fileout and \ + executable == sys.executable: + # "file" command did not return anything; we'll try to provide + # some sensible defaults then... + if sys.platform in _default_architecture: + b, l = _default_architecture[sys.platform] + if b: + bits = b + if l: + linkage = l + return bits, linkage + + if 'executable' not in fileout and 'shared object' not in fileout: + # Format not supported + return bits, linkage + + # Bits + if '32-bit' in fileout: + bits = '32bit' + elif '64-bit' in fileout: + bits = '64bit' + + # Linkage + if 'ELF' in fileout: + linkage = 'ELF' + elif 'PE' in fileout: + # E.g. Windows uses this format + if 'Windows' in fileout: + linkage = 'WindowsPE' + else: + linkage = 'PE' + elif 'COFF' in fileout: + linkage = 'COFF' + elif 'MS-DOS' in fileout: + linkage = 'MSDOS' + else: + # XXX the A.OUT format also falls under this class... + pass + + return bits, linkage + + +def _get_machine_win32(): + # Try to use the PROCESSOR_* environment variables + # available on Win XP and later; see + # http://support.microsoft.com/kb/888731 and + # http://www.geocities.com/rick_lively/MANUALS/ENV/MSWIN/PROCESSI.HTM + + # WOW64 processes mask the native architecture + return ( + os.environ.get('PROCESSOR_ARCHITEW6432', '') or + os.environ.get('PROCESSOR_ARCHITECTURE', '') + ) + + +class _Processor: + @classmethod + def get(cls): + func = getattr(cls, f'get_{sys.platform}', cls.from_subprocess) + return func() or '' + + def get_win32(): + return os.environ.get('PROCESSOR_IDENTIFIER', _get_machine_win32()) + + def get_OpenVMS(): + try: + import vms_lib + except ImportError: + pass + else: + csid, cpu_number = vms_lib.getsyi('SYI$_CPU', 0) + return 'Alpha' if cpu_number >= 128 else 'VAX' + + def from_subprocess(): + """ + Fall back to `uname -p` + """ + try: + import subprocess + except ImportError: + return None + try: + return subprocess.check_output( + ['uname', '-p'], + stderr=subprocess.DEVNULL, + text=True, + encoding="utf8", + ).strip() + except (OSError, subprocess.CalledProcessError): + pass + + +def _unknown_as_blank(val): + return '' if val == 'unknown' else val + + +### Portable uname() interface + +class uname_result( + collections.namedtuple( + "uname_result_base", + "system node release version machine") + ): + """ + A uname_result that's largely compatible with a + simple namedtuple except that 'processor' is + resolved late and cached to avoid calling "uname" + except when needed. + """ + + _fields = ('system', 'node', 'release', 'version', 'machine', 'processor') + + @functools.cached_property + def processor(self): + return _unknown_as_blank(_Processor.get()) + + def __iter__(self): + return itertools.chain( + super().__iter__(), + (self.processor,) + ) + + @classmethod + def _make(cls, iterable): + # override factory to affect length check + num_fields = len(cls._fields) - 1 + result = cls.__new__(cls, *iterable) + if len(result) != num_fields + 1: + msg = f'Expected {num_fields} arguments, got {len(result)}' + raise TypeError(msg) + return result + + def __getitem__(self, key): + return tuple(self)[key] + + def __len__(self): + return len(tuple(iter(self))) + + def __reduce__(self): + return uname_result, tuple(self)[:len(self._fields) - 1] + + +_uname_cache = None + + +def uname(): + + """ Fairly portable uname interface. Returns a tuple + of strings (system, node, release, version, machine, processor) + identifying the underlying platform. + + Note that unlike the os.uname function this also returns + possible processor information as an additional tuple entry. + + Entries which cannot be determined are set to ''. + + """ + global _uname_cache + + if _uname_cache is not None: + return _uname_cache + + # Get some infos from the builtin os.uname API... + try: + system, node, release, version, machine = infos = os.uname() + except AttributeError: + system = sys.platform + node = _node() + release = version = machine = '' + infos = () + + if not any(infos): + # uname is not available + + # Try win32_ver() on win32 platforms + if system == 'win32': + release, version, csd, ptype = win32_ver() + machine = machine or _get_machine_win32() + + # Try the 'ver' system command available on some + # platforms + if not (release and version): + system, release, version = _syscmd_ver(system) + # Normalize system to what win32_ver() normally returns + # (_syscmd_ver() tends to return the vendor name as well) + if system == 'Microsoft Windows': + system = 'Windows' + elif system == 'Microsoft' and release == 'Windows': + # Under Windows Vista and Windows Server 2008, + # Microsoft changed the output of the ver command. The + # release is no longer printed. This causes the + # system and release to be misidentified. + system = 'Windows' + if '6.0' == version[:3]: + release = 'Vista' + else: + release = '' + + # In case we still don't know anything useful, we'll try to + # help ourselves + if system in ('win32', 'win16'): + if not version: + if system == 'win32': + version = '32bit' + else: + version = '16bit' + system = 'Windows' + + elif system[:4] == 'java': + release, vendor, vminfo, osinfo = java_ver() + system = 'Java' + version = ', '.join(vminfo) + if not version: + version = vendor + + # System specific extensions + if system == 'OpenVMS': + # OpenVMS seems to have release and version mixed up + if not release or release == '0': + release = version + version = '' + + # normalize name + if system == 'Microsoft' and release == 'Windows': + system = 'Windows' + release = 'Vista' + + vals = system, node, release, version, machine + # Replace 'unknown' values with the more portable '' + _uname_cache = uname_result(*map(_unknown_as_blank, vals)) + return _uname_cache + +### Direct interfaces to some of the uname() return values + +def system(): + + """ Returns the system/OS name, e.g. 'Linux', 'Windows' or 'Java'. + + An empty string is returned if the value cannot be determined. + + """ + return uname().system + +def node(): + + """ Returns the computer's network name (which may not be fully + qualified) + + An empty string is returned if the value cannot be determined. + + """ + return uname().node + +def release(): + + """ Returns the system's release, e.g. '2.2.0' or 'NT' + + An empty string is returned if the value cannot be determined. + + """ + return uname().release + +def version(): + + """ Returns the system's release version, e.g. '#3 on degas' + + An empty string is returned if the value cannot be determined. + + """ + return uname().version + +def machine(): + + """ Returns the machine type, e.g. 'i386' + + An empty string is returned if the value cannot be determined. + + """ + return uname().machine + +def processor(): + + """ Returns the (true) processor name, e.g. 'amdk6' + + An empty string is returned if the value cannot be + determined. Note that many platforms do not provide this + information or simply return the same value as for machine(), + e.g. NetBSD does this. + + """ + return uname().processor + +### Various APIs for extracting information from sys.version + +_sys_version_parser = re.compile( + r'([\w.+]+)\s*(?:\ \|\ packaged\ by\ conda\-forge\ \|)?\s*' + r'\(#?([^,]+)' # "(#buildno" + r'(?:,\s*([\w ]*)' # ", builddate" + r'(?:,\s*([\w :]*))?)?\)\s*' # ", buildtime)" + r'\[([^\]]+)\]?', re.ASCII) # "[compiler]" + +_ironpython_sys_version_parser = re.compile( + r'IronPython\s*' + r'([\d\.]+)' + r'(?: \(([\d\.]+)\))?' + r' on (.NET [\d\.]+)', re.ASCII) + +# IronPython covering 2.6 and 2.7 +_ironpython26_sys_version_parser = re.compile( + r'([\d.]+)\s*' + r'\(IronPython\s*' + r'[\d.]+\s*' + r'\(([\d.]+)\) on ([\w.]+ [\d.]+(?: \(\d+-bit\))?)\)' +) + +_pypy_sys_version_parser = re.compile( + r'([\w.+]+)\s*' + r'\(#?([^,]+),\s*([\w ]+),\s*([\w :]+)\)\s*' + r'\[PyPy [^\]]+\]?') + +_sys_version_cache = {} + +def _sys_version(sys_version=None): + + """ Returns a parsed version of Python's sys.version as tuple + (name, version, branch, revision, buildno, builddate, compiler) + referring to the Python implementation name, version, branch, + revision, build number, build date/time as string and the compiler + identification string. + + Note that unlike the Python sys.version, the returned value + for the Python version will always include the patchlevel (it + defaults to '.0'). + + The function returns empty strings for tuple entries that + cannot be determined. + + sys_version may be given to parse an alternative version + string, e.g. if the version was read from a different Python + interpreter. + + """ + # Get the Python version + if sys_version is None: + sys_version = sys.version + + # Try the cache first + result = _sys_version_cache.get(sys_version, None) + if result is not None: + return result + + # Parse it + if 'IronPython' in sys_version: + # IronPython + name = 'IronPython' + if sys_version.startswith('IronPython'): + match = _ironpython_sys_version_parser.match(sys_version) + else: + match = _ironpython26_sys_version_parser.match(sys_version) + + if match is None: + raise ValueError( + 'failed to parse IronPython sys.version: %s' % + repr(sys_version)) + + version, alt_version, compiler = match.groups() + buildno = '' + builddate = '' + + elif sys.platform.startswith('java'): + # Jython + name = 'Jython' + match = _sys_version_parser.match(sys_version) + if match is None: + raise ValueError( + 'failed to parse Jython sys.version: %s' % + repr(sys_version)) + version, buildno, builddate, buildtime, _ = match.groups() + if builddate is None: + builddate = '' + compiler = sys.platform + + elif "PyPy" in sys_version: + # PyPy + name = "PyPy" + match = _pypy_sys_version_parser.match(sys_version) + if match is None: + raise ValueError("failed to parse PyPy sys.version: %s" % + repr(sys_version)) + version, buildno, builddate, buildtime = match.groups() + compiler = "" + + else: + # CPython + match = _sys_version_parser.match(sys_version) + if match is None: + raise ValueError( + 'failed to parse CPython sys.version: %s' % + repr(sys_version)) + version, buildno, builddate, buildtime, compiler = \ + match.groups() + name = 'CPython' + if builddate is None: + builddate = '' + elif buildtime: + builddate = builddate + ' ' + buildtime + + if hasattr(sys, '_git'): + _, branch, revision = sys._git + elif hasattr(sys, '_mercurial'): + _, branch, revision = sys._mercurial + else: + branch = '' + revision = '' + + # Add the patchlevel version if missing + l = version.split('.') + if len(l) == 2: + l.append('0') + version = '.'.join(l) + + # Build and cache the result + result = (name, version, branch, revision, buildno, builddate, compiler) + _sys_version_cache[sys_version] = result + return result + +def python_implementation(): + + """ Returns a string identifying the Python implementation. + + Currently, the following implementations are identified: + 'CPython' (C implementation of Python), + 'IronPython' (.NET implementation of Python), + 'Jython' (Java implementation of Python), + 'PyPy' (Python implementation of Python). + + """ + return _sys_version()[0] + +def python_version(): + + """ Returns the Python version as string 'major.minor.patchlevel' + + Note that unlike the Python sys.version, the returned value + will always include the patchlevel (it defaults to 0). + + """ + return _sys_version()[1] + +def python_version_tuple(): + + """ Returns the Python version as tuple (major, minor, patchlevel) + of strings. + + Note that unlike the Python sys.version, the returned value + will always include the patchlevel (it defaults to 0). + + """ + return tuple(_sys_version()[1].split('.')) + +def python_branch(): + + """ Returns a string identifying the Python implementation + branch. + + For CPython this is the SCM branch from which the + Python binary was built. + + If not available, an empty string is returned. + + """ + + return _sys_version()[2] + +def python_revision(): + + """ Returns a string identifying the Python implementation + revision. + + For CPython this is the SCM revision from which the + Python binary was built. + + If not available, an empty string is returned. + + """ + return _sys_version()[3] + +def python_build(): + + """ Returns a tuple (buildno, builddate) stating the Python + build number and date as strings. + + """ + return _sys_version()[4:6] + +def python_compiler(): + + """ Returns a string identifying the compiler used for compiling + Python. + + """ + return _sys_version()[6] + +### The Opus Magnum of platform strings :-) + +_platform_cache = {} + +def platform(aliased=0, terse=0): + + """ Returns a single string identifying the underlying platform + with as much useful information as possible (but no more :). + + The output is intended to be human readable rather than + machine parseable. It may look different on different + platforms and this is intended. + + If "aliased" is true, the function will use aliases for + various platforms that report system names which differ from + their common names, e.g. SunOS will be reported as + Solaris. The system_alias() function is used to implement + this. + + Setting terse to true causes the function to return only the + absolute minimum information needed to identify the platform. + + """ + result = _platform_cache.get((aliased, terse), None) + if result is not None: + return result + + # Get uname information and then apply platform specific cosmetics + # to it... + system, node, release, version, machine, processor = uname() + if machine == processor: + processor = '' + if aliased: + system, release, version = system_alias(system, release, version) + + if system == 'Darwin': + # macOS (darwin kernel) + macos_release = mac_ver()[0] + if macos_release: + system = 'macOS' + release = macos_release + + if system == 'Windows': + # MS platforms + rel, vers, csd, ptype = win32_ver(version) + if terse: + platform = _platform(system, release) + else: + platform = _platform(system, release, version, csd) + + elif system in ('Linux',): + # check for libc vs. glibc + libcname, libcversion = libc_ver() + platform = _platform(system, release, machine, processor, + 'with', + libcname+libcversion) + elif system == 'Java': + # Java platforms + r, v, vminfo, (os_name, os_version, os_arch) = java_ver() + if terse or not os_name: + platform = _platform(system, release, version) + else: + platform = _platform(system, release, version, + 'on', + os_name, os_version, os_arch) + + else: + # Generic handler + if terse: + platform = _platform(system, release) + else: + bits, linkage = architecture(sys.executable) + platform = _platform(system, release, machine, + processor, bits, linkage) + + _platform_cache[(aliased, terse)] = platform + return platform + +### freedesktop.org os-release standard +# https://www.freedesktop.org/software/systemd/man/os-release.html + +# NAME=value with optional quotes (' or "). The regular expression is less +# strict than shell lexer, but that's ok. +_os_release_line = re.compile( + "^(?P[a-zA-Z0-9_]+)=(?P[\"\']?)(?P.*)(?P=quote)$" +) +# unescape five special characters mentioned in the standard +_os_release_unescape = re.compile(r"\\([\\\$\"\'`])") +# /etc takes precedence over /usr/lib +_os_release_candidates = ("/etc/os-release", "/usr/lib/os-release") +_os_release_cache = None + + +def _parse_os_release(lines): + # These fields are mandatory fields with well-known defaults + # in practice all Linux distributions override NAME, ID, and PRETTY_NAME. + info = { + "NAME": "Linux", + "ID": "linux", + "PRETTY_NAME": "Linux", + } + + for line in lines: + mo = _os_release_line.match(line) + if mo is not None: + info[mo.group('name')] = _os_release_unescape.sub( + r"\1", mo.group('value') + ) + + return info + + +def freedesktop_os_release(): + """Return operation system identification from freedesktop.org os-release + """ + global _os_release_cache + + if _os_release_cache is None: + errno = None + for candidate in _os_release_candidates: + try: + with open(candidate, encoding="utf-8") as f: + _os_release_cache = _parse_os_release(f) + break + except OSError as e: + errno = e.errno + else: + raise OSError( + errno, + f"Unable to read files {', '.join(_os_release_candidates)}" + ) + + return _os_release_cache.copy() + + +### Command line interface + +if __name__ == '__main__': + # Default is to print the aliased verbose platform string + terse = ('terse' in sys.argv or '--terse' in sys.argv) + aliased = (not 'nonaliased' in sys.argv and not '--nonaliased' in sys.argv) + print(platform(aliased, terse)) + sys.exit(0) diff --git a/docker_postgres/rootfs/opt/utils/install_list_pgext.tpl.apt b/docker_postgres/rootfs/opt/utils/install_list_pgext.tpl.apt index 05040d2..9de6b8f 100644 --- a/docker_postgres/rootfs/opt/utils/install_list_pgext.tpl.apt +++ b/docker_postgres/rootfs/opt/utils/install_list_pgext.tpl.apt @@ -1,12 +1,18 @@ +% these extensions requries to be listed in shared_preload_libraries +postgresql-${PG_MAJOR}-citus-12.1 +timescaledb-2-postgresql-${PG_MAJOR} +postgresql-${PG_MAJOR}-pgvector +pg-net % https://github.com/supabase/pg_net +postgresql-${PG_MAJOR}-squeeze +postgresql-${PG_MAJOR}-pgaudit +postgresql-${PG_MAJOR}-pg-qualstats +postgresql-${PG_MAJOR}-auto-failover + +% the following extensions does NOT requires to be listed in shared_preload_libraries postgresql-contrib postgresql-${PG_MAJOR}-postgis* -postgresql-${PG_MAJOR}-pgvector postgresql-${PG_MAJOR}-cron postgresql-${PG_MAJOR}-wal2json -timescaledb-2-postgresql-${PG_MAJOR} -postgresql-${PG_MAJOR}-citus-12.1 -pg-graphql % https://github.com/supabase/pg_graphql -pg-net % https://github.com/supabase/pg_net postgresql-${PG_MAJOR}-dirtyread postgresql-${PG_MAJOR}-extra-window-functions postgresql-${PG_MAJOR}-first-last-agg @@ -22,11 +28,9 @@ postgresql-${PG_MAJOR}-plproxy postgresql-${PG_MAJOR}-prefix postgresql-${PG_MAJOR}-rational postgresql-${PG_MAJOR}-rdkit -postgresql-${PG_MAJOR}-pg-qualstats postgresql-${PG_MAJOR}-pg-stat-kcache postgresql-${PG_MAJOR}-pg-wait-sampling postgresql-${PG_MAJOR}-pgfincore -postgresql-${PG_MAJOR}-pgaudit postgresql-${PG_MAJOR}-pgpool2 postgresql-${PG_MAJOR}-pgrouting postgresql-${PG_MAJOR}-pgrouting-doc @@ -57,12 +61,11 @@ postgresql-${PG_MAJOR}-mimeo postgresql-${PG_MAJOR}-pgmp postgresql-${PG_MAJOR}-preprepare postgresql-${PG_MAJOR}-prioritize -postgresql-${PG_MAJOR}-squeeze postgresql-${PG_MAJOR}-toastinfo postgresql-${PG_MAJOR}-unit -postgresql-${PG_MAJOR}-auto-failover -pg-auto-failover-cli postgresql-plpython3-${PG_MAJOR} +pg-auto-failover-cli +pg-graphql % https://github.com/supabase/pg_graphql pgagroal pgpool2 pgbouncer diff --git a/docker_postgres/rootfs/opt/utils/pg-ext.conf b/docker_postgres/rootfs/opt/utils/pg-ext.conf new file mode 100644 index 0000000..61cd815 --- /dev/null +++ b/docker_postgres/rootfs/opt/utils/pg-ext.conf @@ -0,0 +1 @@ +shared_preload_libraries = 'citus,timescaledb,vector,pg_net,pg_squeeze,pgaudit,pg_qualstats,pgautofailover' diff --git a/docker_postgres/rootfs/opt/utils/script-setup-pg_ext.sh b/docker_postgres/rootfs/opt/utils/script-setup-pg_ext.sh index 4811d82..7329f20 100644 --- a/docker_postgres/rootfs/opt/utils/script-setup-pg_ext.sh +++ b/docker_postgres/rootfs/opt/utils/script-setup-pg_ext.sh @@ -1,11 +1,27 @@ +echo "To install PG extensions: $(cat /opt/utils/install_list_pgext.apt)" +install_apt /opt/utils/install_list_pgext.apt + +# Fix pgagent for PG 15 +rm -rf /usr/share/postgresql/15/extension/pgagent* +mv /usr/share/postgresql/16/extension/pgagent* /usr/share/postgresql/15/extension/ + +## remove un-used PG versions and extensions +find /usr/lib/postgresql -mindepth 1 -maxdepth 1 -type d -not -name "${PG_MAJOR}" -not -name "lib" -exec rm -rf {} \; +find /usr/share/postgresql -mindepth 1 -maxdepth 1 -type d -not -name "${PG_MAJOR}" -exec rm -rf {} \; + export USE_PGXS=1 setup_apache_age() { cd /tmp - git clone --depth 1 -b PG15 https://github.com/apache/age + git clone --depth 1 -b PG${PG_MAJOR} https://github.com/apache/age cd /tmp/age + apt-get -qq install -yq --no-install-recommends flex bison postgresql-server-dev-${PG_MAJOR} make -j8 && make install } +setup_apache_age + +# required to build some extensions +apt-get remove -y postgresql-server-dev-${PG_MAJOR} -# setup_apache_age +ls -alh /usr/share/postgresql/*/extension/*.control | sort