~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/handler/ha_innodb.cc

  • Committer: Monty Taylor
  • Date: 2009-03-24 18:13:47 UTC
  • mto: (960.5.2 mordred)
  • mto: This revision was merged to the branch mainline in revision 964.
  • Revision ID: mordred@inaugust.com-20090324181347-phblgoj913uph2hs
Rename hton to engine.

Show diffs side-by-side

added added

removed removed

Lines of Context:
211
211
 
212
212
static INNOBASE_SHARE *get_share(const char *table_name);
213
213
static void free_share(INNOBASE_SHARE *share);
214
 
static int innobase_close_connection(StorageEngine *hton, Session* session);
215
 
static int innobase_commit(StorageEngine *hton, Session* session, bool all);
216
 
static int innobase_rollback(StorageEngine *hton, Session* session, bool all);
217
 
static int innobase_rollback_to_savepoint(StorageEngine *hton, Session* session, 
218
 
           void *savepoint);
219
 
static int innobase_savepoint(StorageEngine *hton, Session* session, void *savepoint);
220
 
static int innobase_release_savepoint(StorageEngine *hton, Session* session, 
221
 
           void *savepoint);
222
 
static handler *innobase_create_handler(StorageEngine *hton,
 
214
static int innobase_close_connection(StorageEngine *engine, Session* session);
 
215
static int innobase_commit(StorageEngine *engine, Session* session, bool all);
 
216
static int innobase_rollback(StorageEngine *engine, Session* session, bool all);
 
217
static int innobase_rollback_to_savepoint(StorageEngine *engine, Session* session, 
 
218
           void *savepoint);
 
219
static int innobase_savepoint(StorageEngine *engine, Session* session, void *savepoint);
 
220
static int innobase_release_savepoint(StorageEngine *engine, Session* session, 
 
221
           void *savepoint);
 
222
static handler *innobase_create_handler(StorageEngine *engine,
223
223
                                        TABLE_SHARE *table,
224
224
                                        MEM_ROOT *mem_root);
225
225
 
274
274
  NULL, NULL, 50, 1, 1024 * 1024 * 1024, 0);
275
275
 
276
276
 
277
 
static handler *innobase_create_handler(StorageEngine *hton,
 
277
static handler *innobase_create_handler(StorageEngine *engine,
278
278
                                        TABLE_SHARE *table, 
279
279
                                        MEM_ROOT *mem_root)
280
280
{
281
 
  return new (mem_root) ha_innobase(hton, table);
 
281
  return new (mem_root) ha_innobase(engine, table);
282
282
}
283
283
 
284
284
/***********************************************************************
288
288
innobase_xa_prepare(
289
289
/*================*/
290
290
                        /* out: 0 or error number */
291
 
        StorageEngine* hton,
 
291
        StorageEngine* engine,
292
292
        Session*        session,        /* in: handle to the MySQL thread of the user
293
293
                        whose XA transaction should be prepared */
294
294
        bool    all);   /* in: TRUE - commit transaction
301
301
/*================*/
302
302
                                /* out: number of prepared transactions
303
303
                                stored in xid_list */
304
 
        StorageEngine* hton,
 
304
        StorageEngine* engine,
305
305
        XID*    xid_list,       /* in/out: prepared transactions */
306
306
        uint    len);           /* in: number of slots in xid_list */
307
307
/***********************************************************************
312
312
innobase_commit_by_xid(
313
313
/*===================*/
314
314
                        /* out: 0 or error number */
315
 
        StorageEngine* hton,
 
315
        StorageEngine* engine,
316
316
        XID*    xid);   /* in: X/Open XA transaction identification */
317
317
/***********************************************************************
318
318
This function is used to rollback one X/Open XA distributed transaction
322
322
innobase_rollback_by_xid(
323
323
/*=====================*/
324
324
                        /* out: 0 or error number */
325
 
        StorageEngine* hton,
 
325
        StorageEngine* engine,
326
326
        XID     *xid);  /* in: X/Open XA transaction identification */
327
327
/*********************************************************************
328
328
Removes all tables in the named database inside InnoDB. */
331
331
innobase_drop_database(
332
332
/*===================*/
333
333
                        /* out: error number */
334
 
        StorageEngine* hton, /* in: StorageEngine of Innodb */
 
334
        StorageEngine* engine, /* in: StorageEngine of Innodb */
335
335
        char*   path);  /* in: database path; inside InnoDB the name
336
336
                        of the last directory in the path is used as
337
337
                        the database name: for example, in 'mysql/data/test'
352
352
innobase_start_trx_and_assign_read_view(
353
353
/*====================================*/
354
354
                        /* out: 0 */
355
 
        StorageEngine* hton, /* in: Innodb StorageEngine */ 
 
355
        StorageEngine* engine, /* in: Innodb StorageEngine */ 
356
356
        Session*        session);       /* in: MySQL thread handle of the user for whom
357
357
                        the transaction should be committed */
358
358
/********************************************************************
363
363
innobase_flush_logs(
364
364
/*================*/
365
365
                                /* out: TRUE if error */
366
 
        StorageEngine*  hton);  /* in: InnoDB StorageEngine */
 
366
        StorageEngine*  engine);        /* in: InnoDB StorageEngine */
367
367
 
368
368
/****************************************************************************
369
369
Implements the SHOW INNODB STATUS command. Sends the output of the InnoDB
372
372
bool
373
373
innodb_show_status(
374
374
/*===============*/
375
 
        StorageEngine*  hton,   /* in: the innodb StorageEngine */
 
375
        StorageEngine*  engine, /* in: the innodb StorageEngine */
376
376
        Session*        session,        /* in: the MySQL query thread of the caller */
377
377
        stat_print_fn *stat_print);
378
378
static
379
 
bool innobase_show_status(StorageEngine *hton, Session* session, 
 
379
bool innobase_show_status(StorageEngine *engine, Session* session, 
380
380
                          stat_print_fn* stat_print,
381
381
                          enum ha_stat_type stat_type);
382
382
 
642
642
innobase_release_temporary_latches(
643
643
/*===============================*/
644
644
                                /* out: 0 */
645
 
        StorageEngine *hton,    /* in: StorageEngine */
 
645
        StorageEngine *engine,  /* in: StorageEngine */
646
646
        Session*                session)        /* in: MySQL thread */
647
647
{
648
648
        trx_t*  trx;
649
649
 
650
 
        assert(hton == innodb_hton_ptr);
 
650
        assert(engine == innodb_hton_ptr);
651
651
 
652
652
        if (!innodb_inited) {
653
653
 
1279
1279
/*************************************************************************
1280
1280
Construct ha_innobase handler. */
1281
1281
UNIV_INTERN
1282
 
ha_innobase::ha_innobase(StorageEngine *hton, TABLE_SHARE *table_arg)
1283
 
  :handler(hton, table_arg),
 
1282
ha_innobase::ha_innobase(StorageEngine *engine, TABLE_SHARE *table_arg)
 
1283
  :handler(engine, table_arg),
1284
1284
  int_table_flags(HA_REC_NOT_IN_SEQ |
1285
1285
                  HA_NULL_IN_KEY |
1286
1286
                  HA_CAN_INDEX_BLOBS |
1350
1350
void
1351
1351
innobase_register_stmt(
1352
1352
/*===================*/
1353
 
        StorageEngine*  hton,   /* in: Innobase hton */
 
1353
        StorageEngine*  engine, /* in: Innobase engine */
1354
1354
        Session*        session)        /* in: MySQL session (connection) object */
1355
1355
{
1356
 
        assert(hton == innodb_hton_ptr);
 
1356
        assert(engine == innodb_hton_ptr);
1357
1357
        /* Register the statement */
1358
 
        trans_register_ha(session, FALSE, hton);
 
1358
        trans_register_ha(session, FALSE, engine);
1359
1359
}
1360
1360
 
1361
1361
/*************************************************************************
1369
1369
void
1370
1370
innobase_register_trx_and_stmt(
1371
1371
/*===========================*/
1372
 
        StorageEngine *hton, /* in: Innobase StorageEngine */
 
1372
        StorageEngine *engine, /* in: Innobase StorageEngine */
1373
1373
        Session*        session)        /* in: MySQL session (connection) object */
1374
1374
{
1375
1375
        /* NOTE that actually innobase_register_stmt() registers also
1376
1376
        the transaction in the AUTOCOMMIT=1 mode. */
1377
1377
 
1378
 
        innobase_register_stmt(hton, session);
 
1378
        innobase_register_stmt(engine, session);
1379
1379
 
1380
1380
        if (session_test_options(session, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
1381
1381
 
1382
1382
                /* No autocommit mode, register for a transaction */
1383
 
                trans_register_ha(session, TRUE, hton);
 
1383
                trans_register_ha(session, TRUE, engine);
1384
1384
        }
1385
1385
}
1386
1386
 
2153
2153
the logs, and the name of this function should be innobase_checkpoint. */
2154
2154
static
2155
2155
bool
2156
 
innobase_flush_logs(StorageEngine *hton)
 
2156
innobase_flush_logs(StorageEngine *engine)
2157
2157
/*=====================*/
2158
2158
                                /* out: TRUE if error */
2159
2159
{
2160
2160
        bool    result = 0;
2161
2161
 
2162
 
        assert(hton == innodb_hton_ptr);
 
2162
        assert(engine == innodb_hton_ptr);
2163
2163
 
2164
2164
        log_buffer_flush_to_disk();
2165
2165
 
2192
2192
innobase_start_trx_and_assign_read_view(
2193
2193
/*====================================*/
2194
2194
                        /* out: 0 */
2195
 
        StorageEngine *hton, /* in: Innodb StorageEngine */ 
 
2195
        StorageEngine *engine, /* in: Innodb StorageEngine */ 
2196
2196
        Session*        session)        /* in: MySQL thread handle of the user for whom
2197
2197
                        the transaction should be committed */
2198
2198
{
2199
2199
        trx_t*  trx;
2200
2200
 
2201
 
        assert(hton == innodb_hton_ptr);
 
2201
        assert(engine == innodb_hton_ptr);
2202
2202
 
2203
2203
        /* Create a new trx struct for session, if it does not yet have one */
2204
2204
 
2221
2221
        /* Set the MySQL flag to mark that there is an active transaction */
2222
2222
 
2223
2223
        if (trx->active_trans == 0) {
2224
 
                innobase_register_trx_and_stmt(hton, current_session);
 
2224
                innobase_register_trx_and_stmt(engine, current_session);
2225
2225
                trx->active_trans = 1;
2226
2226
        }
2227
2227
 
2236
2236
innobase_commit(
2237
2237
/*============*/
2238
2238
                        /* out: 0 */
2239
 
        StorageEngine *hton, /* in: Innodb StorageEngine */ 
 
2239
        StorageEngine *engine, /* in: Innodb StorageEngine */ 
2240
2240
        Session*        session,        /* in: MySQL thread handle of the user for whom
2241
2241
                        the transaction should be committed */
2242
2242
        bool    all)    /* in:  TRUE - commit transaction
2244
2244
{
2245
2245
        trx_t*          trx;
2246
2246
 
2247
 
        assert(hton == innodb_hton_ptr);
 
2247
        assert(engine == innodb_hton_ptr);
2248
2248
 
2249
2249
        trx = check_trx_exists(session);
2250
2250
 
2360
2360
innobase_rollback(
2361
2361
/*==============*/
2362
2362
                        /* out: 0 or error number */
2363
 
        StorageEngine *hton, /* in: Innodb StorageEngine */ 
 
2363
        StorageEngine *engine, /* in: Innodb StorageEngine */ 
2364
2364
        Session*        session,        /* in: handle to the MySQL thread of the user
2365
2365
                        whose transaction should be rolled back */
2366
2366
        bool    all)    /* in:  TRUE - commit transaction
2369
2369
        int     error = 0;
2370
2370
        trx_t*  trx;
2371
2371
 
2372
 
        assert(hton == innodb_hton_ptr);
 
2372
        assert(engine == innodb_hton_ptr);
2373
2373
 
2374
2374
        trx = check_trx_exists(session);
2375
2375
 
2433
2433
/*===========================*/
2434
2434
                                /* out: 0 if success, HA_ERR_NO_SAVEPOINT if
2435
2435
                                no savepoint with the given name */
2436
 
        StorageEngine *hton,       /* in: Innodb StorageEngine */ 
 
2436
        StorageEngine *engine,       /* in: Innodb StorageEngine */ 
2437
2437
        Session*        session,                /* in: handle to the MySQL thread of the user
2438
2438
                                whose transaction should be rolled back */
2439
2439
        void*   savepoint)      /* in: savepoint data */
2443
2443
        trx_t*          trx;
2444
2444
        char            name[64];
2445
2445
 
2446
 
        assert(hton == innodb_hton_ptr);
 
2446
        assert(engine == innodb_hton_ptr);
2447
2447
 
2448
2448
        trx = check_trx_exists(session);
2449
2449
 
2470
2470
/*=======================*/
2471
2471
                                /* out: 0 if success, HA_ERR_NO_SAVEPOINT if
2472
2472
                                no savepoint with the given name */
2473
 
        StorageEngine*  hton,   /* in: StorageEngine for Innodb */
 
2473
        StorageEngine*  engine, /* in: StorageEngine for Innodb */
2474
2474
        Session*        session,                /* in: handle to the MySQL thread of the user
2475
2475
                                whose transaction should be rolled back */
2476
2476
        void*   savepoint)      /* in: savepoint data */
2479
2479
        trx_t*          trx;
2480
2480
        char            name[64];
2481
2481
 
2482
 
        assert(hton == innodb_hton_ptr);
 
2482
        assert(engine == innodb_hton_ptr);
2483
2483
 
2484
2484
        trx = check_trx_exists(session);
2485
2485
 
2499
2499
innobase_savepoint(
2500
2500
/*===============*/
2501
2501
                                /* out: always 0, that is, always succeeds */
2502
 
        StorageEngine*  hton,   /* in: handle to the Innodb StorageEngine */
 
2502
        StorageEngine*  engine,   /* in: handle to the Innodb StorageEngine */
2503
2503
        Session*        session,                /* in: handle to the MySQL thread */
2504
2504
        void*   savepoint)      /* in: savepoint data */
2505
2505
{
2506
2506
        int     error = 0;
2507
2507
        trx_t*  trx;
2508
2508
 
2509
 
        assert(hton == innodb_hton_ptr);
 
2509
        assert(engine == innodb_hton_ptr);
2510
2510
 
2511
2511
        /*
2512
2512
          In the autocommit mode there is no sense to set a savepoint
2541
2541
innobase_close_connection(
2542
2542
/*======================*/
2543
2543
                        /* out: 0 or error number */
2544
 
        StorageEngine*  hton,   /* in:  innobase StorageEngine */
 
2544
        StorageEngine*  engine, /* in:  innobase StorageEngine */
2545
2545
        Session*        session)        /* in: handle to the MySQL thread of the user
2546
2546
                        whose resources should be free'd */
2547
2547
{
2548
2548
        trx_t*  trx;
2549
2549
 
2550
 
        assert(hton == innodb_hton_ptr);
 
2550
        assert(engine == innodb_hton_ptr);
2551
2551
        trx = session_to_trx(session);
2552
2552
 
2553
2553
        ut_a(trx);
6271
6271
innobase_drop_database(
6272
6272
/*===================*/
6273
6273
                        /* out: error number */
6274
 
        StorageEngine *hton, /* in: StorageEngine of Innodb */
 
6274
        StorageEngine *engine, /* in: StorageEngine of Innodb */
6275
6275
        char*   path)   /* in: database path; inside InnoDB the name
6276
6276
                        of the last directory in the path is used as
6277
6277
                        the database name: for example, in 'mysql/data/test'
6287
6287
        /* Get the transaction associated with the current session, or create one
6288
6288
        if not yet created */
6289
6289
 
6290
 
        assert(hton == innodb_hton_ptr);
 
6290
        assert(engine == innodb_hton_ptr);
6291
6291
 
6292
6292
        /* In the Windows plugin, session = current_session is always NULL */
6293
6293
        if (session) {
7758
7758
bool
7759
7759
innodb_show_status(
7760
7760
/*===============*/
7761
 
        StorageEngine*  hton,   /* in: the innodb StorageEngine */
 
7761
        StorageEngine*  engine, /* in: the innodb StorageEngine */
7762
7762
        Session*        session,        /* in: the MySQL query thread of the caller */
7763
7763
        stat_print_fn *stat_print)
7764
7764
{
7768
7768
        ulint                   trx_list_start = ULINT_UNDEFINED;
7769
7769
        ulint                   trx_list_end = ULINT_UNDEFINED;
7770
7770
 
7771
 
        assert(hton == innodb_hton_ptr);
 
7771
        assert(engine == innodb_hton_ptr);
7772
7772
 
7773
7773
        trx = check_trx_exists(session);
7774
7774
 
7845
7845
bool
7846
7846
innodb_mutex_show_status(
7847
7847
/*=====================*/
7848
 
        StorageEngine*  hton,   /* in: the innodb StorageEngine */
 
7848
        StorageEngine*  engine, /* in: the innodb StorageEngine */
7849
7849
        Session*        session,                /* in: the MySQL query thread of the
7850
7850
                                        caller */
7851
7851
        stat_print_fn*  stat_print)
7862
7862
        uint64_t rw_lock_wait_time= 0;
7863
7863
#endif /* UNIV_DEBUG */
7864
7864
        uint      hton_name_len= strlen(innobase_hton_name), buf1len, buf2len;
7865
 
        assert(hton == innodb_hton_ptr);
 
7865
        assert(engine == innodb_hton_ptr);
7866
7866
 
7867
7867
        mutex_enter(&mutex_list_mutex);
7868
7868
 
7964
7964
}
7965
7965
 
7966
7966
static
7967
 
bool innobase_show_status(StorageEngine *hton, Session* session, 
 
7967
bool innobase_show_status(StorageEngine *engine, Session* session, 
7968
7968
                          stat_print_fn* stat_print,
7969
7969
                          enum ha_stat_type stat_type)
7970
7970
{
7971
 
        assert(hton == innodb_hton_ptr);
 
7971
        assert(engine == innodb_hton_ptr);
7972
7972
 
7973
7973
        switch (stat_type) {
7974
7974
        case HA_ENGINE_STATUS:
7975
 
                return innodb_show_status(hton, session, stat_print);
 
7975
                return innodb_show_status(engine, session, stat_print);
7976
7976
        case HA_ENGINE_MUTEX:
7977
 
                return innodb_mutex_show_status(hton, session, stat_print);
 
7977
                return innodb_mutex_show_status(engine, session, stat_print);
7978
7978
        default:
7979
7979
                return(FALSE);
7980
7980
        }
8660
8660
innobase_xa_prepare(
8661
8661
/*================*/
8662
8662
                        /* out: 0 or error number */
8663
 
        StorageEngine   *hton,
 
8663
        StorageEngine   *engine,
8664
8664
        Session*        session,        /* in: handle to the MySQL thread of the user
8665
8665
                        whose XA transaction should be prepared */
8666
8666
        bool    all)    /* in: TRUE - commit transaction
8669
8669
        int error = 0;
8670
8670
        trx_t* trx = check_trx_exists(session);
8671
8671
 
8672
 
        assert(hton == innodb_hton_ptr);
 
8672
        assert(engine == innodb_hton_ptr);
8673
8673
 
8674
8674
        if (all || !session_test_options(session, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
8675
8675
        {
8761
8761
/*================*/
8762
8762
                                /* out: number of prepared transactions
8763
8763
                                stored in xid_list */
8764
 
        StorageEngine *hton,
 
8764
        StorageEngine *engine,
8765
8765
        XID*    xid_list,       /* in/out: prepared transactions */
8766
8766
        uint    len)            /* in: number of slots in xid_list */
8767
8767
{
8768
 
        assert(hton == innodb_hton_ptr);
 
8768
        assert(engine == innodb_hton_ptr);
8769
8769
 
8770
8770
        if (len == 0 || xid_list == NULL) {
8771
8771
 
8783
8783
innobase_commit_by_xid(
8784
8784
/*===================*/
8785
8785
                        /* out: 0 or error number */
8786
 
        StorageEngine *hton,
 
8786
        StorageEngine *engine,
8787
8787
        XID*    xid)    /* in: X/Open XA transaction identification */
8788
8788
{
8789
8789
        trx_t*  trx;
8790
8790
 
8791
 
        assert(hton == innodb_hton_ptr);
 
8791
        assert(engine == innodb_hton_ptr);
8792
8792
 
8793
8793
        trx = trx_get_trx_by_xid(xid);
8794
8794
 
8809
8809
innobase_rollback_by_xid(
8810
8810
/*=====================*/
8811
8811
                        /* out: 0 or error number */
8812
 
        StorageEngine *hton,
 
8812
        StorageEngine *engine,
8813
8813
        XID     *xid)   /* in: X/Open XA transaction identification */
8814
8814
{
8815
8815
        trx_t*  trx;
8816
8816
 
8817
 
        assert(hton == innodb_hton_ptr);
 
8817
        assert(engine == innodb_hton_ptr);
8818
8818
 
8819
8819
        trx = trx_get_trx_by_xid(xid);
8820
8820