diff --git a/ansible/files/postgresql_extension_custom_scripts/pgmq/after-create.sql b/ansible/files/postgresql_extension_custom_scripts/pgmq/after-create.sql index 050e07dfc..f625c9fb3 100644 --- a/ansible/files/postgresql_extension_custom_scripts/pgmq/after-create.sql +++ b/ansible/files/postgresql_extension_custom_scripts/pgmq/after-create.sql @@ -18,8 +18,8 @@ begin physical backups everywhere */ -- Detach and delete the official function -alter extension pgmq drop function pgmq.drop_queue; -drop function pgmq.drop_queue; +alter extension pgmq drop function pgmq.drop_queue(TEXT); +drop function pgmq.drop_queue(TEXT); -- Create and reattach the patched function CREATE FUNCTION pgmq.drop_queue(queue_name TEXT) @@ -134,7 +134,7 @@ BEGIN END; $func$ LANGUAGE plpgsql; -alter extension pgmq add function pgmq.drop_queue; +alter extension pgmq add function pgmq.drop_queue(TEXT); update pg_extension set extowner = 'postgres'::regrole where extname = 'pgmq'; diff --git a/ansible/vars.yml b/ansible/vars.yml index b05651fd3..55c1300e4 100644 --- a/ansible/vars.yml +++ b/ansible/vars.yml @@ -10,9 +10,9 @@ postgres_major: # Full version strings for each major version postgres_release: - postgresorioledb-17: 17.5.1.036-orioledb - postgres17: 17.6.1.015 - postgres15: 15.14.1.015 + postgresorioledb-17: 17.5.1.037-orioledb + postgres17: 17.6.1.016 + postgres15: 15.14.1.016 # Non Postgres Extensions pgbouncer_release: 1.19.0 diff --git a/nix/ext/pgmq.nix b/nix/ext/pgmq.nix index e718c1d02..13cc987b0 100644 --- a/nix/ext/pgmq.nix +++ b/nix/ext/pgmq.nix @@ -3,36 +3,88 @@ stdenv, fetchFromGitHub, postgresql, + buildEnv, }: - -stdenv.mkDerivation rec { +let pname = "pgmq"; - version = "1.4.4"; - buildInputs = [ postgresql ]; - src = fetchFromGitHub { - owner = "tembo-io"; - repo = pname; - rev = "v${version}"; - hash = "sha256-z+8/BqIlHwlMnuIzMz6eylmYbSmhtsNt7TJf/CxbdVw="; - }; - buildPhase = '' - cd pgmq-extension - ''; + # Load version configuration from external file + allVersions = (builtins.fromJSON (builtins.readFile ./versions.json)).${pname}; + + # Filter versions compatible with current PostgreSQL version + supportedVersions = lib.filterAttrs ( + _: value: builtins.elem (lib.versions.major postgresql.version) value.postgresql + ) allVersions; + + # Derived version information + versions = lib.naturalSort (lib.attrNames supportedVersions); + latestVersion = lib.last versions; + numberOfVersions = builtins.length versions; + packages = builtins.attrValues ( + lib.mapAttrs (name: value: build name value.hash) supportedVersions + ); + + # Build function for individual versions + build = + version: hash: + stdenv.mkDerivation rec { + inherit pname version; + buildInputs = [ postgresql ]; + src = fetchFromGitHub { + owner = "tembo-io"; + repo = pname; + rev = "v${version}"; + inherit hash; + }; + + buildPhase = '' + cd pgmq-extension + ''; + + installPhase = '' + runHook preInstall + + mkdir -p $out/share/postgresql/extension + + # Create versioned sql install script + cp sql/${pname}.sql $out/share/postgresql/extension/${pname}--${version}.sql + + # Create versioned control file with modified module path + sed -e "/^default_version =/d" \ + -e "s|^module_pathname = .*|module_pathname = '\$libdir/${pname}'|" \ + ${pname}.control > $out/share/postgresql/extension/${pname}--${version}.control + + # For the latest version, create default control file and symlink and copy SQL upgrade scripts + if [[ "${version}" == "${latestVersion}" ]]; then + { + echo "default_version = '${version}'" + cat $out/share/postgresql/extension/${pname}--${version}.control + } > $out/share/postgresql/extension/${pname}.control + cp sql/*.sql $out/share/postgresql/extension + fi + + runHook postInstall + ''; - installPhase = '' - mkdir -p $out/{lib,share/postgresql/extension} + meta = with lib; { + description = "A lightweight message queue. Like AWS SQS and RSMQ but on Postgres."; + homepage = "https://github.com/tembo-io/pgmq"; + maintainers = with maintainers; [ olirice ]; + inherit (postgresql.meta) platforms; + license = licenses.postgresql; + }; + }; +in +buildEnv { + name = pname; + paths = packages; - mv sql/pgmq.sql $out/share/postgresql/extension/pgmq--${version}.sql - cp sql/*.sql $out/share/postgresql/extension - cp *.control $out/share/postgresql/extension - ''; + pathsToLink = [ "/share/postgresql/extension" ]; - meta = with lib; { - description = "A lightweight message queue. Like AWS SQS and RSMQ but on Postgres."; - homepage = "https://github.com/tembo-io/pgmq"; - maintainers = with maintainers; [ olirice ]; - platforms = postgresql.meta.platforms; - license = licenses.postgresql; + passthru = { + inherit versions numberOfVersions; + pname = "${pname}-all"; + version = + "multi-" + lib.concatStringsSep "-" (map (v: lib.replaceStrings [ "." ] [ "-" ] v) versions); }; } diff --git a/nix/ext/tests/default.nix b/nix/ext/tests/default.nix index 346f480bb..cac49a1a5 100644 --- a/nix/ext/tests/default.nix +++ b/nix/ext/tests/default.nix @@ -187,6 +187,7 @@ builtins.listToAttrs ( "pg_cron" "pg_graphql" "pg_net" + "pgmq" "vector" "wrappers" ] diff --git a/nix/ext/versions.json b/nix/ext/versions.json index 3068b857b..dfedda4aa 100644 --- a/nix/ext/versions.json +++ b/nix/ext/versions.json @@ -277,6 +277,21 @@ ], "hash": "sha256-Cpi2iASi1QJoED0Qs1dANqg/BNZTsz5S+pw8iYyW03Y=" } + }, + "pgmq": { + "1.4.4": { + "postgresql": [ + "15" + ], + "hash": "sha256-z+8/BqIlHwlMnuIzMz6eylmYbSmhtsNt7TJf/CxbdVw=" + }, + "1.5.1": { + "postgresql": [ + "15", + "17" + ], + "hash": "sha256-IU+i6ONPwtgsFKdzya6E+222ualR66gkbb0lDr+7Rb8=" + } }, "pgrouting": { "3.4.1": { @@ -412,7 +427,7 @@ "hash": "sha256-JsZV+I4eRMypXTjGmjCtMBXDVpqTIPHQa28ogXncE/Q=" } }, - "wrappers": { + "wrappers": { "0.5.4": { "postgresql": [ "15", diff --git a/nix/tests/expected/pgmq.out b/nix/tests/expected/pgmq.out index bce379fc7..c2d5d3eec 100644 --- a/nix/tests/expected/pgmq.out +++ b/nix/tests/expected/pgmq.out @@ -160,6 +160,7 @@ order by -------------+-------------------------------+---------- pgmq | _belongs_to_pgmq | postgres pgmq | _ensure_pg_partman_installed | postgres + pgmq | _extension_exists | postgres pgmq | _get_partition_col | postgres pgmq | _get_pg_partman_major_version | postgres pgmq | _get_pg_partman_schema | postgres @@ -174,6 +175,7 @@ order by pgmq | delete | postgres pgmq | detach_archive | postgres pgmq | drop_queue | postgres + pgmq | drop_queue | postgres pgmq | format_table_name | postgres pgmq | list_queues | postgres pgmq | metrics | postgres @@ -183,8 +185,18 @@ order by pgmq | read | postgres pgmq | read_with_poll | postgres pgmq | send | postgres + pgmq | send | postgres + pgmq | send | postgres + pgmq | send | postgres + pgmq | send | postgres + pgmq | send | postgres + pgmq | send_batch | postgres + pgmq | send_batch | postgres + pgmq | send_batch | postgres + pgmq | send_batch | postgres + pgmq | send_batch | postgres pgmq | send_batch | postgres pgmq | set_vt | postgres pgmq | validate_queue_name | postgres -(28 rows) +(40 rows) diff --git a/nix/tests/expected/z_15_ext_interface.out b/nix/tests/expected/z_15_ext_interface.out index d3d9f7c4f..a0db07837 100644 --- a/nix/tests/expected/z_15_ext_interface.out +++ b/nix/tests/expected/z_15_ext_interface.out @@ -1320,6 +1320,7 @@ order by pgcrypto | extensions | pgp_sym_encrypt_bytea | bytea, text, text | bytea pgmq | pgmq | _belongs_to_pgmq | table_name text | boolean pgmq | pgmq | _ensure_pg_partman_installed | | void + pgmq | pgmq | _extension_exists | extension_name text | boolean pgmq | pgmq | _get_partition_col | partition_interval text | text pgmq | pgmq | _get_pg_partman_major_version | | integer pgmq | pgmq | _get_pg_partman_schema | | text @@ -1333,6 +1334,7 @@ order by pgmq | pgmq | delete | queue_name text, msg_id bigint | boolean pgmq | pgmq | delete | queue_name text, msg_ids bigint[] | SETOF bigint pgmq | pgmq | detach_archive | queue_name text | void + pgmq | pgmq | drop_queue | queue_name text, partitioned boolean | boolean pgmq | pgmq | drop_queue | queue_name text | boolean pgmq | pgmq | format_table_name | queue_name text, prefix text | text pgmq | pgmq | list_queues | | SETOF pgmq.queue_record @@ -1340,9 +1342,19 @@ order by pgmq | pgmq | metrics_all | | SETOF pgmq.metrics_result pgmq | pgmq | pop | queue_name text | SETOF pgmq.message_record pgmq | pgmq | purge_queue | queue_name text | bigint - pgmq | pgmq | read | queue_name text, vt integer, qty integer | SETOF pgmq.message_record - pgmq | pgmq | read_with_poll | queue_name text, vt integer, qty integer, max_poll_seconds integer, poll_interval_ms integer | SETOF pgmq.message_record + pgmq | pgmq | read | queue_name text, vt integer, qty integer, conditional jsonb | SETOF pgmq.message_record + pgmq | pgmq | read_with_poll | queue_name text, vt integer, qty integer, max_poll_seconds integer, poll_interval_ms integer, conditional jsonb | SETOF pgmq.message_record + pgmq | pgmq | send | queue_name text, msg jsonb, headers jsonb | SETOF bigint pgmq | pgmq | send | queue_name text, msg jsonb, delay integer | SETOF bigint + pgmq | pgmq | send | queue_name text, msg jsonb, headers jsonb, delay timestamp with time zone | SETOF bigint + pgmq | pgmq | send | queue_name text, msg jsonb, headers jsonb, delay integer | SETOF bigint + pgmq | pgmq | send | queue_name text, msg jsonb | SETOF bigint + pgmq | pgmq | send | queue_name text, msg jsonb, delay timestamp with time zone | SETOF bigint + pgmq | pgmq | send_batch | queue_name text, msgs jsonb[], headers jsonb[] | SETOF bigint + pgmq | pgmq | send_batch | queue_name text, msgs jsonb[], headers jsonb[], delay timestamp with time zone | SETOF bigint + pgmq | pgmq | send_batch | queue_name text, msgs jsonb[], headers jsonb[], delay integer | SETOF bigint + pgmq | pgmq | send_batch | queue_name text, msgs jsonb[] | SETOF bigint + pgmq | pgmq | send_batch | queue_name text, msgs jsonb[], delay timestamp with time zone | SETOF bigint pgmq | pgmq | send_batch | queue_name text, msgs jsonb[], delay integer | SETOF bigint pgmq | pgmq | set_vt | queue_name text, msg_id bigint, vt integer | SETOF pgmq.message_record pgmq | pgmq | validate_queue_name | queue_name text | void @@ -5229,7 +5241,7 @@ order by xml2 | public | xpath_table | text, text, text, text, text | SETOF record xml2 | public | xslt_process | text, text | text xml2 | public | xslt_process | text, text, text | text -(5059 rows) +(5071 rows) /* @@ -5454,6 +5466,7 @@ order by pg_tle | pgtle | feature_info | schema_name pgmq | pgmq | a_foo | archived_at pgmq | pgmq | a_foo | enqueued_at + pgmq | pgmq | a_foo | headers pgmq | pgmq | a_foo | message pgmq | pgmq | a_foo | msg_id pgmq | pgmq | a_foo | read_ct @@ -5463,6 +5476,7 @@ order by pgmq | pgmq | meta | is_unlogged pgmq | pgmq | meta | queue_name pgmq | pgmq | q_foo | enqueued_at + pgmq | pgmq | q_foo | headers pgmq | pgmq | q_foo | message pgmq | pgmq | q_foo | msg_id pgmq | pgmq | q_foo | read_ct @@ -6369,5 +6383,5 @@ order by wrappers | public | wrappers_fdw_stats | rows_in wrappers | public | wrappers_fdw_stats | rows_out wrappers | public | wrappers_fdw_stats | updated_at -(1106 rows) +(1108 rows) diff --git a/nix/tests/expected/z_17_ext_interface.out b/nix/tests/expected/z_17_ext_interface.out index 46792e48f..6a7b4a16c 100644 --- a/nix/tests/expected/z_17_ext_interface.out +++ b/nix/tests/expected/z_17_ext_interface.out @@ -1305,6 +1305,7 @@ order by pgcrypto | extensions | pgp_sym_encrypt_bytea | bytea, text, text | bytea pgmq | pgmq | _belongs_to_pgmq | table_name text | boolean pgmq | pgmq | _ensure_pg_partman_installed | | void + pgmq | pgmq | _extension_exists | extension_name text | boolean pgmq | pgmq | _get_partition_col | partition_interval text | text pgmq | pgmq | _get_pg_partman_major_version | | integer pgmq | pgmq | _get_pg_partman_schema | | text @@ -1318,6 +1319,7 @@ order by pgmq | pgmq | delete | queue_name text, msg_id bigint | boolean pgmq | pgmq | delete | queue_name text, msg_ids bigint[] | SETOF bigint pgmq | pgmq | detach_archive | queue_name text | void + pgmq | pgmq | drop_queue | queue_name text, partitioned boolean | boolean pgmq | pgmq | drop_queue | queue_name text | boolean pgmq | pgmq | format_table_name | queue_name text, prefix text | text pgmq | pgmq | list_queues | | SETOF pgmq.queue_record @@ -1325,9 +1327,19 @@ order by pgmq | pgmq | metrics_all | | SETOF pgmq.metrics_result pgmq | pgmq | pop | queue_name text | SETOF pgmq.message_record pgmq | pgmq | purge_queue | queue_name text | bigint - pgmq | pgmq | read | queue_name text, vt integer, qty integer | SETOF pgmq.message_record - pgmq | pgmq | read_with_poll | queue_name text, vt integer, qty integer, max_poll_seconds integer, poll_interval_ms integer | SETOF pgmq.message_record + pgmq | pgmq | read | queue_name text, vt integer, qty integer, conditional jsonb | SETOF pgmq.message_record + pgmq | pgmq | read_with_poll | queue_name text, vt integer, qty integer, max_poll_seconds integer, poll_interval_ms integer, conditional jsonb | SETOF pgmq.message_record + pgmq | pgmq | send | queue_name text, msg jsonb, headers jsonb | SETOF bigint pgmq | pgmq | send | queue_name text, msg jsonb, delay integer | SETOF bigint + pgmq | pgmq | send | queue_name text, msg jsonb, headers jsonb, delay timestamp with time zone | SETOF bigint + pgmq | pgmq | send | queue_name text, msg jsonb, headers jsonb, delay integer | SETOF bigint + pgmq | pgmq | send | queue_name text, msg jsonb | SETOF bigint + pgmq | pgmq | send | queue_name text, msg jsonb, delay timestamp with time zone | SETOF bigint + pgmq | pgmq | send_batch | queue_name text, msgs jsonb[], headers jsonb[] | SETOF bigint + pgmq | pgmq | send_batch | queue_name text, msgs jsonb[], headers jsonb[], delay timestamp with time zone | SETOF bigint + pgmq | pgmq | send_batch | queue_name text, msgs jsonb[], headers jsonb[], delay integer | SETOF bigint + pgmq | pgmq | send_batch | queue_name text, msgs jsonb[] | SETOF bigint + pgmq | pgmq | send_batch | queue_name text, msgs jsonb[], delay timestamp with time zone | SETOF bigint pgmq | pgmq | send_batch | queue_name text, msgs jsonb[], delay integer | SETOF bigint pgmq | pgmq | set_vt | queue_name text, msg_id bigint, vt integer | SETOF pgmq.message_record pgmq | pgmq | validate_queue_name | queue_name text | void @@ -4873,7 +4885,7 @@ order by xml2 | public | xpath_table | text, text, text, text, text | SETOF record xml2 | public | xslt_process | text, text | text xml2 | public | xslt_process | text, text, text | text -(4716 rows) +(4728 rows) /* @@ -5110,6 +5122,7 @@ order by pg_tle | pgtle | feature_info | schema_name pgmq | pgmq | a_foo | archived_at pgmq | pgmq | a_foo | enqueued_at + pgmq | pgmq | a_foo | headers pgmq | pgmq | a_foo | message pgmq | pgmq | a_foo | msg_id pgmq | pgmq | a_foo | read_ct @@ -5119,6 +5132,7 @@ order by pgmq | pgmq | meta | is_unlogged pgmq | pgmq | meta | queue_name pgmq | pgmq | q_foo | enqueued_at + pgmq | pgmq | q_foo | headers pgmq | pgmq | q_foo | message pgmq | pgmq | q_foo | msg_id pgmq | pgmq | q_foo | read_ct @@ -5294,5 +5308,5 @@ order by wrappers | public | wrappers_fdw_stats | rows_in wrappers | public | wrappers_fdw_stats | rows_out wrappers | public | wrappers_fdw_stats | updated_at -(387 rows) +(389 rows) diff --git a/nix/tests/expected/z_orioledb-17_ext_interface.out b/nix/tests/expected/z_orioledb-17_ext_interface.out index 46792e48f..6a7b4a16c 100644 --- a/nix/tests/expected/z_orioledb-17_ext_interface.out +++ b/nix/tests/expected/z_orioledb-17_ext_interface.out @@ -1305,6 +1305,7 @@ order by pgcrypto | extensions | pgp_sym_encrypt_bytea | bytea, text, text | bytea pgmq | pgmq | _belongs_to_pgmq | table_name text | boolean pgmq | pgmq | _ensure_pg_partman_installed | | void + pgmq | pgmq | _extension_exists | extension_name text | boolean pgmq | pgmq | _get_partition_col | partition_interval text | text pgmq | pgmq | _get_pg_partman_major_version | | integer pgmq | pgmq | _get_pg_partman_schema | | text @@ -1318,6 +1319,7 @@ order by pgmq | pgmq | delete | queue_name text, msg_id bigint | boolean pgmq | pgmq | delete | queue_name text, msg_ids bigint[] | SETOF bigint pgmq | pgmq | detach_archive | queue_name text | void + pgmq | pgmq | drop_queue | queue_name text, partitioned boolean | boolean pgmq | pgmq | drop_queue | queue_name text | boolean pgmq | pgmq | format_table_name | queue_name text, prefix text | text pgmq | pgmq | list_queues | | SETOF pgmq.queue_record @@ -1325,9 +1327,19 @@ order by pgmq | pgmq | metrics_all | | SETOF pgmq.metrics_result pgmq | pgmq | pop | queue_name text | SETOF pgmq.message_record pgmq | pgmq | purge_queue | queue_name text | bigint - pgmq | pgmq | read | queue_name text, vt integer, qty integer | SETOF pgmq.message_record - pgmq | pgmq | read_with_poll | queue_name text, vt integer, qty integer, max_poll_seconds integer, poll_interval_ms integer | SETOF pgmq.message_record + pgmq | pgmq | read | queue_name text, vt integer, qty integer, conditional jsonb | SETOF pgmq.message_record + pgmq | pgmq | read_with_poll | queue_name text, vt integer, qty integer, max_poll_seconds integer, poll_interval_ms integer, conditional jsonb | SETOF pgmq.message_record + pgmq | pgmq | send | queue_name text, msg jsonb, headers jsonb | SETOF bigint pgmq | pgmq | send | queue_name text, msg jsonb, delay integer | SETOF bigint + pgmq | pgmq | send | queue_name text, msg jsonb, headers jsonb, delay timestamp with time zone | SETOF bigint + pgmq | pgmq | send | queue_name text, msg jsonb, headers jsonb, delay integer | SETOF bigint + pgmq | pgmq | send | queue_name text, msg jsonb | SETOF bigint + pgmq | pgmq | send | queue_name text, msg jsonb, delay timestamp with time zone | SETOF bigint + pgmq | pgmq | send_batch | queue_name text, msgs jsonb[], headers jsonb[] | SETOF bigint + pgmq | pgmq | send_batch | queue_name text, msgs jsonb[], headers jsonb[], delay timestamp with time zone | SETOF bigint + pgmq | pgmq | send_batch | queue_name text, msgs jsonb[], headers jsonb[], delay integer | SETOF bigint + pgmq | pgmq | send_batch | queue_name text, msgs jsonb[] | SETOF bigint + pgmq | pgmq | send_batch | queue_name text, msgs jsonb[], delay timestamp with time zone | SETOF bigint pgmq | pgmq | send_batch | queue_name text, msgs jsonb[], delay integer | SETOF bigint pgmq | pgmq | set_vt | queue_name text, msg_id bigint, vt integer | SETOF pgmq.message_record pgmq | pgmq | validate_queue_name | queue_name text | void @@ -4873,7 +4885,7 @@ order by xml2 | public | xpath_table | text, text, text, text, text | SETOF record xml2 | public | xslt_process | text, text | text xml2 | public | xslt_process | text, text, text | text -(4716 rows) +(4728 rows) /* @@ -5110,6 +5122,7 @@ order by pg_tle | pgtle | feature_info | schema_name pgmq | pgmq | a_foo | archived_at pgmq | pgmq | a_foo | enqueued_at + pgmq | pgmq | a_foo | headers pgmq | pgmq | a_foo | message pgmq | pgmq | a_foo | msg_id pgmq | pgmq | a_foo | read_ct @@ -5119,6 +5132,7 @@ order by pgmq | pgmq | meta | is_unlogged pgmq | pgmq | meta | queue_name pgmq | pgmq | q_foo | enqueued_at + pgmq | pgmq | q_foo | headers pgmq | pgmq | q_foo | message pgmq | pgmq | q_foo | msg_id pgmq | pgmq | q_foo | read_ct @@ -5294,5 +5308,5 @@ order by wrappers | public | wrappers_fdw_stats | rows_in wrappers | public | wrappers_fdw_stats | rows_out wrappers | public | wrappers_fdw_stats | updated_at -(387 rows) +(389 rows)