Commit 6bbcff09 authored by Alexander Korotkov's avatar Alexander Korotkov

Mark multirange_constructor0() and multirange_constructor2() strict

These functions shouldn't receive null arguments: multirange_constructor0()
doesn't have any arguments while multirange_constructor2() has a single array
argument, which is never null.

But mark them strict anyway for the sake of uniformity.

Also, make checks for null arguments use elog() instead of ereport() as these
errors should normally be never thrown.  And adjust corresponding comments.

Catversion is bumped.

Reported-by: Peter Eisentraut
Discussion: https://postgr.es/m/0f783a96-8d67-9e71-996b-f34a7352eeef%40enterprisedb.com
parent 3f20d5f3
......@@ -1844,7 +1844,7 @@ makeMultirangeConstructors(const char *name, Oid namespace,
PROKIND_FUNCTION,
false, /* security_definer */
false, /* leakproof */
false, /* isStrict */
true, /* isStrict */
PROVOLATILE_IMMUTABLE, /* volatility */
PROPARALLEL_SAFE, /* parallel safety */
argtypes, /* parameterTypes */
......@@ -1929,7 +1929,7 @@ makeMultirangeConstructors(const char *name, Oid namespace,
PROKIND_FUNCTION,
false, /* security_definer */
false, /* leakproof */
false, /* isStrict */
true, /* isStrict */
PROVOLATILE_IMMUTABLE, /* volatility */
PROPARALLEL_SAFE, /* parallel safety */
argtypes, /* parameterTypes */
......
......@@ -216,6 +216,7 @@ multirange_in(PG_FUNCTION_ARGS)
parse_state = MULTIRANGE_IN_RANGE_QUOTED;
else if (ch == '\\')
parse_state = MULTIRANGE_IN_RANGE_ESCAPED;
/*
* We will include this character into range_str once we
* find the end of the range value.
......@@ -223,6 +224,7 @@ multirange_in(PG_FUNCTION_ARGS)
}
break;
case MULTIRANGE_IN_RANGE_ESCAPED:
/*
* We will include this character into range_str once we find
* the end of the range value.
......@@ -242,8 +244,8 @@ multirange_in(PG_FUNCTION_ARGS)
parse_state = MULTIRANGE_IN_RANGE_QUOTED_ESCAPED;
/*
* We will include this character into range_str once we
* find the end of the range value.
* We will include this character into range_str once we find
* the end of the range value.
*/
break;
case MULTIRANGE_AFTER_RANGE:
......@@ -259,6 +261,7 @@ multirange_in(PG_FUNCTION_ARGS)
errdetail("Expected comma or end of multirange.")));
break;
case MULTIRANGE_IN_RANGE_QUOTED_ESCAPED:
/*
* We will include this character into range_str once we find
* the end of the range value.
......@@ -951,14 +954,13 @@ multirange_constructor2(PG_FUNCTION_ARGS)
PG_RETURN_MULTIRANGE_P(make_multirange(mltrngtypid, rangetyp, 0, NULL));
/*
* These checks should be guaranteed by our signature, but let's do them
* just in case.
* This check should be guaranteed by our signature, but let's do it just
* in case.
*/
if (PG_ARGISNULL(0))
ereport(ERROR,
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
errmsg("multirange values cannot contain NULL members")));
elog(ERROR,
"multirange values cannot contain NULL members");
rangeArray = PG_GETARG_ARRAYTYPE_P(0);
......@@ -1022,14 +1024,13 @@ multirange_constructor1(PG_FUNCTION_ARGS)
rangetyp = typcache->rngtype;
/*
* These checks should be guaranteed by our signature, but let's do them
* just in case.
* This check should be guaranteed by our signature, but let's do it just
* in case.
*/
if (PG_ARGISNULL(0))
ereport(ERROR,
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
errmsg("multirange values cannot contain NULL members")));
elog(ERROR,
"multirange values cannot contain NULL members");
range = PG_GETARG_RANGE_P(0);
......
......@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
#define CATALOG_VERSION_NO 202104211
#define CATALOG_VERSION_NO 202104231
#endif
......@@ -10445,72 +10445,72 @@
proargtypes => 'anymultirange int8', prosrc => 'hash_multirange_extended' },
{ oid => '4280', descr => 'int4multirange constructor',
proname => 'int4multirange', proisstrict => 'f',
proname => 'int4multirange',
prorettype => 'int4multirange', proargtypes => '',
prosrc => 'multirange_constructor0' },
{ oid => '4281', descr => 'int4multirange constructor',
proname => 'int4multirange', prorettype => 'int4multirange',
proargtypes => 'int4range', prosrc => 'multirange_constructor1' },
{ oid => '4282', descr => 'int4multirange constructor',
proname => 'int4multirange', provariadic => 'int4range', proisstrict => 'f',
proname => 'int4multirange', provariadic => 'int4range',
prorettype => 'int4multirange', proargtypes => '_int4range',
proallargtypes => '{_int4range}', proargmodes => '{v}',
prosrc => 'multirange_constructor2' },
{ oid => '4283', descr => 'nummultirange constructor',
proname => 'nummultirange', proisstrict => 'f', prorettype => 'nummultirange',
proname => 'nummultirange', prorettype => 'nummultirange',
proargtypes => '', prosrc => 'multirange_constructor0' },
{ oid => '4284', descr => 'nummultirange constructor',
proname => 'nummultirange', prorettype => 'nummultirange',
proargtypes => 'numrange', prosrc => 'multirange_constructor1' },
{ oid => '4285', descr => 'nummultirange constructor',
proname => 'nummultirange', provariadic => 'numrange', proisstrict => 'f',
proname => 'nummultirange', provariadic => 'numrange',
prorettype => 'nummultirange', proargtypes => '_numrange',
proallargtypes => '{_numrange}', proargmodes => '{v}',
prosrc => 'multirange_constructor2' },
{ oid => '4286', descr => 'tsmultirange constructor',
proname => 'tsmultirange', proisstrict => 'f', prorettype => 'tsmultirange',
proname => 'tsmultirange', prorettype => 'tsmultirange',
proargtypes => '', prosrc => 'multirange_constructor0' },
{ oid => '4287', descr => 'tsmultirange constructor',
proname => 'tsmultirange', prorettype => 'tsmultirange',
proargtypes => 'tsrange', prosrc => 'multirange_constructor1' },
{ oid => '4288', descr => 'tsmultirange constructor',
proname => 'tsmultirange', provariadic => 'tsrange', proisstrict => 'f',
proname => 'tsmultirange', provariadic => 'tsrange',
prorettype => 'tsmultirange', proargtypes => '_tsrange',
proallargtypes => '{_tsrange}', proargmodes => '{v}',
prosrc => 'multirange_constructor2' },
{ oid => '4289', descr => 'tstzmultirange constructor',
proname => 'tstzmultirange', proisstrict => 'f',
proname => 'tstzmultirange',
prorettype => 'tstzmultirange', proargtypes => '',
prosrc => 'multirange_constructor0' },
{ oid => '4290', descr => 'tstzmultirange constructor',
proname => 'tstzmultirange', prorettype => 'tstzmultirange',
proargtypes => 'tstzrange', prosrc => 'multirange_constructor1' },
{ oid => '4291', descr => 'tstzmultirange constructor',
proname => 'tstzmultirange', provariadic => 'tstzrange', proisstrict => 'f',
proname => 'tstzmultirange', provariadic => 'tstzrange',
prorettype => 'tstzmultirange', proargtypes => '_tstzrange',
proallargtypes => '{_tstzrange}', proargmodes => '{v}',
prosrc => 'multirange_constructor2' },
{ oid => '4292', descr => 'datemultirange constructor',
proname => 'datemultirange', proisstrict => 'f',
proname => 'datemultirange',
prorettype => 'datemultirange', proargtypes => '',
prosrc => 'multirange_constructor0' },
{ oid => '4293', descr => 'datemultirange constructor',
proname => 'datemultirange', prorettype => 'datemultirange',
proargtypes => 'daterange', prosrc => 'multirange_constructor1' },
{ oid => '4294', descr => 'datemultirange constructor',
proname => 'datemultirange', provariadic => 'daterange', proisstrict => 'f',
proname => 'datemultirange', provariadic => 'daterange',
prorettype => 'datemultirange', proargtypes => '_daterange',
proallargtypes => '{_daterange}', proargmodes => '{v}',
prosrc => 'multirange_constructor2' },
{ oid => '4295', descr => 'int8multirange constructor',
proname => 'int8multirange', proisstrict => 'f',
proname => 'int8multirange',
prorettype => 'int8multirange', proargtypes => '',
prosrc => 'multirange_constructor0' },
{ oid => '4296', descr => 'int8multirange constructor',
proname => 'int8multirange', prorettype => 'int8multirange',
proargtypes => 'int8range', prosrc => 'multirange_constructor1' },
{ oid => '4297', descr => 'int8multirange constructor',
proname => 'int8multirange', provariadic => 'int8range', proisstrict => 'f',
proname => 'int8multirange', provariadic => 'int8range',
prorettype => 'int8multirange', proargtypes => '_int8range',
proallargtypes => '{_int8range}', proargmodes => '{v}',
prosrc => 'multirange_constructor2' },
......
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