~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzledump.cc

Merged in Eric's whitespace cleanup.

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
                opt_complete_insert= 0, opt_drop_database= 0,
84
84
                opt_replace_into= 0,
85
85
                opt_routines=0,
86
 
                opt_slave_apply= 0, 
 
86
                opt_slave_apply= 0,
87
87
                opt_include_master_host_port= 0,
88
88
                opt_events= 0,
89
89
                opt_alltspcs=0, opt_notspcs= 0;
296
296
   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
297
297
  {"include-master-host-port", OPT_DRIZZLEDUMP_INCLUDE_MASTER_HOST_PORT,
298
298
   "Adds 'MASTER_HOST=<host>, MASTER_PORT=<port>' to 'CHANGE MASTER TO..' in dump produced with --dump-slave.",
299
 
   (char**) &opt_include_master_host_port, 
300
 
   (char**) &opt_include_master_host_port, 
 
299
   (char**) &opt_include_master_host_port,
 
300
   (char**) &opt_include_master_host_port,
301
301
   0, GET_BOOL, NO_ARG,
302
302
   0, 0, 0, 0, 0, 0},
303
303
  {"insert-ignore", OPT_INSERT_IGNORE, "Insert rows with INSERT IGNORE.",
522
522
  {
523
523
    fputs("<?xml version=\"1.0\"?>\n", sql_file);
524
524
    /*
525
 
      Schema reference.  Allows use of xsi:nil for NULL values and 
 
525
      Schema reference.  Allows use of xsi:nil for NULL values and
526
526
      xsi:type to define an element's data type.
527
527
    */
528
528
    fputs("<drizzledump ", sql_file);
865
865
    error_num   - process return value
866
866
    fmt_reason  - a format string for use by vsnprintf.
867
867
    ...         - variable arguments for above fmt_reason string
868
 
  
 
868
 
869
869
  DESCRIPTION
870
870
    This call prints out the formatted error message to stderr and then
871
871
    terminates the process.
894
894
    error_num   - process return value
895
895
    fmt_reason  - a format string for use by vsnprintf.
896
896
    ...         - variable arguments for above fmt_reason string
897
 
  
 
897
 
898
898
  DESCRIPTION
899
899
    This call prints out the formatted error message to stderr and then
900
900
    terminates the process, unless the --force command line option is used.
901
 
    
 
901
 
902
902
    This call should be used for non-fatal errors (such as database
903
903
    errors) that the code may still be able to continue to the next unit
904
904
    of work.
905
 
    
 
905
 
906
906
*/
907
907
static void maybe_die(int error_num, const char* fmt_reason, ...)
908
908
{
1211
1211
  Print xml tag. Optionally add attribute(s).
1212
1212
 
1213
1213
  SYNOPSIS
1214
 
    print_xml_tag(xml_file, sbeg, send, tag_name, first_attribute_name, 
 
1214
    print_xml_tag(xml_file, sbeg, send, tag_name, first_attribute_name,
1215
1215
                    ..., attribute_name_n, attribute_value_n, NULL)
1216
1216
    xml_file              - output file
1217
1217
    sbeg                  - line beginning
1226
1226
    Print XML tag with any number of attribute="value" pairs to the xml_file.
1227
1227
 
1228
1228
    Format is:
1229
 
      sbeg<tag_name first_attribute_name="first_attribute_value" ... 
 
1229
      sbeg<tag_name first_attribute_name="first_attribute_value" ...
1230
1230
      attribute_name_n="attribute_value_n">send
1231
1231
  NOTE
1232
1232
    Additional arguments must be present in attribute/value pairs.
1236
1236
*/
1237
1237
 
1238
1238
static void print_xml_tag(FILE * xml_file, const char* sbeg,
1239
 
                          const char* line_end, 
1240
 
                          const char* tag_name, 
 
1239
                          const char* line_end,
 
1240
                          const char* tag_name,
1241
1241
                          const char* first_attribute_name, ...)
1242
1242
{
1243
1243
  va_list arg_list;
1245
1245
 
1246
1246
  fputs(sbeg, xml_file);
1247
1247
  fputc('<', xml_file);
1248
 
  fputs(tag_name, xml_file);  
 
1248
  fputs(tag_name, xml_file);
1249
1249
 
1250
1250
  va_start(arg_list, first_attribute_name);
1251
1251
  attribute_name= first_attribute_name;
1255
1255
    assert(attribute_value != NULL);
1256
1256
 
1257
1257
    fputc(' ', xml_file);
1258
 
    fputs(attribute_name, xml_file);    
 
1258
    fputs(attribute_name, xml_file);
1259
1259
    fputc('\"', xml_file);
1260
 
    
 
1260
 
1261
1261
    print_quoted_xml(xml_file, attribute_value, strlen(attribute_value));
1262
1262
    fputc('\"', xml_file);
1263
1263
 
1560
1560
            fprintf(sql_file, ",\n  %s %s",
1561
1561
                    quote_name(row[0], name_buff, 0), row[1]);
1562
1562
          }
1563
 
          fprintf(sql_file, "\n) */;\n"); 
 
1563
          fprintf(sql_file, "\n) */;\n");
1564
1564
          check_io(sql_file);
1565
1565
        }
1566
1566
 
1658
1658
      if (!opt_xml)
1659
1659
        fprintf(sql_file, "CREATE TABLE %s (\n", result_table);
1660
1660
      else
1661
 
        print_xml_tag(sql_file, "\t", "\n", "table_structure", "name=", table, 
 
1661
        print_xml_tag(sql_file, "\t", "\n", "table_structure", "name=", table,
1662
1662
                NULL);
1663
1663
      check_io(sql_file);
1664
1664
    }
1879
1879
  }
1880
1880
 
1881
1881
  str.append(option);
1882
 
  
 
1882
 
1883
1883
  if (strncmp(option_value, "0x", sizeof("0x")-1) == 0)
1884
1884
  {
1885
1885
    /* It's a hex constant, don't escape */
1902
1902
 
1903
1903
static void field_escape(string &in, const char *from)
1904
1904
{
1905
 
  uint end_backslashes= 0; 
 
1905
  uint end_backslashes= 0;
1906
1906
 
1907
1907
  in.append("'");
1908
1908
 
2029
2029
      Convert the path to native os format
2030
2030
      and resolve to the full filepath.
2031
2031
    */
2032
 
    convert_dirname(tmp_path,path,NULL);    
 
2032
    convert_dirname(tmp_path,path,NULL);
2033
2033
    my_load_path(tmp_path, tmp_path, NULL);
2034
2034
    fn_format(filename, table, tmp_path, ".txt", MYF(MY_UNPACK_FILENAME));
2035
2035
 
2047
2047
 
2048
2048
    if (fields_terminated || enclosed || opt_enclosed || escaped)
2049
2049
      query_string.append( " FIELDS");
2050
 
    
 
2050
 
2051
2051
    add_load_option(query_string, " TERMINATED BY ", fields_terminated);
2052
2052
    add_load_option(query_string, " ENCLOSED BY ", enclosed);
2053
2053
    add_load_option(query_string, " OPTIONALLY ENCLOSED BY ", opt_enclosed);
2083
2083
              result_table);
2084
2084
      check_io(md_result_file);
2085
2085
    }
2086
 
    
 
2086
 
2087
2087
    query_string.append( "SELECT * FROM ");
2088
2088
    query_string.append( result_table);
2089
2089
 
2094
2094
        fprintf(md_result_file, "-- WHERE:  %s\n", where);
2095
2095
        check_io(md_result_file);
2096
2096
      }
2097
 
      
 
2097
 
2098
2098
      query_string.append( " WHERE ");
2099
2099
      query_string.append( where);
2100
2100
    }
2283
2283
                }
2284
2284
                else
2285
2285
                {
2286
 
                  print_xml_tag(md_result_file, "\t\t", "", "field", "name=", 
 
2286
                  print_xml_tag(md_result_file, "\t\t", "", "field", "name=",
2287
2287
                                field->name, NULL);
2288
2288
                  print_quoted_xml(md_result_file, row[i], length);
2289
2289
                }