Bug #25275 SINGLE USER MODE prevents ALTER on non-ndb tables for other mysqld nodes

parent 47f37fb3
...@@ -126,6 +126,8 @@ public: ...@@ -126,6 +126,8 @@ public:
MinRowsLow = 143, MinRowsLow = 143,
MinRowsHigh = 144, MinRowsHigh = 144,
SingleUserMode = 152,
TableEnd = 999, TableEnd = 999,
AttributeName = 1000, // String, Mandatory AttributeName = 1000, // String, Mandatory
...@@ -273,7 +275,8 @@ public: ...@@ -273,7 +275,8 @@ public:
Uint32 MaxRowsHigh; Uint32 MaxRowsHigh;
Uint32 MinRowsLow; Uint32 MinRowsLow;
Uint32 MinRowsHigh; Uint32 MinRowsHigh;
Uint32 SingleUserMode;
void init(); void init();
}; };
......
...@@ -68,4 +68,11 @@ ...@@ -68,4 +68,11 @@
#define NDB_TYPE_MAX 31 #define NDB_TYPE_MAX 31
/*
* Table single user mode
*/
#define NDB_SUM_LOCKED 0
#define NDB_SUM_READONLY 1
#define NDB_SUM_READ_WRITE 2
#endif #endif
...@@ -497,6 +497,15 @@ public: ...@@ -497,6 +497,15 @@ public:
*/ */
class Table : public Object { class Table : public Object {
public: public:
/*
* Single user mode specifies access rights to table during single user mode
*/
enum SingleUserMode {
SingleUserModeLocked = NDB_SUM_LOCKED,
SingleUserModeReadOnly = NDB_SUM_READONLY,
SingleUserModeReadWrite = NDB_SUM_READ_WRITE
};
/** /**
* @name General * @name General
* @{ * @{
...@@ -735,6 +744,13 @@ public: ...@@ -735,6 +744,13 @@ public:
void setMinRows(Uint64 minRows); void setMinRows(Uint64 minRows);
Uint64 getMinRows() const; Uint64 getMinRows() const;
/**
* Set/Get SingleUserMode
*/
void setSingleUserMode(enum SingleUserMode);
enum SingleUserMode getSingleUserMode() const;
/** @} *******************************************************************/ /** @} *******************************************************************/
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
......
...@@ -51,6 +51,7 @@ DictTabInfo::TableMapping[] = { ...@@ -51,6 +51,7 @@ DictTabInfo::TableMapping[] = {
DTIMAP(Table, MaxRowsHigh, MaxRowsHigh), DTIMAP(Table, MaxRowsHigh, MaxRowsHigh),
DTIMAP(Table, MinRowsLow, MinRowsLow), DTIMAP(Table, MinRowsLow, MinRowsLow),
DTIMAP(Table, MinRowsHigh, MinRowsHigh), DTIMAP(Table, MinRowsHigh, MinRowsHigh),
DTIMAP(Table, SingleUserMode, SingleUserMode),
DTIBREAK(AttributeName) DTIBREAK(AttributeName)
}; };
...@@ -131,6 +132,8 @@ DictTabInfo::Table::init(){ ...@@ -131,6 +132,8 @@ DictTabInfo::Table::init(){
MaxRowsHigh = 0; MaxRowsHigh = 0;
MinRowsLow = 0; MinRowsLow = 0;
MinRowsHigh = 0; MinRowsHigh = 0;
SingleUserMode = 0;
} }
void void
......
...@@ -289,7 +289,7 @@ Dbdict::packTableIntoPagesImpl(SimpleProperties::Writer & w, ...@@ -289,7 +289,7 @@ Dbdict::packTableIntoPagesImpl(SimpleProperties::Writer & w,
w.add(DictTabInfo::MaxRowsHigh, tablePtr.p->maxRowsHigh); w.add(DictTabInfo::MaxRowsHigh, tablePtr.p->maxRowsHigh);
w.add(DictTabInfo::MinRowsLow, tablePtr.p->minRowsLow); w.add(DictTabInfo::MinRowsLow, tablePtr.p->minRowsLow);
w.add(DictTabInfo::MinRowsHigh, tablePtr.p->minRowsHigh); w.add(DictTabInfo::MinRowsHigh, tablePtr.p->minRowsHigh);
w.add(DictTabInfo::SingleUserMode, tablePtr.p->singleUserMode);
if(!signal) if(!signal)
{ {
w.add(DictTabInfo::FragmentCount, tablePtr.p->fragmentCount); w.add(DictTabInfo::FragmentCount, tablePtr.p->fragmentCount);
...@@ -1500,6 +1500,7 @@ void Dbdict::initialiseTableRecord(TableRecordPtr tablePtr) ...@@ -1500,6 +1500,7 @@ void Dbdict::initialiseTableRecord(TableRecordPtr tablePtr)
tablePtr.p->maxRowsHigh = 0; tablePtr.p->maxRowsHigh = 0;
tablePtr.p->minRowsLow = 0; tablePtr.p->minRowsLow = 0;
tablePtr.p->minRowsHigh = 0; tablePtr.p->minRowsHigh = 0;
tablePtr.p->singleUserMode = 0;
tablePtr.p->storedTable = true; tablePtr.p->storedTable = true;
tablePtr.p->tableType = DictTabInfo::UserTable; tablePtr.p->tableType = DictTabInfo::UserTable;
tablePtr.p->primaryTableId = RNIL; tablePtr.p->primaryTableId = RNIL;
...@@ -4718,8 +4719,9 @@ Dbdict::execTAB_COMMITCONF(Signal* signal){ ...@@ -4718,8 +4719,9 @@ Dbdict::execTAB_COMMITCONF(Signal* signal){
signal->theData[4] = (Uint32)tabPtr.p->tableType; signal->theData[4] = (Uint32)tabPtr.p->tableType;
signal->theData[5] = createTabPtr.p->key; signal->theData[5] = createTabPtr.p->key;
signal->theData[6] = (Uint32)tabPtr.p->noOfPrimkey; signal->theData[6] = (Uint32)tabPtr.p->noOfPrimkey;
signal->theData[7] = (Uint32)tabPtr.p->singleUserMode;
sendSignal(DBTC_REF, GSN_TC_SCHVERREQ, signal, 7, JBB);
sendSignal(DBTC_REF, GSN_TC_SCHVERREQ, signal, 8, JBB);
return; return;
} }
...@@ -5084,6 +5086,7 @@ void Dbdict::handleTabInfoInit(SimpleProperties::Reader & it, ...@@ -5084,6 +5086,7 @@ void Dbdict::handleTabInfoInit(SimpleProperties::Reader & it,
tablePtr.p->maxRowsHigh = tableDesc.MaxRowsHigh; tablePtr.p->maxRowsHigh = tableDesc.MaxRowsHigh;
tablePtr.p->minRowsLow = tableDesc.MinRowsLow; tablePtr.p->minRowsLow = tableDesc.MinRowsLow;
tablePtr.p->minRowsHigh = tableDesc.MinRowsHigh; tablePtr.p->minRowsHigh = tableDesc.MinRowsHigh;
tablePtr.p->singleUserMode = tableDesc.SingleUserMode;
Uint64 maxRows = Uint64 maxRows =
(((Uint64)tablePtr.p->maxRowsHigh) << 32) + tablePtr.p->maxRowsLow; (((Uint64)tablePtr.p->maxRowsHigh) << 32) + tablePtr.p->maxRowsLow;
......
...@@ -237,6 +237,11 @@ public: ...@@ -237,6 +237,11 @@ public:
char frmData[MAX_FRM_DATA_SIZE]; char frmData[MAX_FRM_DATA_SIZE];
Uint32 fragmentCount; Uint32 fragmentCount;
/*
* Access rights to table during single user mode
*/
Uint8 singleUserMode;
}; };
typedef Ptr<TableRecord> TableRecordPtr; typedef Ptr<TableRecord> TableRecordPtr;
......
...@@ -702,6 +702,7 @@ public: ...@@ -702,6 +702,7 @@ public:
Uint8 tckeyrec; // ndrad frn R Uint8 tckeyrec; // ndrad frn R
Uint8 tcindxrec; Uint8 tcindxrec;
Uint8 apiFailState; // ndrad frn R Uint8 apiFailState; // ndrad frn R
Uint8 singleUserMode;
ReturnSignal returnsignal; ReturnSignal returnsignal;
Uint8 timeOutCounter; Uint8 timeOutCounter;
...@@ -957,17 +958,28 @@ public: ...@@ -957,17 +958,28 @@ public:
/********************************************************/ /********************************************************/
struct TableRecord { struct TableRecord {
Uint32 currentSchemaVersion; Uint32 currentSchemaVersion;
Uint8 enabled; Uint16 m_flags;
Uint8 dropping;
Uint8 tableType; Uint8 tableType;
Uint8 storedTable; Uint8 singleUserMode;
enum {
TR_ENABLED = 1 << 0,
TR_DROPPING = 1 << 1,
TR_STORED_TABLE = 1 << 2
};
Uint8 get_enabled() const { return (m_flags & TR_ENABLED) != 0; }
Uint8 get_dropping() const { return (m_flags & TR_DROPPING) != 0; }
Uint8 get_storedTable() const { return (m_flags & TR_STORED_TABLE) != 0; }
void set_enabled(Uint8 f) { f ? m_flags |= (Uint16)TR_ENABLED : m_flags &= ~(Uint16)TR_ENABLED; }
void set_dropping(Uint8 f) { f ? m_flags |= (Uint16)TR_DROPPING : m_flags &= ~(Uint16)TR_DROPPING; }
void set_storedTable(Uint8 f) { f ? m_flags |= (Uint16)TR_STORED_TABLE : m_flags &= ~(Uint16)TR_STORED_TABLE; }
Uint8 noOfKeyAttr; Uint8 noOfKeyAttr;
Uint8 hasCharAttr; Uint8 hasCharAttr;
Uint8 noOfDistrKeys; Uint8 noOfDistrKeys;
bool checkTable(Uint32 schemaVersion) const { bool checkTable(Uint32 schemaVersion) const {
return enabled && !dropping && return get_enabled() && !get_dropping() &&
(table_version_major(schemaVersion) == table_version_major(currentSchemaVersion)); (table_version_major(schemaVersion) == table_version_major(currentSchemaVersion));
} }
...@@ -1835,10 +1847,10 @@ private: ...@@ -1835,10 +1847,10 @@ private:
Uint32 transid2); Uint32 transid2);
void removeMarkerForFailedAPI(Signal* signal, Uint32 nodeId, Uint32 bucket); void removeMarkerForFailedAPI(Signal* signal, Uint32 nodeId, Uint32 bucket);
bool getAllowStartTransaction(Uint32 nodeId) const { bool getAllowStartTransaction(Uint32 nodeId, Uint32 table_single_user_mode) const {
if (unlikely(getNodeState().getSingleUserMode())) if (unlikely(getNodeState().getSingleUserMode()))
{ {
if (getNodeState().getSingleUserApi() == nodeId) if (getNodeState().getSingleUserApi() == nodeId || table_single_user_mode)
return true; return true;
else else
return false; return false;
......
This diff is collapsed.
...@@ -1645,6 +1645,7 @@ void Ndbcntr::createSystableLab(Signal* signal, unsigned index) ...@@ -1645,6 +1645,7 @@ void Ndbcntr::createSystableLab(Signal* signal, unsigned index)
//w.add(DictTabInfo::NoOfVariable, (Uint32)0); //w.add(DictTabInfo::NoOfVariable, (Uint32)0);
//w.add(DictTabInfo::KeyLength, 1); //w.add(DictTabInfo::KeyLength, 1);
w.add(DictTabInfo::TableTypeVal, (Uint32)table.tableType); w.add(DictTabInfo::TableTypeVal, (Uint32)table.tableType);
w.add(DictTabInfo::SingleUserMode, (Uint32)NDB_SUM_READ_WRITE);
for (unsigned i = 0; i < table.columnCount; i++) { for (unsigned i = 0; i < table.columnCount; i++) {
const SysColumn& column = table.columnList[i]; const SysColumn& column = table.columnList[i];
......
...@@ -430,6 +430,18 @@ NdbDictionary::Table::getFrmLength() const { ...@@ -430,6 +430,18 @@ NdbDictionary::Table::getFrmLength() const {
return m_impl.m_frm.length(); return m_impl.m_frm.length();
} }
enum NdbDictionary::Table::SingleUserMode
NdbDictionary::Table::getSingleUserMode() const
{
return (enum SingleUserMode)m_impl.m_single_user_mode;
}
void
NdbDictionary::Table::setSingleUserMode(enum NdbDictionary::Table::SingleUserMode mode)
{
m_impl.m_single_user_mode = (Uint8)mode;
}
void void
NdbDictionary::Table::setFrm(const void* data, Uint32 len){ NdbDictionary::Table::setFrm(const void* data, Uint32 len){
m_impl.m_frm.assign(data, len); m_impl.m_frm.assign(data, len);
......
...@@ -318,6 +318,7 @@ NdbTableImpl::init(){ ...@@ -318,6 +318,7 @@ NdbTableImpl::init(){
m_replicaCount= 0; m_replicaCount= 0;
m_min_rows = 0; m_min_rows = 0;
m_max_rows = 0; m_max_rows = 0;
m_single_user_mode = 0;
} }
bool bool
...@@ -378,6 +379,14 @@ NdbTableImpl::equal(const NdbTableImpl& obj) const ...@@ -378,6 +379,14 @@ NdbTableImpl::equal(const NdbTableImpl& obj) const
DBUG_RETURN(false); DBUG_RETURN(false);
} }
if(m_single_user_mode != obj.m_single_user_mode)
{
DBUG_PRINT("info",("m_single_user_mode %d != %d",
(int32)m_single_user_mode,
(int32)obj.m_single_user_mode));
DBUG_RETURN(false);
}
DBUG_RETURN(true); DBUG_RETURN(true);
} }
...@@ -403,7 +412,8 @@ NdbTableImpl::assign(const NdbTableImpl& org) ...@@ -403,7 +412,8 @@ NdbTableImpl::assign(const NdbTableImpl& org)
m_kvalue = org.m_kvalue; m_kvalue = org.m_kvalue;
m_minLoadFactor = org.m_minLoadFactor; m_minLoadFactor = org.m_minLoadFactor;
m_maxLoadFactor = org.m_maxLoadFactor; m_maxLoadFactor = org.m_maxLoadFactor;
m_single_user_mode = org.m_single_user_mode;
if (m_index != 0) if (m_index != 0)
delete m_index; delete m_index;
m_index = org.m_index; m_index = org.m_index;
...@@ -1191,6 +1201,7 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret, ...@@ -1191,6 +1201,7 @@ NdbDictInterface::parseTableInfo(NdbTableImpl ** ret,
impl->m_kvalue = tableDesc.TableKValue; impl->m_kvalue = tableDesc.TableKValue;
impl->m_minLoadFactor = tableDesc.MinLoadFactor; impl->m_minLoadFactor = tableDesc.MinLoadFactor;
impl->m_maxLoadFactor = tableDesc.MaxLoadFactor; impl->m_maxLoadFactor = tableDesc.MaxLoadFactor;
impl->m_single_user_mode = tableDesc.SingleUserMode;
impl->m_indexType = (NdbDictionary::Index::Type) impl->m_indexType = (NdbDictionary::Index::Type)
getApiConstant(tableDesc.TableType, getApiConstant(tableDesc.TableType,
...@@ -1519,12 +1530,14 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb, ...@@ -1519,12 +1530,14 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb,
tmpTab.MaxRowsLow = (Uint32)(impl.m_max_rows & 0xFFFFFFFF); tmpTab.MaxRowsLow = (Uint32)(impl.m_max_rows & 0xFFFFFFFF);
tmpTab.MinRowsHigh = (Uint32)(impl.m_min_rows >> 32); tmpTab.MinRowsHigh = (Uint32)(impl.m_min_rows >> 32);
tmpTab.MinRowsLow = (Uint32)(impl.m_min_rows & 0xFFFFFFFF); tmpTab.MinRowsLow = (Uint32)(impl.m_min_rows & 0xFFFFFFFF);
Uint64 maxRows = Uint64 maxRows =
(((Uint64)tmpTab.MaxRowsHigh) << 32) + tmpTab.MaxRowsLow; (((Uint64)tmpTab.MaxRowsHigh) << 32) + tmpTab.MaxRowsLow;
Uint64 minRows = Uint64 minRows =
(((Uint64)tmpTab.MinRowsHigh) << 32) + tmpTab.MinRowsLow; (((Uint64)tmpTab.MinRowsHigh) << 32) + tmpTab.MinRowsLow;
tmpTab.SingleUserMode = impl.m_single_user_mode;
tmpTab.FragmentType = getKernelConstant(impl.m_fragmentType, tmpTab.FragmentType = getKernelConstant(impl.m_fragmentType,
fragmentTypeMapping, fragmentTypeMapping,
DictTabInfo::AllNodesSmallTable); DictTabInfo::AllNodesSmallTable);
......
...@@ -138,6 +138,7 @@ public: ...@@ -138,6 +138,7 @@ public:
int m_maxLoadFactor; int m_maxLoadFactor;
Uint16 m_keyLenInWords; Uint16 m_keyLenInWords;
Uint16 m_fragmentCount; Uint16 m_fragmentCount;
Uint8 m_single_user_mode;
NdbDictionaryImpl * m_dictionary; NdbDictionaryImpl * m_dictionary;
NdbIndexImpl * m_index; NdbIndexImpl * m_index;
......
...@@ -31,7 +31,7 @@ operator <<(class NdbOut& ndbout, const NDBT_Table & tab) ...@@ -31,7 +31,7 @@ operator <<(class NdbOut& ndbout, const NDBT_Table & tab)
ndbout << "Number of attributes: " << tab.getNoOfColumns() << endl; ndbout << "Number of attributes: " << tab.getNoOfColumns() << endl;
ndbout << "Number of primary keys: " << tab.getNoOfPrimaryKeys() << endl; ndbout << "Number of primary keys: " << tab.getNoOfPrimaryKeys() << endl;
ndbout << "Length of frm data: " << tab.getFrmLength() << endl; ndbout << "Length of frm data: " << tab.getFrmLength() << endl;
ndbout << "SingleUserMode: " << tab.getSingleUserMode() << endl;
//<< ((tab.getTupleKey() == TupleId) ? " tupleid" : "") <<endl; //<< ((tab.getTupleKey() == TupleId) ? " tupleid" : "") <<endl;
ndbout << "TableStatus: "; ndbout << "TableStatus: ";
......
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