truncating redo log file instead of removing it
[csql.git] / src / tools / checkpoint.cxx
blob3f4d41e9e068bb30ddc991164b05dff44d827416
1 /***************************************************************************
2 * Copyright (C) 2007 by www.databasecache.com *
3 * Contact: praba_tuty@databasecache.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 ***************************************************************************/
16 #include <os.h>
17 #include<CSql.h>
18 //#include<DatabaseManagerImpl.h>
19 //#include <Statement.h>
20 #include <SqlFactory.h>
21 #include <SqlConnection.h>
22 //#include <SqlNwConnection.h>
23 //#include <SqlNwStatement.h>
24 //#include <readline/readline.h>
25 //#include <readline/history.h>
26 //#define SQL_STMT_LEN 1024
28 //FILE *fp;
30 AbsSqlConnection *conn = NULL;
31 AbsSqlStatement *stmt = NULL;
33 int main(int argc, char **argv)
35 char username[IDENTIFIER_LENGTH];
36 username [0] = '\0';
37 char password[IDENTIFIER_LENGTH];
38 password [0] = '\0';
39 char filename[512];
40 filename [0] ='\0';
41 int c = 0, opt=0;
42 int connOpt = 0;
43 /* while ((c = getopt(argc, argv, "u:p:")) != EOF)
45 switch (c)
47 case 'u' : strcpy(username , argv[optind - 1]); break;
48 case 'p' : strcpy(password , argv[optind - 1]); break;
49 default: printf("Wrong args\n"); exit(1);
52 }*/
55 conn = SqlFactory::createConnection(CSqlDirect);
56 DbRetVal rv = conn->connect(I_USER, I_PASS);
57 if (rv != OK) {
58 delete conn;
59 return 1;
61 SqlConnection *sqlcon = (SqlConnection *) conn;
62 rv = sqlcon->getExclusiveLock();
63 if (rv != OK) {
64 conn->disconnect();
65 delete conn;
66 return 2;
68 DatabaseManager *dbMgr = conn->getConnObject().getDatabaseManager();
69 rv = dbMgr->checkPoint();
70 if (rv != OK) {
71 printError(rv, "checkpoint: failed");
72 conn->disconnect();
73 return 3;
75 conn->disconnect();
76 delete conn;
77 return 0;