1
[csql.git] / test / dbapi / TableDef / fieldcount2.c
blob09b2d7caa5fdd8088de696bf26d06f1fcd4d9017
1 //100 times addField f1 and dropField f1. getFieldCount() should return 0
2 //and table creation should fail saying no fields in tabledef
3 #include<CSql.h>
4 int main()
6 Connection conn;
7 DbRetVal rv = conn.open("root", "manager");
8 if (rv != OK) return 1;
9 DatabaseManager *dbMgr = conn.getDatabaseManager();
10 if (dbMgr == NULL) { printf("Auth failed\n"); return 2;}
12 TableDef tabDef;
13 for (int i=0;i<100;i++)
15 tabDef.addField("f1", typeInt);
16 tabDef.dropField("f1");
18 int fieldcount=tabDef.getFieldCount();
19 printf("Number of Fields = %d\n",fieldcount);
20 rv=dbMgr->createTable("t1", tabDef);
21 if(rv==OK)
23 printf("Table created without Fields\n");
24 printf("Test failed\n");
25 dbMgr->dropTable("t1");
26 return 3;
29 dbMgr->dropTable("t1");
30 conn.close();
31 return 0;