Below is the list of changes that have just been committed into a local
5.1 repository of stewart. When stewart does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1833 05/03/29 17:06:14 stewart@stripped +2 -0
Further WL2325 work - NDB Injector thread
basic INSERT support.
sql/ha_ndbcluster.h
1.82 05/03/29 17:06:07 stewart@stripped +1 -0
add TABLE* to NDB_SHARE.
This may be incorrect and be a bad idea (thread safety wise). Get this reviewed.
sql/ha_ndbcluster.cc
1.188 05/03/29 17:06:07 stewart@stripped +52 -14
Add basic support for injecting INSERT events.
set table member of NDB_SHARE
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: stewart
# Host: kennedy.(none)
# Root: /home/stewart/Documents/MySQL/5.1/ndb-wl2325
--- 1.187/sql/ha_ndbcluster.cc 2005-03-24 12:07:22 +11:00
+++ 1.188/sql/ha_ndbcluster.cc 2005-03-29 17:06:07 +10:00
@@ -29,6 +29,7 @@
#ifdef HAVE_NDBCLUSTER_DB
#include <my_dir.h>
#include "ha_ndbcluster.h"
+#include "rpl_injector.h"
#include <ndbapi/NdbApi.hpp>
#include <ndbapi/NdbScanFilter.hpp>
@@ -4325,6 +4326,10 @@
free_share(m_share); m_share= 0;
DBUG_RETURN(HA_ERR_NO_CONNECTION);
}
+
+ pthread_mutex_lock(&m_share->mutex);
+ m_share->table= table;
+ pthread_mutex_unlock(&m_share->mutex);
res= get_metadata(name);
if (!res)
@@ -7367,8 +7372,12 @@
{
THD *thd; /* needs to be first for thread_stack */
int error= 0;
+ int i;
Ndb *ndb= 0;
longlong last_gci_in_binlog_index= 0;
+ injector *inj= injector::instance();
+ injector::transaction::table *tbl;
+ bitvector *b;
pthread_mutex_lock(&injector_startup_mutex);
/*
@@ -7421,6 +7430,11 @@
pthread_mutex_unlock(&injector_startup_mutex);
pthread_cond_signal(&injector_startup_cond);
+ {
+ /**
+ * We start off with a transaction
+ */
+ injector::transaction trans= inj->new_trans(thd);
/**
* Main NDB Injector loop
@@ -7479,9 +7493,16 @@
*/
add_binlog_index(thd, gci, "some file name from injector", (longlong)4321);
last_gci_in_binlog_index= gci;
+
+ /**
+ * Commit transaction, start a new one
+ */
+ trans.commit();
+ trans= inj->new_trans(thd);
+ DBUG_PRINT("info",("COMMIT gci %lld",gci));
}
- DBUG_PRINT("info",("EVENT TYPE:%d GCI:%lld",pOp->getEventType(),gci));
+ DBUG_PRINT("info",("EVENT TYPE:%d GCI:%lld, last: %lld",pOp->getEventType(),gci,last_gci_in_binlog_index));
const NDBTAB *table= pOp->getTable();
@@ -7501,40 +7522,56 @@
continue;
}
+ String db_tab(200);
+ db_tab.append("./");
+ db_tab.append(table->getMysqlName());
+ NDB_SHARE *share= get_share(db_tab.c_ptr());
+ byte* row_buf= new byte[share->table->s->rec_buff_length];
+ byte* field_buf= NULL;
+
String col_names(100);
- String col_data(100);
const NdbRecAttr *data= pOp->getFirstPkAttr();
- do
+
+ for(i=0; data; i++,data= data->next())
{
col_names.append(data->getColumn()->getName());
col_names.append(',');
- col_data.append("'");
- col_data.append(data->aRef(),data->arraySize()*data->attrSize());
- col_data.append("',");
+ // find offset in row_buf
+ field_buf= row_buf + (share->table->field[i]->ptr - share->table->record[0]);
+
+ memcpy(field_buf,data->aRef(),data->arraySize()*data->attrSize());
+
DBUG_PRINT("info",("Col:%s ref:%x attrSize:%d arraySize:%d",data->getColumn()->getName(),data->aRef(),data->attrSize(),data->arraySize()));
- } while((data= data->next())!=NULL);
+ }
data= pOp->getFirstDataAttr();
- do
+ for(; data; i++,data= data->next())
{
col_names.append(data->getColumn()->getName());
col_names.append(',');
- col_data.append("'");
- col_data.append(data->aRef(),data->arraySize());
- col_data.append("',");
+ // find offset in row_buf
+ field_buf= row_buf + (share->table->field[i]->ptr - share->table->record[0]);
+
+ memcpy(field_buf,data->aRef(),data->arraySize()*data->attrSize());
+
DBUG_PRINT("info",("Col:%s ref:%x attrSize:%d arraySize:%d",data->getColumn()->getName(),data->aRef(),data->attrSize(),data->arraySize()));
- } while((data= data->next())!=NULL);
+ }
col_names.chop();
- col_data.chop();
+
switch(pOp->getEventType())
{
case NdbDictionary::Event::TE_INSERT:
- DBUG_PRINT("info",("INSERT INTO %s (%s) values (%s)",table->getName(),col_names.c_ptr(),col_data.c_ptr()));
+ DBUG_PRINT("info",("INSERT INTO %s (%s)",table->getName(),col_names.c_ptr()));
+ tbl= new injector::transaction::table(share->table->s->db,table->getName());
+ b= new bitvector(i);
+ b->set_all();
+ trans.write_row(::server_id, *tbl, *b,row_buf);
+ delete b;
break;
case NdbDictionary::Event::TE_DELETE:
DBUG_PRINT("info",("DELETE FROM %s",table->getName()));
@@ -7554,6 +7591,7 @@
} // while
} // if
} // for(;;)
+ }
err:
sql_print_information("Stopping Cluster Replication");
/* don't mess with the injector_ndb anymore from other threads */
--- 1.81/sql/ha_ndbcluster.h 2005-03-18 17:59:35 +11:00
+++ 1.82/sql/ha_ndbcluster.h 2005-03-29 17:06:07 +10:00
@@ -67,6 +67,7 @@
ulonglong commit_count;
#ifdef HAVE_REPLICATION
NdbEventOperation *op;
+ TABLE *table;
#endif
} NDB_SHARE;
| Thread |
|---|
| • bk commit into 5.1 tree (stewart:1.1833) | Stewart Smith | 29 Mar |