~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzletest.cc

  • Committer: Monty Taylor
  • Date: 2009-02-08 11:28:58 UTC
  • mto: This revision was merged to the branch mainline in revision 852.
  • Revision ID: mordred@inaugust.com-20090208112858-aouo9w2okht5r6x0
ZOMG. Renamed all the rest of the stuff in libdrizzleclient to be drizzleclient_*. I love commandline perl.

Show diffs side-by-side

added added

removed removed

Lines of Context:
444
444
void handle_no_error(struct st_command*);
445
445
 
446
446
 
447
 
#define do_send_query(cn,q,q_len,flags) drizzle_send_query(&cn->drizzle, q, q_len)
 
447
#define do_send_query(cn,q,q_len,flags) drizzleclient_send_query(&cn->drizzle, q, q_len)
448
448
 
449
449
void do_eval(string *query_eval, const char *query,
450
450
             const char *query_end, bool pass_through_escape_chars)
567
567
  if (!drizzle)
568
568
    return;
569
569
 
570
 
  if (drizzle_query(drizzle, query))
 
570
  if (drizzleclient_query(drizzle, query))
571
571
  {
572
572
    log_msg("Error running query '%s': %d %s",
573
 
            query, drizzle_errno(drizzle), drizzle_error(drizzle));
 
573
            query, drizzleclient_errno(drizzle), drizzleclient_error(drizzle));
574
574
    return;
575
575
  }
576
576
 
577
 
  if ((res= drizzle_store_result(drizzle)) == NULL)
 
577
  if ((res= drizzleclient_store_result(drizzle)) == NULL)
578
578
  {
579
579
    /* No result set returned */
580
580
    return;
584
584
    DRIZZLE_ROW row;
585
585
    unsigned int i;
586
586
    unsigned int row_num= 0;
587
 
    unsigned int num_fields= drizzle_num_fields(res);
588
 
    const DRIZZLE_FIELD *fields= drizzle_fetch_fields(res);
 
587
    unsigned int num_fields= drizzleclient_num_fields(res);
 
588
    const DRIZZLE_FIELD *fields= drizzleclient_fetch_fields(res);
589
589
 
590
590
    fprintf(stderr, "=== %s ===\n", query);
591
 
    while ((row= drizzle_fetch_row(res)))
 
591
    while ((row= drizzleclient_fetch_row(res)))
592
592
    {
593
 
      uint32_t *lengths= drizzle_fetch_lengths(res);
 
593
      uint32_t *lengths= drizzleclient_fetch_lengths(res);
594
594
      row_num++;
595
595
 
596
596
      fprintf(stderr, "---- %d. ----\n", row_num);
605
605
      fprintf(stderr, "=");
606
606
    fprintf(stderr, "\n\n");
607
607
  }
608
 
  drizzle_free_result(res);
 
608
  drizzleclient_free_result(res);
609
609
 
610
610
  return;
611
611
}
633
633
  if (!drizzle)
634
634
    return;
635
635
 
636
 
  if (drizzle_query(drizzle, query))
 
636
  if (drizzleclient_query(drizzle, query))
637
637
  {
638
638
    log_msg("Error running query '%s': %d %s",
639
 
            query, drizzle_errno(drizzle), drizzle_error(drizzle));
 
639
            query, drizzleclient_errno(drizzle), drizzleclient_error(drizzle));
640
640
    return;
641
641
  }
642
642
 
643
 
  if ((res= drizzle_store_result(drizzle)) == NULL)
 
643
  if ((res= drizzleclient_store_result(drizzle)) == NULL)
644
644
  {
645
645
    /* No result set returned */
646
646
    return;
647
647
  }
648
648
 
649
 
  if (drizzle_num_rows(res) <= 1)
 
649
  if (drizzleclient_num_rows(res) <= 1)
650
650
  {
651
651
    /* Don't display the last row, it's "last error" */
652
652
  }
654
654
  {
655
655
    DRIZZLE_ROW row;
656
656
    unsigned int row_num= 0;
657
 
    unsigned int num_fields= drizzle_num_fields(res);
 
657
    unsigned int num_fields= drizzleclient_num_fields(res);
658
658
 
659
659
    fprintf(stderr, "\nWarnings from just before the error:\n");
660
 
    while ((row= drizzle_fetch_row(res)))
 
660
    while ((row= drizzleclient_fetch_row(res)))
661
661
    {
662
662
      uint32_t i;
663
 
      uint32_t *lengths= drizzle_fetch_lengths(res);
 
663
      uint32_t *lengths= drizzleclient_fetch_lengths(res);
664
664
 
665
 
      if (++row_num >= drizzle_num_rows(res))
 
665
      if (++row_num >= drizzleclient_num_rows(res))
666
666
      {
667
667
        /* Don't display the last row, it's "last error" */
668
668
        break;
676
676
      fprintf(stderr, "\n");
677
677
    }
678
678
  }
679
 
  drizzle_free_result(res);
 
679
  drizzleclient_free_result(res);
680
680
 
681
681
  return;
682
682
}
805
805
 
806
806
  for (--next_con; next_con >= connections; --next_con)
807
807
  {
808
 
    drizzle_close(&next_con->drizzle);
 
808
    drizzleclient_close(&next_con->drizzle);
809
809
    if (next_con->util_drizzle)
810
 
      drizzle_close(next_con->util_drizzle);
 
810
      drizzleclient_close(next_con->util_drizzle);
811
811
    free(next_con->name);
812
812
  }
813
813
  return;
1756
1756
 
1757
1757
/*
1758
1758
  Store an integer (typically the returncode of the last SQL)
1759
 
  statement in the drizzletest builtin variable $drizzle_errno
 
1759
  statement in the drizzletest builtin variable $drizzleclient_errno
1760
1760
*/
1761
1761
 
1762
1762
static void var_set_errno(int sql_errno)
1763
1763
{
1764
 
  var_set_int("$drizzle_errno", sql_errno);
 
1764
  var_set_int("$drizzleclient_errno", sql_errno);
1765
1765
}
1766
1766
 
1767
1767
 
1768
1768
/*
1769
 
  Update $drizzle_get_server_version variable with version
 
1769
  Update $drizzleclient_get_server_version variable with version
1770
1770
  of the currently connected server
1771
1771
*/
1772
1772
 
1773
 
static void var_set_drizzle_get_server_version(DRIZZLE *drizzle)
 
1773
static void var_set_drizzleclient_get_server_version(DRIZZLE *drizzle)
1774
1774
{
1775
 
  var_set_int("$drizzle_get_server_version", drizzle_get_server_version(drizzle));
 
1775
  var_set_int("$drizzleclient_get_server_version", drizzleclient_get_server_version(drizzle));
1776
1776
}
1777
1777
 
1778
1778
 
1818
1818
  /* Eval the query, thus replacing all environment variables */
1819
1819
  do_eval(&ds_query, query, end, false);
1820
1820
 
1821
 
  if (drizzle_real_query(drizzle, ds_query.c_str(), ds_query.length()))
 
1821
  if (drizzleclient_real_query(drizzle, ds_query.c_str(), ds_query.length()))
1822
1822
    die("Error running query '%s': %d %s", ds_query.c_str(),
1823
 
        drizzle_errno(drizzle), drizzle_error(drizzle));
1824
 
  if (!(res= drizzle_store_result(drizzle)))
 
1823
        drizzleclient_errno(drizzle), drizzleclient_error(drizzle));
 
1824
  if (!(res= drizzleclient_store_result(drizzle)))
1825
1825
    die("Query '%s' didn't return a result set", ds_query.c_str());
1826
1826
 
1827
 
  if ((row= drizzle_fetch_row(res)) && row[0])
 
1827
  if ((row= drizzleclient_fetch_row(res)) && row[0])
1828
1828
  {
1829
1829
    /*
1830
1830
      Concatenate all fields in the first row with tab in between
1834
1834
    uint32_t i;
1835
1835
    uint32_t *lengths;
1836
1836
 
1837
 
    lengths= drizzle_fetch_lengths(res);
1838
 
    for (i= 0; i < drizzle_num_fields(res); i++)
 
1837
    lengths= drizzleclient_fetch_lengths(res);
 
1838
    for (i= 0; i < drizzleclient_num_fields(res); i++)
1839
1839
    {
1840
1840
      if (row[i])
1841
1841
      {
1850
1850
  else
1851
1851
    eval_expr(var, "", 0);
1852
1852
 
1853
 
  drizzle_free_result(res);
 
1853
  drizzleclient_free_result(res);
1854
1854
  return;
1855
1855
}
1856
1856
 
1913
1913
  ds_query.append(unstripped_query);
1914
1914
 
1915
1915
  /* Run the query */
1916
 
  if (drizzle_real_query(drizzle, ds_query.c_str(), ds_query.length()))
 
1916
  if (drizzleclient_real_query(drizzle, ds_query.c_str(), ds_query.length()))
1917
1917
    die("Error running query '%s': %d %s", ds_query.c_str(),
1918
 
        drizzle_errno(drizzle), drizzle_error(drizzle));
1919
 
  if (!(res= drizzle_store_result(drizzle)))
 
1918
        drizzleclient_errno(drizzle), drizzleclient_error(drizzle));
 
1919
  if (!(res= drizzleclient_store_result(drizzle)))
1920
1920
    die("Query '%s' didn't return a result set", ds_query.c_str());
1921
1921
 
1922
1922
  {
1923
1923
    /* Find column number from the given column name */
1924
1924
    uint i;
1925
 
    uint num_fields= drizzle_num_fields(res);
1926
 
    const DRIZZLE_FIELD *fields= drizzle_fetch_fields(res);
 
1925
    uint num_fields= drizzleclient_num_fields(res);
 
1926
    const DRIZZLE_FIELD *fields= drizzleclient_fetch_fields(res);
1927
1927
 
1928
1928
    for (i= 0; i < num_fields; i++)
1929
1929
    {
1936
1936
    }
1937
1937
    if (col_no == -1)
1938
1938
    {
1939
 
      drizzle_free_result(res);
 
1939
      drizzleclient_free_result(res);
1940
1940
      die("Could not find column '%s' in the result of '%s'",
1941
1941
          ds_col.c_str(), ds_query.c_str());
1942
1942
    }
1948
1948
    long rows= 0;
1949
1949
    const char* value= "No such row";
1950
1950
 
1951
 
    while ((row= drizzle_fetch_row(res)))
 
1951
    while ((row= drizzleclient_fetch_row(res)))
1952
1952
    {
1953
1953
      if (++rows == row_no)
1954
1954
      {
1964
1964
    }
1965
1965
    eval_expr(var, value, 0);
1966
1966
  }
1967
 
  drizzle_free_result(res);
 
1967
  drizzleclient_free_result(res);
1968
1968
 
1969
1969
  return;
1970
1970
}
2872
2872
  if (!ds_db.length())
2873
2873
    ds_db.append(drizzle->db);
2874
2874
 
2875
 
  if (drizzle_change_user(drizzle, ds_user.c_str(),
 
2875
  if (drizzleclient_change_user(drizzle, ds_user.c_str(),
2876
2876
                          ds_passwd.c_str(), ds_db.c_str()))
2877
 
    die("change user failed: %s", drizzle_error(drizzle));
 
2877
    die("change user failed: %s", drizzleclient_error(drizzle));
2878
2878
 
2879
2879
 
2880
2880
  return;
3006
3006
    DRIZZLE_ROW row;
3007
3007
    int done;
3008
3008
 
3009
 
    if (drizzle_query(drizzle,"show status like 'Slave_running'") ||
3010
 
        !(res=drizzle_store_result(drizzle)))
 
3009
    if (drizzleclient_query(drizzle,"show status like 'Slave_running'") ||
 
3010
        !(res=drizzleclient_store_result(drizzle)))
3011
3011
      die("Query failed while probing slave for stop: %s",
3012
 
          drizzle_error(drizzle));
3013
 
    if (!(row=drizzle_fetch_row(res)) || !row[1])
 
3012
          drizzleclient_error(drizzle));
 
3013
    if (!(row=drizzleclient_fetch_row(res)) || !row[1])
3014
3014
    {
3015
 
      drizzle_free_result(res);
 
3015
      drizzleclient_free_result(res);
3016
3016
      die("Strange result from query while probing slave for stop");
3017
3017
    }
3018
3018
    done = !strcmp(row[1],"OFF");
3019
 
    drizzle_free_result(res);
 
3019
    drizzleclient_free_result(res);
3020
3020
    if (done)
3021
3021
      break;
3022
3022
    usleep(SLAVE_POLL_INTERVAL);
3041
3041
 
3042
3042
wait_for_position:
3043
3043
 
3044
 
  if (drizzle_query(drizzle, query_buf))
3045
 
    die("failed in '%s': %d: %s", query_buf, drizzle_errno(drizzle),
3046
 
        drizzle_error(drizzle));
 
3044
  if (drizzleclient_query(drizzle, query_buf))
 
3045
    die("failed in '%s': %d: %s", query_buf, drizzleclient_errno(drizzle),
 
3046
        drizzleclient_error(drizzle));
3047
3047
 
3048
 
  if (!(res= drizzle_store_result(drizzle)))
3049
 
    die("drizzle_store_result() returned NULL for '%s'", query_buf);
3050
 
  if (!(row= drizzle_fetch_row(res)))
 
3048
  if (!(res= drizzleclient_store_result(drizzle)))
 
3049
    die("drizzleclient_store_result() returned NULL for '%s'", query_buf);
 
3050
  if (!(row= drizzleclient_fetch_row(res)))
3051
3051
  {
3052
 
    drizzle_free_result(res);
 
3052
    drizzleclient_free_result(res);
3053
3053
    die("empty result in %s", query_buf);
3054
3054
  }
3055
3055
  if (!row[0])
3058
3058
      It may be that the slave SQL thread has not started yet, though START
3059
3059
      SLAVE has been issued ?
3060
3060
    */
3061
 
    drizzle_free_result(res);
 
3061
    drizzleclient_free_result(res);
3062
3062
    if (tries++ == 30)
3063
3063
    {
3064
3064
      show_query(drizzle, "SHOW MASTER STATUS");
3068
3068
    sleep(1); /* So at most we will wait 30 seconds and make 31 tries */
3069
3069
    goto wait_for_position;
3070
3070
  }
3071
 
  drizzle_free_result(res);
 
3071
  drizzleclient_free_result(res);
3072
3072
  return;
3073
3073
}
3074
3074
 
3104
3104
  const char *query;
3105
3105
 
3106
3106
 
3107
 
  if (drizzle_query(drizzle, query= "show master status"))
 
3107
  if (drizzleclient_query(drizzle, query= "show master status"))
3108
3108
    die("failed in 'show master status': %d %s",
3109
 
        drizzle_errno(drizzle), drizzle_error(drizzle));
 
3109
        drizzleclient_errno(drizzle), drizzleclient_error(drizzle));
3110
3110
 
3111
 
  if (!(res = drizzle_store_result(drizzle)))
3112
 
    die("drizzle_store_result() retuned NULL for '%s'", query);
3113
 
  if (!(row = drizzle_fetch_row(res)))
 
3111
  if (!(res = drizzleclient_store_result(drizzle)))
 
3112
    die("drizzleclient_store_result() retuned NULL for '%s'", query);
 
3113
  if (!(row = drizzleclient_fetch_row(res)))
3114
3114
    die("empty result in show master status");
3115
3115
  strncpy(master_pos.file, row[0], sizeof(master_pos.file)-1);
3116
3116
  master_pos.pos = strtoul(row[1], (char**) 0, 10);
3117
 
  drizzle_free_result(res);
 
3117
  drizzleclient_free_result(res);
3118
3118
  return(0);
3119
3119
}
3120
3120
 
3481
3481
{
3482
3482
  bool reconnect= val;
3483
3483
 
3484
 
  drizzle_options(drizzle, DRIZZLE_OPT_RECONNECT, (char *)&reconnect);
 
3484
  drizzleclient_options(drizzle, DRIZZLE_OPT_RECONNECT, (char *)&reconnect);
3485
3485
 
3486
3486
  return;
3487
3487
}
3492
3492
  if (!(cur_con= find_connection_by_name(name)))
3493
3493
    die("connection '%s' not found in connection pool", name);
3494
3494
 
3495
 
  /* Update $drizzle_get_server_version to that of current connection */
3496
 
  var_set_drizzle_get_server_version(&cur_con->drizzle);
 
3495
  /* Update $drizzleclient_get_server_version to that of current connection */
 
3496
  var_set_drizzleclient_get_server_version(&cur_con->drizzle);
3497
3497
 
3498
3498
  return(0);
3499
3499
}
3543
3543
    }
3544
3544
  }
3545
3545
 
3546
 
  drizzle_close(&con->drizzle);
 
3546
  drizzleclient_close(&con->drizzle);
3547
3547
 
3548
3548
  if (con->util_drizzle)
3549
 
    drizzle_close(con->util_drizzle);
 
3549
    drizzleclient_close(con->util_drizzle);
3550
3550
  con->util_drizzle= 0;
3551
3551
 
3552
3552
  free(con->name);
3595
3595
  static uint32_t connection_retry_sleep= 100000; /* Microseconds */
3596
3596
 
3597
3597
 
3598
 
  while(!drizzle_connect(drizzle, host, user, pass, db, port, NULL,
 
3598
  while(!drizzleclient_connect(drizzle, host, user, pass, db, port, NULL,
3599
3599
                         CLIENT_MULTI_STATEMENTS | CLIENT_REMEMBER_OPTIONS))
3600
3600
  {
3601
3601
    /*
3606
3606
      on protocol/connection type
3607
3607
    */
3608
3608
 
3609
 
    if ((drizzle_errno(drizzle) == CR_CONN_HOST_ERROR ||
3610
 
         drizzle_errno(drizzle) == CR_CONNECTION_ERROR) &&
 
3609
    if ((drizzleclient_errno(drizzle) == CR_CONN_HOST_ERROR ||
 
3610
         drizzleclient_errno(drizzle) == CR_CONNECTION_ERROR) &&
3611
3611
        failed_attempts < opt_max_connect_retries)
3612
3612
    {
3613
3613
      verbose_msg("Connect attempt %d/%d failed: %d: %s", failed_attempts,
3614
 
                  opt_max_connect_retries, drizzle_errno(drizzle),
3615
 
                  drizzle_error(drizzle));
 
3614
                  opt_max_connect_retries, drizzleclient_errno(drizzle),
 
3615
                  drizzleclient_error(drizzle));
3616
3616
      usleep(connection_retry_sleep);
3617
3617
    }
3618
3618
    else
3619
3619
    {
3620
3620
      if (failed_attempts > 0)
3621
3621
        die("Could not open connection '%s' after %d attempts: %d %s", name,
3622
 
            failed_attempts, drizzle_errno(drizzle), drizzle_error(drizzle));
 
3622
            failed_attempts, drizzleclient_errno(drizzle), drizzleclient_error(drizzle));
3623
3623
      else
3624
3624
        die("Could not open connection '%s': %d %s", name,
3625
 
            drizzle_errno(drizzle), drizzle_error(drizzle));
 
3625
            drizzleclient_errno(drizzle), drizzleclient_error(drizzle));
3626
3626
    }
3627
3627
    failed_attempts++;
3628
3628
  }
3684
3684
    ds_res.append(delimiter);
3685
3685
    ds_res.append("\n");
3686
3686
  }
3687
 
  if (!drizzle_connect(con, host, user, pass, db, port, 0,
 
3687
  if (!drizzleclient_connect(con, host, user, pass, db, port, 0,
3688
3688
                       CLIENT_MULTI_STATEMENTS))
3689
3689
  {
3690
 
    var_set_errno(drizzle_errno(con));
3691
 
    handle_error(command, drizzle_errno(con), drizzle_error(con),
3692
 
                 drizzle_sqlstate(con), &ds_res);
 
3690
    var_set_errno(drizzleclient_errno(con));
 
3691
    handle_error(command, drizzleclient_errno(con), drizzleclient_error(con),
 
3692
                 drizzleclient_sqlstate(con), &ds_res);
3693
3693
    return 0; /* Not connected */
3694
3694
  }
3695
3695
 
3817
3817
          (int) (sizeof(connections)/sizeof(struct st_connection)));
3818
3818
  }
3819
3819
 
3820
 
  if (!drizzle_create(&con_slot->drizzle))
3821
 
    die("Failed on drizzle_create()");
 
3820
  if (!drizzleclient_create(&con_slot->drizzle))
 
3821
    die("Failed on drizzleclient_create()");
3822
3822
  if (opt_compress || con_compress)
3823
 
    drizzle_options(&con_slot->drizzle, DRIZZLE_OPT_COMPRESS, NULL);
3824
 
  drizzle_options(&con_slot->drizzle, DRIZZLE_OPT_LOCAL_INFILE, 0);
 
3823
    drizzleclient_options(&con_slot->drizzle, DRIZZLE_OPT_COMPRESS, NULL);
 
3824
  drizzleclient_options(&con_slot->drizzle, DRIZZLE_OPT_LOCAL_INFILE, 0);
3825
3825
 
3826
3826
  /* Use default db name */
3827
3827
  if (ds_database.length() == 0)
3844
3844
      next_con++; /* if we used the next_con slot, advance the pointer */
3845
3845
  }
3846
3846
 
3847
 
  /* Update $drizzle_get_server_version to that of current connection */
3848
 
  var_set_drizzle_get_server_version(&cur_con->drizzle);
 
3847
  /* Update $drizzleclient_get_server_version to that of current connection */
 
3848
  var_set_drizzleclient_get_server_version(&cur_con->drizzle);
3849
3849
 
3850
3850
  return;
3851
3851
}
4530
4530
static void print_version(void)
4531
4531
{
4532
4532
  printf("%s  Ver %s Distrib %s, for %s (%s)\n",my_progname,MTEST_VERSION,
4533
 
         drizzle_get_client_info(),SYSTEM_TYPE,MACHINE_TYPE);
 
4533
         drizzleclient_get_client_info(),SYSTEM_TYPE,MACHINE_TYPE);
4534
4534
}
4535
4535
 
4536
4536
static void usage(void)
4851
4851
static void append_result(string *ds, DRIZZLE_RES *res)
4852
4852
{
4853
4853
  DRIZZLE_ROW row;
4854
 
  uint32_t num_fields= drizzle_num_fields(res);
4855
 
  const DRIZZLE_FIELD *fields= drizzle_fetch_fields(res);
 
4854
  uint32_t num_fields= drizzleclient_num_fields(res);
 
4855
  const DRIZZLE_FIELD *fields= drizzleclient_fetch_fields(res);
4856
4856
  uint32_t *lengths;
4857
4857
 
4858
 
  while ((row = drizzle_fetch_row(res)))
 
4858
  while ((row = drizzleclient_fetch_row(res)))
4859
4859
  {
4860
4860
    uint32_t i;
4861
 
    lengths = drizzle_fetch_lengths(res);
 
4861
    lengths = drizzleclient_fetch_lengths(res);
4862
4862
    for (i = 0; i < num_fields; i++)
4863
4863
      append_field(ds, i, &fields[i],
4864
4864
                   (const char*)row[i], lengths[i], !row[i]);
4971
4971
  DRIZZLE_RES *warn_res;
4972
4972
 
4973
4973
 
4974
 
  if (!(count= drizzle_warning_count(drizzle)))
 
4974
  if (!(count= drizzleclient_warning_count(drizzle)))
4975
4975
    return(0);
4976
4976
 
4977
4977
  /*
4979
4979
    through PS API we should not issue SHOW WARNINGS until
4980
4980
    we have not read all results...
4981
4981
  */
4982
 
  assert(!drizzle_more_results(drizzle));
4983
 
 
4984
 
  if (drizzle_real_query(drizzle, "SHOW WARNINGS", 13))
4985
 
    die("Error running query \"SHOW WARNINGS\": %s", drizzle_error(drizzle));
4986
 
 
4987
 
  if (!(warn_res= drizzle_store_result(drizzle)))
 
4982
  assert(!drizzleclient_more_results(drizzle));
 
4983
 
 
4984
  if (drizzleclient_real_query(drizzle, "SHOW WARNINGS", 13))
 
4985
    die("Error running query \"SHOW WARNINGS\": %s", drizzleclient_error(drizzle));
 
4986
 
 
4987
  if (!(warn_res= drizzleclient_store_result(drizzle)))
4988
4988
    die("Warning count is %u but didn't get any warnings",
4989
4989
        count);
4990
4990
 
5023
5023
     */
5024
5024
    if (do_send_query(cn, query, query_len, flags))
5025
5025
    {
5026
 
      handle_error(command, drizzle_errno(drizzle), drizzle_error(drizzle),
5027
 
                   drizzle_sqlstate(drizzle), ds);
 
5026
      handle_error(command, drizzleclient_errno(drizzle), drizzleclient_error(drizzle),
 
5027
                   drizzleclient_sqlstate(drizzle), ds);
5028
5028
      goto end;
5029
5029
    }
5030
5030
  }
5034
5034
  do
5035
5035
  {
5036
5036
    /*
5037
 
      When  on first result set, call drizzle_read_query_result to retrieve
 
5037
      When  on first result set, call drizzleclient_read_query_result to retrieve
5038
5038
      answer to the query sent earlier
5039
5039
    */
5040
 
    if ((counter==0) && drizzle_read_query_result(drizzle))
 
5040
    if ((counter==0) && drizzleclient_read_query_result(drizzle))
5041
5041
    {
5042
 
      handle_error(command, drizzle_errno(drizzle), drizzle_error(drizzle),
5043
 
                   drizzle_sqlstate(drizzle), ds);
 
5042
      handle_error(command, drizzleclient_errno(drizzle), drizzleclient_error(drizzle),
 
5043
                   drizzleclient_sqlstate(drizzle), ds);
5044
5044
      goto end;
5045
5045
 
5046
5046
    }
5048
5048
    /*
5049
5049
      Store the result of the query if it will return any fields
5050
5050
    */
5051
 
    if (drizzle_field_count(drizzle) && ((res= drizzle_store_result(drizzle)) == 0))
 
5051
    if (drizzleclient_field_count(drizzle) && ((res= drizzleclient_store_result(drizzle)) == 0))
5052
5052
    {
5053
 
      handle_error(command, drizzle_errno(drizzle), drizzle_error(drizzle),
5054
 
                   drizzle_sqlstate(drizzle), ds);
 
5053
      handle_error(command, drizzleclient_errno(drizzle), drizzleclient_error(drizzle),
 
5054
                   drizzleclient_sqlstate(drizzle), ds);
5055
5055
      goto end;
5056
5056
    }
5057
5057
 
5061
5061
 
5062
5062
      if (res)
5063
5063
      {
5064
 
        const DRIZZLE_FIELD *fields= drizzle_fetch_fields(res);
5065
 
        uint num_fields= drizzle_num_fields(res);
 
5064
        const DRIZZLE_FIELD *fields= drizzleclient_fetch_fields(res);
 
5065
        uint num_fields= drizzleclient_num_fields(res);
5066
5066
 
5067
5067
        if (display_metadata)
5068
5068
          append_metadata(ds, fields, num_fields);
5074
5074
      }
5075
5075
 
5076
5076
      /*
5077
 
        Need to call drizzle_affected_rows() before the "new"
 
5077
        Need to call drizzleclient_affected_rows() before the "new"
5078
5078
        query to find the warnings
5079
5079
      */
5080
5080
      if (!disable_info)
5081
 
        affected_rows= drizzle_affected_rows(drizzle);
 
5081
        affected_rows= drizzleclient_affected_rows(drizzle);
5082
5082
 
5083
5083
      /*
5084
5084
        Add all warnings to the result. We can't do this if we are in
5085
5085
        the middle of processing results from multi-statement, because
5086
5086
        this will break protocol.
5087
5087
      */
5088
 
      if (!disable_warnings && !drizzle_more_results(drizzle))
 
5088
      if (!disable_warnings && !drizzleclient_more_results(drizzle))
5089
5089
      {
5090
5090
        if (append_warnings(ds_warnings, drizzle) || ds_warnings->length())
5091
5091
        {
5095
5095
      }
5096
5096
 
5097
5097
      if (!disable_info)
5098
 
        append_info(ds, affected_rows, drizzle_info(drizzle));
 
5098
        append_info(ds, affected_rows, drizzleclient_info(drizzle));
5099
5099
    }
5100
5100
 
5101
5101
    if (res)
5102
5102
    {
5103
 
      drizzle_free_result(res);
 
5103
      drizzleclient_free_result(res);
5104
5104
      res= 0;
5105
5105
    }
5106
5106
    counter++;
5107
 
  } while (!(err= drizzle_next_result(drizzle)));
 
5107
  } while (!(err= drizzleclient_next_result(drizzle)));
5108
5108
  if (err > 0)
5109
5109
  {
5110
 
    /* We got an error from drizzle_next_result, maybe expected */
5111
 
    handle_error(command, drizzle_errno(drizzle), drizzle_error(drizzle),
5112
 
                 drizzle_sqlstate(drizzle), ds);
 
5110
    /* We got an error from drizzleclient_next_result, maybe expected */
 
5111
    handle_error(command, drizzleclient_errno(drizzle), drizzleclient_error(drizzle),
 
5112
                 drizzleclient_sqlstate(drizzle), ds);
5113
5113
    goto end;
5114
5114
  }
5115
5115
  assert(err == -1); /* Successful and there are no more results */
5120
5120
end:
5121
5121
 
5122
5122
  /*
5123
 
    We save the return code (drizzle_errno(drizzle)) from the last call sent
5124
 
    to the server into the drizzletest builtin variable $drizzle_errno. This
 
5123
    We save the return code (drizzleclient_errno(drizzle)) from the last call sent
 
5124
    to the server into the drizzletest builtin variable $drizzleclient_errno. This
5125
5125
    variable then can be used from the test case itself.
5126
5126
  */
5127
 
  var_set_errno(drizzle_errno(drizzle));
 
5127
  var_set_errno(drizzleclient_errno(drizzle));
5128
5128
  return;
5129
5129
}
5130
5130
 
5527
5527
                1024, 0, 0, get_var_key, var_free, MYF(0)))
5528
5528
    die("Variable hash initialization failed");
5529
5529
 
5530
 
  var_set_string("$DRIZZLE_SERVER_VERSION", drizzle_get_client_info());
 
5530
  var_set_string("$DRIZZLE_SERVER_VERSION", drizzleclient_get_client_info());
5531
5531
 
5532
5532
  memset(&master_pos, 0, sizeof(master_pos));
5533
5533
 
5552
5552
    cur_file->lineno= 1;
5553
5553
  }
5554
5554
  cur_con= connections;
5555
 
  if (!( drizzle_create(&cur_con->drizzle)))
5556
 
    die("Failed in drizzle_create()");
 
5555
  if (!( drizzleclient_create(&cur_con->drizzle)))
 
5556
    die("Failed in drizzleclient_create()");
5557
5557
  if (opt_compress)
5558
 
    drizzle_options(&cur_con->drizzle,DRIZZLE_OPT_COMPRESS,NULL);
5559
 
  drizzle_options(&cur_con->drizzle, DRIZZLE_OPT_LOCAL_INFILE, 0);
 
5558
    drizzleclient_options(&cur_con->drizzle,DRIZZLE_OPT_COMPRESS,NULL);
 
5559
  drizzleclient_options(&cur_con->drizzle, DRIZZLE_OPT_LOCAL_INFILE, 0);
5560
5560
 
5561
5561
  if (!(cur_con->name = strdup("default")))
5562
5562
    die("Out of memory");
5568
5568
  timer_start= timer_now();
5569
5569
 
5570
5570
  /*
5571
 
    Initialize $drizzle_errno with -1, so we can
 
5571
    Initialize $drizzleclient_errno with -1, so we can
5572
5572
    - distinguish it from valid values ( >= 0 ) and
5573
5573
    - detect if there was never a command sent to the server
5574
5574
  */
5575
5575
  var_set_errno(-1);
5576
5576
 
5577
 
  /* Update $drizzle_get_server_version to that of current connection */
5578
 
  var_set_drizzle_get_server_version(&cur_con->drizzle);
 
5577
  /* Update $drizzleclient_get_server_version to that of current connection */
 
5578
  var_set_drizzleclient_get_server_version(&cur_con->drizzle);
5579
5579
 
5580
5580
  if (opt_include)
5581
5581
  {
5763
5763
        command->last_argument= command->end;
5764
5764
        break;
5765
5765
      case Q_PING:
5766
 
        (void) drizzle_ping(&cur_con->drizzle);
 
5766
        (void) drizzleclient_ping(&cur_con->drizzle);
5767
5767
        break;
5768
5768
      case Q_EXEC:
5769
5769
        do_exec(command);