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

Commita4402ec

Browse files
committed
Fixes a bug in 'create index'
Submitted by: Dan McGuirk <mcguirk@indirect.com>
1 parentd6fa4d9 commita4402ec

File tree

7 files changed

+106
-59
lines changed

7 files changed

+106
-59
lines changed

‎src/backend/catalog/pg_amop.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: pg_amop.h,v 1.2 1996/07/20 08:19:11 scrappy Exp $
10+
* $Id: pg_amop.h,v 1.3 1996/08/15 07:42:06 scrappy Exp $
1111
*
1212
* NOTES
1313
* the genbki.sh script reads this file and generates .bki
@@ -219,11 +219,11 @@ DATA(insert OID = 0 ( 403 408 462 5 btreesel btreenpage ));
219219
* nbtree name_ops
220220
*/
221221

222-
DATA(insertOID=0 (4034096601btreeselbtreenpage ));
223-
DATA(insertOID=0 (4034096612btreeselbtreenpage ));
224-
DATA(insertOID=0 (403409933btreeselbtreenpage ));
225-
DATA(insertOID=0 (4034096634btreeselbtreenpage ));
226-
DATA(insertOID=0 (4034096625btreeselbtreenpage ));
222+
DATA(insertOID=0 (40311816601btreeselbtreenpage ));
223+
DATA(insertOID=0 (40311816612btreeselbtreenpage ));
224+
DATA(insertOID=0 (4031181933btreeselbtreenpage ));
225+
DATA(insertOID=0 (40311816634btreeselbtreenpage ));
226+
DATA(insertOID=0 (40311816625btreeselbtreenpage ));
227227

228228
/*
229229
* nbtree char16_ops
@@ -453,11 +453,11 @@ DATA(insert OID = 0 ( 404 430 647 5 btreesel btreenpage ));
453453
* nobtree name_ops
454454
*/
455455

456-
DATA(insertOID=0 (4044096601btreeselbtreenpage ));
457-
DATA(insertOID=0 (4044096612btreeselbtreenpage ));
458-
DATA(insertOID=0 (404409933btreeselbtreenpage ));
459-
DATA(insertOID=0 (4044096634btreeselbtreenpage ));
460-
DATA(insertOID=0 (4044096625btreeselbtreenpage ));
456+
DATA(insertOID=0 (40411816601btreeselbtreenpage ));
457+
DATA(insertOID=0 (40411816612btreeselbtreenpage ));
458+
DATA(insertOID=0 (4041181933btreeselbtreenpage ));
459+
DATA(insertOID=0 (40411816634btreeselbtreenpage ));
460+
DATA(insertOID=0 (40411816625btreeselbtreenpage ));
461461

462462
/*
463463
* nobtree text_ops
@@ -526,7 +526,7 @@ DATA(insert OID = 0 ( 405 430 99 1 hashsel hashnpage ));
526526
/*
527527
* hash table name_ops
528528
*/
529-
DATA(insertOID=0 (405409931hashselhashnpage ));
529+
DATA(insertOID=0 (4051181931hashselhashnpage ));
530530
/*
531531
* hash table text_ops
532532
*/

‎src/backend/catalog/pg_amproc.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
* Copyright (c) 1994, Regents of the University of California
1111
*
12-
* $Id: pg_amproc.h,v 1.2 1996/07/20 08:19:13 scrappy Exp $
12+
* $Id: pg_amproc.h,v 1.3 1996/08/15 07:42:07 scrappy Exp $
1313
*
1414
* NOTES
1515
* the genbki.sh script reads this file and generates .bki
@@ -82,7 +82,7 @@ DATA(insert OID = 0 (403 429 358 1));
8282
DATA(insertOID=0 (4034066891));
8383
DATA(insertOID=0 (4034076901));
8484
DATA(insertOID=0 (4034086911));
85-
DATA(insertOID=0 (4034093591));
85+
DATA(insertOID=0 (40311813591));
8686
DATA(insertOID=0 (4034303741));
8787
DATA(insertOID=0 (4034313601));
8888
DATA(insertOID=0 (4034323571));
@@ -108,7 +108,7 @@ DATA(insert OID = 0 (404 429 358 1));
108108
DATA(insertOID=0 (4044066891));
109109
DATA(insertOID=0 (4044076901));
110110
DATA(insertOID=0 (4044086911));
111-
DATA(insertOID=0 (4044093591));
111+
DATA(insertOID=0 (40411813591));
112112
DATA(insertOID=0 (4044303741));
113113
DATA(insertOID=0 (4044313601));
114114
DATA(insertOID=0 (4044323571));
@@ -125,7 +125,7 @@ DATA(insert OID = 0 (405 429 454 1));
125125
DATA(insertOID=0 (4054066921));
126126
DATA(insertOID=0 (4054076931));
127127
DATA(insertOID=0 (4054086941));
128-
DATA(insertOID=0 (4054094551));
128+
DATA(insertOID=0 (40511814551));
129129
DATA(insertOID=0 (4054304991));
130130
DATA(insertOID=0 (4054314561));
131131
DATA(insertOID=0 (405107610801));

‎src/backend/catalog/pg_opclass.h

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: pg_opclass.h,v 1.1.1.1 1996/07/09 06:21:17 scrappy Exp $
10+
* $Id: pg_opclass.h,v 1.2 1996/08/15 07:42:09 scrappy Exp $
1111
*
1212
* NOTES
1313
* the genbki.sh script reads this file and generates .bki
@@ -34,6 +34,7 @@
3434

3535
CATALOG(pg_opclass) {
3636
NameDataopcname;
37+
Oidopcdeftype;
3738
}FormData_pg_opclass;
3839

3940
/* ----------------
@@ -47,39 +48,46 @@ typedef FormData_pg_opclass*Form_pg_opclass;
4748
*compiler constants for pg_opclass
4849
* ----------------
4950
*/
50-
#defineNatts_pg_opclass1
51+
#defineNatts_pg_opclass2
5152
#defineAnum_pg_opclass_opcname1
53+
#defineAnum_pg_opclass_opcdeftype 2
5254

5355
/* ----------------
5456
*initial contents of pg_opclass
5557
* ----------------
5658
*/
5759

58-
DATA(insertOID=406 (char2_ops ));
59-
DATA(insertOID=407 (char4_ops ));
60-
DATA(insertOID=408 (char8_ops ));
61-
DATA(insertOID=409 (name_ops ));
62-
DATA(insertOID=421 (int2_ops ));
63-
DATA(insertOID=422 (box_ops ));
64-
DATA(insertOID=423 (float8_ops ));
65-
DATA(insertOID=424 (int24_ops ));
66-
DATA(insertOID=425 (int42_ops ));
67-
DATA(insertOID=426 (int4_ops ));
60+
/*
61+
* putting _null_'s in the (fixed-length) type field is bad
62+
* (see the README in this directory), so just put zeros
63+
* in, which are invalid OID's anyway. --djm
64+
*/
65+
DATA(insertOID=406 (char2_ops409 ));
66+
DATA(insertOID=407 (char4_ops410 ));
67+
DATA(insertOID=408 (char8_ops411 ));
68+
/* OID 409 is already used in table pg_type--this one should be unused */
69+
DATA(insertOID=1181 (name_ops19 ));
70+
DATA(insertOID=421 (int2_ops21 ));
71+
DATA(insertOID=422 (box_ops603 ));
72+
DATA(insertOID=423 (float8_ops701 ));
73+
DATA(insertOID=424 (int24_ops0 ));
74+
DATA(insertOID=425 (int42_ops0 ));
75+
DATA(insertOID=426 (int4_ops23 ));
6876
#defineINT4_OPS_OID 426
69-
DATA(insertOID=427 (oid_ops ));
70-
DATA(insertOID=428 (float4_ops ));
71-
DATA(insertOID=429 (char_ops ));
72-
DATA(insertOID=430 (char16_ops ));
73-
DATA(insertOID=431 (text_ops ));
74-
DATA(insertOID=432 (abstime_ops ));
75-
DATA(insertOID=433 (bigbox_ops));
76-
DATA(insertOID=434 (poly_ops));
77-
DATA(insertOID=435 (oidint4_ops));
78-
DATA(insertOID=436 (oidname_ops));
79-
DATA(insertOID=437 (oidint2_ops));
80-
DATA(insertOID=1076 (bpchar_ops));
81-
DATA(insertOID=1077 (varchar_ops));
82-
DATA(insertOID=1114 (date_ops));
83-
DATA(insertOID=1115 (time_ops));
77+
DATA(insertOID=427(oid_ops26 ));
78+
DATA(insertOID=428(float4_ops700 ));
79+
DATA(insertOID=429(char_ops18 ));
80+
DATA(insertOID=430(char16_ops20 ));
81+
DATA(insertOID=431(text_ops25 ));
82+
DATA(insertOID=432(abstime_ops702 ));
83+
DATA(insertOID=433(bigbox_ops0));
84+
DATA(insertOID=434(poly_ops604));
85+
DATA(insertOID=435(oidint4_ops910));
86+
DATA(insertOID=436(oidname_ops911));
87+
DATA(insertOID=437(oidint2_ops810));
88+
DATA(insertOID=1076 (bpchar_ops1042));
89+
DATA(insertOID=1077 (varchar_ops1043));
90+
DATA(insertOID=1114 (date_ops1082));
91+
DATA(insertOID=1115 (time_ops1083));
8492

8593
#endif/* PG_OPCLASS_H */

‎src/backend/commands/defind.c

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.1.1.1 1996/07/09 06:21:20 scrappy Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.2 1996/08/15 07:42:19 scrappy Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -23,6 +23,7 @@
2323
#include"catalog/index.h"
2424
#include"catalog/pg_index.h"
2525
#include"catalog/pg_proc.h"
26+
#include"catalog/pg_opclass.h"
2627
#include"nodes/pg_list.h"
2728
#include"nodes/plannodes.h"
2829
#include"nodes/primnodes.h"
@@ -51,6 +52,7 @@ static void FuncIndexArgs(IndexElem *funcIndex, AttrNumber *attNumP,
5152
Oid*argTypes,Oid*opOidP,OidrelId);
5253
staticvoidNormIndexAttrs(List*attList,AttrNumber*attNumP,
5354
Oid*opOidP,OidrelId);
55+
staticchar*GetDefaultOpClass(Oidatttypid);
5456

5557
/*
5658
* DefineIndex --
@@ -439,14 +441,10 @@ NormIndexAttrs(List *attList,/* list of IndexElem's */
439441

440442
for (rest=attList;rest!=NIL;rest=lnext(rest)) {
441443
IndexElem*attribute;
444+
AttributeTupleFormattform;
442445

443446
attribute=lfirst(rest);
444447

445-
if (attribute->class==NULL) {
446-
elog(WARN,
447-
"DefineIndex: default index class unsupported");
448-
}
449-
450448
if (attribute->name==NULL)
451449
elog(WARN,"missing attribute for define index");
452450

@@ -459,7 +457,19 @@ NormIndexAttrs(List *attList,/* list of IndexElem's */
459457
"DefineIndex: attribute \"%s\" not found",
460458
attribute->name);
461459
}
462-
*attNumP++= ((AttributeTupleForm)GETSTRUCT(tuple))->attnum;
460+
461+
attform= (AttributeTupleForm)GETSTRUCT(tuple);
462+
*attNumP++=attform->attnum;
463+
464+
if (attribute->class==NULL) {
465+
/* no operator class specified, so find the default */
466+
attribute->class=GetDefaultOpClass(attform->atttypid);
467+
if(attribute->class==NULL) {
468+
elog(WARN,
469+
"Can't find a default operator class for type %d.",
470+
attform->atttypid);
471+
}
472+
}
463473

464474
tuple=SearchSysCacheTuple(CLANAME,
465475
PointerGetDatum(attribute->class),
@@ -473,6 +483,21 @@ NormIndexAttrs(List *attList,/* list of IndexElem's */
473483
}
474484
}
475485

486+
staticchar*
487+
GetDefaultOpClass(Oidatttypid)
488+
{
489+
HeapTupletuple;
490+
491+
tuple=SearchSysCacheTuple(CLADEFTYPE,
492+
ObjectIdGetDatum(atttypid),
493+
0,0,0);
494+
if(!HeapTupleIsValid(tuple)) {
495+
return0;
496+
}
497+
498+
returnnameout(&(((Form_pg_opclass)GETSTRUCT(tuple))->opcname));
499+
}
500+
476501
/*
477502
* RemoveIndex --
478503
*Deletes an index.

‎src/backend/parser/gram.y

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.6 1996/08/13 01:29:33 scrappy Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.7 1996/08/15 07:42:29 scrappy Exp $
1414
*
1515
* HISTORY
1616
* AUTHORDATEMAJOR EVENT
@@ -109,8 +109,8 @@ static Node *makeA_Expr(int op, char *opname, Node *lexpr, Node *rexpr);
109109
ExplainStmt
110110

111111
%type <str>relation_name, copy_file_name, copy_delimiter, def_name,
112-
database_name,access_method, attr_name, class, index_name,
113-
var_name, name, file_name, recipe_name
112+
database_name,access_method_clause, access_method, attr_name,
113+
class, index_name,var_name, name, file_name, recipe_name
114114

115115
%type <str>opt_id, opt_portal_name,
116116
before_clause, after_clause, all_Op, MathOp, opt_name, opt_unique
@@ -653,21 +653,25 @@ opt_portal_name: IN name{ $$ = $2;}
653653
*****************************************************************************/
654654

655655
IndexStmt: CREATE INDEX index_name ON relation_name
656-
USING access_method '(' index_params ')'
656+
access_method_clause '(' index_params ')'
657657
{
658658
/* should check that access_method is valid,
659659
etc ... but doesn't */
660660
IndexStmt *n = makeNode(IndexStmt);
661661
n->idxname = $3;
662662
n->relname = $5;
663-
n->accessMethod = $7;
664-
n->indexParams = $9;
663+
n->accessMethod = $6;
664+
n->indexParams = $8;
665665
n->withClause = NIL;
666666
n->whereClause = NULL;
667667
$$ = (Node *)n;
668668
}
669669
;
670670

671+
access_method_clause: USING access_method { $$ = $2; }
672+
| /* empty -- 'btree' is default access method */
673+
{ $$ = "btree"; }
674+
671675
/*****************************************************************************
672676
*
673677
*QUERY:

‎src/backend/utils/cache/syscache.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.1.1.1 1996/07/09 06:22:07 scrappy Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.2 1996/08/15 07:42:52 scrappy Exp $
1111
*
1212
* NOTES
1313
* These routines allow the parser/planner/executor to perform
@@ -304,7 +304,16 @@ static struct cachedesc cacheinfo[] = {
304304
0 },
305305
offsetof(FormData_pg_proc,prosrc),
306306
ProcedureSrcIndex,
307-
(ScanFunc)ProcedureSrcIndexScan }
307+
(ScanFunc)ProcedureSrcIndexScan },
308+
{OperatorClassRelationName,/* CLADEFTYPE */
309+
1,
310+
{Anum_pg_opclass_opcdeftype,
311+
0,
312+
0,
313+
0 },
314+
sizeof(FormData_pg_opclass),
315+
NULL,
316+
(ScanFunc)NULL }
308317
};
309318

310319
staticstructcatcache*SysCache[lengthof(cacheinfo)];

‎src/backend/utils/syscache.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: syscache.h,v 1.1.1.1 1996/07/09 06:22:02 scrappy Exp $
9+
* $Id: syscache.h,v 1.2 1996/08/15 07:42:45 scrappy Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -58,6 +58,7 @@
5858
#defineGROSYSID24
5959
#defineREWRITENAME25
6060
#definePROSRC 26
61+
#defineCLADEFTYPE 27
6162

6263
/* ----------------
6364
*struct cachedesc:information needed for a call to InitSysCache()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp