Commit e4daae90 authored by unknown's avatar unknown

Merge joreland@bk-internal.mysql.com:/home/bk/mysql-5.0

into mysql.com:/home/jonas/src/mysql-5.0


sql/sql_parse.cc:
  Auto merged
parents 736f9b4b c398f5cc
......@@ -32,7 +32,8 @@ testTransactions \
testDeadlock \
test_event ndbapi_slow_select testReadPerf testLcp \
testPartitioning \
testBitfield
testBitfield \
DbCreate DbAsyncGenerator
#flexTimedAsynch
#testBlobs
......@@ -73,6 +74,8 @@ testReadPerf_SOURCES = testReadPerf.cpp
testLcp_SOURCES = testLcp.cpp
testPartitioning_SOURCES = testPartitioning.cpp
testBitfield_SOURCES = testBitfield.cpp
DbCreate_SOURCES= bench/mainPopulate.cpp bench/dbPopulate.cpp bench/userInterface.cpp
DbAsyncGenerator_SOURCES= bench/mainAsyncGenerator.cpp bench/asyncGenerator.cpp bench/ndb_async2.cpp
INCLUDES_LOC = -I$(top_srcdir)/ndb/include/kernel
......
This diff is collapsed.
/* Copyright (C) 2003 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef DBGENERATOR_H
#define DBGENERATOR_H
/***************************************************************
* I N C L U D E D F I L E S *
***************************************************************/
#include "testData.h"
#include "userInterface.h"
/***************************************************************
* M A C R O S *
***************************************************************/
/***************************************************************/
/* C O N S T A N T S */
/***************************************************************/
/***************************************************************
* D A T A S T R U C T U R E S *
***************************************************************/
/***************************************************************
* P U B L I C F U N C T I O N S *
***************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
extern void asyncGenerator(ThreadData *d, int parallellism,
int millisSendPoll,
int minEventSendPoll,
int forceSendPoll);
#ifdef __cplusplus
}
#endif
/***************************************************************
* E X T E R N A L D A T A *
***************************************************************/
#endif /* DBGENERATOR_H */
/* Copyright (C) 2003 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/***************************************************************
* I N C L U D E D F I L E S *
***************************************************************/
#include <ndb_global.h>
#include "userInterface.h"
#include "dbPopulate.h"
#include <NdbOut.hpp>
#include <random.h>
/***************************************************************
* L O C A L C O N S T A N T S *
***************************************************************/
/***************************************************************
* L O C A L D A T A S T R U C T U R E S *
***************************************************************/
/***************************************************************
* L O C A L F U N C T I O N S *
***************************************************************/
static void getRandomSubscriberData(int subscriberNo,
SubscriberNumber number,
SubscriberName name);
static void populate(char *title,
int count,
void (*func)(UserHandle*,int),
UserHandle *uh);
static void populateServers(UserHandle *uh, int count);
static void populateSubscribers(UserHandle *uh, int count);
static void populateGroups(UserHandle *uh, int count);
/***************************************************************
* L O C A L D A T A *
***************************************************************/
static SequenceValues permissionsDefinition[] = {
{90, 1},
{10, 0},
{0, 0}
};
/***************************************************************
* P U B L I C D A T A *
***************************************************************/
/***************************************************************
****************************************************************
* L O C A L F U N C T I O N S C O D E S E C T I O N *
****************************************************************
***************************************************************/
static void getRandomSubscriberData(int subscriberNo,
SubscriberNumber number,
SubscriberName name)
{
char sbuf[SUBSCRIBER_NUMBER_LENGTH + 1];
sprintf(sbuf, "%.*d", SUBSCRIBER_NUMBER_LENGTH, subscriberNo);
memcpy(number, sbuf, SUBSCRIBER_NUMBER_LENGTH);
memset(name, myRandom48(26)+'A', SUBSCRIBER_NAME_LENGTH);
}
static void populate(char *title,
int count,
void (*func)(UserHandle*, int),
UserHandle *uh)
{
ndbout_c("Populating %d '%s' ... ",count, title);
/* fflush(stdout); */
func(uh,count);
ndbout_c("done");
}
static void populateServers(UserHandle *uh, int count)
{
int i, j;
int len;
char tmp[80];
int suffix_length = 1;
ServerName serverName;
SubscriberSuffix suffix;
int commitCount = 0;
for(i = 0; i < SUBSCRIBER_NUMBER_SUFFIX_LENGTH; i++)
suffix_length *= 10;
for(i = 0; i < count; i++) {
sprintf(tmp, "-Server %d-", i);
len = strlen(tmp);
for(j = 0; j < SERVER_NAME_LENGTH; j++){
serverName[j] = tmp[j % len];
}
/* serverName[j] = 0; not null-terminated */
for(j = 0; j < suffix_length; j++){
char sbuf[SUBSCRIBER_NUMBER_SUFFIX_LENGTH + 1];
sprintf(sbuf, "%.*d", SUBSCRIBER_NUMBER_SUFFIX_LENGTH, j);
memcpy(suffix, sbuf, SUBSCRIBER_NUMBER_SUFFIX_LENGTH);
userDbInsertServer(uh, i, suffix, serverName);
commitCount ++;
if((commitCount % OP_PER_TRANS) == 0)
userDbCommit(uh);
}
}
if((commitCount % OP_PER_TRANS) != 0)
userDbCommit(uh);
}
static void populateSubscribers(UserHandle *uh, int count)
{
SubscriberNumber number;
SubscriberName name;
int i, j, k;
int res;
SequenceValues values[NO_OF_GROUPS+1];
RandomSequence seq;
for(i = 0; i < NO_OF_GROUPS; i++) {
values[i].length = 1;
values[i].value = i;
}
values[i].length = 0;
values[i].value = 0;
if( initSequence(&seq, values) != 0 ) {
ndbout_c("could not set the sequence of random groups");
exit(0);
}
#define RETRIES 25
for(i = 0; i < count; i+= OP_PER_TRANS) {
for(j = 0; j<RETRIES; j++){
for(k = 0; k<OP_PER_TRANS && i+k < count; k++){
getRandomSubscriberData(i+k, number, name);
userDbInsertSubscriber(uh, number, getNextRandom(&seq), name);
}
res = userDbCommit(uh);
if(res == 0)
break;
if(res != 1){
ndbout_c("Terminating");
exit(0);
}
}
if(j == RETRIES){
ndbout_c("Terminating");
exit(0);
}
}
}
static void populateGroups(UserHandle *uh, int count)
{
int i;
int j;
int len;
RandomSequence seq;
Permission allow[NO_OF_GROUPS];
ServerBit serverBit;
GroupName groupName;
char tmp[80];
int commitCount = 0;
if( initSequence(&seq, permissionsDefinition) != 0 ) {
ndbout_c("could not set the sequence of random permissions");
exit(0);
}
for(i = 0; i < NO_OF_GROUPS; i++)
allow[i] = 0;
for(i = 0; i < NO_OF_SERVERS; i++) {
serverBit = 1 << i;
for(j = 0; j < NO_OF_GROUPS; j++ ) {
if( getNextRandom(&seq) )
allow[j] |= serverBit;
}
}
for(i = 0; i < NO_OF_GROUPS; i++) {
sprintf(tmp, "-Group %d-", i);
len = strlen(tmp);
for(j = 0; j < GROUP_NAME_LENGTH; j++) {
groupName[j] = tmp[j % len];
}
/* groupName[j] = 0; not null-terminated */
userDbInsertGroup(uh,
i,
groupName,
allow[i],
allow[i],
allow[i]);
commitCount ++;
if((commitCount % OP_PER_TRANS) == 0)
userDbCommit(uh);
}
if((commitCount % OP_PER_TRANS) != 0)
userDbCommit(uh);
}
/***************************************************************
****************************************************************
* P U B L I C F U N C T I O N S C O D E S E C T I O N *
****************************************************************
***************************************************************/
void dbPopulate(UserHandle *uh)
{
populate("servers", NO_OF_SERVERS, populateServers, uh);
populate("subscribers", NO_OF_SUBSCRIBERS, populateSubscribers, uh);
populate("groups", NO_OF_GROUPS, populateGroups, uh);
}
/* Copyright (C) 2003 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef DBPOPULATE_H
#define DBPOPULATE_H
/***************************************************************
* I N C L U D E D F I L E S *
***************************************************************/
#include "userInterface.h"
/***************************************************************
* M A C R O S *
***************************************************************/
/***************************************************************/
/* C O N S T A N T S */
/***************************************************************/
/***************************************************************
* D A T A S T R U C T U R E S *
***************************************************************/
/***************************************************************
* P U B L I C F U N C T I O N S *
***************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
extern void dbPopulate(UserHandle *uh);
#ifdef __cplusplus
}
#endif
/***************************************************************
* E X T E R N A L D A T A *
***************************************************************/
#endif /* DBPOPULATE_H */
/* Copyright (C) 2003 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef MACROS_H
#define MACROS_H
#include <ndb_global.h>
#include <NdbOut.hpp>
#define ERROR(x) {ndbout_c((x));}
#define ERROR1(x,y) {ndbout_c((x), (y));}
#define ERROR2(x,y,z) {ndbout_c((x), (y), (z));}
#define ERROR3(x,y,z,u) {ndbout_c((x), (y), (z), (u));}
#define ERROR4(x,y,z,u,w) {ndbout_c((x), (y), (z), (u), (w));}
#define INIT_RANDOM(x) srand48((x))
#define UI_RANDOM(x) ((unsigned int)(lrand48()%(x)))
#define ASSERT(cond, message) \
{ if(!(cond)) { ERROR(message); exit(-1); }}
#ifdef DEBUG_ON
#define DEBUG(x) {ndbout_c((x));}
#define DEBUG1(x,y) {ndbout_c((x), (y));}
#define DEBUG2(x,y,z) {ndbout_c((x), (y), (z));}
#define DEBUG3(x,y,z,u) {ndbout_c((x), (y), (z), (u));}
#define DEBUG4(x,y,z,u,w) {ndbout_c((x), (y), (z), (u), (w));}
#define DEBUG5(x,y,z,u,w, v) {ndbout_c((x), (y), (z), (u), (w), (v));}
#else
#define DEBUG(x)
#define DEBUG1(x,y)
#define DEBUG2(x,y,z)
#define DEBUG3(x,y,z,u)
#define DEBUG4(x,y,z,u,w)
#define DEBUG5(x,y,z,u,w, v)
#endif
#endif
This diff is collapsed.
/* Copyright (C) 2003 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <ndb_global.h>
#include <ndb_opts.h>
#include "userInterface.h"
#include "dbPopulate.h"
#include <NdbMain.h>
#include <NdbOut.hpp>
#include <random.h>
#ifdef __cplusplus
extern "C" {
#endif
int useTableLogging;
int useIndexTables;
#ifdef __cplusplus
}
#endif
static void usage()
{
}
static
void usage(const char *prog)
{
ndbout_c(
"Usage: %s [-l]\n"
" -l Use logging and checkpointing on tables\n",
" -i Use index tables\n",
prog);
exit(1);
}
NDB_STD_OPTS_VARS;
NDB_COMMAND(DbCreate, "DbCreate", "DbCreate", "DbCreate", 16384)
{
int i;
UserHandle *uh;
useTableLogging = useIndexTables = 0;
NDB_INIT(argv[0]);
for(i = 1; i<argc; i++){
if(strcmp(argv[i], "-l") == 0){
useTableLogging = 1;
} else if(strcmp(argv[i], "-i") == 0){
useIndexTables = 1;
} else {
usage(argv[0]);
return 0;
}
}
ndbout_c("Using %s tables and %s key storage",
useTableLogging ? "logging" : "temporary",
useIndexTables ? "index" : "normal");
myRandom48Init(0x3e6f);
uh = userDbConnect(1, "TEST_DB");
dbPopulate(uh);
userDbDisconnect(uh);
return(0);
}
This diff is collapsed.
This diff is collapsed.
/* Copyright (C) 2003 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef NDB_ERROR_H
#define NDB_ERROR_H
#include <ndb_global.h>
#include <NdbOut.hpp>
#include "userInterface.h"
#include <NdbError.hpp>
#include <NdbApi.hpp>
#define error_handler(x,y, z) { \
ndbout << x << " " << y << endl; \
exit(-1); }
#define CHECK_MINUS_ONE(x, y, z) if(x == -1) \
error_handler(y,(z->getNdbError()), 0)
inline
void
CHECK_ALLOWED_ERROR(const char * str,
const ThreadData * td,
const struct NdbError & error){
char buf[100];
snprintf(buf, sizeof(buf), "subscriber = %.*s ",
SUBSCRIBER_NUMBER_LENGTH,
td->transactionData.number);
ndbout << str << " " << error << endl
<< buf;
showTime();
switch(error.classification) {
case NdbError::TimeoutExpired:
case NdbError::OverloadError:
case NdbError::TemporaryResourceError:
case NdbError::NodeRecoveryError:
break;
default:
if(error.status != NdbError::TemporaryError)
exit(-1);
}
}
inline
void
CHECK_NULL(void * null,
const char * str,
const ThreadData * td,
const struct NdbError & err){
if(null == 0){
CHECK_ALLOWED_ERROR(str, td, err);
exit(-1);
}
}
inline
void
CHECK_NULL(void * null, const char* msg, NdbConnection* obj)
{
if(null == 0)
{
error_handler(msg, obj->getNdbError(), 0);
}
}
#endif
/* Copyright (C) 2003 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef NDB_SCHEMA_H
#define NDB_SCHEMA_H
#include "testDefinitions.h"
#define SUBSCRIBER_TABLE "SUBSCRIBER"
#define SUBSCRIBER_NUMBER "NUMBER"
#define SUBSCRIBER_LOCATION "LOCATION"
#define SUBSCRIBER_NAME "NAME"
#define SUBSCRIBER_GROUP "GROUP_ID"
#define SUBSCRIBER_SESSIONS "SESSIONS"
#define SUBSCRIBER_CHANGED_BY "CHANGED_BY"
#define SUBSCRIBER_CHANGED_TIME "CHANGED_TIME"
#define SERVER_TABLE "SERVER"
#define SERVER_ID "SERVER_ID"
#define SERVER_SUBSCRIBER_SUFFIX "SUFFIX"
#define SERVER_NAME "NAME"
#define SERVER_READS "NO_OF_READ"
#define SERVER_INSERTS "NO_OF_INSERT"
#define SERVER_DELETES "NO_OF_DELETE"
#define GROUP_TABLE "GROUP"
#define GROUP_ID "GROUP_ID"
#define GROUP_NAME "GROUP_NAME"
#define GROUP_ALLOW_READ "ALLOW_READ"
#define GROUP_ALLOW_INSERT "ALLOW_INSERT"
#define GROUP_ALLOW_DELETE "ALLOW_DELETE"
#define SESSION_TABLE "SESSION"
#define SESSION_SERVER "SERVER_ID"
#define SESSION_SUBSCRIBER "NUMBER"
#define SESSION_DATA "DATA"
/** Numbers */
#define IND_SUBSCRIBER_NUMBER (unsigned)0
#define IND_SUBSCRIBER_NAME (unsigned)1
#define IND_SUBSCRIBER_GROUP (unsigned)2
#define IND_SUBSCRIBER_LOCATION (unsigned)3
#define IND_SUBSCRIBER_SESSIONS (unsigned)4
#define IND_SUBSCRIBER_CHANGED_BY (unsigned)5
#define IND_SUBSCRIBER_CHANGED_TIME (unsigned)6
#define IND_SERVER_SUBSCRIBER_SUFFIX (unsigned)0
#define IND_SERVER_ID (unsigned)1
#define IND_SERVER_NAME (unsigned)2
#define IND_SERVER_READS (unsigned)3
#define IND_SERVER_INSERTS (unsigned)4
#define IND_SERVER_DELETES (unsigned)5
#define IND_GROUP_ID (unsigned)0
#define IND_GROUP_NAME (unsigned)1
#define IND_GROUP_ALLOW_READ (unsigned)2
#define IND_GROUP_ALLOW_INSERT (unsigned)3
#define IND_GROUP_ALLOW_DELETE (unsigned)4
#define IND_SESSION_SUBSCRIBER (unsigned)0
#define IND_SESSION_SERVER (unsigned)1
#define IND_SESSION_DATA (unsigned)2
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* Copyright (C) 2003 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifndef TESTDATA_H
#define TESTDATA_H
/***************************************************************
* I N C L U D E D F I L E S *
***************************************************************/
#include <NdbTick.h>
#include <NdbThread.h>
#include <NDBT_Stats.hpp>
#include <random.h>
#include "testDefinitions.h"
/***************************************************************
* M A C R O S *
***************************************************************/
/***************************************************************/
/* C O N S T A N T S */
/***************************************************************/
#define NUM_TRANSACTION_TYPES 5
#define SESSION_LIST_LENGTH 1000
/***************************************************************
* D A T A S T R U C T U R E S *
***************************************************************/
typedef struct {
SubscriberNumber subscriberNumber;
ServerId serverId;
} SessionElement;
typedef struct {
SessionElement list[SESSION_LIST_LENGTH];
unsigned int readIndex;
unsigned int writeIndex;
unsigned int numberInList;
} SessionList;
typedef struct {
unsigned int count;
unsigned int branchExecuted;
unsigned int rollbackExecuted;
/**
* Latency measures
*/
NDB_TICKS startTime;
NDBT_Stats latency;
unsigned int latencyCounter;
inline void startLatency(){
if((latencyCounter & 127) == 127)
startTime = NdbTick_CurrentMillisecond();
}
inline void stopLatency(){
if((latencyCounter & 127) == 127){
const NDB_TICKS tmp = NdbTick_CurrentMillisecond() - startTime;
latency.addObservation(tmp);
}
latencyCounter++;
}
} TransactionDefinition;
typedef struct {
RandomSequence transactionSequence;
RandomSequence rollbackSequenceT4;
RandomSequence rollbackSequenceT5;
TransactionDefinition transactions[NUM_TRANSACTION_TYPES];
unsigned int totalTransactions;
double outerLoopTime;
double outerTps;
SessionList activeSessions;
} GeneratorStatistics;
typedef enum{
Runnable,
Running
} RunState ;
typedef struct {
SubscriberNumber number;
SubscriberSuffix suffix;
SubscriberName name;
Location location;
ChangedBy changed_by;
ChangedTime changed_time;
ServerId server_id;
ServerBit server_bit;
SessionDetails session_details;
GroupId group_id;
ActiveSessions sessions;
Permission permission;
unsigned int do_rollback;
unsigned int branchExecuted;
unsigned int sessionElement;
} TransactionData ;
typedef struct {
struct NdbThread* pThread;
unsigned long randomSeed;
unsigned long changedTime;
unsigned int warmUpSeconds;
unsigned int testSeconds;
unsigned int coolDownSeconds;
GeneratorStatistics generator;
/**
* For async execution
*/
RunState runState;
double startTime;
TransactionData transactionData;
struct Ndb * pNDB;
} ThreadData;
/***************************************************************
* P U B L I C F U N C T I O N S *
***************************************************************/
/***************************************************************
* E X T E R N A L D A T A *
***************************************************************/
#endif /* TESTDATA_H */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment