Commit a3102373 authored by unknown's avatar unknown
Browse files

Merge mskold@bk-internal.mysql.com:/home/bk/mysql-5.1-new

into  mysql.com:/usr/local/home/marty/MySQL/mysql-5.1-new

parents 9f6f3ae0 14ff02d3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ mysqlbinlog_SOURCES = mysqlbinlog.cc $(top_srcdir)/mysys/mf_tempdir.c \
				$(top_srcdir)/mysys/my_vle.c \
				$(top_srcdir)/mysys/base64.c
mysqlbinlog_LDADD =		$(LDADD) $(CXXLDFLAGS)
mysqlslap_LDADD =		$(LDADD) $(CXXLDFLAGS) -lpthread
mysqltestmanager_pwgen_SOURCES =   mysqlmanager-pwgen.c 
mysqltestmanagerc_SOURCES=      mysqlmanagerc.c $(yassl_dummy_link_fix)
mysqlcheck_SOURCES=             mysqlcheck.c $(yassl_dummy_link_fix)
+1 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ enum options_client
  OPT_MYSQL_ONLY_PRINT,
  OPT_MYSQL_LOCK_DIRECTORY,
  OPT_MYSQL_SLAP_SLAVE,
  OPT_USE_THREADS,
  OPT_MYSQL_NUMBER_OF_QUERY,
  OPT_MYSQL_PRESERVE_SCHEMA,
  OPT_IGNORE_TABLE,OPT_INSERT_IGNORE,OPT_SHOW_WARNINGS,OPT_DROP_DATABASE,
+103 −44
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <ctype.h>
#include <my_pthread.h>

#define MYSLAPLOCK "/myslaplock.lck"
#define MYSLAPLOCK_DIR "/tmp"
@@ -132,6 +133,7 @@ static uint opt_protocol= 0;

static int get_options(int *argc,char ***argv);
static uint opt_mysql_port= 0;
static uint opt_use_threads;

static const char *load_default_groups[]= { "mysqlslap","client",0 };

@@ -151,6 +153,13 @@ struct stats {
  unsigned long long rows;
};

typedef struct thread_context thread_context;

struct thread_context {
  statement *stmt;
  ulonglong limit;
};

typedef struct conclusions conclusions;

struct conclusions {
@@ -184,7 +193,7 @@ static int create_schema(MYSQL *mysql, const char *db, statement *stmt,
              statement *engine_stmt);
static int run_scheduler(stats *sptr, statement *stmts, uint concur, 
                         ulonglong limit);
int run_task(statement *stmt, ulonglong limit);
int run_task(thread_context *con);
void statement_cleanup(statement *stmt);

static const char ALPHANUMERICS[]=
@@ -440,6 +449,10 @@ static struct my_option my_long_options[] =
  {"socket", 'S', "Socket file to use for connection.",
    (gptr*) &opt_mysql_unix_port, (gptr*) &opt_mysql_unix_port, 0, GET_STR,
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
  {"use-threads", OPT_USE_THREADS,
    "Use pthread calls instead of fork() calls (default on Windows)",
      (gptr*) &opt_use_threads, (gptr*) &opt_use_threads, 0, 
      GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
#include <sslopt-longopts.h>
#ifndef DONT_ALLOW_USER_CHANGE
  {"user", 'u', "User for login if not current user.", (gptr*) &user,
@@ -930,8 +943,11 @@ run_scheduler(stats *sptr, statement *stmts, uint concur, ulonglong limit)
  uint x;
  File lock_file;
  struct timeval start_time, end_time;
  thread_context con;
  DBUG_ENTER("run_scheduler");

  con.stmt= stmts;
  con.limit= limit;

  lock_file= my_open(lock_file_str, O_CREAT|O_WRONLY|O_TRUNC, MYF(0));

@@ -943,6 +959,30 @@ run_scheduler(stats *sptr, statement *stmts, uint concur, ulonglong limit)
      exit(0);
    }

  if (opt_use_threads)
  {
    pthread_t mainthread;            /* Thread descriptor */
    pthread_attr_t attr;          /* Thread attributes */

    for (x= 0; x < concur; x++)
    {
      pthread_attr_init(&attr);
      pthread_attr_setdetachstate(&attr,
                                   PTHREAD_CREATE_DETACHED);

      /* now create the thread */
      if (pthread_create(&mainthread, &attr, (void *)run_task, 
                         (void *)&con) != 0)
      {
        fprintf(stderr,"%s: Could not create thread\n",
                my_progname);
        exit(0);
      }
    }
  }
  else
  {
    fflush(NULL);
    for (x= 0; x < concur; x++)
    {
      int pid;
@@ -958,7 +998,7 @@ run_scheduler(stats *sptr, statement *stmts, uint concur, ulonglong limit)
          fprintf(stderr,
                  "%s: fork returned 0, calling task pid %d gid %d\n",
                  my_progname, pid, getgid());
      run_task(stmts, limit);
        run_task(&con);
        exit(0);
        break;
      case -1:
@@ -979,14 +1019,30 @@ run_scheduler(stats *sptr, statement *stmts, uint concur, ulonglong limit)
        break;
      }
    }
  }

  /* Lets release use some clients! */
  if (!opt_slave)
    my_lock(lock_file, F_UNLCK, 0, F_TO_EOF, MYF(0));

  gettimeofday(&start_time, NULL);

  my_close(lock_file, MYF(0));

  /*
    We look to grab a write lock at this point. Once we get it we know that
    all clients have completed their work.
  */
  if (opt_use_threads)
  {
    if (my_lock(lock_file, F_WRLCK, 0, F_TO_EOF, MYF(0)))
    {
      fprintf(stderr,"%s: Could not get lockfile\n",
              my_progname);
      exit(0);
    }
    my_lock(lock_file, F_UNLCK, 0, F_TO_EOF, MYF(0));
  }
  else
  {
WAIT:
    while (x--)
    {
@@ -994,8 +1050,11 @@ run_scheduler(stats *sptr, statement *stmts, uint concur, ulonglong limit)
      pid= wait(&status);
      DBUG_PRINT("info", ("Parent: child %d status %d", pid, status));
    }
  }
  gettimeofday(&end_time, NULL);

  my_close(lock_file, MYF(0));

  sptr->timing= timedif(end_time, start_time);
  sptr->users= concur;
  sptr->rows= limit;
@@ -1004,7 +1063,7 @@ run_scheduler(stats *sptr, statement *stmts, uint concur, ulonglong limit)
}

int
run_task(statement *qstmt, ulonglong limit)
run_task(thread_context *con)
{
  ulonglong counter= 0, queries;
  File lock_file;
@@ -1014,7 +1073,7 @@ run_task(statement *qstmt, ulonglong limit)
  statement *ptr;

  DBUG_ENTER("run_task");
  DBUG_PRINT("info", ("task script \"%s\"", qstmt->string));
  DBUG_PRINT("info", ("task script \"%s\"", con->stmt->string));

  mysql_init(&mysql);

@@ -1036,7 +1095,7 @@ run_task(statement *qstmt, ulonglong limit)
  queries= 0; 

limit_not_met:
    for (ptr= qstmt; ptr && ptr->length; ptr= ptr->next)
    for (ptr= con->stmt; ptr && ptr->length; ptr= ptr->next)
    {
      if (opt_only_print) 
      {
@@ -1060,11 +1119,11 @@ run_task(statement *qstmt, ulonglong limit)
      }
      queries++;

      if (limit && queries == limit)
      if (con->limit && queries == con->limit)
        DBUG_RETURN(0);
    }

  if (limit && queries < limit)
  if (con->limit && queries < con->limit)
    goto limit_not_met;

  my_lock(lock_file, F_UNLCK, 0, F_TO_EOF, MYF(0));
+7 −1
Original line number Diff line number Diff line
@@ -206,6 +206,11 @@ enum ha_base_keytype {
#define HA_NULL_ARE_EQUAL	2048	/* NULL in key are cmp as equal */
#define HA_GENERATED_KEY	8192	/* Automaticly generated key */

        /* The combination of the above can be used for key type comparison. */
#define HA_KEYFLAG_MASK (HA_NOSAME | HA_PACK_KEY | HA_AUTO_KEY | \
                         HA_BINARY_PACK_KEY | HA_FULLTEXT | HA_UNIQUE_CHECK | \
                         HA_SPATIAL | HA_NULL_ARE_EQUAL | HA_GENERATED_KEY)

	/* Automatic bits in key-flag */

#define HA_SPACE_PACK_USED	 4	/* Test for if SPACE_PACK used */
@@ -349,8 +354,9 @@ enum ha_base_keytype {
#define HA_ERR_NO_PARTITION_FOUND 160  /* There's no partition in table for
                                          given value */
#define HA_ERR_RBR_LOGGING_FAILED 161  /* Row-based binlogging of row failed */
#define HA_ERR_DROP_INDEX_FK      162  /* Index needed in foreign key constr. */

#define HA_ERR_LAST               161  /* Copy last error no */
#define HA_ERR_LAST               162  /* Copy last error no */

/* Add error numbers before HA_ERR_LAST and change it accordingly. */
#define HA_ERR_ERRORS            (HA_ERR_LAST - HA_ERR_FIRST + 1)
+68 −0
Original line number Diff line number Diff line
@@ -396,3 +396,71 @@ a int(11) NO PRI
b	varchar(20)	NO	MUL		
c	varchar(20)	NO			
drop table t1;
create table t1 (
c1 int,
c2 char(12),
c3 varchar(123),
c4 timestamp,
index (c1),
index i1 (c1),
index i2 (c2),
index i3 (c3),
unique i4 (c4),
index i5 (c1, c2, c3, c4),
primary key (c2, c3),
index (c2, c4));
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `c1` int(11) default NULL,
  `c2` char(12) NOT NULL default '',
  `c3` varchar(123) NOT NULL default '',
  `c4` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  PRIMARY KEY  (`c2`,`c3`),
  UNIQUE KEY `i4` (`c4`),
  KEY `c1` (`c1`),
  KEY `i1` (`c1`),
  KEY `i2` (`c2`),
  KEY `i3` (`c3`),
  KEY `i5` (`c1`,`c2`,`c3`,`c4`),
  KEY `c2` (`c2`,`c4`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
alter table t1 drop index c1;
alter table t1 add index (c1);
alter table t1 add index (c1);
alter table t1 drop index i3;
alter table t1 add index i3 (c3);
alter table t1 drop index i2, drop index i4;
alter table t1 add index i2 (c2), add index i4 (c4);
alter table t1 drop index i2, drop index i4, add index i6 (c2, c4);
alter table t1 add index i2 (c2), add index i4 (c4), drop index i6;
alter table t1 drop index i2, drop index i4, add unique i4 (c4);
alter table t1 add index i2 (c2), drop index i4, add index i4 (c4);
alter table t1 drop index c2, add index (c2(4),c3(7));
alter table t1 drop index c2, add index (c2(4),c3(7));
alter table t1 add primary key (c1, c2), drop primary key;
alter table t1 drop primary key;
alter table t1 add primary key (c1, c2), drop primary key;
ERROR 42000: Can't DROP 'PRIMARY'; check that column/key exists
show create table t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `c1` int(11) NOT NULL default '0',
  `c2` char(12) NOT NULL default '',
  `c3` varchar(123) NOT NULL default '',
  `c4` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  KEY `i1` (`c1`),
  KEY `i5` (`c1`,`c2`,`c3`,`c4`),
  KEY `c1` (`c1`),
  KEY `c1_2` (`c1`),
  KEY `i3` (`c3`),
  KEY `i2` (`c2`),
  KEY `i4` (`c4`),
  KEY `c2` (`c2`(4),`c3`(7))
) ENGINE=MyISAM DEFAULT CHARSET=latin1
insert into t1 values(1, 'a', 'a', NULL);
insert into t1 values(1, 'b', 'b', NULL);
alter table t1 drop index i3, drop index i2, drop index i1;
alter table t1 add index i3 (c3), add index i2 (c2), add unique index i1 (c1);
ERROR 23000: Duplicate entry '1' for key 1
drop table t1;
Loading