Commit d94aa81c authored by unknown's avatar unknown

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

into poseidon.ndb.mysql.com:/home/tomas/mysql-5.0


sql/item.h:
  Auto merged
sql/sql_select.cc:
  Auto merged
parents a7ed0bdf 9fb70d85
......@@ -344,6 +344,10 @@ SOURCE=..\mysys\my_alloc.c
# End Source File
# Begin Source File
SOURCE=..\mysys\my_decimal.cpp
# End Source File
# Begin Source File
SOURCE=..\mysys\my_getopt.c
# End Source File
# Begin Source File
......
......@@ -1085,6 +1085,10 @@ SOURCE=.\mf_iocache.cpp
# End Source File
# Begin Source File
SOURCE=.\my_decimal.cpp
# End Source File
# Begin Source File
SOURCE=.\my_time.c
# End Source File
# Begin Source File
......
......@@ -177,6 +177,10 @@ SOURCE=.\ctype.c
# End Source File
# Begin Source File
SOURCE=.\decimal.c
# End Source File
# Begin Source File
SOURCE=.\int2str.c
# End Source File
# Begin Source File
......
......@@ -310,9 +310,6 @@ inline double ulonglong2double(ulonglong value)
#define HAVE_SETFILEPOINTER
#define HAVE_VIO
#define HAME_MMAP /* in mysys/my_mmap.c */
#define HAVE_GETPAGESIZE /* in mysys/my_mmap.c */
#ifdef NOT_USED
#define HAVE_SNPRINTF /* Gave link error */
#define _snprintf snprintf
......@@ -353,6 +350,8 @@ inline double ulonglong2double(ulonglong value)
#define DO_NOT_REMOVE_THREAD_WRAPPERS
#define thread_safe_increment(V,L) InterlockedIncrement((long*) &(V))
#define thread_safe_decrement(V,L) InterlockedDecrement((long*) &(V))
#define thread_safe_dec_and_test(V, L) thread_safe_decrement(V,L)
/* The following is only used for statistics, so it should be good enough */
#ifdef __NT__ /* This should also work on Win98 but .. */
#define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C))
......@@ -366,6 +365,7 @@ inline double ulonglong2double(ulonglong value)
#define statistic_add(V,C,L) (V)+=(C)
#endif
#define statistic_increment(V,L) thread_safe_increment((V),(L))
#define statistic_decrement(V,L) thread_safe_decrement((V),(L))
#define shared_memory_buffer_length 16000
#define default_shared_memory_base_name "MYSQL"
......
......@@ -17,7 +17,9 @@
#ifndef _decimal_h
#define _decimal_h
typedef enum {TRUNCATE=0, HALF_EVEN, HALF_UP, CEILING, FLOOR} decimal_round_mode;
typedef enum
{TRUNCATE=0, HALF_EVEN, HALF_UP, CEILING, FLOOR}
decimal_round_mode;
typedef int32 decimal_digit;
typedef struct st_decimal {
......@@ -26,11 +28,10 @@ typedef struct st_decimal {
decimal_digit *buf;
} decimal;
int internal_str2dec(const char *from, decimal *to, char **end, my_bool fixed);
int decimal2string(decimal *from, char *to, int *to_len,
int fixed_precision, int fixed_decimals,
char filler);
int string2decimal(char *from, decimal *to, char **end);
int string2decimal_fixed(char *from, decimal *to, char **end);
int decimal2ulonglong(decimal *from, ulonglong *to);
int ulonglong2decimal(ulonglong from, decimal *to);
int decimal2longlong(decimal *from, longlong *to);
......@@ -51,10 +52,14 @@ int decimal_cmp(decimal *from1, decimal *from2);
int decimal_mul(decimal *from1, decimal *from2, decimal *to);
int decimal_div(decimal *from1, decimal *from2, decimal *to, int scale_incr);
int decimal_mod(decimal *from1, decimal *from2, decimal *to);
int decimal_round(decimal *from, decimal *to, int new_scale, decimal_round_mode mode);
int decimal_round(decimal *from, decimal *to, int new_scale,
decimal_round_mode mode);
int decimal_is_zero(decimal *from);
void max_decimal(int precision, int frac, decimal *to);
#define string2decimal(A,B,C) internal_str2dec((A), (B), (C), 0)
#define string2decimal_fixed(A,B,C) internal_str2dec((A), (B), (C), 1)
/* set a decimal to zero */
#define decimal_make_zero(dec) do { \
......
......@@ -796,7 +796,7 @@ void my_free_open_file_info(void);
ulonglong my_getsystime(void);
my_bool my_gethwaddr(uchar *to);
#ifdef HAVE_MMAP
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
#ifndef MAP_NOSYNC
......@@ -811,9 +811,11 @@ my_bool my_gethwaddr(uchar *to);
/* not a complete set of mmap() flags, but only those that nesessary */
#define PROT_READ 1
#define PROT_WRITE 2
#define MAP_NOSYNC 0x800
#define MAP_SHARED 0x0001
#define MAP_NOSYNC 0x0800
#define MAP_FAILED ((void *)-1)
#define MS_SYNC 0x0000
#define HAVE_MMAP
int my_getpagesize(void);
void *my_mmap(void *, size_t, int, int, int, my_off_t);
......
......@@ -102,3 +102,10 @@ select * from t1 procedure analyse();
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
test.t1.v " \\ 1 19 0 0 3.7619 NULL ENUM('"','""','"c','\'\0\\"','\'','\'\'','\'b','a\0\0\0b','a\0','a""""b','a\'\'\'\'b','abc','abc\'def\\hij"klm\0opq','a\\\\\\\\b','b\'','c"','d\\','The\ZEnd','\\','\\d','\\\\') NOT NULL
drop table t1;
create table t1 (df decimal(5,1));
insert into t1 values(1.1);
insert into t1 values(2.2);
select * from t1 procedure analyse();
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
test.t1.df 1.1 2.2 8 8 0 0 1.650000000 0.302500000 ENUM('1.1','2.2') NOT NULL
drop table t1;
......@@ -187,3 +187,19 @@ timediff(cast('2004-12-30 12:00:00' as time), '12:00:00')
select timediff(cast('1 12:00:00' as time), '12:00:00');
timediff(cast('1 12:00:00' as time), '12:00:00')
24:00:00
select cast('1.2' as decimal(3,2));
cast('1.2' as decimal(3,2))
1.20
select 1e18 * cast('1.2' as decimal(3,2));
1e18 * cast('1.2' as decimal(3,2))
1.2e+18
select cast(cast('1.2' as decimal(3,2)) as signed);
cast(cast('1.2' as decimal(3,2)) as signed)
1
set @v1=1e18;
select cast(@v1 as decimal(22, 2));
cast(@v1 as decimal(22, 2))
1000000000000000000.00
select cast(-1e18 as decimal(22,2));
cast(-1e18 as decimal(22,2))
-1000000000000000000.00
......@@ -90,6 +90,26 @@ id avg(rating)
1 3.0000
2 NULL
3 2.0000
select sql_small_result t2.id, avg(rating) from t2 group by t2.id;
id avg(rating)
1 3.0000
2 NULL
3 2.0000
select sql_big_result t2.id, avg(rating) from t2 group by t2.id;
id avg(rating)
1 3.0000
2 NULL
3 2.0000
select sql_small_result t2.id, avg(rating+0.0e0) from t2 group by t2.id;
id avg(rating+0.0e0)
1 3
2 NULL
3 2
select sql_big_result t2.id, avg(rating+0.0e0) from t2 group by t2.id;
id avg(rating+0.0e0)
1 3
2 NULL
3 2
drop table t1,t2;
create table t1 (a smallint(6) primary key, c char(10), b text);
INSERT INTO t1 VALUES (1,'1','1');
......@@ -749,3 +769,38 @@ show columns from t2;
Field Type Null Key Default Extra
f2 datetime NO 0000-00-00 00:00:00
drop table t2, t1;
create table t2 (ff double);
insert into t2 values (2.2);
select cast(sum(distinct ff) as decimal(5,2)) from t2;
cast(sum(distinct ff) as decimal(5,2))
2.20
select cast(sum(distinct ff) as signed) from t2;
cast(sum(distinct ff) as signed)
2
select cast(variance(ff) as decimal(10,3)) from t2;
cast(variance(ff) as decimal(10,3))
0.000
select cast(min(ff) as decimal(5,2)) from t2;
cast(min(ff) as decimal(5,2))
2.20
create table t1 (df decimal(5,1));
insert into t1 values(1.1);
insert into t1 values(2.2);
select cast(sum(distinct df) as signed) from t1;
cast(sum(distinct df) as signed)
3
select cast(min(df) as signed) from t1;
cast(min(df) as signed)
0
select 1e8 * sum(distinct df) from t1;
1e8 * sum(distinct df)
330000000
select 1e8 * min(df) from t1;
1e8 * min(df)
110000000
create table t3 (ifl int);
insert into t3 values(1), (2);
select cast(min(ifl) as decimal(5,2)) from t3;
cast(min(ifl) as decimal(5,2))
1.00
drop table t1, t2, t3;
......@@ -30,6 +30,12 @@ Y-N-N-Y-N Y,N,N,Y,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,
select elt(2,1),field(NULL,"a","b","c");
elt(2,1) field(NULL,"a","b","c")
NULL 0
select field("b","a",NULL),field(1,0,NULL)+0,field(1.0,0.0,NULL)+0.0,field(1.0e1,0.0e1,NULL)+0.0e1;
field("b","a",NULL) field(1,0,NULL)+0 field(1.0,0.0,NULL)+0.0 field(1.0e1,0.0e1,NULL)+0.0e1
0 0 0.0 0
select field(NULL,"a",NULL),field(NULL,0,NULL)+0,field(NULL,0.0,NULL)+0.0,field(NULL,0.0e1,NULL)+0.0e1;
field(NULL,"a",NULL) field(NULL,0,NULL)+0 field(NULL,0.0,NULL)+0.0 field(NULL,0.0e1,NULL)+0.0e1
0 0 0.0 0
select find_in_set("","a,b,c"),find_in_set("","a,b,c,"),find_in_set("",",a,b,c");
find_in_set("","a,b,c") find_in_set("","a,b,c,") find_in_set("",",a,b,c")
0 4 1
......
......@@ -1798,3 +1798,5 @@ Variable_name Value
innodb_thread_sleep_delay 10000
create table t1 (v varchar(16384)) engine=innodb;
ERROR 42000: Column length too big for column 'v' (max = 255); use BLOB instead
create table t1 (a bit, key(a)) engine=innodb;
ERROR 42000: The storage engine for the table doesn't support BIT FIELD
......@@ -111,10 +111,14 @@ insert into t1 values ("Alas");
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
ROLLBACK;
use test;
SET TIMESTAMP=1065204671;
SET TIMESTAMP=1108844556;
BEGIN;
SET TIMESTAMP=1108844555;
insert t1 values (1);
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
use test;
SET TIMESTAMP=1065204671;
SET TIMESTAMP=1108844556;
BEGIN;
SET TIMESTAMP=1108844555;
insert t1 values (1);
drop table t1, t2;
......@@ -72,3 +72,11 @@ show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
drop table t1, t2;
set GLOBAL query_cache_size=0;
set GLOBAL ndb_cache_check_time=0;
reset query cache;
flush status;
set GLOBAL query_cache_size=0;
set GLOBAL ndb_cache_check_time=0;
reset query cache;
flush status;
......@@ -6,8 +6,12 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
stop slave;
flush logs;
create table t1 (a int) engine=bdb;
reset slave;
start slave;
show slave status;
Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master
# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 4 # # master-bin.000001 Yes No 0 Rolling back unfinished transaction (no COMMIT or ROLLBACK) from relay log. A probable cause is that the master died while writing the transaction to its binary log. 0 79 # None 0 No #
# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 4 # # master-bin.000002 Yes Yes 0 Rolling back unfinished transaction (no COMMIT or ROLLBACK) from relay log. A probable cause is that the master died while writing the transaction to its binary log. 0 4 # None 0 No #
select * from t1;
a
drop table t1;
......@@ -2276,3 +2276,39 @@ pass userid parentid parentgroup childid groupname grouptypeid crse categoryid c
1 5141 12 group2 12 group2 5 1 2 88 Oct04
1 5141 12 group2 12 group2 5 1 2 89 Oct04
drop table if exists t1, t2, t3, t4, t5;
create table t1 (df decimal(5,1));
insert into t1 values(1.1);
insert into t1 values(2.2);
select * from t1 where df <= all (select avg(df) from t1 group by df);
df
1.1
select * from t1 where df >= all (select avg(df) from t1 group by df);
df
2.2
drop table t1;
create table t1 (df decimal(5,1));
insert into t1 values(1.1);
select 1.1 * exists(select * from t1);
1.1 * exists(select * from t1)
1.1
drop table t1;
CREATE TABLE t1 (
grp int(11) default NULL,
a decimal(10,2) default NULL);
insert into t1 values (1, 1), (2, 2), (2, 3), (3, 4), (3, 5), (3, 6), (NULL, NULL);
select * from t1;
grp a
1 1.00
2 2.00
2 3.00
3 4.00
3 5.00
3 6.00
NULL NULL
select min(a) from t1 group by grp;
min(a)
NULL
1.00
2.00
4.00
drop table t1;
......@@ -44,8 +44,6 @@ t1 CREATE TABLE `t1` (
`a` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 (a bit, key(a)) engine=innodb;
ERROR 42000: The storage engine for the table doesn't support BIT FIELD
create table t1 (a bit(64));
insert into t1 values
(b'1111111111111111111111111111111111111111111111111111111111111111'),
......
......@@ -169,8 +169,19 @@ Warnings:
Warning 1264 Out of range value adjusted for column 'a' at row 1
Note 1265 Data truncated for column 'a' at row 2
Warning 1264 Out of range value adjusted for column 'a' at row 3
insert into t1 values ("1e+4294967296"),("1e-4294967296");
Warnings:
Warning 1264 Out of range value adjusted for column 'a' at row 1
Note 1265 Data truncated for column 'a' at row 2
insert into t1 values ("1e+18446744073709551615"),("1e+18446744073709551616"),("1e-9223372036854775807"),("1e-9223372036854775809");
Warnings:
Warning 1264 Out of range value adjusted for column 'a' at row 1
Warning 1366 Incorrect decimal value: '1e+18446744073709551616' for column 'a' at row 2
Note 1265 Data truncated for column 'a' at row 3
Warning 1366 Incorrect decimal value: '1e-9223372036854775809' for column 'a' at row 4
insert into t1 values ("123.4e"),("123.4e+2"),("123.4e-2"),("123e1"),("123e+0");
Warnings:
Note 1265 Data truncated for column 'a' at row 1
Note 1265 Data truncated for column 'a' at row 3
select * from t1;
a
......@@ -195,6 +206,12 @@ a
99999999.99
0.00
-99999999.99
99999999.99
0.00
99999999.99
0.00
0.00
0.00
123.40
12340.00
1.23
......@@ -229,6 +246,7 @@ Note 1265 Data truncated for column 'a' at row 2
Warning 1264 Out of range value adjusted for column 'a' at row 3
insert into t1 values ("123.4e"),("123.4e+2"),("123.4e-2"),("123e1"),("123e+0");
Warnings:
Note 1265 Data truncated for column 'a' at row 1
Note 1265 Data truncated for column 'a' at row 3
select * from t1;
a
......@@ -287,6 +305,7 @@ Note 1265 Data truncated for column 'a' at row 2
Warning 1264 Out of range value adjusted for column 'a' at row 3
insert into t1 values ("123.4e"),("123.4e+2"),("123.4e-2"),("123e1"),("123e+0");
Warnings:
Note 1265 Data truncated for column 'a' at row 1
Note 1265 Data truncated for column 'a' at row 3
select * from t1;
a
......@@ -338,6 +357,7 @@ Warning 1264 Out of range value adjusted for column 'a' at row 3
insert into t1 values (123.4e0),(123.4e+2),(123.4e-2),(123e1),(123e+0);
Warnings:
Note 1265 Data truncated for column 'a' at row 3
insert into t1 values (MID("987",1,2)),("987 "),("987.6e+2 ");
select * from t1;
a
0.00
......@@ -366,6 +386,9 @@ a
1.23
1230.00
123.00
98.00
987.00
98760.00
drop table t1;
create table t1 (a decimal);
insert into t1 values (-99999999999999),(-1),('+1'),('01'),('+00000000000001'),('+12345678901'),(99999999999999);
......
......@@ -696,7 +696,7 @@ end while; select v1, v2, v3 * 0.000000000001, v4 * 0.000000000001; end;//
call p1()//
#
v1 v2 v3 * 0.000000000001 v4 * 0.000000000001
1.000000100000 1.999999900000 1.000000100000000000 1.999999900000000000
1.000000100000 1.999999900000 1.000000100000 1.999999900000
drop procedure p1;
drop table if exists t1;
Warnings:
......
......@@ -47,3 +47,11 @@ create table t1 (v varchar(128));
insert into t1 values ('abc'),('abc\'def\\hij\"klm\0opq'),('\''),('\"'),('\\'),('a\0'),('b\''),('c\"'),('d\\'),('\'b'),('\"c'),('\\d'),('a\0\0\0b'),('a\'\'\'\'b'),('a\"\"\"\"b'),('a\\\\\\\\b'),('\'\0\\\"'),('\'\''),('\"\"'),('\\\\'),('The\ZEnd');
select * from t1 procedure analyse();
drop table t1;
#decimal-related test
create table t1 (df decimal(5,1));
insert into t1 values(1.1);
insert into t1 values(2.2);
select * from t1 procedure analyse();
drop table t1;
......@@ -118,3 +118,11 @@ select date_add(cast('2004-12-30 12:00:00' as date), interval 0 hour);
select timediff(cast('2004-12-30 12:00:00' as time), '12:00:00');
# Still we should not throw away "days" part of time value
select timediff(cast('1 12:00:00' as time), '12:00:00');
#decimal-related additions
select cast('1.2' as decimal(3,2));
select 1e18 * cast('1.2' as decimal(3,2));
select cast(cast('1.2' as decimal(3,2)) as signed);
set @v1=1e18;
select cast(@v1 as decimal(22, 2));
select cast(-1e18 as decimal(22,2));
......@@ -58,6 +58,11 @@ create table t2 (id int not null,rating int null);
insert into t1 values(1),(2),(3);
insert into t2 values(1, 3),(2, NULL),(2, NULL),(3, 2),(3, NULL);
select t1.id, avg(rating) from t1 left join t2 on ( t1.id = t2.id ) group by t1.id;
# Test different types with avg()
select sql_small_result t2.id, avg(rating) from t2 group by t2.id;
select sql_big_result t2.id, avg(rating) from t2 group by t2.id;
select sql_small_result t2.id, avg(rating+0.0e0) from t2 group by t2.id;
select sql_big_result t2.id, avg(rating+0.0e0) from t2 group by t2.id;
drop table t1,t2;
#
......@@ -487,3 +492,25 @@ drop table t2;
create table t2 select f2 from (select now() f2 from t1) a;
show columns from t2;
drop table t2, t1;
# decimal-related tests
create table t2 (ff double);
insert into t2 values (2.2);
select cast(sum(distinct ff) as decimal(5,2)) from t2;
select cast(sum(distinct ff) as signed) from t2;
select cast(variance(ff) as decimal(10,3)) from t2;
select cast(min(ff) as decimal(5,2)) from t2;
create table t1 (df decimal(5,1));
insert into t1 values(1.1);
insert into t1 values(2.2);
select cast(sum(distinct df) as signed) from t1;
select cast(min(df) as signed) from t1;
select 1e8 * sum(distinct df) from t1;
select 1e8 * min(df) from t1;
create table t3 (ifl int);
insert into t3 values(1), (2);
select cast(min(ifl) as decimal(5,2)) from t3;
drop table t1, t2, t3;
......@@ -18,6 +18,8 @@ select export_set(9,"Y","N","-",5),export_set(9,"Y","N"),export_set(9,"Y","N",""
# Wrong usage of functions
#
select elt(2,1),field(NULL,"a","b","c");
select field("b","a",NULL),field(1,0,NULL)+0,field(1.0,0.0,NULL)+0.0,field(1.0e1,0.0e1,NULL)+0.0e1;
select field(NULL,"a",NULL),field(NULL,0,NULL)+0,field(NULL,0.0,NULL)+0.0,field(NULL,0.0e1,NULL)+0.0e1;
select find_in_set("","a,b,c"),find_in_set("","a,b,c,"),find_in_set("",",a,b,c");
select find_in_set("abc","abc"),find_in_set("ab","abc"),find_in_set("abcd","abc");
select interval(null, 1, 10, 100);
......
......@@ -1278,3 +1278,7 @@ show variables like "innodb_thread_sleep_delay";
# InnoDB specific varchar tests
--error 1074
create table t1 (v varchar(16384)) engine=innodb;
# The following should be moved to type_bit.test when innodb will support it
--error 1178
create table t1 (a bit, key(a)) engine=innodb;
......@@ -68,4 +68,14 @@ show status like "Qcache_hits";
drop table t1, t2;
# Turn off and reset query cache on server1 and server2
connection server1;
set GLOBAL query_cache_size=0;
set GLOBAL ndb_cache_check_time=0;
reset query cache;
flush status;
connection server2;
set GLOBAL query_cache_size=0;
set GLOBAL ndb_cache_check_time=0;
reset query cache;
flush status;
# We are testing if a binlog which contains BEGIN but not COMMIT (the
# master did while writing the transaction to the binlog) triggers an
# error on slave. So we use such a truncated binlog and simulate that
# master died while writing the transaction to the binlog) triggers a
# rollback on slave. So we use such a truncated binlog and simulate that
# the master restarted after this.
source include/master-slave.inc;
connection slave;
# If we are not supporting transactions in the slave, the unfinished transaction
# won't cause any error, so we need to skip the test. In the 4.0 testsuite, the
# slave always runs without InnoDB, so we check for BDB.
# If we are not supporting transactions in the slave, the unfinished
# transaction won't cause any error, so we need to skip the test. In the 4.0
# testsuite, the slave always runs without InnoDB, so we check for BDB.
source include/have_bdb.inc;
stop slave;
connection master;
flush logs;
system mv -f var/log/master-bin.000001 var/log/master-bin.000002;
system cp std_data/trunc_binlog.000001 var/log/master-bin.000001;
connection slave;
# truncated binlog contains: BEGIN; INSERT t1 VALUES (1);
# so let's create the table t1 on slave
create table t1 (a int) engine=bdb;
reset slave;
start slave;
# can't sync_with_master so we must sleep
......@@ -23,3 +30,6 @@ sleep 3;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 8 # 9 # 23 # 33 #
show slave status;
select * from t1;
drop table t1;
......@@ -1543,3 +1543,26 @@ group by
drop table if exists t1, t2, t3, t4, t5;
#decimal-related tests
create table t1 (df decimal(5,1));
insert into t1 values(1.1);
insert into t1 values(2.2);
select * from t1 where df <= all (select avg(df) from t1 group by df);
select * from t1 where df >= all (select avg(df) from t1 group by df);
drop table t1;
create table t1 (df decimal(5,1));
insert into t1 values(1.1);
select 1.1 * exists(select * from t1);
drop table t1;
CREATE TABLE t1 (
grp int(11) default NULL,
a decimal(10,2) default NULL);
insert into t1 values (1, 1), (2, 2), (2, 3), (3, 4), (3, 5), (3, 6), (NULL, NULL);
select * from t1;
select min(a) from t1 group by grp;
drop table t1;
......@@ -26,9 +26,6 @@ create table t1 (a bit(0));
show create table t1;
drop table t1;
--error 1178
create table t1 (a bit, key(a)) engine=innodb;
create table t1 (a bit(64));
insert into t1 values
(b'1111111111111111111111111111111111111111111111111111111111111111'),
......
......@@ -165,6 +165,8 @@ insert into t1 values ("00000000000001"),("+0000000000001"),("-0000000000001");
insert into t1 values ("+111111111.11"),("111111111.11"),("-11111111.11");
insert into t1 values ("-111111111.11"),("+1111111111.11"),("1111111111.11");
insert into t1 values ("1e+1000"),("1e-1000"),("-1e+1000");
insert into t1 values ("1e+4294967296"),("1e-4294967296");
insert into t1 values ("1e+18446744073709551615"),("1e+18446744073709551616"),("1e-9223372036854775807"),("1e-9223372036854775809");
insert into t1 values ("123.4e"),("123.4e+2"),("123.4e-2"),("123e1"),("123e+0");
select * from t1;
drop table t1;
......@@ -201,6 +203,7 @@ insert into t1 values (+111111111.11),(111111111.11),(-11111111.11);
insert into t1 values (-111111111.11),(+1111111111.11),(1111111111.11);
insert into t1 values (1e+100),(1e-100),(-1e+100);
insert into t1 values (123.4e0),(123.4e+2),(123.4e-2),(123e1),(123e+0);
insert into t1 values (MID("987",1,2)),("987 "),("987.6e+2 ");
select * from t1;
drop table t1;
......
......@@ -16,7 +16,7 @@
#include "mysys_priv.h"
#ifdef HAVE_MMAP
#ifdef HAVE_SYS_MMAN_H
/*
system msync() only syncs mmap'ed area to fs cache.
......@@ -84,6 +84,6 @@ int my_msync(int fd, void *addr, size_t len, int flags)
}
#endif
#error "no mmap!"
#warning "no mmap!"
#endif
......@@ -633,17 +633,8 @@ NdbSqlUtil::cmpDate(const void* info, const void* p1, unsigned n1, const void* p
return 0;
}
#else
char t1[4], t2[4];
if (n1 == 3 && n2 == 3)
{
memcpy(t1, p1, 3);
memcpy(t2, p2, 3);
p1 = t1;
p2 = t2;
n1 = n2 = 4;
}
#ifdef ndb_date_sol9x86_cc_xO3_madness
if (n2 >= 4) { // may access 4-th byte
if (n2 >= 3) {
const uchar* v1 = (const uchar*)p1;
const uchar* v2 = (const uchar*)p2;
// from Field_newdate::val_int
......@@ -658,7 +649,7 @@ NdbSqlUtil::cmpDate(const void* info, const void* p1, unsigned n1, const void* p
return 0;
}
#else
if (n2 >= 4) {
if (n2 >= 3) {
const uchar* v1 = (const uchar*)p1;
const uchar* v2 = (const uchar*)p2;
uint j1 = uint3korr(v1);
......@@ -712,7 +703,7 @@ NdbSqlUtil::cmpText(const void* info, const void* p1, unsigned n1, const void* p
int
NdbSqlUtil::cmpTime(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2, bool full)
{
if (n2 >= 4) { // may access 4-th byte
if (n2 >= 3) {
const uchar* v1 = (const uchar*)p1;
const uchar* v2 = (const uchar*)p2;
// from Field_time::val_int
......
......@@ -2245,9 +2245,9 @@ void Dbdict::checkSchemaStatus(Signal* signal)
restartCreateTab(signal, tableId, oldEntry, false);
return;
}//if
ndbrequire(ok);
break;
}
ndbrequire(ok);
break;
}
case SchemaFile::DROP_TABLE_STARTED:
jam();
......
......@@ -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>
#include <NDBT.hpp>
#ifdef __cplusplus
extern "C" {
#endif
int useTableLogging;
#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",
prog);
exit(1);
}
NDB_STD_OPTS_VARS;
NDB_COMMAND(DbCreate, "DbCreate", "DbCreate", "DbCreate", 16384)
{
ndb_init();
int i;
UserHandle *uh;
useTableLogging = 0;
for(i = 1; i<argc; i++){
if(strcmp(argv[i], "-l") == 0){
useTableLogging = 1;
} else {
usage(argv[0]);
return 0;
}
}
ndbout_c("Using %s tables",
useTableLogging ? "logging" : "temporary");
myRandom48Init(0x3e6f);
uh = userDbConnect(1, "TEST_DB");
dbPopulate(uh);
userDbDisconnect(uh);
return NDBT_ProgramExit(NDBT_OK);
}
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 */
/* 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 TESTDEFINITIONS_H
#define TESTDEFINITIONS_H
/***************************************************************/
/* I N C L U D E D F I L E S */
/***************************************************************/
#include <ndb_types.h>
/***************************************************************/
/* C O N S T A N T S */
/***************************************************************/
#define OP_PER_TRANS 200
#define NO_OF_SUBSCRIBERS 500000
#define NO_OF_GROUPS 100
#define NO_OF_SERVERS 20
#define SUBSCRIBER_NUMBER_LENGTH 12
#define SUBSCRIBER_NUMBER_SUFFIX_LENGTH 2
#define SUBSCRIBER_NAME_LENGTH 32
#define CHANGED_BY_LENGTH 32
#define CHANGED_TIME_LENGTH 32
#define SESSION_DETAILS_LENGTH 2000
#define SERVER_NAME_LENGTH 32
#define GROUP_NAME_LENGTH 32
/***************************************************************
* D A T A S T R U C T U R E S *
***************************************************************/
#define PADDING 4
typedef char SubscriberNumber[SUBSCRIBER_NUMBER_LENGTH];
typedef char SubscriberSuffix[SUBSCRIBER_NUMBER_SUFFIX_LENGTH + 2];
typedef char SubscriberName[SUBSCRIBER_NAME_LENGTH];
typedef char ServerName[SERVER_NAME_LENGTH];
typedef char GroupName[GROUP_NAME_LENGTH];
typedef char ChangedBy[CHANGED_BY_LENGTH];
typedef char ChangedTime[CHANGED_TIME_LENGTH];
typedef char SessionDetails[SESSION_DETAILS_LENGTH];
typedef Uint32 ServerId;
typedef Uint32 ServerBit;
typedef Uint32 GroupId;
typedef Uint32 Location;
typedef Uint32 Permission;
typedef Uint32 Counter;
typedef Uint32 ActiveSessions;
typedef unsigned int BranchExecuted;
typedef unsigned int DoRollback;
/***************************************************************
* P U B L I C F U N C T I O N S *
***************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
/***************************************************************
* E X T E R N A L D A T A *
***************************************************************/
#endif /* TESTDEFINITIONS_H */
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 DBINTERFACE_H
#define DBINTERFACE_H
/***************************************************************/
/* I N C L U D E D F I L E S */
/***************************************************************/
#include "testDefinitions.h"
#include "testData.h"
/***************************************************************
* M A C R O S *
***************************************************************/
/***************************************************************/
/* C O N S T A N T S */
/***************************************************************/
/*-----------------------*/
/* Default Database Name */
/*-----------------------*/
#define DEFAULTDB "TestDbClient"
/***************************************************************
* 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 *
***************************************************************/
typedef struct Ndb Ndb;
#ifdef __cplusplus
extern "C" {
#endif
extern void showTime();
extern double userGetTime(void);
extern Ndb *asyncDbConnect(int parallellism);
extern void asyncDbDisconnect(Ndb* pNDB);
extern void start_T1(Ndb * uh, ThreadData * data, int async);
extern void start_T2(Ndb * uh, ThreadData * data, int async);
extern void start_T3(Ndb * uh, ThreadData * data, int async);
extern void start_T4(Ndb * uh, ThreadData * data, int async);
extern void start_T5(Ndb * uh, ThreadData * data, int async);
extern void complete_T1(ThreadData * data);
extern void complete_T2(ThreadData * data);
extern void complete_T3(ThreadData * data);
extern void complete_T4(ThreadData * data);
extern void complete_T5(ThreadData * data);
#ifdef __cplusplus
}
#endif
/***************************************************************/
/* I N C L U D E D F I L E S */
/***************************************************************/
#include "testDefinitions.h"
/***************************************************************
* M A C R O S *
***************************************************************/
/***************************************************************/
/* C O N S T A N T S */
/***************************************************************/
/*-----------------------*/
/* Default Database Name */
/*-----------------------*/
#define DEFAULTDB "TestDbClient"
/***************************************************************
* D A T A S T R U C T U R E S *
***************************************************************/
typedef struct {
struct Ndb_cluster_connection* pNCC;
struct Ndb * pNDB;
struct NdbTransaction * pCurrTrans;
} UserHandle;
/***************************************************************
* P U B L I C F U N C T I O N S *
***************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
extern double userGetTimeSync(void);
extern void userCheckpoint(UserHandle *uh);
extern UserHandle *userDbConnect(uint32 createDb, char *dbName);
extern void userDbDisconnect(UserHandle *uh);
extern int userDbInsertServer(UserHandle *uh,
ServerId serverId,
SubscriberSuffix suffix,
ServerName name);
extern int userDbInsertSubscriber(UserHandle *uh,
SubscriberNumber number,
uint32 groupId,
SubscriberName name);
extern int userDbInsertGroup(UserHandle *uh,
GroupId groupId,
GroupName name,
Permission allowRead,
Permission allowInsert,
Permission allowDelete);
extern int userDbCommit(UserHandle *uh);
extern int userDbRollback(UserHandle *uh);
#ifdef __cplusplus
}
#endif
/***************************************************************
* E X T E R N A L D A T A *
***************************************************************/
#endif /* DBINTERFACE_H */
max-time: 25000
max-time: 3600
cmd: atrt-mysql-test-run
args: --force
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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