32
32
#include <stddef.h>
36
#include "cslib/CSGlobal.h"
37
#include "cslib/CSStrUtil.h"
38
#include "cslib/CSStorage.h"
34
40
#include "temp_log_ms.h"
35
41
#include "open_table_ms.h"
36
42
#include "trans_log_ms.h"
37
43
#include "transaction_ms.h"
38
44
#include "parameters_ms.h"
40
#include "cslib/CSGlobal.h"
41
#include "cslib/CSStrUtil.h"
42
#include "cslib/CSStorage.h"
45
47
// Search the transaction log for a MS_ReferenceTxn record for the given BLOB.
46
48
// Just search the log file and not the cache. Seaching the cache may be faster but
111
113
MSTempLogFile *MSTempLogFile::newTempLogFile(uint32_t id, MSTempLog *temp_log, CSFile *file)
113
115
MSTempLogFile *f;
115
if (!(f = new MSTempLogFile())) {
121
if (!(f = new MSTempLogFile()))
118
122
CSException::throwOSError(CS_CONTEXT, ENOMEM);
120
124
f->myTempLogID = id;
121
130
f->myTempLog = temp_log;
123
f->myFilePath = file->myFilePath;
124
f->myFilePath->retain();
128
134
MSTempLog::MSTempLog(uint32_t id, MSDatabase *db, off64_t file_size):
270
bool MSTempLogThread::try_ReleaseBLOBReference(CSThread *self, CSStringBuffer *buffer, uint32_t tab_id, int type, uint64_t blob_id, uint32_t auth_code)
272
volatile bool rtc = true;
274
/* Release the BLOB reference. */
277
if (type == MS_TL_REPO_REF) {
278
MSRepoFile *repo_file;
280
if ((repo_file = iTempLogDatabase->getRepoFileFromPool(tab_id, true))) {
281
frompool_(repo_file);
282
repo_file->checkBlob(buffer, blob_id, auth_code, iTempLogFile->myTempLogID, iLogOffset);
283
backtopool_(repo_file);
287
if ((otab = MSTableList::getOpenTableByID(iTempLogDatabase->myDatabaseID, tab_id))) {
289
if (type == MS_TL_BLOB_REF) {
290
otab->checkBlob(buffer, blob_id, auth_code, iTempLogFile->myTempLogID, iLogOffset);
294
ASSERT(type == MS_TL_TABLE_REF);
295
if ((type == MS_TL_TABLE_REF) && otab->deleteReferences(iTempLogFile->myTempLogID, iLogOffset, &myMustQuit)) {
296
/* Delete the file now... */
299
MSOpenTablePool *tab_pool;
301
tab = otab->getDBTable();
302
from_path = otab->getDBTable()->getTableFile();
310
tab_pool = MSTableList::lockTablePoolForDeletion(otab); // This returns otab to the pool.
313
from_path->removeFile();
314
tab->myDatabase->removeTable(tab);
316
backtopool_(tab_pool); // The will unlock and close the table pool freeing all tables in it.
317
pop_(tab); // Returning the pool will have released this. (YUK!)
264
334
bool MSTempLogThread::doWork()
330
399
myWaitTime = MSTempLog::adjustWaitTime(then, now);
335
/* Release the BLOB reference. */
338
if (type == MS_TL_REPO_REF) {
339
MSRepoFile *repo_file;
341
if ((repo_file = iTempLogDatabase->getRepoFileFromPool(tab_id, true))) {
342
frompool_(repo_file);
343
repo_file->checkBlob(buffer, blob_id, auth_code, iTempLogFile->myTempLogID, iLogOffset);
344
backtopool_(repo_file);
348
if ((otab = MSTableList::getOpenTableByID(iTempLogDatabase->myDatabaseID, tab_id))) {
350
if (type == MS_TL_BLOB_REF) {
351
otab->checkBlob(buffer, blob_id, auth_code, iTempLogFile->myTempLogID, iLogOffset);
355
ASSERT(type == MS_TL_TABLE_REF);
356
if ((type == MS_TL_TABLE_REF) && otab->deleteReferences(iTempLogFile->myTempLogID, iLogOffset, &myMustQuit)) {
357
/* Delete the file now... */
360
MSOpenTablePool *tab_pool;
362
tab = otab->getDBTable();
363
from_path = otab->getDBTable()->getTableFile();
371
tab_pool = MSTableList::lockTablePoolForDeletion(otab); // This returns otab to the pool.
374
from_path->removeFile();
375
tab->myDatabase->removeTable(tab);
377
backtopool_(tab_pool); // The will unlock and close the table pool freeing all tables in it.
378
pop_(tab); // Returning the pool will have released this. (YUK!)
403
if (try_ReleaseBLOBReference(self, buffer, tab_id, type, blob_id, auth_code)) {
388
404
int err = self->myException.getErrorCode();
390
406
if (err == MS_ERR_TABLE_LOCKED) {