Skip to content

Commit e40492e

Browse files
committed
Remove useless and dangerous 'opt_type' option from CREATE INDEX.
1 parent 6bfe640 commit e40492e

File tree

4 files changed

+27
-43
lines changed

4 files changed

+27
-43
lines changed

src/backend/nodes/outfuncs.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.121 2000/07/12 02:37:06 tgl Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.122 2000/07/15 00:01:37 tgl Exp $
1010
*
1111
* NOTES
1212
* Every (plan) node in POSTGRES has an associated "out" routine which
@@ -139,9 +139,9 @@ _outIndexStmt(StringInfo str, IndexStmt *node)
139139
appendStringInfo(str, " :rangetable ");
140140
_outNode(str, node->rangetable);
141141

142-
appendStringInfo(str, " :lossy %s :unique %s ",
143-
node->lossy ? "true" : "false",
144-
node->unique ? "true" : "false");
142+
appendStringInfo(str, " :unique %s :primary %s ",
143+
node->unique ? "true" : "false",
144+
node->primary ? "true" : "false");
145145
}
146146

147147
static void
@@ -210,8 +210,6 @@ _outIndexElem(StringInfo str, IndexElem *node)
210210
_outNode(str, node->args);
211211
appendStringInfo(str, " :class ");
212212
_outToken(str, node->class);
213-
appendStringInfo(str, " :typename ");
214-
_outNode(str, node->typename);
215213
}
216214

217215
static void

src/backend/parser/analyze.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: analyze.c,v 1.150 2000/07/14 15:43:32 thomas Exp $
9+
* $Id: analyze.c,v 1.151 2000/07/15 00:01:41 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -947,7 +947,6 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
947947
iparam->name = pstrdup(column->colname);
948948
iparam->args = NIL;
949949
iparam->class = NULL;
950-
iparam->typename = NULL;
951950
index->indexParams = lappend(index->indexParams, iparam);
952951

953952
if (index->idxname == NULL)

src/backend/parser/gram.y

Lines changed: 10 additions & 26 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.178 2000/07/14 15:43:32 thomas Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.179 2000/07/15 00:01:41 tgl Exp $
1515
*
1616
* HISTORY
1717
* AUTHOR DATE MAJOR EVENT
@@ -250,7 +250,7 @@ static void doNegateFloat(Value *v);
250250
%type <target> target_el, update_target_el
251251
%type <paramno> ParamNo
252252

253-
%type <typnam> Typename, opt_type, SimpleTypename, ConstTypename
253+
%type <typnam> Typename, SimpleTypename, ConstTypename
254254
Generic, Numeric, Character, ConstDatetime, ConstInterval, Bit
255255
%type <str> typename, generic, numeric, character, datetime, bit
256256
%type <str> extract_arg
@@ -1778,7 +1778,7 @@ TriggerFuncArg: ICONST
17781778
}
17791779
| FCONST { $$ = $1; }
17801780
| Sconst { $$ = $1; }
1781-
| IDENT { $$ = $1; }
1781+
| ColId { $$ = $1; }
17821782
;
17831783

17841784
OptConstrFromTable: /* Empty */
@@ -2315,8 +2315,6 @@ RevokeStmt: REVOKE privileges ON relation_name_list FROM grantee
23152315
IndexStmt: CREATE index_opt_unique INDEX index_name ON relation_name
23162316
access_method_clause '(' index_params ')' opt_with
23172317
{
2318-
/* should check that access_method is valid,
2319-
etc ... but doesn't */
23202318
IndexStmt *n = makeNode(IndexStmt);
23212319
n->unique = $2;
23222320
n->idxname = $4;
@@ -2345,37 +2343,24 @@ index_list: index_list ',' index_elem { $$ = lappend($1, $3); }
23452343
| index_elem { $$ = lcons($1, NIL); }
23462344
;
23472345

2348-
func_index: func_name '(' name_list ')' opt_type opt_class
2346+
func_index: func_name '(' name_list ')' opt_class
23492347
{
23502348
$$ = makeNode(IndexElem);
23512349
$$->name = $1;
23522350
$$->args = $3;
2353-
$$->class = $6;
2354-
$$->typename = $5;
2351+
$$->class = $5;
23552352
}
23562353
;
23572354

2358-
index_elem: attr_name opt_type opt_class
2355+
index_elem: attr_name opt_class
23592356
{
23602357
$$ = makeNode(IndexElem);
23612358
$$->name = $1;
23622359
$$->args = NIL;
2363-
$$->class = $3;
2364-
$$->typename = $2;
2360+
$$->class = $2;
23652361
}
23662362
;
23672363

2368-
opt_type: ':' Typename { $$ = $2; }
2369-
| FOR Typename { $$ = $2; }
2370-
| /*EMPTY*/ { $$ = NULL; }
2371-
;
2372-
2373-
/* opt_class "WITH class" conflicts with preceeding opt_type
2374-
* for Typename of "TIMESTAMP WITH TIME ZONE"
2375-
* So, remove "WITH class" from the syntax. OK??
2376-
* - thomas 1997-10-12
2377-
* | WITH class { $$ = $2; }
2378-
*/
23792364
opt_class: class {
23802365
/*
23812366
* Release 7.0 removed network_ops, timespan_ops, and datetime_ops,
@@ -5352,9 +5337,9 @@ relation_name: SpecialRuleRelation
53525337
;
53535338

53545339
database_name: ColId { $$ = $1; };
5355-
access_method: IDENT { $$ = $1; };
5340+
access_method: ColId { $$ = $1; };
53565341
attr_name: ColId { $$ = $1; };
5357-
class: IDENT { $$ = $1; };
5342+
class: ColId { $$ = $1; };
53585343
index_name: ColId { $$ = $1; };
53595344

53605345
/* Functions
@@ -5365,7 +5350,6 @@ name: ColId { $$ = $1; };
53655350
func_name: ColId { $$ = xlateSqlFunc($1); };
53665351

53675352
file_name: Sconst { $$ = $1; };
5368-
/* NOT USED recipe_name: IDENT { $$ = $1; };*/
53695353

53705354
/* Constants
53715355
* Include TRUE/FALSE for SQL3 support. - thomas 1997-10-24
@@ -5453,7 +5437,7 @@ ParamNo: PARAM opt_indirection
54535437

54545438
Iconst: ICONST { $$ = $1; };
54555439
Sconst: SCONST { $$ = $1; };
5456-
UserId: IDENT { $$ = $1; };
5440+
UserId: ColId { $$ = $1; };
54575441

54585442
/* Column identifier
54595443
* Include date/time keywords as SQL92 extension.

src/include/nodes/parsenodes.h

Lines changed: 12 additions & 9 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: parsenodes.h,v 1.109 2000/07/14 15:43:51 thomas Exp $
10+
* $Id: parsenodes.h,v 1.110 2000/07/15 00:01:38 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -467,13 +467,12 @@ typedef struct IndexStmt
467467
NodeTag type;
468468
char *idxname; /* name of the index */
469469
char *relname; /* name of relation to index on */
470-
char *accessMethod; /* name of acess methood (eg. btree) */
470+
char *accessMethod; /* name of access method (eg. btree) */
471471
List *indexParams; /* a list of IndexElem */
472472
List *withClause; /* a list of DefElem */
473-
Node *whereClause; /* qualifications */
474-
List *rangetable; /* range table, filled in by
473+
Node *whereClause; /* qualification (partial-index predicate) */
474+
List *rangetable; /* range table for qual, filled in by
475475
* transformStmt() */
476-
bool *lossy; /* is index lossy? */
477476
bool unique; /* is index unique? */
478477
bool primary; /* is index on primary key? */
479478
} IndexStmt;
@@ -1088,14 +1087,18 @@ typedef struct RangeVar
10881087

10891088
/*
10901089
* IndexElem - index parameters (used in CREATE INDEX)
1090+
*
1091+
* For a plain index, each 'name' is an attribute name in the heap relation,
1092+
* and 'args' is NIL. For a functional index, only one IndexElem is allowed.
1093+
* It has name = name of function and args = list of attribute names that
1094+
* are the function's arguments.
10911095
*/
10921096
typedef struct IndexElem
10931097
{
10941098
NodeTag type;
1095-
char *name; /* name of index */
1096-
List *args; /* if not NULL, function index */
1097-
char *class;
1098-
TypeName *typename; /* type of index's keys (optional) */
1099+
char *name; /* name of attribute to index, or function */
1100+
List *args; /* list of names of function arguments */
1101+
char *class; /* name of desired opclass; NULL = default */
10991102
} IndexElem;
11001103

11011104
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy