*** empty log message ***
[csql.git] / test / dbapi / Index / compositekeyindex1.c
blob11ef39ee81917f5ccfc4c1a2bd5be83900a8725b
1 #include<CSql.h>
2 //creating index with two fields
3 //It should be Passed
4 int main()
7 Connection conn;
8 DbRetVal rv = conn.open("root", "manager");
9 if (rv != OK)
11 printf("Error during connection %d\n", rv);
12 return -1;
14 DatabaseManager *dbMgr = conn.getDatabaseManager();
15 if (dbMgr == NULL) { printf("Auth failed\n"); return -1;}
16 TableDef tabDef;
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;
27 #ifdef TREEINDEX
28 idxInfo->indType = treeIndex;
29 #elif TRIEINDEX
30 idxInfo->indType = treeIndex;
31 #endif
32 rv = dbMgr->createIndex("indx1", idxInfo);
33 #ifdef TREEINDEX
34 if(rv == OK) { printf("Composite Index creation Passed\n"); return 1; }
35 printf("Composite Index failed as expected\n");
36 #elif TRIEINDEX
37 if(rv == OK) { printf("Composite Index creation Passed\n"); return 1; }
38 printf("Composite Index failed as expected\n");
39 #else
40 if(rv != OK) { printf("Composite Index creation Failed\n"); return 1; }
41 printf("Composite Index created\n");
42 #endif
43 delete idxInfo;
44 dbMgr->dropTable("t1");
45 conn.close();
46 return 0;