@ -20,31 +20,47 @@
-- allowed.
-- allowed.
-- This should match IsBinaryCoercible() in parse_coerce.c.
-- This should match IsBinaryCoercible() in parse_coerce.c.
create function binary_coercible(oid, oid) returns bool as $$
create function binary_coercible(oid, oid) returns bool as $$
SELECT ($1 = $2) OR
begin
EXISTS(select 1 from pg_catalog.pg_cast where
if $1 = $2 then return true; end if;
if EXISTS(select 1 from pg_catalog.pg_cast where
castsource = $1 and casttarget = $2 and
castsource = $1 and casttarget = $2 and
castmethod = 'b' and castcontext = 'i') OR
castmethod = 'b' and castcontext = 'i')
($2 = 'pg_catalog.any'::pg_catalog.regtype) OR
then return true; end if;
($2 = 'pg_catalog.anyarray'::pg_catalog.regtype AND
if $2 = 'pg_catalog.any'::pg_catalog.regtype then return true; end if;
EXISTS(select 1 from pg_catalog.pg_type where
if $2 = 'pg_catalog.anyarray'::pg_catalog.regtype then
oid = $1 and typelem != 0 and typlen = -1)) OR
if EXISTS(select 1 from pg_catalog.pg_type where
($2 = 'pg_catalog.anyrange'::pg_catalog.regtype AND
oid = $1 and typelem != 0 and typlen = -1)
(select typtype from pg_catalog.pg_type where oid = $1) = 'r')
then return true; end if;
$$ language sql strict stable;
end if;
if $2 = 'pg_catalog.anyrange'::pg_catalog.regtype then
if (select typtype from pg_catalog.pg_type where oid = $1) = 'r'
then return true; end if;
end if;
return false;
end
$$ language plpgsql strict stable;
-- This one ignores castcontext, so it considers only physical equivalence
-- This one ignores castcontext, so it considers only physical equivalence
-- and not whether the coercion can be invoked implicitly.
-- and not whether the coercion can be invoked implicitly.
create function physically_coercible(oid, oid) returns bool as $$
create function physically_coercible(oid, oid) returns bool as $$
SELECT ($1 = $2) OR
begin
EXISTS(select 1 from pg_catalog.pg_cast where
if $1 = $2 then return true; end if;
if EXISTS(select 1 from pg_catalog.pg_cast where
castsource = $1 and casttarget = $2 and
castsource = $1 and casttarget = $2 and
castmethod = 'b') OR
castmethod = 'b')
($2 = 'pg_catalog.any'::pg_catalog.regtype) OR
then return true; end if;
($2 = 'pg_catalog.anyarray'::pg_catalog.regtype AND
if $2 = 'pg_catalog.any'::pg_catalog.regtype then return true; end if;
EXISTS(select 1 from pg_catalog.pg_type where
if $2 = 'pg_catalog.anyarray'::pg_catalog.regtype then
oid = $1 and typelem != 0 and typlen = -1)) OR
if EXISTS(select 1 from pg_catalog.pg_type where
($2 = 'pg_catalog.anyrange'::pg_catalog.regtype AND
oid = $1 and typelem != 0 and typlen = -1)
(select typtype from pg_catalog.pg_type where oid = $1) = 'r')
then return true; end if;
$$ language sql strict stable;
end if;
if $2 = 'pg_catalog.anyrange'::pg_catalog.regtype then
if (select typtype from pg_catalog.pg_type where oid = $1) = 'r'
then return true; end if;
end if;
return false;
end
$$ language plpgsql strict stable;
-- **************** pg_proc ****************
-- **************** pg_proc ****************
-- Look for illegal values in pg_proc fields.
-- Look for illegal values in pg_proc fields.
SELECT p1.oid, p1.proname
SELECT p1.oid, p1.proname
@ -1190,10 +1206,14 @@ WHERE d.classoid IS NULL AND p1.oid <= 9999;
-- be called directly; those should have comments matching their operator.
-- be called directly; those should have comments matching their operator.
WITH funcdescs AS (
WITH funcdescs AS (
SELECT p.oid as p_oid, proname, o.oid as o_oid,
SELECT p.oid as p_oid, proname, o.oid as o_oid,
obj_description(p.oid, 'pg_proc') as prodesc,
pd.description as prodesc,
'implementation of ' || oprname || ' operator' as expecteddesc,
'implementation of ' || oprname || ' operator' as expecteddesc,
obj_description(o.oid, 'pg_operator') as oprdesc
od.description as oprdesc
FROM pg_proc p JOIN pg_operator o ON oprcode = p.oid
FROM pg_proc p JOIN pg_operator o ON oprcode = p.oid
LEFT JOIN pg_description pd ON
(pd.objoid = p.oid and pd.classoid = p.tableoid and pd.objsubid = 0)
LEFT JOIN pg_description od ON
(od.objoid = o.oid and od.classoid = o.tableoid and od.objsubid = 0)
WHERE o.oid <= 9999
WHERE o.oid <= 9999
)
)
SELECT * FROM funcdescs
SELECT * FROM funcdescs
@ -1210,10 +1230,14 @@ SELECT * FROM funcdescs
-- This should be a pretty short list; it's mostly legacy cases.
-- This should be a pretty short list; it's mostly legacy cases.
WITH funcdescs AS (
WITH funcdescs AS (
SELECT p.oid as p_oid, proname, o.oid as o_oid,
SELECT p.oid as p_oid, proname, o.oid as o_oid,
obj_description(p.oid, 'pg_proc') as prodesc,
pd.description as prodesc,
'implementation of ' || oprname || ' operator' as expecteddesc,
'implementation of ' || oprname || ' operator' as expecteddesc,
obj_description(o.oid, 'pg_operator') as oprdesc
od.description as oprdesc
FROM pg_proc p JOIN pg_operator o ON oprcode = p.oid
FROM pg_proc p JOIN pg_operator o ON oprcode = p.oid
LEFT JOIN pg_description pd ON
(pd.objoid = p.oid and pd.classoid = p.tableoid and pd.objsubid = 0)
LEFT JOIN pg_description od ON
(od.objoid = o.oid and od.classoid = o.tableoid and od.objsubid = 0)
WHERE o.oid <= 9999
WHERE o.oid <= 9999
)
)
SELECT p_oid, proname, prodesc FROM funcdescs
SELECT p_oid, proname, prodesc FROM funcdescs