~jlukas79/+junk/mysql-server

« back to all changes in this revision

Viewing changes to storage/falcon/StorageDatabase.cpp

manual merge 6.0-main --> 6.0-bka-review

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
#include "ScaledBinary.h"
50
50
#include "Dbb.h"
51
51
#include "CmdGen.h"
 
52
#include "IndexWalker.h"
52
53
//#include "SyncTest.h"
53
54
 
54
55
#define ACCOUNT                         "mysql"
210
211
                statement->release();
211
212
                storageConnection->setErrorText(&exception);
212
213
                
 
214
                throw;
 
215
                }
 
216
                
 
217
        return findTable(tableName, schemaName);
 
218
}
 
219
 
 
220
Table* StorageDatabase::upgradeTable(StorageConnection *storageConnection, const char* tableName, const char *schemaName, const char* sql, int64 autoIncrementValue)
 
221
{
 
222
        Database *database = masterConnection->database;
 
223
        
 
224
        if (!user)
 
225
                if ((user = database->findUser(ACCOUNT)))
 
226
                        user->addRef();         
 
227
        
 
228
        Statement *statement = masterConnection->createStatement();
 
229
        
 
230
        try
 
231
                {
 
232
                //Table *table = database->findTable(schemaName, tableName);
 
233
                statement->execute(sql);
 
234
                
 
235
                if (autoIncrementValue)
 
236
                        {
 
237
                        char buffer[1024];
 
238
                        snprintf(buffer, sizeof(buffer), "create sequence  %s.\"%s\" start with " I64FORMAT, schemaName, tableName, autoIncrementValue - 1);
 
239
                        statement->execute(buffer);
 
240
                        }
 
241
                        
 
242
                statement->release();
 
243
                }
 
244
        catch (SQLException& exception)
 
245
                {
 
246
                statement->release();
 
247
                storageConnection->setErrorText(&exception);
 
248
                
213
249
                return NULL;
214
250
                }
215
251
                
415
451
                        candidate->release();
416
452
 
417
453
                storageConnection->setErrorText(&exception);
418
 
 
419
454
                int errorCode = exception.getSqlcode();
 
455
                
420
456
                switch (errorCode)
421
457
                        {
422
458
                        case UPDATE_CONFLICT:
423
459
                                return StorageErrorUpdateConflict;
 
460
                                
424
461
                        case OUT_OF_MEMORY_ERROR:
425
462
                                return StorageErrorOutOfMemory;
 
463
                                
426
464
                        case OUT_OF_RECORD_MEMORY_ERROR:
427
465
                                return StorageErrorOutOfRecordMemory;
 
466
                                
428
467
                        case DEADLOCK:
429
468
                                return StorageErrorDeadlock;
 
469
                                
430
470
                        case LOCK_TIMEOUT:
431
471
                                return StorageErrorLockTimeout;
432
472
                        }
435
475
                }
436
476
}
437
477
 
 
478
 
 
479
int StorageDatabase::nextIndexed(StorageTable* storageTable, IndexWalker* indexWalker, bool lockForUpdate)
 
480
{
 
481
        Record *record = indexWalker->getNext(lockForUpdate);
 
482
 
 
483
        if (!record)
 
484
                return StorageErrorRecordNotFound;
 
485
                
 
486
        storageTable->setRecord(record, lockForUpdate);
 
487
        
 
488
        return record->recordNumber;
 
489
}
 
490
 
438
491
RecordVersion* StorageDatabase::lockRecord(StorageConnection* storageConnection, Table *table, Record* record)
439
492
{
440
493
        try
658
711
        return 0;
659
712
}
660
713
 
 
714
int StorageDatabase::dropIndex(StorageConnection *storageConnection, Table* table, const char* indexName, const char* sql)
 
715
{
 
716
        Connection *connection = storageConnection->connection;
 
717
        Statement *statement = connection->createStatement();
 
718
        
 
719
        try
 
720
                {
 
721
                statement->execute(sql);
 
722
                }
 
723
        catch (SQLException& exception)
 
724
                {
 
725
                storageConnection->setErrorText(&exception);
 
726
                statement->release();
 
727
                
 
728
                if (exception.getSqlcode() == INDEX_OVERFLOW)
 
729
                        return StorageErrorIndexOverflow;
 
730
                
 
731
                return StorageErrorNoIndex;
 
732
                }
 
733
        
 
734
        statement->release();
 
735
        
 
736
        return 0;
 
737
}
 
738
 
661
739
int StorageDatabase::renameTable(StorageConnection* storageConnection, Table* table, const char* tableName, const char *schemaName)
662
740
{
663
741
        Connection *connection = storageConnection->connection;
738
816
                                                        storageConnection->connection->getTransaction(), bitmap);
739
817
}
740
818
 
 
819
 
 
820
IndexWalker* StorageDatabase::indexPosition(Index* index, StorageKey* lower, StorageKey* upper, int searchFlags, StorageConnection* storageConnection)
 
821
{
 
822
        if (!index)
 
823
                return NULL;
 
824
 
 
825
        if (lower)
 
826
                lower->indexKey.index = index;
 
827
                
 
828
        if (upper)
 
829
                upper->indexKey.index = index;
 
830
                
 
831
        return index->positionIndex((lower) ? &lower->indexKey : NULL,
 
832
                                                                (upper) ? &upper->indexKey : NULL, searchFlags, 
 
833
                                                                storageConnection->connection->getTransaction());
 
834
}
 
835
 
741
836
int StorageDatabase::makeKey(StorageIndexDesc* indexDesc, const UCHAR* key, int keyLength, StorageKey* storageKey)
742
837
{
743
838
        int segmentNumber = 0;
1178
1273
        if (masterConnection && masterConnection->database)
1179
1274
                masterConnection->database->getTransactionSummaryInfo(infoTable);
1180
1275
}
 
1276
 
 
1277
void StorageDatabase::getTableSpaceInfo(InfoTable* infoTable)
 
1278
{
 
1279
        if (masterConnection && masterConnection->database)
 
1280
                masterConnection->database->getTableSpaceInfo(infoTable);
 
1281
}
 
1282
 
 
1283
void StorageDatabase::getTableSpaceFilesInfo(InfoTable* infoTable)
 
1284
{
 
1285
        if (masterConnection && masterConnection->database)
 
1286
                masterConnection->database->getTableSpaceFilesInfo(infoTable);
 
1287
}