Commit df046728 authored by unknown's avatar unknown

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

into  zim.(none):/home/brian/mysql/archive-5.1

parents e8595bb5 c9f5a5cc
...@@ -4,13 +4,13 @@ Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, ...@@ -4,13 +4,13 @@ Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
) ENGINE=archive; ) ENGINE=archive;
INSERT INTO t1 VALUES (9410,9412); INSERT INTO t1 VALUES (9410,9412);
select period from t1; select period FROM t1;
period period
9410 9410
select * from t1; select * FROM t1;
Period Varor_period Period Varor_period
9410 9412 9410 9412
select t1.* from t1; select t1.* FROM t1;
Period Varor_period Period Varor_period
9410 9412 9410 9412
CREATE TABLE t2 ( CREATE TABLE t2 (
...@@ -22,13 +22,13 @@ fld4 char(35) DEFAULT '' NOT NULL, ...@@ -22,13 +22,13 @@ fld4 char(35) DEFAULT '' NOT NULL,
fld5 char(35) DEFAULT '' NOT NULL, fld5 char(35) DEFAULT '' NOT NULL,
fld6 char(4) DEFAULT '' NOT NULL fld6 char(4) DEFAULT '' NOT NULL
) ENGINE=archive; ) ENGINE=archive;
select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%"; select t2.fld3 FROM t2 where companynr = 58 and fld3 like "%imaginable%";
fld3 fld3
imaginable imaginable
select fld3 from t2 where fld3 like "%cultivation" ; select fld3 FROM t2 where fld3 like "%cultivation" ;
fld3 fld3
cultivation cultivation
select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3; select t2.fld3,companynr FROM t2 where companynr = 57+1 order by fld3;
fld3 companynr fld3 companynr
concoct 58 concoct 58
druggists 58 druggists 58
...@@ -53,7 +53,7 @@ synergy 58 ...@@ -53,7 +53,7 @@ synergy 58
thanking 58 thanking 58
tying 58 tying 58
unlocks 58 unlocks 58
select fld3,companynr from t2 where companynr = 58 order by fld3; select fld3,companynr FROM t2 where companynr = 58 order by fld3;
fld3 companynr fld3 companynr
concoct 58 concoct 58
druggists 58 druggists 58
...@@ -78,7 +78,7 @@ synergy 58 ...@@ -78,7 +78,7 @@ synergy 58
thanking 58 thanking 58
tying 58 tying 58
unlocks 58 unlocks 58
select fld3 from t2 order by fld3 desc limit 10; select fld3 FROM t2 order by fld3 desc limit 10;
fld3 fld3
youthfulness youthfulness
yelped yelped
...@@ -90,49 +90,49 @@ Winsett ...@@ -90,49 +90,49 @@ Winsett
Willy Willy
willed willed
wildcats wildcats
select fld3 from t2 order by fld3 desc limit 5; select fld3 FROM t2 order by fld3 desc limit 5;
fld3 fld3
youthfulness youthfulness
yelped yelped
Wotan Wotan
workers workers
Witt Witt
select fld3 from t2 order by fld3 desc limit 5,5; select fld3 FROM t2 order by fld3 desc limit 5,5;
fld3 fld3
witchcraft witchcraft
Winsett Winsett
Willy Willy
willed willed
wildcats wildcats
select t2.fld3 from t2 where fld3 = 'honeysuckle'; select t2.fld3 FROM t2 where fld3 = 'honeysuckle';
fld3 fld3
honeysuckle honeysuckle
select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_'; select t2.fld3 FROM t2 where fld3 LIKE 'honeysuckl_';
fld3 fld3
honeysuckle honeysuckle
select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_'; select t2.fld3 FROM t2 where fld3 LIKE 'hon_ysuckl_';
fld3 fld3
honeysuckle honeysuckle
select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%'; select t2.fld3 FROM t2 where fld3 LIKE 'honeysuckle%';
fld3 fld3
honeysuckle honeysuckle
select t2.fld3 from t2 where fld3 LIKE 'h%le'; select t2.fld3 FROM t2 where fld3 LIKE 'h%le';
fld3 fld3
honeysuckle honeysuckle
select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_'; select t2.fld3 FROM t2 where fld3 LIKE 'honeysuckle_';
fld3 fld3
select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%'; select t2.fld3 FROM t2 where fld3 LIKE 'don_t_find_me_please%';
fld3 fld3
select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; select t2.fld3 FROM t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
fld3 fld3
honeysuckle honeysuckle
honoring honoring
select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3; select fld1,fld3 FROM t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3;
fld1 fld3 fld1 fld3
148504 Colombo 148504 Colombo
068305 Colombo 068305 Colombo
000000 nondecreasing 000000 nondecreasing
select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%'; select fld1,fld3 FROM t2 where companynr = 37 and fld3 like 'f%';
fld1 fld3 fld1 fld3
012001 flanking 012001 flanking
013602 foldout 013602 foldout
...@@ -165,37 +165,37 @@ fld1 fld3 ...@@ -165,37 +165,37 @@ fld1 fld3
232102 forgivably 232102 forgivably
238007 filial 238007 filial
238008 fixedly 238008 fixedly
select fld3 from t2 where fld3 like "L%" and fld3 = "ok"; select fld3 FROM t2 where fld3 like "L%" and fld3 = "ok";
fld3 fld3
select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly"); select fld3 FROM t2 where (fld3 like "C%" and fld3 = "Chantilly");
fld3 fld3
Chantilly Chantilly
select fld1,fld3 from t2 where fld1 like "25050%"; select fld1,fld3 FROM t2 where fld1 like "25050%";
fld1 fld3 fld1 fld3
250501 poisoning 250501 poisoning
250502 Iraqis 250502 Iraqis
250503 heaving 250503 heaving
250504 population 250504 population
250505 bomb 250505 bomb
select fld1,fld3 from t2 where fld1 like "25050_"; select fld1,fld3 FROM t2 where fld1 like "25050_";
fld1 fld3 fld1 fld3
250501 poisoning 250501 poisoning
250502 Iraqis 250502 Iraqis
250503 heaving 250503 heaving
250504 population 250504 population
250505 bomb 250505 bomb
create table t3 engine=archive select * from t2; create table t3 engine=archive select * FROM t2;
select * from t3 where fld3='bonfire'; select * FROM t3 where fld3='bonfire';
auto fld1 companynr fld3 fld4 fld5 fld6 auto fld1 companynr fld3 fld4 fld5 fld6
1191 068504 00 bonfire corresponds positively 1191 068504 00 bonfire corresponds positively
select count(*) from t3; select count(*) FROM t3;
count(*) count(*)
1199 1199
rename table t3 to t4; rename table t3 to t4;
select * from t4 where fld3='bonfire'; select * FROM t4 where fld3='bonfire';
auto fld1 companynr fld3 fld4 fld5 fld6 auto fld1 companynr fld3 fld4 fld5 fld6
1191 068504 00 bonfire corresponds positively 1191 068504 00 bonfire corresponds positively
select count(*) from t4; select count(*) FROM t4;
count(*) count(*)
1199 1199
INSERT INTO t2 VALUES (1,000001,00,'Omaha','teethe','neat',''); INSERT INTO t2 VALUES (1,000001,00,'Omaha','teethe','neat','');
...@@ -11130,7 +11130,7 @@ t2 CREATE TABLE `t2` ( ...@@ -11130,7 +11130,7 @@ t2 CREATE TABLE `t2` (
`fld4` char(35) NOT NULL default '', `fld4` char(35) NOT NULL default '',
`fld5` char(35) NOT NULL default '' `fld5` char(35) NOT NULL default ''
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 ) ENGINE=ARCHIVE DEFAULT CHARSET=latin1
SELECT * from t2; SELECT * FROM t2;
auto fld1 companynr fld3 fld4 fld5 auto fld1 companynr fld3 fld4 fld5
1 000001 00 Omaha teethe neat 1 000001 00 Omaha teethe neat
2 011401 37 breaking dreaded Steinberg 2 011401 37 breaking dreaded Steinberg
...@@ -12346,4 +12346,63 @@ auto fld1 companynr fld3 fld4 fld5 ...@@ -12346,4 +12346,63 @@ auto fld1 companynr fld3 fld4 fld5
3 011402 37 Romans scholastics jarring 3 011402 37 Romans scholastics jarring
4 011403 37 intercepted audiology tinily 4 011403 37 intercepted audiology tinily
4 011403 37 intercepted audiology tinily 4 011403 37 intercepted audiology tinily
drop table t1, t2, t4; CREATE TABLE `t5` (
`a` int(11) NOT NULL auto_increment,
b char(12),
PRIMARY KEY (`a`)
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
INSERT INTO t5 VALUES (0, "foo");
INSERT INTO t5 VALUES (0, "foo");
INSERT INTO t5 VALUES (0, "foo");
INSERT INTO t5 VALUES (0, "foo");
INSERT INTO t5 VALUES (0, "foo");
INSERT INTO t5 VALUES (32, "foo");
INSERT INTO t5 VALUES (23, "foo");
INSERT INTO t5 VALUES (0, "foo");
INSERT INTO t5 VALUES (0, "foo");
INSERT INTO t5 VALUES (3, "foo");
ERROR 23000: Can't write; duplicate key in table 't5'
INSERT INTO t5 VALUES (0, "foo");
SELECT * FROM t5;
a b
1 foo
2 foo
3 foo
4 foo
5 foo
32 foo
23 foo
33 foo
34 foo
35 foo
DROP TABLE t5;
CREATE TABLE `t5` (
`a` int(11) NOT NULL auto_increment,
b char(12),
KEY (`a`)
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
INSERT INTO t5 VALUES (0, "foo");
INSERT INTO t5 VALUES (0, "foo");
INSERT INTO t5 VALUES (0, "foo");
INSERT INTO t5 VALUES (0, "foo");
INSERT INTO t5 VALUES (0, "foo");
INSERT INTO t5 VALUES (32, "foo");
INSERT INTO t5 VALUES (23, "foo");
INSERT INTO t5 VALUES (0, "foo");
INSERT INTO t5 VALUES (0, "foo");
INSERT INTO t5 VALUES (3, "foo");
INSERT INTO t5 VALUES (0, "foo");
SELECT * FROM t5;
a b
1 foo
2 foo
3 foo
4 foo
5 foo
32 foo
23 foo
33 foo
34 foo
3 foo
35 foo
drop table t1, t2, t4, t5;
# #
# Simple test for archive example # Simple test for archive example
# Taken from the select test # Taken FROM the select test
# #
-- source include/have_archive.inc -- source include/have_archive.inc
...@@ -15,9 +15,9 @@ CREATE TABLE t1 ( ...@@ -15,9 +15,9 @@ CREATE TABLE t1 (
INSERT INTO t1 VALUES (9410,9412); INSERT INTO t1 VALUES (9410,9412);
select period from t1; select period FROM t1;
select * from t1; select * FROM t1;
select t1.* from t1; select t1.* FROM t1;
# #
# Create test table # Create test table
...@@ -1243,64 +1243,64 @@ INSERT INTO t2 VALUES (1193,000000,00,'nondecreasing','implant','thrillingly','' ...@@ -1243,64 +1243,64 @@ INSERT INTO t2 VALUES (1193,000000,00,'nondecreasing','implant','thrillingly',''
# Search with a key # Search with a key
# #
select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%"; select t2.fld3 FROM t2 where companynr = 58 and fld3 like "%imaginable%";
select fld3 from t2 where fld3 like "%cultivation" ; select fld3 FROM t2 where fld3 like "%cultivation" ;
# #
# Search with a key using sorting and limit the same time # Search with a key using sorting and limit the same time
# #
select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3; select t2.fld3,companynr FROM t2 where companynr = 57+1 order by fld3;
select fld3,companynr from t2 where companynr = 58 order by fld3; select fld3,companynr FROM t2 where companynr = 58 order by fld3;
select fld3 from t2 order by fld3 desc limit 10; select fld3 FROM t2 order by fld3 desc limit 10;
select fld3 from t2 order by fld3 desc limit 5; select fld3 FROM t2 order by fld3 desc limit 5;
select fld3 from t2 order by fld3 desc limit 5,5; select fld3 FROM t2 order by fld3 desc limit 5,5;
# #
# Search with a key having a constant with each unique key. # Search with a key having a constant with each unique key.
# The table is read directly with read-next on fld3 # The table is read directly with read-next on fld3
# #
select t2.fld3 from t2 where fld3 = 'honeysuckle'; select t2.fld3 FROM t2 where fld3 = 'honeysuckle';
select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_'; select t2.fld3 FROM t2 where fld3 LIKE 'honeysuckl_';
select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_'; select t2.fld3 FROM t2 where fld3 LIKE 'hon_ysuckl_';
select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%'; select t2.fld3 FROM t2 where fld3 LIKE 'honeysuckle%';
select t2.fld3 from t2 where fld3 LIKE 'h%le'; select t2.fld3 FROM t2 where fld3 LIKE 'h%le';
select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_'; select t2.fld3 FROM t2 where fld3 LIKE 'honeysuckle_';
select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%'; select t2.fld3 FROM t2 where fld3 LIKE 'don_t_find_me_please%';
# #
# Test sorting with a used key (there is no need for sorting) # Test sorting with a used key (there is no need for sorting)
# #
select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3; select t2.fld3 FROM t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3; select fld1,fld3 FROM t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3;
# #
# Search with a key with LIKE constant # Search with a key with LIKE constant
# If the like starts with a certain letter key will be used. # If the like starts with a certain letter key will be used.
# #
select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%'; select fld1,fld3 FROM t2 where companynr = 37 and fld3 like 'f%';
select fld3 from t2 where fld3 like "L%" and fld3 = "ok"; select fld3 FROM t2 where fld3 like "L%" and fld3 = "ok";
select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly"); select fld3 FROM t2 where (fld3 like "C%" and fld3 = "Chantilly");
select fld1,fld3 from t2 where fld1 like "25050%"; select fld1,fld3 FROM t2 where fld1 like "25050%";
select fld1,fld3 from t2 where fld1 like "25050_"; select fld1,fld3 FROM t2 where fld1 like "25050_";
# #
# Test rename of table # Test rename of table
# #
create table t3 engine=archive select * from t2; create table t3 engine=archive select * FROM t2;
select * from t3 where fld3='bonfire'; select * FROM t3 where fld3='bonfire';
select count(*) from t3; select count(*) FROM t3;
# Clean up path in error message # Clean up path in error message
--replace_result $MYSQL_TEST_DIR . /var/master-data/ / --replace_result $MYSQL_TEST_DIR . /var/master-data/ /
rename table t3 to t4; rename table t3 to t4;
select * from t4 where fld3='bonfire'; select * FROM t4 where fld3='bonfire';
select count(*) from t4; select count(*) FROM t4;
# End of 4.1 tests # End of 4.1 tests
...@@ -1351,10 +1351,58 @@ INSERT DELAYED INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily','' ...@@ -1351,10 +1351,58 @@ INSERT DELAYED INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily',''
# Adding test for alter table # Adding test for alter table
ALTER TABLE t2 DROP COLUMN fld6; ALTER TABLE t2 DROP COLUMN fld6;
SHOW CREATE TABLE t2; SHOW CREATE TABLE t2;
SELECT * from t2; SELECT * FROM t2;
# Adding tests for autoincrement
# First the simple stuff
CREATE TABLE `t5` (
`a` int(11) NOT NULL auto_increment,
b char(12),
PRIMARY KEY (`a`)
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
INSERT INTO t5 VALUES (0, "foo");
INSERT INTO t5 VALUES (0, "foo");
INSERT INTO t5 VALUES (0, "foo");
INSERT INTO t5 VALUES (0, "foo");
INSERT INTO t5 VALUES (0, "foo");
INSERT INTO t5 VALUES (32, "foo");
INSERT INTO t5 VALUES (23, "foo");
INSERT INTO t5 VALUES (0, "foo");
INSERT INTO t5 VALUES (0, "foo");
--error 1022
INSERT INTO t5 VALUES (3, "foo");
INSERT INTO t5 VALUES (0, "foo");
SELECT * FROM t5;
DROP TABLE t5;
CREATE TABLE `t5` (
`a` int(11) NOT NULL auto_increment,
b char(12),
KEY (`a`)
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
INSERT INTO t5 VALUES (0, "foo");
INSERT INTO t5 VALUES (0, "foo");
INSERT INTO t5 VALUES (0, "foo");
INSERT INTO t5 VALUES (0, "foo");
INSERT INTO t5 VALUES (0, "foo");
INSERT INTO t5 VALUES (32, "foo");
INSERT INTO t5 VALUES (23, "foo");
INSERT INTO t5 VALUES (0, "foo");
INSERT INTO t5 VALUES (0, "foo");
INSERT INTO t5 VALUES (3, "foo");
INSERT INTO t5 VALUES (0, "foo");
SELECT * FROM t5;
# #
# Cleanup, test is over # Cleanup, test is over
# #
drop table t1, t2, t4; --disable_warnings
drop table t1, t2, t4, t5;
--enable_warnings
...@@ -253,7 +253,15 @@ public: ...@@ -253,7 +253,15 @@ public:
ptr-=row_offset; ptr-=row_offset;
return tmp; return tmp;
} }
inline longlong val_int(char *new_ptr)
{
char *old_ptr= ptr;
longlong return_value;
ptr= new_ptr;
return_value= val_int();
ptr= old_ptr;
return return_value;
}
inline String *val_str(String *str, char *new_ptr) inline String *val_str(String *str, char *new_ptr)
{ {
char *old_ptr= ptr; char *old_ptr= ptr;
......
This diff is collapsed.
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#pragma interface /* gcc class implementation */ #pragma interface /* gcc class implementation */
#endif #endif
#include <values.h>
#include <zlib.h> #include <zlib.h>
#include "../storage/archive/azlib.h" #include "../storage/archive/azlib.h"
...@@ -38,13 +39,14 @@ typedef struct st_archive_share { ...@@ -38,13 +39,14 @@ typedef struct st_archive_share {
bool dirty; /* Flag for if a flush should occur */ bool dirty; /* Flag for if a flush should occur */
bool crashed; /* Meta file is crashed */ bool crashed; /* Meta file is crashed */
ha_rows rows_recorded; /* Number of rows in tables */ ha_rows rows_recorded; /* Number of rows in tables */
ulonglong auto_increment_value;
} ARCHIVE_SHARE; } ARCHIVE_SHARE;
/* /*
Version for file format. Version for file format.
1 - Initial Version 1 - Initial Version
*/ */
#define ARCHIVE_VERSION 1 #define ARCHIVE_VERSION 2
class ha_archive: public handler class ha_archive: public handler
{ {
...@@ -68,13 +70,22 @@ public: ...@@ -68,13 +70,22 @@ public:
const char **bas_ext() const; const char **bas_ext() const;
ulong table_flags() const ulong table_flags() const
{ {
return (HA_REC_NOT_IN_SEQ | HA_NOT_EXACT_COUNT | HA_NO_AUTO_INCREMENT | return (HA_REC_NOT_IN_SEQ | HA_NOT_EXACT_COUNT |
HA_FILE_BASED | HA_CAN_INSERT_DELAYED | HA_CAN_GEOMETRY); HA_FILE_BASED | HA_CAN_INSERT_DELAYED | HA_CAN_GEOMETRY);
} }
ulong index_flags(uint idx, uint part, bool all_parts) const ulong index_flags(uint idx, uint part, bool all_parts) const
{ {
return 0; return HA_ONLY_WHOLE_INDEX;
} }
ulonglong get_auto_increment();
uint max_supported_keys() const { return 1; }
uint max_supported_key_length() const { return sizeof(ulonglong); }
uint max_supported_key_part_length() const { return sizeof(ulonglong); }
int index_init(uint keynr, bool sorted);
virtual int index_read(byte * buf, const byte * key,
uint key_len, enum ha_rkey_function find_flag);
virtual int index_read_idx(byte * buf, uint index, const byte * key,
uint key_len, enum ha_rkey_function find_flag);
int open(const char *name, int mode, uint test_if_locked); int open(const char *name, int mode, uint test_if_locked);
int close(void); int close(void);
int write_row(byte * buf); int write_row(byte * buf);
...@@ -84,8 +95,9 @@ public: ...@@ -84,8 +95,9 @@ public:
int rnd_next(byte *buf); int rnd_next(byte *buf);
int rnd_pos(byte * buf, byte *pos); int rnd_pos(byte * buf, byte *pos);
int get_row(azio_stream *file_to_read, byte *buf); int get_row(azio_stream *file_to_read, byte *buf);
int read_meta_file(File meta_file, ha_rows *rows); int read_meta_file(File meta_file, ha_rows *rows, ulonglong *auto_increment);
int write_meta_file(File meta_file, ha_rows rows, bool dirty); int write_meta_file(File meta_file, ha_rows rows,
ulonglong auto_increment, bool dirty);
ARCHIVE_SHARE *get_share(const char *table_name, TABLE *table); ARCHIVE_SHARE *get_share(const char *table_name, TABLE *table);
int free_share(ARCHIVE_SHARE *share); int free_share(ARCHIVE_SHARE *share);
bool auto_repair() const { return 1; } // For the moment we just do this bool auto_repair() const { return 1; } // For the moment we just do this
......
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