Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d76c8e3

Browse files
authored
raise_exception() returns anyelement instead boolean
1 parent 1a97814 commit d76c8e3

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

‎functions/raise_exception.sql‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ create or replace function public.raise_exception(
1313
"table" text default null,
1414
"column" text default null
1515
)
16-
returns boolean
16+
returns anyelement
1717
immutable
1818
--strict -- returns null if any parameter is null
1919
parallel safe
@@ -32,7 +32,7 @@ begin
3232
table = coalesce("table", ''),
3333
column = coalesce("column", ''),
3434
datatype = pg_typeof(value)::text;
35-
return null::bool;
35+
return null::anyelement;
3636
end;
3737
$$;
3838

@@ -133,7 +133,7 @@ left join generate_series(1, 4 + 1) as hand2(finger) using (finger)
133133
where case when hand1.finger between 1 and 5
134134
and hand2.finger is not null
135135
then true
136-
else public.raise_exception(array[hand1.finger, hand2.finger])
136+
else public.raise_exception(array[hand1.finger, hand2.finger])::text::bool
137137
end
138138
order by hand1.finger;
139139

@@ -143,7 +143,7 @@ with t as materialized (
143143
from generate_series(1, 100000) as x(i)
144144
where case when clock_timestamp() < '1s' + statement_timestamp()
145145
then true
146-
else public.raise_exception(i)
146+
else public.raise_exception(i)::bool
147147
end
148148
order by i
149149
)
@@ -161,4 +161,9 @@ WHERE
161161
table_name = 'source_1234567890' AND
162162
column_name = 'scope';
163163

164+
--USE EXAMPLE 5
165+
SELECT CASE WHEN true THEN point(0,0)
166+
ELSE public.raise_exception(null::point)
167+
END;
168+
164169
--See also: https://github.com/decibel/pgerror

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /