mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-12 18:34:36 +08:00
Fixes a bug in 'create index'
Submitted by: Dan McGuirk <mcguirk@indirect.com>
This commit is contained in:
parent
d6fa4d95cd
commit
a4402ecc8c
@ -7,7 +7,7 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: pg_amop.h,v 1.2 1996/07/20 08:19:11 scrappy Exp $
|
||||
* $Id: pg_amop.h,v 1.3 1996/08/15 07:42:06 scrappy Exp $
|
||||
*
|
||||
* NOTES
|
||||
* the genbki.sh script reads this file and generates .bki
|
||||
@ -219,11 +219,11 @@ DATA(insert OID = 0 ( 403 408 462 5 btreesel btreenpage ));
|
||||
* nbtree name_ops
|
||||
*/
|
||||
|
||||
DATA(insert OID = 0 ( 403 409 660 1 btreesel btreenpage ));
|
||||
DATA(insert OID = 0 ( 403 409 661 2 btreesel btreenpage ));
|
||||
DATA(insert OID = 0 ( 403 409 93 3 btreesel btreenpage ));
|
||||
DATA(insert OID = 0 ( 403 409 663 4 btreesel btreenpage ));
|
||||
DATA(insert OID = 0 ( 403 409 662 5 btreesel btreenpage ));
|
||||
DATA(insert OID = 0 ( 403 1181 660 1 btreesel btreenpage ));
|
||||
DATA(insert OID = 0 ( 403 1181 661 2 btreesel btreenpage ));
|
||||
DATA(insert OID = 0 ( 403 1181 93 3 btreesel btreenpage ));
|
||||
DATA(insert OID = 0 ( 403 1181 663 4 btreesel btreenpage ));
|
||||
DATA(insert OID = 0 ( 403 1181 662 5 btreesel btreenpage ));
|
||||
|
||||
/*
|
||||
* nbtree char16_ops
|
||||
@ -453,11 +453,11 @@ DATA(insert OID = 0 ( 404 430 647 5 btreesel btreenpage ));
|
||||
* nobtree name_ops
|
||||
*/
|
||||
|
||||
DATA(insert OID = 0 ( 404 409 660 1 btreesel btreenpage ));
|
||||
DATA(insert OID = 0 ( 404 409 661 2 btreesel btreenpage ));
|
||||
DATA(insert OID = 0 ( 404 409 93 3 btreesel btreenpage ));
|
||||
DATA(insert OID = 0 ( 404 409 663 4 btreesel btreenpage ));
|
||||
DATA(insert OID = 0 ( 404 409 662 5 btreesel btreenpage ));
|
||||
DATA(insert OID = 0 ( 404 1181 660 1 btreesel btreenpage ));
|
||||
DATA(insert OID = 0 ( 404 1181 661 2 btreesel btreenpage ));
|
||||
DATA(insert OID = 0 ( 404 1181 93 3 btreesel btreenpage ));
|
||||
DATA(insert OID = 0 ( 404 1181 663 4 btreesel btreenpage ));
|
||||
DATA(insert OID = 0 ( 404 1181 662 5 btreesel btreenpage ));
|
||||
|
||||
/*
|
||||
* nobtree text_ops
|
||||
@ -526,7 +526,7 @@ DATA(insert OID = 0 ( 405 430 99 1 hashsel hashnpage ));
|
||||
/*
|
||||
* hash table name_ops
|
||||
*/
|
||||
DATA(insert OID = 0 ( 405 409 93 1 hashsel hashnpage ));
|
||||
DATA(insert OID = 0 ( 405 1181 93 1 hashsel hashnpage ));
|
||||
/*
|
||||
* hash table text_ops
|
||||
*/
|
||||
|
@ -9,7 +9,7 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: pg_amproc.h,v 1.2 1996/07/20 08:19:13 scrappy Exp $
|
||||
* $Id: pg_amproc.h,v 1.3 1996/08/15 07:42:07 scrappy Exp $
|
||||
*
|
||||
* NOTES
|
||||
* the genbki.sh script reads this file and generates .bki
|
||||
@ -82,7 +82,7 @@ DATA(insert OID = 0 (403 429 358 1));
|
||||
DATA(insert OID = 0 (403 406 689 1));
|
||||
DATA(insert OID = 0 (403 407 690 1));
|
||||
DATA(insert OID = 0 (403 408 691 1));
|
||||
DATA(insert OID = 0 (403 409 359 1));
|
||||
DATA(insert OID = 0 (403 1181 359 1));
|
||||
DATA(insert OID = 0 (403 430 374 1));
|
||||
DATA(insert OID = 0 (403 431 360 1));
|
||||
DATA(insert OID = 0 (403 432 357 1));
|
||||
@ -108,7 +108,7 @@ DATA(insert OID = 0 (404 429 358 1));
|
||||
DATA(insert OID = 0 (404 406 689 1));
|
||||
DATA(insert OID = 0 (404 407 690 1));
|
||||
DATA(insert OID = 0 (404 408 691 1));
|
||||
DATA(insert OID = 0 (404 409 359 1));
|
||||
DATA(insert OID = 0 (404 1181 359 1));
|
||||
DATA(insert OID = 0 (404 430 374 1));
|
||||
DATA(insert OID = 0 (404 431 360 1));
|
||||
DATA(insert OID = 0 (404 432 357 1));
|
||||
@ -125,7 +125,7 @@ DATA(insert OID = 0 (405 429 454 1));
|
||||
DATA(insert OID = 0 (405 406 692 1));
|
||||
DATA(insert OID = 0 (405 407 693 1));
|
||||
DATA(insert OID = 0 (405 408 694 1));
|
||||
DATA(insert OID = 0 (405 409 455 1));
|
||||
DATA(insert OID = 0 (405 1181 455 1));
|
||||
DATA(insert OID = 0 (405 430 499 1));
|
||||
DATA(insert OID = 0 (405 431 456 1));
|
||||
DATA(insert OID = 0 (405 1076 1080 1));
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: pg_opclass.h,v 1.1.1.1 1996/07/09 06:21:17 scrappy Exp $
|
||||
* $Id: pg_opclass.h,v 1.2 1996/08/15 07:42:09 scrappy Exp $
|
||||
*
|
||||
* NOTES
|
||||
* the genbki.sh script reads this file and generates .bki
|
||||
@ -34,6 +34,7 @@
|
||||
|
||||
CATALOG(pg_opclass) {
|
||||
NameData opcname;
|
||||
Oid opcdeftype;
|
||||
} FormData_pg_opclass;
|
||||
|
||||
/* ----------------
|
||||
@ -47,39 +48,46 @@ typedef FormData_pg_opclass *Form_pg_opclass;
|
||||
* compiler constants for pg_opclass
|
||||
* ----------------
|
||||
*/
|
||||
#define Natts_pg_opclass 1
|
||||
#define Natts_pg_opclass 2
|
||||
#define Anum_pg_opclass_opcname 1
|
||||
#define Anum_pg_opclass_opcdeftype 2
|
||||
|
||||
/* ----------------
|
||||
* initial contents of pg_opclass
|
||||
* ----------------
|
||||
*/
|
||||
|
||||
DATA(insert OID = 406 ( char2_ops ));
|
||||
DATA(insert OID = 407 ( char4_ops ));
|
||||
DATA(insert OID = 408 ( char8_ops ));
|
||||
DATA(insert OID = 409 ( name_ops ));
|
||||
DATA(insert OID = 421 ( int2_ops ));
|
||||
DATA(insert OID = 422 ( box_ops ));
|
||||
DATA(insert OID = 423 ( float8_ops ));
|
||||
DATA(insert OID = 424 ( int24_ops ));
|
||||
DATA(insert OID = 425 ( int42_ops ));
|
||||
DATA(insert OID = 426 ( int4_ops ));
|
||||
/*
|
||||
* putting _null_'s in the (fixed-length) type field is bad
|
||||
* (see the README in this directory), so just put zeros
|
||||
* in, which are invalid OID's anyway. --djm
|
||||
*/
|
||||
DATA(insert OID = 406 ( char2_ops 409 ));
|
||||
DATA(insert OID = 407 ( char4_ops 410 ));
|
||||
DATA(insert OID = 408 ( char8_ops 411 ));
|
||||
/* OID 409 is already used in table pg_type--this one should be unused */
|
||||
DATA(insert OID = 1181 ( name_ops 19 ));
|
||||
DATA(insert OID = 421 ( int2_ops 21 ));
|
||||
DATA(insert OID = 422 ( box_ops 603 ));
|
||||
DATA(insert OID = 423 ( float8_ops 701 ));
|
||||
DATA(insert OID = 424 ( int24_ops 0 ));
|
||||
DATA(insert OID = 425 ( int42_ops 0 ));
|
||||
DATA(insert OID = 426 ( int4_ops 23 ));
|
||||
#define INT4_OPS_OID 426
|
||||
DATA(insert OID = 427 ( oid_ops ));
|
||||
DATA(insert OID = 428 ( float4_ops ));
|
||||
DATA(insert OID = 429 ( char_ops ));
|
||||
DATA(insert OID = 430 ( char16_ops ));
|
||||
DATA(insert OID = 431 ( text_ops ));
|
||||
DATA(insert OID = 432 ( abstime_ops ));
|
||||
DATA(insert OID = 433 ( bigbox_ops));
|
||||
DATA(insert OID = 434 ( poly_ops));
|
||||
DATA(insert OID = 435 ( oidint4_ops));
|
||||
DATA(insert OID = 436 ( oidname_ops));
|
||||
DATA(insert OID = 437 ( oidint2_ops));
|
||||
DATA(insert OID = 1076 ( bpchar_ops));
|
||||
DATA(insert OID = 1077 ( varchar_ops));
|
||||
DATA(insert OID = 1114 ( date_ops));
|
||||
DATA(insert OID = 1115 ( time_ops));
|
||||
DATA(insert OID = 427 ( oid_ops 26 ));
|
||||
DATA(insert OID = 428 ( float4_ops 700 ));
|
||||
DATA(insert OID = 429 ( char_ops 18 ));
|
||||
DATA(insert OID = 430 ( char16_ops 20 ));
|
||||
DATA(insert OID = 431 ( text_ops 25 ));
|
||||
DATA(insert OID = 432 ( abstime_ops 702 ));
|
||||
DATA(insert OID = 433 ( bigbox_ops 0 ));
|
||||
DATA(insert OID = 434 ( poly_ops 604 ));
|
||||
DATA(insert OID = 435 ( oidint4_ops 910 ));
|
||||
DATA(insert OID = 436 ( oidname_ops 911 ));
|
||||
DATA(insert OID = 437 ( oidint2_ops 810 ));
|
||||
DATA(insert OID = 1076 ( bpchar_ops 1042 ));
|
||||
DATA(insert OID = 1077 ( varchar_ops 1043 ));
|
||||
DATA(insert OID = 1114 ( date_ops 1082 ));
|
||||
DATA(insert OID = 1115 ( time_ops 1083 ));
|
||||
|
||||
#endif /* PG_OPCLASS_H */
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.1.1.1 1996/07/09 06:21:20 scrappy Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.2 1996/08/15 07:42:19 scrappy Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -23,6 +23,7 @@
|
||||
#include "catalog/index.h"
|
||||
#include "catalog/pg_index.h"
|
||||
#include "catalog/pg_proc.h"
|
||||
#include "catalog/pg_opclass.h"
|
||||
#include "nodes/pg_list.h"
|
||||
#include "nodes/plannodes.h"
|
||||
#include "nodes/primnodes.h"
|
||||
@ -51,6 +52,7 @@ static void FuncIndexArgs(IndexElem *funcIndex, AttrNumber *attNumP,
|
||||
Oid *argTypes, Oid *opOidP, Oid relId);
|
||||
static void NormIndexAttrs(List *attList, AttrNumber *attNumP,
|
||||
Oid *opOidP, Oid relId);
|
||||
static char *GetDefaultOpClass(Oid atttypid);
|
||||
|
||||
/*
|
||||
* DefineIndex --
|
||||
@ -439,14 +441,10 @@ NormIndexAttrs(List *attList, /* list of IndexElem's */
|
||||
|
||||
for (rest=attList; rest != NIL; rest = lnext(rest)) {
|
||||
IndexElem *attribute;
|
||||
AttributeTupleForm attform;
|
||||
|
||||
attribute = lfirst(rest);
|
||||
|
||||
if (attribute->class == NULL) {
|
||||
elog(WARN,
|
||||
"DefineIndex: default index class unsupported");
|
||||
}
|
||||
|
||||
if (attribute->name == NULL)
|
||||
elog(WARN, "missing attribute for define index");
|
||||
|
||||
@ -459,7 +457,19 @@ NormIndexAttrs(List *attList, /* list of IndexElem's */
|
||||
"DefineIndex: attribute \"%s\" not found",
|
||||
attribute->name);
|
||||
}
|
||||
*attNumP++ = ((AttributeTupleForm)GETSTRUCT(tuple))->attnum;
|
||||
|
||||
attform = (AttributeTupleForm)GETSTRUCT(tuple);
|
||||
*attNumP++ = attform->attnum;
|
||||
|
||||
if (attribute->class == NULL) {
|
||||
/* no operator class specified, so find the default */
|
||||
attribute->class = GetDefaultOpClass(attform->atttypid);
|
||||
if(attribute->class == NULL) {
|
||||
elog(WARN,
|
||||
"Can't find a default operator class for type %d.",
|
||||
attform->atttypid);
|
||||
}
|
||||
}
|
||||
|
||||
tuple = SearchSysCacheTuple(CLANAME,
|
||||
PointerGetDatum(attribute->class),
|
||||
@ -473,6 +483,21 @@ NormIndexAttrs(List *attList, /* list of IndexElem's */
|
||||
}
|
||||
}
|
||||
|
||||
static char *
|
||||
GetDefaultOpClass(Oid atttypid)
|
||||
{
|
||||
HeapTuple tuple;
|
||||
|
||||
tuple = SearchSysCacheTuple(CLADEFTYPE,
|
||||
ObjectIdGetDatum(atttypid),
|
||||
0, 0, 0);
|
||||
if(!HeapTupleIsValid(tuple)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return nameout(&(((Form_pg_opclass)GETSTRUCT(tuple))->opcname));
|
||||
}
|
||||
|
||||
/*
|
||||
* RemoveIndex --
|
||||
* Deletes an index.
|
||||
|
@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.6 1996/08/13 01:29:33 scrappy Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.7 1996/08/15 07:42:29 scrappy Exp $
|
||||
*
|
||||
* HISTORY
|
||||
* AUTHOR DATE MAJOR EVENT
|
||||
@ -109,8 +109,8 @@ static Node *makeA_Expr(int op, char *opname, Node *lexpr, Node *rexpr);
|
||||
ExplainStmt
|
||||
|
||||
%type <str> relation_name, copy_file_name, copy_delimiter, def_name,
|
||||
database_name, access_method, attr_name, class, index_name,
|
||||
var_name, name, file_name, recipe_name
|
||||
database_name, access_method_clause, access_method, attr_name,
|
||||
class, index_name, var_name, name, file_name, recipe_name
|
||||
|
||||
%type <str> opt_id, opt_portal_name,
|
||||
before_clause, after_clause, all_Op, MathOp, opt_name, opt_unique
|
||||
@ -653,21 +653,25 @@ opt_portal_name: IN name { $$ = $2;}
|
||||
*****************************************************************************/
|
||||
|
||||
IndexStmt: CREATE INDEX index_name ON relation_name
|
||||
USING access_method '(' index_params ')'
|
||||
access_method_clause '(' index_params ')'
|
||||
{
|
||||
/* should check that access_method is valid,
|
||||
etc ... but doesn't */
|
||||
IndexStmt *n = makeNode(IndexStmt);
|
||||
n->idxname = $3;
|
||||
n->relname = $5;
|
||||
n->accessMethod = $7;
|
||||
n->indexParams = $9;
|
||||
n->accessMethod = $6;
|
||||
n->indexParams = $8;
|
||||
n->withClause = NIL;
|
||||
n->whereClause = NULL;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
;
|
||||
|
||||
access_method_clause: USING access_method { $$ = $2; }
|
||||
| /* empty -- 'btree' is default access method */
|
||||
{ $$ = "btree"; }
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* QUERY:
|
||||
|
13
src/backend/utils/cache/syscache.c
vendored
13
src/backend/utils/cache/syscache.c
vendored
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.1.1.1 1996/07/09 06:22:07 scrappy Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.2 1996/08/15 07:42:52 scrappy Exp $
|
||||
*
|
||||
* NOTES
|
||||
* These routines allow the parser/planner/executor to perform
|
||||
@ -304,7 +304,16 @@ static struct cachedesc cacheinfo[] = {
|
||||
0 },
|
||||
offsetof(FormData_pg_proc, prosrc),
|
||||
ProcedureSrcIndex,
|
||||
(ScanFunc) ProcedureSrcIndexScan }
|
||||
(ScanFunc) ProcedureSrcIndexScan },
|
||||
{ OperatorClassRelationName, /* CLADEFTYPE */
|
||||
1,
|
||||
{ Anum_pg_opclass_opcdeftype,
|
||||
0,
|
||||
0,
|
||||
0 },
|
||||
sizeof(FormData_pg_opclass),
|
||||
NULL,
|
||||
(ScanFunc) NULL }
|
||||
};
|
||||
|
||||
static struct catcache *SysCache[lengthof(cacheinfo)];
|
||||
|
@ -6,7 +6,7 @@
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: syscache.h,v 1.1.1.1 1996/07/09 06:22:02 scrappy Exp $
|
||||
* $Id: syscache.h,v 1.2 1996/08/15 07:42:45 scrappy Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -58,6 +58,7 @@
|
||||
#define GROSYSID 24
|
||||
#define REWRITENAME 25
|
||||
#define PROSRC 26
|
||||
#define CLADEFTYPE 27
|
||||
|
||||
/* ----------------
|
||||
* struct cachedesc: information needed for a call to InitSysCache()
|
||||
|
Loading…
Reference in New Issue
Block a user