Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0224177

Browse files
committed
TOAST mop-up work: update comments for tuple-size-related symbols such
as MaxHeapAttributeNumber. Increase MaxAttrSize to something morereasonable (given what it's used for, namely checking char(n) declarations,I didn't make it the full 1G that it could theoretically be --- 10Mbseemed a more reasonable number). Improve calculation of MaxTupleSize.
1 parentd2165a4 commit0224177

File tree

8 files changed

+93
-60
lines changed

8 files changed

+93
-60
lines changed

‎src/backend/parser/gram.y

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.183 2000/08/0706:54:51 thomas Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.184 2000/08/0720:16:13 tgl Exp $
1515
*
1616
* HISTORY
1717
* AUTHORDATEMAJOR EVENT
@@ -4153,10 +4153,11 @@ Bit: bit '(' Iconst ')'
41534153
$$ = makeNode(TypeName);
41544154
$$->name =$1;
41554155
if ($3 <1)
4156-
elog(ERROR,"length for type '%s' must be at least 1",$1);
4157-
elseif ($3 > (MaxAttrSize *sizeof(char)))
4158-
elog(ERROR,"length for type '%s' cannot exceed %ld",$1,
4159-
(MaxAttrSize *sizeof(char)));
4156+
elog(ERROR,"length for type '%s' must be at least 1",
4157+
$1);
4158+
elseif ($3 > (MaxAttrSize * BITSPERBYTE))
4159+
elog(ERROR,"length for type '%s' cannot exceed %d",
4160+
$1, (MaxAttrSize * BITSPERBYTE));
41604161
$$->typmod =$3;
41614162
}
41624163
|bit
@@ -4187,10 +4188,11 @@ Character: character '(' Iconst ')'
41874188
$$ = makeNode(TypeName);
41884189
$$->name =$1;
41894190
if ($3 <1)
4190-
elog(ERROR,"length for type '%s' must be at least 1",$1);
4191+
elog(ERROR,"length for type '%s' must be at least 1",
4192+
$1);
41914193
elseif ($3 > MaxAttrSize)
4192-
elog(ERROR,"length for type '%s' cannot exceed %ld",$1,
4193-
MaxAttrSize);
4194+
elog(ERROR,"length for type '%s' cannot exceed %d",
4195+
$1,MaxAttrSize);
41944196

41954197
/* we actually implement these like a varlen, so
41964198
* the first 4 bytes is the length. (the difference

‎src/backend/utils/adt/varbit.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Functions for the built-in type bit() and varying bit().
55
*
66
* IDENTIFICATION
7-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.6 2000/07/28 02:13:31 tgl Exp $
7+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.7 2000/08/07 20:15:37 tgl Exp $
88
*
99
*-------------------------------------------------------------------------
1010
*/
@@ -107,7 +107,7 @@ zpbit_in(char *s, int dummy, int32 atttypmod)
107107

108108
if (len>MaxAttrSize)
109109
elog(ERROR,"zpbit_in: length of bit() must be less than %ld",
110-
(MaxAttrSize-VARHDRSZ-VARBITHDRSZ)*BITSPERBYTE);
110+
(long) ((MaxAttrSize-VARHDRSZ-VARBITHDRSZ)*BITSPERBYTE));
111111

112112
result= (bits8*)palloc(len);
113113
/* set to 0 so that *r is always initialised and strin is zero-padded */
@@ -338,7 +338,7 @@ varbit_in(char *s, int dummy, int32 atttypmod)
338338

339339
if (len>MaxAttrSize)
340340
elog(ERROR,"varbit_in: length of bit() must be less than %ld",
341-
(MaxAttrSize-VARHDRSZ-VARBITHDRSZ)*BITSPERBYTE);
341+
(long) ((MaxAttrSize-VARHDRSZ-VARBITHDRSZ)*BITSPERBYTE));
342342

343343
result= (bits8*)palloc(len);
344344
/* set to 0 so that *r is always initialised and strin is zero-padded */

‎src/include/access/htup.h

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: htup.h,v 1.33 2000/07/04 01:49:43 vadim Exp $
10+
* $Id: htup.h,v 1.34 2000/08/07 20:15:40 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -18,8 +18,16 @@
1818

1919
#defineMinHeapTupleBitmapSize32/* 8 * 4 */
2020

21-
/* check these, they are likely to be more severely limited by t_hoff */
22-
21+
/*
22+
* MaxHeapAttributeNumber limits the number of (user) columns in a table.
23+
* The key limit on this value is that the size of the fixed overhead for
24+
* a tuple, plus the size of the null-values bitmap (at 1 bit per column),
25+
* plus MAXALIGN alignment, must fit into t_hoff which is uint8. On most
26+
* machines the absolute upper limit without making t_hoff wider would be
27+
* about 1700. Note, however, that depending on column data types you will
28+
* likely also be running into the disk-block-based limit on overall tuple
29+
* size if you have more than a thousand or so columns. TOAST won't help.
30+
*/
2331
#defineMaxHeapAttributeNumber1600/* 8 * 200 */
2432

2533
/*
@@ -130,13 +138,32 @@ typedef struct xl_heap_move
130138

131139
#endif/* XLOG */
132140

133-
#defineMinTupleSize(MAXALIGN(sizeof (PageHeaderData)) + \
134-
MAXALIGN(sizeof(HeapTupleHeaderData)) + \
135-
MAXALIGN(sizeof(char)))
136141

137-
#defineMaxTupleSize(BLCKSZ - MinTupleSize)
142+
/*
143+
* MaxTupleSize is the maximum allowed size of a tuple, including header and
144+
* MAXALIGN alignment padding. Basically it's BLCKSZ minus the other stuff
145+
* that has to be on a disk page. The "other stuff" includes access-method-
146+
* dependent "special space", which we assume will be no more than
147+
* MaxSpecialSpace bytes (currently, on heap pages it's actually zero).
148+
*
149+
* NOTE: we do not need to count an ItemId for the tuple because
150+
* sizeof(PageHeaderData) includes the first ItemId on the page.
151+
*/
152+
#defineMaxSpecialSpace 32
153+
154+
#defineMaxTupleSize\
155+
(BLCKSZ - MAXALIGN(sizeof(PageHeaderData) + MaxSpecialSpace))
156+
157+
158+
/*
159+
* MaxAttrSize is a somewhat arbitrary upper limit on the declared size of
160+
* data fields of char(n) and similar types. It need not have anything
161+
* directly to do with the *actual* upper limit of varlena values, which
162+
* is currently 1Gb (see struct varattrib in postgres.h). I've set it
163+
* at 10Mb which seems like a reasonable number --- tgl 8/6/00.
164+
*/
165+
#defineMaxAttrSize(10 * 1024 * 1024)
138166

139-
#defineMaxAttrSize(MaxTupleSize - MAXALIGN(sizeof(HeapTupleHeaderData)))
140167

141168
#defineSelfItemPointerAttributeNumber(-1)
142169
#defineObjectIdAttributeNumber(-2)

‎src/include/config.h.in

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* or in config.h afterwards. Of course, if you edit config.h, then your
99
* changes will be overwritten the next time you run configure.
1010
*
11-
* $Id: config.h.in,v 1.129 2000/08/0700:51:38 tgl Exp $
11+
* $Id: config.h.in,v 1.130 2000/08/0720:15:44 tgl Exp $
1212
*/
1313

1414
#ifndefCONFIG_H
@@ -106,12 +106,16 @@
106106
#defineDEF_NBUFFERS (DEF_MAXBACKENDS > 8 ? DEF_MAXBACKENDS * 2 : 16)
107107

108108
/*
109-
* Size of a disk block --- currently, this limits the size of a tuple.
110-
* You can set it bigger if you need bigger tuples.
109+
* Size of a disk block --- this also limits the size of a tuple.
110+
* You can set it bigger if you need bigger tuples (although TOAST
111+
* should reduce the need to have large tuples, since fields can now
112+
* be spread across multiple tuples).
111113
*
112-
* CAUTION: changing BLCKSZ requires an initdb.
114+
* The maximum possible value of BLCKSZ is currently 2^15 (32768).
115+
* This is determined by the 15-bit widths of the lp_off and lp_len
116+
* fields in ItemIdData (see include/storage/itemid.h).
113117
*
114-
*currently must be <= 32k bjm
118+
*CAUTION: changing BLCKSZ requires an initdb.
115119
*/
116120
#defineBLCKSZ8192
117121

@@ -213,6 +217,12 @@
213217
*/
214218
#defineDEFAULT_MAX_EXPR_DEPTH10000
215219

220+
/*
221+
* You can try changing this if you have a machine with bytes of another
222+
* size, but no guarantee...
223+
*/
224+
#defineBITSPERBYTE8
225+
216226
/*
217227
*------------------------------------------------------------------------
218228
* These hand-configurable symbols are for enabling debugging code,

‎src/include/storage/bufmgr.h

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,21 @@
77
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: bufmgr.h,v 1.39 2000/06/15 03:33:00 momjian Exp $
10+
* $Id: bufmgr.h,v 1.40 2000/08/07 20:15:50 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
1414
#ifndefBUFMGR_H
1515
#defineBUFMGR_H
1616

17-
1817
#include"storage/buf_internals.h"
1918

20-
/*
21-
* the maximum size of a disk block for any possible installation.
22-
*
23-
* in theory this could be anything, but in practice this is actually
24-
* limited to 2^13 bytes because we have limited ItemIdData.lp_off and
25-
* ItemIdData.lp_len to 13 bits (see itemid.h).
26-
*
27-
* limit is now 2^15. Took four bits from ItemIdData.lp_flags and gave
28-
* two apiece to ItemIdData.lp_len and lp_off. darrenk 01/06/98
29-
*
30-
*/
31-
32-
#defineMAXBLCKSZ32768
3319

3420
typedefvoid*Block;
3521

3622
/* special pageno for bget */
3723
#defineP_NEWInvalidBlockNumber/* grow the file to get a new page */
3824

39-
typedefbits16BufferLock;
4025

4126
/**********************************************************************
4227

‎src/include/storage/itemid.h

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,48 @@
77
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: itemid.h,v 1.10 2000/01/26 05:58:33 momjian Exp $
10+
* $Id: itemid.h,v 1.11 2000/08/07 20:15:50 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
1414
#ifndefITEMID_H
1515
#defineITEMID_H
1616

17-
typedefuint16ItemOffset;
18-
typedefuint16ItemLength;
19-
20-
typedefbits16ItemIdFlags;
21-
22-
2317

18+
/*
19+
* An item pointer (also called line pointer) on a buffer page
20+
*/
2421
typedefstructItemIdData
2522
{/* line pointers */
26-
unsignedlp_off:15,/* offset to find tup */
27-
/* can be reduced by 2 if necc. */
28-
lp_flags:2,/* flags on tuple */
23+
unsignedlp_off:15,/* offset to start of tuple */
24+
lp_flags:2,/* flags for tuple */
2925
lp_len:15;/* length of tuple */
3026
}ItemIdData;
3127

32-
typedefstructItemIdData*ItemId;
28+
typedefItemIdData*ItemId;
3329

34-
#ifndefLP_USED
30+
/*
31+
* lp_flags contains these flags:
32+
*/
3533
#defineLP_USED0x01/* this line pointer is being used */
36-
#endif
34+
/* currently, there is one unused flag bit ... */
35+
36+
37+
/*
38+
* Item offsets, lengths, and flags are represented by these types when
39+
* they're not actually stored in an ItemIdData.
40+
*/
41+
typedefuint16ItemOffset;
42+
typedefuint16ItemLength;
43+
44+
typedefbits16ItemIdFlags;
45+
3746

3847
/* ----------------
3948
*support macros
4049
* ----------------
4150
*/
51+
4252
/*
4353
*ItemIdGetLength
4454
*/

‎src/include/utils/varbit.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ struct varbita
1818
bits8vl_dat[1];
1919
};
2020

21-
#undef BITSPERBYTE/* sometimes declared in <values.h> */
22-
#defineBITSPERBYTE8
2321
#defineVARBITHDRSZsizeof(int32)
2422
/* Number of bits in this bit string */
2523
#defineVARBITLEN(PTR)(((struct varbita *)VARDATA(PTR))->vl_len)

‎src/interfaces/ecpg/preproc/preproc.y

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3114,12 +3114,13 @@ Bit: bit '(' Iconst ')'
31143114
if (atol($3) <1)
31153115
{
31163116
sprintf(errortext,"length for type '%s' must be at least 1",$1);
3117-
mmerror(ET_ERROR, errortext);
3117+
mmerror(ET_ERROR, errortext);
31183118
}
3119-
elseif (atol($3) > (MaxAttrSize *sizeof(char)))
3119+
elseif (atol($3) > (MaxAttrSize * BITSPERBYTE))
31203120
{
3121-
sprintf(errortext,"length for type '%s' cannot exceed %ld", $1,
3122-
(MaxAttrSize *sizeof(char)));
3121+
sprintf(errortext,"length for type '%s' cannot exceed %d", $1,
3122+
(MaxAttrSize * BITSPERBYTE));
3123+
mmerror(ET_ERROR, errortext);
31233124
}
31243125
}
31253126
|bit
@@ -3147,7 +3148,7 @@ Character: character '(' Iconst ')'
31473148
}
31483149
elseif (atol($3) > MaxAttrSize)
31493150
{
3150-
sprintf(errortext,"length for type '%s' cannot exceed %ld", $1, MaxAttrSize);
3151+
sprintf(errortext,"length for type '%s' cannot exceed %d", $1, MaxAttrSize);
31513152
mmerror(ET_ERROR, errortext);
31523153
}
31533154

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp