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