~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzledump.cc

Merged LinuxJedi.

Show diffs side-by-side

added added

removed removed

Lines of Context:
94
94
                opt_include_master_host_port= false,
95
95
                opt_alltspcs= false;
96
96
static bool debug_info_flag= false, debug_check_flag= false;
97
 
static uint32_t opt_max_allowed_packet, opt_net_buffer_length;
 
97
static uint32_t opt_max_allowed_packet, opt_net_buffer_length, show_progress_size= 0;
 
98
static uint64_t total_rows= 0;
98
99
static DRIZZLE drizzle_connection, *drizzle= 0;
99
100
static string insert_pat;
100
101
static char  *opt_password= NULL, *current_user= NULL,
392
393
   (char**) &path, (char**) &path, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
393
394
  {"tables", OPT_TABLES, "Overrides option --databases (-B).",
394
395
   0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
 
396
  {"show-progress-size", OPT_SHOW_PROGRESS_SIZE, N_("Number of rows before each output progress report (requires --verbose)."),
 
397
   (char**) &show_progress_size, (char**) &show_progress_size, 0, GET_ULONG, REQUIRED_ARG,
 
398
   10000, 0, 0, 0, 0, 0},
395
399
#ifndef DONT_ALLOW_USER_CHANGE
396
400
  {"user", 'u', "User for login if not current user.",
397
401
   (char**) &current_user, (char**) &current_user, 0, GET_STR, REQUIRED_ARG,
417
421
static void print_value(FILE *file, DRIZZLE_RES  *result, DRIZZLE_ROW row,
418
422
                        const char *prefix,const char *name,
419
423
                        int string_value);
 
424
static const char* fetch_named_row(DRIZZLE_RES *result, DRIZZLE_ROW row, const char* name);
420
425
static int dump_selected_tables(char *db, char **table_names, int tables);
421
426
static int dump_all_tables_in_db(char *db);
422
427
static int init_dumping_tables(char *);
1681
1686
        fputs("\n)",sql_file);
1682
1687
        check_io(sql_file);
1683
1688
      }
1684
 
 
1685
1689
      /* Get DRIZZLE specific create options */
1686
1690
      if (create_options)
1687
1691
      {
1715
1719
            print_value(sql_file,result,row,"engine=","Engine",0);
1716
1720
            print_value(sql_file,result,row,"","Create_options",0);
1717
1721
            print_value(sql_file,result,row,"comment=","Comment",1);
 
1722
 
1718
1723
            fputs(" */",sql_file);
1719
1724
            check_io(sql_file);
1720
1725
          }
2026
2031
      uint i;
2027
2032
      uint32_t *lengths= drizzle_fetch_lengths(res);
2028
2033
      rownr++;
 
2034
      if ((rownr % show_progress_size) == 0)
 
2035
      {
 
2036
        verbose_msg(_("-- %"PRIu32" of ~%"PRIu64" rows dumped for table %s\n"), rownr, total_rows, opt_quoted_table);
 
2037
      }
2029
2038
      if (!extended_insert && !opt_xml)
2030
2039
      {
2031
2040
        fputs(insert_pat.c_str(),md_result_file);
2923
2932
  return;                                       /* This shouldn't happen */
2924
2933
} /* print_value */
2925
2934
 
 
2935
/**
 
2936
 * Fetches a row from a result based on a field name
 
2937
 * Returns const char* of the data in that row or NULL if not found
 
2938
 */
 
2939
 
 
2940
static const char* fetch_named_row(DRIZZLE_RES *result, DRIZZLE_ROW row, const char *name)
 
2941
{
 
2942
  DRIZZLE_FIELD   *field;
 
2943
  drizzle_field_seek(result, 0);
 
2944
  for ( ; (field= drizzle_fetch_field(result)) ; row++)
 
2945
  {
 
2946
    if (!strcmp(field->name,name))
 
2947
    {
 
2948
      if (row[0] && row[0][0] && strcmp(row[0],"0")) /* Skip default */
 
2949
      {
 
2950
        drizzle_field_seek(result, 0);
 
2951
        return row[0];
 
2952
      }
 
2953
    }
 
2954
  }
 
2955
  drizzle_field_seek(result, 0);
 
2956
  return NULL;
 
2957
}
 
2958
 
2926
2959
 
2927
2960
/*
2928
2961
  SYNOPSIS
2952
2985
{
2953
2986
  char result= IGNORE_NONE;
2954
2987
  char buff[FN_REFLEN+80], show_name_buff[FN_REFLEN];
 
2988
  const char *number_of_rows= NULL;
2955
2989
  DRIZZLE_RES *res= NULL;
2956
2990
  DRIZZLE_ROW row;
2957
2991
 
2958
 
 
2959
2992
  /* Check memory for quote_for_like() */
2960
2993
  assert(2*sizeof(table_name) < sizeof(show_name_buff));
2961
2994
  snprintf(buff, sizeof(buff), "show table status like %s",
2977
3010
    drizzle_free_result(res);
2978
3011
    return(result);                         /* assume table is ok */
2979
3012
  }
2980
 
 
 
3013
  else
 
3014
  {
 
3015
    if ((number_of_rows= fetch_named_row(res, row, "Rows")) != NULL)
 
3016
    {
 
3017
      total_rows= strtoul(number_of_rows, NULL, 10);
 
3018
    }
 
3019
  }
2981
3020
  /*
2982
3021
    If the table type matches any of these, we do support delayed inserts.
2983
3022
    Note: we do not want to skip dumping this table if if is not one of