Revision 2722
Added by Aaron Marcuse-Kubitza over 12 years ago
schemas/functions.sql | ||
---|---|---|
110 | 110 |
BEGIN |
111 | 111 |
IF new.type = 'str' THEN -- no cast needed |
112 | 112 |
new.result := (SELECT nullif(new.value, new."null")); |
113 |
-- Invalid value -> warning, but invalid null value -> error
|
|
113 |
-- Invalid value is ignored, but invalid null value generates error
|
|
114 | 114 |
ELSIF new.type = 'float' THEN |
115 |
new.result := (SELECT nullif(functions."double precision"(new.value), |
|
116 |
new."null"::double precision)); |
|
115 |
DECLARE |
|
116 |
-- Outside the try block so that invalid null value generates error |
|
117 |
"null" double precision := new."null"::double precision; |
|
118 |
BEGIN |
|
119 |
new.result := (SELECT nullif(new.value::double precision, "null")); |
|
120 |
EXCEPTION |
|
121 |
WHEN data_exception THEN NULL; -- ignore invalid value |
|
122 |
END; |
|
117 | 123 |
END IF; |
118 | 124 |
|
119 | 125 |
RETURN new; |
Also available in: Unified diff
schemas/functions.sql: _nullIf(): Ignore uncastable value, because a value that's invalid for the given type is still well-defined as not matching the nullif() criterion