Skip to content

Commit

Permalink
query_id and my_xid -> ulonglong
Browse files Browse the repository at this point in the history
fix for binlog+autocommit+tclog
comments, style fixes
  • Loading branch information
[email protected] committed Jan 27, 2005
1 parent 2c0d5bb commit 3c50609
Show file tree
Hide file tree
Showing 27 changed files with 378 additions and 302 deletions.
2 changes: 1 addition & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -1914,7 +1914,7 @@ AC_CHECK_FUNCS(alarm bcmp bfill bmove bzero chsize cuserid fchmod fcntl \
getcwd gethostbyaddr_r gethostbyname_r getpass getpassphrase getpwnam \
getpwuid getrlimit getrusage getwd gmtime_r index initgroups isnan \
localtime_r locking longjmp lrand48 madvise mallinfo memcpy memmove \
mkstemp mlockall perror poll pread pthread_attr_create mmap \
mkstemp mlockall perror poll pread pthread_attr_create mmap getpagesize \
pthread_attr_getstacksize pthread_attr_setprio pthread_attr_setschedparam \
pthread_attr_setstacksize pthread_condattr_create pthread_getsequence_np \
pthread_key_delete pthread_rwlock_rdlock pthread_setprio \
Expand Down
2 changes: 1 addition & 1 deletion include/my_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ typedef long int32;
#endif
typedef unsigned long uint32; /* Short for unsigned integer >= 32 bits */
#else
error "Neither int or long is of 4 bytes width"
#error "Neither int or long is of 4 bytes width"
#endif

#if !defined(HAVE_ULONG) && !defined(HAVE_LINUXTHREADS) && !defined(__USE_MISC)
Expand Down
2 changes: 1 addition & 1 deletion include/my_pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ static inline bool thread_safe_dec_and_test(ulong &V, pthread_mutex_t *L)
{
ulong res;
pthread_mutex_lock(L);
res=V--;
res=--V;
pthread_mutex_unlock(L);
return res==0;
}
Expand Down
Empty file modified libmysqld/libmysqld.rc
100755 → 100644
Empty file.
Empty file modified libmysqld/resource.h
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion mysql-test/r/bdb.result
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,7 @@ qq
*a *a*a *
explain select * from t1 where v='a';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref v,v_2 v 13 const 10 Using where
1 SIMPLE t1 ref v,v_2 # 13 const # Using where
select v,count(*) from t1 group by v limit 10;
v count(*)
a 1
Expand Down
6 changes: 3 additions & 3 deletions mysql-test/r/innodb.result
Original file line number Diff line number Diff line change
Expand Up @@ -1609,14 +1609,14 @@ t2 CREATE TABLE `t2` (
drop table t2, t1;
show status like "binlog_cache_use";
Variable_name Value
Binlog_cache_use 24
Binlog_cache_use 150
show status like "binlog_cache_disk_use";
Variable_name Value
Binlog_cache_disk_use 0
create table t1 (a int) engine=innodb;
show status like "binlog_cache_use";
Variable_name Value
Binlog_cache_use 25
Binlog_cache_use 151
show status like "binlog_cache_disk_use";
Variable_name Value
Binlog_cache_disk_use 1
Expand All @@ -1625,7 +1625,7 @@ delete from t1;
commit;
show status like "binlog_cache_use";
Variable_name Value
Binlog_cache_use 26
Binlog_cache_use 152
show status like "binlog_cache_disk_use";
Variable_name Value
Binlog_cache_disk_use 1
Expand Down
42 changes: 26 additions & 16 deletions mysql-test/r/mix_innodb_myisam_binlog.result
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ master-bin.000001 96 Query 1 # use `test`; BEGIN
master-bin.000001 158 Query 1 # use `test`; insert into t1 values(1)
master-bin.000001 239 Query 1 # use `test`; insert into t2 select * from t1
master-bin.000001 327 Xid 1 # xid=7
master-bin.000001 350 Query 1 # use `test`; COMMIT
master-bin.000001 354 Query 1 # use `test`; COMMIT
delete from t1;
delete from t2;
reset master;
Expand Down Expand Up @@ -49,7 +49,7 @@ master-bin.000001 318 Query 1 # use `test`; insert into t1 values(4)
master-bin.000001 399 Query 1 # use `test`; insert into t2 select * from t1
master-bin.000001 487 Query 1 # use `test`; rollback to savepoint my_savepoint
master-bin.000001 578 Xid 1 # xid=24
master-bin.000001 601 Query 1 # use `test`; COMMIT
master-bin.000001 605 Query 1 # use `test`; COMMIT
delete from t1;
delete from t2;
reset master;
Expand Down Expand Up @@ -77,7 +77,7 @@ master-bin.000001 399 Query 1 # use `test`; insert into t2 select * from t1
master-bin.000001 487 Query 1 # use `test`; rollback to savepoint my_savepoint
master-bin.000001 578 Query 1 # use `test`; insert into t1 values(7)
master-bin.000001 659 Xid 1 # xid=36
master-bin.000001 682 Query 1 # use `test`; COMMIT
master-bin.000001 686 Query 1 # use `test`; COMMIT
delete from t1;
delete from t2;
reset master;
Expand All @@ -96,15 +96,19 @@ master-bin.000001 96 Query 1 # use `test`; BEGIN
master-bin.000001 158 Query 1 # use `test`; insert into t1 values(8)
master-bin.000001 239 Query 1 # use `test`; insert into t2 select * from t1
master-bin.000001 327 Query 1 # use `test`; ROLLBACK
master-bin.000001 392 Query 1 # use `test`; DO RELEASE_LOCK("a")
delete from t1;
delete from t2;
reset master;
insert into t1 values(9);
insert into t2 select * from t1;
show binlog events from 96;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 96 Query 1 # use `test`; insert into t1 values(9)
master-bin.000001 177 Query 1 # use `test`; insert into t2 select * from t1
master-bin.000001 96 Query 1 # use `test`; BEGIN
master-bin.000001 158 Query 1 # use `test`; insert into t1 values(9)
master-bin.000001 239 Xid 1 # xid=59
master-bin.000001 266 Query 1 # use `test`; COMMIT
master-bin.000001 329 Query 1 # use `test`; insert into t2 select * from t1
delete from t1;
delete from t2;
reset master;
Expand All @@ -113,18 +117,24 @@ begin;
insert into t2 select * from t1;
show binlog events from 96;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 96 Query 1 # use `test`; insert into t1 values(10)
master-bin.000001 178 Query 1 # use `test`; insert into t2 select * from t1
master-bin.000001 96 Query 1 # use `test`; BEGIN
master-bin.000001 158 Query 1 # use `test`; insert into t1 values(10)
master-bin.000001 240 Xid 1 # xid=65
master-bin.000001 267 Query 1 # use `test`; COMMIT
master-bin.000001 330 Query 1 # use `test`; insert into t2 select * from t1
insert into t1 values(11);
commit;
show binlog events from 96;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 96 Query 1 # use `test`; insert into t1 values(10)
master-bin.000001 178 Query 1 # use `test`; insert into t2 select * from t1
master-bin.000001 266 Query 1 # use `test`; BEGIN
master-bin.000001 328 Query 1 # use `test`; insert into t1 values(11)
master-bin.000001 410 Xid 1 # xid=67
master-bin.000001 433 Query 1 # use `test`; COMMIT
master-bin.000001 96 Query 1 # use `test`; BEGIN
master-bin.000001 158 Query 1 # use `test`; insert into t1 values(10)
master-bin.000001 240 Xid 1 # xid=65
master-bin.000001 267 Query 1 # use `test`; COMMIT
master-bin.000001 330 Query 1 # use `test`; insert into t2 select * from t1
master-bin.000001 418 Query 1 # use `test`; BEGIN
master-bin.000001 480 Query 1 # use `test`; insert into t1 values(11)
master-bin.000001 562 Xid 1 # xid=67
master-bin.000001 589 Query 1 # use `test`; COMMIT
alter table t2 engine=INNODB;
delete from t1;
delete from t2;
Expand All @@ -139,7 +149,7 @@ master-bin.000001 96 Query 1 # use `test`; BEGIN
master-bin.000001 158 Query 1 # use `test`; insert into t1 values(12)
master-bin.000001 240 Query 1 # use `test`; insert into t2 select * from t1
master-bin.000001 328 Xid 1 # xid=77
master-bin.000001 351 Query 1 # use `test`; COMMIT
master-bin.000001 355 Query 1 # use `test`; COMMIT
delete from t1;
delete from t2;
reset master;
Expand All @@ -164,7 +174,7 @@ Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 96 Query 1 # use `test`; BEGIN
master-bin.000001 158 Query 1 # use `test`; insert into t1 values(14)
master-bin.000001 240 Xid 1 # xid=93
master-bin.000001 263 Query 1 # use `test`; COMMIT
master-bin.000001 267 Query 1 # use `test`; COMMIT
delete from t1;
delete from t2;
reset master;
Expand All @@ -186,7 +196,7 @@ master-bin.000001 96 Query 1 # use `test`; BEGIN
master-bin.000001 158 Query 1 # use `test`; insert into t1 values(16)
master-bin.000001 240 Query 1 # use `test`; insert into t1 values(18)
master-bin.000001 322 Xid 1 # xid=104
master-bin.000001 345 Query 1 # use `test`; COMMIT
master-bin.000001 349 Query 1 # use `test`; COMMIT
delete from t1;
delete from t2;
alter table t2 type=MyISAM;
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/r/rpl_relayrotate.result
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ max(a)
8000
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_MYPORT 1 master-bin.000001 687231 # # master-bin.000001 Yes Yes 0 0 687231 # None 0 No #
# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 687235 # # master-bin.000001 Yes Yes 0 0 687235 # None 0 No #
drop table t1;
26 changes: 12 additions & 14 deletions sql/ha_berkeley.cc
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,13 @@ static int berkeley_commit(THD *thd, bool all)
DBUG_ENTER("berkeley_commit");
DBUG_PRINT("trans",("ending transaction %s", all ? "all" : "stmt"));
berkeley_trx_data *trx=(berkeley_trx_data *)thd->ha_data[berkeley_hton.slot];
int error=txn_commit(all ? trx->all : trx->stmt,0);
DB_TXN **txn= all ? &trx->all : &trx->stmt;
int error=txn_commit(*txn,0);
*txn=0;
#ifndef DBUG_OFF
if (error)
DBUG_PRINT("error",("error: %d",error));
#endif
if (all)
trx->all=0;
else
trx->stmt=0;
DBUG_RETURN(error);
}

Expand All @@ -255,11 +253,9 @@ static int berkeley_rollback(THD *thd, bool all)
DBUG_ENTER("berkeley_rollback");
DBUG_PRINT("trans",("aborting transaction %s", all ? "all" : "stmt"));
berkeley_trx_data *trx=(berkeley_trx_data *)thd->ha_data[berkeley_hton.slot];
int error=txn_abort(all ? trx->all : trx->stmt);
if (all)
trx->all=0;
else
trx->stmt=0;
DB_TXN **txn= all ? &trx->all : &trx->stmt;
int error=txn_abort(*txn);
*txn=0;
DBUG_RETURN(error);
}

Expand Down Expand Up @@ -1904,7 +1900,7 @@ int ha_berkeley::external_lock(THD *thd, int lock_type)
if (trx->stmt)
{
/*
F_UNLOCK is done without a transaction commit / rollback.
F_UNLCK is done without a transaction commit / rollback.
This happens if the thread didn't update any rows
We must in this case commit the work to keep the row locks
*/
Expand All @@ -1929,6 +1925,7 @@ int ha_berkeley::start_stmt(THD *thd)
int error=0;
DBUG_ENTER("ha_berkeley::start_stmt");
berkeley_trx_data *trx=(berkeley_trx_data *)thd->ha_data[berkeley_hton.slot];
DBUG_ASSERT(trx);
/*
note that trx->stmt may have been already initialized as start_stmt()
is called for *each table* not for each storage engine,
Expand Down Expand Up @@ -2277,6 +2274,7 @@ int ha_berkeley::analyze(THD* thd, HA_CHECK_OPT* check_opt)
DB_BTREE_STAT *stat=0;
DB_TXN_STAT *txn_stat_ptr= 0;
berkeley_trx_data *trx=(berkeley_trx_data *)thd->ha_data[berkeley_hton.slot];
DBUG_ASSERT(trx);

/*
Original bdb documentation says:
Expand All @@ -2291,18 +2289,18 @@ int ha_berkeley::analyze(THD* thd, HA_CHECK_OPT* check_opt)
txn_stat_ptr && txn_stat_ptr->st_nactive>=2)
{
DB_TXN_ACTIVE *atxn_stmt= 0, *atxn_all= 0;

u_int32_t all_id= trx->all->id(trx->all);
u_int32_t stmt_id= trx->stmt->id(trx->stmt);

DB_TXN_ACTIVE *cur= txn_stat_ptr->st_txnarray;
DB_TXN_ACTIVE *end= cur + txn_stat_ptr->st_nactive;
for (; cur!=end && (!atxn_stmt || !atxn_all); cur++)
{
if (cur->txnid==all_id) atxn_all= cur;
if (cur->txnid==stmt_id) atxn_stmt= cur;
}

if (atxn_stmt && atxn_all &&
log_compare(&atxn_stmt->lsn,&atxn_all->lsn))
{
Expand Down
48 changes: 30 additions & 18 deletions sql/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ ha_innobase::update_thd(
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
trx_t* trx;

trx = check_trx_exists(thd);

if (prebuilt->trx != trx) {
Expand All @@ -711,11 +711,23 @@ ha_innobase::update_thd(
return(0);
}

static void register_trans(THD *thd)
/*************************************************************************
Registers the InnoDB transaction in MySQL, to receive commit/rollback
events. This function must be called every time InnoDB starts a
transaction internally. */
static
void
register_trans(
/*============*/
THD* thd) /* in: thd to use the handle */
{
trans_register_ha(thd, FALSE, &innobase_hton);
if (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
trans_register_ha(thd, TRUE, &innobase_hton);
/* register the start of the statement */
trans_register_ha(thd, FALSE, &innobase_hton);
if (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {

/* no autocommit mode, register for a transaction */
trans_register_ha(thd, TRUE, &innobase_hton);
}
}

/* BACKGROUND INFO: HOW THE MYSQL QUERY CACHE WORKS WITH INNODB
Expand Down Expand Up @@ -1459,12 +1471,12 @@ innobase_report_binlog_offset_and_commit(

ut_a(trx != NULL);

trx->mysql_log_file_name = log_file_name;
trx->mysql_log_file_name = log_file_name;
trx->mysql_log_offset = (ib_longlong)end_offset;

trx->flush_log_later = TRUE;

innobase_commit(thd, trx_handle);
innobase_commit(thd, trx_handle);

trx->flush_log_later = FALSE;

Expand All @@ -1474,18 +1486,18 @@ innobase_report_binlog_offset_and_commit(
/***********************************************************************
This function stores the binlog offset and flushes logs. */

void
void
innobase_store_binlog_offset_and_flush_log(
/*=======================================*/
char *binlog_name, /* in: binlog name */
longlong offset) /* in: binlog offset */
longlong offset) /* in: binlog offset */
{
mtr_t mtr;

assert(binlog_name != NULL);

/* Start a mini-transaction */
mtr_start_noninline(&mtr);
mtr_start_noninline(&mtr);

/* Update the latest MySQL binlog name and offset info
in trx sys header */
Expand All @@ -1497,7 +1509,7 @@ innobase_store_binlog_offset_and_flush_log(

/* Commits the mini-transaction */
mtr_commit(&mtr);

/* Syncronous flush of the log buffer to disk */
log_buffer_flush_to_disk();
}
Expand All @@ -1520,14 +1532,14 @@ innobase_commit_complete(

if (trx && trx->active_trans) {

trx->active_trans = 0;
trx->active_trans = 0;

if (srv_flush_log_at_trx_commit == 0) {
if (srv_flush_log_at_trx_commit == 0) {

return(0);
}
return(0);
}

trx_commit_complete_for_mysql(trx);
trx_commit_complete_for_mysql(trx);
}

return(0);
Expand Down
Loading

0 comments on commit 3c50609

Please sign in to comment.