Commit 8a37951e authored by Tom Lane's avatar Tom Lane

Mark built-in coercion functions as leakproof where possible.

Making these leakproof seems helpful since (for example) if you have a
function f(int8) that is leakproof, you don't want it to effectively
become non-leakproof when you apply it to an int4 or int2 column.
But that's what happens today, since the implicit up-coercion will
not be leakproof.

Most of the coercion functions that visibly can't throw errors are
functions that convert numeric datatypes to other, wider ones.
Notable is that float4_numeric and float8_numeric can be marked
leakproof; before commit a57d312a they could not have been.
I also marked the functions that coerce strings to "name" as leakproof;
that's okay today because they truncate silently, but if we ever
reconsidered that behavior then they could no longer be leakproof.

I desisted from marking rtrim1() as leakproof; it appears so right now,
but the code seems a little too complex and perhaps subject to change,
since it's shared with other SQL functions.

Discussion: https://postgr.es/m/459322.1595607431@sss.pgh.pa.us
parent 2a249422
......@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
#define CATALOG_VERSION_NO 202007202
#define CATALOG_VERSION_NO 202007251
#endif
This diff is collapsed.
......@@ -572,6 +572,8 @@ int24ge(smallint,integer)
int42ge(integer,smallint)
oideq(oid,oid)
oidne(oid,oid)
float8(smallint)
float4(smallint)
nameeqtext(name,text)
namelttext(name,text)
nameletext(name,text)
......@@ -610,6 +612,10 @@ float84lt(double precision,real)
float84le(double precision,real)
float84gt(double precision,real)
float84ge(double precision,real)
float8(real)
int4(smallint)
float8(integer)
float4(integer)
btint2cmp(smallint,smallint)
btint4cmp(integer,integer)
btfloat4cmp(real,real)
......@@ -620,6 +626,9 @@ btnamecmp(name,name)
bttextcmp(text,text)
cash_cmp(money,money)
btoidvectorcmp(oidvector,oidvector)
text(name)
name(text)
name(character)
text_larger(text,text)
text_smaller(text,text)
int8eq(bigint,bigint)
......@@ -634,7 +643,10 @@ int84lt(bigint,integer)
int84gt(bigint,integer)
int84le(bigint,integer)
int84ge(bigint,integer)
int8(integer)
float8(bigint)
oidvectorne(oidvector,oidvector)
float4(bigint)
namelt(name,name)
namele(name,name)
namegt(name,name)
......@@ -651,6 +663,7 @@ text_lt(text,text)
text_le(text,text)
text_gt(text,text)
text_ge(text,text)
int8(smallint)
macaddr_eq(macaddr,macaddr)
macaddr_lt(macaddr,macaddr)
macaddr_le(macaddr,macaddr)
......@@ -716,6 +729,7 @@ interval_ge(interval,interval)
interval_gt(interval,interval)
charlt("char","char")
tidne(tid,tid)
int8(oid)
tideq(tid,tid)
timestamptz_cmp(timestamp with time zone,timestamp with time zone)
interval_cmp(interval,interval)
......@@ -727,6 +741,9 @@ timetz_le(time with time zone,time with time zone)
timetz_ge(time with time zone,time with time zone)
timetz_gt(time with time zone,time with time zone)
timetz_cmp(time with time zone,time with time zone)
"interval"(time without time zone)
name(character varying)
"varchar"(name)
circle_eq(circle,circle)
circle_ne(circle,circle)
circle_lt(circle,circle)
......@@ -757,6 +774,11 @@ varbitcmp(bit varying,bit varying)
boolle(boolean,boolean)
boolge(boolean,boolean)
btboolcmp(boolean,boolean)
"numeric"(integer)
"numeric"(real)
"numeric"(double precision)
"numeric"(bigint)
"numeric"(smallint)
int28eq(smallint,bigint)
int28ne(smallint,bigint)
int28lt(smallint,bigint)
......@@ -803,6 +825,8 @@ btfloat48cmp(real,double precision)
btfloat84cmp(double precision,real)
md5(text)
md5(bytea)
bool(integer)
int4(boolean)
tidgt(tid,tid)
tidlt(tid,tid)
tidge(tid,tid)
......@@ -837,6 +861,7 @@ macaddr8_gt(macaddr8,macaddr8)
macaddr8_ge(macaddr8,macaddr8)
macaddr8_ne(macaddr8,macaddr8)
macaddr8_cmp(macaddr8,macaddr8)
macaddr8(macaddr)
xid8lt(xid8,xid8)
xid8gt(xid8,xid8)
xid8le(xid8,xid8)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment