Project

General

Profile

« Previous | Next » 

Revision 14272

bugfix: schemas/util.sql: check_constraint_expr_enable(): don't remove suffix without also removing prefix. this is done by using extract_by_regexp() instead. also changed check_constraint_enabled() to use regexps to match this.

View differences:

trunk/schemas/util.sql
1086 1086

  
1087 1087
CREATE FUNCTION check_constraint_enabled(constraint_def check_constraint_def) RETURNS boolean
1088 1088
    LANGUAGE sql STABLE
1089
    AS $_$
1089
    AS $_X$
1090 1090
-- **WARNING**: whitespace in strings is significant
1091
SELECT NOT /*disabled*/util.starts_with($$
1091
SELECT NOT /*disabled*/constraint_def.expr ~ $_$^
1092 1092
CASE
1093 1093
    WHEN true THEN true
1094
    ELSE $$,
1095
constraint_def.expr)
1096
$_$;
1094
    ELSE $_$
1095
$_X$;
1097 1096

  
1098 1097

  
1099 1098
--
......
1138 1137

  
1139 1138
CREATE FUNCTION check_constraint_expr_enable(expr text) RETURNS text
1140 1139
    LANGUAGE sql IMMUTABLE
1141
    AS $_$
1140
    AS $_X$
1142 1141
-- **WARNING**: whitespace in strings is significant
1143 1142
-- **IMPORTANT**: need to remove the enclosing () to be consistent everywhere
1144 1143
SELECT util.trim_parens(
1145
util.remove_prefix($$
1144
util.extract_by_regexp($_$^
1146 1145
CASE
1147 1146
    WHEN true THEN true
1148
    ELSE $$,
1149
util.remove_suffix($$
1150
END$$,
1151
util.trim_parens(expr), require := false), require := false))
1152
$_$;
1147
    ELSE (.*)
1148
END$$_$,
1149
util.trim_parens(expr)))
1150
$_X$;
1153 1151

  
1154 1152

  
1155 1153
--

Also available in: Unified diff