~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzleimport.cc

  • Committer: Brian Aker
  • Date: 2008-08-10 17:18:41 UTC
  • mfrom: (287.3.13 codestyle)
  • Revision ID: brian@tangent.org-20080810171841-pkvi2ky94wbd0nt5
Merge from Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
*/
27
27
#define IMPORT_VERSION "3.7"
28
28
 
 
29
#include <string>
 
30
 
29
31
#include "client_priv.h"
30
 
#include <mysys/my_pthread.h>
 
32
#include <pthread.h>
31
33
 
 
34
using namespace std;
32
35
 
33
36
/* Global Thread counter */
34
37
uint counter;
42
45
           const char *statement);
43
46
 
44
47
static bool  verbose=0,lock_tables=0,ignore_errors=0,opt_delete=0,
45
 
    replace=0,silent=0,ignore=0,opt_compress=0,
46
 
                opt_low_priority= 0, tty_password= 0;
 
48
  opt_replace=0,silent=0,ignore=0,opt_compress=0,
 
49
  opt_low_priority= 0, tty_password= 0;
47
50
static bool debug_info_flag= 0, debug_check_flag= 0;
48
51
static uint opt_use_threads=0, opt_local_file=0, my_end_arg= 0;
49
52
static char  *opt_password=0, *current_user=0,
128
131
  {"protocol", OPT_DRIZZLE_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).",
129
132
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
130
133
  {"replace", 'r', "If duplicate unique key was found, replace old row.",
131
 
   (char**) &replace, (char**) &replace, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
 
134
   (char**) &opt_replace, (char**) &opt_replace, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
132
135
  {"silent", 's', "Be more silent.", (char**) &silent, (char**) &silent, 0,
133
136
   GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
134
137
  {"socket", 'S', "Socket file to use for connection.",
227
230
    fprintf(stderr, "You can't use ..enclosed.. and ..optionally-enclosed.. at the same time.\n");
228
231
    return(1);
229
232
  }
230
 
  if (replace && ignore)
 
233
  if (opt_replace && ignore)
231
234
  {
232
235
    fprintf(stderr, "You can't use --ignore (-i) and --replace (-r) at the same time.\n");
233
236
    return(1);
290
293
    opt_low_priority ? "LOW_PRIORITY" : "",
291
294
    opt_local_file ? "LOCAL" : "", hard_path);
292
295
  end= strend(sql_statement);
293
 
  if (replace)
 
296
  if (opt_replace)
294
297
    end= stpcpy(end, " REPLACE");
295
298
  if (ignore)
296
299
    end= stpcpy(end, " IGNORE");
331
334
 
332
335
static void lock_table(DRIZZLE *drizzle, int tablecount, char **raw_tablename)
333
336
{
334
 
  DYNAMIC_STRING query;
 
337
  string query;
335
338
  int i;
336
339
  char tablename[FN_REFLEN];
337
340
 
338
341
  if (verbose)
339
342
    fprintf(stdout, "Locking tables for write\n");
340
 
  init_dynamic_string(&query, "LOCK TABLES ", 256, 1024);
 
343
  query.append("LOCK TABLES ");
341
344
  for (i=0 ; i < tablecount ; i++)
342
345
  {
343
346
    fn_format(tablename, raw_tablename[i], "", "", 1 | 2);
344
 
    dynstr_append(&query, tablename);
345
 
    dynstr_append(&query, " WRITE,");
 
347
    query.append(tablename);
 
348
    query.append(" WRITE,");
346
349
  }
347
 
  if (drizzle_real_query(drizzle, query.str, query.length-1))
 
350
  if (drizzle_real_query(drizzle, query.c_str(), query.length()-1))
348
351
    db_error(drizzle); /* We shall countinue here, if --force was given */
349
352
}
350
353
 
473
476
 
474
477
int exitcode= 0;
475
478
 
476
 
static pthread_handler_t worker_thread(void *arg)
 
479
static void * worker_thread(void *arg)
477
480
{
478
481
  int error;
479
482
  char *raw_table_name= (char *)arg;