string suport <= and >=
[csql.git] / test / dbapi / Index / multiplecompositeindex1.c
blob3a6bf63fd42471499c8e3d3e94c14ec79e8c7e40
1 // create table t1(f1 int,f2 int,f3 int)
2 // create composite index cmpidx on t1(f1,f2,f3)
3 // create composite index cmpidx1 on t1(f1,f2)
4 // create composite index cmpidx2 on t1(f2,f3);
6 #include<CSql.h>
7 int main()
9 Connection conn;
10 DbRetVal rv = conn.open("root","manager");
11 if(rv!=OK)
13 printf("Connection Failed with return value %d\n",rv);
14 return 1;
16 DatabaseManager *dbmgr=conn.getDatabaseManager();
17 if(dbmgr==NULL) { printf("Authentication Failed\n"); return 2;}
18 TableDef tabDef;
19 tabDef.addField("f1",typeInt,0,NULL,true);
20 tabDef.addField("f2",typeInt);
21 tabDef.addField("f3",typeInt);
22 rv=dbmgr->createTable("t1", tabDef);
23 if (rv != OK) { printf("Table creation failed\n"); return 3; }
24 printf("Table created\n");
26 HashIndexInitInfo *idx1 = new HashIndexInitInfo();
27 strcpy(idx1->tableName, "t1");
28 idx1->list.append("f1");
29 idx1->list.append("f2");
30 idx1->list.append("f3");
31 idx1->indType = hashIndex;
32 rv = dbmgr->createIndex("cmpidx", idx1);
33 if(rv != OK) { printf("Composite Index creation Failed\n"); return 4; }
34 printf("Composite Index 'cmpidx' created on t1(f1,f2,f3)\n");
35 delete idx1;
37 HashIndexInitInfo *idx2 = new HashIndexInitInfo();
38 strcpy(idx2->tableName, "t1");
39 idx2->list.append("f1");
40 idx2->list.append("f2");
41 idx2->indType = hashIndex;
42 rv = dbmgr->createIndex("cmpidx1", idx2);
43 if(rv != OK) { printf("Composite Index creation Failed\n"); return 5; }
44 printf("Composite Index 'cmpidx1' created on t1(f1,f2)\n");
45 delete idx2;
47 HashIndexInitInfo *idx3 = new HashIndexInitInfo();
48 strcpy(idx3->tableName, "t1");
49 idx3->list.append("f2");
50 idx3->list.append("f3");
51 idx3->indType = hashIndex;
52 rv = dbmgr->createIndex("cmpidx2", idx3);
53 if(rv != OK) { printf("Composite Index creation Failed\n"); return 5; }
54 printf("Composite Index 'cmpidx2' created on t1(f2,f3)\n");
55 delete idx3;
57 HashIndexInitInfo *idx4 = new HashIndexInitInfo();
58 strcpy(idx4->tableName, "t1");
59 idx4->list.append("f1");
60 idx4->list.append("f3");
61 idx4->indType = hashIndex;
62 rv = dbmgr->createIndex("cm4)dx3", idx4);
63 if(rv != OK) { printf("Composite Index creation Failed\n"); return 5; }
64 printf("Composite Index 'cmpidx3' created on t1(f1,f3)\n");
65 delete idx4;
66 dbmgr->dropTable("t1");
67 conn.close();
68 return 0;