~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzleimport.cc

  • Committer: Stewart Smith
  • Date: 2010-02-15 01:56:32 UTC
  • mto: (1273.13.96 build)
  • mto: This revision was merged to the branch mainline in revision 1308.
  • Revision ID: stewart@flamingspork.com-20100215015632-pm7lnxfq5j5uh8kj
move DATABASE() to function plugin. modify parser so that it looks for a function named 'database' when DATABASE() is called. Special case still needed in parser due to hilarity of not-really-reserved words.

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
static uint32_t opt_drizzle_port= 0;
68
68
static int64_t opt_ignore_lines= -1;
69
69
 
70
 
static struct option my_long_options[] =
 
70
static struct my_option my_long_options[] =
71
71
{
72
72
  {"columns", 'c',
73
73
   "Use only these columns to import the data to. Give the column names in a comma separated list. This is same as giving columns to LOAD DATA INFILE.",
113
113
   "Use LOW_PRIORITY when updating the table.", (char**) &opt_low_priority,
114
114
   (char**) &opt_low_priority, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
115
115
  {"mysql", 'm', N_("Use MySQL Protocol."),
116
 
   (char**) &opt_mysql, (char**) &opt_mysql, 0, GET_BOOL, NO_ARG, 1, 0, 0,
 
116
   (char**) &opt_mysql, (char**) &opt_mysql, 0, GET_BOOL, NO_ARG, 0, 0, 0,
117
117
   0, 0, 0},
118
118
  {"password", 'P',
119
119
   "Password to use when connecting to server. If password is not given it's asked from the tty.",
170
170
  my_print_variables(my_long_options);
171
171
}
172
172
 
173
 
static int get_one_option(int optid, const struct option *, char *argument)
 
173
static bool get_one_option(int optid, const struct my_option *, char *argument)
174
174
{
175
175
  char *endchar= NULL;
176
176
  uint64_t temp_drizzle_port= 0;
182
182
    if (strlen(endchar) != 0)
183
183
    {
184
184
      fprintf(stderr, _("Non-integer value supplied for port.  If you are trying to enter a password please use --password instead.\n"));
185
 
      return EXIT_ARGUMENT_INVALID;
 
185
      exit(1);
186
186
    }
187
187
    /* If the port number is > 65535 it is not a valid port
188
188
       This also helps with potential data loss casting unsigned long to a
190
190
    if ((temp_drizzle_port == 0) || (temp_drizzle_port > 65535))
191
191
    {
192
192
      fprintf(stderr, _("Value supplied for port is not valid.\n"));
193
 
      return EXIT_ARGUMENT_INVALID;
 
193
      exit(1);
194
194
    }
195
195
    else
196
196
    {
208
208
      {
209
209
        fprintf(stderr, "Memory allocation error while copying password. "
210
210
                        "Aborting.\n");
211
 
        return EXIT_OUT_OF_MEMORY;
 
211
        exit(ENOMEM);
212
212
      }
213
213
      while (*argument)
214
214
      {
286
286
    if (verbose)
287
287
      fprintf(stdout, "Deleting the old data from table %s\n", tablename);
288
288
#ifdef HAVE_SNPRINTF
289
 
    snprintf(sql_statement, sizeof(sql_statement), "DELETE FROM %s", tablename);
 
289
    snprintf(sql_statement, FN_REFLEN*16+256, "DELETE FROM %s", tablename);
290
290
#else
291
 
    snprintf(sql_statement, sizeof(sql_statement), "DELETE FROM %s", tablename);
 
291
    sprintf(sql_statement, "DELETE FROM %s", tablename);
292
292
#endif
293
293
    if (drizzle_query_str(con, &result, sql_statement, &ret) == NULL ||
294
294
        ret != DRIZZLE_RETURN_OK)
307
307
      fprintf(stdout, "Loading data from SERVER file: %s into %s\n",
308
308
        hard_path, tablename);
309
309
  }
310
 
  snprintf(sql_statement, sizeof(sql_statement), "LOAD DATA %s %s INFILE '%s'",
 
310
  sprintf(sql_statement, "LOAD DATA %s %s INFILE '%s'",
311
311
    opt_low_priority ? "LOW_PRIORITY" : "",
312
312
    opt_local_file ? "LOCAL" : "", hard_path);
313
313
  end= strchr(sql_statement, '\0');