lock manager and chunk allocation mutex modificationsw
[csql.git] / test / dbapi / Index / dupindex2.c
blobd590a4820fff9aa209b66c4550d10ebf0e4f7ab5
1 #include<CSql.h>
2 //creating two index of same type on different field with same name
3 //It should fail
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, 0, NULL, true);
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->indType = hashIndex;
26 #ifdef TREEINDEX
27 idxInfo->indType = treeIndex;
28 #endif
29 rv = dbMgr->createIndex("indx1", idxInfo);
30 if (rv != OK) { printf("Index creation failed\n"); return -1; }
31 printf("Index created for f1\n");
33 idxInfo->list.remove("f1");
34 idxInfo->list.append("f2");
35 int ret =0;
36 rv = dbMgr->createIndex("indx1", idxInfo);
37 if (rv == OK) ret =1;
38 delete idxInfo;
39 dbMgr->dropTable("t1");
40 conn.close();
41 return ret;