pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Do not return NULL for error cases in satisfies_hash_partition()
4+ messages / 1 participants
[nested] [flat]

* pgsql: Do not return NULL for error cases in satisfies_hash_partition()
@ 2020-11-16 21:40  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2020-11-16 21:40 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Do not return NULL for error cases in satisfies_hash_partition().

Since this function is used as a CHECK constraint condition,
returning NULL is tantamount to returning TRUE, which would have the
effect of letting in a row that doesn't satisfy the hash condition.
Admittedly, the cases for which this is done should be unreachable
in practice, but that doesn't make it any less a bad idea.  It also
seems like a dartboard was used to decide which error cases should
throw errors as opposed to returning NULL.

For the checks for NULL input values, I just switched it to returning
false.  There's some argument that an error would be better; but the
case really should be can't-happen in a generated hash constraint,
so it's likely not worth more code for.

For the parent-relation-open-failure case, it seems like we might
as well let relation_open throw an error, instead of having an
impossible-to-diagnose constraint failure.

Back-patch to v11 where this code came in.

Discussion: https://postgr.es/m/24067.1605134819@sss.pgh.pa.us

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/fea5960fafb0002ea2a80bed1dc03e3a4f85fa1d

Modified Files
--------------
src/backend/partitioning/partbounds.c   | 13 ++++++-------
src/test/regress/expected/hash_part.out | 10 +++-------
2 files changed, 9 insertions(+), 14 deletions(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* pgsql: Do not return NULL for error cases in satisfies_hash_partition()
@ 2020-11-16 21:40  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2020-11-16 21:40 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Do not return NULL for error cases in satisfies_hash_partition().

Since this function is used as a CHECK constraint condition,
returning NULL is tantamount to returning TRUE, which would have the
effect of letting in a row that doesn't satisfy the hash condition.
Admittedly, the cases for which this is done should be unreachable
in practice, but that doesn't make it any less a bad idea.  It also
seems like a dartboard was used to decide which error cases should
throw errors as opposed to returning NULL.

For the checks for NULL input values, I just switched it to returning
false.  There's some argument that an error would be better; but the
case really should be can't-happen in a generated hash constraint,
so it's likely not worth more code for.

For the parent-relation-open-failure case, it seems like we might
as well let relation_open throw an error, instead of having an
impossible-to-diagnose constraint failure.

Back-patch to v11 where this code came in.

Discussion: https://postgr.es/m/24067.1605134819@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4025e6c46620048804467d2ad29d31aa9ba50387

Modified Files
--------------
src/backend/partitioning/partbounds.c   | 13 ++++++-------
src/test/regress/expected/hash_part.out | 10 +++-------
2 files changed, 9 insertions(+), 14 deletions(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* pgsql: Do not return NULL for error cases in satisfies_hash_partition()
@ 2020-11-16 21:40  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2020-11-16 21:40 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Do not return NULL for error cases in satisfies_hash_partition().

Since this function is used as a CHECK constraint condition,
returning NULL is tantamount to returning TRUE, which would have the
effect of letting in a row that doesn't satisfy the hash condition.
Admittedly, the cases for which this is done should be unreachable
in practice, but that doesn't make it any less a bad idea.  It also
seems like a dartboard was used to decide which error cases should
throw errors as opposed to returning NULL.

For the checks for NULL input values, I just switched it to returning
false.  There's some argument that an error would be better; but the
case really should be can't-happen in a generated hash constraint,
so it's likely not worth more code for.

For the parent-relation-open-failure case, it seems like we might
as well let relation_open throw an error, instead of having an
impossible-to-diagnose constraint failure.

Back-patch to v11 where this code came in.

Discussion: https://postgr.es/m/24067.1605134819@sss.pgh.pa.us

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/84e31622882358f61e9d3c16c5b4f3187f504a68

Modified Files
--------------
src/backend/partitioning/partbounds.c   | 15 +++++++--------
src/test/regress/expected/hash_part.out | 10 +++-------
2 files changed, 10 insertions(+), 15 deletions(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* pgsql: Do not return NULL for error cases in satisfies_hash_partition()
@ 2020-11-16 21:40  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2020-11-16 21:40 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Do not return NULL for error cases in satisfies_hash_partition().

Since this function is used as a CHECK constraint condition,
returning NULL is tantamount to returning TRUE, which would have the
effect of letting in a row that doesn't satisfy the hash condition.
Admittedly, the cases for which this is done should be unreachable
in practice, but that doesn't make it any less a bad idea.  It also
seems like a dartboard was used to decide which error cases should
throw errors as opposed to returning NULL.

For the checks for NULL input values, I just switched it to returning
false.  There's some argument that an error would be better; but the
case really should be can't-happen in a generated hash constraint,
so it's likely not worth more code for.

For the parent-relation-open-failure case, it seems like we might
as well let relation_open throw an error, instead of having an
impossible-to-diagnose constraint failure.

Back-patch to v11 where this code came in.

Discussion: https://postgr.es/m/24067.1605134819@sss.pgh.pa.us

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/54a94064407375ac3c108e1b791303a42baf030a

Modified Files
--------------
src/backend/partitioning/partbounds.c   | 15 +++++++--------
src/test/regress/expected/hash_part.out | 10 +++-------
2 files changed, 10 insertions(+), 15 deletions(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2020-11-16 21:40 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-11-16 21:40 pgsql: Do not return NULL for error cases in satisfies_hash_partition() Tom Lane <tgl@sss.pgh.pa.us>
2020-11-16 21:40 pgsql: Do not return NULL for error cases in satisfies_hash_partition() Tom Lane <tgl@sss.pgh.pa.us>
2020-11-16 21:40 pgsql: Do not return NULL for error cases in satisfies_hash_partition() Tom Lane <tgl@sss.pgh.pa.us>
2020-11-16 21:40 pgsql: Do not return NULL for error cases in satisfies_hash_partition() Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox