~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzledump_data.cc

  • Committer: Brian Aker
  • Date: 2011-11-26 23:14:59 UTC
  • mto: This revision was merged to the branch mainline in revision 2465.
  • Revision ID: brian@tangent.org-20111126231459-pa9i3arizevf0vlr
Remove con from being passed object.

Show diffs side-by-side

added added

removed removed

Lines of Context:
543
543
  hostName(host),
544
544
  drizzleProtocol(drizzle_protocol)
545
545
{
546
 
  drizzle_return_t ret;
547
 
 
548
546
  if (host.empty())
549
547
  {
550
548
    host= "localhost";
564
562
    std::cerr << "drizzle_create() failed" << std::endl;
565
563
  }
566
564
 
567
 
  drizzle_con_create(drizzle, &connection);
568
 
  drizzle_con_set_tcp(&connection, (char *)host.c_str(), port);
569
 
  drizzle_con_set_auth(&connection, (char *)username.c_str(),
570
 
    (char *)password.c_str());
571
 
  drizzle_con_add_options(&connection, 
572
 
    drizzle_protocol ? DRIZZLE_CON_EXPERIMENTAL : DRIZZLE_CON_MYSQL);
573
 
  ret= drizzle_con_connect(&connection);
 
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);
 
569
 
 
570
  drizzle_return_t ret= drizzle_con_connect(connection);
574
571
  if (ret != DRIZZLE_RETURN_OK)
575
572
  {
576
573
    errorHandler(NULL, ret, "when trying to connect");
577
574
    throw std::exception();
578
575
  }
579
576
 
580
 
  ServerDetect server_detect= ServerDetect(&connection);
 
577
  ServerDetect server_detect= ServerDetect(connection);
581
578
 
582
579
  serverType= server_detect.getServerType();
583
580
  serverVersion= server_detect.getServerVersion();
587
584
{
588
585
  drizzle_return_t ret;
589
586
  drizzle_result_st* result= new drizzle_result_st;
590
 
  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
591
588
      ret != DRIZZLE_RETURN_OK)
592
589
  {
593
590
    if (ret == DRIZZLE_RETURN_ERROR_CODE)
598
595
    }
599
596
    else
600
597
    {
601
 
      std::cerr << _("Error executing query: ") <<
602
 
        drizzle_con_error(&connection) << std::endl;
 
598
      std::cerr << _("Error executing query: ") << drizzle_con_error(connection) << std::endl;
603
599
    }
604
600
    return NULL;
605
601
  }
606
602
 
607
603
  if (drizzle_result_buffer(result) != DRIZZLE_RETURN_OK)
608
604
  {
609
 
    std::cerr << _("Could not buffer result: ") <<
610
 
        drizzle_con_error(&connection) << std::endl;
 
605
    std::cerr << _("Could not buffer result: ") << drizzle_con_error(connection) << std::endl;
611
606
    return NULL;
612
607
  }
613
608
  return result;
624
619
  drizzle_return_t ret;
625
620
  drizzle_result_st result;
626
621
 
627
 
  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
628
623
      ret != DRIZZLE_RETURN_OK)
629
624
  {
630
625
    if (ret == DRIZZLE_RETURN_ERROR_CODE)
635
630
    }
636
631
    else
637
632
    {
638
 
      std::cerr << _("Error executing query: ") <<
639
 
        drizzle_con_error(&connection) << std::endl;
 
633
      std::cerr << _("Error executing query: ") << drizzle_con_error(connection) << std::endl;
640
634
    }
641
635
    return false;
642
636
  }
649
643
{
650
644
  drizzle_return_t ret;
651
645
  drizzle_result_st result;
652
 
  if (drizzle_select_db(&connection, &result, databaseName.c_str(), &ret) == 
653
 
    NULL || ret != DRIZZLE_RETURN_OK)
 
646
 
 
647
  if (drizzle_select_db(connection, &result, databaseName.c_str(), &ret) == NULL or 
 
648
      ret != DRIZZLE_RETURN_OK)
654
649
  {
655
650
    std::cerr << _("Error: Could not set db '") << databaseName << "'" << std::endl;
656
651
    if (ret == DRIZZLE_RETURN_ERROR_CODE)
 
652
    {
657
653
      drizzle_result_free(&result);
 
654
    }
 
655
 
658
656
    return false;
659
657
  }
660
658
  drizzle_result_free(&result);
 
659
 
661
660
  return true;
662
661
}
663
662
 
666
665
{
667
666
  if (res == NULL)
668
667
  {
669
 
    std::cerr << _("Got error: ") << drizzle_con_error(&connection) << " "
670
 
      << when << std::endl;
 
668
    std::cerr << _("Got error: ") << drizzle_con_error(connection) << " " << when << std::endl;
671
669
  }
672
670
  else if (ret == DRIZZLE_RETURN_ERROR_CODE)
673
671
  {
690
688
    std::cerr << _("-- Disconnecting from ") << hostName << "..." << std::endl;
691
689
  }
692
690
 
693
 
  drizzle_con_free(&connection);
 
691
  drizzle_con_free(connection);
694
692
  drizzle_free(drizzle);
695
693
}