Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5ce851d

Browse files
committed
Reduce default file size limit to 1Gb, and move the
configuration constant to config.h.
1 parent 9cae93d commit 5ce851d

File tree

2 files changed

+23
-29
lines changed

2 files changed

+23
-29
lines changed

src/backend/storage/smgr/md.c

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.41 1999/02/13 23:18:35 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.42 1999/04/05 22:25:11 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -33,10 +33,11 @@
3333
* The magnetic disk storage manager keeps track of open file descriptors
3434
* in its own descriptor pool. This happens for two reasons. First, at
3535
* transaction boundaries, we walk the list of descriptors and flush
36-
* anything that we've dirtied in the current transaction. Second, we
37-
* have to support relations of > 4GBytes. In order to do this, we break
38-
* relations up into chunks of < 2GBytes and store one chunk in each of
39-
* several files that represent the relation.
36+
* anything that we've dirtied in the current transaction. Second, we want
37+
* to support relations larger than the OS' file size limit (often 2GBytes).
38+
* In order to do that, we break relations up into chunks of < 2GBytes
39+
* and store one chunk in each of several files that represent the relation.
40+
* See the BLCKSZ and RELSEG_SIZE configuration constants in include/config.h.
4041
*/
4142

4243
typedef struct _MdfdVec
@@ -59,30 +60,6 @@ static MemoryContext MdCxt;
5960
#define MDFD_DIRTY (uint16) 0x01
6061
#define MDFD_FREE (uint16) 0x02
6162

62-
/*
63-
* RELSEG_SIZE appears to be the number of segments that can
64-
* be in a disk file. It was defined as 262144 based on 8k
65-
* blocks, but now that the block size can be changed, this
66-
* has to be calculated at compile time. Otherwise, the file
67-
* size limit would not work out to 2-gig (2147483648).
68-
*
69-
* The number needs to be (2 ** 31) / BLCKSZ, but to be keep
70-
* the math under MAXINT, pre-divide by 256 and use ...
71-
*
72-
* (((2 ** 23) / BLCKSZ) * (2 ** 8))
73-
*
74-
* 07 Jan 98 darrenk
75-
*
76-
* Now possibly let the OS handle it...
77-
*
78-
* 19 Mar 98 darrenk
79-
*
80-
*/
81-
82-
#ifndef LET_OS_MANAGE_FILESIZE
83-
#define RELSEG_SIZE ((8388608 / BLCKSZ) * 256)
84-
#endif
85-
8663
/* routines declared here */
8764
static MdfdVec *_mdfd_openseg(Relation reln, int segno, int oflags);
8865
static MdfdVec *_mdfd_getseg(Relation reln, int blkno, int oflag);

src/include/config.h.in

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,23 @@
2727
*/
2828
#define BLCKSZ 8192
2929

30+
/*
31+
* RELSEG_SIZE is the maximum number of blocks allowed in one disk file.
32+
* Thus, the maximum size of a single file is RELSEG_SIZE * BLCKSZ;
33+
* relations bigger than that are divided into multiple files.
34+
*
35+
* CAUTION: RELSEG_SIZE * BLCKSZ must be less than your OS' limit on file size.
36+
* This is typically 2Gb or 4Gb in a 32-bit operating system. By default,
37+
* we make the limit one billion bytes to avoid any possible integer-overflow
38+
* problems within the OS. A limit smaller than necessary only means we
39+
* divide a large relation into more chunks than necessary, so it seems best
40+
* to err in the direction of a small limit.
41+
*
42+
* CAUTION: you had best do an initdb if you change either BLCKSZ or
43+
* RELSEG_SIZE.
44+
*/
45+
#define RELSEG_SIZE (1000000000 / BLCKSZ)
46+
3047
/*
3148
* The following is set using configure.
3249
*/

0 commit comments

Comments
 (0)