1 /***************************************************************************
2 * Copyright (C) 2007 by www.databasecache.com *
3 * Contact: praba_tuty@databasecache.com *
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. *
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. *
15 ***************************************************************************/
17 #include <Statement.h>
18 #include <SqlFactory.h>
19 #include <SqlStatement.h>
22 AbsSqlConnection
*conn
;
24 bool interactive
=false;
25 char fileName
[MAX_FILE_LEN
];
27 int main(int argc
, char **argv
)
31 while ((c
= getopt(argc
, argv
, "f:ail?")) != EOF
) {
33 case '?' : { opt
= 1; break; } //print help
34 case 'a' : { opt
= 2; break; }
35 case 'i' : { interactive
= true; break; }
36 case 'l' : { list
= true; break; }
37 case 'f' : {strcpy(fileName
, argv
[optind
- 1]); break;}
38 default: printf("Wrong args\n"); exit(1);
43 printf("This is an internal csql command with i and f <filename> options.");
46 char *verbose
= os::getenv("CSQL_INTERACTIVE");
47 if (verbose
!=NULL
&& strcmp(verbose
, "true") == 0)
49 printf("VERBOSE ON %s\n", verbose
);
52 conn
= SqlFactory::createConnection(CSqlDirect
);
53 DbRetVal rv
= conn
->connect(I_USER
, I_PASS
);
55 printError(ErrNoConnection
, "REDO: could not connect to DB.");
60 if (strcmp(fileName
, "") ==0) {
61 sprintf(fileName
, "%s/csql.db.cur", Conf::config
.getDbFile());
63 SqlConnection
*sCon
= (SqlConnection
*) conn
;
64 if(!list
) rv
= sCon
->getExclusiveLock();
65 //during connection close, this exclusive lock will be automatically released
72 int retVal
= recovery
.applyRedoLogs(fileName
, conn
, list
, interactive
);