Commit 200545c5 authored by unknown's avatar unknown

Merge rkalimullin@bk-internal.mysql.com:/home/bk/mysql-4.1

into gw.mysql.r18.ru:/usr/home/ram/work/4.1.b4198

parents f527bdb7 8fade235
select * from t9;
select * from t9 order by a;
a b
1 2
2 3
4 5
3 4
1 2
4 5
show status like 'handler_discover%';
Variable_name Value
Handler_discover 1
......
......@@ -5,7 +5,7 @@
# The previous step has simply removed the frm file
# from disk, but left the table in NDB
#
select * from t9;
select * from t9 order by a;
# handler_discover should be zero
show status like 'handler_discover%';
......
......@@ -34,6 +34,9 @@
#include <Dbtux.hpp>
#include <NdbEnv.h>
#ifndef VM_TRACE
#define NEW_BLOCK(B) new B
#else
enum SIMBLOCKLIST_DUMMY { A_VALUE = 0 };
static
......@@ -60,13 +63,13 @@ void * operator new (size_t sz, SIMBLOCKLIST_DUMMY dummy){
return tmp;
}
#define NEW_BLOCK(B) new(A_VALUE) B
#endif
void
SimBlockList::load(const Configuration & conf){
noOfBlocks = 16;
theList = new SimulatedBlock * [noOfBlocks];
for(int i = 0; i<noOfBlocks; i++)
theList[i] = 0;
Dbdict* dbdict = 0;
Dbdih* dbdih = 0;
......@@ -75,28 +78,28 @@ SimBlockList::load(const Configuration & conf){
Uint32 dl;
const ndb_mgm_configuration_iterator * p = conf.getOwnConfigIterator();
if(p && !ndb_mgm_get_int_parameter(p, CFG_DB_DISCLESS, &dl) && dl){
fs = new (A_VALUE) VoidFs(conf);
fs = NEW_BLOCK(VoidFs)(conf);
} else {
fs = new (A_VALUE) Ndbfs(conf);
fs = NEW_BLOCK(Ndbfs)(conf);
}
}
theList[0] = new (A_VALUE) Dbacc(conf);
theList[1] = new (A_VALUE) Cmvmi(conf);
theList[0] = NEW_BLOCK(Dbacc)(conf);
theList[1] = NEW_BLOCK(Cmvmi)(conf);
theList[2] = fs;
theList[3] = dbdict = new (A_VALUE) Dbdict(conf);
theList[4] = dbdih = new (A_VALUE) Dbdih(conf);
theList[5] = new (A_VALUE) Dblqh(conf);
theList[6] = new (A_VALUE) Dbtc(conf);
theList[7] = new (A_VALUE) Dbtup(conf);
theList[8] = new (A_VALUE) Ndbcntr(conf);
theList[9] = new (A_VALUE) Qmgr(conf);
theList[10] = new (A_VALUE) Trix(conf);
theList[11] = new (A_VALUE) Backup(conf);
theList[12] = new (A_VALUE) DbUtil(conf);
theList[13] = new (A_VALUE) Suma(conf);
theList[14] = new (A_VALUE) Grep(conf);
theList[15] = new (A_VALUE) Dbtux(conf);
theList[3] = dbdict = NEW_BLOCK(Dbdict)(conf);
theList[4] = dbdih = NEW_BLOCK(Dbdih)(conf);
theList[5] = NEW_BLOCK(Dblqh)(conf);
theList[6] = NEW_BLOCK(Dbtc)(conf);
theList[7] = NEW_BLOCK(Dbtup)(conf);
theList[8] = NEW_BLOCK(Ndbcntr)(conf);
theList[9] = NEW_BLOCK(Qmgr)(conf);
theList[10] = NEW_BLOCK(Trix)(conf);
theList[11] = NEW_BLOCK(Backup)(conf);
theList[12] = NEW_BLOCK(DbUtil)(conf);
theList[13] = NEW_BLOCK(Suma)(conf);
theList[14] = NEW_BLOCK(Grep)(conf);
theList[15] = NEW_BLOCK(Dbtux)(conf);
// Metadata common part shared by block instances
ptrMetaDataCommon = new MetaData::Common(*dbdict, *dbdih);
......
......@@ -38,10 +38,6 @@ Name: Ndb.cpp
#include <NdbEnv.h>
#include <BaseString.hpp>
#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
/****************************************************************************
void connect();
......@@ -1028,18 +1024,14 @@ const char * Ndb::getCatalogName() const
void Ndb::setCatalogName(const char * a_catalog_name)
{
if (a_catalog_name) {
strncpy(theDataBase, a_catalog_name, NDB_MAX_DATABASE_NAME_SIZE);
// Prepare prefix for faster operations
uint db_len = MIN(strlen(theDataBase), NDB_MAX_DATABASE_NAME_SIZE - 1);
uint schema_len =
MIN(strlen(theDataBaseSchema), NDB_MAX_SCHEMA_NAME_SIZE - 1);
strncpy(prefixName, theDataBase, NDB_MAX_DATABASE_NAME_SIZE - 1);
prefixName[db_len] = table_name_separator;
strncpy(prefixName+db_len+1, theDataBaseSchema,
NDB_MAX_SCHEMA_NAME_SIZE - 1);
prefixName[db_len+schema_len+1] = table_name_separator;
prefixName[db_len+schema_len+2] = '\0';
prefixEnd = prefixName + db_len+schema_len + 2;
snprintf(theDataBase, sizeof(theDataBase), "%s",
a_catalog_name ? a_catalog_name : "");
int len = snprintf(prefixName, sizeof(prefixName), "%s%c%s%c",
theDataBase, table_name_separator,
theDataBaseSchema, table_name_separator);
prefixEnd = prefixName + (len < sizeof(prefixName) ? len :
sizeof(prefixName) - 1);
}
}
......@@ -1051,18 +1043,14 @@ const char * Ndb::getSchemaName() const
void Ndb::setSchemaName(const char * a_schema_name)
{
if (a_schema_name) {
strncpy(theDataBaseSchema, a_schema_name, NDB_MAX_SCHEMA_NAME_SIZE);
// Prepare prefix for faster operations
uint db_len = MIN(strlen(theDataBase), NDB_MAX_DATABASE_NAME_SIZE - 1);
uint schema_len =
MIN(strlen(theDataBaseSchema), NDB_MAX_SCHEMA_NAME_SIZE - 1);
strncpy(prefixName, theDataBase, NDB_MAX_DATABASE_NAME_SIZE - 1);
prefixName[db_len] = table_name_separator;
strncpy(prefixName+db_len+1, theDataBaseSchema,
NDB_MAX_SCHEMA_NAME_SIZE - 1);
prefixName[db_len+schema_len+1] = table_name_separator;
prefixName[db_len+schema_len+2] = '\0';
prefixEnd = prefixName + db_len+schema_len + 2;
snprintf(theDataBaseSchema, sizeof(theDataBase), "%s",
a_schema_name ? a_schema_name : "");
int len = snprintf(prefixName, sizeof(prefixName), "%s%c%s%c",
theDataBase, table_name_separator,
theDataBaseSchema, table_name_separator);
prefixEnd = prefixName + (len < sizeof(prefixName) ? len :
sizeof(prefixName) - 1);
}
}
......
......@@ -56,7 +56,7 @@ Ndb(const char* aDataBase);
Parameters: aDataBase : Name of the database.
Remark: Connect to the database.
***************************************************************************/
Ndb::Ndb( const char* aDataBase , const char* aDataBaseSchema) :
Ndb::Ndb( const char* aDataBase , const char* aSchema) :
theNdbObjectIdMap(0),
thePreparedTransactionsArray(NULL),
theSentTransactionsArray(NULL),
......@@ -121,22 +121,16 @@ Ndb::Ndb( const char* aDataBase , const char* aDataBaseSchema) :
theLastTupleId[i] = 0;
}//for
if (aDataBase)
strncpy(theDataBase, aDataBase, NDB_MAX_DATABASE_NAME_SIZE);
else
memset(theDataBase, 0, sizeof(theDataBase));
strncpy(theDataBaseSchema, aDataBaseSchema, NDB_MAX_SCHEMA_NAME_SIZE);
// Prepare prefix for faster operations
uint db_len = MIN(strlen(theDataBase), NDB_MAX_DATABASE_NAME_SIZE - 1);
uint schema_len =
MIN(strlen(theDataBaseSchema), NDB_MAX_SCHEMA_NAME_SIZE - 1);
strncpy(prefixName, theDataBase, NDB_MAX_DATABASE_NAME_SIZE - 1);
prefixName[db_len] = table_name_separator;
strncpy(prefixName+db_len+1, theDataBaseSchema,
NDB_MAX_SCHEMA_NAME_SIZE - 1);
prefixName[db_len+schema_len+1] = table_name_separator;
prefixName[db_len+schema_len+2] = '\0';
prefixEnd = prefixName + db_len+schema_len + 2;
snprintf(theDataBase, sizeof(theDataBase), "%s",
aDataBase ? aDataBase : "");
snprintf(theDataBaseSchema, sizeof(theDataBaseSchema), "%s",
aSchema ? aSchema : "");
int len = snprintf(prefixName, sizeof(prefixName), "%s%c%s%c",
theDataBase, table_name_separator,
theDataBaseSchema, table_name_separator);
prefixEnd = prefixName + (len < sizeof(prefixName) ? len :
sizeof(prefixName) - 1);
NdbMutex_Lock(&createNdbMutex);
......
......@@ -385,17 +385,25 @@ int ha_report_binlog_offset_and_commit(THD *thd,
#ifdef HAVE_INNOBASE_DB
THD_TRANS *trans;
trans = &thd->transaction.all;
if (trans->innobase_tid)
if (trans->innobase_tid && trans->innodb_active_trans)
{
/*
If we updated some InnoDB tables (innodb_active_trans is true), the
binlog coords will be reported into InnoDB during the InnoDB commit
(innobase_report_binlog_offset_and_commit). But if we updated only
non-InnoDB tables, we need an explicit call to report it.
*/
if ((error=innobase_report_binlog_offset_and_commit(thd,
trans->innobase_tid,
log_file_name,
end_offset)))
trans->innobase_tid,
log_file_name,
end_offset)))
{
my_error(ER_ERROR_DURING_COMMIT, MYF(0), error);
error=1;
}
}
else if (opt_innodb_safe_binlog) // Don't report if not useful
innobase_store_binlog_offset_and_flush_log(log_file_name, end_offset);
#endif
return error;
}
......
......@@ -283,7 +283,7 @@ public:
create_time(0), check_time(0), update_time(0),
key_used_on_scan(MAX_KEY), active_index(MAX_KEY),
ref_length(sizeof(my_off_t)), block_size(0),
raid_type(0), ft_handler(0), implicit_emptied(0), inited(NONE)
raid_type(0), ft_handler(0), inited(NONE), implicit_emptied(0)
{}
virtual ~handler(void) { /* TODO: DBUG_ASSERT(inited == NONE); */ }
int ha_open(const char *name, int mode, int test_if_locked);
......
......@@ -2073,9 +2073,9 @@ bool MYSQL_LOG::cut_spurious_tail()
name);
DBUG_RETURN(1);
}
sql_print_error("After InnoDB crash recovery, trying to truncate "
"the binary log '%s' at position %s corresponding to the "
"last committed transaction...", name, llstr(pos, llbuf1));
sql_print_error("After InnoDB crash recovery, checking if the binary log "
"'%s' contains rolled back transactions which must be "
"removed from it...", name);
/* If we have a too long binlog, cut. If too short, print error */
int fd= my_open(name, O_EXCL | O_APPEND | O_BINARY | O_WRONLY, MYF(MY_WME));
if (fd < 0)
......@@ -2091,10 +2091,17 @@ bool MYSQL_LOG::cut_spurious_tail()
if (pos > (actual_size= my_seek(fd, 0L, MY_SEEK_END, MYF(MY_WME))))
{
/*
Note that when we have MyISAM rollback this error message should be
reconsidered.
*/
sql_print_error("The binary log '%s' is shorter than its expected size "
"(actual: %s, expected: %s) so it misses at least one "
"committed transaction; so it should not be used for "
"replication.", name, llstr(actual_size, llbuf1),
"replication or point-in-time recovery. You would need "
"to restart slaves from a fresh master's data "
"snapshot ",
name, llstr(actual_size, llbuf1),
llstr(pos, llbuf2));
error= 1;
goto err;
......
......@@ -869,7 +869,7 @@ extern ulong rpl_recovery_rank, thread_cache_size;
extern ulong com_stat[(uint) SQLCOM_END], com_other, back_log;
extern ulong specialflag, current_pid;
extern ulong expire_logs_days, sync_binlog_period, sync_binlog_counter;
extern my_bool relay_log_purge;
extern my_bool relay_log_purge, opt_innodb_safe_binlog;
extern uint test_flags,select_errors,ha_open_options;
extern uint protocol_version, mysqld_port, dropping_tables;
extern uint delay_key_write_options, lower_case_table_names;
......
......@@ -2538,6 +2538,12 @@ server.");
if (opt_innodb_safe_binlog)
{
if (have_innodb != SHOW_OPTION_YES)
{
sql_print_error("Error: --innodb-safe-binlog is meaningful only if "
"the InnoDB storage engine is enabled in the server.");
unireg_abort(1);
}
if (innobase_flush_log_at_trx_commit != 1)
{
sql_print_error("Warning: --innodb-safe-binlog is meaningful only if "
......@@ -4641,9 +4647,8 @@ replicating a LOAD DATA INFILE command.",
effect).
*/
{"innodb_safe_binlog", OPT_INNODB_SAFE_BINLOG,
"After a crash recovery by InnoDB, truncate the binary log to the last \
InnoDB committed transaction. Use only if this server updates ONLY InnoDB \
tables.",
"After a crash recovery by InnoDB, truncate the binary log after the last "
"not-rolled-back statement/transaction.",
(gptr*) &opt_innodb_safe_binlog, (gptr*) &opt_innodb_safe_binlog,
0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
#endif
......
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