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

Commit97dfff8

Browse files
committed
Fix to prevent too large tuple from being created.
1 parent954e466 commit97dfff8

File tree

11 files changed

+46
-40
lines changed

11 files changed

+46
-40
lines changed

‎src/backend/access/heap/stats.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/heap/Attic/stats.c,v 1.15 1999/02/13 23:14:25 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/heap/Attic/stats.c,v 1.16 1999/07/03 00:32:36 momjian Exp $
1111
*
1212
* NOTES
1313
* initam should be moved someplace else.
@@ -16,6 +16,7 @@
1616
*/
1717

1818
#include<stdio.h>
19+
#include<time.h>
1920

2021
#include<postgres.h>
2122

‎src/backend/catalog/index.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.79 1999/06/19 04:54:11 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.80 1999/07/03 00:32:38 momjian Exp $
1111
*
1212
*
1313
* INTERFACE ROUTINES
@@ -20,6 +20,7 @@
2020
#include"postgres.h"
2121

2222
#include"access/genam.h"
23+
#include"access/htup.h"
2324
#include"access/heapam.h"
2425
#include"access/istrat.h"
2526
#include"access/xact.h"
@@ -56,7 +57,7 @@
5657
/*
5758
* macros used in guessing how many tuples are on a page.
5859
*/
59-
#defineAVG_TUPLE_SIZE8
60+
#defineAVG_TUPLE_SIZEMinTupleSize
6061
#defineNTUPLES_PER_PAGE(natts) (BLCKSZ/((natts)*AVG_TUPLE_SIZE))
6162

6263
/* non-export function prototypes */

‎src/backend/commands/copy.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.80 1999/06/12 20:41:25 tgl Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.81 1999/07/03 00:32:39 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -1073,7 +1073,7 @@ GetIndexRelations(Oid main_relation_oid,
10731073
}
10741074
}
10751075

1076-
#defineEXT_ATTLEN 5*BLCKSZ
1076+
#defineEXT_ATTLEN(5 *BLCKSZ)
10771077

10781078
/*
10791079
returns 1 is c is in s

‎src/backend/commands/vacuum.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.109 1999/06/11 09:35:08 vadim Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.110 1999/07/03 00:32:40 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -624,7 +624,7 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
624624
empty_end_pages;
625625
Sizefree_size,
626626
usable_free_size;
627-
Sizemin_tlen=MAXTUPLEN;
627+
Sizemin_tlen=MaxTupleSize;
628628
Sizemax_tlen=0;
629629
int32i;
630630
structrusageru0,

‎src/backend/optimizer/path/_deadcode/xfunc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/_deadcode/Attic/xfunc.c,v 1.4 1999/05/25 22:41:36 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/_deadcode/Attic/xfunc.c,v 1.5 1999/07/03 00:32:42 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -20,6 +20,7 @@
2020

2121
#include"postgres.h"
2222

23+
#include"access/htup.h"
2324
#include"access/heapam.h"
2425
#include"catalog/pg_language.h"
2526
#include"catalog/pg_proc.h"
@@ -1094,7 +1095,7 @@ xfunc_expense_per_tuple(JoinPath joinnode, int whichchild)
10941095
RelOptInfoouterrel=get_parent((Path)get_outerjoinpath(joinnode));
10951096
RelOptInfoinnerrel=get_parent((Path)get_innerjoinpath(joinnode));
10961097
Countouterwidth=get_width(outerrel);
1097-
Countouters_per_page=ceil(BLCKSZ / (outerwidth+sizeof(HeapTupleData)));
1098+
Countouters_per_page=ceil(BLCKSZ / (outerwidth+MinTupleSize));
10981099

10991100
if (IsA(joinnode,HashPath))
11001101
{

‎src/backend/parser/gram.y

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.84 1999/06/07 14:28:25 tgl Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.85 1999/07/03 00:32:44 momjian Exp $
1414
*
1515
* HISTORY
1616
* AUTHORDATEMAJOR EVENT
@@ -36,6 +36,7 @@
3636
#include <ctype.h>
3737

3838
#include "postgres.h"
39+
#include "access/htup.h"
3940
#include "nodes/parsenodes.h"
4041
#include "nodes/print.h"
4142
#include "parser/gramparse.h"
@@ -3384,8 +3385,9 @@ Character: character '(' Iconst ')'
33843385

33853386
if ($3 < 1)
33863387
elog(ERROR,"length for '%s' type must be at least 1",$1);
3387-
else if ($3 > BLCKSZ - 128)
3388-
elog(ERROR,"length for type '%s' cannot exceed %d",$1, BLCKSZ-128);
3388+
else if ($3 > MaxTupleSize)
3389+
elog(ERROR,"length for type '%s' cannot exceed %d",$1,
3390+
MaxTupleSize);
33893391

33903392
/* we actually implement this sort of like a varlen, so
33913393
* the first 4 bytes is the length. (the difference

‎src/backend/storage/page/bufpage.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.22 1999/05/25 16:11:25 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.23 1999/07/03 00:32:48 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -45,7 +45,7 @@ PageInit(Page page, Size pageSize, Size specialSize)
4545

4646
Assert(pageSize==BLCKSZ);
4747
Assert(pageSize>
48-
specialSize+sizeof(PageHeaderData)-sizeof(ItemIdData));
48+
specialSize+sizeof(PageHeaderData)-sizeof(ItemIdData));
4949

5050
specialSize=DOUBLEALIGN(specialSize);
5151

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.46 1999/05/25 16:12:21 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.47 1999/07/03 00:32:50 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
1414
#include<stdio.h>/* for sprintf() */
1515
#include<string.h>
1616
#include"postgres.h"
17+
#include"access/htup.h"
1718
#include"utils/array.h"
1819
#include"utils/builtins.h"
1920
#include"catalog/pg_type.h"
@@ -81,8 +82,9 @@ bpcharin(char *s, int dummy, int32 atttypmod)
8182
else
8283
len=atttypmod-VARHDRSZ;
8384

84-
if (len>BLCKSZ-128)
85-
elog(ERROR,"bpcharin: length of char() must be less than %d",BLCKSZ-128);
85+
if (len>MaxTupleSize)
86+
elog(ERROR,"bpcharin: length of char() must be less than %d",
87+
MaxTupleSize);
8688

8789
result= (char*)palloc(atttypmod);
8890
VARSIZE(result)=atttypmod;
@@ -151,8 +153,9 @@ bpchar(char *s, int32 len)
151153

152154
rlen=len-VARHDRSZ;
153155

154-
if (rlen>BLCKSZ-128)
155-
elog(ERROR,"bpchar: length of char() must be less than %d",BLCKSZ-128);
156+
if (rlen>MaxTupleSize)
157+
elog(ERROR,"bpchar: length of char() must be less than %d",
158+
MaxTupleSize);
156159

157160
#ifdefSTRINGDEBUG
158161
printf("bpchar- convert string length %d (%d) ->%d (%d)\n",
@@ -332,8 +335,9 @@ varcharin(char *s, int dummy, int32 atttypmod)
332335
if (atttypmod!=-1&&len>atttypmod)
333336
len=atttypmod;/* clip the string at max length */
334337

335-
if (len>BLCKSZ-128)
336-
elog(ERROR,"varcharin: length of char() must be less than %d",BLCKSZ-128);
338+
if (len>MaxTupleSize)
339+
elog(ERROR,"varcharin: length of char() must be less than %d",
340+
MaxTupleSize);
337341

338342
result= (char*)palloc(len);
339343
VARSIZE(result)=len;
@@ -403,8 +407,9 @@ varchar(char *s, int32 slen)
403407
len=slen-VARHDRSZ;
404408
#endif
405409

406-
if (len>BLCKSZ-128)
407-
elog(ERROR,"varchar: length of varchar() must be less than BLCKSZ-128");
410+
if (len>MaxTupleSize)
411+
elog(ERROR,"varchar: length of varchar() must be less than %d",
412+
MaxTupleSize);
408413

409414
result= (char*)palloc(slen);
410415
VARSIZE(result)=slen;

‎src/include/access/htup.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: htup.h,v 1.16 1999/05/25 22:42:32 momjian Exp $
9+
* $Id: htup.h,v 1.17 1999/07/03 00:32:55 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
1313
#ifndefHTUP_H
1414
#defineHTUP_H
1515

16-
#include<utils/nabstime.h>
16+
#include<storage/bufpage.h>
1717
#include<storage/itemptr.h>
1818

1919
#defineMinHeapTupleBitmapSize32/* 8 * 4 */
@@ -52,6 +52,11 @@ typedef struct HeapTupleHeaderData
5252

5353
typedefHeapTupleHeaderData*HeapTupleHeader;
5454

55+
#defineMinTupleSize(sizeof (PageHeaderData) + \
56+
sizeof(HeapTupleHeaderData) + sizeof(int4))
57+
58+
#defineMaxTupleSize(BLCKSZ/2 - MinTupleSize)
59+
5560
#defineSelfItemPointerAttributeNumber(-1)
5661
#defineObjectIdAttributeNumber(-2)
5762
#defineMinTransactionIdAttributeNumber(-3)

‎src/include/storage/bufpage.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: bufpage.h,v 1.22 1999/05/25 16:14:40 momjian Exp $
9+
* $Id: bufpage.h,v 1.23 1999/07/03 00:32:59 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -133,18 +133,6 @@ typedef enum
133133
OverwritePageManagerMode
134134
}PageManagerMode;
135135

136-
/* ----------------
137-
*misc support macros
138-
* ----------------
139-
*/
140-
141-
/*
142-
* XXX this is wrong -- ignores padding/alignment, variable page size,
143-
* AM-specific opaque space at the end of the page (as in btrees), ...
144-
* however, it at least serves as an upper bound for heap pages.
145-
*/
146-
#defineMAXTUPLEN(BLCKSZ - sizeof (PageHeaderData))
147-
148136
/* ----------------------------------------------------------------
149137
*page support macros
150138
* ----------------------------------------------------------------

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
#include<stdio.h>
44
#include<string.h>
55
#include<stdlib.h>
6+
7+
#include"postgres.h"
8+
#include"access/htup.h"
69
#include"catalog/catname.h"
710
#include"utils/numeric.h"
811

@@ -3351,8 +3354,8 @@ Character: character '(' Iconst ')'
33513354
sprintf(errortext,"length for '%s' type must be at least 1",$1);
33523355
yyerror(errortext);
33533356
}
3354-
elseif (atol($3) >BLCKSZ -128) {
3355-
sprintf(errortext,"length for type '%s' cannot exceed %d",$1,BLCKSZ -128);
3357+
elseif (atol($3) >MaxTupleSize) {
3358+
sprintf(errortext,"length for type '%s' cannot exceed %d",$1,MaxTupleSize);
33563359
yyerror(errortext);
33573360
}
33583361

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp