summaryrefslogtreecommitdiff
path: root/contrib/isn/sql
diff options
context:
space:
mode:
authorTom Lane2025-03-16 17:45:48 +0000
committerTom Lane2025-03-16 17:45:48 +0000
commit44890442398cf3a65230d53167e61905d2b0d348 (patch)
tree1cb9b611315da7ac77b46aef74addc5918cb22d7 /contrib/isn/sql
parent682c5be25c28192c56e9d5e2a9ca14673a2fcf4b (diff)
contrib/isn: Make weak mode a GUC setting, and fix related functions.
isn's weak mode used to be a simple static variable, settable only via the isn_weak(boolean) function. This wasn't optimal, as this means it doesn't respect transactions nor respond to RESET ALL. This patch makes isn.weak a GUC parameter instead, so that it acts like any other user-settable parameter. The isn_weak() functions are retained for backwards compatibility. But we must fix their volatility markings: they were marked IMMUTABLE which is surely incorrect, and PARALLEL RESTRICTED which isn't right for GUC-related functions either. Mark isn_weak(boolean) as VOLATILE and PARALLEL UNSAFE, matching set_config(). Mark isn_weak() as STABLE and PARALLEL SAFE, matching current_setting(). Reported-by: Viktor Holmberg <v@viktorh.net> Diagnosed-by: Daniel Gustafsson <daniel@yesql.se> Author: Viktor Holmberg <v@viktorh.net> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/790bc1f9-74dc-4b50-94d2-8147315b1556@Spark
Diffstat (limited to 'contrib/isn/sql')
-rw-r--r--contrib/isn/sql/isn.sql13
1 files changed, 13 insertions, 0 deletions
diff --git a/contrib/isn/sql/isn.sql b/contrib/isn/sql/isn.sql
index 2c2ea077d1e..043e5580b0d 100644
--- a/contrib/isn/sql/isn.sql
+++ b/contrib/isn/sql/isn.sql
@@ -121,6 +121,19 @@ FROM (VALUES ('9780123456786', 'UPC'),
LATERAL pg_input_error_info(a.str, a.typ) as errinfo;
--
+-- test weak mode
+--
+SELECT '2222222222221'::ean13; -- fail
+SET isn.weak TO TRUE;
+SELECT '2222222222221'::ean13;
+SELECT is_valid('2222222222221'::ean13);
+SELECT make_valid('2222222222221'::ean13);
+
+SELECT isn_weak(); -- backwards-compatibility wrappers for accessing the GUC
+SELECT isn_weak(false);
+SHOW isn.weak;
+
+--
-- cleanup
--
DROP EXTENSION isn;