Commit 170736f8 authored by unknown's avatar unknown

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
parent 189509c6
......@@ -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
......
......@@ -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
......@@ -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
......
......@@ -402,3 +402,7 @@ id parent_id level
1180 105 2
count(*)
1
a
1
2
3
......@@ -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;
......@@ -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*) &current_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*) &current_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
{
......
......@@ -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,7 +57,7 @@ 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 key_read, using_ignore;
bool fix_rec_buff_for_blob(ulong length);
byte current_ident[BDB_HIDDEN_PRIMARY_KEY_LENGTH];
......
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