diff options
author | unknown <monty@donna.mysql.com> | 2001-01-02 00:27:08 +0200 |
---|---|---|
committer | unknown <monty@donna.mysql.com> | 2001-01-02 00:27:08 +0200 |
commit | 170736f88607d53e818bf73d6d40309f7d96b1b6 (patch) | |
tree | ad69c7c5b1ebe3a109f863f979e2c6b9ceb041c7 | |
parent | 189509c623d09692e7bda2e998f5fbd9215f9ab3 (diff) | |
download | mariadb-git-170736f88607d53e818bf73d6d40309f7d96b1b6.tar.gz |
Fixed bug when opening BDB tables twice
Build-tools/Do-all-build-steps:
Create the result directory
Docs/manual.texi:
More explanation about mysql_install_db
mysql-test/mysql-test-run.sh:
Add --core option
mysql-test/r/bdb.result:
Test of opening tables twice
mysql-test/t/bdb.test:
Test of opening tables twice
sql/ha_berkeley.cc:
Fixed bug when table is in use
sql/ha_berkeley.h:
Fixed bug when table is in use
-rwxr-xr-x | Build-tools/Do-all-build-steps | 1 | ||||
-rw-r--r-- | Docs/manual.texi | 11 | ||||
-rw-r--r-- | mysql-test/mysql-test-run.sh | 2 | ||||
-rw-r--r-- | mysql-test/r/bdb.result | 4 | ||||
-rw-r--r-- | mysql-test/t/bdb.test | 8 | ||||
-rw-r--r-- | sql/ha_berkeley.cc | 19 | ||||
-rw-r--r-- | sql/ha_berkeley.h | 6 |
7 files changed, 39 insertions, 12 deletions
diff --git a/Build-tools/Do-all-build-steps b/Build-tools/Do-all-build-steps index 2ce7347cea2..fab62f1c13f 100755 --- a/Build-tools/Do-all-build-steps +++ b/Build-tools/Do-all-build-steps @@ -15,6 +15,7 @@ echo "Building on $to_host" rm -rf $BD/* rm -f $WD/binary/* +mkdir -p $WD/binary mkdir -p $WD/Logs mkdir -p $BD/Logs diff --git a/Docs/manual.texi b/Docs/manual.texi index 485a394dc47..cf073bba165 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -8704,7 +8704,16 @@ shell> ./bin/mysql_install_db shell> ./bin/safe_mysqld --user=mysql & @end example -This installs and starts @code{MySQL} without any passwords. +This creates the @code{mysql} database which will hold all database +privileges, the @code{test} database which you can use to test +@strong{MySQL} and also privilege entries for the user that run +@code{mysql_install_db} and a @code{root} user (without any passwords). +This also starts the @code{mysqld} server. + +@code{mysql_install_db} will not overwrite any old privilege tables, so +it should be safe to run in any circumstances. If you don't want to +have the @code{test} database you can remove it with @code{mysqladmin -u +root drop test}. Testing is most easily done from the top-level directory of the @strong{MySQL} distribution. For a binary distribution, this is your installation directory diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index abc0452f3b1..a276cb5e414 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -286,6 +286,7 @@ start_master() --pid-file=$MASTER_MYPID \ --socket=$MASTER_MYSOCK \ --log=$MASTER_MYLOG --default-character-set=latin1 \ + --core \ --language=english $EXTRA_MASTER_OPT $EXTRA_MASTER_MYSQLD_OPT" if [ x$DO_DDD = x1 ] then @@ -327,6 +328,7 @@ start_slave() --port=$SLAVE_MYPORT \ --socket=$SLAVE_MYSOCK \ --log=$SLAVE_MYLOG --default-character-set=latin1 \ + --core \ --language=english $EXTRA_SLAVE_OPT $EXTRA_SLAVE_MYSQLD_OPT" if [ x$DO_DDD = x1 ] then diff --git a/mysql-test/r/bdb.result b/mysql-test/r/bdb.result index 3d5bf5f0edb..b008413dd7e 100644 --- a/mysql-test/r/bdb.result +++ b/mysql-test/r/bdb.result @@ -402,3 +402,7 @@ id parent_id level 1180 105 2 count(*) 1 +a +1 +2 +3 diff --git a/mysql-test/t/bdb.test b/mysql-test/t/bdb.test index c03dd16dce5..370e10e7afa 100644 --- a/mysql-test/t/bdb.test +++ b/mysql-test/t/bdb.test @@ -326,3 +326,11 @@ CREATE TABLE t1 ( INSERT INTO t1 ( sca_code, cat_code, sca_desc, lan_code, sca_pic, sca_sdesc, sca_sch_desc) VALUES ( 'PD', 'J', 'PENDANT', 'EN', NULL, NULL, 'PENDANT'),( 'RI', 'J', 'RING', 'EN', NULL, NULL, 'RING'); select count(*) from t1 where sca_code = 'PD'; drop table t1; + +# +# Test of opening table twice +# +CREATE TABLE t1 (a int not null, primary key (a)) type=bdb; +insert into t1 values(1),(2),(3); +select t1.a from t1 natural join t1 as t2 order by t1.a; +drop table t1; diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index 28a33c6a99e..1aa34052152 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -424,7 +424,6 @@ int ha_berkeley::open(const char *name, int mode, uint test_if_locked) if ((primary_key=table->primary_key) >= MAX_KEY) { // No primary key primary_key=table->keys; - fixed_length_primary_key=1; ref_length=hidden_primary_key=BDB_HIDDEN_PRIMARY_KEY_LENGTH; } key_used_on_scan=primary_key; @@ -457,6 +456,7 @@ int ha_berkeley::open(const char *name, int mode, uint test_if_locked) thr_lock_data_init(&share->lock,&lock,(void*) 0); key_file = share->key_file; key_type = share->key_type; + bzero((char*) ¤t_row,sizeof(current_row)); /* Fill in shared structure, if needed */ pthread_mutex_lock(&share->mutex); @@ -489,10 +489,9 @@ int ha_berkeley::open(const char *name, int mode, uint test_if_locked) DBUG_RETURN(1); } - /* Open other keys */ + /* Open other keys; These are part of the share structure */ key_file[primary_key]=file; key_type[primary_key]=DB_NOOVERWRITE; - bzero((char*) ¤t_row,sizeof(current_row)); DB **ptr=key_file; for (uint i=0, used_keys=0; i < table->keys ; i++, ptr++) @@ -522,6 +521,7 @@ int ha_berkeley::open(const char *name, int mode, uint test_if_locked) } } /* Calculate pack_length of primary key */ + share->fixed_length_primary_key=1; if (!hidden_primary_key) { ref_length=0; @@ -529,18 +529,19 @@ int ha_berkeley::open(const char *name, int mode, uint test_if_locked) KEY_PART_INFO *end=key_part+table->key_info[primary_key].key_parts; for ( ; key_part != end ; key_part++) ref_length+= key_part->field->max_packed_col_length(key_part->length); - fixed_length_primary_key= + share->fixed_length_primary_key= (ref_length == table->key_info[primary_key].key_length); share->status|=STATUS_PRIMARY_KEY_INIT; } + share->ref_length=ref_length; } + ref_length=share->ref_length; // If second open pthread_mutex_unlock(&share->mutex); transaction=0; cursor=0; key_read=0; - fixed_length_row=!(table->db_create_options & HA_OPTION_PACK_RECORD); - + share->fixed_length_row=!(table->db_create_options & HA_OPTION_PACK_RECORD); get_status(); info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST); @@ -598,7 +599,7 @@ ulong ha_berkeley::max_row_length(const byte *buf) int ha_berkeley::pack_row(DBT *row, const byte *record, bool new_row) { bzero((char*) row,sizeof(*row)); - if (fixed_length_row) + if (share->fixed_length_row) { row->data=(void*) record; row->size=table->reclength+hidden_primary_key; @@ -640,7 +641,7 @@ int ha_berkeley::pack_row(DBT *row, const byte *record, bool new_row) void ha_berkeley::unpack_row(char *record, DBT *row) { - if (fixed_length_row) + if (share->fixed_length_row) memcpy(record,(char*) row->data,table->reclength+hidden_primary_key); else { @@ -1486,7 +1487,7 @@ DBT *ha_berkeley::get_pos(DBT *to, byte *pos) bzero((char*) to,sizeof(*to)); to->data=pos; - if (fixed_length_primary_key) + if (share->fixed_length_primary_key) to->size=ref_length; else { diff --git a/sql/ha_berkeley.h b/sql/ha_berkeley.h index f0809598798..8684bbb0442 100644 --- a/sql/ha_berkeley.h +++ b/sql/ha_berkeley.h @@ -35,6 +35,8 @@ typedef struct st_berkeley_share { u_int32_t *key_type; uint table_name_length,use_count; uint status,version; + uint ref_length; + bool fixed_length_primary_key, fixed_length_row; } BDB_SHARE; @@ -55,8 +57,8 @@ class ha_berkeley: public handler ulong changed_rows; uint primary_key,last_dup_key, hidden_primary_key, version; u_int32_t lock_on_read; - bool fixed_length_row, fixed_length_primary_key, key_read, using_ignore; - bool fix_rec_buff_for_blob(ulong length); + bool key_read, using_ignore; + bool fix_rec_buff_for_blob(ulong length); byte current_ident[BDB_HIDDEN_PRIMARY_KEY_LENGTH]; ulong max_row_length(const byte *buf); |