~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/pbms/src/system_table_ms.cc

  • Committer: Lee Bieber
  • Date: 2010-10-22 16:47:38 UTC
  • mfrom: (1841.1.7 drizzle_pbms)
  • Revision ID: kalebral@gmail.com-20101022164738-vv8w22b8towpb307
Merge Barry - fix bug 657830: PBMS build failure in GCC 4.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
93
93
#ifdef HAVE_ALIAS_SUPPORT
94
94
        {"Blob_alias",                  BLOB_ALIAS_LENGTH, NULL, MYSQL_TYPE_VARCHAR,            &my_charset_utf8_bin,   0,                                                              "The BLOB alias"},
95
95
#endif
96
 
        {"Repository_id",               NULL, NULL, MYSQL_TYPE_LONG,            NULL,                                   NOT_NULL_FLAG,                                  "The repository file number"},
97
 
        {"Repo_blob_offset",    NULL, NULL, MYSQL_TYPE_LONGLONG,        NULL,                                   NOT_NULL_FLAG,                                  "The offset of the BLOB in the repository file"},
98
 
        {"Blob_size",                   NULL, NULL, MYSQL_TYPE_LONGLONG,        NULL,                                   NOT_NULL_FLAG,                                  "The size of the BLOB in bytes"},
 
96
        {"Repository_id",               NOVAL, NULL, MYSQL_TYPE_LONG,           NULL,                                   NOT_NULL_FLAG,                                  "The repository file number"},
 
97
        {"Repo_blob_offset",    NOVAL, NULL, MYSQL_TYPE_LONGLONG,       NULL,                                   NOT_NULL_FLAG,                                  "The offset of the BLOB in the repository file"},
 
98
        {"Blob_size",                   NOVAL, NULL, MYSQL_TYPE_LONGLONG,       NULL,                                   NOT_NULL_FLAG,                                  "The size of the BLOB in bytes"},
99
99
        {"MD5_Checksum",                32,   NULL,     MYSQL_TYPE_VARCHAR,             system_charset_info,    0,                                                              "The MD5 Digest of the BLOB data."},
100
 
        {"Head_size",                   NULL, NULL, MYSQL_TYPE_SHORT,           NULL,                                   NOT_NULL_FLAG | UNSIGNED_FLAG,  "The size of the BLOB header - proceeds the BLOB data"},
101
 
        {"Access_code",                 NULL, NULL, MYSQL_TYPE_LONG,            NULL,                                   NOT_NULL_FLAG,                                  "The 4-byte authorisation code required to access the BLOB - part of the BLOB URL"},
102
 
        {"Creation_time",               NULL, NULL, MYSQL_TYPE_TIMESTAMP,       NULL,                                   NOT_NULL_FLAG,                                  "The time the BLOB was created"},
103
 
        {"Last_ref_time",               NULL, NULL, MYSQL_TYPE_TIMESTAMP,       NULL,                                   0,                                                              "The last time the BLOB was referenced"},
104
 
        {"Last_access_time",    NULL, NULL, MYSQL_TYPE_TIMESTAMP,       NULL,                                   0,                                                              "The last time the BLOB was accessed (read)"},
105
 
        {"Access_count",                NULL, NULL, MYSQL_TYPE_LONG,            NULL,                                   NOT_NULL_FLAG,                                  "The count of the number of times the BLOB has been read"},
106
 
        {NULL,NULL, NULL, MYSQL_TYPE_STRING,NULL, 0, NULL}
 
100
        {"Head_size",                   NOVAL, NULL, MYSQL_TYPE_SHORT,          NULL,                                   NOT_NULL_FLAG | UNSIGNED_FLAG,  "The size of the BLOB header - proceeds the BLOB data"},
 
101
        {"Access_code",                 NOVAL, NULL, MYSQL_TYPE_LONG,           NULL,                                   NOT_NULL_FLAG,                                  "The 4-byte authorisation code required to access the BLOB - part of the BLOB URL"},
 
102
        {"Creation_time",               NOVAL, NULL, MYSQL_TYPE_TIMESTAMP,      NULL,                                   NOT_NULL_FLAG,                                  "The time the BLOB was created"},
 
103
        {"Last_ref_time",               NOVAL, NULL, MYSQL_TYPE_TIMESTAMP,      NULL,                                   0,                                                              "The last time the BLOB was referenced"},
 
104
        {"Last_access_time",    NOVAL, NULL, MYSQL_TYPE_TIMESTAMP,      NULL,                                   0,                                                              "The last time the BLOB was accessed (read)"},
 
105
        {"Access_count",                NOVAL, NULL, MYSQL_TYPE_LONG,           NULL,                                   NOT_NULL_FLAG,                                  "The count of the number of times the BLOB has been read"},
 
106
        {NULL,NOVAL, NULL, MYSQL_TYPE_STRING,NULL, 0, NULL}
107
107
};
108
108
 
109
109
#ifdef PBMS_HAS_KEYS
116
116
 
117
117
static DT_FIELD_INFO pbms_metadata_info[]=
118
118
{
119
 
        {"Repository_id",               NULL,                                   NULL, MYSQL_TYPE_LONG,          NULL,                                                   NOT_NULL_FLAG,  "The repository file number"},
120
 
        {"Repo_blob_offset",    NULL,                                   NULL, MYSQL_TYPE_LONGLONG,      NULL,                                                   NOT_NULL_FLAG,  "The offset of the BLOB in the repository file"},
 
119
        {"Repository_id",               NOVAL,                                  NULL, MYSQL_TYPE_LONG,          NULL,                                                   NOT_NULL_FLAG,  "The repository file number"},
 
120
        {"Repo_blob_offset",    NOVAL,                                  NULL, MYSQL_TYPE_LONGLONG,      NULL,                                                   NOT_NULL_FLAG,  "The offset of the BLOB in the repository file"},
121
121
        {"Name",                                MS_META_NAME_SIZE,      NULL, MYSQL_TYPE_VARCHAR,       &UTF8_CHARSET,  NOT_NULL_FLAG,  "Metadata name"},
122
122
        {"Value",                               MS_META_VALUE_SIZE,     NULL, MYSQL_TYPE_VARCHAR,       &UTF8_CHARSET,                  NOT_NULL_FLAG,  "Metadata value"},
123
 
        {NULL,                                  NULL,                                   NULL, MYSQL_TYPE_STRING,        NULL, 0, NULL}
 
123
        {NULL,                                  NOVAL,                                  NULL, MYSQL_TYPE_STRING,        NULL, 0, NULL}
124
124
};
125
125
 
126
126
#ifdef PBMS_HAS_KEYS
135
135
#ifdef HAVE_ALIAS_SUPPORT
136
136
static DT_FIELD_INFO pbms_alias_info[]=
137
137
{
138
 
        {"Repository_id",               NULL, NULL, MYSQL_TYPE_LONG,            NULL,                           NOT_NULL_FLAG,  "The repository file number"},
139
 
        {"Repo_blob_offset",    NULL, NULL, MYSQL_TYPE_LONGLONG,        NULL,                           NOT_NULL_FLAG,  "The offset of the BLOB in the repository file"},
 
138
        {"Repository_id",               NOVAL, NULL, MYSQL_TYPE_LONG,           NULL,                           NOT_NULL_FLAG,  "The repository file number"},
 
139
        {"Repo_blob_offset",    NOVAL, NULL, MYSQL_TYPE_LONGLONG,       NULL,                           NOT_NULL_FLAG,  "The offset of the BLOB in the repository file"},
140
140
        {"Blob_alias",                  BLOB_ALIAS_LENGTH, NULL, MYSQL_TYPE_VARCHAR,            &my_charset_utf8_bin,   NOT_NULL_FLAG,                  "The BLOB alias"},
141
 
        {NULL,NULL, NULL, MYSQL_TYPE_STRING,NULL, 0, NULL}
 
141
        {NULL,NOVAL, NULL, MYSQL_TYPE_STRING,NULL, 0, NULL}
142
142
};
143
143
 
144
144
static DT_KEY_INFO pbms_alias_keys[]=
150
150
 
151
151
static DT_FIELD_INFO pbms_blobs_info[]=
152
152
{
153
 
        {"Repository_id",               NULL, NULL, MYSQL_TYPE_LONG,            NULL,                           NOT_NULL_FLAG,  "The repository file number"},
154
 
        {"Repo_blob_offset",    NULL, NULL, MYSQL_TYPE_LONGLONG,        NULL,                           NOT_NULL_FLAG,  "The offset of the BLOB in the repository file"},
155
 
        {"Blob_data",                   NULL, NULL, MYSQL_TYPE_LONG_BLOB,       &my_charset_bin,        NOT_NULL_FLAG,  "The data of this BLOB"},
156
 
        {NULL,NULL, NULL, MYSQL_TYPE_STRING,NULL, 0, NULL}
 
153
        {"Repository_id",               NOVAL, NULL, MYSQL_TYPE_LONG,           NULL,                           NOT_NULL_FLAG,  "The repository file number"},
 
154
        {"Repo_blob_offset",    NOVAL, NULL, MYSQL_TYPE_LONGLONG,       NULL,                           NOT_NULL_FLAG,  "The offset of the BLOB in the repository file"},
 
155
        {"Blob_data",                   NOVAL, NULL, MYSQL_TYPE_LONG_BLOB,      &my_charset_bin,        NOT_NULL_FLAG,  "The data of this BLOB"},
 
156
        {NULL,NOVAL, NULL, MYSQL_TYPE_STRING,NULL, 0, NULL}
157
157
};
158
158
 
159
159
#ifdef PBMS_HAS_KEYS
167
167
static DT_FIELD_INFO pbms_reference_info[]=
168
168
{
169
169
        {"Table_name",          MS_TABLE_NAME_SIZE,             NULL, MYSQL_TYPE_STRING,        system_charset_info,    0,      "The name of the referencing table"},
170
 
        {"Column_ordinal",      NULL,                                   NULL, MYSQL_TYPE_LONG,          NULL,                                   0,      "The column ordinal of the referencing field"},
171
 
        {"Blob_id",                     NULL,                                   NULL, MYSQL_TYPE_LONGLONG,      NULL,                                   NOT_NULL_FLAG,  "The BLOB reference number - part of the BLOB URL"},
 
170
        {"Column_ordinal",      NOVAL,                                  NULL, MYSQL_TYPE_LONG,          NULL,                                   0,      "The column ordinal of the referencing field"},
 
171
        {"Blob_id",                     NOVAL,                                  NULL, MYSQL_TYPE_LONGLONG,      NULL,                                   NOT_NULL_FLAG,  "The BLOB reference number - part of the BLOB URL"},
172
172
        {"Blob_url",            PBMS_BLOB_URL_SIZE,             NULL, MYSQL_TYPE_VARCHAR,       system_charset_info,    0,      "The BLOB URL for HTTP GET access"},
173
 
        {"Repository_id",       NULL,                                   NULL, MYSQL_TYPE_LONG,          NULL,                                   NOT_NULL_FLAG,  "The repository file number of the BLOB"},
174
 
        {"Repo_blob_offset",NULL,                                       NULL, MYSQL_TYPE_LONGLONG,      NULL,                                   NOT_NULL_FLAG,  "The offset in the repository file"},
175
 
        {"Blob_size",           NULL,                                   NULL, MYSQL_TYPE_LONGLONG,      NULL,                                   NOT_NULL_FLAG,  "The size of the BLOB in bytes"},
176
 
        {"Deletion_time",       NULL,                                   NULL, MYSQL_TYPE_TIMESTAMP,     NULL,                                   0,                              "The time the BLOB was deleted"},
177
 
        {"Remove_in",           NULL,                                   NULL, MYSQL_TYPE_LONG,          NULL,                                   0,                              "The number of seconds before the reference/BLOB is removed perminently"},
178
 
        {"Temp_log_id",         NULL,                                   NULL, MYSQL_TYPE_LONG,          NULL,                                   0,                              "Temporary log number of the referencing deletion entry"},
179
 
        {"Temp_log_offset",     NULL,                                   NULL, MYSQL_TYPE_LONGLONG,      NULL,                                   0,                              "Temporary log offset of the referencing deletion entry"},
180
 
        {NULL,NULL, NULL, MYSQL_TYPE_STRING,NULL, 0, NULL}
 
173
        {"Repository_id",       NOVAL,                                  NULL, MYSQL_TYPE_LONG,          NULL,                                   NOT_NULL_FLAG,  "The repository file number of the BLOB"},
 
174
        {"Repo_blob_offset",NOVAL,                                      NULL, MYSQL_TYPE_LONGLONG,      NULL,                                   NOT_NULL_FLAG,  "The offset in the repository file"},
 
175
        {"Blob_size",           NOVAL,                                  NULL, MYSQL_TYPE_LONGLONG,      NULL,                                   NOT_NULL_FLAG,  "The size of the BLOB in bytes"},
 
176
        {"Deletion_time",       NOVAL,                                  NULL, MYSQL_TYPE_TIMESTAMP,     NULL,                                   0,                              "The time the BLOB was deleted"},
 
177
        {"Remove_in",           NOVAL,                                  NULL, MYSQL_TYPE_LONG,          NULL,                                   0,                              "The number of seconds before the reference/BLOB is removed perminently"},
 
178
        {"Temp_log_id",         NOVAL,                                  NULL, MYSQL_TYPE_LONG,          NULL,                                   0,                              "Temporary log number of the referencing deletion entry"},
 
179
        {"Temp_log_offset",     NOVAL,                                  NULL, MYSQL_TYPE_LONGLONG,      NULL,                                   0,                              "Temporary log offset of the referencing deletion entry"},
 
180
        {NULL,NOVAL, NULL, MYSQL_TYPE_STRING,NULL, 0, NULL}
181
181
};
182
182
 
183
183
#ifdef PBMS_HAS_KEYS
423
423
        if (!db)
424
424
                return false;
425
425
                
426
 
        cs_strcpy(PATH_MAX, path, ms_my_get_mysql_home_path().c_str());
 
426
        cs_strcpy(PATH_MAX, path, ms_my_get_mysql_home_path());
427
427
        cs_add_name_to_path(PATH_MAX, path, db);
428
428
        
429
429
        if (stat(path, &stat_info) == 0)
489
489
}
490
490
 
491
491
//----------------
 
492
bool PBMSSystemTables::try_loadSystemTables(CSThread *self, int i, MSDatabase *db)
 
493
{
 
494
        volatile bool rtc = true;
 
495
        try_(a) {
 
496
                switch (i) {
 
497
                        case 0:
 
498
                                MSHTTPHeaderTable::loadTable(RETAIN(db));
 
499
                                break;
 
500
                        case 1:
 
501
                                MSCloudTable::loadTable(RETAIN(db));
 
502
                                break;
 
503
                        case 2:
 
504
                                MSBackupTable::loadTable(RETAIN(db));
 
505
                                break;
 
506
                        case 3:
 
507
                                // Variable must be loaded after cloud and backup info
 
508
                                // incase BLOB recovery is required.
 
509
                                MSVariableTable::loadTable(RETAIN(db)); 
 
510
                                break;
 
511
                                
 
512
                        default:
 
513
                                ASSERT(false);
 
514
                }
 
515
                rtc = false;
 
516
        }
 
517
        catch_(a);
 
518
        cont_(a);
 
519
        return rtc;
 
520
}
 
521
//----------------
492
522
void PBMSSystemTables::loadSystemTables(MSDatabase *db)
493
523
{
494
 
        int i = 0;
495
 
        
496
 
        CLOBBER_PROTECT(i);
497
524
        enter_();
498
525
        push_(db);
499
526
        
500
 
        for ( i = 0; i < 4; i++) {
501
 
                try_(a) {
502
 
                        switch (i) {
503
 
                                case 0:
504
 
                                        MSHTTPHeaderTable::loadTable(RETAIN(db));
505
 
                                        break;
506
 
                                case 1:
507
 
                                        MSCloudTable::loadTable(RETAIN(db));
508
 
                                        break;
509
 
                                case 2:
510
 
                                        MSBackupTable::loadTable(RETAIN(db));
511
 
                                        break;
512
 
                                case 3:
513
 
                                        // Variable must be loaded after cloud and backup info
514
 
                                        // incase BLOB recovery is required.
515
 
                                        MSVariableTable::loadTable(RETAIN(db)); 
516
 
                                        break;
517
 
                                        
518
 
                                default:
519
 
                                        ASSERT(false);
520
 
                        }
521
 
                }
522
 
                catch_(a) {
523
 
                        self->logException();
524
 
                }
525
 
                cont_(a);
 
527
        for ( int i = 0; i < 4; i++) {
 
528
                if (try_loadSystemTables(self, i, db))
 
529
                        self->logException();                   
526
530
        }
527
531
        
528
532
        release_(db);
675
679
 
676
680
void MSOpenSystemTable::setNotNullInRecord(Field *field, char *record)
677
681
{
 
682
#ifdef DRIZZLED
678
683
        if (field->null_ptr)
679
684
                record[(uint) (field->null_ptr - (uchar *) field->getTable()->getInsertRecord())] &= (uchar) ~field->null_bit;
 
685
#else
 
686
        if (field->null_ptr)
 
687
                record[(uint) (field->null_ptr - (uchar *) field->table->record[0])] &= (uchar) ~field->null_bit;
 
688
#endif
680
689
}
681
690
 
682
691
/*
722
731
//-----------------------
723
732
void MSRepositoryTable::use()
724
733
{
 
734
        MSDatabase *db;
 
735
        enter_();
 
736
 
 
737
        if (!iBlobBuffer)
 
738
                new_(iBlobBuffer, CSStringBuffer(20));
 
739
                
 
740
        db = myShare->mySysDatabase;
 
741
        if ((iCompactor = db->getCompactorThread())) {
 
742
                if (iCompactor->isMe(self))
 
743
                        iCompactor = NULL;
 
744
                else {
 
745
                        iCompactor->retain();
 
746
                        iCompactor->suspend();
 
747
                }
 
748
        }
 
749
        exit_();
725
750
}
726
751
 
727
752
//-----------------------
744
769
//-----------------------
745
770
void MSRepositoryTable::seqScanInit()
746
771
{
747
 
        MSDatabase *db;
748
 
 
749
772
        enter_();
750
773
        
751
774
        // Flush all committed transactions to the repository file.
753
776
 
754
777
        iRepoIndex = 0;
755
778
        iRepoOffset = 0;
756
 
        if (!iBlobBuffer)
757
 
                new_(iBlobBuffer, CSStringBuffer(20));
758
 
        db = myShare->mySysDatabase;
759
 
        if ((iCompactor = db->getCompactorThread())) {
760
 
                if (iCompactor->isMe(self))
761
 
                        iCompactor = NULL;
762
 
                else {
763
 
                        iCompactor->retain();
764
 
                        iCompactor->suspend();
765
 
                }
766
 
        }
767
779
                
768
780
        exit_();
769
781
}
959
971
        save_write_set = table->write_set;
960
972
        table->write_set = NULL;
961
973
 
 
974
#ifdef DRIZZLED
962
975
        memset(buf, 0xFF, table->getNullBytes());
 
976
#else
 
977
        memset(buf, 0xFF, table->s->null_bytes);
 
978
#endif
963
979
        for (Field **field=GET_TABLE_FIELDS(table) ; *field ; field++) {
964
980
                curr_field = *field;
965
 
 
966
981
                save = curr_field->ptr;
967
982
#if MYSQL_VERSION_ID < 50114
968
983
                curr_field->ptr = (byte *) buf + curr_field->offset();
969
984
#else
 
985
#ifdef DRIZZLED
970
986
                curr_field->ptr = (byte *) buf + curr_field->offset(curr_field->getTable()->getInsertRecord());
 
987
#else
 
988
                curr_field->ptr = (byte *) buf + curr_field->offset(curr_field->table->record[0]);
 
989
#endif
971
990
#endif
972
991
                switch (curr_field->field_name[0]) {
973
992
                        case 'A':
1121
1140
        save_write_set = table->write_set;
1122
1141
        table->write_set = NULL;
1123
1142
 
 
1143
#ifdef DRIZZLED
1124
1144
        memset(buf, 0xFF, table->getNullBytes());
 
1145
#else
 
1146
        memset(buf, 0xFF, table->s->null_bytes);
 
1147
#endif
1125
1148
        for (Field **field=GET_TABLE_FIELDS(table) ; *field ; field++) {
1126
1149
                curr_field = *field;
1127
 
 
1128
1150
                save = curr_field->ptr;
1129
1151
#if MYSQL_VERSION_ID < 50114
1130
1152
                curr_field->ptr = (byte *) buf + curr_field->offset();
1131
1153
#else
 
1154
#ifdef DRIZZLED
1132
1155
                curr_field->ptr = (byte *) buf + curr_field->offset(curr_field->getTable()->getInsertRecord());
 
1156
#else
 
1157
                curr_field->ptr = (byte *) buf + curr_field->offset(curr_field->table->record[0]);
 
1158
#endif
1133
1159
#endif
1134
1160
                switch (curr_field->field_name[0]) {
1135
1161
                        case 'R':
1211
1237
        save_write_set = table->write_set;
1212
1238
        table->write_set = NULL;
1213
1239
 
 
1240
#ifdef DRIZZLED
 
1241
        memset(buf, 0xFF, table->getNullBytes());
 
1242
#else
1214
1243
        memset(buf, 0xFF, table->s->null_bytes);
 
1244
#endif
1215
1245
        for (Field **field=GET_TABLE_FIELDS(table) ; *field ; field++) {
1216
1246
                curr_field = *field;
1217
 
 
1218
1247
                save = curr_field->ptr;
1219
1248
#if MYSQL_VERSION_ID < 50114
1220
1249
                curr_field->ptr = (byte *) buf + curr_field->offset();
1221
1250
#else
1222
 
                curr_field->ptr = (byte *) buf + curr_field->offset(curr_field->table->getInsertRecord());
 
1251
#ifdef DRIZZLED
 
1252
                curr_field->ptr = (byte *) buf + curr_field->offset(curr_field->getTable()->getInsertRecord());
 
1253
#else
 
1254
                curr_field->ptr = (byte *) buf + curr_field->offset(curr_field->table->record[0]);
 
1255
#endif
1223
1256
#endif
1224
1257
                switch (curr_field->field_name[0]) {
1225
1258
                        case 'R':
1564
1597
        table->write_set = NULL;
1565
1598
        table->read_set = NULL;
1566
1599
 
 
1600
#ifdef DRIZZLED
1567
1601
        memset(buf, 0xFF, table->getNullBytes());
 
1602
#else
 
1603
        memset(buf, 0xFF, table->s->null_bytes);
 
1604
#endif
1568
1605
        for (Field **field=GET_TABLE_FIELDS(table) ; *field ; field++) {
1569
1606
                curr_field = *field;
1570
 
 
1571
1607
                save = curr_field->ptr;
1572
1608
#if MYSQL_VERSION_ID < 50114
1573
1609
                curr_field->ptr = (byte *) buf + curr_field->offset();
1574
1610
#else
 
1611
#ifdef DRIZZLED
1575
1612
                curr_field->ptr = (byte *) buf + curr_field->offset(curr_field->getTable()->getInsertRecord());
 
1613
#else
 
1614
                curr_field->ptr = (byte *) buf + curr_field->offset(curr_field->table->record[0]);
 
1615
#endif
1576
1616
#endif
1577
1617
                switch (curr_field->field_name[0]) {
1578
1618
                        case 'B':
1730
1770
        return  (MSMetaDataTable*) MSSystemTableShare::openSystemTable(path, NULL);
1731
1771
}
1732
1772
 
 
1773
void MSMetaDataTable::use()
 
1774
{
 
1775
        MSRepositoryTable::use();
 
1776
        new_(iMetData, CSStringBuffer(80));
 
1777
        iMetDataSize = 0;
 
1778
}
 
1779
 
1733
1780
void MSMetaDataTable::unuse()
1734
1781
{
1735
1782
        MSRepositoryTable::unuse();
1748
1795
        iMetDataPos = 0;
1749
1796
        iMetBlobRepo = 0;
1750
1797
        iMetBlobOffset = 0;
1751
 
        new_(iMetData, CSStringBuffer(80));
1752
1798
        iMetStateSaved = false;
1753
1799
}
1754
1800
 
1921
1967
        save_write_set = table->write_set;
1922
1968
        table->write_set = NULL;
1923
1969
 
 
1970
#ifdef DRIZZLED
1924
1971
        memset(buf, 0xFF, table->getNullBytes());
 
1972
#else
 
1973
        memset(buf, 0xFF, table->s->null_bytes);
 
1974
#endif
1925
1975
        for (Field **field=GET_TABLE_FIELDS(table) ; *field ; field++) {
1926
1976
                curr_field = *field;
1927
 
 
1928
1977
                save = curr_field->ptr;
1929
1978
#if MYSQL_VERSION_ID < 50114
1930
1979
                curr_field->ptr = (byte *) buf + curr_field->offset();
1931
1980
#else
 
1981
#ifdef DRIZZLED
1932
1982
                curr_field->ptr = (byte *) buf + curr_field->offset(curr_field->getTable()->getInsertRecord());
 
1983
#else
 
1984
                curr_field->ptr = (byte *) buf + curr_field->offset(curr_field->table->record[0]);
 
1985
#endif
1933
1986
#endif
1934
1987
                switch (curr_field->field_name[0]) {
1935
1988
                        case 'R':
2162
2215
        exit_();
2163
2216
}
2164
2217
 
 
2218
class UpdateRowCleanUp : public CSRefObject {
 
2219
        bool do_cleanup;
 
2220
        MSMetaDataTable *tab;
 
2221
        char *row_data;
 
2222
        
 
2223
        uint32_t ref_id;
 
2224
 
 
2225
        public:
 
2226
        
 
2227
        UpdateRowCleanUp(): CSRefObject(),
 
2228
                do_cleanup(false), tab(NULL), row_data(NULL){}
 
2229
                
 
2230
        ~UpdateRowCleanUp() 
 
2231
        {
 
2232
                if (do_cleanup) {
 
2233
                        tab->deleteRow(row_data);
 
2234
                }
 
2235
        }
 
2236
        
 
2237
        void setCleanUp(MSMetaDataTable *table, char *data)
 
2238
        {
 
2239
                row_data = data;
 
2240
                tab = table;
 
2241
                do_cleanup = true;
 
2242
        }
 
2243
        
 
2244
        void cancelCleanUp()
 
2245
        {
 
2246
                do_cleanup = false;
 
2247
        }
 
2248
        
 
2249
};
 
2250
 
2165
2251
void MSMetaDataTable::updateRow(char *old_data, char *new_data)
2166
2252
{
2167
2253
        uint32_t o_repo_index, n_repo_index;
2191
2277
        
2192
2278
        // If the meta data is not for the same BLOB then we do an insert and delete.
2193
2279
        if ((n_repo_index != o_repo_index) || (n_repo_offset != o_repo_offset)) {
 
2280
                UpdateRowCleanUp *cleanup;
 
2281
                new_(cleanup, UpdateRowCleanUp());
 
2282
                push_(cleanup);
 
2283
 
2194
2284
                insertRow(new_data);
2195
 
                try_(a) {
2196
 
                        deleteRow(old_data);
2197
 
                }
2198
 
                catch_(a) {
2199
 
                        deleteRow(new_data);
2200
 
                        throw_();
2201
 
                }
2202
 
                cont_(a);
 
2285
                
 
2286
                cleanup->setCleanUp(this, new_data);
 
2287
                
 
2288
                deleteRow(old_data);
 
2289
                
 
2290
                cleanup->cancelCleanUp();
 
2291
                release_(cleanup);
 
2292
                
2203
2293
                exit_();
2204
2294
        }
2205
2295
        
2300
2390
 
2301
2391
MSSystemTableShare::~MSSystemTableShare()
2302
2392
{
 
2393
#ifdef DRIZZLED
2303
2394
        myThrLock.unlock();
 
2395
#else
 
2396
        thr_lock_delete(&myThrLock);
 
2397
#endif
2304
2398
        if (myTablePath) {
2305
2399
                myTablePath->release();
2306
2400
                myTablePath = NULL;