Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YSQL] Backport proper overflow checking from PostgreSQL master #588

Open
mbautin opened this issue Nov 15, 2018 · 0 comments
Open

[YSQL] Backport proper overflow checking from PostgreSQL master #588

mbautin opened this issue Nov 15, 2018 · 0 comments
Assignees
Labels
area/ysql Yugabyte SQL (YSQL) kind/bug This issue is a bug priority/medium Medium priority issue
Projects

Comments

@mbautin
Copy link
Collaborator

mbautin commented Nov 15, 2018

Jira Link: DB-4577

$ git log src/include/common/int.h
commit bdf46af748d0f15f257c99bf06e9e25aba6a24f9
Author: Tom Lane tgl@sss.pgh.pa.us
Date: Thu Apr 26 14:47:16 2018 -0400

Post-feature-freeze pgindent run.

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

commit 6d7dc5350042697bbb141a7362649db7fa67bd55
Author: Andres Freund andres@anarazel.de
Date: Wed Feb 14 14:17:28 2018 -0800

Return implementation defined value if pg_$op_s$bit_overflow overflows.

Some older compilers otherwise sometimes complain about undefined
values, even though the return value should not be used in the
overflow case.  We assume that any decent compiler will optimize away
the unnecessary assignment in performance critical cases.

We do not want to restrain the returned value to a specific value,
e.g. 0 or the wrapped-around value, because some fast ways to
implement overflow detecting math do not easily allow for
that (e.g. msvc intrinsics).  As the function documentation already
documents the returned value in case of intrinsics to be
implementation defined, no documentation has to be updated.

Per complaint from Tom Lane and his buildfarm member prairiedog.

Author: Andres Freund
Discussion: https://postgr.es/m/18169.1513958454@sss.pgh.pa.us

commit 9d4649ca49416111aee2c84b7e4441a0b7aa2fac
Author: Bruce Momjian bruce@momjian.us
Date: Tue Jan 2 23:30:12 2018 -0500

Update copyright for 2018

Backpatch-through: certain files through 9.3

commit 11b8f076c02b4ff0230430fb8d82c80acc450c90
Author: Andres Freund andres@anarazel.de
Date: Thu Dec 14 12:33:48 2017 -0800

Fix a number of copy & paste comment errors in common/int.h.

Author: Christoph Berg
Discussion: https://postgr.es/m/20171214082808.GA5775@msg.df7cb.de

commit 4d6ad31257adaf8a51e1c4377d96afa656d9165f
Author: Andres Freund andres@anarazel.de
Date: Sun Oct 29 22:13:54 2017 -0700

Provide overflow safe integer math inline functions.

It's not easy to get signed integer overflow checks correct and
fast. Therefore abstract the necessary infrastructure into a common
header providing addition, subtraction and multiplication for 16, 32,
64 bit signed integers.

The new macros aren't yet used, but a followup commit will convert
several open coded overflow checks.

Author: Andres Freund, with some code stolen from Greg Stark
Reviewed-By: Robert Haas
Discussion: https://postgr.es/m/20171024103954.ztmatprlglz3rwke@alap3.anarazel.de

dev-server-mbautin-4cpu-15gb-1:~/code/postgres [master ↓·522|✔]
01:00 $ git log src/include/common/int.h
commit bdf46af748d0f15f257c99bf06e9e25aba6a24f9
Author: Tom Lane tgl@sss.pgh.pa.us
Date: Thu Apr 26 14:47:16 2018 -0400

Post-feature-freeze pgindent run.

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

commit 6d7dc5350042697bbb141a7362649db7fa67bd55
Author: Andres Freund andres@anarazel.de
Date: Wed Feb 14 14:17:28 2018 -0800

Return implementation defined value if pg_$op_s$bit_overflow overflows.

Some older compilers otherwise sometimes complain about undefined
values, even though the return value should not be used in the
overflow case.  We assume that any decent compiler will optimize away
the unnecessary assignment in performance critical cases.

We do not want to restrain the returned value to a specific value,
e.g. 0 or the wrapped-around value, because some fast ways to
implement overflow detecting math do not easily allow for
that (e.g. msvc intrinsics).  As the function documentation already
documents the returned value in case of intrinsics to be
implementation defined, no documentation has to be updated.

Per complaint from Tom Lane and his buildfarm member prairiedog.

Author: Andres Freund
Discussion: https://postgr.es/m/18169.1513958454@sss.pgh.pa.us

commit 9d4649ca49416111aee2c84b7e4441a0b7aa2fac
Author: Bruce Momjian bruce@momjian.us
Date: Tue Jan 2 23:30:12 2018 -0500

Update copyright for 2018

Backpatch-through: certain files through 9.3

commit 11b8f076c02b4ff0230430fb8d82c80acc450c90
Author: Andres Freund andres@anarazel.de
Date: Thu Dec 14 12:33:48 2017 -0800

Fix a number of copy & paste comment errors in common/int.h.

Author: Christoph Berg
Discussion: https://postgr.es/m/20171214082808.GA5775@msg.df7cb.de

commit 4d6ad31257adaf8a51e1c4377d96afa656d9165f
Author: Andres Freund andres@anarazel.de
Date: Sun Oct 29 22:13:54 2017 -0700

Provide overflow safe integer math inline functions.

It's not easy to get signed integer overflow checks correct and
fast. Therefore abstract the necessary infrastructure into a common
header providing addition, subtraction and multiplication for 16, 32,
64 bit signed integers.

The new macros aren't yet used, but a followup commit will convert
several open coded overflow checks.

Author: Andres Freund, with some code stolen from Greg Stark
Reviewed-By: Robert Haas
Discussion: https://postgr.es/m/20171024103954.ztmatprlglz3rwke@alap3.anarazel.de
@mbautin mbautin added the kind/bug This issue is a bug label Nov 15, 2018
@mbautin mbautin self-assigned this Nov 15, 2018
@mbautin mbautin added this to To do in YSQL via automation Nov 15, 2018
@ndeodhar ndeodhar moved this from To do to Backlog in YSQL Aug 5, 2020
@rthallamko3 rthallamko3 added the area/ysql Yugabyte SQL (YSQL) label Dec 29, 2022
@yugabyte-ci yugabyte-ci added the priority/medium Medium priority issue label Dec 29, 2022
@yugabyte-ci yugabyte-ci added status/awaiting-triage Issue awaiting triage and removed status/awaiting-triage Issue awaiting triage labels Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ysql Yugabyte SQL (YSQL) kind/bug This issue is a bug priority/medium Medium priority issue
Projects
Status: No status
YSQL
  
Backlog
Development

No branches or pull requests

3 participants