2732 John H. Embretsen 2009-07-03 [merge]
Merge mysql-6.0-falcon-team --> mysql-6.0-falcon.
added:
mysql-test/suite/falcon/r/falcon_bug_45775.result
mysql-test/suite/falcon/t/falcon_bug_45775.test
modified:
storage/falcon/IO.cpp
storage/falcon/IOx.h
storage/falcon/IndexRootPage.cpp
storage/falcon/IndexRootPage.h
storage/falcon/StorageTable.cpp
storage/falcon/StorageTableShare.cpp
storage/falcon/StorageTableShare.h
storage/falcon/StorageVersion.h
storage/falcon/Table.cpp
storage/falcon/Table.h
storage/falcon/ha_falcon.cpp
storage/falcon/ha_falcon.h
2731 John H. Embretsen 2009-06-25 [merge]
Merged mysql-6.0-falcon-team --> mysql-6.0-falcon
added:
mysql-test/collections/mysql-6.0-falcon-team.weekly
mysql-test/collections/mysql-6.0-falcon.daily
renamed:
mysql-test/suite/falcon_team/r/falcon_bug_34351_B.result =>
mysql-test/suite/falcon/r/falcon_bug_34351_B.result
mysql-test/suite/falcon_team/r/falcon_bug_34351_C.result =>
mysql-test/suite/falcon/r/falcon_bug_34351_C.result
mysql-test/suite/falcon_team/r/falcon_deadlock.result =>
mysql-test/suite/falcon/r/falcon_deadlock.result
mysql-test/suite/falcon_team/t/falcon_bug_34351_B.test =>
mysql-test/suite/falcon/t/falcon_bug_34351_B.test
mysql-test/suite/falcon_team/t/falcon_bug_34351_C.test =>
mysql-test/suite/falcon/t/falcon_bug_34351_C.test
mysql-test/suite/falcon_team/t/falcon_deadlock.test =>
mysql-test/suite/falcon/t/falcon_deadlock.test
modified:
mysql-test/collections/default.experimental
mysql-test/collections/falcon_team.experimental
mysql-test/suite/falcon_team/r/falcon_bug_34174.result
mysql-test/suite/falcon_team/t/falcon_bug_34174.test
storage/falcon/DataPage.cpp
storage/falcon/DeferredIndex.cpp
storage/falcon/Index.cpp
storage/falcon/Index.h
storage/falcon/Log.cpp
storage/falcon/Log.h
storage/falcon/Record.cpp
storage/falcon/Record.h
storage/falcon/RecordVersion.cpp
storage/falcon/RecordVersion.h
storage/falcon/SRLUpdateRecords.cpp
storage/falcon/StorageDatabase.cpp
storage/falcon/StorageTableShare.h
storage/falcon/Table.cpp
storage/falcon/Thread.cpp
storage/falcon/Transaction.cpp
storage/falcon/TransactionState.h
storage/falcon/ha_falcon.cpp
storage/falcon/ha_falcon.h
mysql-test/suite/falcon/r/falcon_bug_34351_B.result
mysql-test/suite/falcon/t/falcon_bug_34351_B.test
=== added file 'mysql-test/suite/falcon/r/falcon_bug_45775.result'
--- a/mysql-test/suite/falcon/r/falcon_bug_45775.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/falcon/r/falcon_bug_45775.result 2009-06-28 18:58:38 +0000
@@ -0,0 +1,31 @@
+*** Bug #45775 ***
+SET @@storage_engine = 'Falcon';
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a int NOT NULL UNIQUE, b int, c int);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` int(11) DEFAULT NULL,
+ `c` int(11) DEFAULT NULL,
+ UNIQUE KEY `a` (`a`)
+) ENGINE=Falcon DEFAULT CHARSET=latin1
+ALTER TABLE t1 ADD PRIMARY KEY (b);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL,
+ `b` int(11) NOT NULL DEFAULT '0',
+ `c` int(11) DEFAULT NULL,
+ PRIMARY KEY (`b`),
+ UNIQUE KEY `a` (`a`)
+) ENGINE=Falcon DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES (1,1,1);
+INSERT INTO t1 VALUES (1,1,2);
+ERROR 23000: Duplicate entry '1' for key 'a'
+INSERT INTO t1 VALUES (1,2,2);
+ERROR 23000: Duplicate entry '1' for key 'a'
+INSERT INTO t1 VALUES (2,1,2);
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+INSERT INTO t1 VALUES (2,2,2);
+DROP TABLE t1;
=== added file 'mysql-test/suite/falcon/t/falcon_bug_45775.test'
--- a/mysql-test/suite/falcon/t/falcon_bug_45775.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/falcon/t/falcon_bug_45775.test 2009-06-28 18:58:38 +0000
@@ -0,0 +1,50 @@
+#
+# Bug #45775: Crash when adding primary key to Falcon table with unique constraint
+#
+# The server treats a primary key and a unique key with non-null columns as
+# effectively the same. This test confirms that the storage engine makes the
+# correct distinction between the two.
+#
+--echo *** Bug #45775 ***
+
+--source include/have_falcon.inc
+
+# ----------------------------------------------------- #
+# --- Initialisation --- #
+# ----------------------------------------------------- #
+let $engine = 'Falcon';
+eval SET @@storage_engine = $engine;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# ----------------------------------------------------- #
+# --- Test --- #
+# ----------------------------------------------------- #
+CREATE TABLE t1 (a int NOT NULL UNIQUE, b int, c int);
+SHOW CREATE TABLE t1;
+ALTER TABLE t1 ADD PRIMARY KEY (b);
+SHOW CREATE TABLE t1;
+
+INSERT INTO t1 VALUES (1,1,1);
+
+## Should fail with key conflict
+--error ER_DUP_ENTRY
+INSERT INTO t1 VALUES (1,1,2);
+
+## Should fail with unique key conflict
+--error ER_DUP_ENTRY
+INSERT INTO t1 VALUES (1,2,2);
+
+## Should fail with primary key conflict
+--error ER_DUP_ENTRY
+INSERT INTO t1 VALUES (2,1,2);
+
+INSERT INTO t1 VALUES (2,2,2);
+
+# ----------------------------------------------------- #
+# --- Final cleanup --- #
+# ----------------------------------------------------- #
+DROP TABLE t1;
+
=== modified file 'storage/falcon/IO.cpp'
--- a/storage/falcon/IO.cpp 2009-04-07 20:16:05 +0000
+++ b/storage/falcon/IO.cpp 2009-06-26 11:13:44 +0000
@@ -109,6 +109,8 @@ static const int TRACE_SYNC_END = -2;
static const uint16 NON_ZERO_CHECKSUM_MAGIC = 0xAFFE;
+static const int NO_VALID_PAGE_NUMBER = -2;
+
#ifdef SIMULATE_DISK_FULL
static int simulateDiskFull = SIMULATE_DISK_FULL;
#endif
@@ -289,7 +291,7 @@ void IO::readPage(Bdb * bdb)
if (length != pageSize)
{
- declareFatalError();
+ declareFatalError("IO::readPage", bdb->pageNumber, errno);
if (length == -1)
{
throw SQLError(IO_ERROR, "read error on page %d of \"%s\": %s (%d)",
@@ -390,7 +392,7 @@ void IO::writePages(int32 pageNumber, in
if (errno == ENOSPC)
throw SQLError(DEVICE_FULL, "device full error on %s, page %d\n", (const char*)
fileName, pageNumber);
- declareFatalError();
+ declareFatalError("IO::writePages", pageNumber, errno);
throw SQLError(IO_ERROR, "write error on page %d (%d/%d/%d) of \"%s\": %s (%d)",
pageNumber, length, pageSize, fileId,
@@ -452,9 +454,27 @@ void IO::longSeek(int64 offset)
Error::error ("long seek failed on \"%s\"", (const char*) fileName);
}
-void IO::declareFatalError()
+void IO::declareFatalError(const char *methodName, int pageNumber, int errorNumber)
{
+ // Update status about that a fatal IO error has occured
+
fatalError = true;
+
+ // Convert the page number to a string. Note that we use
+ // NO_VALID_PAGE_NUMBER to indicate that this error is not related
+ // to a specific page.
+
+ char pageNumberStr[40];
+ pageNumberStr[0] = 0;
+
+ if (pageNumber != NO_VALID_PAGE_NUMBER)
+ {
+ sprintf(pageNumberStr, ", page %d", pageNumber);
+ }
+
+ Log::fatal("Falcon: Fatal IO error occurred in \"%s\": file \"%s\"%s: %s (%d)\n",
+ methodName, (const char*) fileName, pageNumberStr,
+ strerror(errorNumber), errorNumber);
}
@@ -705,7 +725,7 @@ void IO::sync(void)
#ifdef _WIN32
if (_commit(fileId))
{
- declareFatalError();
+ declareFatalError("IO::sync", NO_VALID_PAGE_NUMBER, errno);
throw SQLError(IO_ERROR, "_commit failed on \"%s\": %s (%d)",
(const char*) fileName, strerror (errno), errno);
}
=== modified file 'storage/falcon/IOx.h'
--- a/storage/falcon/IOx.h 2008-09-11 10:56:00 +0000
+++ b/storage/falcon/IOx.h 2009-06-26 11:13:44 +0000
@@ -56,7 +56,6 @@ public:
void write(uint32 length, const UCHAR *data);
static bool doesFileExist(const char *fileName);
static int fileStat(const char *fileName, struct stat *stats = NULL, int *errnum =
NULL);
- void declareFatalError();
void seek (int pageNumber);
void closeFile();
void readHeader (Hdr *header);
@@ -88,6 +87,10 @@ public:
static void deleteFile(const char* fileName);
static int getWriteMode(int attempt);
+private:
+ void declareFatalError(const char *methodName, int PageNumber, int errorNumber);
+
+public:
JString fileName;
SyncObject syncObject;
int fileId;
=== modified file 'storage/falcon/IndexRootPage.cpp'
--- a/storage/falcon/IndexRootPage.cpp 2009-04-14 19:14:20 +0000
+++ b/storage/falcon/IndexRootPage.cpp 2009-07-01 09:02:00 +0000
@@ -182,10 +182,9 @@ bool IndexRootPage::addIndexEntry(Dbb *
/* Node didn't fit. Split the page and propagate the
split upward. Sooner or later we'll go back and re-try
the original insertion */
-
- if (splitIndexPage (dbb, indexId, bdb, transId, result, key, recordNumber, isRoot))
- return true;
-
+
+ splitIndexPage (dbb, indexId, bdb, transId, result, key, recordNumber, isRoot);
+
#ifdef _DEBUG
if (n)
{
@@ -483,7 +482,7 @@ void IndexRootPage::scanIndex (Dbb *dbb
}
}
-bool IndexRootPage::splitIndexPage(Dbb * dbb, int32 indexId, Bdb * bdb, TransId transId,
+void IndexRootPage::splitIndexPage(Dbb * dbb, int32 indexId, Bdb * bdb, TransId transId,
AddNodeResult addResult, IndexKey *indexKey, int recordNumber, bool isRoot)
{
@@ -557,7 +556,7 @@ bool IndexRootPage::splitIndexPage(Dbb *
leftBdb->release(REL_HISTORY);
bdb->release(REL_HISTORY);
- return false;
+ return;
}
@@ -596,15 +595,15 @@ bool IndexRootPage::splitIndexPage(Dbb *
}
parentBdb->release(REL_HISTORY);
- return false;
+ return;
}
// Parent page needs to be split.Recurse
ASSERT(result == SplitMiddle || result == SplitEnd || result == NextPage);
- if (splitIndexPage (dbb, indexId, parentBdb, transId, result, &splitKey,
- splitPageNumber, (parentBdb->pageNumber == rootPageNumber)))
- return true;
+ splitIndexPage (dbb, indexId, parentBdb, transId, result, &splitKey,
+ splitPageNumber, (parentBdb->pageNumber == rootPageNumber));
+
}
}
=== modified file 'storage/falcon/IndexRootPage.h'
--- a/storage/falcon/IndexRootPage.h 2009-03-02 18:36:32 +0000
+++ b/storage/falcon/IndexRootPage.h 2009-07-01 09:02:00 +0000
@@ -43,7 +43,7 @@ public:
static void debugBucket (Dbb *dbb, int indexId, int recordNumber, TransId
transactionId);
static void deleteIndex (Dbb *dbb, int32 indexId, TransId transId);
static bool deleteIndexEntry (Dbb *dbb, int32 indexId, IndexKey *key, int32
recordNumber, TransId transId);
- static bool splitIndexPage (Dbb *dbb, int32 indexId, Bdb *bdb, TransId transId,
+ static void splitIndexPage (Dbb *dbb, int32 indexId, Bdb *bdb, TransId transId,
AddNodeResult addResult, IndexKey *indexKey, int recordNumber, bool isRootPage);
static void scanIndex (Dbb *dbb, int32 indexId, int32 rootPage, IndexKey *low, IndexKey
*high, int searchFlags, TransId transId, Bitmap *bitmap);
static void positionIndex(Dbb* dbb, int indexId, int32 rootPage, WalkIndex* walkIndex);
=== modified file 'storage/falcon/StorageTable.cpp'
--- a/storage/falcon/StorageTable.cpp 2009-05-14 05:16:08 +0000
+++ b/storage/falcon/StorageTable.cpp 2009-06-25 22:48:40 +0000
@@ -643,7 +643,7 @@ void StorageTable::clearAlter(void)
bool StorageTable::setAlter(void)
{
- return share->table->setAlter();
+ return share->table->setAlter(storageConnection->connection);
}
int StorageTable::alterCheck(void)
=== modified file 'storage/falcon/StorageTableShare.cpp'
--- a/storage/falcon/StorageTableShare.cpp 2009-04-27 16:43:53 +0000
+++ b/storage/falcon/StorageTableShare.cpp 2009-06-28 18:58:38 +0000
@@ -219,11 +219,11 @@ int StorageTableShare::create(StorageCon
case TABLESPACE_NOT_EXIST_ERROR:
return StorageErrorTableSpaceNotExist;
default:
- return StorageErrorTableExits;
+ return StorageErrorTableExists;
}
}
if (!table)
- return StorageErrorTableExits;
+ return StorageErrorTableExists;
format = table->getCurrentFormat();
@@ -235,8 +235,12 @@ int StorageTableShare::create(StorageCon
int StorageTableShare::upgrade(StorageConnection *storageConnection, const char* sql,
int64 autoIncrementValue)
{
- if (!(table = storageDatabase->upgradeTable(storageConnection, name, schemaName, sql,
autoIncrementValue)))
- return StorageErrorTableExits;
+ Table* tableUpgrade = storageDatabase->upgradeTable(storageConnection, name,
schemaName, sql, autoIncrementValue);
+
+ if (tableUpgrade)
+ table = tableUpgrade;
+ else
+ return StorageErrorTableExists;
format = table->getCurrentFormat();
=== modified file 'storage/falcon/StorageTableShare.h'
--- a/storage/falcon/StorageTableShare.h 2009-06-24 22:17:25 +0000
+++ b/storage/falcon/StorageTableShare.h 2009-06-28 18:58:38 +0000
@@ -100,7 +100,7 @@ enum StorageError {
StorageErrorTableNotFound = -3,
StorageErrorNoIndex = -4,
StorageErrorBadKey = -5,
- StorageErrorTableExits = -6,
+ StorageErrorTableExists = -6,
StorageErrorNoSequence = -7,
StorageErrorUpdateConflict = -8,
StorageErrorUncommittedUpdates = -9, // specific for drop table
=== modified file 'storage/falcon/StorageVersion.h'
--- a/storage/falcon/StorageVersion.h 2009-04-30 10:06:12 +0000
+++ b/storage/falcon/StorageVersion.h 2009-07-03 11:14:02 +0000
@@ -14,5 +14,5 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#define FALCON_VERSION "T1.6-0"
-#define FALCON_DATE "30 April, 2009"
+#define FALCON_VERSION "T1.6-1"
+#define FALCON_DATE "03 July, 2009"
=== modified file 'storage/falcon/Table.cpp'
--- a/storage/falcon/Table.cpp 2009-06-23 21:16:25 +0000
+++ b/storage/falcon/Table.cpp 2009-06-25 22:48:40 +0000
@@ -917,7 +917,8 @@ void Table::init(int id, const char *sch
debugThawedBytes = 0;
cardinality = 0;
priorCardinality = 0;
- alterIsActive = false;
+ alterIsActive = 0;
+ alterConnection = NULL;
syncObject.setName("Table::syncObject");
syncTriggers.setName("Table::syncTriggers");
syncAlter.setName("Table::syncAlter");
@@ -1774,7 +1775,8 @@ void Table::truncate(Transaction *transa
ageGroup = database->currentGeneration;
debugThawedRecords = 0;
debugThawedBytes = 0;
- alterIsActive = false;
+ alterIsActive = 0;
+ alterConnection = NULL;
deleting = false;
}
@@ -3695,19 +3697,21 @@ void Table::clearAlter(void)
{
Sync sync(&syncAlter, "Table::clearAlter");
sync.lock(Exclusive);
- alterIsActive = false;
+ if (--alterIsActive == 0)
+ alterConnection = NULL;
}
}
-bool Table::setAlter(void)
+bool Table::setAlter(Connection* connection)
{
Sync sync(&syncAlter, "Table::setAlter");
sync.lock(Exclusive);
- if (alterIsActive)
+ if (alterIsActive && (connection != alterConnection))
return false;
- alterIsActive = true;
+ alterIsActive++;
+ alterConnection = connection;
return true;
}
=== modified file 'storage/falcon/Table.h'
--- a/storage/falcon/Table.h 2009-06-02 15:25:59 +0000
+++ b/storage/falcon/Table.h 2009-06-25 22:48:40 +0000
@@ -127,7 +127,7 @@ public:
int nextColumnId (int previous);
void loadStuff();
void clearAlter(void);
- bool setAlter(void);
+ bool setAlter(Connection* connection);
void addTrigger (Trigger *trigger);
void dropTrigger (Trigger *trigger);
@@ -271,7 +271,8 @@ public:
bool changed;
bool eof;
bool markedForDelete;
- bool alterIsActive;
+ int alterIsActive;
+ Connection* alterConnection; // The connection currintly doing an alter.
bool deleting; // dropping or truncating.
int32 recordBitmapHighWater;
int32 ageGroup;
=== modified file 'storage/falcon/ha_falcon.cpp'
--- a/storage/falcon/ha_falcon.cpp 2009-06-24 22:17:25 +0000
+++ b/storage/falcon/ha_falcon.cpp 2009-06-28 18:58:38 +0000
@@ -91,6 +91,10 @@ extern StorageHandler *storageHandler;
#undef PARAMETER_UINT
#undef PARAMETER_BOOL
+// Unique name assigned by server to the primary key
+
+extern const char *primary_key_name;
+
ulonglong falcon_record_memory_max;
ulonglong falcon_serial_log_file_size;
uint falcon_allocation_extent;
@@ -909,16 +913,14 @@ int StorageInterface::create(const char
if ((ret = storageTable->create(gen.getString(), incrementValue)))
{
storageTable->deleteTable();
-
DBUG_RETURN(error(ret));
}
for (n = 0; n < form->s->keys; ++n)
- if (n != form->s->primary_key)
+ if (!isPrimaryKey(form, n))
if ((ret = createIndex(schemaName, tableName, form, n)))
{
storageTable->deleteTable();
-
DBUG_RETURN(error(ret));
}
@@ -1586,6 +1588,19 @@ ha_rows StorageInterface::records_in_ran
DBUG_RETURN(MAX(guestimate, 2));
}
+bool StorageInterface::isPrimaryKey(TABLE *srvTable, uint indexId)
+{
+ uint primaryKey = srvTable->s->primary_key;
+
+ // If primary_key != MAX_KEY, then the key is either a primary key or
+ // a unique key with all non-NULL columns. Check the key name to
+ // distinguish between them. The primary key is always "PRIMARY".
+
+ return (indexId == primaryKey &&
+ primaryKey != MAX_KEY &&
+ !strcmp(srvTable->s->key_info[primaryKey].name, primary_key_name));
+}
+
void StorageInterface::getKeyDesc(TABLE *srvTable, int indexId, StorageIndexDesc
*indexDesc)
{
KEY *keyInfo = srvTable->key_info + indexId;
@@ -1594,7 +1609,7 @@ void StorageInterface::getKeyDesc(TABLE
indexDesc->id = indexId;
indexDesc->numberSegments = numberKeys;
indexDesc->unique = (keyInfo->flags & HA_NOSAME);
- indexDesc->primaryKey = (srvTable->s->primary_key == (uint)indexId);
+ indexDesc->primaryKey = isPrimaryKey(srvTable, indexId);
// Clean up the index name for internal use
@@ -2151,7 +2166,7 @@ int StorageInterface::getMySqlError(int
DBUG_PRINT("info", ("StorageErrorBadKey"));
return (HA_ERR_WRONG_INDEX);
- case StorageErrorTableExits:
+ case StorageErrorTableExists:
DBUG_PRINT("info", ("StorageErrorTableExits"));
return (HA_ERR_TABLE_EXIST);
@@ -2557,10 +2572,6 @@ int StorageInterface::addColumn(THD* thd
{
int ret;
int64 incrementValue = 0;
- /***
- const char *tableName = storageTable->getName();
- const char *schemaName = storageTable->getSchemaName();
- ***/
CmdGen gen;
genTable(alteredTable, &gen);
@@ -2815,7 +2826,9 @@ int StorageInterface::genTable(TABLE* sr
sep = ",\n";
}
- if (srvTable->s->primary_key < srvTable->s->keys)
+ // Confirm that primary_key is actually a primary key
+
+ if (isPrimaryKey(srvTable, srvTable->s->primary_key))
{
KEY *key = srvTable->key_info + srvTable->s->primary_key;
gen->gen(",\n primary key ");
=== modified file 'storage/falcon/ha_falcon.h'
--- a/storage/falcon/ha_falcon.h 2009-06-24 21:28:30 +0000
+++ b/storage/falcon/ha_falcon.h 2009-06-28 18:58:38 +0000
@@ -146,6 +146,7 @@ public:
int createIndex(const char *schemaName, const char *tableName, TABLE *srvTable, int
indexId);
int dropIndex(const char *schemaName, const char *tableName, TABLE *srvTable, int
indexId, bool online);
void getKeyDesc(TABLE *srvTable, int indexId, StorageIndexDesc *indexInfo);
+ bool isPrimaryKey(TABLE *srvTable, uint indexId);
void startTransaction(void);
bool threadSwitch(THD *newThread);
int threadSwitchError(void);
Attachment: [text/bzr-bundle] bzr/john.embretsen@sun.com-20090703114135-je2vurfepmad6m87.bundle
| Thread |
|---|
| • bzr push into mysql-6.0-falcon branch (john.embretsen:2731 to 2732) | John H. Embretsen | 3 Jul 2009 |