Commit e947c95f authored by monty@bitch.mysql.fi's avatar monty@bitch.mysql.fi
Browse files

Merge hundin:/my/mysql-4.0 into bitch.mysql.fi:/my/mysql-4.0

parents a49763f3 4dbd9e06
Loading
Loading
Loading
Loading
+895 −28

File changed.

Preview size limit exceeded, changes collapsed.

Docs/section.Comparisons.texi

deleted100644 → 0
+0 −1119

File deleted.

Preview size limit exceeded, changes collapsed.

+27 −47
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@
#include <signal.h>
#include <violite.h>

const char *VER="11.18";
const char *VER="11.19";

/* Don't try to make a nice table if the data is too big */
#define MAX_COLUMN_LENGTH	     1024
@@ -172,8 +172,7 @@ static int sql_connect(char *host,char *database,char *user,char *password,
static int put_info(const char *str,INFO_TYPE info,uint error=0);
static void safe_put_field(const char *pos,ulong length);
static const char *array_value(const char **array, char *key);
static void xmlencode(char *dest, char *src);
static void my_chomp(char *end);
static void xmlencode_print(const char *src, uint length);
static void init_pager();
static void end_pager();
static void init_tee();
@@ -1708,18 +1707,11 @@ print_table_data_xml(MYSQL_RES *result)

  mysql_field_seek(result,0);

  char *statement;
  statement=(char*) my_malloc(strlen(glob_buffer.ptr())*5+1, MYF(MY_WME));
  xmlencode(statement, (char*) glob_buffer.ptr());

  (void) my_chomp(strend(statement));

  tee_fprintf(PAGER,"<?xml version=\"1.0\"?>\n\n<resultset statement=\"%s\">", statement);

  my_free(statement,MYF(MY_ALLOW_ZERO_PTR));
  tee_fputs("<?xml version=\"1.0\"?>\n\n<resultset statement=\"", PAGER);
  xmlencode_print(glob_buffer.ptr(), strlen(glob_buffer.ptr()) - 1);
  tee_fputs("\">", PAGER);

  fields = mysql_fetch_fields(result);

  while ((cur = mysql_fetch_row(result)))
  {
    (void) tee_fputs("\n  <row>\n", PAGER);
@@ -1727,16 +1719,13 @@ print_table_data_xml(MYSQL_RES *result)
    {
      char *data;
      ulong *lengths=mysql_fetch_lengths(result);
      data=(char*) my_malloc(lengths[i]*5+1, MYF(MY_WME));
      tee_fprintf(PAGER, "\t<%s>", (fields[i].name ?
				  (fields[i].name[0] ? fields[i].name :
				   " &nbsp; ") : "NULL"));
      xmlencode(data, cur[i]);
      safe_put_field(data, strlen(data));
      xmlencode_print(cur[i], lengths[i]);
      tee_fprintf(PAGER, "</%s>\n", (fields[i].name ?
				     (fields[i].name[0] ? fields[i].name :
				      " &nbsp; ") : "NULL"));
      my_free(data,MYF(MY_ALLOW_ZERO_PTR));
    }
    (void) tee_fputs("  </row>\n", PAGER);
  }
@@ -1774,43 +1763,34 @@ print_table_data_vertically(MYSQL_RES *result)
  }
}


static const char
*array_value(const char **array, char *key) {
*array_value(const char **array, char key)
{
  int x;
  for (x= 0; array[x]; x+= 2)
    if(!strcmp(array[x], key))
    if (*array[x] == key)
      return array[x + 1];
  return 0;
}


static void
xmlencode(char *dest, char *src)
xmlencode_print(const char *src, uint length)
{
  char *p = src;
  const char *t;
  char s[2] = { 0, 0 };
  *dest = 0;

  do
  if (!src)
    tee_fputs("NULL", PAGER);
  else
  {
    s[0] = *p;
    if (!(t=array_value(xmlmeta, s)))
      t = s;
    dest=strmov(dest, t);
  } while(*p++);
    for (const char *p = src; *p && length; *p++, length--)
    {
      const char *t;
      if ((t = array_value(xmlmeta, *p)))
	tee_fputs(t, PAGER);
      else
	tee_putc(*p, PAGER);
    }
  }

static void
my_chomp(char *end) {
  char *mend;
  mend = end;

  do {
    if (isspace(*mend)) {
      *mend = '\0';
    } else
      mend--;
  } while (mend && *mend);
}


+86 −58
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@

**********************************************************************/

#define MTEST_VERSION "1.12"
#define MTEST_VERSION "1.13"

#include <my_global.h>
#include <mysql_embed.h>
@@ -243,7 +243,8 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname);
void reject_dump(const char *record_file, char *buf, int size);

int close_connection(struct st_query* q);
VAR* var_get(const char *var_name, const char** var_name_end, int raw);
VAR* var_get(const char *var_name, const char** var_name_end, my_bool raw,
	     my_bool ignore_not_existing);
int eval_expr(VAR* v, const char *p, const char** p_end);
static int read_server_arguments(const char *name);

@@ -261,6 +262,7 @@ struct st_replace *init_replace(my_string *from, my_string *to, uint count,
				my_string word_end_chars);
uint replace_strings(struct st_replace *rep, my_string *start,
		     uint *max_length, my_string from);
void free_replace();
static int insert_pointer_name(reg1 POINTER_ARRAY *pa,my_string name);
void free_pointer_array(POINTER_ARRAY *pa);
static int initialize_replace_buffer(void);
@@ -314,7 +316,7 @@ static void do_eval(DYNAMIC_STRING* query_eval, const char* query)
	    }
	  else
	    {
	      if(!(v = var_get(p, &p, 0)))
	      if(!(v = var_get(p, &p, 0, 0)))
		die("Bad variable in eval");
	      dynstr_append_mem(query_eval, v->str_val, v->str_val_len);
	    }
@@ -545,37 +547,40 @@ static int check_result(DYNAMIC_STRING* ds, const char* fname,
  return error;
}

VAR* var_get(const char* var_name, const char** var_name_end, int raw)
VAR* var_get(const char* var_name, const char** var_name_end, my_bool raw,
	     my_bool ignore_not_existing)
{
  int digit;
  VAR* v;
  if (*var_name++ != '$')
  {
    --var_name;
  DBUG_ENTER("var_get");
  DBUG_PRINT("enter",("var_name: %s",var_name));

  if (*var_name != '$')
    goto err;
  }
  digit = *var_name - '0';
  digit = *++var_name - '0';
  if (!(digit < 10 && digit >= 0))
  {
    const char* save_var_name = var_name, *end;
    end = (var_name_end) ? *var_name_end : 0;
    while (isvar(*var_name))
    {
      if(end && var_name == end)
	break;
    while (isvar(*var_name) && var_name != end)
      ++var_name;
    }
    if (var_name == save_var_name)
    {
      if (ignore_not_existing)
	DBUG_RETURN(0);
      die("Empty variable");
    }

    if (!(v = (VAR*) hash_search(&var_hash, save_var_name,
			       var_name - save_var_name)))
    {
      if (ignore_not_existing)
	DBUG_RETURN(0);
      if (end)
	*(char*) end = 0;
      die("Variable '%s' used uninitialized", save_var_name);
    }
    --var_name;
    --var_name;					/* Point at last character */
  }
  else 
    v = var_reg + digit;
@@ -588,12 +593,12 @@ VAR* var_get(const char* var_name, const char** var_name_end, int raw)
  }
  if (var_name_end)
    *var_name_end = var_name  ;
  return v;
  DBUG_RETURN(v);
err:
  if (var_name_end)
    *var_name_end = 0;
  die("Unsupported variable name: %s", var_name);
  return 0;
  DBUG_RETURN(0);
}

static VAR* var_obtain(char* name, int len)
@@ -747,11 +752,11 @@ void var_copy(VAR* dest, VAR* src)
  dest->int_val=src->int_val;
  dest->int_dirty=src->int_dirty;
  if (dest->alloced_len < src->alloced_len &&
      !(dest->str_val=my_realloc(dest->str_val,src->alloced_len,
      !(dest->str_val=my_realloc(dest->str_val,src->alloced_len+1,
				 MYF(MY_WME))))
    die("Out of memory");
  dest->str_val_len=src->str_val_len;
  memcpy(dest->str_val,src->str_val,src->str_val_len);
  memcpy(dest->str_val,src->str_val,src->str_val_len+1);
}

int eval_expr(VAR* v, const char* p, const char** p_end)
@@ -759,7 +764,7 @@ int eval_expr(VAR* v, const char* p, const char** p_end)
  VAR* vp;
  if (*p == '$')
  {
      if ((vp = var_get(p,p_end,0)))
    if ((vp = var_get(p,p_end,0,0)))
    {
      var_copy(v, vp);
      return 0;
@@ -778,9 +783,9 @@ int eval_expr(VAR* v, const char* p, const char** p_end)
        v->alloced_len = (new_val_len < MIN_VAR_ALLOC - 1) ?
	  MIN_VAR_ALLOC : new_val_len + 1;
	if (!(v->str_val =
	      v->str_val ? my_realloc(v->str_val, v->alloced_len,
	      v->str_val ? my_realloc(v->str_val, v->alloced_len+1,
				      MYF(MY_WME)) :
	      my_malloc(v->alloced_len, MYF(MY_WME))))
	      my_malloc(v->alloced_len+1, MYF(MY_WME))))
	  die("Out of memory");
      }
      v->str_val_len = new_val_len;
@@ -801,7 +806,7 @@ int do_inc(struct st_query* q)
{
  char* p=q->first_argument;
  VAR* v;
  v = var_get(p, 0, 1);
  v = var_get(p, 0, 1, 0);
  v->int_val++;
  v->int_dirty = 1;
  return 0;
@@ -811,7 +816,7 @@ int do_dec(struct st_query* q)
{
  char* p=q->first_argument;
  VAR* v;
  v = var_get(p, 0, 1);
  v = var_get(p, 0, 1, 0);
  v->int_val--;
  v->int_dirty = 1;
  return 0;
@@ -1042,14 +1047,16 @@ static uint get_ints(uint *to,struct st_query* q)
/*
  Get a string;  Return ptr to end of string
  Strings may be surrounded by " or '

  If string is a '$variable', return the value of the variable.
*/


static void get_string(char **to_ptr, char **from_ptr,
static char *get_string(char **to_ptr, char **from_ptr,
			struct st_query* q)
{
  reg1 char c,sep;
  char *to= *to_ptr, *from= *from_ptr;
  char *to= *to_ptr, *from= *from_ptr, *start=to;
  DBUG_ENTER("get_string");

  /* Find separator */
@@ -1099,9 +1106,22 @@ static void get_string(char **to_ptr, char **from_ptr,
  while (isspace(*from))		/* Point to next string */
    from++;

  *to++ =0;				/* End of string marker */
  *to_ptr= to;
  *to =0;				/* End of string marker */
  *to_ptr= to+1;			/* Store pointer to end */
  *from_ptr= from;

  /* Check if this was a variable */
  if (*start == '$')
  {
    const char *end= to;
    VAR *var=var_get(start, &end, 0, 1);
    if (var && to == (char*) end+1)
    {
      DBUG_PRINT("info",("var: %s -> %s", start, var->str_val));
      DBUG_RETURN(var->str_val);	/* return found variable value */
    }
  }
  DBUG_RETURN(start);
}


@@ -1109,6 +1129,8 @@ static void get_string(char **to_ptr, char **from_ptr,
  Get arguments for replace. The syntax is:
  replace from to [from to ...]
  Where each argument may be quoted with ' or "
  A argument may also be a variable, in which case the value of the
  variable is replaced.
*/

static void get_replace(struct st_query *q)
@@ -1120,6 +1142,9 @@ static void get_replace(struct st_query *q)
  POINTER_ARRAY to_array,from_array;
  DBUG_ENTER("get_replace");

  if (glob_replace)
    free_replace();

  bzero((char*) &to_array,sizeof(to_array));
  bzero((char*) &from_array,sizeof(from_array));
  if (!*from)
@@ -1128,12 +1153,11 @@ static void get_replace(struct st_query *q)
  while (*from)
  {
    char *to=buff;
    get_string(&buff, &from, q);
    to=get_string(&buff, &from, q);
    if (!*from)
      die("Wrong number of arguments to replace in %s\n", q->query);
    insert_pointer_name(&from_array,to);
    to=buff;
    get_string(&buff, &from, q);
    to=get_string(&buff, &from, q);
    insert_pointer_name(&to_array,to);
  }
  for (i=1,pos=word_end_chars ; i < 256 ; i++)
@@ -1149,6 +1173,7 @@ static void get_replace(struct st_query *q)
  free_pointer_array(&from_array);
  free_pointer_array(&to_array);
  my_free(start, MYF(0));
  DBUG_VOID_RETURN;
}

void free_replace()
@@ -1310,7 +1335,7 @@ int do_connect(struct st_query* q)
    p = safe_get_param(p, &con_port_str, "missing connection port");
    if (*con_port_str == '$')
    {
      if (!(var_port = var_get(con_port_str, 0, 0)))
      if (!(var_port = var_get(con_port_str, 0, 0, 0)))
	die("Unknown variable '%s'", con_port_str+1);
      con_port = var_port->int_val;
    }
@@ -1319,7 +1344,7 @@ int do_connect(struct st_query* q)
    p = safe_get_param(p, &con_sock, "missing connection socket");
    if (*con_sock == '$')
    {
      if (!(var_sock = var_get(con_sock, 0, 0)))
      if (!(var_sock = var_get(con_sock, 0, 0, 0)))
	die("Unknown variable '%s'", con_sock+1);
      if (!(con_sock = (char*)my_malloc(var_sock->str_val_len+1, MYF(0))))
	die("Out of memory");
@@ -1993,7 +2018,7 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
	mysql_errno(mysql), errno);
  if ((flags & QUERY_SEND) && !disable_query_log)
  {
    dynstr_append_mem(ds,query,query_len);
    replace_dynstr_append_mem(ds,query, query_len);
    dynstr_append_mem(ds,";\n",2);
  }
  if (!(flags & QUERY_REAP))
@@ -2175,12 +2200,15 @@ static VAR* var_init(VAR* v, const char* name, int name_len, const char* val,
  tmp_var->name = (name) ? (char*) tmp_var + sizeof(*tmp_var) : 0;
  tmp_var->alloced = (v == 0); 

  if(!(tmp_var->str_val = my_malloc(val_alloc_len, MYF(MY_WME))))
  if (!(tmp_var->str_val = my_malloc(val_alloc_len+1, MYF(MY_WME))))
    die("Out of memory");

  memcpy(tmp_var->name, name, name_len);
  if (val)
    memcpy(tmp_var->str_val, val, val_len + 1);
  {
    memcpy(tmp_var->str_val, val, val_len);
    tmp_var->str_val[val_len]=0;
  }
  tmp_var->name_len = name_len;
  tmp_var->str_val_len = val_len;
  tmp_var->alloced_len = val_alloc_len;
+4 −4
Original line number Diff line number Diff line
@@ -819,8 +819,8 @@ case $SYSTEM_TYPE in
    ;;
  *hpux10.20*)
    echo "Enabling snprintf workaround for hpux 10.20"
    CFLAGS="$CFLAGS -DHAVE_BROKEN_SNPRINTF -DSIGNALS_DONT_BREAK_READ"
    CXXFLAGS="$CXXFLAGS -DHAVE_BROKEN_SNPRINTF -D_INCLUDE_LONGLONG -DSIGNALS_DONT_BREAK_READ"
    CFLAGS="$CFLAGS -DHAVE_BROKEN_SNPRINTF -DSIGNALS_DONT_BREAK_READ -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHPUX"
    CXXFLAGS="$CXXFLAGS -DHAVE_BROKEN_SNPRINTF -D_INCLUDE_LONGLONG -DSIGNALS_DONT_BREAK_READ -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHPUX"
    if test "$with_named_thread" = "no"
    then 
      echo "Using --with-named-thread=-lpthread"
@@ -829,8 +829,8 @@ case $SYSTEM_TYPE in
    ;;
  *hpux11.*)
    echo "Enabling pread/pwrite workaround for hpux 11"
    CFLAGS="$CFLAGS -DHAVE_BROKEN_PREAD -DDONT_USE_FINITE -DHAVE_BROKEN_GETPASS -DNO_FCNTL_NONBLOCK"
    CXXFLAGS="$CXXFLAGS -DHAVE_BROKEN_PREAD -DDONT_USE_FINITE -D_INCLUDE_LONGLONG -DNO_FCNTL_NONBLOCK"
    CFLAGS="$CFLAGS -DHAVE_BROKEN_PREAD -DDONT_USE_FINITE -DHAVE_BROKEN_GETPASS -DNO_FCNTL_NONBLOCK -DDO_NOT_REMOVE_THREAD_WRAPPERS"
    CXXFLAGS="$CXXFLAGS -DHAVE_BROKEN_PREAD -DDONT_USE_FINITE -D_INCLUDE_LONGLONG -DNO_FCNTL_NONBLOCK -DDO_NOT_REMOVE_THREAD_WRAPPERS"
    if test "$with_named_thread" = "no"
    then 
      echo "Using --with-named-thread=-lpthread"
Loading