~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzledump.cc

  • Committer: Brian Aker
  • Date: 2008-12-02 16:33:43 UTC
  • mfrom: (632.1.19 devel)
  • Revision ID: brian@tangent.org-20081202163343-007ifg17p0lvjga7
Merge from Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
604
604
}
605
605
 
606
606
 
607
 
static unsigned char* get_table_key(const char *entry, size_t *length,
608
 
                            bool not_used __attribute__((unused)))
 
607
static unsigned char* get_table_key(const char *entry, size_t *length, bool)
609
608
{
610
609
  *length= strlen(entry);
611
610
  return (unsigned char*) entry;
612
611
}
613
612
 
614
613
 
615
 
static bool
616
 
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
617
 
               char *argument)
 
614
extern "C"
 
615
bool get_one_option(int optid, const struct my_option *, char *argument)
618
616
{
619
617
  switch (optid) {
620
618
  case 'p':
716
714
                                    &err_ptr, &error_len);
717
715
      if (error_len)
718
716
      {
719
 
        strmake(buff, err_ptr, min((uint32_t)sizeof(buff), error_len));
 
717
        strncpy(buff, err_ptr, min((uint32_t)sizeof(buff), error_len));
720
718
        fprintf(stderr, "Invalid mode to --compatible: %s\n", buff);
721
719
        exit(1);
722
720
      }
963
961
 
964
962
  @returns  whether there was an error or not
965
963
*/
966
 
static int switch_character_set_results(DRIZZLE *drizzle, const char *cs_name)
 
964
static int switch_character_set_results(const char *cs_name)
967
965
{
968
966
  char query_buffer[QUERY_LENGTH];
969
967
  size_t query_length;
975
973
  query_length= snprintf(query_buffer,
976
974
                         sizeof (query_buffer),
977
975
                         "SET SESSION character_set_results = '%s'",
978
 
                         (const char *) cs_name);
 
976
                         cs_name);
979
977
 
980
978
  return drizzle_real_query(drizzle, query_buffer, query_length);
981
979
}
1415
1413
  if ((write_data= !(*ignore_flag & IGNORE_DATA)))
1416
1414
  {
1417
1415
    complete_insert= opt_complete_insert;
1418
 
    insert_pat= "";
 
1416
    insert_pat.clear();
1419
1417
  }
1420
1418
 
1421
1419
  insert_option= ((delayed && opt_ignore) ? " DELAYED IGNORE " :
1447
1445
 
1448
1446
      snprintf(buff, sizeof(buff), "show create table %s", result_table);
1449
1447
 
1450
 
      if (switch_character_set_results(drizzle, "binary") ||
 
1448
      if (switch_character_set_results("binary") ||
1451
1449
          drizzle_query_with_error_report(drizzle, &result, buff) ||
1452
 
          switch_character_set_results(drizzle, default_charset))
 
1450
          switch_character_set_results(default_charset))
1453
1451
        return(0);
1454
1452
 
1455
1453
      if (path)
1506
1504
        */
1507
1505
        snprintf(query_buff, sizeof(query_buff),
1508
1506
                 "SHOW FIELDS FROM %s", result_table);
1509
 
        if (switch_character_set_results(drizzle, "binary") ||
 
1507
        if (switch_character_set_results("binary") ||
1510
1508
            drizzle_query_with_error_report(drizzle, &result, query_buff) ||
1511
 
            switch_character_set_results(drizzle, default_charset))
 
1509
            switch_character_set_results(default_charset))
1512
1510
        {
1513
1511
          /*
1514
1512
            View references invalid or privileged table/col/fun (err 1356),
2204
2202
        if (extended_insert && !opt_xml)
2205
2203
        {
2206
2204
          if (i == 0)
2207
 
            extended_row= "(";
 
2205
          {
 
2206
            extended_row.clear();
 
2207
            extended_row.append("(");
 
2208
          }
2208
2209
          else
2209
2210
            extended_row.append(",");
2210
2211
 
2589
2590
    print_xml_tag(md_result_file, "", "\n", "database", "name=", database, NULL);
2590
2591
  if (lock_tables)
2591
2592
  {
2592
 
    string query;
2593
 
    query= "LOCK TABLES ";
 
2593
    string query("LOCK TABLES ");
2594
2594
    for (numrows= 0 ; (table= getTableName(1)) ; )
2595
2595
    {
2596
2596
      char *end= my_stpcpy(afterdot, table);
2689
2689
static int dump_selected_tables(char *db, char **table_names, int tables)
2690
2690
{
2691
2691
  char table_buff[NAME_LEN*2+3];
2692
 
  string lock_tables_query;
 
2692
  string lock_tables_query("LOCK TABLES ");
2693
2693
  MEM_ROOT root;
2694
2694
  char **dump_tables, **pos, **end;
2695
2695
 
2701
2701
  if (!(dump_tables= pos= (char**) alloc_root(&root, tables * sizeof(char *))))
2702
2702
     die(EX_EOM, "alloc_root failure.");
2703
2703
 
2704
 
  lock_tables_query= "LOCK TABLES ";
2705
2704
  for (; tables > 0 ; tables-- , table_names++)
2706
2705
  {
2707
2706
    /* the table name passed on commandline may be wrong case */
2975
2974
    Only one row is returned, and the first column is the name of the
2976
2975
    active log.
2977
2976
  */
2978
 
  strmake(buff_log_name, row[0], buff_len - 1);
 
2977
  strncpy(buff_log_name, row[0], buff_len - 1);
2979
2978
 
2980
2979
  drizzle_free_result(res);
2981
2980
  return 0;
3047
3046
 
3048
3047
      for (; pos != end && *pos != ','; pos++) ;
3049
3048
      var_len= (uint32_t) (pos - start);
3050
 
      strmake(buff, start, min((uint32_t)sizeof(buff), var_len));
 
3049
      strncpy(buff, start, min((uint32_t)sizeof(buff), var_len));
3051
3050
      find= find_type(buff, lib, var_len);
3052
3051
      if (!find)
3053
3052
      {
3055
3054
        *err_len= var_len;
3056
3055
      }
3057
3056
      else
3058
 
        found|= ((int64_t) 1 << (find - 1));
 
3057
        found|= (uint32_t)((int64_t) 1 << (find - 1));
3059
3058
      if (pos == end)
3060
3059
        break;
3061
3060
      start= pos + 1;
3148
3147
    return(result);                         /* assume table is ok */
3149
3148
  }
3150
3149
  if (!(row[1]))
3151
 
    strmake(table_type, "VIEW", NAME_LEN-1);
 
3150
    strncpy(table_type, "VIEW", NAME_LEN-1);
3152
3151
  else
3153
3152
  {
3154
3153
    /*
3157
3156
      these types, but we do want to use delayed inserts in the dump if
3158
3157
      the table type is _NOT_ one of these types
3159
3158
    */
3160
 
    strmake(table_type, row[1], NAME_LEN-1);
 
3159
    strncpy(table_type, row[1], NAME_LEN-1);
3161
3160
    if (opt_delayed)
3162
3161
    {
3163
3162
      if (strcmp(table_type,"MyISAM") &&