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 ***************************************************************************/
21 printf("Usage: repltable [-U username] [-P passwd] -t tablename \n"
22 " [-m TSYNC|ASYNC>][-u] [-r] \n");
23 printf(" username -> username to connect with csql.\n");
24 printf(" passwd -> password for the above username to connect with csql.\n");
25 printf(" tablename -> table name to be replicated in csql with peers.\n");
26 printf(" u -> unreplicate the table\n");
27 printf(" r -> replicate and load all the records from peer site\n");
28 printf(" m -> replication mode for the table\n");
29 printf(" -> Modes could be one of TSYNC|ASYNC\n");
30 printf(" no option -> replicates with default mode ASYNC\n");
31 printf(" Note:Table should not have any records for this command to succeed\n");
35 int main(int argc
, char **argv
)
37 char username
[IDENTIFIER_LENGTH
];
39 char password
[IDENTIFIER_LENGTH
];
42 char tablename
[IDENTIFIER_LENGTH
];
43 char syncModeStr
[IDENTIFIER_LENGTH
];
44 bool tableNameSpecified
= false;
45 while ((c
= getopt(argc
, argv
, "U:P:t:l:m:u?")) != EOF
)
49 case 'U' : { strcpy(username
, argv
[optind
- 1]); opt
=10; break; }
50 case 'P' : { strcpy(password
, argv
[optind
- 1]); opt
=10; break; }
51 case 't' : { strcpy(tablename
, argv
[optind
- 1]);
53 tableNameSpecified
= true;
56 case '?' : { opt
= 10; break; } //print help
57 case 'r' : { opt
= 4; break; } //replicate the table
58 case 'u' : { opt
= 5; break; } //unreplicate the table
68 //printf("%s %s \n", username, password);
69 if (username
[0] == '\0' )
71 strcpy(username
, "root");
72 strcpy(password
, "manager");