postgresql/src/include/nodes
Tomas Vondra f2369bc610 Use Size instead of int64 to track allocated memory
Commit 5dd7fc1519 added block-level memory accounting, but used int64 variable to
track the amount of allocated memory. That is incorrect, because we have Size for
exactly these purposes, but it was mostly harmless until c477f3e449 which changed
how we handle with repalloc() when downsizing the chunk. Previously we've ignored
these cases and just kept using the original chunk, but now we need to update the
accounting, and the code was doing this:

    context->mem_allocated += blksize - oldblksize;

Both blksize and oldblksize are Size (so unsigned) which means the subtraction
underflows, producing a very high positive value. On 64-bit platforms (where Size
has the same size as mem_alllocated) this happens to work because the result wraps
to the right value, but on (some) 32-bit platforms this fails.

This fixes two things - it changes mem_allocated (and related variables) to Size,
and it splits the update to two separate steps, to prevent any underflows.

Discussion: https://www.postgresql.org/message-id/15151.1570163761%40sss.pgh.pa.us
2019-10-04 16:10:56 +02:00
..
bitmapset.h Add support for multivariate MCV lists 2019-03-27 18:32:18 +01:00
execnodes.h Fix ExprState's tag to be of type NodeTag rather than Node. 2019-09-23 15:28:13 -07:00
extensible.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
lockoptions.h Don't include heapam.h from others headers. 2019-01-14 16:24:41 -08:00
makefuncs.h Fix handling of expressions and predicates in REINDEX CONCURRENTLY 2019-07-29 09:58:49 +09:00
memnodes.h Use Size instead of int64 to track allocated memory 2019-10-04 16:10:56 +02:00
nodeFuncs.h Selectively include window frames in expression walks/mutates. 2019-10-03 10:54:52 +01:00
nodes.h Allow setting statistics target for extended statistics 2019-09-11 00:25:51 +02:00
params.h Refactor ParamListInfo initialization 2019-03-14 13:30:09 +01:00
parsenodes.h Fix under-parenthesized macro definitions 2019-09-13 16:26:55 -03:00
pathnodes.h Remove fmgr.h includes from headers that don't really need it. 2019-08-16 10:35:31 -07:00
pg_list.h Rationalize use of list_concat + list_copy combinations. 2019-08-12 11:20:18 -04:00
plannodes.h Fix representation of hash keys in Hash/HashJoin nodes. 2019-08-02 00:02:46 -07:00
primnodes.h Fix many typos and inconsistencies 2019-07-01 10:00:23 +09:00
print.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
readfuncs.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
replnodes.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
supportnodes.h Allow extensions to generate lossy index conditions. 2019-02-11 21:26:14 -05:00
tidbitmap.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
value.h Update copyright for 2019 2019-01-02 12:44:25 -05:00