Avoid using backslash in SQL string literals

pull/7669/head
Karina Litskevich 2024-08-09 13:10:23 +03:00 committed by Karina
parent 68d28ecdc0
commit eead8ccad2
25 changed files with 28 additions and 28 deletions

View File

@ -71,7 +71,7 @@ BEGIN
-- from version 12 and up we have support for tableam's if installed on pg11 we can't
-- create the objects here. Instead we rely on citus_finish_pg_upgrade to be called by the
-- user instead to add the missing objects
IF substring(current_Setting('server_version'), '\d+')::int >= 12 THEN
IF substring(current_Setting('server_version'), '[0-9]+')::int >= 12 THEN
EXECUTE $$
--#include "udfs/columnar_handler/10.0-1.sql"
CREATE OR REPLACE FUNCTION columnar.columnar_handler(internal)

View File

@ -4,7 +4,7 @@
-- Postgres assigns different names to those foreign keys in PG11, so act accordingly.
DO $proc$
BEGIN
IF substring(current_Setting('server_version'), '\d+')::int >= 12 THEN
IF substring(current_Setting('server_version'), '[0-9]+')::int >= 12 THEN
EXECUTE $$
ALTER TABLE columnar.chunk DROP CONSTRAINT chunk_storage_id_stripe_num_chunk_group_num_fkey;
ALTER TABLE columnar.chunk_group DROP CONSTRAINT chunk_group_storage_id_stripe_num_fkey;

View File

@ -67,7 +67,7 @@ BEGIN
-- from version 12 and up we have support for tableam's if installed on pg11 we can't
-- create the objects here. Instead we rely on citus_finish_pg_upgrade to be called by the
-- user instead to add the missing objects
IF substring(current_Setting('server_version'), '\d+')::int >= 12 THEN
IF substring(current_Setting('server_version'), '[0-9]+')::int >= 12 THEN
EXECUTE $$
#include "udfs/columnar_handler/10.0-1.sql"
#include "udfs/alter_columnar_table_set/10.0-1.sql"

View File

@ -5,7 +5,7 @@ SET search_path TO columnar;
DO $proc$
BEGIN
IF substring(current_Setting('server_version'), '\d+')::int >= 12 THEN
IF substring(current_Setting('server_version'), '[0-9]+')::int >= 12 THEN
EXECUTE $$
DROP FUNCTION pg_catalog.alter_columnar_table_reset(
table_name regclass,

View File

@ -15,7 +15,7 @@ BEGIN
-- when postgres is version 12 or above we need to create the tableam. If the tableam
-- exist we assume all objects have been created.
IF substring(current_Setting('server_version'), '\d+')::int >= 12 THEN
IF substring(current_Setting('server_version'), '[0-9]+')::int >= 12 THEN
IF NOT EXISTS (SELECT 1 FROM pg_am WHERE amname = 'columnar') THEN
#include "../columnar_handler/10.0-1.sql"

View File

@ -15,7 +15,7 @@ BEGIN
-- when postgres is version 12 or above we need to create the tableam. If the tableam
-- exist we assume all objects have been created.
IF substring(current_Setting('server_version'), '\d+')::int >= 12 THEN
IF substring(current_Setting('server_version'), '[0-9]+')::int >= 12 THEN
IF NOT EXISTS (SELECT 1 FROM pg_am WHERE amname = 'columnar') THEN
#include "../columnar_handler/10.0-1.sql"

View File

@ -323,7 +323,7 @@ CREATE TRIGGER dist_shard_cache_invalidate
DO $proc$
BEGIN
IF substring(current_Setting('server_version'), '\d+')::int >= 14 THEN
IF substring(current_Setting('server_version'), '[0-9]+')::int >= 14 THEN
EXECUTE $$
CREATE AGGREGATE array_cat_agg(anycompatiblearray) (SFUNC = array_cat, STYPE = anycompatiblearray);
COMMENT ON AGGREGATE array_cat_agg(anycompatiblearray)

View File

@ -1,7 +1,7 @@
DO $proc$
BEGIN
-- PG16 has its own any_value, so only create it pre PG16.
IF substring(current_Setting('server_version'), '\d+')::int < 16 THEN
IF substring(current_Setting('server_version'), '[0-9]+')::int < 16 THEN
EXECUTE $$
CREATE OR REPLACE FUNCTION pg_catalog.any_value_agg ( anyelement, anyelement )

View File

@ -1,7 +1,7 @@
DO $proc$
BEGIN
-- PG16 has its own any_value, so only create it pre PG16.
IF substring(current_Setting('server_version'), '\d+')::int < 16 THEN
IF substring(current_Setting('server_version'), '[0-9]+')::int < 16 THEN
EXECUTE $$
CREATE OR REPLACE FUNCTION pg_catalog.any_value_agg ( anyelement, anyelement )

View File

@ -18,7 +18,7 @@ BEGIN
FROM pg_dist_node_metadata;
SELECT r[1], r[2], r[3]
FROM regexp_matches(last_upgrade_version_string,'([0-9]+)\.([0-9]+)-([0-9]+)','') r
FROM regexp_matches(last_upgrade_version_string,'([0-9]+)[.]([0-9]+)-([0-9]+)','') r
INTO last_upgrade_major_version, last_upgrade_minor_version, last_upgrade_sqlpatch_version;
IF last_upgrade_major_version IS NULL OR last_upgrade_minor_version IS NULL OR last_upgrade_sqlpatch_version IS NULL THEN

View File

@ -18,7 +18,7 @@ BEGIN
FROM pg_dist_node_metadata;
SELECT r[1], r[2], r[3]
FROM regexp_matches(last_upgrade_version_string,'([0-9]+)\.([0-9]+)-([0-9]+)','') r
FROM regexp_matches(last_upgrade_version_string,'([0-9]+)[.]([0-9]+)-([0-9]+)','') r
INTO last_upgrade_major_version, last_upgrade_minor_version, last_upgrade_sqlpatch_version;
IF last_upgrade_major_version IS NULL OR last_upgrade_minor_version IS NULL OR last_upgrade_sqlpatch_version IS NULL THEN

View File

@ -10,7 +10,7 @@ DECLARE
BEGIN
IF substring(current_Setting('server_version'), '\d+')::int >= 14 THEN
IF substring(current_Setting('server_version'), '[0-9]+')::int >= 14 THEN
EXECUTE $cmd$
CREATE AGGREGATE array_cat_agg(anycompatiblearray) (SFUNC = array_cat, STYPE = anycompatiblearray);
COMMENT ON AGGREGATE array_cat_agg(anycompatiblearray)

View File

@ -10,7 +10,7 @@ DECLARE
BEGIN
IF substring(current_Setting('server_version'), '\d+')::int >= 14 THEN
IF substring(current_Setting('server_version'), '[0-9]+')::int >= 14 THEN
EXECUTE $cmd$
CREATE AGGREGATE array_cat_agg(anycompatiblearray) (SFUNC = array_cat, STYPE = anycompatiblearray);
COMMENT ON AGGREGATE array_cat_agg(anycompatiblearray)

View File

@ -10,7 +10,7 @@ DECLARE
BEGIN
IF substring(current_Setting('server_version'), '\d+')::int >= 14 THEN
IF substring(current_Setting('server_version'), '[0-9]+')::int >= 14 THEN
EXECUTE $cmd$
CREATE AGGREGATE array_cat_agg(anycompatiblearray) (SFUNC = array_cat, STYPE = anycompatiblearray);
COMMENT ON AGGREGATE array_cat_agg(anycompatiblearray)

View File

@ -10,7 +10,7 @@ DECLARE
BEGIN
IF substring(current_Setting('server_version'), '\d+')::int >= 14 THEN
IF substring(current_Setting('server_version'), '[0-9]+')::int >= 14 THEN
EXECUTE $cmd$
-- disable propagation to prevent EnsureCoordinator errors
-- the aggregate created here does not depend on Citus extension (yet)

View File

@ -10,7 +10,7 @@ DECLARE
BEGIN
IF substring(current_Setting('server_version'), '\d+')::int >= 14 THEN
IF substring(current_Setting('server_version'), '[0-9]+')::int >= 14 THEN
EXECUTE $cmd$
-- disable propagation to prevent EnsureCoordinator errors
-- the aggregate created here does not depend on Citus extension (yet)

View File

@ -10,7 +10,7 @@ DECLARE
BEGIN
IF substring(current_Setting('server_version'), '\d+')::int >= 14 THEN
IF substring(current_Setting('server_version'), '[0-9]+')::int >= 14 THEN
EXECUTE $cmd$
-- disable propagation to prevent EnsureCoordinator errors
-- the aggregate created here does not depend on Citus extension (yet)

View File

@ -10,7 +10,7 @@ DECLARE
BEGIN
IF substring(current_Setting('server_version'), '\d+')::int >= 14 THEN
IF substring(current_Setting('server_version'), '[0-9]+')::int >= 14 THEN
EXECUTE $cmd$
-- disable propagation to prevent EnsureCoordinator errors
-- the aggregate created here does not depend on Citus extension (yet)

View File

@ -10,7 +10,7 @@ DECLARE
BEGIN
IF substring(current_Setting('server_version'), '\d+')::int >= 14 THEN
IF substring(current_Setting('server_version'), '[0-9]+')::int >= 14 THEN
EXECUTE $cmd$
-- disable propagation to prevent EnsureCoordinator errors
-- the aggregate created here does not depend on Citus extension (yet)

View File

@ -10,7 +10,7 @@ DECLARE
BEGIN
IF substring(current_Setting('server_version'), '\d+')::int >= 14 THEN
IF substring(current_Setting('server_version'), '[0-9]+')::int >= 14 THEN
EXECUTE $cmd$
-- disable propagation to prevent EnsureCoordinator errors
-- the aggregate created here does not depend on Citus extension (yet)
@ -53,7 +53,7 @@ BEGIN
-- PG16 has its own any_value, so only create it pre PG16.
-- We can remove this part when we drop support for PG16
IF substring(current_Setting('server_version'), '\d+')::int < 16 THEN
IF substring(current_Setting('server_version'), '[0-9]+')::int < 16 THEN
EXECUTE $cmd$
-- disable propagation to prevent EnsureCoordinator errors
-- the aggregate created here does not depend on Citus extension (yet)

View File

@ -10,7 +10,7 @@ DECLARE
BEGIN
IF substring(current_Setting('server_version'), '\d+')::int >= 14 THEN
IF substring(current_Setting('server_version'), '[0-9]+')::int >= 14 THEN
EXECUTE $cmd$
-- disable propagation to prevent EnsureCoordinator errors
-- the aggregate created here does not depend on Citus extension (yet)
@ -53,7 +53,7 @@ BEGIN
-- PG16 has its own any_value, so only create it pre PG16.
-- We can remove this part when we drop support for PG16
IF substring(current_Setting('server_version'), '\d+')::int < 16 THEN
IF substring(current_Setting('server_version'), '[0-9]+')::int < 16 THEN
EXECUTE $cmd$
-- disable propagation to prevent EnsureCoordinator errors
-- the aggregate created here does not depend on Citus extension (yet)

View File

@ -10,7 +10,7 @@ DECLARE
BEGIN
IF substring(current_Setting('server_version'), '\d+')::int >= 14 THEN
IF substring(current_Setting('server_version'), '[0-9]+')::int >= 14 THEN
EXECUTE $cmd$
-- disable propagation to prevent EnsureCoordinator errors
-- the aggregate created here does not depend on Citus extension (yet)
@ -53,7 +53,7 @@ BEGIN
-- PG16 has its own any_value, so only create it pre PG16.
-- We can remove this part when we drop support for PG16
IF substring(current_Setting('server_version'), '\d+')::int < 16 THEN
IF substring(current_Setting('server_version'), '[0-9]+')::int < 16 THEN
EXECUTE $cmd$
-- disable propagation to prevent EnsureCoordinator errors
-- the aggregate created here does not depend on Citus extension (yet)

View File

@ -23,7 +23,7 @@ JOIN
ON
pg_dist_partition.logicalrelid = pg_dist_shard.logicalrelid
LEFT JOIN
(SELECT (regexp_matches(table_name,'_(\d+)$'))[1]::int as shard_id, max(size) as size from citus_shard_sizes() GROUP BY shard_id) as shard_sizes
(SELECT (regexp_matches(table_name,'_([0-9]+)$'))[1]::int as shard_id, max(size) as size from citus_shard_sizes() GROUP BY shard_id) as shard_sizes
ON
pg_dist_shard.shardid = shard_sizes.shard_id
WHERE

View File

@ -23,7 +23,7 @@ JOIN
ON
pg_dist_partition.logicalrelid = pg_dist_shard.logicalrelid
LEFT JOIN
(SELECT (regexp_matches(table_name,'_(\d+)$'))[1]::int as shard_id, max(size) as size from citus_shard_sizes() GROUP BY shard_id) as shard_sizes
(SELECT (regexp_matches(table_name,'_([0-9]+)$'))[1]::int as shard_id, max(size) as size from citus_shard_sizes() GROUP BY shard_id) as shard_sizes
ON
pg_dist_shard.shardid = shard_sizes.shard_id
WHERE

View File

@ -474,7 +474,7 @@ PendingWorkerTransactionList(MultiConnection *connection)
int32 coordinatorId = GetLocalGroupId();
appendStringInfo(command, "SELECT gid FROM pg_prepared_xacts "
"WHERE gid LIKE 'citus\\_%d\\_%%' and database = current_database()",
"WHERE gid LIKE 'citus/_%d/_%%' ESCAPE '/' and database = current_database()",
coordinatorId);
int querySent = SendRemoteCommand(connection, command->data);