96
96
static bool debug_info_flag= false, debug_check_flag= false;
97
97
static uint32_t opt_max_allowed_packet, opt_net_buffer_length, show_progress_size= 0;
98
98
static uint64_t total_rows= 0;
99
static DRIZZLE drizzle_connection, *drizzle= 0;
99
static DRIZZLE drizzleclient_connection, *drizzle= 0;
100
100
static string insert_pat;
101
101
static char *opt_password= NULL, *current_user= NULL,
102
102
*current_host= NULL, *path= NULL, *fields_terminated= NULL,
472
472
static void print_version(void)
474
474
printf(_("%s Ver %s Distrib %s, for %s (%s)\n"),my_progname,DUMP_VERSION,
475
drizzle_get_client_info(),SYSTEM_TYPE,MACHINE_TYPE);
475
drizzleclient_get_client_info(),SYSTEM_TYPE,MACHINE_TYPE);
476
476
} /* print_version */
526
526
fprintf(sql_file,
527
527
"-- DRIZZLE dump %s Distrib %s, for %s (%s)\n--\n",
528
DUMP_VERSION, drizzle_get_client_info(),
528
DUMP_VERSION, drizzleclient_get_client_info(),
529
529
SYSTEM_TYPE, MACHINE_TYPE);
530
530
fprintf(sql_file, "-- Host: %s Database: %s\n",
531
531
current_host ? current_host : "localhost", db_name ? db_name :
533
533
fputs("-- ------------------------------------------------------\n",
535
535
fprintf(sql_file, "-- Server version\t%s\n",
536
drizzle_get_server_info(&drizzle_connection));
536
drizzleclient_get_server_info(&drizzleclient_connection));
538
538
if (opt_set_charset)
539
539
fprintf(sql_file,
774
774
static int get_options(int *argc, char ***argv)
777
const DRIZZLE_PARAMETERS *drizzle_params= drizzle_get_parameters();
777
const DRIZZLE_PARAMETERS *drizzle_params= drizzleclient_get_parameters();
779
779
opt_max_allowed_packet= *drizzle_params->p_max_allowed_packet;
780
780
opt_net_buffer_length= *drizzle_params->p_net_buffer_length;
868
868
maybe_die(EX_DRIZZLEERR, _("Got error: %d: %s %s"),
869
drizzle_errno(drizzle_arg), drizzle_error(drizzle_arg), when);
869
drizzleclient_errno(drizzle_arg), drizzleclient_error(drizzle_arg), when);
943
drizzle_query_with_error_report()
943
drizzleclient_query_with_error_report()
944
944
drizzle_con connection to use
945
945
res if non zero, result will be put there with
946
drizzle_store_result()
946
drizzleclient_store_result()
947
947
query query to send to server
954
static int drizzle_query_with_error_report(DRIZZLE *drizzle_con, DRIZZLE_RES **res,
954
static int drizzleclient_query_with_error_report(DRIZZLE *drizzle_con, DRIZZLE_RES **res,
955
955
const char *query)
957
if (drizzle_query(drizzle_con, query) ||
958
(res && !((*res)= drizzle_store_result(drizzle_con))))
957
if (drizzleclient_query(drizzle_con, query) ||
958
(res && !((*res)= drizzleclient_store_result(drizzle_con))))
960
960
maybe_die(EX_DRIZZLEERR, _("Couldn't execute '%s': %s (%d)"),
961
query, drizzle_error(drizzle_con), drizzle_errno(drizzle_con));
961
query, drizzleclient_error(drizzle_con), drizzleclient_errno(drizzle_con));
1019
1019
static int connect_to_db(char *host, char *user,char *passwd)
1021
1021
verbose_msg(_("-- Connecting to %s...\n"), host ? host : "localhost");
1022
drizzle_create(&drizzle_connection);
1022
drizzleclient_create(&drizzleclient_connection);
1023
1023
if (opt_compress)
1024
drizzle_options(&drizzle_connection,DRIZZLE_OPT_COMPRESS,NULL);
1025
if (!(drizzle= drizzle_connect(&drizzle_connection,host,user,passwd,
1024
drizzleclient_options(&drizzleclient_connection,DRIZZLE_OPT_COMPRESS,NULL);
1025
if (!(drizzle= drizzleclient_connect(&drizzleclient_connection,host,user,passwd,
1026
1026
NULL,opt_drizzle_port, NULL,
1029
DB_error(&drizzle_connection, "when trying to connect");
1029
DB_error(&drizzleclient_connection, "when trying to connect");
1051
1051
if (!(tmp=(char*) malloc(length*2+1)))
1052
1052
die(EX_DRIZZLEERR, _("Couldn't allocate memory"));
1054
drizzle_escape_string(tmp, pos, length);
1054
drizzleclient_escape_string(tmp, pos, length);
1055
1055
fputc('\'', file);
1056
1056
fputs(tmp, file);
1057
1057
fputc('\'', file);
1314
1314
DRIZZLE_FIELD *field;
1315
uint32_t *lengths= drizzle_fetch_lengths(tableRes);
1315
uint32_t *lengths= drizzleclient_fetch_lengths(tableRes);
1317
1317
fprintf(xml_file, "\t\t<%s", row_name);
1318
1318
check_io(xml_file);
1319
drizzle_field_seek(tableRes, 0);
1320
for (i= 0; (field= drizzle_fetch_field(tableRes)); i++)
1319
drizzleclient_field_seek(tableRes, 0);
1320
for (i= 0; (field= drizzleclient_fetch_field(tableRes)); i++)
1427
1427
snprintf(buff, sizeof(buff), "show create table %s", result_table);
1429
if (drizzle_query_with_error_report(drizzle, &result, buff))
1429
if (drizzleclient_query_with_error_report(drizzle, &result, buff))
1451
1451
check_io(sql_file);
1454
field= drizzle_fetch_field_direct(result, 0);
1454
field= drizzleclient_fetch_field_direct(result, 0);
1456
row= drizzle_fetch_row(result);
1456
row= drizzleclient_fetch_row(result);
1458
1458
fprintf(sql_file, "%s;\n", row[1]);
1460
1460
check_io(sql_file);
1461
drizzle_free_result(result);
1461
drizzleclient_free_result(result);
1463
1463
snprintf(query_buff, sizeof(query_buff), "show fields from %s",
1465
if (drizzle_query_with_error_report(drizzle, &result, query_buff))
1465
if (drizzleclient_query_with_error_report(drizzle, &result, query_buff))
1468
1468
my_fclose(sql_file, MYF(MY_WME));
1508
1508
insert_pat.append(quote_name(row[SHOW_FIELDNAME], name_buff, 0));
1511
*num_fields= drizzle_num_rows(result);
1512
drizzle_free_result(result);
1511
*num_fields= drizzleclient_num_rows(result);
1512
drizzleclient_free_result(result);
1516
1516
verbose_msg(_("%s: Warning: Can't set SQL_QUOTE_SHOW_CREATE option (%s)\n"),
1517
my_progname, drizzle_error(drizzle));
1517
my_progname, drizzleclient_error(drizzle));
1519
1519
snprintf(query_buff, sizeof(query_buff), "show fields from %s",
1521
if (drizzle_query_with_error_report(drizzle, &result, query_buff))
1521
if (drizzleclient_query_with_error_report(drizzle, &result, query_buff))
1524
1524
/* Make an sql-file, if path was given iow. option -T was given */
1565
while ((row= drizzle_fetch_row(result)))
1565
while ((row= drizzleclient_fetch_row(result)))
1567
uint32_t *lengths= drizzle_fetch_lengths(result);
1567
uint32_t *lengths= drizzleclient_fetch_lengths(result);
1570
1570
if (!opt_xml && !opt_no_create_info)
1606
1606
check_io(sql_file);
1609
*num_fields= drizzle_num_rows(result);
1610
drizzle_free_result(result);
1609
*num_fields= drizzleclient_num_rows(result);
1610
drizzleclient_free_result(result);
1611
1611
if (!opt_no_create_info)
1613
1613
/* Make an sql-file, if path was given iow. option -T was given */
1614
1614
char buff[20+FN_REFLEN];
1615
1615
uint keynr,primary_key;
1616
1616
snprintf(buff, sizeof(buff), "show keys from %s", result_table);
1617
if (drizzle_query_with_error_report(drizzle, &result, buff))
1617
if (drizzleclient_query_with_error_report(drizzle, &result, buff))
1619
if (drizzle_errno(drizzle) == ER_WRONG_OBJECT)
1619
if (drizzleclient_errno(drizzle) == ER_WRONG_OBJECT)
1621
1621
/* it is VIEW */
1622
1622
fputs("\t\t<options Comment=\"view\" />\n", sql_file);
1623
1623
goto continue_xml;
1625
1625
fprintf(stderr, _("%s: Can't get keys for table %s (%s)\n"),
1626
my_progname, result_table, drizzle_error(drizzle));
1626
my_progname, result_table, drizzleclient_error(drizzle));
1628
1628
my_fclose(sql_file, MYF(MY_WME));
1651
drizzle_data_seek(result,0);
1651
drizzleclient_data_seek(result,0);
1653
while ((row= drizzle_fetch_row(result)))
1653
while ((row= drizzleclient_fetch_row(result)))
1695
1695
snprintf(buff, sizeof(buff), "show table status like %s",
1696
1696
quote_for_like(table, show_name_buff));
1698
if (drizzle_query_with_error_report(drizzle, &result, buff))
1698
if (drizzleclient_query_with_error_report(drizzle, &result, buff))
1700
if (drizzle_errno(drizzle) != ER_PARSE_ERROR)
1700
if (drizzleclient_errno(drizzle) != ER_PARSE_ERROR)
1701
1701
{ /* If old DRIZZLE version */
1702
1702
verbose_msg(_("-- Warning: Couldn't get status information for " \
1703
"table %s (%s)\n"), result_table,drizzle_error(drizzle));
1703
"table %s (%s)\n"), result_table,drizzleclient_error(drizzle));
1706
else if (!(row= drizzle_fetch_row(result)))
1706
else if (!(row= drizzleclient_fetch_row(result)))
1708
1708
fprintf(stderr,
1709
1709
_("Error: Couldn't read status information for table %s (%s)\n"),
1710
result_table,drizzle_error(drizzle));
1710
result_table,drizzleclient_error(drizzle));
1931
1931
query_string.append( order_by);
1934
if (drizzle_real_query(drizzle, query_string.c_str(), query_string.length()))
1934
if (drizzleclient_real_query(drizzle, query_string.c_str(), query_string.length()))
1936
1936
DB_error(drizzle, _("when executing 'SELECT INTO OUTFILE'"));
1976
1976
fputs("\n", md_result_file);
1977
1977
check_io(md_result_file);
1979
if (drizzle_query_with_error_report(drizzle, 0, query_string.c_str()))
1979
if (drizzleclient_query_with_error_report(drizzle, 0, query_string.c_str()))
1981
1981
DB_error(drizzle, _("when retrieving data from server"));
1985
res=drizzle_use_result(drizzle);
1985
res=drizzleclient_use_result(drizzle);
1987
res=drizzle_store_result(drizzle);
1987
res=drizzleclient_store_result(drizzle);
1990
1990
DB_error(drizzle, _("when retrieving data from server"));
1994
1994
verbose_msg(_("-- Retrieving rows...\n"));
1995
if (drizzle_num_fields(res) != num_fields)
1995
if (drizzleclient_num_fields(res) != num_fields)
1997
1997
fprintf(stderr,_("%s: Error in field count for table: %s ! Aborting.\n"),
1998
1998
my_progname, result_table);
2026
2026
check_io(md_result_file);
2029
while ((row= drizzle_fetch_row(res)))
2029
while ((row= drizzleclient_fetch_row(res)))
2032
uint32_t *lengths= drizzle_fetch_lengths(res);
2032
uint32_t *lengths= drizzleclient_fetch_lengths(res);
2034
2034
if ((rownr % show_progress_size) == 0)
2040
2040
fputs(insert_pat.c_str(),md_result_file);
2041
2041
check_io(md_result_file);
2043
drizzle_field_seek(res,0);
2043
drizzleclient_field_seek(res,0);
2048
2048
check_io(md_result_file);
2051
for (i= 0; i < drizzle_num_fields(res); i++)
2051
for (i= 0; i < drizzleclient_num_fields(res); i++)
2054
2054
uint32_t length= lengths[i];
2056
if (!(field= drizzle_fetch_field(res)))
2056
if (!(field= drizzleclient_fetch_field(res)))
2057
2057
die(EX_CONSCHECK,
2058
2058
_("Not enough fields from table %s! Aborting.\n"),
2095
2095
if (opt_hex_blob && is_blob)
2097
2097
extended_row.append("0x");
2098
octet2hex(tmp_str, row[i], length);
2098
drizzleclient_drizzleclient_octet2hex(tmp_str, row[i], length);
2099
2099
extended_row.append(tmp_str);
2103
2103
extended_row.append("'");
2104
drizzle_escape_string(tmp_str,
2104
drizzleclient_escape_string(tmp_str,
2105
2105
row[i],length);
2106
2106
extended_row.append(tmp_str);
2107
2107
extended_row.append("'");
2238
2238
fputs(";\n", md_result_file); /* If not empty table */
2239
2239
fflush(md_result_file);
2240
2240
check_io(md_result_file);
2241
if (drizzle_errno(drizzle))
2241
if (drizzleclient_errno(drizzle))
2243
2243
snprintf(buf, sizeof(buf),
2244
2244
_("%s: Error %d: %s when dumping table %s at row: %d\n"),
2246
drizzle_errno(drizzle),
2247
drizzle_error(drizzle),
2246
drizzleclient_errno(drizzle),
2247
drizzleclient_error(drizzle),
2250
2250
fputs(buf,stderr);
2269
2269
fprintf(md_result_file, "commit;\n");
2270
2270
check_io(md_result_file);
2272
drizzle_free_result(res);
2272
drizzleclient_free_result(res);
2289
if (!(res= drizzle_list_tables(drizzle,NULL)))
2289
if (!(res= drizzleclient_list_tables(drizzle,NULL)))
2292
if ((row= drizzle_fetch_row(res)))
2292
if ((row= drizzleclient_fetch_row(res)))
2293
2293
return((char*) row[0]);
2296
drizzle_data_seek(res,0); /* We want to read again */
2296
drizzleclient_data_seek(res,0); /* We want to read again */
2299
drizzle_free_result(res);
2299
drizzleclient_free_result(res);
2309
2309
DRIZZLE_RES *tableres;
2312
if (drizzle_query_with_error_report(drizzle, &tableres, "SHOW DATABASES"))
2312
if (drizzleclient_query_with_error_report(drizzle, &tableres, "SHOW DATABASES"))
2314
while ((row= drizzle_fetch_row(tableres)))
2314
while ((row= drizzleclient_fetch_row(tableres)))
2316
2316
if (dump_all_tables_in_db(row[0]))
2362
2362
"SHOW CREATE DATABASE IF NOT EXISTS %s",
2365
if (drizzle_query(drizzle, qbuf) || !(dbinfo = drizzle_store_result(drizzle)))
2365
if (drizzleclient_query(drizzle, qbuf) || !(dbinfo = drizzleclient_store_result(drizzle)))
2367
2367
/* Old server version, dump generic CREATE DATABASE */
2368
2368
if (opt_drop_database)
2379
2379
fprintf(md_result_file,
2380
2380
"\nDROP DATABASE IF EXISTS %s;\n",
2382
row = drizzle_fetch_row(dbinfo);
2382
row = drizzleclient_fetch_row(dbinfo);
2385
2385
fprintf(md_result_file,"\n%s;\n",row[1]);
2387
drizzle_free_result(dbinfo);
2387
drizzleclient_free_result(dbinfo);
2394
2394
static int init_dumping(char *database, int init_func(char*))
2396
if (drizzle_get_server_version(drizzle) >= 50003 &&
2396
if (drizzleclient_get_server_version(drizzle) >= 50003 &&
2397
2397
!my_strcasecmp(&my_charset_utf8_general_ci, database, "information_schema"))
2400
if (drizzle_select_db(drizzle, database))
2400
if (drizzleclient_select_db(drizzle, database))
2402
2402
DB_error(drizzle, _("when selecting the database"));
2403
2403
return 1; /* If --force */
2466
2466
query.append( " READ LOCAL,");
2469
if (numrows && drizzle_real_query(drizzle, query.c_str(), query.length()-1))
2469
if (numrows && drizzleclient_real_query(drizzle, query.c_str(), query.length()-1))
2470
2470
DB_error(drizzle, _("when using LOCK TABLES"));
2471
2471
/* We shall continue here, if --force was given */
2474
2474
if (flush_logs)
2476
if (drizzle_refresh(drizzle, REFRESH_LOG))
2476
if (drizzleclient_refresh(drizzle, REFRESH_LOG))
2477
2477
DB_error(drizzle, _("when doing refresh"));
2478
2478
/* We shall continue here, if --force was given */
2493
2493
check_io(md_result_file);
2495
2495
if (lock_tables)
2496
drizzle_query_with_error_report(drizzle, 0, "UNLOCK TABLES");
2496
drizzleclient_query_with_error_report(drizzle, 0, "UNLOCK TABLES");
2499
2499
} /* dump_all_tables_in_db */
2524
2524
snprintf(query, sizeof(query), "SHOW TABLES LIKE %s",
2525
2525
quote_for_like(old_table_name, show_name_buff));
2527
if (drizzle_query_with_error_report(drizzle, 0, query))
2527
if (drizzleclient_query_with_error_report(drizzle, 0, query))
2530
if ((table_res= drizzle_store_result(drizzle)))
2530
if ((table_res= drizzleclient_store_result(drizzle)))
2532
uint64_t num_rows= drizzle_num_rows(table_res);
2532
uint64_t num_rows= drizzleclient_num_rows(table_res);
2533
2533
if (num_rows > 0)
2535
2535
uint32_t *lengths;
2537
2537
Return first row
2538
2538
TODO: Return all matching rows
2540
row= drizzle_fetch_row(table_res);
2541
lengths= drizzle_fetch_lengths(table_res);
2540
row= drizzleclient_fetch_row(table_res);
2541
lengths= drizzleclient_fetch_lengths(table_res);
2542
2542
name= strmake_root(root, row[0], lengths[0]);
2544
drizzle_free_result(table_res);
2544
drizzleclient_free_result(table_res);
2590
2590
if (lock_tables)
2592
if (drizzle_real_query(drizzle, lock_tables_query.c_str(),
2592
if (drizzleclient_real_query(drizzle, lock_tables_query.c_str(),
2593
2593
lock_tables_query.length()-1))
2595
2595
if (!ignore_errors)
2603
2603
if (flush_logs)
2605
if (drizzle_refresh(drizzle, REFRESH_LOG))
2605
if (drizzleclient_refresh(drizzle, REFRESH_LOG))
2607
2607
if (!ignore_errors)
2608
2608
free_root(&root, MYF(0));
2626
2626
check_io(md_result_file);
2628
2628
if (lock_tables)
2629
drizzle_query_with_error_report(drizzle, 0, "UNLOCK TABLES");
2629
drizzleclient_query_with_error_report(drizzle, 0, "UNLOCK TABLES");
2631
2631
} /* dump_selected_tables */
2637
2637
DRIZZLE_RES *master;
2638
2638
const char *comment_prefix=
2639
2639
(opt_master_data == DRIZZLE_OPT_MASTER_DATA_COMMENTED_SQL) ? "-- " : "";
2640
if (drizzle_query_with_error_report(drizzle_con, &master, "SHOW MASTER STATUS"))
2640
if (drizzleclient_query_with_error_report(drizzle_con, &master, "SHOW MASTER STATUS"))
2646
row= drizzle_fetch_row(master);
2646
row= drizzleclient_fetch_row(master);
2647
2647
if (row && row[0] && row[1])
2649
2649
/* SHOW MASTER STATUS reports file and position */
2661
2661
/* SHOW MASTER STATUS reports nothing and --force is not enabled */
2662
2662
my_printf_error(0, _("Error: Binlogging on server not active"),
2664
drizzle_free_result(master);
2664
drizzleclient_free_result(master);
2665
2665
maybe_exit(EX_DRIZZLEERR);
2668
drizzle_free_result(master);
2668
drizzleclient_free_result(master);
2675
2675
DRIZZLE_RES *slave;
2676
2676
/* We need to check if the slave sql is running in the first place */
2677
if (drizzle_query_with_error_report(drizzle_con, &slave, "SHOW SLAVE STATUS"))
2677
if (drizzleclient_query_with_error_report(drizzle_con, &slave, "SHOW SLAVE STATUS"))
2681
DRIZZLE_ROW row= drizzle_fetch_row(slave);
2681
DRIZZLE_ROW row= drizzleclient_fetch_row(slave);
2682
2682
if (row && row[11])
2684
2684
/* if SLAVE SQL is not running, we don't stop it */
2685
2685
if (!strcmp(row[11],"No"))
2687
drizzle_free_result(slave);
2687
drizzleclient_free_result(slave);
2688
2688
/* Silently assume that they don't have the slave running */
2693
drizzle_free_result(slave);
2693
drizzleclient_free_result(slave);
2695
2695
/* now, stop slave if running */
2696
if (drizzle_query_with_error_report(drizzle_con, 0, "STOP SLAVE SQL_THREAD"))
2696
if (drizzleclient_query_with_error_report(drizzle_con, 0, "STOP SLAVE SQL_THREAD"))
2722
2722
DRIZZLE_RES *slave;
2723
2723
const char *comment_prefix=
2724
2724
(opt_slave_data == DRIZZLE_OPT_SLAVE_DATA_COMMENTED_SQL) ? "-- " : "";
2725
if (drizzle_query_with_error_report(drizzle_con, &slave, "SHOW SLAVE STATUS"))
2725
if (drizzleclient_query_with_error_report(drizzle_con, &slave, "SHOW SLAVE STATUS"))
2727
2727
if (!ignore_errors)
2766
2766
DRIZZLE_RES *slave;
2767
2767
/* We need to check if the slave sql is stopped in the first place */
2768
if (drizzle_query_with_error_report(drizzle_con, &slave, "SHOW SLAVE STATUS"))
2768
if (drizzleclient_query_with_error_report(drizzle_con, &slave, "SHOW SLAVE STATUS"))
2772
DRIZZLE_ROW row= drizzle_fetch_row(slave);
2772
DRIZZLE_ROW row= drizzleclient_fetch_row(slave);
2773
2773
if (row && row[11])
2775
2775
/* if SLAVE SQL is not running, we don't start it */
2776
2776
if (!strcmp(row[11],"Yes"))
2778
drizzle_free_result(slave);
2778
drizzleclient_free_result(slave);
2779
2779
/* Silently assume that they don't have the slave running */
2784
drizzle_free_result(slave);
2784
drizzleclient_free_result(slave);
2786
2786
/* now, start slave if stopped */
2787
if (drizzle_query_with_error_report(drizzle_con, 0, "START SLAVE"))
2787
if (drizzleclient_query_with_error_report(drizzle_con, 0, "START SLAVE"))
2789
2789
my_printf_error(0, _("Error: Unable to start slave"), MYF(0));
2805
2805
update starts between the two FLUSHes, we have that bad stall.
2808
( drizzle_query_with_error_report(drizzle_con, 0, "FLUSH TABLES") ||
2809
drizzle_query_with_error_report(drizzle_con, 0,
2808
( drizzleclient_query_with_error_report(drizzle_con, 0, "FLUSH TABLES") ||
2809
drizzleclient_query_with_error_report(drizzle_con, 0,
2810
2810
"FLUSH TABLES WITH READ LOCK") );
2814
2814
static int do_unlock_tables(DRIZZLE *drizzle_con)
2816
return drizzle_query_with_error_report(drizzle_con, 0, "UNLOCK TABLES");
2816
return drizzleclient_query_with_error_report(drizzle_con, 0, "UNLOCK TABLES");
2819
2819
static int get_bin_log_name(DRIZZLE *drizzle_con,
2822
2822
DRIZZLE_RES *res;
2823
2823
DRIZZLE_ROW row;
2825
if (drizzle_query(drizzle_con, "SHOW MASTER STATUS") ||
2826
!(res= drizzle_store_result(drizzle)))
2825
if (drizzleclient_query(drizzle_con, "SHOW MASTER STATUS") ||
2826
!(res= drizzleclient_store_result(drizzle)))
2829
if (!(row= drizzle_fetch_row(res)))
2829
if (!(row= drizzleclient_fetch_row(res)))
2831
drizzle_free_result(res);
2831
drizzleclient_free_result(res);
2847
2847
string str= "PURGE BINARY LOGS TO '";
2848
2848
str.append(log_name);
2849
2849
str.append("'");
2850
err = drizzle_query_with_error_report(drizzle_con, 0, str.c_str());
2850
err = drizzleclient_query_with_error_report(drizzle_con, 0, str.c_str());
2855
2855
static int start_transaction(DRIZZLE *drizzle_con)
2857
return (drizzle_query_with_error_report(drizzle_con, 0,
2857
return (drizzleclient_query_with_error_report(drizzle_con, 0,
2858
2858
"SET SESSION TRANSACTION ISOLATION "
2859
2859
"LEVEL REPEATABLE READ") ||
2860
drizzle_query_with_error_report(drizzle_con, 0,
2860
drizzleclient_query_with_error_report(drizzle_con, 0,
2861
2861
"START TRANSACTION "
2862
2862
"WITH CONSISTENT SNAPSHOT"));
2910
2910
int string_value)
2912
2912
DRIZZLE_FIELD *field;
2913
drizzle_field_seek(result, 0);
2913
drizzleclient_field_seek(result, 0);
2915
for ( ; (field= drizzle_fetch_field(result)) ; row++)
2915
for ( ; (field= drizzleclient_fetch_field(result)) ; row++)
2917
2917
if (!strcmp(field->name,name))
2940
2940
static const char* fetch_named_row(DRIZZLE_RES *result, DRIZZLE_ROW row, const char *name)
2942
2942
DRIZZLE_FIELD *field;
2943
drizzle_field_seek(result, 0);
2944
for ( ; (field= drizzle_fetch_field(result)) ; row++)
2943
drizzleclient_field_seek(result, 0);
2944
for ( ; (field= drizzleclient_fetch_field(result)) ; row++)
2946
2946
if (!strcmp(field->name,name))
2948
2948
if (row[0] && row[0][0] && strcmp(row[0],"0")) /* Skip default */
2950
drizzle_field_seek(result, 0);
2950
drizzleclient_field_seek(result, 0);
2955
drizzle_field_seek(result, 0);
2955
drizzleclient_field_seek(result, 0);
2993
2993
assert(2*sizeof(table_name) < sizeof(show_name_buff));
2994
2994
snprintf(buff, sizeof(buff), "show table status like %s",
2995
2995
quote_for_like(table_name, show_name_buff));
2996
if (drizzle_query_with_error_report(drizzle, &res, buff))
2996
if (drizzleclient_query_with_error_report(drizzle, &res, buff))
2998
if (drizzle_errno(drizzle) != ER_PARSE_ERROR)
2998
if (drizzleclient_errno(drizzle) != ER_PARSE_ERROR)
2999
2999
{ /* If old DRIZZLE version */
3000
3000
verbose_msg(_("-- Warning: Couldn't get status information for "
3001
"table %s (%s)\n"), table_name, drizzle_error(drizzle));
3001
"table %s (%s)\n"), table_name, drizzleclient_error(drizzle));
3002
3002
return(result); /* assume table is ok */
3005
if (!(row= drizzle_fetch_row(res)))
3005
if (!(row= drizzleclient_fetch_row(res)))
3007
3007
fprintf(stderr,
3008
3008
_("Error: Couldn't read status information for table %s (%s)\n"),
3009
table_name, drizzle_error(drizzle));
3010
drizzle_free_result(res);
3009
table_name, drizzleclient_error(drizzle));
3010
drizzleclient_free_result(res);
3011
3011
return(result); /* assume table is ok */
3071
3071
snprintf(show_keys_buff, sizeof(show_keys_buff),
3072
3072
"SHOW KEYS FROM %s", table_name);
3073
if (drizzle_query(drizzle, show_keys_buff) ||
3074
!(res= drizzle_store_result(drizzle)))
3073
if (drizzleclient_query(drizzle, show_keys_buff) ||
3074
!(res= drizzleclient_store_result(drizzle)))
3076
3076
fprintf(stderr, _("Warning: Couldn't read keys from table %s;"
3077
3077
" records are NOT sorted (%s)\n"),
3078
table_name, drizzle_error(drizzle));
3078
table_name, drizzleclient_error(drizzle));
3079
3079
/* Don't exit, because it's better to print out unsorted records */
3086
3086
* row, and UNIQUE keys come before others. So we only need to check
3087
3087
* the first key, not all keys.
3089
if ((row= drizzle_fetch_row(res)) && atoi(row[1]) == 0)
3089
if ((row= drizzleclient_fetch_row(res)) && atoi(row[1]) == 0)
3091
3091
/* Key is unique */
3094
3094
quoted_field= quote_name(row[4], buff, 0);
3095
3095
result_length+= strlen(quoted_field) + 1; /* + 1 for ',' or \0 */
3096
} while ((row= drizzle_fetch_row(res)) && atoi(row[3]) > 1);
3096
} while ((row= drizzleclient_fetch_row(res)) && atoi(row[3]) > 1);
3099
3099
/* Build the ORDER BY clause result */
3107
3107
fprintf(stderr, _("Error: Not enough memory to store ORDER BY clause\n"));
3110
drizzle_data_seek(res, 0);
3111
row= drizzle_fetch_row(res);
3110
drizzleclient_data_seek(res, 0);
3111
row= drizzleclient_fetch_row(res);
3112
3112
quoted_field= quote_name(row[4], buff, 0);
3113
3113
end= strcpy(result, quoted_field) + strlen(quoted_field);
3114
while ((row= drizzle_fetch_row(res)) && atoi(row[3]) > 1)
3114
while ((row= drizzleclient_fetch_row(res)) && atoi(row[3]) > 1)
3116
3116
quoted_field= quote_name(row[4], buff, 0);
3117
3117
end+= sprintf(end,",%s",quoted_field);
3162
3162
if (opt_delete_master_logs)
3164
if (drizzle_refresh(drizzle, REFRESH_LOG) ||
3164
if (drizzleclient_refresh(drizzle, REFRESH_LOG) ||
3165
3165
get_bin_log_name(drizzle, bin_log_name, sizeof(bin_log_name)))
3169
3169
if (opt_lock_all_tables || opt_master_data)
3171
if (flush_logs && drizzle_refresh(drizzle, REFRESH_LOG))
3171
if (flush_logs && drizzleclient_refresh(drizzle, REFRESH_LOG))
3173
3173
flush_logs= 0; /* not anymore; that would not be sensible */