From b6b415c17a4cfc9512d935b039d9ceeabdafbfa5 Mon Sep 17 00:00:00 2001 From: Alper Kocatas Date: Mon, 2 Jun 2025 10:21:17 +0300 Subject: [PATCH 1/2] Bump Citus version to 13.1.0 (#8012) Bump Citus version to 13.1.0 --- configure | 18 +++++++++--------- configure.ac | 2 +- src/test/regress/expected/multi_extension.out | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/configure b/configure index 4cdb73c1b..b325a79cd 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for Citus 13.1devel. +# Generated by GNU Autoconf 2.69 for Citus 13.1.0. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -579,8 +579,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='Citus' PACKAGE_TARNAME='citus' -PACKAGE_VERSION='13.1devel' -PACKAGE_STRING='Citus 13.1devel' +PACKAGE_VERSION='13.1.0' +PACKAGE_STRING='Citus 13.1.0' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1262,7 +1262,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures Citus 13.1devel to adapt to many kinds of systems. +\`configure' configures Citus 13.1.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1324,7 +1324,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of Citus 13.1devel:";; + short | recursive ) echo "Configuration of Citus 13.1.0:";; esac cat <<\_ACEOF @@ -1429,7 +1429,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -Citus configure 13.1devel +Citus configure 13.1.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1912,7 +1912,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by Citus $as_me 13.1devel, which was +It was created by Citus $as_me 13.1.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -5393,7 +5393,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by Citus $as_me 13.1devel, which was +This file was extended by Citus $as_me 13.1.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -5455,7 +5455,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -Citus config.status 13.1devel +Citus config.status 13.1.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 53127894c..90792977f 100644 --- a/configure.ac +++ b/configure.ac @@ -5,7 +5,7 @@ # everyone needing autoconf installed, the resulting files are checked # into the SCM. -AC_INIT([Citus], [13.1devel]) +AC_INIT([Citus], [13.1.0]) AC_COPYRIGHT([Copyright (c) Citus Data, Inc.]) # we'll need sed and awk for some of the version commands diff --git a/src/test/regress/expected/multi_extension.out b/src/test/regress/expected/multi_extension.out index c8468883b..7ff85605b 100644 --- a/src/test/regress/expected/multi_extension.out +++ b/src/test/regress/expected/multi_extension.out @@ -1492,7 +1492,7 @@ DROP TABLE multi_extension.prev_objects, multi_extension.extension_diff; SHOW citus.version; citus.version --------------------------------------------------------------------- - 13.1devel + 13.1.0 (1 row) -- ensure no unexpected objects were created outside pg_catalog From e42847196ad8dab408d5ba2f8dddacc5ead2666b Mon Sep 17 00:00:00 2001 From: Onur Tirtir Date: Mon, 2 Jun 2025 10:15:32 +0300 Subject: [PATCH 2/2] Add skip_qualify_public param to shard_name() to allow qualifying for "public" schema (#8014) DESCRIPTION: Adds skip_qualify_public param to `shard_name()` UDF to allow qualifying for "public" schema when needed. --- .../distributed/relay/relay_event_utility.c | 3 +- .../distributed/sql/citus--13.0-1--13.1-1.sql | 7 +++++ .../sql/downgrades/citus--13.1-1--13.0-1.sql | 21 ++++++++++++++ .../sql/udfs/shard_name/13.1-1.sql | 8 ++++++ .../sql/udfs/shard_name/latest.sql | 8 ++++++ src/test/regress/expected/citus_shards.out | 28 +++++++++++++++++++ src/test/regress/expected/multi_extension.out | 4 ++- .../expected/upgrade_list_citus_objects.out | 2 +- src/test/regress/sql/citus_shards.sql | 11 ++++++++ 9 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 src/backend/distributed/sql/udfs/shard_name/13.1-1.sql create mode 100644 src/backend/distributed/sql/udfs/shard_name/latest.sql diff --git a/src/backend/distributed/relay/relay_event_utility.c b/src/backend/distributed/relay/relay_event_utility.c index f89dba138..ca9b90212 100644 --- a/src/backend/distributed/relay/relay_event_utility.c +++ b/src/backend/distributed/relay/relay_event_utility.c @@ -962,6 +962,7 @@ shard_name(PG_FUNCTION_ARGS) Oid relationId = PG_GETARG_OID(0); int64 shardId = PG_GETARG_INT64(1); + bool skipQualifyPublic = PG_GETARG_BOOL(2); char *qualifiedName = NULL; @@ -991,7 +992,7 @@ shard_name(PG_FUNCTION_ARGS) Oid schemaId = get_rel_namespace(relationId); char *schemaName = get_namespace_name(schemaId); - if (strncmp(schemaName, "public", NAMEDATALEN) == 0) + if (skipQualifyPublic && strncmp(schemaName, "public", NAMEDATALEN) == 0) { qualifiedName = (char *) quote_identifier(relationName); } diff --git a/src/backend/distributed/sql/citus--13.0-1--13.1-1.sql b/src/backend/distributed/sql/citus--13.0-1--13.1-1.sql index 4d0dc19a3..1599b21f1 100644 --- a/src/backend/distributed/sql/citus--13.0-1--13.1-1.sql +++ b/src/backend/distributed/sql/citus--13.0-1--13.1-1.sql @@ -51,3 +51,10 @@ DROP VIEW IF EXISTS pg_catalog.citus_lock_waits; #include "udfs/citus_stat_counters/13.1-1.sql" #include "udfs/citus_stat_counters_reset/13.1-1.sql" #include "udfs/citus_nodes/13.1-1.sql" + +-- Since shard_name/13.1-1.sql first drops the function and then creates it, we first +-- need to drop citus_shards view since that view depends on this function. And immediately +-- after creating the function, we recreate citus_shards view again. +DROP VIEW pg_catalog.citus_shards; +#include "udfs/shard_name/13.1-1.sql" +#include "udfs/citus_shards/12.0-1.sql" diff --git a/src/backend/distributed/sql/downgrades/citus--13.1-1--13.0-1.sql b/src/backend/distributed/sql/downgrades/citus--13.1-1--13.0-1.sql index 8e18cd33b..bec49703b 100644 --- a/src/backend/distributed/sql/downgrades/citus--13.1-1--13.0-1.sql +++ b/src/backend/distributed/sql/downgrades/citus--13.1-1--13.0-1.sql @@ -46,3 +46,24 @@ DROP VIEW pg_catalog.citus_stat_counters; DROP FUNCTION pg_catalog.citus_stat_counters(oid); DROP FUNCTION pg_catalog.citus_stat_counters_reset(oid); DROP VIEW IF EXISTS pg_catalog.citus_nodes; + +-- Definition of shard_name() prior to this release doesn't have a separate SQL file +-- because it's quite an old UDF that its prior definition(s) was(were) squashed into +-- citus--8.0-1.sql. For this reason, to downgrade it, here we directly execute its old +-- definition instead of including it from such a separate file. +-- +-- And before dropping and creating the function, we also need to drop citus_shards view +-- since it depends on it. And immediately after creating the function, we recreate +-- citus_shards view again. + +DROP VIEW pg_catalog.citus_shards; + +DROP FUNCTION pg_catalog.shard_name(object_name regclass, shard_id bigint, skip_qualify_public boolean); +CREATE FUNCTION pg_catalog.shard_name(object_name regclass, shard_id bigint) + RETURNS text + LANGUAGE C STABLE STRICT + AS 'MODULE_PATHNAME', $$shard_name$$; +COMMENT ON FUNCTION pg_catalog.shard_name(object_name regclass, shard_id bigint) + IS 'returns schema-qualified, shard-extended identifier of object name'; + +#include "../udfs/citus_shards/12.0-1.sql" diff --git a/src/backend/distributed/sql/udfs/shard_name/13.1-1.sql b/src/backend/distributed/sql/udfs/shard_name/13.1-1.sql new file mode 100644 index 000000000..02f3c246f --- /dev/null +++ b/src/backend/distributed/sql/udfs/shard_name/13.1-1.sql @@ -0,0 +1,8 @@ +-- skip_qualify_public is set to true by default just for backward compatibility +DROP FUNCTION pg_catalog.shard_name(object_name regclass, shard_id bigint); +CREATE FUNCTION pg_catalog.shard_name(object_name regclass, shard_id bigint, skip_qualify_public boolean DEFAULT true) + RETURNS text + LANGUAGE C STABLE STRICT + AS 'MODULE_PATHNAME', $$shard_name$$; +COMMENT ON FUNCTION pg_catalog.shard_name(object_name regclass, shard_id bigint, skip_qualify_public boolean) + IS 'returns schema-qualified, shard-extended identifier of object name'; diff --git a/src/backend/distributed/sql/udfs/shard_name/latest.sql b/src/backend/distributed/sql/udfs/shard_name/latest.sql new file mode 100644 index 000000000..02f3c246f --- /dev/null +++ b/src/backend/distributed/sql/udfs/shard_name/latest.sql @@ -0,0 +1,8 @@ +-- skip_qualify_public is set to true by default just for backward compatibility +DROP FUNCTION pg_catalog.shard_name(object_name regclass, shard_id bigint); +CREATE FUNCTION pg_catalog.shard_name(object_name regclass, shard_id bigint, skip_qualify_public boolean DEFAULT true) + RETURNS text + LANGUAGE C STABLE STRICT + AS 'MODULE_PATHNAME', $$shard_name$$; +COMMENT ON FUNCTION pg_catalog.shard_name(object_name regclass, shard_id bigint, skip_qualify_public boolean) + IS 'returns schema-qualified, shard-extended identifier of object name'; diff --git a/src/test/regress/expected/citus_shards.out b/src/test/regress/expected/citus_shards.out index b434a984b..8a8719073 100644 --- a/src/test/regress/expected/citus_shards.out +++ b/src/test/regress/expected/citus_shards.out @@ -33,5 +33,33 @@ SELECT * FROM citus_shards; t1 | 99456903 | citus_shards.t1_99456903 | distributed | 456900 | localhost | 57638 | 8192 (8 rows) +SET search_path TO public; +CREATE TABLE t3 (i int); +SELECT citus_add_local_table_to_metadata('t3'); + citus_add_local_table_to_metadata +--------------------------------------------------------------------- + +(1 row) + +SELECT shard_name('t3', shardid) FROM pg_dist_shard WHERE logicalrelid = 't3'::regclass; + shard_name +--------------------------------------------------------------------- + t3_99456908 +(1 row) + +SELECT shard_name('t3', shardid, true) FROM pg_dist_shard WHERE logicalrelid = 't3'::regclass; + shard_name +--------------------------------------------------------------------- + t3_99456908 +(1 row) + +SELECT shard_name('t3', shardid, false) FROM pg_dist_shard WHERE logicalrelid = 't3'::regclass; + shard_name +--------------------------------------------------------------------- + public.t3_99456908 +(1 row) + +DROP TABLE t3; +SET search_path TO citus_shards; SET client_min_messages TO WARNING; DROP SCHEMA citus_shards CASCADE; diff --git a/src/test/regress/expected/multi_extension.out b/src/test/regress/expected/multi_extension.out index 7ff85605b..5d854f762 100644 --- a/src/test/regress/expected/multi_extension.out +++ b/src/test/regress/expected/multi_extension.out @@ -1455,6 +1455,7 @@ SELECT * FROM multi_extension.print_extension_changes(); previous_object | current_object --------------------------------------------------------------------- function citus_unmark_object_distributed(oid,oid,integer) void | + function shard_name(regclass,bigint) text | | function citus_internal.acquire_citus_advisory_object_class_lock(integer,cstring) void | function citus_internal.add_colocation_metadata(integer,integer,integer,regtype,oid) void | function citus_internal.add_object_metadata(text,text[],text[],integer,integer,boolean) void @@ -1483,9 +1484,10 @@ SELECT * FROM multi_extension.print_extension_changes(); | function citus_stat_counters(oid) SETOF record | function citus_stat_counters_reset(oid) void | function citus_unmark_object_distributed(oid,oid,integer,boolean) void + | function shard_name(regclass,bigint,boolean) text | view citus_nodes | view citus_stat_counters -(31 rows) +(33 rows) DROP TABLE multi_extension.prev_objects, multi_extension.extension_diff; -- show running version diff --git a/src/test/regress/expected/upgrade_list_citus_objects.out b/src/test/regress/expected/upgrade_list_citus_objects.out index 3390dc387..030228fe3 100644 --- a/src/test/regress/expected/upgrade_list_citus_objects.out +++ b/src/test/regress/expected/upgrade_list_citus_objects.out @@ -289,7 +289,7 @@ ORDER BY 1; function run_command_on_placements(regclass,text,boolean) function run_command_on_shards(regclass,text,boolean) function run_command_on_workers(text,boolean) - function shard_name(regclass,bigint) + function shard_name(regclass,bigint,boolean) function start_metadata_sync_to_all_nodes() function start_metadata_sync_to_node(text,integer) function stop_metadata_sync_to_node(text,integer,boolean) diff --git a/src/test/regress/sql/citus_shards.sql b/src/test/regress/sql/citus_shards.sql index 9234ffd2e..1edb3c98c 100644 --- a/src/test/regress/sql/citus_shards.sql +++ b/src/test/regress/sql/citus_shards.sql @@ -13,5 +13,16 @@ INSERT INTO t1 SELECT generate_series(1, 100); INSERT INTO "t with space" SELECT generate_series(1, 1000); SELECT * FROM citus_shards; +SET search_path TO public; +CREATE TABLE t3 (i int); +SELECT citus_add_local_table_to_metadata('t3'); + +SELECT shard_name('t3', shardid) FROM pg_dist_shard WHERE logicalrelid = 't3'::regclass; +SELECT shard_name('t3', shardid, true) FROM pg_dist_shard WHERE logicalrelid = 't3'::regclass; +SELECT shard_name('t3', shardid, false) FROM pg_dist_shard WHERE logicalrelid = 't3'::regclass; + +DROP TABLE t3; +SET search_path TO citus_shards; + SET client_min_messages TO WARNING; DROP SCHEMA citus_shards CASCADE;