Below is the list of changes that have just been committed into a local
5.1 repository of frazer. When frazer 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@stripped, 2008-02-01 09:43:35+00:00, frazer@stripped +6 -0
WL4086 NdbRecord modifications
Remove ability to access pseudo columns via NdbRecord.
Prep for making NdbRecord always use ReadPacked.
sql/ha_ndbcluster.cc@stripped, 2008-02-01 09:43:28+00:00, frazer@stripped +44
-62
Change use of pseudo columns via NdbRecord to use extra GetValues API
sql/ha_ndbcluster.h@stripped, 2008-02-01 09:43:28+00:00, frazer@stripped +0 -5
Change use of pseudo columns via NdbRecord to use extra GetValues API
storage/ndb/include/ndbapi/NdbDictionary.hpp@stripped, 2008-02-01 09:43:29+00:00,
frazer@stripped +3 -0
Add comment about not using pseudo columns via NdbRecord
storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp@stripped, 2008-02-01 09:43:29+00:00,
frazer@stripped +9 -0
Add check that pseudo columns are not used via NdbRecord.
storage/ndb/src/ndbapi/NdbOperationExec.cpp@stripped, 2008-02-01 09:43:29+00:00,
frazer@stripped +8 -4
Extra assertions that pseudo columns are not used before column mask lookup.
storage/ndb/src/ndbapi/ndberror.c@stripped, 2008-02-01 09:43:30+00:00,
frazer@stripped +1 -0
New pseudo-column + NdbRecord error msg
diff -Nrup a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
--- a/sql/ha_ndbcluster.cc 2008-01-25 14:15:20 +00:00
+++ b/sql/ha_ndbcluster.cc 2008-02-01 09:43:28 +00:00
@@ -156,9 +156,7 @@ HASH ndbcluster_open_tables;
static uchar *ndbcluster_get_key(NDB_SHARE *share, size_t *length,
my_bool not_used __attribute__((unused)));
-static
-NdbRecord *
-ndb_get_table_statistics_ndbrecord(NDBDICT *, const NDBTAB *);
+
static int ndb_get_table_statistics(ha_ndbcluster*, bool, Ndb*, const NDBTAB *,
struct Ndb_statistics *);
static int ndb_get_table_statistics(ha_ndbcluster*, bool, Ndb*,
@@ -735,7 +733,7 @@ ha_rows ha_ndbcluster::records()
Ndb *ndb= get_ndb();
ndb->setDatabaseName(m_dbname);
struct Ndb_statistics stat;
- if (ndb_get_table_statistics(this, TRUE, ndb, m_ndb_statistics_record,
+ if (ndb_get_table_statistics(this, TRUE, ndb, m_ndb_record,
&stat) == 0)
{
retval= stat.row_count;
@@ -770,7 +768,7 @@ int ha_ndbcluster::records_update()
{
return my_errno= HA_ERR_OUT_OF_MEM;
}
- result= ndb_get_table_statistics(this, TRUE, ndb, m_ndb_statistics_record,
+ result= ndb_get_table_statistics(this, TRUE, ndb, m_ndb_record,
&stat);
if (result == 0)
{
@@ -1727,11 +1725,6 @@ ha_ndbcluster::add_table_ndb_record(NDBD
ERR_RETURN(dict->getNdbError());
m_ndb_record= rec;
- rec= ndb_get_table_statistics_ndbrecord(dict, m_table);
- if (! rec)
- ERR_RETURN(dict->getNdbError());
- m_ndb_statistics_record= rec;
-
DBUG_RETURN(0);
}
@@ -2101,11 +2094,6 @@ void ha_ndbcluster::release_metadata(THD
dict->releaseRecord(m_ndb_hidden_key_record);
m_ndb_hidden_key_record= NULL;
}
- if (m_ndb_statistics_record != NULL)
- {
- dict->releaseRecord(m_ndb_statistics_record);
- m_ndb_statistics_record= NULL;
- }
if (m_table->getObjectStatus() == NdbDictionary::Object::Invalid)
invalidate_indexes= 1;
dict->removeTableGlobal(*m_table, invalidate_indexes);
@@ -4825,7 +4813,7 @@ int ha_ndbcluster::info(uint flag)
}
if (current_thd->variables.ndb_use_exact_count &&
(result= ndb_get_table_statistics
- (this, TRUE, ndb, m_ndb_statistics_record, &stat)) == 0)
+ (this, TRUE, ndb, m_ndb_record, &stat)) == 0)
{
stats.mean_rec_length= stat.row_size;
stats.data_file_length= stat.fragment_memory;
@@ -7393,7 +7381,6 @@ ha_ndbcluster::ha_ndbcluster(handlerton
m_key_fields(NULL),
m_ndb_record(0),
m_ndb_hidden_key_record(0),
- m_ndb_statistics_record(0),
m_dupkey((uint) -1),
m_ha_not_exact_count(FALSE),
m_autoincrement_prefetch((ha_rows) 32),
@@ -7615,7 +7602,7 @@ int ha_ndbcluster::open(const char *name
break;
}
struct Ndb_statistics stat;
- res= ndb_get_table_statistics(NULL, FALSE, ndb, m_ndb_statistics_record,
+ res= ndb_get_table_statistics(NULL, FALSE, ndb, m_ndb_record,
&stat);
stats.mean_rec_length= stat.row_size;
stats.data_file_length= stat.fragment_memory;
@@ -9012,7 +8999,7 @@ ha_ndbcluster::records_in_range(uint inx
{
Ndb_statistics stat;
if ((res=ndb_get_table_statistics(this, TRUE, ndb,
- m_ndb_statistics_record, &stat)))
+ m_ndb_record, &stat)))
break;
table_rows=stat.row_count;
DBUG_PRINT("info", ("use db row_count: %lu", (ulong) table_rows));
@@ -9849,36 +9836,7 @@ struct ndb_table_statistics_row {
Uint64 var_mem;
};
-static
-NdbRecord *
-ndb_get_table_statistics_ndbrecord(NDBDICT *dict, const NDBTAB *table)
-{
- NdbDictionary::RecordSpecification spec[5];
- spec[0].column= NdbDictionary::Column::ROW_COUNT;
- spec[0].offset= offsetof(struct ndb_table_statistics_row, rows);
- spec[0].nullbit_byte_offset= 0;
- spec[0].nullbit_bit_in_byte= 0;
- spec[1].column= NdbDictionary::Column::COMMIT_COUNT;
- spec[1].offset= offsetof(struct ndb_table_statistics_row, commits);
- spec[1].nullbit_byte_offset= 0;
- spec[1].nullbit_bit_in_byte= 0;
- spec[2].column= NdbDictionary::Column::ROW_SIZE;
- spec[2].offset= offsetof(struct ndb_table_statistics_row, size);
- spec[2].nullbit_byte_offset= 0;
- spec[2].nullbit_bit_in_byte= 0;
- spec[3].column= NdbDictionary::Column::FRAGMENT_FIXED_MEMORY;
- spec[3].offset= offsetof(struct ndb_table_statistics_row, fixed_mem);
- spec[3].nullbit_byte_offset= 0;
- spec[3].nullbit_bit_in_byte= 0;
- spec[4].column= NdbDictionary::Column::FRAGMENT_VARSIZED_MEMORY;
- spec[4].offset= offsetof(struct ndb_table_statistics_row, var_mem);
- spec[4].nullbit_byte_offset= 0;
- spec[4].nullbit_bit_in_byte= 0;
-
- return dict->createRecord(table, spec,
- sizeof(spec)/sizeof(spec[0]), sizeof(spec[0]), 0);
-}
-
+/* Fetch statistics for table referred to by NdbRecord passed in */
static
int
ndb_get_table_statistics(ha_ndbcluster* file, bool report_error, Ndb* ndb,
@@ -9891,7 +9849,14 @@ ndb_get_table_statistics(ha_ndbcluster*
int retries= 10;
int reterr= 0;
int retry_sleep= 30 * 1000; /* 30 milliseconds */
- const char *row;
+ const char *dummyRowPtr;
+ const Uint32 extraCols= 5;
+ NdbOperation::GetValueSpec extraGets[extraCols];
+ Uint64 rows, commits, fixed_mem, var_mem;
+ Uint32 size;
+ // TODO : Provide an empty mask for NdbRecord users in general
+ const Uint32 emptyMask[ (NDB_MAX_ATTRIBUTES_IN_TABLE + 31) >> 5]
+ = {0, 0, 0, 0 };
#ifndef DBUG_OFF
char buff[22], buff2[22], buff3[22], buff4[22];
#endif
@@ -9899,6 +9864,22 @@ ndb_get_table_statistics(ha_ndbcluster*
DBUG_ASSERT(record != 0);
+ /* We use the passed in NdbRecord just to get access to the
+ table, we mask out any/all columns it may have and add
+ our reads as extraGets. This is necessary as they are
+ all pseudo-columns
+ */
+ extraGets[0].column= NdbDictionary::Column::ROW_COUNT;
+ extraGets[0].appStorage= &rows;
+ extraGets[1].column= NdbDictionary::Column::COMMIT_COUNT;
+ extraGets[1].appStorage= &commits;
+ extraGets[2].column= NdbDictionary::Column::ROW_SIZE;
+ extraGets[2].appStorage= &size;
+ extraGets[3].column= NdbDictionary::Column::FRAGMENT_FIXED_MEMORY;
+ extraGets[3].appStorage= &fixed_mem;
+ extraGets[4].column= NdbDictionary::Column::FRAGMENT_VARSIZED_MEMORY;
+ extraGets[4].appStorage= &var_mem;
+
const Uint32 codeWords= 1;
Uint32 codeSpace[ codeWords ];
NdbInterpretedCode code(NULL, // Table is irrelevant
@@ -9931,13 +9912,16 @@ ndb_get_table_statistics(ha_ndbcluster*
NdbScanOperation::ScanOptions options;
options.optionsPresent= NdbScanOperation::ScanOptions::SO_BATCH |
+ NdbScanOperation::ScanOptions::SO_GETVALUE |
NdbScanOperation::ScanOptions::SO_INTERPRETED;
/* Set batch_size=1, as we need only one row per fragment. */
options.batch= 1;
+ options.extraGetValues= &extraGets[0];
+ options.numExtraGetValues= extraCols;
options.interpretedCode= &code;
if ((pOp= pTrans->scanTable(record, NdbOperation::LM_CommittedRead,
- NULL,
+ (unsigned char*) &emptyMask,
&options,
sizeof(NdbScanOperation::ScanOptions))) == NULL)
{
@@ -9954,16 +9938,13 @@ ndb_get_table_statistics(ha_ndbcluster*
goto retry;
}
- while ((check= pOp->nextResult(&row, TRUE, TRUE)) == 0)
+ while ((check= pOp->nextResult(&dummyRowPtr, TRUE, TRUE)) == 0)
{
- /* NDB API ensures proper alignment of rows to make the cast valid. */
- const ndb_table_statistics_row *stat=
- (const ndb_table_statistics_row *)row;
- sum_rows+= stat->rows;
- sum_commits+= stat->commits;
- if (sum_row_size < stat->size)
- sum_row_size= stat->size;
- sum_mem+= stat->fixed_mem + stat->var_mem;
+ sum_rows+= rows;
+ sum_commits+= commits;
+ if (sum_row_size < size)
+ sum_row_size= size;
+ sum_mem+= fixed_mem + var_mem;
count++;
}
@@ -10027,8 +10008,9 @@ retry:
/*
Query cache stuff still call this NdbRecAttr-based version, as they
- have no easy access to a pre-computed NdbRecord for the table. Could be
- fixed to also use the NdbRecord version.
+ have no easy access to a pre-computed NdbRecord for the table.
+ When a pre-computed NdbRecord is available in the table share / or
+ from the NdbDictionary, this version could be removed.
*/
static
int
diff -Nrup a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h
--- a/sql/ha_ndbcluster.h 2008-01-25 14:12:57 +00:00
+++ b/sql/ha_ndbcluster.h 2008-02-01 09:43:28 +00:00
@@ -706,11 +706,6 @@ private:
/* NdbRecord for accessing tuple by hidden Uint64 primary key. */
NdbRecord *m_ndb_hidden_key_record;
- /*
- Special NdbRecord for ndb_get_table_statistics(), reading lots of
- pseudo-columns.
- */
- NdbRecord *m_ndb_statistics_record;
/* Bitmap used for NdbRecord operation column mask. */
MY_BITMAP m_bitmap;
my_bitmap_map m_bitmap_buf[(NDB_MAX_ATTRIBUTES_IN_TABLE +
diff -Nrup a/storage/ndb/include/ndbapi/NdbDictionary.hpp
b/storage/ndb/include/ndbapi/NdbDictionary.hpp
--- a/storage/ndb/include/ndbapi/NdbDictionary.hpp 2008-01-14 12:54:37 +00:00
+++ b/storage/ndb/include/ndbapi/NdbDictionary.hpp 2008-02-01 09:43:29 +00:00
@@ -1492,6 +1492,9 @@ public:
Note that even when creating an NdbRecord for an index, the column
pointers must be to columns obtained from the underlying table, not
from the index itself.
+ Note that pseudo columns cannot be used as part of a RecordSpecification.
+ To read pesudo column values, use the extra get value and set value
+ APIs.
*/
const Column *column;
/*
diff -Nrup a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp
b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp
--- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp 2008-01-14 12:55:01 +00:00
+++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp 2008-02-01 09:43:29 +00:00
@@ -5221,6 +5221,14 @@ NdbDictionaryImpl::initialiseColumnData(
m_error.code= 4290;
return -1;
}
+
+ if (col->m_attrId & AttributeHeader::PSEUDO)
+ {
+ /* Pseudo columns not supported by NdbRecord */
+ m_error.code= 4540;
+ return -1;
+ }
+
NdbRecord::Attr *recCol= &rec->columns[colNum];
recCol->attrId= col->m_attrId;
recCol->column_no= col->m_column_no;
@@ -6198,3 +6206,4 @@ const NdbDictionary::Column * NdbDiction
const NdbDictionary::Column * NdbDictionary::Column::ROW_GCI = 0;
const NdbDictionary::Column * NdbDictionary::Column::ANY_VALUE = 0;
const NdbDictionary::Column * NdbDictionary::Column::COPY_ROWID = 0;
+
diff -Nrup a/storage/ndb/src/ndbapi/NdbOperationExec.cpp
b/storage/ndb/src/ndbapi/NdbOperationExec.cpp
--- a/storage/ndb/src/ndbapi/NdbOperationExec.cpp 2008-01-17 08:48:19 +00:00
+++ b/storage/ndb/src/ndbapi/NdbOperationExec.cpp 2008-02-01 09:43:29 +00:00
@@ -751,8 +751,10 @@ NdbOperation::buildSignalsNdbRecord(Uint
col= &attr_rec->columns[i];
Uint32 attrId= col->attrId;
- if (!(attrId & AttributeHeader::PSEUDO) &&
- !BitmaskImpl::get((NDB_MAX_ATTRIBUTES_IN_TABLE+31)>>5,
+ /* Pseudo columns not allowed for NdbRecord */
+ assert(! (attrId & AttributeHeader::PSEUDO));
+
+ if (!BitmaskImpl::get((NDB_MAX_ATTRIBUTES_IN_TABLE+31)>>5,
m_read_mask, attrId))
continue;
@@ -832,8 +834,10 @@ NdbOperation::buildSignalsNdbRecord(Uint
col= &attr_rec->columns[i];
Uint32 attrId= col->attrId;
- if (!(attrId & AttributeHeader::PSEUDO) &&
- !BitmaskImpl::get((NDB_MAX_ATTRIBUTES_IN_TABLE+31)>>5,
+ /* Pseudo columns not allowed for NdbRecord */
+ assert(! (attrId & AttributeHeader::PSEUDO));
+
+ if (!BitmaskImpl::get((NDB_MAX_ATTRIBUTES_IN_TABLE+31)>>5,
m_read_mask, attrId))
continue;
diff -Nrup a/storage/ndb/src/ndbapi/ndberror.c b/storage/ndb/src/ndbapi/ndberror.c
--- a/storage/ndb/src/ndbapi/ndberror.c 2008-01-14 12:55:29 +00:00
+++ b/storage/ndb/src/ndbapi/ndberror.c 2008-02-01 09:43:30 +00:00
@@ -574,6 +574,7 @@ ErrorBundle ErrorCodes[] = {
{ 4537, DMEC, AE, "Wrong API. Use NdbInterpretedCode for NdbRecord operations" },
{ 4538, DMEC, AE, "NdbInterpretedCode instruction requires that table is set" },
{ 4539, DMEC, AE, "NdbInterpretedCode not supported for operation type" },
+ { 4540, DMEC, AE, "Pseudo columns not supported by NdbRecord" },
{ 4200, DMEC, AE, "Status Error when defining an operation" },
{ 4201, DMEC, AE, "Variable Arrays not yet supported" },
| Thread |
|---|
| • bk commit into 5.1 tree (frazer:1.2643) | Frazer Clement | 4 Feb |