List:Commits« Previous MessageNext Message »
From:U-ROWVWADEjas Date:April 22 2008 9:46pm
Subject:bk commit into 6.0 tree (jas:1.2636)
View as plain text  
Below is the list of changes that have just been committed into a local
6.0 repository of jas.  When jas 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-04-22 15:46:19-04:00, jas@rowvwade. +10 -0
  Relaxed the assumption that logical and physical fields are 
  one to one and colinear to support online add/drop field.

  storage/falcon/Format.cpp@stripped, 2008-04-22 15:46:05-04:00, jas@rowvwade. +23 -16
    Do a little more accounting in the Format object to support
    a map from physical field to the logical field.  This is
    necessary to support the general case of online add/drop
    field.

  storage/falcon/Format.h@stripped, 2008-04-22 15:46:05-04:00, jas@rowvwade. +2 -1
    Do a little more accounting in the Format object to support
    a map from physical field to the logical field.  This is
    necessary to support the general case of online add/drop
    field.

  storage/falcon/Record.cpp@stripped, 2008-04-22 15:46:06-04:00, jas@rowvwade. +6 -6
    Change name of Format::index to Format::physicalId in the interest of
    minimizing long term confusion.

  storage/falcon/StorageTable.cpp@stripped, 2008-04-22 15:46:06-04:00, jas@rowvwade. +1 -0
    Track the format of the current record in StorageTable.

  storage/falcon/StorageTable.h@stripped, 2008-04-22 15:46:06-04:00, jas@rowvwade. +2 -0
    Track the format of the current record in StorageTable.

  storage/falcon/StorageTableShare.cpp@stripped, 2008-04-22 15:46:07-04:00, jas@rowvwade. +16
-0
    Track the format of the current record in StorageTable.

  storage/falcon/StorageTableShare.h@stripped, 2008-04-22 15:46:07-04:00, jas@rowvwade. +3 -0
    Track the format of the current record in StorageTable.

  storage/falcon/Table.cpp@stripped, 2008-04-22 15:46:08-04:00, jas@rowvwade. +17 -14
    Stylistic edit for consistency.

  storage/falcon/ha_falcon.cpp@stripped, 2008-04-22 15:46:08-04:00, jas@rowvwade. +62 -10
    Relaxed the assumption that logical and physical fields are 
    one to one and colinear to support online add/drop field.

  storage/falcon/ha_falcon.h@stripped, 2008-04-22 15:46:08-04:00, jas@rowvwade. +3 -0
    Relaxed the assumption that logical and physical fields are 
    one to one and colinear to support online add/drop field.

diff -Nrup a/storage/falcon/Format.cpp b/storage/falcon/Format.cpp
--- a/storage/falcon/Format.cpp	2008-03-03 13:40:14 -05:00
+++ b/storage/falcon/Format.cpp	2008-04-22 15:46:05 -04:00
@@ -51,8 +51,8 @@ Format::Format(Table *tbl, int newVersio
 		++count;
 	END_FOR;
 
-	format = new FieldFormat [++maxId];
-	memset (format, 0, sizeof (struct FieldFormat) * maxId);
+	format = new FieldFormat[++maxId];
+	memset(format, 0, sizeof (struct FieldFormat) * maxId);
 	int offset = sizeof (short) + (count + 7) / 8;
 	int index = 0;
 	//printf ("Table %s.%s\n", table->schemaName, table->name);
@@ -66,7 +66,8 @@ Format::Format(Table *tbl, int newVersio
 		ff->offset = offset;
 		ff->length = field->getPhysicalLength();
 		ff->scale = field->scale;
-		ff->index = index++;
+		format[index].fieldId = id;
+		ff->physicalId = index++;
 		//printf ("  %s offset %d, length %d\n", field->name, ff->offset, ff->length);
 		offset += ff->length;			
 	END_FOR;
@@ -84,7 +85,7 @@ Format::Format(Table *tbl, int newVersio
 	length = offset;
 }
 
-Format::Format(Table *tbl, ResultSet * resultSet)
+Format::Format(Table *tbl, ResultSet *resultSet)
 {
 	table = tbl;
 	format = NULL;
@@ -92,37 +93,43 @@ Format::Format(Table *tbl, ResultSet * r
 
 	while (resultSet->next())
 		{
-		int id = resultSet->getInt (2);
+		int id = resultSet->getInt(2);
 
 		if (!format)
 			{
-			maxId = resultSet->getInt (7);
-			format = new FieldFormat [maxId];
-			memset (format, 0, sizeof (struct FieldFormat) * maxId);
-			version = resultSet->getInt (1);
+			maxId = resultSet->getInt(7);
+			format = new FieldFormat[maxId];
+			memset(format, 0, sizeof (struct FieldFormat) * maxId);
+			version = resultSet->getInt(1);
 			}
 
 		FieldFormat *ff = format + id;
-		ff->type = (Type) resultSet->getInt (3);
-		ff->offset = resultSet->getInt (4);
-		ff->length = resultSet->getInt (5);
-		ff->scale = (short) resultSet->getInt (6);
+		ff->type = (Type) resultSet->getInt(3);
+		ff->offset = resultSet->getInt(4);
+		ff->length = resultSet->getInt(5);
+		ff->scale = (short) resultSet->getInt(6);
 		}
 
+	int n;
+	
+	for (n = 0; n < maxId; ++n)
+		format[n].fieldId = -1;
+
 	ASSERT (format != NULL);
 	length = 0;
 	int position = 0;
 	count = 0;
 
-	for (int n = 0; n < maxId; ++n)
+	for (n = 0; n < maxId; ++n)
 		{
 		FieldFormat *ff = format + n;
 
 		if (ff->offset != 0)
 			{
 			ff->nullPosition = position++;
-			length = MAX (length, ff->offset + ff->length);
-			ff->index = count++;
+			length = MAX(length, ff->offset + ff->length);
+			format[count].fieldId = n;
+			ff->physicalId = count++;
 			}
 		}
 }
diff -Nrup a/storage/falcon/Format.h b/storage/falcon/Format.h
--- a/storage/falcon/Format.h	2007-09-25 01:14:41 -04:00
+++ b/storage/falcon/Format.h	2008-04-22 15:46:05 -04:00
@@ -31,7 +31,8 @@ struct FieldFormat {
 	short	type;
 	short	nullPosition;
 	short	scale;
-	short	index;
+	short	physicalId;				// mapping from field id to physical id
+	short	fieldId;				// maping from physical id to field id
     int32	offset;
 	int32	length;
 	};
diff -Nrup a/storage/falcon/Record.cpp b/storage/falcon/Record.cpp
--- a/storage/falcon/Record.cpp	2008-04-09 10:51:44 -04:00
+++ b/storage/falcon/Record.cpp	2008-04-22 15:46:06 -04:00
@@ -180,7 +180,7 @@ void Record::setValue(Transaction * tran
 			data.record = (char*) NEW Value[format->count];
 			encoding = valueVector;
 		case valueVector:
-			((Value*) data.record)[format->format[id].index].setValue(value, copyFlag);
+			((Value*) data.record)[format->format[id].physicalId].setValue(value, copyFlag);
 			return;
 
 		case traditional:
@@ -364,7 +364,7 @@ void Record::getRawValue(int fieldId, Va
 			return;
 
 		case valueVector:
-			value->setValue(((Value*) data.record) + format->format[fieldId].index, false);
+			value->setValue(((Value*) data.record) + format->format[fieldId].physicalId,
false);
 			return;
 
 		case traditional:
@@ -630,7 +630,7 @@ void Record::getEncodedValue(int fieldId
 		{
 		case shortVector:
 			{
-			int index = format->format[fieldId].index;
+			int index = format->format[fieldId].physicalId;
 			USHORT *vector = (USHORT*) data.record;
 
 			if (highWater < index)
@@ -676,7 +676,7 @@ void Record::finalize(Transaction *trans
 		if (fld->offset == 0)
 			continue;
 
-		Value *value = values + fld->index;
+		Value *value = values + fld->physicalId;
 		encodedStream.encode(fld->type, value);
 		}
 
@@ -778,7 +778,7 @@ bool Record::isNull(int fieldId)
 		{
 		case shortVector:
 			{
-			int index = format->format[fieldId].index;
+			int index = format->format[fieldId].physicalId;
 			USHORT *vector = (USHORT*) data.record;
 
 			if (highWater < index)
@@ -799,7 +799,7 @@ bool Record::isNull(int fieldId)
 			}
 
 		case valueVector:
-			return ((Value**) data.record)[format->format[fieldId].index]->isNull();
+			return ((Value**) data.record)[format->format[fieldId].physicalId]->isNull();
 
 		case traditional:
 			{
diff -Nrup a/storage/falcon/StorageTable.cpp b/storage/falcon/StorageTable.cpp
--- a/storage/falcon/StorageTable.cpp	2008-04-21 12:27:05 -04:00
+++ b/storage/falcon/StorageTable.cpp	2008-04-22 15:46:06 -04:00
@@ -311,6 +311,7 @@ void StorageTable::setRecord(Record* new
 	
 	record = newRecord;
 	recordLocked = locked;
+	format = record->format;
 	
 	// The following is confusing because Record::getEncodeRecord returns pointer to
 	// the actual data fields while Record::getEncodedSize return length of the data fields
plus
diff -Nrup a/storage/falcon/StorageTable.h b/storage/falcon/StorageTable.h
--- a/storage/falcon/StorageTable.h	2008-04-21 12:27:06 -04:00
+++ b/storage/falcon/StorageTable.h	2008-04-22 15:46:06 -04:00
@@ -46,6 +46,7 @@ class StorageDatabase;
 class Index;
 class Record;
 class SyncObject;
+class Format;
 
 struct StorageIndexDesc;
 
@@ -118,6 +119,7 @@ public:
 	StorageKey			*lowerBound;
 	StorageKey			*upperBound;
 	Record				*record;
+	Format				*format;
 	EncodedDataStream	dataStream;
 	Stream				insertStream;
 	int					searchFlags;
diff -Nrup a/storage/falcon/StorageTableShare.cpp b/storage/falcon/StorageTableShare.cpp
--- a/storage/falcon/StorageTableShare.cpp	2008-04-21 15:41:22 -04:00
+++ b/storage/falcon/StorageTableShare.cpp	2008-04-22 15:46:07 -04:00
@@ -25,6 +25,7 @@
 #include "Sequence.h"
 #include "Index.h"
 #include "Table.h"
+#include "Field.h"
 #include "Interlock.h"
 #include "CollationManager.h"
 #include "MySQLCollation.h"
@@ -113,6 +114,7 @@ int StorageTableShare::open(void)
 	if (!table)
 		{
 		table = storageDatabase->findTable(name, schemaName);
+		format = table->getCurrentFormat();
 		sequence = storageDatabase->findSequence(name, schemaName);
 		}
 	
@@ -127,6 +129,8 @@ int StorageTableShare::create(StorageCon
 	if (!(table = storageDatabase->createTable(storageConnection, name, schemaName, sql,
autoIncrementValue)))
 		return StorageErrorTableExits;
 	
+	format = table->getCurrentFormat();
+
 	if (autoIncrementValue)
 		sequence = storageDatabase->findSequence(name, schemaName);
 		
@@ -137,6 +141,8 @@ int StorageTableShare::upgrade(StorageCo
 {
 	if (!(table = storageDatabase->upgradeTable(storageConnection, name, schemaName, sql,
autoIncrementValue)))
 		return StorageErrorTableExits;
+
+	format = table->getCurrentFormat();
 	
 	if (autoIncrementValue)
 		sequence = storageDatabase->findSequence(name, schemaName);
@@ -554,4 +560,14 @@ void StorageTableShare::clearTruncateLoc
 		syncTruncate->unlock();
 //		syncTruncate->unlock(NULL, Shared);
 		}
+}
+
+int StorageTableShare::getFieldId(const char* fieldName)
+{
+	Field *field = table->findField(fieldName);
+	
+	if (!field)
+		return -1;
+	
+	return field->id;
 }
diff -Nrup a/storage/falcon/StorageTableShare.h b/storage/falcon/StorageTableShare.h
--- a/storage/falcon/StorageTableShare.h	2008-04-21 12:27:06 -04:00
+++ b/storage/falcon/StorageTableShare.h	2008-04-22 15:46:07 -04:00
@@ -35,6 +35,7 @@ class Index;
 class SyncObject;
 class Sequence;
 class SyncObject;
+class Format;
 
 struct StorageSegment {
 	short			type;
@@ -145,9 +146,11 @@ public:
 	Table				*table;
 	StorageIndexDesc	**indexes;
 	Sequence			*sequence;
+	Format				*format;						// format for insertion
 	int					numberIndexes;
 	volatile INTERLOCK_TYPE	truncateLockCount;
 	bool				tempTable;
+	int getFieldId(const char* fieldName);
 };
 
 #endif
diff -Nrup a/storage/falcon/Table.cpp b/storage/falcon/Table.cpp
--- a/storage/falcon/Table.cpp	2008-04-21 15:05:45 -04:00
+++ b/storage/falcon/Table.cpp	2008-04-22 15:46:08 -04:00
@@ -1208,20 +1208,23 @@ void Table::updateIndexes(Transaction *t
 **/
 void Table::insertIndexes(Transaction *transaction, RecordVersion *record)
 {
-	if (indexes)
-	{
-	FOR_INDEXES(index, this);
-		Sync sync(&(index->syncUnique), "Table::insertIndexes");
-		if(needUniqueCheck(index,record))
-			for(;;)
-			{
-			sync.lock(Exclusive);
-			if(!checkUniqueIndex(index, transaction, record, &sync))
-				break;
-			}
-		index->insert(record, transaction);
-	END_FOR;
-	}
+    if (indexes)
+		{
+		FOR_INDEXES(index, this);
+			Sync sync(&index->syncUnique, "Table::insertIndexes");
+			
+			if (needUniqueCheck(index,record))
+				for(;;)
+					{
+					sync.lock(Exclusive);
+					
+					if(!checkUniqueIndex(index, transaction, record, &sync))
+						break;
+					}
+				
+			index->insert(record, transaction);
+		END_FOR;
+		}
 }
 
 
diff -Nrup a/storage/falcon/ha_falcon.cpp b/storage/falcon/ha_falcon.cpp
--- a/storage/falcon/ha_falcon.cpp	2008-04-21 15:28:47 -04:00
+++ b/storage/falcon/ha_falcon.cpp	2008-04-22 15:46:08 -04:00
@@ -33,6 +33,7 @@
 #include "StorageHandler.h"
 #include "CmdGen.h"
 #include "InfoTable.h"
+#include "Format.h"
 
 #ifdef _WIN32
 #define I64FORMAT			"%I64d"
@@ -398,7 +399,8 @@ StorageInterface::StorageInterface(handl
 	activeBlobs = NULL;
 	freeBlobs = NULL;
 	errorText = NULL;
-
+	fieldMap = NULL;
+	
 	if (table_arg)
 		{
 		recordLength = table_arg->reclength;
@@ -435,7 +437,7 @@ StorageInterface::~StorageInterface(void
 		storageConnection = NULL;
 		}
 
-	//delete [] dbName;
+	delete [] fieldMap;
 }
 
 int StorageInterface::rnd_init(bool scan)
@@ -505,6 +507,10 @@ int StorageInterface::open(const char *n
 	thr_lock_data_init((THR_LOCK *)storageShare->impure, &lockData, NULL);
 
 	ret = setIndexes();
+	
+	if (table)
+		mapFields(table);
+	
 	if (ret)
 		DBUG_RETURN(error(ret));
 
@@ -824,6 +830,8 @@ int StorageInterface::create(const char 
 				DBUG_RETURN(error(ret));
 				}
 
+	mapFields(form);
+
 	DBUG_RETURN(0);
 }
 
@@ -1875,7 +1883,9 @@ int StorageInterface::external_lock(THD 
 			default:
 				break;
 			}
+			
 		int isolation = getTransactionIsolation(thd);
+		
 		if (thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
 			{
 			checkBinLog();
@@ -2051,8 +2061,6 @@ int StorageInterface::check_if_supported
 		
 		if (!field)
 			field = altered_table->field[altered_table->s->fields - 1];
-		else
-			DBUG_RETURN(HA_ALTER_NOT_SUPPORTED);	// temporary until field skipping gets
implemented
 		
 		if (!field->real_maybe_null())
 			DBUG_RETURN(HA_ALTER_NOT_SUPPORTED);
@@ -2382,11 +2390,23 @@ void StorageInterface::encodeRecord(ucha
 	my_ptrdiff_t ptrDiff = buf - table->record[0];
 	my_bitmap_map *old_map = dbug_tmp_use_all_columns(table, table->read_set);
 	EncodedDataStream *dataStream = &storageTable->dataStream;
+	FieldFormat *fieldFormat = storageShare->format->format;
+	int maxId = storageShare->format->maxId;
 	
-	for (uint n = 0; n < table->s->fields; ++n)
+	for (int n = 0; n < maxId; ++n, ++fieldFormat)
 		{
-		Field *field = table->field[n];
+		if (fieldFormat->fieldId < 0 || fieldFormat->offset == 0)
+			continue;
+			
+		Field *field = fieldMap[fieldFormat->fieldId];
 
+		if (!field)
+			{
+			dataStream->encodeNull();
+			
+			continue;
+			}
+		
 		if (ptrDiff)
 			field->move_field_offset(ptrDiff);
 
@@ -2544,12 +2564,24 @@ void StorageInterface::decodeRecord(ucha
 	my_ptrdiff_t ptrDiff = buf - table->record[0];
 	my_bitmap_map *old_map = dbug_tmp_use_all_columns(table, table->write_set);
 	DBUG_ENTER("StorageInterface::decodeRecord");
-
-	for (uint n = 0; n < table->s->fields; ++n)
+	FieldFormat *fieldFormat = storageTable->format->format;
+	int maxId = storageTable->format->maxId;
+	
+	for (int n = 0; n < maxId; ++n, ++fieldFormat)
 		{
-		Field *field = table->field[n];
+		// If the format doesn't have an offset, the field doesn't exist in the record
+		
+		if (fieldFormat->fieldId < 0 || fieldFormat->offset == 0)
+			continue;
+			
 		dataStream->decode();
+		Field *field = fieldMap[fieldFormat->fieldId];
 
+		// If we don't a field for the physical field, just skip over it and don't worrry.
+		
+		if (field == NULL)
+			continue;
+				
 		if (ptrDiff)
 			field->move_field_offset(ptrDiff);
 
@@ -3340,17 +3372,37 @@ int StorageInterface::recover (handlerto
 	uint count = 0;
 	unsigned char xid[sizeof(XID)];
 
-	memset (xid, 0, sizeof(XID));
+	memset(xid, 0, sizeof(XID));
 
 	while (storageHandler->recoverGetNextLimbo(sizeof(XID), xid))
 		{
 		count++;
 		memcpy(xids++, xid, sizeof(XID));
+		
 		if (count >= length)
 			break;
 		}
 
 	DBUG_RETURN(count);
+}
+
+
+void StorageInterface::mapFields(TABLE *table)
+{
+	maxFields = storageShare->format->maxId;
+	fieldMap = new Field*[maxFields];
+	memset(fieldMap, 0, sizeof(fieldMap[0]) * maxFields);
+	char nameBuffer[129];
+
+	for (uint n = 0; n < table->s->fields; ++n)
+		{
+		Field *field = table->field[n];
+		storageShare->cleanupFieldName(field->field_name, nameBuffer,
sizeof(nameBuffer));
+		int id = storageShare->getFieldId(nameBuffer);
+		
+		if (id >= 0)
+			fieldMap[id] = field;
+		}
 }
 
 static MYSQL_SYSVAR_STR(serial_log_dir, falcon_serial_log_dir,
diff -Nrup a/storage/falcon/ha_falcon.h b/storage/falcon/ha_falcon.h
--- a/storage/falcon/ha_falcon.h	2008-04-21 12:27:07 -04:00
+++ b/storage/falcon/ha_falcon.h	2008-04-22 15:46:08 -04:00
@@ -125,6 +125,7 @@ public:
 	void			decodeRecord(uchar *buf);
 	void			unlockTable(void);
 	void			checkBinLog(void);
+	void			mapFields(TABLE *table);
 
 	static StorageConnection* getStorageConnection(THD* thd);
 	
@@ -166,6 +167,7 @@ public:
 	StorageConnection*	storageConnection;
 	StorageTable*		storageTable;
 	StorageTableShare*	storageShare;
+	Field				**fieldMap;
 	const char*			errorText;
 	THR_LOCK_DATA		lockData;			// MySQL lock
 	THD					*mySqlThread;
@@ -175,6 +177,7 @@ public:
 	int					nextRecord;
 	int					indexErrorId;
 	int					errorKey;
+	int					maxFields;
 	StorageBlob			*activeBlobs;
 	StorageBlob			*freeBlobs;
 	bool				haveStartKey;
Thread
bk commit into 6.0 tree (jas:1.2636)U-ROWVWADEjas22 Apr