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

Commitceb5db6

Browse files
committed
Defend against JOINs having more than 32K columns altogether. We cannot
currently support this because we must be able to build Vars referencingjoin columns, and varattno is only 16 bits wide. Perhaps this should beimproved in future, but considering that it never came up before, I'm notsure the problem is worth much effort. Per bug #4070 from MarcelloCeschia.The problem seems largely academic in 8.0 and 7.4, because they have(different) O(N^2) performance issues with such wide joins, butback-patch all the way anyway.
1 parent2a1cf97 commitceb5db6

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

‎src/backend/parser/parse_relation.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.130 2008/01/01 19:45:51 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.131 2008/04/05 01:58:20 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1025,6 +1025,16 @@ addRangeTableEntryForJoin(ParseState *pstate,
10251025
Alias*eref;
10261026
intnumaliases;
10271027

1028+
/*
1029+
* Fail if join has too many columns --- we must be able to reference
1030+
* any of the columns with an AttrNumber.
1031+
*/
1032+
if (list_length(aliasvars)>MaxAttrNumber)
1033+
ereport(ERROR,
1034+
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1035+
errmsg("joins can have at most %d columns",
1036+
MaxAttrNumber)));
1037+
10281038
rte->rtekind=RTE_JOIN;
10291039
rte->relid=InvalidOid;
10301040
rte->subquery=NULL;

‎src/include/access/attnum.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/access/attnum.h,v 1.24 2008/01/01 19:45:56 momjian Exp $
10+
* $PostgreSQL: pgsql/src/include/access/attnum.h,v 1.25 2008/04/05 01:58:20 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -21,6 +21,7 @@
2121
typedefint16AttrNumber;
2222

2323
#defineInvalidAttrNumber0
24+
#defineMaxAttrNumber32767
2425

2526
/* ----------------
2627
*support macros

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp