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

Commit488f315

Browse files
committed
Defend against > INDEX_MAX_KEYS keys in an index.
1 parent8acc568 commit488f315

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

‎src/backend/commands/indexcmds.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*-------------------------------------------------------------------------
22
*
3-
*defind.c
3+
*indexcmds.c
44
* POSTGRES define, extend and remove index code.
55
*
66
* Copyright (c) 1994, Regents of the University of California
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.18 2000/01/11 03:33:11 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.19 2000/01/12 05:04:42 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -87,6 +87,9 @@ DefineIndex(char *heapRelationName,
8787
numberOfAttributes=length(attributeList);
8888
if (numberOfAttributes <=0)
8989
elog(ERROR,"DefineIndex: must specify at least one attribute");
90+
if (numberOfAttributes>INDEX_MAX_KEYS)
91+
elog(ERROR,"Cannot use more than %d attributes in an index",
92+
INDEX_MAX_KEYS);
9093

9194
/*
9295
* compute heap relation id
@@ -152,10 +155,8 @@ DefineIndex(char *heapRelationName,
152155

153156
nargs=length(funcIndex->args);
154157
if (nargs>INDEX_MAX_KEYS)
155-
{
156-
elog(ERROR,
157-
"Too many args to function, limit of %d",INDEX_MAX_KEYS);
158-
}
158+
elog(ERROR,"Index function can take at most %d arguments",
159+
INDEX_MAX_KEYS);
159160

160161
FIsetnArgs(&fInfo,nargs);
161162

@@ -258,10 +259,12 @@ ExtendIndex(char *indexRelationName, Expr *predicate, List *rangetable)
258259
relationId=index->indrelid;
259260
indproc=index->indproc;
260261

261-
for (i=INDEX_MAX_KEYS-1;i >=0;i--)
262+
for (i=0;i<INDEX_MAX_KEYS;i++)
263+
{
262264
if (index->indkey[i]==InvalidAttrNumber)
263265
break;
264-
numberOfAttributes=i+1;
266+
}
267+
numberOfAttributes=i;
265268

266269
if (VARSIZE(&index->indpred)!=0)
267270
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp