17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
#include "client/drizzledump_data.h"
23
#include "client/client_priv.h"
20
#include "drizzledump_data.h"
21
#include "client_priv.h"
24
22
#include <drizzled/definitions.h>
25
23
#include <drizzled/gettext.h>
554
552
std::cerr << _("-- Connecting to ") << host << _(" using protocol ")
555
553
<< protocol << "..." << std::endl;
558
drizzle= drizzle_create();
562
std::cerr << "drizzle_create() failed" << std::endl;
565
connection= drizzle_con_create(drizzle);
566
drizzle_con_set_tcp(connection, (char *)host.c_str(), port);
567
drizzle_con_set_auth(connection, (char *)username.c_str(), (char *)password.c_str());
568
drizzle_con_add_options(connection, drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL);
570
drizzle_return_t ret= drizzle_con_connect(connection);
555
drizzle_create(&drizzle);
556
drizzle_con_create(&drizzle, &connection);
557
drizzle_con_set_tcp(&connection, (char *)host.c_str(), port);
558
drizzle_con_set_auth(&connection, (char *)username.c_str(),
559
(char *)password.c_str());
560
drizzle_con_add_options(&connection,
561
drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL);
562
ret= drizzle_con_connect(&connection);
571
563
if (ret != DRIZZLE_RETURN_OK)
573
565
errorHandler(NULL, ret, "when trying to connect");
574
566
throw std::exception();
577
ServerDetect server_detect= ServerDetect(connection);
569
ServerDetect server_detect= ServerDetect(&connection);
579
571
serverType= server_detect.getServerType();
580
572
serverVersion= server_detect.getServerVersion();
585
577
drizzle_return_t ret;
586
578
drizzle_result_st* result= new drizzle_result_st;
587
if (drizzle_query_str(connection, result, str_query.c_str(), &ret) == NULL or
579
if (drizzle_query_str(&connection, result, str_query.c_str(), &ret) == NULL ||
588
580
ret != DRIZZLE_RETURN_OK)
590
582
if (ret == DRIZZLE_RETURN_ERROR_CODE)
598
std::cerr << _("Error executing query: ") << drizzle_con_error(connection) << std::endl;
590
std::cerr << _("Error executing query: ") <<
591
drizzle_con_error(&connection) << std::endl;
603
596
if (drizzle_result_buffer(result) != DRIZZLE_RETURN_OK)
605
std::cerr << _("Could not buffer result: ") << drizzle_con_error(connection) << std::endl;
598
std::cerr << _("Could not buffer result: ") <<
599
drizzle_con_error(&connection) << std::endl;
619
613
drizzle_return_t ret;
620
614
drizzle_result_st result;
622
if (drizzle_query_str(connection, &result, str_query.c_str(), &ret) == NULL or
616
if (drizzle_query_str(&connection, &result, str_query.c_str(), &ret) == NULL ||
623
617
ret != DRIZZLE_RETURN_OK)
625
619
if (ret == DRIZZLE_RETURN_ERROR_CODE)
644
639
drizzle_return_t ret;
645
640
drizzle_result_st result;
647
if (drizzle_select_db(connection, &result, databaseName.c_str(), &ret) == NULL or
648
ret != DRIZZLE_RETURN_OK)
641
if (drizzle_select_db(&connection, &result, databaseName.c_str(), &ret) ==
642
NULL || ret != DRIZZLE_RETURN_OK)
650
644
std::cerr << _("Error: Could not set db '") << databaseName << "'" << std::endl;
651
645
if (ret == DRIZZLE_RETURN_ERROR_CODE)
653
646
drizzle_result_free(&result);
658
649
drizzle_result_free(&result);