|
| 1 | +/*------------------------------------------------------------------------- |
| 2 | + * |
| 3 | + * multikey.c-- |
| 4 | + * POSTGRES multikey indices create code. |
| 5 | + * |
| 6 | + *------------------------------------------------------------------------- |
| 7 | + */ |
| 8 | +#include<stdio.h> |
| 9 | +#include<string.h> |
| 10 | + |
| 11 | +#include<postgres.h> |
| 12 | + |
| 13 | +#include<storage/lmgr.h> |
| 14 | +#include<nodes/parsenodes.h> |
| 15 | +#include<commands/defrem.h> |
| 16 | +#include<utils/builtins.h> |
| 17 | + |
| 18 | +int4create_mki_2 (structvarlena*index,structvarlena*rel, |
| 19 | +structvarlena*a1,structvarlena*a2); |
| 20 | +int4create_mki_3 (structvarlena*index,structvarlena*rel, |
| 21 | +structvarlena*a1,structvarlena*a2, |
| 22 | +structvarlena*a3); |
| 23 | +int4create_mki_4 (structvarlena*index,structvarlena*rel, |
| 24 | +structvarlena*a1,structvarlena*a2, |
| 25 | +structvarlena*a3,structvarlena*a4); |
| 26 | + |
| 27 | +externboolFastBuild; |
| 28 | +staticboolBuildMode; |
| 29 | + |
| 30 | + |
| 31 | +int4create_mki_2 (structvarlena*index,structvarlena*rel, |
| 32 | +structvarlena*a1,structvarlena*a2) |
| 33 | +{ |
| 34 | +char*indexname=textout (index); |
| 35 | +char*relname=textout (rel); |
| 36 | +char*a1name=textout (a1); |
| 37 | +char*a2name=textout (a2); |
| 38 | +IndexElem*ie1=makeNode(IndexElem); |
| 39 | +IndexElem*ie2=makeNode(IndexElem); |
| 40 | +List*alist; |
| 41 | + |
| 42 | +ie1->name=a1name; |
| 43 | +ie1->args=NIL;ie1->class=NULL;ie1->tname= (TypeName*)NULL; |
| 44 | +ie2->name=a2name; |
| 45 | +ie2->args=NIL;ie2->class=NULL;ie2->tname= (TypeName*)NULL; |
| 46 | + |
| 47 | +alist=lcons (ie2,NIL); |
| 48 | +alist=lcons (ie1,alist); |
| 49 | + |
| 50 | +BuildMode=FastBuild; |
| 51 | +FastBuild= false;/* for the moment */ |
| 52 | + |
| 53 | +DefineIndex (relname,indexname,"btree",alist, |
| 54 | + (List*)NULL, false, (Expr*)NULL, (List*)NULL); |
| 55 | + |
| 56 | +FastBuild=BuildMode; |
| 57 | + |
| 58 | +return (0); |
| 59 | + |
| 60 | +} |
| 61 | + |
| 62 | + |
| 63 | +int4create_mki_3 (structvarlena*index,structvarlena*rel, |
| 64 | +structvarlena*a1,structvarlena*a2, |
| 65 | +structvarlena*a3) |
| 66 | +{ |
| 67 | +char*indexname=textout (index); |
| 68 | +char*relname=textout (rel); |
| 69 | +char*a1name=textout (a1); |
| 70 | +char*a2name=textout (a2); |
| 71 | +char*a3name=textout (a3); |
| 72 | +IndexElem*ie1=makeNode(IndexElem); |
| 73 | +IndexElem*ie2=makeNode(IndexElem); |
| 74 | +IndexElem*ie3=makeNode(IndexElem); |
| 75 | +List*alist; |
| 76 | + |
| 77 | +ie1->name=a1name; |
| 78 | +ie1->args=NIL;ie1->class=NULL;ie1->tname= (TypeName*)NULL; |
| 79 | +ie2->name=a2name; |
| 80 | +ie2->args=NIL;ie2->class=NULL;ie2->tname= (TypeName*)NULL; |
| 81 | +ie3->name=a3name; |
| 82 | +ie3->args=NIL;ie3->class=NULL;ie3->tname= (TypeName*)NULL; |
| 83 | + |
| 84 | +alist=lcons (ie3,NIL); |
| 85 | +alist=lcons (ie2,alist); |
| 86 | +alist=lcons (ie1,alist); |
| 87 | + |
| 88 | +BuildMode=FastBuild; |
| 89 | +FastBuild= false;/* for the moment */ |
| 90 | + |
| 91 | +DefineIndex (relname,indexname,"btree",alist, |
| 92 | + (List*)NULL, false, (Expr*)NULL, (List*)NULL); |
| 93 | + |
| 94 | +FastBuild=BuildMode; |
| 95 | + |
| 96 | +return (0); |
| 97 | + |
| 98 | +} |
| 99 | + |
| 100 | + |
| 101 | +int4create_mki_4 (structvarlena*index,structvarlena*rel, |
| 102 | +structvarlena*a1,structvarlena*a2, |
| 103 | +structvarlena*a3,structvarlena*a4) |
| 104 | +{ |
| 105 | +char*indexname=textout (index); |
| 106 | +char*relname=textout (rel); |
| 107 | +char*a1name=textout (a1); |
| 108 | +char*a2name=textout (a2); |
| 109 | +char*a3name=textout (a3); |
| 110 | +char*a4name=textout (a4); |
| 111 | +IndexElem*ie1=makeNode(IndexElem); |
| 112 | +IndexElem*ie2=makeNode(IndexElem); |
| 113 | +IndexElem*ie3=makeNode(IndexElem); |
| 114 | +IndexElem*ie4=makeNode(IndexElem); |
| 115 | +List*alist; |
| 116 | + |
| 117 | +ie1->name=a1name; |
| 118 | +ie1->args=NIL;ie1->class=NULL;ie1->tname= (TypeName*)NULL; |
| 119 | +ie2->name=a2name; |
| 120 | +ie2->args=NIL;ie2->class=NULL;ie2->tname= (TypeName*)NULL; |
| 121 | +ie3->name=a3name; |
| 122 | +ie3->args=NIL;ie3->class=NULL;ie3->tname= (TypeName*)NULL; |
| 123 | +ie4->name=a4name; |
| 124 | +ie4->args=NIL;ie4->class=NULL;ie4->tname= (TypeName*)NULL; |
| 125 | + |
| 126 | +alist=lcons (ie4,NIL); |
| 127 | +alist=lcons (ie3,alist); |
| 128 | +alist=lcons (ie2,alist); |
| 129 | +alist=lcons (ie1,alist); |
| 130 | + |
| 131 | +BuildMode=FastBuild; |
| 132 | +FastBuild= false;/* for the moment */ |
| 133 | + |
| 134 | +DefineIndex (relname,indexname,"btree",alist, |
| 135 | + (List*)NULL, false, (Expr*)NULL, (List*)NULL); |
| 136 | + |
| 137 | +FastBuild=BuildMode; |
| 138 | + |
| 139 | +return (0); |
| 140 | + |
| 141 | +} |