From 675798b9cc6887bb5a2655022d5507a4ff138519 Mon Sep 17 00:00:00 2001 From: Hope Gao Date: Tue, 1 Dec 2026 14:23:52 +0800 Subject: Fix backslash escaping in pg_upgrade's Unicode update check check_for_unicode_update() uses ordinary SQL string literals containing \w to build regular expressions. When standard_conforming_strings is off on the source server, SQL parsing removes the backslashes, changing the patterns' meaning and potentially causing affected objects to be missed. This also produces warnings about nonstandard escape usage. Use explicit escape string literals with appropriate C-level escaping so the patterns work correctly regardless of standard_conforming_strings. --- src/bin/pg_upgrade/check.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c index 1e6e82c01d0..8cce1ab02b1 100644 --- a/src/bin/pg_upgrade/check.c +++ b/src/bin/pg_upgrade/check.c @@ -2022,10 +2022,10 @@ check_for_unicode_update(ClusterInfo *cluster) "patterns(p) AS ( " " SELECT '{FUNCEXPR :funcid ' || procid::text || '[ }]' FROM functions " " UNION " - " SELECT '{OPEXPR :opno ' || operid::text || ' (:\\w+ \\w+ )*' || " + " SELECT '{OPEXPR :opno ' || operid::text || E' (:\\\\w+ \\\\w+ )*' || " " ':inputcollid ' || collid::text || '[ }]' FROM coll_operators " " UNION " - " SELECT '{FUNCEXPR :funcid ' || procid::text || ' (:\\w+ \\w+ )*' || " + " SELECT '{FUNCEXPR :funcid ' || procid::text || E' (:\\\\w+ \\\\w+ )*' || " " ':inputcollid ' || collid::text || '[ }]' FROM coll_functions " ") " -- 2.43.0