typo
[csql.git] / test / dbapi / Index / dupindex1.c
blob9d77ca59c3d407e37818228a3fc70f4a8ae95372
1 #include<CSql.h>
2 //creating two index of same type on same field.
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 rv = dbMgr->createIndex("indx1", idxInfo);
27 if (rv != OK) { printf("Index creation failed\n"); return -1; }
28 printf("Index created for f1\n");
29 int ret =0;
30 rv = dbMgr->createIndex("indx2", idxInfo);
31 if (rv == OK) ret =1;
32 delete idxInfo;
33 dbMgr->dropTable("t1");
34 conn.close();
35 return ret;