mirror of
https://github.com/postgres/postgres.git
synced 2025-11-16 15:02:33 +03:00
Convert the arithmetic for shared memory size calculation from 'int'
to 'Size' (that is, size_t), and install overflow detection checks in it. This allows us to remove the former arbitrary restrictions on NBuffers etc. It won't make any difference in a 32-bit machine, but in a 64-bit machine you could theoretically have terabytes of shared buffers. (How efficiently we could manage 'em remains to be seen.) Similarly, num_temp_buffers, work_mem, and maintenance_work_mem can be set above 2Gb on a 64-bit machine. Original patch from Koichi Suzuki, additional work by moi.
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.28 2005/04/28 21:47:15 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.29 2005/08/20 23:26:24 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -129,17 +129,18 @@ NumLWLocks(void)
|
||||
/*
|
||||
* Compute shmem space needed for LWLocks.
|
||||
*/
|
||||
int
|
||||
Size
|
||||
LWLockShmemSize(void)
|
||||
{
|
||||
Size size;
|
||||
int numLocks = NumLWLocks();
|
||||
uint32 spaceLocks;
|
||||
|
||||
/* Allocate the LWLocks plus space for shared allocation counter. */
|
||||
spaceLocks = numLocks * sizeof(LWLock) + 2 * sizeof(int);
|
||||
spaceLocks = MAXALIGN(spaceLocks);
|
||||
size = mul_size(numLocks, sizeof(LWLock));
|
||||
|
||||
return (int) spaceLocks;
|
||||
size = add_size(size, 2 * sizeof(int));
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +151,7 @@ void
|
||||
CreateLWLocks(void)
|
||||
{
|
||||
int numLocks = NumLWLocks();
|
||||
uint32 spaceLocks = LWLockShmemSize();
|
||||
Size spaceLocks = LWLockShmemSize();
|
||||
LWLock *lock;
|
||||
int id;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user