~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzletest.cc

  • Committer: Stewart Smith
  • Date: 2010-02-15 01:56:32 UTC
  • mto: (1273.13.96 build)
  • mto: This revision was merged to the branch mainline in revision 1308.
  • Revision ID: stewart@flamingspork.com-20100215015632-pm7lnxfq5j5uh8kj
move DATABASE() to function plugin. modify parser so that it looks for a function named 'database' when DATABASE() is called. Special case still needed in parser due to hilarity of not-really-reserved words.

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
/* Added this for string translation. */
65
65
#include "drizzled/gettext.h"
66
66
#include "drizzled/hash.h"
67
 
#include "drizzled/drizzle_time.h"
 
67
#include "drizzled/my_time.h"
68
68
#include "drizzled/charset.h"
69
69
 
70
70
#ifndef DRIZZLE_RETURN_SERVER_GONE
77
77
extern "C"
78
78
unsigned char *get_var_key(const unsigned char* var, size_t *len, bool);
79
79
 
80
 
int get_one_option(int optid, const struct option *, char *argument);
 
80
bool get_one_option(int optid, const struct my_option *, char *argument);
81
81
 
82
82
#define MAX_VAR_NAME_LENGTH    256
83
83
#define MAX_COLUMNS            256
2147
2147
 
2148
2148
  if (!internal::test_if_hard_path(name))
2149
2149
  {
2150
 
    snprintf(buff, sizeof(buff), "%s%s",opt_basedir,name);
 
2150
    sprintf(buff,"%s%s",opt_basedir,name);
2151
2151
    name=buff;
2152
2152
  }
2153
2153
  internal::fn_format(buff, name, "", "", MY_UNPACK_FILENAME);
3121
3121
  if (!master_pos.file[0])
3122
3122
    die("Calling 'sync_with_master' without calling 'save_master_pos'");
3123
3123
 
3124
 
  snprintf(query_buf, sizeof(query_buf), "select master_pos_wait('%s', %ld)", master_pos.file,
 
3124
  sprintf(query_buf, "select master_pos_wait('%s', %ld)", master_pos.file,
3125
3125
          master_pos.pos + offset);
3126
3126
 
3127
3127
wait_for_position:
4578
4578
}
4579
4579
 
4580
4580
 
4581
 
static struct option my_long_options[] =
 
4581
static struct my_option my_long_options[] =
4582
4582
{
4583
4583
  {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG,
4584
4584
   0, 0, 0, 0, 0, 0},
4607
4607
   (char**) &opt_max_connect_retries, (char**) &opt_max_connect_retries, 0,
4608
4608
   GET_INT, REQUIRED_ARG, 500, 1, 10000, 0, 0, 0},
4609
4609
  {"mysql", 'm', N_("Use MySQL Protocol."),
4610
 
   (char**) &opt_mysql, (char**) &opt_mysql, 0, GET_BOOL, NO_ARG, 1, 0, 0,
 
4610
   (char**) &opt_mysql, (char**) &opt_mysql, 0, GET_BOOL, NO_ARG, 0, 0, 0,
4611
4611
   0, 0, 0},
4612
4612
  {"password", 'P', "Password to use when connecting to server.",
4613
4613
   0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
4666
4666
  my_print_variables(my_long_options);
4667
4667
}
4668
4668
 
4669
 
int get_one_option(int optid, const struct option *, char *argument)
 
4669
bool get_one_option(int optid, const struct my_option *, char *argument)
4670
4670
{
4671
4671
  char *endchar= NULL;
4672
4672
  uint64_t temp_drizzle_port= 0;
4680
4680
    char buff[FN_REFLEN];
4681
4681
    if (!internal::test_if_hard_path(argument))
4682
4682
    {
4683
 
      snprintf(buff, sizeof(buff), "%s%s",opt_basedir,argument);
 
4683
      sprintf(buff,"%s%s",opt_basedir,argument);
4684
4684
      argument= buff;
4685
4685
    }
4686
4686
    internal::fn_format(buff, argument, "", "", MY_UNPACK_FILENAME);
4687
4687
    assert(cur_file == file_stack && cur_file->file == 0);
4688
4688
    if (!(cur_file->file= fopen(buff, "r")))
4689
 
    {
4690
 
      fprintf(stderr, _("Could not open '%s' for reading: errno = %d"), buff, errno);
4691
 
      return EXIT_ARGUMENT_INVALID;
4692
 
    }
 
4689
      die("Could not open '%s' for reading: errno = %d", buff, errno);
4693
4690
    if (!(cur_file->file_name= strdup(buff)))
4694
 
    {
4695
 
      fprintf(stderr, _("Out of memory"));
4696
 
      return EXIT_OUT_OF_MEMORY;
4697
 
    }
 
4691
      die("Out of memory");
4698
4692
    cur_file->lineno= 1;
4699
4693
    break;
4700
4694
  }
4703
4697
    static char buff[FN_REFLEN];
4704
4698
    if (!internal::test_if_hard_path(argument))
4705
4699
    {
4706
 
      snprintf(buff, sizeof(buff), "%s%s",opt_basedir,argument);
 
4700
      sprintf(buff,"%s%s",opt_basedir,argument);
4707
4701
      argument= buff;
4708
4702
    }
4709
4703
    internal::fn_format(buff, argument, "", "", MY_UNPACK_FILENAME);
4717
4711
    if (strlen(endchar) != 0)
4718
4712
    {
4719
4713
      fprintf(stderr, _("Non-integer value supplied for port.  If you are trying to enter a password please use --password instead.\n"));
4720
 
      return EXIT_ARGUMENT_INVALID;
 
4714
      exit(1);
4721
4715
    }
4722
4716
    /* If the port number is > 65535 it is not a valid port
4723
4717
       This also helps with potential data loss casting unsigned long to a
4725
4719
    if ((temp_drizzle_port == 0) || (temp_drizzle_port > 65535))
4726
4720
    {
4727
4721
      fprintf(stderr, _("Value supplied for port is not valid.\n"));
4728
 
      return EXIT_ARGUMENT_INVALID;
 
4722
      exit(1);
4729
4723
    }
4730
4724
    else
4731
4725
    {
4739
4733
        free(opt_pass);
4740
4734
      opt_pass = strdup(argument);
4741
4735
      if (opt_pass == NULL)
4742
 
      {
4743
 
        fprintf(stderr, _("Out of memory"));
4744
 
        return EXIT_OUT_OF_MEMORY;
4745
 
      }
 
4736
        die("Out of memory");
4746
4737
      while (*argument)
4747
4738
      {
4748
4739
        /* Overwriting password with 'x' */
4806
4797
  int flags= O_WRONLY | O_CREAT;
4807
4798
  if (!internal::test_if_hard_path(fname))
4808
4799
  {
4809
 
    snprintf(buff, sizeof(buff), "%s%s",opt_basedir,fname);
 
4800
    sprintf(buff,"%s%s",opt_basedir,fname);
4810
4801
    fname= buff;
4811
4802
  }
4812
4803
  internal::fn_format(buff, fname, "", "", MY_UNPACK_FILENAME);