2 //creating index with two fields
8 DbRetVal rv
= conn
.open("root", "manager");
11 printf("Error during connection %d\n", rv
);
14 DatabaseManager
*dbMgr
= conn
.getDatabaseManager();
15 if (dbMgr
== NULL
) { printf("Auth failed\n"); return -1;}
17 tabDef
.addField("f1", typeInt
);
18 tabDef
.addField("f2", typeInt
);
19 rv
= dbMgr
->createTable("t1", tabDef
);
20 if (rv
!= OK
) { printf("Table creation failed\n"); return -1; }
21 printf("Table created\n");
22 HashIndexInitInfo
*idxInfo
= new HashIndexInitInfo();
23 strcpy(idxInfo
->tableName
, "t1");
24 idxInfo
->list
.append("f1");
25 idxInfo
->list
.append("f2");
26 idxInfo
->indType
= hashIndex
;
28 idxInfo
->indType
= treeIndex
;
30 idxInfo
->indType
= treeIndex
;
32 rv
= dbMgr
->createIndex("indx1", idxInfo
);
34 if(rv
== OK
) { printf("Composite Index creation Passed\n"); return 1; }
35 printf("Composite Index failed as expected\n");
37 if(rv
== OK
) { printf("Composite Index creation Passed\n"); return 1; }
38 printf("Composite Index failed as expected\n");
40 if(rv
!= OK
) { printf("Composite Index creation Failed\n"); return 1; }
41 printf("Composite Index created\n");
44 dbMgr
->dropTable("t1");