pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Tidy up GetMultiXactIdMembers()'s behavior on error
6+ messages / 1 participants
[nested] [flat]

* pgsql: Tidy up GetMultiXactIdMembers()'s behavior on error
@ 2021-06-17 12:57 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 6+ messages in thread

From: Heikki Linnakangas @ 2021-06-17 12:57 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Tidy up GetMultiXactIdMembers()'s behavior on error

One of the error paths left *members uninitialized. That's not a live
bug, because most callers don't look at *members when the function
returns -1, but let's be tidy. One caller, in heap_lock_tuple(), does
"if (members != NULL) pfree(members)", but AFAICS it never passes an
invalid 'multi' value so it should not reach that error case.

The callers are also a bit inconsistent in their expectations.
heap_lock_tuple() pfrees the 'members' array if it's not-NULL, others
pfree() it if "nmembers >= 0", and others if "nmembers > 0". That's
not a live bug either, because the function should never return 0, but
add an Assert for that to make it more clear. I left the callers alone
for now.

I also moved the line where we set *nmembers. It wasn't wrong before,
but I like to do that right next to the 'return' statement, to make it
clear that it's always set on return.

Also remove one unreachable return statement after ereport(ERROR), for
brevity and for consistency with the similar if-block right after it.

Author: Greg Nancarrow with the additional changes by me
Backpatch-through: 9.6, all supported versions

Branch
------
master

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

Modified Files
--------------
src/backend/access/transam/multixact.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)



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

* pgsql: Tidy up GetMultiXactIdMembers()'s behavior on error
@ 2021-06-17 12:57 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 6+ messages in thread

From: Heikki Linnakangas @ 2021-06-17 12:57 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Tidy up GetMultiXactIdMembers()'s behavior on error

One of the error paths left *members uninitialized. That's not a live
bug, because most callers don't look at *members when the function
returns -1, but let's be tidy. One caller, in heap_lock_tuple(), does
"if (members != NULL) pfree(members)", but AFAICS it never passes an
invalid 'multi' value so it should not reach that error case.

The callers are also a bit inconsistent in their expectations.
heap_lock_tuple() pfrees the 'members' array if it's not-NULL, others
pfree() it if "nmembers >= 0", and others if "nmembers > 0". That's
not a live bug either, because the function should never return 0, but
add an Assert for that to make it more clear. I left the callers alone
for now.

I also moved the line where we set *nmembers. It wasn't wrong before,
but I like to do that right next to the 'return' statement, to make it
clear that it's always set on return.

Also remove one unreachable return statement after ereport(ERROR), for
brevity and for consistency with the similar if-block right after it.

Author: Greg Nancarrow with the additional changes by me
Backpatch-through: 9.6, all supported versions

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/42f782be916807121fcce20811892c0bad95fca3

Modified Files
--------------
src/backend/access/transam/multixact.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)



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

* pgsql: Tidy up GetMultiXactIdMembers()'s behavior on error
@ 2021-06-17 12:57 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 6+ messages in thread

From: Heikki Linnakangas @ 2021-06-17 12:57 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Tidy up GetMultiXactIdMembers()'s behavior on error

One of the error paths left *members uninitialized. That's not a live
bug, because most callers don't look at *members when the function
returns -1, but let's be tidy. One caller, in heap_lock_tuple(), does
"if (members != NULL) pfree(members)", but AFAICS it never passes an
invalid 'multi' value so it should not reach that error case.

The callers are also a bit inconsistent in their expectations.
heap_lock_tuple() pfrees the 'members' array if it's not-NULL, others
pfree() it if "nmembers >= 0", and others if "nmembers > 0". That's
not a live bug either, because the function should never return 0, but
add an Assert for that to make it more clear. I left the callers alone
for now.

I also moved the line where we set *nmembers. It wasn't wrong before,
but I like to do that right next to the 'return' statement, to make it
clear that it's always set on return.

Also remove one unreachable return statement after ereport(ERROR), for
brevity and for consistency with the similar if-block right after it.

Author: Greg Nancarrow with the additional changes by me
Backpatch-through: 9.6, all supported versions

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6765cbd22a6bf1d11f4293fe7daed7512fb54ecf

Modified Files
--------------
src/backend/access/transam/multixact.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)



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

* pgsql: Tidy up GetMultiXactIdMembers()'s behavior on error
@ 2021-06-17 12:57 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 6+ messages in thread

From: Heikki Linnakangas @ 2021-06-17 12:57 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Tidy up GetMultiXactIdMembers()'s behavior on error

One of the error paths left *members uninitialized. That's not a live
bug, because most callers don't look at *members when the function
returns -1, but let's be tidy. One caller, in heap_lock_tuple(), does
"if (members != NULL) pfree(members)", but AFAICS it never passes an
invalid 'multi' value so it should not reach that error case.

The callers are also a bit inconsistent in their expectations.
heap_lock_tuple() pfrees the 'members' array if it's not-NULL, others
pfree() it if "nmembers >= 0", and others if "nmembers > 0". That's
not a live bug either, because the function should never return 0, but
add an Assert for that to make it more clear. I left the callers alone
for now.

I also moved the line where we set *nmembers. It wasn't wrong before,
but I like to do that right next to the 'return' statement, to make it
clear that it's always set on return.

Also remove one unreachable return statement after ereport(ERROR), for
brevity and for consistency with the similar if-block right after it.

Author: Greg Nancarrow with the additional changes by me
Backpatch-through: 9.6, all supported versions

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/25c171f322747eaed037a1ed1777eb7624c1c976

Modified Files
--------------
src/backend/access/transam/multixact.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)



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

* pgsql: Tidy up GetMultiXactIdMembers()'s behavior on error
@ 2021-06-17 12:57 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 6+ messages in thread

From: Heikki Linnakangas @ 2021-06-17 12:57 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Tidy up GetMultiXactIdMembers()'s behavior on error

One of the error paths left *members uninitialized. That's not a live
bug, because most callers don't look at *members when the function
returns -1, but let's be tidy. One caller, in heap_lock_tuple(), does
"if (members != NULL) pfree(members)", but AFAICS it never passes an
invalid 'multi' value so it should not reach that error case.

The callers are also a bit inconsistent in their expectations.
heap_lock_tuple() pfrees the 'members' array if it's not-NULL, others
pfree() it if "nmembers >= 0", and others if "nmembers > 0". That's
not a live bug either, because the function should never return 0, but
add an Assert for that to make it more clear. I left the callers alone
for now.

I also moved the line where we set *nmembers. It wasn't wrong before,
but I like to do that right next to the 'return' statement, to make it
clear that it's always set on return.

Also remove one unreachable return statement after ereport(ERROR), for
brevity and for consistency with the similar if-block right after it.

Author: Greg Nancarrow with the additional changes by me
Backpatch-through: 9.6, all supported versions

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/7ecdc7b675432ac473e64c559e52c53b59b6c159

Modified Files
--------------
src/backend/access/transam/multixact.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)



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

* pgsql: Tidy up GetMultiXactIdMembers()'s behavior on error
@ 2021-06-17 12:57 Heikki Linnakangas <heikki.linnakangas@iki.fi>
  0 siblings, 0 replies; 6+ messages in thread

From: Heikki Linnakangas @ 2021-06-17 12:57 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Tidy up GetMultiXactIdMembers()'s behavior on error

One of the error paths left *members uninitialized. That's not a live
bug, because most callers don't look at *members when the function
returns -1, but let's be tidy. One caller, in heap_lock_tuple(), does
"if (members != NULL) pfree(members)", but AFAICS it never passes an
invalid 'multi' value so it should not reach that error case.

The callers are also a bit inconsistent in their expectations.
heap_lock_tuple() pfrees the 'members' array if it's not-NULL, others
pfree() it if "nmembers >= 0", and others if "nmembers > 0". That's
not a live bug either, because the function should never return 0, but
add an Assert for that to make it more clear. I left the callers alone
for now.

I also moved the line where we set *nmembers. It wasn't wrong before,
but I like to do that right next to the 'return' statement, to make it
clear that it's always set on return.

Also remove one unreachable return statement after ereport(ERROR), for
brevity and for consistency with the similar if-block right after it.

Author: Greg Nancarrow with the additional changes by me
Backpatch-through: 9.6, all supported versions

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/009ee51af7fd6a8dd9c518f2e6d62a4f139c766a

Modified Files
--------------
src/backend/access/transam/multixact.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)



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


end of thread, other threads:[~2021-06-17 12:57 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-06-17 12:57 pgsql: Tidy up GetMultiXactIdMembers()'s behavior on error Heikki Linnakangas <heikki.linnakangas@iki.fi>
2021-06-17 12:57 pgsql: Tidy up GetMultiXactIdMembers()'s behavior on error Heikki Linnakangas <heikki.linnakangas@iki.fi>
2021-06-17 12:57 pgsql: Tidy up GetMultiXactIdMembers()'s behavior on error Heikki Linnakangas <heikki.linnakangas@iki.fi>
2021-06-17 12:57 pgsql: Tidy up GetMultiXactIdMembers()'s behavior on error Heikki Linnakangas <heikki.linnakangas@iki.fi>
2021-06-17 12:57 pgsql: Tidy up GetMultiXactIdMembers()'s behavior on error Heikki Linnakangas <heikki.linnakangas@iki.fi>
2021-06-17 12:57 pgsql: Tidy up GetMultiXactIdMembers()'s behavior on error Heikki Linnakangas <heikki.linnakangas@iki.fi>

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