test cases for trie index
[csql.git] / test / dbapi / Index / primarynonunique.c
blob9b5fc0789f1ccd3cb7132ddb10468ec779683263
1 #include<CSql.h>
2 //creating index with primary attribute set but unique unset
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);
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 idxInfo->isUnique = false;
28 idxInfo->isPrimary = true;
29 rv = dbMgr->createIndex("indx1", idxInfo);
30 int ret = 0;
31 if (rv == OK) ret =1;
32 delete idxInfo;
33 dbMgr->dropTable("t1");
34 conn.close();
35 return ret;