~jlukas79/+junk/mysql-server

« back to all changes in this revision

Viewing changes to storage/falcon/ha_falcon.cpp

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

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#include "StorageHandler.h"
34
34
#include "CmdGen.h"
35
35
#include "InfoTable.h"
 
36
#include "Format.h"
36
37
 
37
38
#ifdef _WIN32
38
39
#define I64FORMAT                       "%I64d"
52
53
#define MAX(a,b)                        ((a >= b) ? (a) : (b))
53
54
#endif
54
55
 
 
56
#ifndef ONLINE_ALTER
 
57
//#define ONLINE_ALTER
 
58
#endif
 
59
 
55
60
#ifdef DEBUG_BACKLOG
56
61
static const uint LOAD_AUTOCOMMIT_RECORDS = 10000000;
57
62
#else
79
84
 
80
85
ulonglong       falcon_record_memory_max;
81
86
ulonglong       falcon_initial_allocation;
 
87
ulonglong       falcon_serial_log_file_size;
82
88
uint            falcon_allocation_extent;
83
89
ulonglong       falcon_page_cache_size;
84
90
char*           falcon_serial_log_dir;
107
113
                                                                                                | HA_PARTIAL_COLUMN_READ
108
114
                                                                                                | HA_CAN_GEOMETRY
109
115
                                                                                                //| HA_AUTO_PART_KEY
110
 
                                                                                                | HA_BINLOG_ROW_CAPABLE);
 
116
                                                                                                | HA_ONLINE_ALTER
 
117
                                                                                                | HA_BINLOG_ROW_CAPABLE
 
118
                                                                                                | HA_CAN_READ_ORDER_IF_LIMIT);
111
119
 
112
120
static struct st_mysql_show_var falconStatus[] =
113
121
{
218
226
 
219
227
        if (error)
220
228
                {
221
 
                        // Cleanup after error
222
 
                        delete storageHandler;
223
 
                        storageHandler = 0;
224
 
                        DBUG_RETURN(1);
 
229
                // Cleanup after error
 
230
                delete storageHandler;
 
231
                storageHandler = 0;
 
232
                DBUG_RETURN(1);
225
233
                }
 
234
                
226
235
        DBUG_RETURN(0);
227
236
}
228
237
 
397
406
        activeBlobs = NULL;
398
407
        freeBlobs = NULL;
399
408
        errorText = NULL;
400
 
 
 
409
        fieldMap = NULL;
 
410
        indexOrder = false;
 
411
        
401
412
        if (table_arg)
402
413
                {
403
414
                recordLength = table_arg->reclength;
434
445
                storageConnection = NULL;
435
446
                }
436
447
 
437
 
        //delete [] dbName;
 
448
        unmapFields();
438
449
}
439
450
 
440
451
int StorageInterface::rnd_init(bool scan)
451
462
{
452
463
        DBUG_ENTER("StorageInterface::open");
453
464
 
454
 
        FALCON_OPEN();
 
465
        // Temporarily comment out DTrace probes in Falcon, see bug #36403
 
466
        // FALCON_OPEN();
455
467
 
456
468
        if (!mySqlThread)
457
469
                mySqlThread = current_thd;
504
516
        thr_lock_data_init((THR_LOCK *)storageShare->impure, &lockData, NULL);
505
517
 
506
518
        ret = setIndexes();
 
519
        
 
520
        if (table)
 
521
                mapFields(table);
 
522
        
507
523
        if (ret)
508
524
                DBUG_RETURN(error(ret));
509
525
 
523
539
        if (storageTable)
524
540
                storageTable->clearTruncateLock();
525
541
 
526
 
        FALCON_CLOSE();
 
542
        unmapFields();
 
543
 
 
544
        // Temporarily comment out DTrace probes in Falcon, see bug #36403
 
545
        // FALCON_CLOSE();
527
546
 
528
547
        DBUG_RETURN(0);
529
548
}
724
743
        DBUG_RETURN(tableFlags);
725
744
}
726
745
 
727
 
 
728
746
ulong StorageInterface::index_flags(uint idx, uint part, bool all_parts) const
729
747
{
730
748
        DBUG_ENTER("StorageInterface::index_flags");
731
 
        DBUG_RETURN(HA_READ_RANGE | HA_KEY_SCAN_NOT_ROR);
 
749
        ulong flags = HA_READ_RANGE | ((indexOrder) ? HA_READ_ORDER : HA_KEY_SCAN_NOT_ROR);
 
750
        
 
751
        DBUG_RETURN(flags);
 
752
        //DBUG_RETURN(HA_READ_RANGE | HA_KEY_SCAN_NOT_ROR | (indexOrder ? HA_READ_ORDER : 0));
732
753
}
733
754
 
734
 
 
735
 
int StorageInterface::create(const char *mySqlName, TABLE *form,
736
 
                            HA_CREATE_INFO *info)
 
755
int StorageInterface::create(const char *mySqlName, TABLE *form, HA_CREATE_INFO *info)
737
756
{
738
757
        DBUG_ENTER("StorageInterface::create");
739
758
        tempTable = (info->options & HA_LEX_CREATE_TMP_TABLE) ? true : false;
768
787
        CmdGen gen;
769
788
        const char *tableName = storageTable->getName();
770
789
        const char *schemaName = storageTable->getSchemaName();
771
 
        gen.gen("create table \"%s\".\"%s\" (\n", schemaName, tableName);
772
 
        const char *sep = "";
773
 
        char nameBuffer[129];
774
 
 
775
 
        for (n = 0; n < form->s->fields; ++n)
776
 
                {
777
 
                Field *field = form->field[n];
778
 
                CHARSET_INFO *charset = field->charset();
779
 
 
780
 
                if (charset)
781
 
                        storageShare->registerCollation(charset->name, charset);
782
 
 
783
 
                storageShare->cleanupFieldName(field->field_name, nameBuffer,
784
 
                                                                                sizeof(nameBuffer));
785
 
                gen.gen("%s  \"%s\" ", sep, nameBuffer);
786
 
                int ret = genType(field, &gen);
787
 
 
788
 
                if (ret)
789
 
                        DBUG_RETURN(ret);
790
 
 
791
 
                if (!field->maybe_null())
792
 
                        gen.gen(" not null");
793
 
 
794
 
                sep = ",\n";
795
 
                }
796
 
 
 
790
        //gen.gen("create table \"%s\".\"%s\" (\n", schemaName, tableName);
 
791
        genTable(form, &gen);
 
792
        
797
793
        if (form->found_next_number_field) // && form->s->next_number_key_offset == 0)
798
794
                {
799
795
                incrementValue = info->auto_increment_value;
802
798
                        incrementValue = 1;
803
799
                }
804
800
 
 
801
        /***
805
802
        if (form->s->primary_key < form->s->keys)
806
803
                {
807
804
                KEY *key = form->key_info + form->s->primary_key;
810
807
                }
811
808
 
812
809
        gen.gen (")");
 
810
        ***/
813
811
        const char *tableSpace = NULL;
814
812
 
815
813
        if (tempTable)
 
814
                {
 
815
                if (info->tablespace)
 
816
                        push_warning_printf(mySqlThread, MYSQL_ERROR::WARN_LEVEL_WARN, ER_ILLEGAL_HA_CREATE_OPTION,
 
817
                                "TABLESPACE option is not supported for temporary tables. Switching to '%s' tablespace.", TEMPORARY_TABLESPACE);
816
818
                tableSpace = TEMPORARY_TABLESPACE;
 
819
                }
817
820
        else if (info->tablespace)
818
821
                tableSpace = info->tablespace;
819
822
        else
840
843
                                DBUG_RETURN(error(ret));
841
844
                                }
842
845
 
 
846
        mapFields(form);
 
847
 
843
848
        DBUG_RETURN(0);
844
849
}
845
850
 
864
869
        return storageTable->share->createIndex(storageConnection, key->name, sql);
865
870
}
866
871
 
 
872
int StorageInterface::dropIndex(const char *schemaName, const char *tableName,
 
873
                                 KEY *key, int indexNumber)
 
874
{
 
875
        CmdGen gen;
 
876
        gen.gen("drop index %s.\"%s$%d\"", schemaName, tableName, indexNumber);
 
877
        const char *sql = gen.getString();
 
878
 
 
879
        return storageTable->share->dropIndex(storageConnection, key->name, sql);
 
880
}
 
881
 
867
882
#if 0
868
883
uint StorageInterface::alter_table_flags(uint flags)
869
884
{
1065
1080
                        case SQLCOM_LOAD:
1066
1081
                        case SQLCOM_ALTER_TABLE:
1067
1082
                        case SQLCOM_CREATE_TABLE:
 
1083
                        case SQLCOM_CREATE_INDEX:
1068
1084
                                storageHandler->commit(mySqlThread);
1069
1085
                                storageConnection->startTransaction(getTransactionIsolation(mySqlThread));
1070
1086
                                storageConnection->markVerb();
1328
1344
                        DBUG_RETURN(error(ret));
1329
1345
 
1330
1346
        storageTable->clearBitmap();
1331
 
        if ((ret = storageTable->indexScan()))
 
1347
        if ((ret = storageTable->indexScan(indexOrder)))
1332
1348
                DBUG_RETURN(error(ret));
1333
1349
 
1334
1350
        nextRecord = 0;
1561
1577
                        DBUG_RETURN(error(ret));
1562
1578
                }
1563
1579
 
1564
 
        storageTable->indexScan();
 
1580
        storageTable->indexScan(indexOrder);
1565
1581
        nextRecord = 0;
1566
1582
        lastRecord = -1;
1567
1583
        eq_range = eqRange;
1582
1598
        DBUG_RETURN(0);
1583
1599
}
1584
1600
 
 
1601
int StorageInterface::index_first(uchar* buf)
 
1602
{
 
1603
        storageTable->indexScan(indexOrder);
 
1604
 
 
1605
        return index_next(buf);
 
1606
}
1585
1607
 
1586
1608
int StorageInterface::index_next(uchar *buf)
1587
1609
{
1942
1964
                        DBUG_PRINT("info", ("StorageErrorOutOfRecordMemory"));
1943
1965
                        return (200 - storageError);
1944
1966
 
 
1967
                case StorageErrorTableNotEmpty:
 
1968
                        DBUG_PRINT("info", ("StorageErrorTableNotEmpty"));
 
1969
                        return HA_ERR_TABLESPACE_NOT_EMPTY;
 
1970
 
 
1971
                case StorageErrorTableSpaceDataFileExist:
 
1972
                        DBUG_PRINT("info", ("StorageErrorTableSpaceDataFileExist"));
 
1973
                        return (HA_ERR_TABLESPACE_DATAFILE_EXIST);
 
1974
 
1945
1975
                default:
1946
1976
                        DBUG_PRINT("info", ("Unknown Falcon Error"));
1947
1977
                        return (200 - storageError);
1959
1989
        DBUG_RETURN(0);
1960
1990
}
1961
1991
 
 
1992
int StorageInterface::reset()
 
1993
{
 
1994
        DBUG_ENTER("StorageInterface::start_stmt");
 
1995
        indexOrder = false;
 
1996
 
 
1997
        DBUG_RETURN(0);
 
1998
}
 
1999
 
 
2000
 
 
2001
 
1962
2002
int StorageInterface::external_lock(THD *thd, int lock_type)
1963
2003
{
1964
2004
        DBUG_ENTER("StorageInterface::external_lock");
1979
2019
                        storageConnection->releaseVerb();
1980
2020
 
1981
2021
                if (storageTable)
1982
 
                        {
1983
 
                        storageTable->clearRecord();
1984
 
                        storageTable->clearBitmap();
1985
 
                        storageTable->clearAlter();
1986
 
                        }
 
2022
                        storageTable->clearStatement();
1987
2023
                }
1988
2024
        else
1989
2025
                {
2018
2054
                        default:
2019
2055
                                break;
2020
2056
                        }
 
2057
                        
2021
2058
                int isolation = getTransactionIsolation(thd);
 
2059
                
2022
2060
                if (thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
2023
2061
                        {
2024
2062
                        checkBinLog();
2140
2178
                ADD DATAFILE 'file'
2141
2179
                USE LOGFILE GROUP logfile_group
2142
2180
                [EXTENT_SIZE [=] extent_size]
2143
 
                INITIAL_SIZE [=] initial_size
 
2181
                [INITIAL_SIZE [=] initial_size]
 
2182
                [AUTOEXTEND_SIZE [=] autoextend_size]
 
2183
                [MAX_SIZE [=] max_size]
 
2184
                [NODEGROUP [=] nodegroup_id]
 
2185
                [WAIT]
 
2186
                [COMMENT [=] comment_text]
2144
2187
                ENGINE [=] engine
2145
2188
        */
 
2189
        if (ts_info->data_file_name)
 
2190
                {
 
2191
                char buff[FN_REFLEN];
 
2192
                size_t dirname_part_length;
 
2193
                dirname_part(buff, ts_info->data_file_name, &dirname_part_length);
 
2194
                fn_format(buff, buff, mysql_real_data_home, "",
 
2195
                        MY_RELATIVE_PATH | MY_UNPACK_FILENAME);
 
2196
                if (test_if_data_home_dir(buff))
 
2197
                        {
 
2198
                        my_error(ER_WRONG_ARGUMENTS, MYF(0), "DATAFILE");
 
2199
                        DBUG_RETURN(1);
 
2200
                        }
 
2201
                }
2146
2202
 
2147
2203
        switch (ts_info->ts_cmd_type)
2148
2204
                {
2149
2205
                case CREATE_TABLESPACE:
2150
 
                        ret = storageHandler->createTablespace(ts_info->tablespace_name, ts_info->data_file_name);
 
2206
                        ret = storageHandler->createTablespace( ts_info->tablespace_name,
 
2207
                                                                                                        ts_info->data_file_name,
 
2208
                                                                                                        ts_info->initial_size,
 
2209
                                                                                                        ts_info->extent_size,
 
2210
                                                                                                        ts_info->autoextend_size,
 
2211
                                                                                                        ts_info->max_size,
 
2212
                                                                                                        ts_info->nodegroup_id,
 
2213
                                                                                                        ts_info->wait_until_completed,
 
2214
                                                                                                        ts_info->ts_comment);
2151
2215
                        break;
2152
2216
 
2153
2217
                case DROP_TABLESPACE:
2161
2225
        DBUG_RETURN(getMySqlError(ret));
2162
2226
}
2163
2227
 
 
2228
int StorageInterface::check_if_supported_alter(TABLE *altered_table, HA_CREATE_INFO *create_info, HA_ALTER_FLAGS *alter_flags, uint table_changes)
 
2229
{
 
2230
        DBUG_ENTER("StorageInterface::check_if_supported_alter");
 
2231
        tempTable = (create_info->options & HA_LEX_CREATE_TMP_TABLE) ? true : false;
 
2232
        HA_ALTER_FLAGS supported;
 
2233
        supported = supported | HA_ADD_INDEX | HA_DROP_INDEX;
 
2234
                                                /**
 
2235
                                                | HA_ADD_COLUMN | HA_ADD_UNIQUE_INDEX | HA_DROP_UNIQUE_INDEX
 
2236
                                                | HA_COLUMN_STORAGE | HA_COLUMN_FORMAT;
 
2237
                                                **/
 
2238
        HA_ALTER_FLAGS notSupported = ~(supported);
 
2239
        
 
2240
#ifndef ONLINE_ALTER
 
2241
        DBUG_RETURN(HA_ALTER_NOT_SUPPORTED);
 
2242
#endif  
 
2243
 
 
2244
        if (tempTable || (*alter_flags & notSupported).is_set())
 
2245
                DBUG_RETURN(HA_ALTER_NOT_SUPPORTED);
 
2246
 
 
2247
        // TODO:
 
2248
        // 1. Check for supported ALTER combinations
 
2249
        // 2. Check for explicit default (altered_table->s->default_values)
 
2250
        
 
2251
        if (alter_flags->is_set(HA_ADD_COLUMN))
 
2252
                {
 
2253
                Field *field = NULL;
 
2254
                
 
2255
                for (uint i = 0; i < altered_table->s->fields; i++)
 
2256
                        {
 
2257
                        field = altered_table->s->field[i];
 
2258
                        bool found = false;
 
2259
                        
 
2260
                        for (uint n = 0; n < table->s->fields; n++)
 
2261
                                if (found = (strcmp(table->s->field[n]->field_name, field->field_name) == 0))
 
2262
                                        break;
 
2263
                
 
2264
                        if (field && !found)
 
2265
                                if (!field->real_maybe_null())
 
2266
                                        {
 
2267
                                        DBUG_PRINT("info",("Online add column must be nullable"));
 
2268
                                        DBUG_RETURN(HA_ALTER_NOT_SUPPORTED);
 
2269
                                        }
 
2270
                        }
 
2271
                }
 
2272
                
 
2273
        // TODO for Add Index:
 
2274
        // 1. Check for supported ALTER combinations
 
2275
        // 2. Can error message be improved for non-null columns?
 
2276
        
 
2277
        if (alter_flags->is_set(HA_ADD_INDEX))
 
2278
                {
 
2279
                for (unsigned int n = 0; n < altered_table->s->keys; n++)
 
2280
                        {
 
2281
                        if (n != altered_table->s->primary_key)
 
2282
                                {
 
2283
                                KEY *key = altered_table->key_info + n;
 
2284
                                KEY *tableEnd = table->key_info + table->s->keys;
 
2285
                                KEY *tableKey;
 
2286
                                
 
2287
                                // Determine if this is a new index
 
2288
 
 
2289
                                for (tableKey = table->key_info; tableKey < tableEnd; tableKey++)
 
2290
                                        if (!strcmp(tableKey->name, key->name))
 
2291
                                                break;
 
2292
                                
 
2293
                                // Verify that each part is nullable
 
2294
                                
 
2295
                                if (tableKey >= tableEnd)
 
2296
                                        for (uint p = 0; p < key->key_parts; p++)
 
2297
                                                {
 
2298
                                                KEY_PART_INFO *keyPart = key->key_part + p;
 
2299
                                                if (keyPart && !keyPart->field->real_maybe_null())
 
2300
                                                        {
 
2301
                                                        DBUG_PRINT("info",("Online add index columns must be nullable"));
 
2302
                                                        DBUG_RETURN(HA_ALTER_NOT_SUPPORTED);
 
2303
                                                        }
 
2304
                                                }
 
2305
                                }
 
2306
                        }
 
2307
                }
 
2308
                
 
2309
        if (alter_flags->is_set(HA_DROP_INDEX))
 
2310
                {
 
2311
                }
 
2312
                
 
2313
        DBUG_RETURN(HA_ALTER_SUPPORTED_NO_LOCK);
 
2314
}
 
2315
 
 
2316
int StorageInterface::alter_table_phase1(THD* thd, TABLE* altered_table, HA_CREATE_INFO* create_info, HA_ALTER_INFO* alter_info, HA_ALTER_FLAGS* alter_flags)
 
2317
{
 
2318
        DBUG_ENTER("StorageInterface::alter_table_phase1");
 
2319
        int ret = 0;
 
2320
        
 
2321
        if (alter_flags->is_set(HA_ADD_COLUMN))
 
2322
                ret = addColumn(thd, altered_table, create_info, alter_info, alter_flags);
 
2323
                
 
2324
        if (alter_flags->is_set(HA_ADD_INDEX) && !ret)
 
2325
                ret = addIndex(thd, altered_table, create_info, alter_info, alter_flags);
 
2326
                
 
2327
        if (alter_flags->is_set(HA_DROP_INDEX) && !ret)
 
2328
                ret = dropIndex(thd, altered_table, create_info, alter_info, alter_flags);
 
2329
                
 
2330
        DBUG_RETURN(ret);
 
2331
}
 
2332
 
 
2333
int StorageInterface::alter_table_phase2(THD* thd, TABLE* altered_table, HA_CREATE_INFO* create_info, HA_ALTER_INFO* alter_info, HA_ALTER_FLAGS* alter_flags)
 
2334
{
 
2335
        DBUG_ENTER("StorageInterface::alter_table_phase2");
 
2336
        
 
2337
        DBUG_RETURN(0);
 
2338
}
 
2339
 
 
2340
int StorageInterface::alter_table_phase3(THD* thd, TABLE* altered_table)
 
2341
{
 
2342
        DBUG_ENTER("StorageInterface::alter_table_phase3");
 
2343
        
 
2344
        DBUG_RETURN(0);
 
2345
}
 
2346
 
 
2347
int StorageInterface::addColumn(THD* thd, TABLE* alteredTable, HA_CREATE_INFO* createInfo, HA_ALTER_INFO* alterInfo, HA_ALTER_FLAGS* alterFlags)
 
2348
{
 
2349
        int ret;
 
2350
        int64 incrementValue = 0;
 
2351
        /***
 
2352
        const char *tableName = storageTable->getName();
 
2353
        const char *schemaName = storageTable->getSchemaName();
 
2354
        ***/
 
2355
        CmdGen gen;
 
2356
        genTable(alteredTable, &gen);
 
2357
        
 
2358
        /***
 
2359
        if (alteredTable->found_next_number_field)
 
2360
                {
 
2361
                incrementValue = alterInfo->auto_increment_value;
 
2362
 
 
2363
                if (incrementValue == 0)
 
2364
                        incrementValue = 1;
 
2365
                }
 
2366
        ***/
 
2367
        
 
2368
        /***
 
2369
        if (alteredTable->s->primary_key < alteredTable->s->keys)
 
2370
                {
 
2371
                KEY *key = alteredTable->key_info + alteredTable->s->primary_key;
 
2372
                gen.gen(",\n  primary key ");
 
2373
                genKeyFields(key, &gen);
 
2374
                }
 
2375
 
 
2376
        gen.gen (")");
 
2377
        ***/
 
2378
        
 
2379
        if ((ret = storageTable->upgrade(gen.getString(), incrementValue)))
 
2380
                return (error(ret));
 
2381
 
 
2382
        return 0;
 
2383
}
 
2384
 
 
2385
int StorageInterface::addIndex(THD* thd, TABLE* alteredTable, HA_CREATE_INFO* createInfo, HA_ALTER_INFO* alterInfo, HA_ALTER_FLAGS* alterFlags)
 
2386
{
 
2387
        int ret;
 
2388
        const char *tableName = storageTable->getName();
 
2389
        const char *schemaName = storageTable->getSchemaName();
 
2390
 
 
2391
        // Find indexes to be added by comparing table and alteredTable
 
2392
 
 
2393
        for (unsigned int n = 0; n < alteredTable->s->keys; n++)
 
2394
                {
 
2395
                if (n != alteredTable->s->primary_key)
 
2396
                        {
 
2397
                        KEY *key = alteredTable->key_info + n;
 
2398
                        KEY *tableEnd = table->key_info + table->s->keys;
 
2399
                        KEY *tableKey;
 
2400
                        
 
2401
                        for (tableKey = table->key_info; tableKey < tableEnd; tableKey++)
 
2402
                                if (!strcmp(tableKey->name, key->name))
 
2403
                                        break;
 
2404
                                        
 
2405
                        if (tableKey >= tableEnd)
 
2406
                                if ((ret = createIndex(schemaName, tableName, key, n)))
 
2407
                                        return (error(ret));
 
2408
                        }
 
2409
                }
 
2410
        return 0;
 
2411
}
 
2412
 
 
2413
int StorageInterface::dropIndex(THD* thd, TABLE* alteredTable, HA_CREATE_INFO* createInfo, HA_ALTER_INFO* alterInfo, HA_ALTER_FLAGS* alterFlags)
 
2414
{
 
2415
        int ret;
 
2416
        const char *tableName = storageTable->getName();
 
2417
        const char *schemaName = storageTable->getSchemaName();
 
2418
        
 
2419
        // Find indexes to be dropped by comparing table and alteredTable
 
2420
        
 
2421
        for (unsigned int n = 0; n < table->s->keys; n++)
 
2422
                {
 
2423
                if (n != table->s->primary_key)
 
2424
                                {
 
2425
                        KEY *key = table->key_info + n;
 
2426
                        KEY *alterEnd = alteredTable->key_info + alteredTable->s->keys;
 
2427
                        KEY *alterKey;
 
2428
                        
 
2429
                        for (alterKey = alteredTable->key_info; alterKey < alterEnd; alterKey++)
 
2430
                                if (!strcmp(alterKey->name, key->name))
 
2431
                                        break;
 
2432
 
 
2433
                        if (alterKey >= alterEnd)
 
2434
                                if ((ret = dropIndex(schemaName, tableName, key, n)))
 
2435
                                return (error(ret));
 
2436
                                }
 
2437
                }
 
2438
        
 
2439
        return 0;
 
2440
}
 
2441
 
2164
2442
uint StorageInterface::max_supported_key_length(void) const
2165
2443
{
2166
2444
        // Assume 4K page unless proven otherwise.
2196
2474
                }
2197
2475
}
2198
2476
 
2199
 
 
2200
2477
int StorageInterface::setIndexes(void)
2201
2478
{
2202
 
        if (!table || storageShare->haveIndexes())
 
2479
        if (!table || storageShare->haveIndexes(table->s->keys))
2203
2480
                return 0;
2204
2481
 
2205
2482
        storageShare->lock(true);
2206
2483
 
2207
 
        if (!storageShare->haveIndexes())
 
2484
        if (!storageShare->haveIndexes(table->s->keys))
2208
2485
                {
2209
2486
                StorageIndexDesc indexDesc;
2210
2487
 
2225
2502
        return 0;
2226
2503
}
2227
2504
 
 
2505
int StorageInterface::genTable(TABLE* table, CmdGen* gen)
 
2506
{
 
2507
        const char *tableName = storageTable->getName();
 
2508
        const char *schemaName = storageTable->getSchemaName();
 
2509
        gen->gen("upgrade table \"%s\".\"%s\" (\n", schemaName, tableName);
 
2510
        const char *sep = "";
 
2511
        char nameBuffer[129];
 
2512
 
 
2513
        for (uint n = 0; n < table->s->fields; ++n)
 
2514
                {
 
2515
                Field *field = table->field[n];
 
2516
                CHARSET_INFO *charset = field->charset();
 
2517
 
 
2518
                if (charset)
 
2519
                        storageShare->registerCollation(charset->name, charset);
 
2520
 
 
2521
                storageShare->cleanupFieldName(field->field_name, nameBuffer, sizeof(nameBuffer));
 
2522
                gen->gen("%s  \"%s\" ", sep, nameBuffer);
 
2523
                int ret = genType(field, gen);
 
2524
 
 
2525
                if (ret)
 
2526
                        return (ret);
 
2527
 
 
2528
                if (!field->maybe_null())
 
2529
                        gen->gen(" not null");
 
2530
 
 
2531
                sep = ",\n";
 
2532
                }
 
2533
 
 
2534
        if (table->s->primary_key < table->s->keys)
 
2535
                {
 
2536
                KEY *key = table->key_info + table->s->primary_key;
 
2537
                gen->gen(",\n  primary key ");
 
2538
                genKeyFields(key, gen);
 
2539
                }
 
2540
 
 
2541
        gen->gen (")");
 
2542
 
 
2543
        return 0;
 
2544
}
2228
2545
 
2229
2546
int StorageInterface::genType(Field* field, CmdGen* gen)
2230
2547
{
2369
2686
        my_ptrdiff_t ptrDiff = buf - table->record[0];
2370
2687
        my_bitmap_map *old_map = dbug_tmp_use_all_columns(table, table->read_set);
2371
2688
        EncodedDataStream *dataStream = &storageTable->dataStream;
 
2689
        FieldFormat *fieldFormat = storageShare->format->format;
 
2690
        int maxId = storageShare->format->maxId;
2372
2691
        
2373
 
        for (uint n = 0; n < table->s->fields; ++n)
 
2692
        for (int n = 0; n < maxId; ++n, ++fieldFormat)
2374
2693
                {
2375
 
                Field *field = table->field[n];
 
2694
                if (fieldFormat->fieldId < 0 || fieldFormat->offset == 0)
 
2695
                        continue;
 
2696
                        
 
2697
                Field *field = fieldMap[fieldFormat->fieldId];
2376
2698
 
 
2699
                if (!field)
 
2700
                        {
 
2701
                        dataStream->encodeNull();
 
2702
                        
 
2703
                        continue;
 
2704
                        }
 
2705
                
2377
2706
                if (ptrDiff)
2378
2707
                        field->move_field_offset(ptrDiff);
2379
2708
 
2531
2860
        my_ptrdiff_t ptrDiff = buf - table->record[0];
2532
2861
        my_bitmap_map *old_map = dbug_tmp_use_all_columns(table, table->write_set);
2533
2862
        DBUG_ENTER("StorageInterface::decodeRecord");
2534
 
 
2535
 
        for (uint n = 0; n < table->s->fields; ++n)
 
2863
        FieldFormat *fieldFormat = storageTable->format->format;
 
2864
        int maxId = storageTable->format->maxId;
 
2865
        
 
2866
        for (int n = 0; n < maxId; ++n, ++fieldFormat)
2536
2867
                {
2537
 
                Field *field = table->field[n];
 
2868
                // If the format doesn't have an offset, the field doesn't exist in the record
 
2869
                
 
2870
                if (fieldFormat->fieldId < 0 || fieldFormat->offset == 0)
 
2871
                        continue;
 
2872
                        
2538
2873
                dataStream->decode();
 
2874
                Field *field = fieldMap[fieldFormat->fieldId];
2539
2875
 
 
2876
                // If we don't have a field for the physical field, just skip over it and don't worry
 
2877
                
 
2878
                if (field == NULL)
 
2879
                        continue;
 
2880
                                
2540
2881
                if (ptrDiff)
2541
2882
                        field->move_field_offset(ptrDiff);
2542
2883
 
2588
2929
                                case MYSQL_TYPE_TIMESTAMP:
2589
2930
                                        {
2590
2931
                                        int value = (int) (dataStream->value.integer64 / 1000);
2591
 
#ifdef _BIG_ENDIAN
2592
 
                                        if (table->s->db_low_byte_first)
2593
 
                                        int4store(field->ptr, value);
2594
 
                                        else
2595
 
#endif
2596
2932
                                        longstore(field->ptr, value);
2597
2933
                                        }
2598
2934
                                        break;
2602
2938
                                        break;
2603
2939
 
2604
2940
                                case MYSQL_TYPE_NEWDATE:
2605
 
                                        //field->store(dataStream->getInt64(), false);
2606
2941
                                        int3store(field->ptr, dataStream->getInt32());
2607
2942
                                        break;
2608
2943
 
2611
2946
                                        break;
2612
2947
 
2613
2948
                                case MYSQL_TYPE_DATETIME:
2614
 
                                        //field->store(dataStream->getInt64(), false);
2615
2949
                                        int8store(field->ptr, dataStream->getInt64());
2616
2950
                                        break;
2617
2951
 
2675
3009
int StorageInterface::extra(ha_extra_function operation)
2676
3010
{
2677
3011
        DBUG_ENTER("StorageInterface::extra");
 
3012
        
 
3013
        if (operation == HA_EXTRA_ORDERBY_LIMIT)
 
3014
                {
 
3015
                // SQL Layer informs us that it is considering an ORDER BY .. LIMIT
 
3016
                // query. It's time we could
 
3017
                //  1. start returning HA_READ_ORDER flag from index_flags() calls,
 
3018
                //     which will make the SQL layer consider using indexes to
 
3019
                //     satisfy ORDER BY ... LIMIT.
 
3020
                //  2. If doing #1, every index/range scan must return records in
 
3021
                //     index order.
 
3022
 
 
3023
                indexOrder = true;
 
3024
                }
 
3025
 
 
3026
        if (operation == HA_EXTRA_NO_ORDERBY_LIMIT)
 
3027
                {
 
3028
                // SQL Layer figured it won't be able to use index to resolve the 
 
3029
                // ORDER BY ... LIMIT. This could happen for a number of reasons,
 
3030
                // but the result is that we don't have to return records in index
 
3031
                // order.
 
3032
                
 
3033
                indexOrder = false;
 
3034
                }
 
3035
 
2678
3036
        DBUG_RETURN(0);
2679
3037
}
2680
3038
 
2727
3085
 
2728
3086
//*****************************************************************************
2729
3087
//
2730
 
// System Memory Usage
 
3088
// FALCON_SYSTEM_MEMORY_DETAIL
2731
3089
//
2732
3090
//*****************************************************************************
2733
 
int NfsPluginHandler::call_fillSystemMemoryDetailTable(THD *thd, TABLE_LIST *tables, COND *cond)
 
3091
int NfsPluginHandler::getSystemMemoryDetailInfo(THD *thd, TABLE_LIST *tables, COND *cond)
2734
3092
{
2735
3093
        InfoTableImpl infoTable(thd, tables, system_charset_info);
2736
3094
 
2740
3098
        return infoTable.error;
2741
3099
}
2742
3100
 
2743
 
 
2744
3101
ST_FIELD_INFO memoryDetailFieldInfo[]=
2745
3102
{
2746
3103
        {"FILE",                  120, MYSQL_TYPE_STRING,       0, 0, "File", SKIP_OPEN_TABLE},
2752
3109
        {0,                                     0, MYSQL_TYPE_STRING,   0, 0, 0, SKIP_OPEN_TABLE}
2753
3110
};
2754
3111
 
2755
 
int NfsPluginHandler::initSystemMemoryDetail(void *p)
 
3112
int NfsPluginHandler::initSystemMemoryDetailInfo(void *p)
2756
3113
{
2757
 
        DBUG_ENTER("initSystemMemoryDetail");
 
3114
        DBUG_ENTER("initSystemMemoryDetailInfo");
2758
3115
        ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE*) p;
2759
3116
        schema->fields_info = memoryDetailFieldInfo;
2760
 
        schema->fill_table = NfsPluginHandler::call_fillSystemMemoryDetailTable;
 
3117
        schema->fill_table = NfsPluginHandler::getSystemMemoryDetailInfo;
2761
3118
        DBUG_RETURN(0);
2762
3119
}
2763
3120
 
2764
 
int NfsPluginHandler::deinitSystemMemoryDetail(void *p)
 
3121
int NfsPluginHandler::deinitSystemMemoryDetailInfo(void *p)
2765
3122
{
2766
 
        DBUG_ENTER("deinitSystemMemoryDetail");
 
3123
        DBUG_ENTER("deinitSystemMemoryDetailInfo");
2767
3124
        DBUG_RETURN(0);
2768
3125
}
2769
3126
 
2770
3127
//*****************************************************************************
2771
3128
//
2772
 
// System memory usage summary
 
3129
// FALCON_SYSTEM_MEMORY_SUMMARY
2773
3130
//
2774
3131
//*****************************************************************************
2775
3132
 
2776
 
int NfsPluginHandler::call_fillSystemMemorySummaryTable(THD *thd, TABLE_LIST *tables, COND *cond)
 
3133
int NfsPluginHandler::getSystemMemorySummaryInfo(THD *thd, TABLE_LIST *tables, COND *cond)
2777
3134
{
2778
3135
        //return(pluginHandler->fillSystemMemorySummaryTable(thd, tables, cond));
2779
3136
        InfoTableImpl infoTable(thd, tables, system_charset_info);
2795
3152
        {0,                                     0, MYSQL_TYPE_STRING,           0, 0, 0, SKIP_OPEN_TABLE}
2796
3153
};
2797
3154
 
2798
 
int NfsPluginHandler::initSystemMemorySummary(void *p)
 
3155
int NfsPluginHandler::initSystemMemorySummaryInfo(void *p)
2799
3156
{
2800
 
        DBUG_ENTER("initSystemMemorySummary");
 
3157
        DBUG_ENTER("initSystemMemorySummaryInfo");
2801
3158
        ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *)p;
2802
3159
        schema->fields_info = memorySummaryFieldInfo;
2803
 
        schema->fill_table = NfsPluginHandler::call_fillSystemMemorySummaryTable;
 
3160
        schema->fill_table = NfsPluginHandler::getSystemMemorySummaryInfo;
2804
3161
 
2805
3162
        DBUG_RETURN(0);
2806
3163
}
2807
3164
 
2808
 
int NfsPluginHandler::deinitSystemMemorySummary(void *p)
 
3165
int NfsPluginHandler::deinitSystemMemorySummaryInfo(void *p)
2809
3166
{
2810
 
        DBUG_ENTER("deinitSystemMemorySummary");
 
3167
        DBUG_ENTER("deinitSystemMemorySummaryInfo");
2811
3168
        DBUG_RETURN(0);
2812
3169
}
2813
3170
 
2814
3171
//*****************************************************************************
2815
3172
//
2816
 
// Record cache usage detail
 
3173
// FALCON_RECORD_CACHE_DETAIL
2817
3174
//
2818
3175
//*****************************************************************************
2819
3176
 
2820
 
int NfsPluginHandler::call_fillRecordCacheDetailTable(THD *thd, TABLE_LIST *tables, COND *cond)
 
3177
int NfsPluginHandler::getRecordCacheDetailInfo(THD *thd, TABLE_LIST *tables, COND *cond)
2821
3178
{
2822
3179
        InfoTableImpl infoTable(thd, tables, system_charset_info);
2823
3180
 
2838
3195
        {0,                                     0, MYSQL_TYPE_STRING,   0, 0, 0, SKIP_OPEN_TABLE}
2839
3196
};
2840
3197
 
2841
 
int NfsPluginHandler::initRecordCacheDetail(void *p)
 
3198
int NfsPluginHandler::initRecordCacheDetailInfo(void *p)
2842
3199
{
2843
 
        DBUG_ENTER("initRecordCacheDetail");
 
3200
        DBUG_ENTER("initRecordCacheDetailInfo");
2844
3201
        ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *)p;
2845
3202
        schema->fields_info = recordDetailFieldInfo;
2846
 
        schema->fill_table = NfsPluginHandler::call_fillRecordCacheDetailTable;
 
3203
        schema->fill_table = NfsPluginHandler::getRecordCacheDetailInfo;
2847
3204
 
2848
3205
        DBUG_RETURN(0);
2849
3206
}
2850
3207
 
2851
 
int NfsPluginHandler::deinitRecordCacheDetail(void *p)
 
3208
int NfsPluginHandler::deinitRecordCacheDetailInfo(void *p)
2852
3209
{
2853
 
        DBUG_ENTER("deinitRecordCacheDetail");
 
3210
        DBUG_ENTER("deinitRecordCacheDetailInfo");
2854
3211
        DBUG_RETURN(0);
2855
3212
}
2856
3213
 
2857
3214
//*****************************************************************************
2858
3215
//
2859
 
// Record cache usage summary
 
3216
// FALCON_RECORD_CACHE_SUMMARY
2860
3217
//
2861
3218
//*****************************************************************************
2862
3219
 
2863
 
int NfsPluginHandler::call_fillRecordCacheSummaryTable(THD *thd, TABLE_LIST *tables, COND *cond)
 
3220
int NfsPluginHandler::getRecordCacheSummaryInfo(THD *thd, TABLE_LIST *tables, COND *cond)
2864
3221
{
2865
3222
        InfoTableImpl infoTable(thd, tables, system_charset_info);
2866
3223
 
2881
3238
        {0,                                     0, MYSQL_TYPE_STRING,           0, 0, 0, SKIP_OPEN_TABLE}
2882
3239
};
2883
3240
 
2884
 
int NfsPluginHandler::initRecordCacheSummary(void *p)
 
3241
int NfsPluginHandler::initRecordCacheSummaryInfo(void *p)
2885
3242
{
2886
 
        DBUG_ENTER("initRecordCacheSummary");
 
3243
        DBUG_ENTER("initRecordCacheSummaryInfo");
2887
3244
        ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *)p;
2888
3245
        schema->fields_info = recordSummaryFieldInfo;
2889
 
        schema->fill_table = NfsPluginHandler::call_fillRecordCacheSummaryTable;
 
3246
        schema->fill_table = NfsPluginHandler::getRecordCacheSummaryInfo;
2890
3247
 
2891
3248
        DBUG_RETURN(0);
2892
3249
}
2893
3250
 
2894
 
int NfsPluginHandler::deinitRecordCacheSummary(void *p)
 
3251
int NfsPluginHandler::deinitRecordCacheSummaryInfo(void *p)
2895
3252
{
2896
 
        DBUG_ENTER("deinitRecordCacheSummary");
 
3253
        DBUG_ENTER("deinitRecordCacheSummaryInfo");
2897
3254
        DBUG_RETURN(0);
2898
3255
}
2899
3256
 
2900
3257
//*****************************************************************************
2901
3258
//
2902
 
// Database IO
 
3259
// FALCON_TABLESPACE_IO
2903
3260
//
2904
3261
//*****************************************************************************
2905
3262
 
2906
 
int NfsPluginHandler::call_fillDatabaseIOTable(THD *thd, TABLE_LIST *tables, COND *cond)
 
3263
int NfsPluginHandler::getTableSpaceIOInfo(THD *thd, TABLE_LIST *tables, COND *cond)
2907
3264
{
2908
3265
        InfoTableImpl infoTable(thd, tables, system_charset_info);
2909
3266
 
2913
3270
        return infoTable.error;
2914
3271
}
2915
3272
 
2916
 
ST_FIELD_INFO databaseIOFieldInfo[]=
 
3273
ST_FIELD_INFO tableSpaceIOFieldInfo[]=
2917
3274
{
2918
3275
        {"TABLESPACE",    120, MYSQL_TYPE_STRING,       0, 0, "Tablespace", SKIP_OPEN_TABLE},
2919
3276
        {"PAGE_SIZE",           4, MYSQL_TYPE_LONG,             0, 0, "Page Size", SKIP_OPEN_TABLE},
2925
3282
        {0,                                     0, MYSQL_TYPE_STRING,   0, 0, 0, SKIP_OPEN_TABLE}
2926
3283
};
2927
3284
 
2928
 
int NfsPluginHandler::initDatabaseIO(void *p)
2929
 
{
2930
 
        DBUG_ENTER("initDatabaseIO");
2931
 
        ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *)p;
2932
 
        schema->fields_info = databaseIOFieldInfo;
2933
 
        schema->fill_table = NfsPluginHandler::call_fillDatabaseIOTable;
2934
 
 
2935
 
        DBUG_RETURN(0);
2936
 
}
2937
 
 
2938
 
int NfsPluginHandler::deinitDatabaseIO(void *p)
2939
 
{
2940
 
        DBUG_ENTER("deinitDatabaseIO");
2941
 
        DBUG_RETURN(0);
2942
 
}
2943
 
 
2944
 
int NfsPluginHandler::callTablesInfo(THD *thd, TABLE_LIST *tables, COND *cond)
 
3285
int NfsPluginHandler::initTableSpaceIOInfo(void *p)
 
3286
{
 
3287
        DBUG_ENTER("initTableSpaceIOInfo");
 
3288
        ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *)p;
 
3289
        schema->fields_info = tableSpaceIOFieldInfo;
 
3290
        schema->fill_table = NfsPluginHandler::getTableSpaceIOInfo;
 
3291
 
 
3292
        DBUG_RETURN(0);
 
3293
}
 
3294
 
 
3295
int NfsPluginHandler::deinitTableSpaceIOInfo(void *p)
 
3296
{
 
3297
        DBUG_ENTER("deinitTableSpaceIOInfo");
 
3298
        DBUG_RETURN(0);
 
3299
}
 
3300
 
 
3301
//*****************************************************************************
 
3302
//
 
3303
// FALCON_TABLESPACES
 
3304
//
 
3305
//*****************************************************************************
 
3306
 
 
3307
int NfsPluginHandler::getTableSpaceInfo(THD *thd, TABLE_LIST *tables, COND *cond)
 
3308
{
 
3309
        InfoTableImpl infoTableSpace(thd, tables, system_charset_info);
 
3310
 
 
3311
        if (storageHandler)
 
3312
                storageHandler->getTableSpaceInfo(&infoTableSpace);
 
3313
 
 
3314
        return infoTableSpace.error;
 
3315
}
 
3316
 
 
3317
ST_FIELD_INFO tableSpaceFieldInfo[]=
 
3318
{
 
3319
        {"TABLESPACE_NAME",     127, MYSQL_TYPE_STRING,         0, 0, "TableSpace Name", SKIP_OPEN_TABLE},
 
3320
        {"TYPE",                        127, MYSQL_TYPE_STRING,         0, 0, "Type", SKIP_OPEN_TABLE},
 
3321
        {"COMMENT",                     127, MYSQL_TYPE_STRING,         0, 0, "Comment", SKIP_OPEN_TABLE},
 
3322
        {0,                                     0, MYSQL_TYPE_STRING,           0, 0, 0, SKIP_OPEN_TABLE}
 
3323
};
 
3324
 
 
3325
int NfsPluginHandler::initTableSpaceInfo(void *p)
 
3326
{
 
3327
        DBUG_ENTER("initTableSpaceInfo");
 
3328
        ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *)p;
 
3329
        schema->fields_info = tableSpaceFieldInfo;
 
3330
        schema->fill_table = NfsPluginHandler::getTableSpaceInfo;
 
3331
 
 
3332
        DBUG_RETURN(0);
 
3333
}
 
3334
 
 
3335
int NfsPluginHandler::deinitTableSpaceInfo(void *p)
 
3336
{
 
3337
        DBUG_ENTER("deinitTableSpaceInfo");
 
3338
        DBUG_RETURN(0);
 
3339
}
 
3340
 
 
3341
//*****************************************************************************
 
3342
//
 
3343
// FALCON_TABLESPACE_FILES
 
3344
//
 
3345
//*****************************************************************************
 
3346
 
 
3347
int NfsPluginHandler::getTableSpaceFilesInfo(THD *thd, TABLE_LIST *tables, COND *cond)
 
3348
{
 
3349
        InfoTableImpl infoTableSpace(thd, tables, system_charset_info);
 
3350
 
 
3351
        if (storageHandler)
 
3352
                storageHandler->getTableSpaceFilesInfo(&infoTableSpace);
 
3353
 
 
3354
        return infoTableSpace.error;
 
3355
}
 
3356
 
 
3357
ST_FIELD_INFO tableSpaceFilesFieldInfo[]=
 
3358
{
 
3359
        {"TABLESPACE_NAME",     127, MYSQL_TYPE_STRING,         0, 0, "TableSpace Name", SKIP_OPEN_TABLE},
 
3360
        {"TYPE",                        127, MYSQL_TYPE_STRING,         0, 0, "Type", SKIP_OPEN_TABLE},
 
3361
        {"FILE_ID",                     127, MYSQL_TYPE_LONG,           0, 0, "File ID", SKIP_OPEN_TABLE},
 
3362
        {"FILE_NAME",           127, MYSQL_TYPE_STRING,         0, 0, "File Name", SKIP_OPEN_TABLE},
 
3363
        {0,                                     0, MYSQL_TYPE_STRING,           0, 0, 0, SKIP_OPEN_TABLE}
 
3364
};
 
3365
 
 
3366
int NfsPluginHandler::initTableSpaceFilesInfo(void *p)
 
3367
{
 
3368
        DBUG_ENTER("initTableSpaceFilesInfo");
 
3369
        ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *)p;
 
3370
        schema->fields_info = tableSpaceFilesFieldInfo;
 
3371
        schema->fill_table = NfsPluginHandler::getTableSpaceFilesInfo;
 
3372
 
 
3373
        DBUG_RETURN(0);
 
3374
}
 
3375
 
 
3376
int NfsPluginHandler::deinitTableSpaceFilesInfo(void *p)
 
3377
{
 
3378
        DBUG_ENTER("deinitTableSpaceFilesInfo");
 
3379
        DBUG_RETURN(0);
 
3380
}
 
3381
 
 
3382
//*****************************************************************************
 
3383
//
 
3384
// FALCON_TABLES
 
3385
//
 
3386
//*****************************************************************************
 
3387
 
 
3388
int NfsPluginHandler::getTablesInfo(THD *thd, TABLE_LIST *tables, COND *cond)
2945
3389
{
2946
3390
        InfoTableImpl infoTable(thd, tables, system_charset_info);
2947
3391
 
2951
3395
        return infoTable.error;
2952
3396
}
2953
3397
 
2954
 
 
2955
3398
ST_FIELD_INFO tablesFieldInfo[]=
2956
3399
{
2957
3400
        {"SCHEMA_NAME",   127, MYSQL_TYPE_STRING,       0, 0, "Schema Name", SKIP_OPEN_TABLE},
2967
3410
        DBUG_ENTER("initTablesInfo");
2968
3411
        ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *)p;
2969
3412
        schema->fields_info = tablesFieldInfo;
2970
 
        schema->fill_table = NfsPluginHandler::callTablesInfo;
 
3413
        schema->fill_table = NfsPluginHandler::getTablesInfo;
2971
3414
 
2972
3415
        DBUG_RETURN(0);
2973
3416
}
2974
3417
 
2975
3418
int NfsPluginHandler::deinitTablesInfo(void *p)
2976
3419
{
2977
 
        DBUG_ENTER("initTables");
 
3420
        DBUG_ENTER("deinitTablesInfo");
2978
3421
        DBUG_RETURN(0);
2979
3422
}
2980
3423
 
2981
3424
//*****************************************************************************
2982
3425
//
2983
 
// Transaction Information
 
3426
// FALCON_TRANSACTIONS
2984
3427
//
2985
3428
//*****************************************************************************
2986
3429
 
2987
 
int NfsPluginHandler::callTransactionInfo(THD *thd, TABLE_LIST *tables, COND *cond)
 
3430
int NfsPluginHandler::getTransactionInfo(THD *thd, TABLE_LIST *tables, COND *cond)
2988
3431
{
2989
3432
        InfoTableImpl infoTable(thd, tables, system_charset_info);
2990
3433
 
3014
3457
        DBUG_ENTER("initTransactionInfo");
3015
3458
        ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *)p;
3016
3459
        schema->fields_info = transactionInfoFieldInfo;
3017
 
        schema->fill_table = NfsPluginHandler::callTransactionInfo;
 
3460
        schema->fill_table = NfsPluginHandler::getTransactionInfo;
3018
3461
 
3019
3462
        DBUG_RETURN(0);
3020
3463
}
3027
3470
 
3028
3471
//*****************************************************************************
3029
3472
//
3030
 
// Transaction Summary Information
 
3473
// FALCON_TRANSACTION_SUMMARY
3031
3474
//
3032
3475
//*****************************************************************************
3033
3476
 
3034
 
int NfsPluginHandler::callTransactionSummaryInfo(THD *thd, TABLE_LIST *tables, COND *cond)
 
3477
int NfsPluginHandler::getTransactionSummaryInfo(THD *thd, TABLE_LIST *tables, COND *cond)
3035
3478
{
3036
3479
        InfoTableImpl infoTable(thd, tables, system_charset_info);
3037
3480
 
3057
3500
        DBUG_ENTER("initTransactionSummaryInfo");
3058
3501
        ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *)p;
3059
3502
        schema->fields_info = transactionInfoFieldSummaryInfo;
3060
 
        schema->fill_table = NfsPluginHandler::callTransactionSummaryInfo;
 
3503
        schema->fill_table = NfsPluginHandler::getTransactionSummaryInfo;
3061
3504
 
3062
3505
        DBUG_RETURN(0);
3063
3506
}
3068
3511
        DBUG_RETURN(0);
3069
3512
}
3070
3513
 
3071
 
 
3072
 
//*****************************************************************************
3073
 
//
3074
 
// SerialLog Information
3075
 
//
3076
 
//*****************************************************************************
3077
 
 
3078
 
int NfsPluginHandler::callSerialLogInfo(THD *thd, TABLE_LIST *tables, COND *cond)
 
3514
//*****************************************************************************
 
3515
//
 
3516
// FALCON_SERIAL_LOG_INFO
 
3517
//
 
3518
//*****************************************************************************
 
3519
 
 
3520
int NfsPluginHandler::getSerialLogInfo(THD *thd, TABLE_LIST *tables, COND *cond)
3079
3521
{
3080
3522
        InfoTableImpl infoTable(thd, tables, system_charset_info);
3081
3523
 
3100
3542
        DBUG_ENTER("initSerialLogInfoInfo");
3101
3543
        ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *)p;
3102
3544
        schema->fields_info = serialSerialLogFieldInfo;
3103
 
        schema->fill_table = NfsPluginHandler::callSerialLogInfo;
 
3545
        schema->fill_table = NfsPluginHandler::getSerialLogInfo;
3104
3546
 
3105
3547
        DBUG_RETURN(0);
3106
3548
}
3113
3555
 
3114
3556
//*****************************************************************************
3115
3557
//
3116
 
// Falcon Version Information
 
3558
// FALCON_VERSION
3117
3559
//
3118
3560
//*****************************************************************************
3119
3561
 
3120
 
int NfsPluginHandler::callFalconVersionInfo(THD *thd, TABLE_LIST *tables, COND *cond)
 
3562
int NfsPluginHandler::getFalconVersionInfo(THD *thd, TABLE_LIST *tables, COND *cond)
3121
3563
{
3122
3564
        InfoTableImpl infoTable(thd, tables, system_charset_info);
3123
3565
 
3139
3581
        DBUG_ENTER("initFalconVersionInfo");
3140
3582
        ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *)p;
3141
3583
        schema->fields_info = falconVersionFieldInfo;
3142
 
        schema->fill_table = NfsPluginHandler::callFalconVersionInfo;
 
3584
        schema->fill_table = NfsPluginHandler::getFalconVersionInfo;
3143
3585
 
3144
3586
        DBUG_RETURN(0);
3145
3587
}
3150
3592
        DBUG_RETURN(0);
3151
3593
}
3152
3594
 
3153
 
 
3154
 
//*****************************************************************************
3155
 
//
3156
 
// Sync Information
3157
 
//
3158
 
//*****************************************************************************
3159
 
 
3160
 
int NfsPluginHandler::callSyncInfo(THD *thd, TABLE_LIST *tables, COND *cond)
 
3595
//*****************************************************************************
 
3596
//
 
3597
// FALCON_SYNCOBJECTS
 
3598
//
 
3599
//*****************************************************************************
 
3600
 
 
3601
int NfsPluginHandler::getSyncInfo(THD *thd, TABLE_LIST *tables, COND *cond)
3161
3602
{
3162
3603
        InfoTableImpl infoTable(thd, tables, system_charset_info);
3163
3604
 
3182
3623
        DBUG_ENTER("initSyncInfo");
3183
3624
        ST_SCHEMA_TABLE *schema = (ST_SCHEMA_TABLE *)p;
3184
3625
        schema->fields_info = syncInfoFieldInfo;
3185
 
        schema->fill_table = NfsPluginHandler::callSyncInfo;
 
3626
        schema->fill_table = NfsPluginHandler::getSyncInfo;
3186
3627
 
3187
3628
        DBUG_RETURN(0);
3188
3629
}
3199
3640
{
3200
3641
        falcon_index_chill_threshold = *(uint *)save;
3201
3642
        if(storageHandler)
3202
 
                storageHandler->setIndexChillThreshold(falcon_index_chill_threshold * 1024 * 1024);
 
3643
                storageHandler->setIndexChillThreshold(falcon_index_chill_threshold);
3203
3644
}
3204
3645
 
3205
3646
static void updateRecordChillThreshold(MYSQL_THD thd,
3208
3649
{
3209
3650
        falcon_record_chill_threshold = *(uint *)save;
3210
3651
        if(storageHandler)
3211
 
                storageHandler->setRecordChillThreshold(falcon_record_chill_threshold * 1024 * 1024);
 
3652
                storageHandler->setRecordChillThreshold(falcon_record_chill_threshold);
3212
3653
}
3213
3654
 
3214
3655
void StorageInterface::updateRecordMemoryMax(MYSQL_THD thd, struct st_mysql_sys_var* variable, void* var_ptr, const void* save)
3244
3685
        uint count = 0;
3245
3686
        unsigned char xid[sizeof(XID)];
3246
3687
 
3247
 
        memset (xid, 0, sizeof(XID));
 
3688
        memset(xid, 0, sizeof(XID));
3248
3689
 
3249
3690
        while (storageHandler->recoverGetNextLimbo(sizeof(XID), xid))
3250
3691
                {
3251
3692
                count++;
3252
3693
                memcpy(xids++, xid, sizeof(XID));
 
3694
                
3253
3695
                if (count >= length)
3254
3696
                        break;
3255
3697
                }
3257
3699
        DBUG_RETURN(count);
3258
3700
}
3259
3701
 
 
3702
 
 
3703
void StorageInterface::mapFields(TABLE *table)
 
3704
{
 
3705
        maxFields = storageShare->format->maxId;
 
3706
        unmapFields();
 
3707
        fieldMap = new Field*[maxFields];
 
3708
        memset(fieldMap, 0, sizeof(fieldMap[0]) * maxFields);
 
3709
        char nameBuffer[129];
 
3710
 
 
3711
        for (uint n = 0; n < table->s->fields; ++n)
 
3712
                {
 
3713
                Field *field = table->field[n];
 
3714
                storageShare->cleanupFieldName(field->field_name, nameBuffer, sizeof(nameBuffer));
 
3715
                int id = storageShare->getFieldId(nameBuffer);
 
3716
                
 
3717
                if (id >= 0)
 
3718
                        fieldMap[id] = field;
 
3719
                }
 
3720
}
 
3721
 
 
3722
void StorageInterface::unmapFields(void)
 
3723
{
 
3724
        if (fieldMap)
 
3725
                {
 
3726
                delete []fieldMap;
 
3727
                fieldMap = NULL;
 
3728
                }
 
3729
}
 
3730
 
3260
3731
static MYSQL_SYSVAR_STR(serial_log_dir, falcon_serial_log_dir,
3261
3732
  PLUGIN_VAR_RQCMDARG| PLUGIN_VAR_READONLY | PLUGIN_VAR_MEMALLOC,
3262
3733
  "Falcon serial log file directory.",
3296
3767
  "Initial allocation (in bytes) of falcon user tablespace.",
3297
3768
  NULL, NULL, 0, 0, LL(4000000000), LL(1)<<20);
3298
3769
 
 
3770
static MYSQL_SYSVAR_ULONGLONG(serial_log_file_size, falcon_serial_log_file_size,
 
3771
  PLUGIN_VAR_RQCMDARG,
 
3772
  "If serial log file grows larger than this value, it will be truncated when it is reused",
 
3773
  NULL, NULL , LL(10)<<20, LL(1)<<20,LL(0x7fffffffffffffff), LL(1)<<20);
 
3774
 
3299
3775
/***
3300
3776
static MYSQL_SYSVAR_UINT(allocation_extent, falcon_allocation_extent,
3301
3777
  PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
3343
3819
        //MYSQL_SYSVAR(allocation_extent),
3344
3820
        MYSQL_SYSVAR(page_cache_size),
3345
3821
        MYSQL_SYSVAR(consistent_read),
 
3822
        MYSQL_SYSVAR(serial_log_file_size),
3346
3823
        NULL
3347
3824
};
3348
3825
 
3351
3828
static st_mysql_information_schema falcon_system_memory_summary =       { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION};
3352
3829
static st_mysql_information_schema falcon_record_cache_detail   =       { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION};
3353
3830
static st_mysql_information_schema falcon_record_cache_summary  =       { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION};
3354
 
static st_mysql_information_schema falcon_database_io                   =       { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION};
3355
 
static st_mysql_information_schema falcon_transaction_info              =       { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION};
3356
 
static st_mysql_information_schema falcon_transaction_summary_info=     { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION};
3357
 
static st_mysql_information_schema falcon_sync_info                             =       { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION};
 
3831
static st_mysql_information_schema falcon_tablespace_io                 =       { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION};
 
3832
static st_mysql_information_schema falcon_transactions                  =       { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION};
 
3833
static st_mysql_information_schema falcon_transaction_summary   =       { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION};
 
3834
static st_mysql_information_schema falcon_syncobjects                   =       { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION};
3358
3835
static st_mysql_information_schema falcon_serial_log_info               =       { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION};
 
3836
static st_mysql_information_schema falcon_tablespaces                   =       { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION};
 
3837
static st_mysql_information_schema falcon_tablespace_files              =       { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION};
3359
3838
static st_mysql_information_schema falcon_tables                                =       { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION};
3360
3839
static st_mysql_information_schema falcon_version                               =       { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION};
3361
3840
 
3382
3861
        "MySQL AB",
3383
3862
        "Falcon System Memory Detail.",
3384
3863
        PLUGIN_LICENSE_GPL,
3385
 
        NfsPluginHandler::initSystemMemoryDetail,       /* plugin init */
3386
 
        NfsPluginHandler::deinitSystemMemoryDetail,     /* plugin deinit */
 
3864
        NfsPluginHandler::initSystemMemoryDetailInfo,   /* plugin init */
 
3865
        NfsPluginHandler::deinitSystemMemoryDetailInfo, /* plugin deinit */
3387
3866
        0x0005,
3388
3867
        NULL,                                                                           /* status variables */
3389
3868
        NULL,                                                                           /* system variables */
3397
3876
        "MySQL AB",
3398
3877
        "Falcon System Memory Summary.",
3399
3878
        PLUGIN_LICENSE_GPL,
3400
 
        NfsPluginHandler::initSystemMemorySummary,      /* plugin init */
3401
 
        NfsPluginHandler::deinitSystemMemorySummary,/* plugin deinit */
 
3879
        NfsPluginHandler::initSystemMemorySummaryInfo,  /* plugin init */
 
3880
        NfsPluginHandler::deinitSystemMemorySummaryInfo,/* plugin deinit */
3402
3881
        0x0005,
3403
3882
        NULL,                                                                           /* status variables */
3404
3883
        NULL,                                                                           /* system variables */
3412
3891
        "MySQL AB",
3413
3892
        "Falcon Record Cache Detail.",
3414
3893
        PLUGIN_LICENSE_GPL,
3415
 
        NfsPluginHandler::initRecordCacheDetail,        /* plugin init */
3416
 
        NfsPluginHandler::deinitRecordCacheDetail,      /* plugin deinit */
 
3894
        NfsPluginHandler::initRecordCacheDetailInfo,    /* plugin init */
 
3895
        NfsPluginHandler::deinitRecordCacheDetailInfo,  /* plugin deinit */
3417
3896
        0x0005,
3418
3897
        NULL,                                                                           /* status variables */
3419
3898
        NULL,                                                                           /* system variables */
3427
3906
        "MySQL AB",
3428
3907
        "Falcon Record Cache Summary.",
3429
3908
        PLUGIN_LICENSE_GPL,
3430
 
        NfsPluginHandler::initRecordCacheSummary,       /* plugin init */
3431
 
        NfsPluginHandler::deinitRecordCacheSummary,     /* plugin deinit */
 
3909
        NfsPluginHandler::initRecordCacheSummaryInfo,   /* plugin init */
 
3910
        NfsPluginHandler::deinitRecordCacheSummaryInfo, /* plugin deinit */
3432
3911
        0x0005,
3433
3912
        NULL,                                                                           /* status variables */
3434
3913
        NULL,                                                                           /* system variables */
3437
3916
 
3438
3917
        {
3439
3918
        MYSQL_INFORMATION_SCHEMA_PLUGIN,
3440
 
        &falcon_transaction_info,
 
3919
        &falcon_transactions,
3441
3920
        "FALCON_TRANSACTIONS",
3442
3921
        "MySQL AB",
3443
3922
        "Falcon Transactions.",
3452
3931
 
3453
3932
        {
3454
3933
        MYSQL_INFORMATION_SCHEMA_PLUGIN,
3455
 
        &falcon_transaction_summary_info,
 
3934
        &falcon_transaction_summary,
3456
3935
        "FALCON_TRANSACTION_SUMMARY",
3457
3936
        "MySQL AB",
3458
3937
        "Falcon Transaction Summary.",
3467
3946
 
3468
3947
        {
3469
3948
        MYSQL_INFORMATION_SCHEMA_PLUGIN,
3470
 
        &falcon_sync_info,
 
3949
        &falcon_syncobjects,
3471
3950
        "FALCON_SYNCOBJECTS",
3472
3951
        "MySQL AB",
3473
3952
        "Falcon SyncObjects.",
3497
3976
 
3498
3977
        {
3499
3978
        MYSQL_INFORMATION_SCHEMA_PLUGIN,
3500
 
        &falcon_database_io,
3501
 
        "FALCON_DATABASE_IO",
 
3979
        &falcon_tablespace_io,
 
3980
        "FALCON_TABLESPACE_IO",
3502
3981
        "MySQL AB",
3503
 
        "Falcon Database IO.",
 
3982
        "Falcon Tablespace IO.",
3504
3983
        PLUGIN_LICENSE_GPL,
3505
 
        NfsPluginHandler::initDatabaseIO,                       /* plugin init */
3506
 
        NfsPluginHandler::deinitDatabaseIO,                     /* plugin deinit */
 
3984
        NfsPluginHandler::initTableSpaceIOInfo,         /* plugin init */
 
3985
        NfsPluginHandler::deinitTableSpaceIOInfo,       /* plugin deinit */
3507
3986
        0x0005,
3508
3987
        NULL,                                                                           /* status variables */
3509
3988
        NULL,                                                                           /* system variables */
3527
4006
 
3528
4007
        {
3529
4008
        MYSQL_INFORMATION_SCHEMA_PLUGIN,
 
4009
        &falcon_tablespaces,
 
4010
        "FALCON_TABLESPACES",
 
4011
        "MySQL AB",
 
4012
        "Falcon TableSpaces.",
 
4013
        PLUGIN_LICENSE_GPL,
 
4014
        NfsPluginHandler::initTableSpaceInfo,           /* plugin init */
 
4015
        NfsPluginHandler::deinitTableSpaceInfo,         /* plugin deinit */
 
4016
        0x0005,
 
4017
        NULL,                                                                           /* status variables */
 
4018
        NULL,                                                                           /* system variables */
 
4019
        NULL                                                                            /* config options   */
 
4020
        },
 
4021
 
 
4022
        {
 
4023
        MYSQL_INFORMATION_SCHEMA_PLUGIN,
 
4024
        &falcon_tablespace_files,
 
4025
        "FALCON_TABLESPACE_FILES",
 
4026
        "MySQL AB",
 
4027
        "Falcon TableSpace Files.",
 
4028
        PLUGIN_LICENSE_GPL,
 
4029
        NfsPluginHandler::initTableSpaceFilesInfo,      /* plugin init */
 
4030
        NfsPluginHandler::deinitTableSpaceFilesInfo,/* plugin deinit */
 
4031
        0x0005,
 
4032
        NULL,                                                                           /* status variables */
 
4033
        NULL,                                                                           /* system variables */
 
4034
        NULL                                                                            /* config options   */
 
4035
        },
 
4036
        
 
4037
        {
 
4038
        MYSQL_INFORMATION_SCHEMA_PLUGIN,
3530
4039
        &falcon_tables,
3531
4040
        "FALCON_TABLES",
3532
4041
        "MySQL AB",