test cases for trie index
[csql.git] / test / dbapi / Index / createindexnotexist.c
blob0850402c8efb02dca342d93b8bb17185cf3a7408
1 #include<CSql.h>
2 //creating index with non existing 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("notexist");
25 idxInfo->indType = hashIndex;
26 #ifdef TREEINDEX
27 idxInfo->indType = treeIndex;
28 #elif defined TRIEINDEX
29 idxInfo->indType = trieIndex;
30 #endif
31 int ret =0;
32 rv = dbMgr->createIndex("indx1", idxInfo);
33 if (rv == OK) ret =1;
34 delete idxInfo;
35 dbMgr->dropTable("t1");
36 conn.close();
37 return ret;