|
1 | 1 | /*-------------------------------------------------------------------------
|
2 | 2 | *
|
3 |
| - * defind.c |
| 3 | + * indexcmds.c |
4 | 4 | * POSTGRES define, extend and remove index code.
|
5 | 5 | *
|
6 | 6 | * Copyright (c) 1994, Regents of the University of California
|
7 | 7 | *
|
8 | 8 | *
|
9 | 9 | * 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 $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -87,6 +87,9 @@ DefineIndex(char *heapRelationName,
|
87 | 87 | numberOfAttributes = length(attributeList);
|
88 | 88 | if (numberOfAttributes <= 0)
|
89 | 89 | 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); |
90 | 93 |
|
91 | 94 | /*
|
92 | 95 | * compute heap relation id
|
@@ -152,10 +155,8 @@ DefineIndex(char *heapRelationName,
|
152 | 155 |
|
153 | 156 | nargs = length(funcIndex->args);
|
154 | 157 | 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); |
159 | 160 |
|
160 | 161 | FIsetnArgs(&fInfo, nargs);
|
161 | 162 |
|
@@ -258,10 +259,12 @@ ExtendIndex(char *indexRelationName, Expr *predicate, List *rangetable)
|
258 | 259 | relationId = index->indrelid;
|
259 | 260 | indproc = index->indproc;
|
260 | 261 |
|
261 |
| - for (i = INDEX_MAX_KEYS-1; i >= 0; i--) |
| 262 | + for (i = 0; i < INDEX_MAX_KEYS; i++) |
| 263 | + { |
262 | 264 | if (index->indkey[i] == InvalidAttrNumber)
|
263 | 265 | break;
|
264 |
| - numberOfAttributes = i+1; |
| 266 | + } |
| 267 | + numberOfAttributes = i; |
265 | 268 |
|
266 | 269 | if (VARSIZE(&index->indpred) != 0)
|
267 | 270 | {
|
|
0 commit comments