Skip to content

Commit 6bbcff0

Browse files
committed
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
1 parent 3f20d5f commit 6bbcff0

File tree

4 files changed

+28
-27
lines changed

4 files changed

+28
-27
lines changed

src/backend/commands/typecmds.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,7 +1844,7 @@ makeMultirangeConstructors(const char *name, Oid namespace,
18441844
PROKIND_FUNCTION,
18451845
false, /* security_definer */
18461846
false, /* leakproof */
1847-
false, /* isStrict */
1847+
true, /* isStrict */
18481848
PROVOLATILE_IMMUTABLE, /* volatility */
18491849
PROPARALLEL_SAFE, /* parallel safety */
18501850
argtypes, /* parameterTypes */
@@ -1929,7 +1929,7 @@ makeMultirangeConstructors(const char *name, Oid namespace,
19291929
PROKIND_FUNCTION,
19301930
false, /* security_definer */
19311931
false, /* leakproof */
1932-
false, /* isStrict */
1932+
true, /* isStrict */
19331933
PROVOLATILE_IMMUTABLE, /* volatility */
19341934
PROPARALLEL_SAFE, /* parallel safety */
19351935
argtypes, /* parameterTypes */

src/backend/utils/adt/multirangetypes.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,15 @@ multirange_in(PG_FUNCTION_ARGS)
216216
parse_state = MULTIRANGE_IN_RANGE_QUOTED;
217217
else if (ch == '\\')
218218
parse_state = MULTIRANGE_IN_RANGE_ESCAPED;
219+
219220
/*
220221
* We will include this character into range_str once we
221222
* find the end of the range value.
222223
*/
223224
}
224225
break;
225226
case MULTIRANGE_IN_RANGE_ESCAPED:
227+
226228
/*
227229
* We will include this character into range_str once we find
228230
* the end of the range value.
@@ -242,8 +244,8 @@ multirange_in(PG_FUNCTION_ARGS)
242244
parse_state = MULTIRANGE_IN_RANGE_QUOTED_ESCAPED;
243245

244246
/*
245-
* We will include this character into range_str once we
246-
* find the end of the range value.
247+
* We will include this character into range_str once we find
248+
* the end of the range value.
247249
*/
248250
break;
249251
case MULTIRANGE_AFTER_RANGE:
@@ -259,6 +261,7 @@ multirange_in(PG_FUNCTION_ARGS)
259261
errdetail("Expected comma or end of multirange.")));
260262
break;
261263
case MULTIRANGE_IN_RANGE_QUOTED_ESCAPED:
264+
262265
/*
263266
* We will include this character into range_str once we find
264267
* the end of the range value.
@@ -951,14 +954,13 @@ multirange_constructor2(PG_FUNCTION_ARGS)
951954
PG_RETURN_MULTIRANGE_P(make_multirange(mltrngtypid, rangetyp, 0, NULL));
952955

953956
/*
954-
* These checks should be guaranteed by our signature, but let's do them
955-
* just in case.
957+
* This check should be guaranteed by our signature, but let's do it just
958+
* in case.
956959
*/
957960

958961
if (PG_ARGISNULL(0))
959-
ereport(ERROR,
960-
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
961-
errmsg("multirange values cannot contain NULL members")));
962+
elog(ERROR,
963+
"multirange values cannot contain NULL members");
962964

963965
rangeArray = PG_GETARG_ARRAYTYPE_P(0);
964966

@@ -1022,14 +1024,13 @@ multirange_constructor1(PG_FUNCTION_ARGS)
10221024
rangetyp = typcache->rngtype;
10231025

10241026
/*
1025-
* These checks should be guaranteed by our signature, but let's do them
1026-
* just in case.
1027+
* This check should be guaranteed by our signature, but let's do it just
1028+
* in case.
10271029
*/
10281030

10291031
if (PG_ARGISNULL(0))
1030-
ereport(ERROR,
1031-
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
1032-
errmsg("multirange values cannot contain NULL members")));
1032+
elog(ERROR,
1033+
"multirange values cannot contain NULL members");
10331034

10341035
range = PG_GETARG_RANGE_P(0);
10351036

src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/* yyyymmddN */
56-
#define CATALOG_VERSION_NO 202104211
56+
#define CATALOG_VERSION_NO 202104231
5757

5858
#endif

src/include/catalog/pg_proc.dat

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10445,72 +10445,72 @@
1044510445
proargtypes => 'anymultirange int8', prosrc => 'hash_multirange_extended' },
1044610446

1044710447
{ oid => '4280', descr => 'int4multirange constructor',
10448-
proname => 'int4multirange', proisstrict => 'f',
10448+
proname => 'int4multirange',
1044910449
prorettype => 'int4multirange', proargtypes => '',
1045010450
prosrc => 'multirange_constructor0' },
1045110451
{ oid => '4281', descr => 'int4multirange constructor',
1045210452
proname => 'int4multirange', prorettype => 'int4multirange',
1045310453
proargtypes => 'int4range', prosrc => 'multirange_constructor1' },
1045410454
{ oid => '4282', descr => 'int4multirange constructor',
10455-
proname => 'int4multirange', provariadic => 'int4range', proisstrict => 'f',
10455+
proname => 'int4multirange', provariadic => 'int4range',
1045610456
prorettype => 'int4multirange', proargtypes => '_int4range',
1045710457
proallargtypes => '{_int4range}', proargmodes => '{v}',
1045810458
prosrc => 'multirange_constructor2' },
1045910459
{ oid => '4283', descr => 'nummultirange constructor',
10460-
proname => 'nummultirange', proisstrict => 'f', prorettype => 'nummultirange',
10460+
proname => 'nummultirange', prorettype => 'nummultirange',
1046110461
proargtypes => '', prosrc => 'multirange_constructor0' },
1046210462
{ oid => '4284', descr => 'nummultirange constructor',
1046310463
proname => 'nummultirange', prorettype => 'nummultirange',
1046410464
proargtypes => 'numrange', prosrc => 'multirange_constructor1' },
1046510465
{ oid => '4285', descr => 'nummultirange constructor',
10466-
proname => 'nummultirange', provariadic => 'numrange', proisstrict => 'f',
10466+
proname => 'nummultirange', provariadic => 'numrange',
1046710467
prorettype => 'nummultirange', proargtypes => '_numrange',
1046810468
proallargtypes => '{_numrange}', proargmodes => '{v}',
1046910469
prosrc => 'multirange_constructor2' },
1047010470
{ oid => '4286', descr => 'tsmultirange constructor',
10471-
proname => 'tsmultirange', proisstrict => 'f', prorettype => 'tsmultirange',
10471+
proname => 'tsmultirange', prorettype => 'tsmultirange',
1047210472
proargtypes => '', prosrc => 'multirange_constructor0' },
1047310473
{ oid => '4287', descr => 'tsmultirange constructor',
1047410474
proname => 'tsmultirange', prorettype => 'tsmultirange',
1047510475
proargtypes => 'tsrange', prosrc => 'multirange_constructor1' },
1047610476
{ oid => '4288', descr => 'tsmultirange constructor',
10477-
proname => 'tsmultirange', provariadic => 'tsrange', proisstrict => 'f',
10477+
proname => 'tsmultirange', provariadic => 'tsrange',
1047810478
prorettype => 'tsmultirange', proargtypes => '_tsrange',
1047910479
proallargtypes => '{_tsrange}', proargmodes => '{v}',
1048010480
prosrc => 'multirange_constructor2' },
1048110481
{ oid => '4289', descr => 'tstzmultirange constructor',
10482-
proname => 'tstzmultirange', proisstrict => 'f',
10482+
proname => 'tstzmultirange',
1048310483
prorettype => 'tstzmultirange', proargtypes => '',
1048410484
prosrc => 'multirange_constructor0' },
1048510485
{ oid => '4290', descr => 'tstzmultirange constructor',
1048610486
proname => 'tstzmultirange', prorettype => 'tstzmultirange',
1048710487
proargtypes => 'tstzrange', prosrc => 'multirange_constructor1' },
1048810488
{ oid => '4291', descr => 'tstzmultirange constructor',
10489-
proname => 'tstzmultirange', provariadic => 'tstzrange', proisstrict => 'f',
10489+
proname => 'tstzmultirange', provariadic => 'tstzrange',
1049010490
prorettype => 'tstzmultirange', proargtypes => '_tstzrange',
1049110491
proallargtypes => '{_tstzrange}', proargmodes => '{v}',
1049210492
prosrc => 'multirange_constructor2' },
1049310493
{ oid => '4292', descr => 'datemultirange constructor',
10494-
proname => 'datemultirange', proisstrict => 'f',
10494+
proname => 'datemultirange',
1049510495
prorettype => 'datemultirange', proargtypes => '',
1049610496
prosrc => 'multirange_constructor0' },
1049710497
{ oid => '4293', descr => 'datemultirange constructor',
1049810498
proname => 'datemultirange', prorettype => 'datemultirange',
1049910499
proargtypes => 'daterange', prosrc => 'multirange_constructor1' },
1050010500
{ oid => '4294', descr => 'datemultirange constructor',
10501-
proname => 'datemultirange', provariadic => 'daterange', proisstrict => 'f',
10501+
proname => 'datemultirange', provariadic => 'daterange',
1050210502
prorettype => 'datemultirange', proargtypes => '_daterange',
1050310503
proallargtypes => '{_daterange}', proargmodes => '{v}',
1050410504
prosrc => 'multirange_constructor2' },
1050510505
{ oid => '4295', descr => 'int8multirange constructor',
10506-
proname => 'int8multirange', proisstrict => 'f',
10506+
proname => 'int8multirange',
1050710507
prorettype => 'int8multirange', proargtypes => '',
1050810508
prosrc => 'multirange_constructor0' },
1050910509
{ oid => '4296', descr => 'int8multirange constructor',
1051010510
proname => 'int8multirange', prorettype => 'int8multirange',
1051110511
proargtypes => 'int8range', prosrc => 'multirange_constructor1' },
1051210512
{ oid => '4297', descr => 'int8multirange constructor',
10513-
proname => 'int8multirange', provariadic => 'int8range', proisstrict => 'f',
10513+
proname => 'int8multirange', provariadic => 'int8range',
1051410514
prorettype => 'int8multirange', proargtypes => '_int8range',
1051510515
proallargtypes => '{_int8range}', proargmodes => '{v}',
1051610516
prosrc => 'multirange_constructor2' },

0 commit comments

Comments
 (0)