~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Jay Pipes
  • Date: 2008-07-17 19:20:49 UTC
  • mto: This revision was merged to the branch mainline in revision 182.
  • Revision ID: jay@mysql.com-20080717192049-b3h6tlylrssff8a7
Removed DBUG symbols from innodb handler

Show diffs side-by-side

added added

removed removed

Lines of Context:
539
539
{
540
540
        trx_t*  trx;
541
541
 
542
 
        DBUG_ASSERT(hton == innodb_hton_ptr);
 
542
        assert(hton == innodb_hton_ptr);
543
543
 
544
544
        if (!innodb_inited) {
545
545
 
878
878
                my_close(). */
879
879
                fd2 = dup(fd);
880
880
                if (fd2 < 0) {
881
 
                        DBUG_PRINT("error",("Got error %d on dup",fd2));
882
881
                        my_errno=errno;
883
882
                        my_error(EE_OUT_OF_FILERESOURCES,
884
883
                                 MYF(ME_BELL+ME_WAITTANG),
925
924
        ut_ad(thd == current_thd);
926
925
 
927
926
        if (trx == NULL) {
928
 
                DBUG_ASSERT(thd != NULL);
 
927
                assert(thd != NULL);
929
928
                trx = trx_allocate_for_mysql();
930
929
 
931
930
                trx->mysql_thd = thd;
1414
1413
        bool            ret;
1415
1414
        char            *default_path;
1416
1415
 
1417
 
        DBUG_ENTER("innobase_init");
1418
1416
        handlerton *innobase_hton= (handlerton *)p;
1419
1417
        innodb_hton_ptr = innobase_hton;
1420
1418
 
1678
1676
        pthread_cond_init(&commit_cond, NULL);
1679
1677
        innodb_inited= 1;
1680
1678
 
1681
 
        DBUG_RETURN(FALSE);
 
1679
        return(FALSE);
1682
1680
error:
1683
 
        DBUG_RETURN(TRUE);
 
1681
        return(TRUE);
1684
1682
}
1685
1683
 
1686
1684
/***********************************************************************
1694
1692
{
1695
1693
        int     err= 0;
1696
1694
 
1697
 
        DBUG_ENTER("innobase_end");
1698
 
 
1699
1695
#ifdef __NETWARE__      /* some special cleanup for NetWare */
1700
1696
        if (nw_panic) {
1701
1697
                set_panic_flag_for_netware();
1718
1714
                pthread_cond_destroy(&commit_cond);
1719
1715
        }
1720
1716
 
1721
 
        DBUG_RETURN(err);
 
1717
        return(err);
1722
1718
}
1723
1719
 
1724
1720
/********************************************************************
1732
1728
{
1733
1729
        bool    result = 0;
1734
1730
 
1735
 
        DBUG_ENTER("innobase_flush_logs");
1736
 
 
1737
1731
        log_buffer_flush_to_disk();
1738
1732
 
1739
 
        DBUG_RETURN(result);
 
1733
        return(result);
1740
1734
}
1741
1735
 
1742
1736
/*********************************************************************
1771
1765
{
1772
1766
        trx_t*  trx;
1773
1767
 
1774
 
        DBUG_ENTER("innobase_start_trx_and_assign_read_view");
1775
 
 
1776
1768
        /* Create a new trx struct for thd, if it does not yet have one */
1777
1769
 
1778
1770
        trx = check_trx_exists(thd);
1798
1790
                trx->active_trans = 1;
1799
1791
        }
1800
1792
 
1801
 
        DBUG_RETURN(0);
 
1793
        return(0);
1802
1794
}
1803
1795
 
1804
1796
/*********************************************************************
1817
1809
{
1818
1810
        trx_t*          trx;
1819
1811
 
1820
 
        DBUG_ENTER("innobase_commit");
1821
 
        DBUG_PRINT("trans", ("ending transaction"));
1822
 
 
1823
1812
        trx = check_trx_exists(thd);
1824
1813
 
1825
1814
        /* Update the info whether we should skip XA steps that eat CPU time */
1926
1915
        threads: */
1927
1916
        srv_active_wake_master_thread();
1928
1917
 
1929
 
        DBUG_RETURN(0);
 
1918
        return(0);
1930
1919
}
1931
1920
 
1932
1921
/*********************************************************************
1945
1934
        int     error = 0;
1946
1935
        trx_t*  trx;
1947
1936
 
1948
 
        DBUG_ENTER("innobase_rollback");
1949
 
        DBUG_PRINT("trans", ("aborting transaction"));
1950
 
 
1951
1937
        trx = check_trx_exists(thd);
1952
1938
 
1953
1939
        /* Update the info whether we should skip XA steps that eat CPU time */
1974
1960
                error = trx_rollback_last_sql_stat_for_mysql(trx);
1975
1961
        }
1976
1962
 
1977
 
        DBUG_RETURN(convert_error_code_to_mysql(error, NULL));
 
1963
        return(convert_error_code_to_mysql(error, NULL));
1978
1964
}
1979
1965
 
1980
1966
/*********************************************************************
1988
1974
{
1989
1975
        int     error = 0;
1990
1976
 
1991
 
        DBUG_ENTER("innobase_rollback_trx");
1992
 
        DBUG_PRINT("trans", ("aborting transaction"));
1993
 
 
1994
1977
        /* Release a possible FIFO ticket and search latch. Since we will
1995
1978
        reserve the kernel mutex, we have to release the search system latch
1996
1979
        first to obey the latching order. */
2005
1988
 
2006
1989
        error = trx_rollback_for_mysql(trx);
2007
1990
 
2008
 
        DBUG_RETURN(convert_error_code_to_mysql(error, NULL));
 
1991
        return(convert_error_code_to_mysql(error, NULL));
2009
1992
}
2010
1993
 
2011
1994
/*********************************************************************
2026
2009
        trx_t*          trx;
2027
2010
        char            name[64];
2028
2011
 
2029
 
        DBUG_ENTER("innobase_rollback_to_savepoint");
2030
 
 
2031
2012
        trx = check_trx_exists(thd);
2032
2013
 
2033
2014
        /* Release a possible FIFO ticket and search latch. Since we will
2042
2023
 
2043
2024
        error = (int) trx_rollback_to_savepoint_for_mysql(trx, name,
2044
2025
                                                &mysql_binlog_cache_pos);
2045
 
        DBUG_RETURN(convert_error_code_to_mysql(error, NULL));
 
2026
        return(convert_error_code_to_mysql(error, NULL));
2046
2027
}
2047
2028
 
2048
2029
/*********************************************************************
2062
2043
        trx_t*          trx;
2063
2044
        char            name[64];
2064
2045
 
2065
 
        DBUG_ENTER("innobase_release_savepoint");
2066
 
 
2067
2046
        trx = check_trx_exists(thd);
2068
2047
 
2069
2048
        /* TODO: use provided savepoint data area to store savepoint data */
2072
2051
 
2073
2052
        error = (int) trx_release_savepoint_for_mysql(trx, name);
2074
2053
 
2075
 
        DBUG_RETURN(convert_error_code_to_mysql(error, NULL));
 
2054
        return(convert_error_code_to_mysql(error, NULL));
2076
2055
}
2077
2056
 
2078
2057
/*********************************************************************
2089
2068
        int     error = 0;
2090
2069
        trx_t*  trx;
2091
2070
 
2092
 
        DBUG_ENTER("innobase_savepoint");
2093
 
 
2094
2071
        /*
2095
2072
          In the autocommit mode there is no sense to set a savepoint
2096
2073
          (unless we are in sub-statement), so SQL layer ensures that
2097
2074
          this method is never called in such situation.
2098
2075
        */
2099
2076
#ifdef MYSQL_SERVER /* plugins cannot access thd->in_sub_stmt */
2100
 
        DBUG_ASSERT(thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN) ||
 
2077
        assert(thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN) ||
2101
2078
                thd->in_sub_stmt);
2102
2079
#endif /* MYSQL_SERVER */
2103
2080
 
2110
2087
        innobase_release_stat_resources(trx);
2111
2088
 
2112
2089
        /* cannot happen outside of transaction */
2113
 
        DBUG_ASSERT(trx->active_trans);
 
2090
        assert(trx->active_trans);
2114
2091
 
2115
2092
        /* TODO: use provided savepoint data area to store savepoint data */
2116
2093
        char name[64];
2118
2095
 
2119
2096
        error = (int) trx_savepoint_for_mysql(trx, name, (ib_longlong)0);
2120
2097
 
2121
 
        DBUG_RETURN(convert_error_code_to_mysql(error, NULL));
 
2098
        return(convert_error_code_to_mysql(error, NULL));
2122
2099
}
2123
2100
 
2124
2101
/*********************************************************************
2134
2111
{
2135
2112
        trx_t*  trx;
2136
2113
 
2137
 
        DBUG_ENTER("innobase_close_connection");
2138
 
        DBUG_ASSERT(hton == innodb_hton_ptr);
 
2114
        assert(hton == innodb_hton_ptr);
2139
2115
        trx = thd_to_trx(thd);
2140
2116
 
2141
2117
        ut_a(trx);
2162
2138
        thr_local_free(trx->mysql_thread_id);
2163
2139
        trx_free_for_mysql(trx);
2164
2140
 
2165
 
        DBUG_RETURN(0);
 
2141
        return(0);
2166
2142
}
2167
2143
 
2168
2144
 
2246
2222
 
2247
2223
        name_ptr = ptr + 1;
2248
2224
 
2249
 
        DBUG_ASSERT(ptr > name);
 
2225
        assert(ptr > name);
2250
2226
 
2251
2227
        ptr--;
2252
2228
 
2281
2257
        char            norm_name[1000];
2282
2258
        THD*            thd;
2283
2259
 
2284
 
        DBUG_ENTER("ha_innobase::open");
2285
 
 
2286
2260
        UT_NOT_USED(mode);
2287
2261
        UT_NOT_USED(test_if_locked);
2288
2262
 
2293
2267
 
2294
2268
        if (!(share=get_share(name))) {
2295
2269
 
2296
 
                DBUG_RETURN(1);
 
2270
                return(1);
2297
2271
        }
2298
2272
 
2299
2273
        /* Create buffers for packing the fields of a record. Why
2310
2284
                        NullS)) {
2311
2285
                free_share(share);
2312
2286
 
2313
 
                DBUG_RETURN(1);
 
2287
                return(1);
2314
2288
        }
2315
2289
 
2316
2290
        /* Get pointer to a table object in InnoDB dictionary cache */
2337
2311
                my_free(upd_buff, MYF(0));
2338
2312
                my_errno = ENOENT;
2339
2313
 
2340
 
                DBUG_RETURN(HA_ERR_NO_SUCH_TABLE);
 
2314
                return(HA_ERR_NO_SUCH_TABLE);
2341
2315
        }
2342
2316
 
2343
2317
        if (ib_table->ibd_file_missing && !thd_tablespace_op(thd)) {
2354
2328
                my_errno = ENOENT;
2355
2329
 
2356
2330
                dict_table_decrement_handle_count(ib_table);
2357
 
                DBUG_RETURN(HA_ERR_NO_SUCH_TABLE);
 
2331
                return(HA_ERR_NO_SUCH_TABLE);
2358
2332
        }
2359
2333
 
2360
2334
        prebuilt = row_create_prebuilt(ib_table);
2429
2403
 
2430
2404
        info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
2431
2405
 
2432
 
        DBUG_RETURN(0);
 
2406
        return(0);
2433
2407
}
2434
2408
 
2435
2409
uint
2448
2422
{
2449
2423
        THD*    thd;
2450
2424
 
2451
 
        DBUG_ENTER("ha_innobase::close");
2452
 
 
2453
2425
        thd = current_thd;  // avoid calling current_thd twice, it may be slow
2454
2426
        if (thd != NULL) {
2455
2427
                innobase_release_temporary_latches(ht, thd);
2465
2437
 
2466
2438
        srv_active_wake_master_thread();
2467
2439
 
2468
 
        DBUG_RETURN(0);
 
2440
        return(0);
2469
2441
}
2470
2442
 
2471
2443
/* The following accessor functions should really be inside MySQL code! */
2557
2529
        enum_field_types        mysql_tp;
2558
2530
        int                     ret;
2559
2531
 
2560
 
        DBUG_ASSERT(a_length != UNIV_SQL_NULL);
2561
 
        DBUG_ASSERT(b_length != UNIV_SQL_NULL);
 
2532
        assert(a_length != UNIV_SQL_NULL);
 
2533
        assert(b_length != UNIV_SQL_NULL);
2562
2534
 
2563
2535
        mysql_tp = (enum_field_types) mysql_type;
2564
2536
 
2630
2602
        8 bits: this is used in ibuf and also when DATA_NOT_NULL is ORed to
2631
2603
        the type */
2632
2604
 
2633
 
        DBUG_ASSERT((ulint)MYSQL_TYPE_STRING < 256);
2634
 
        DBUG_ASSERT((ulint)MYSQL_TYPE_VAR_STRING < 256);
2635
 
        DBUG_ASSERT((ulint)MYSQL_TYPE_DOUBLE < 256);
 
2605
        assert((ulint)MYSQL_TYPE_STRING < 256);
 
2606
        assert((ulint)MYSQL_TYPE_VAR_STRING < 256);
 
2607
        assert((ulint)MYSQL_TYPE_DOUBLE < 256);
2636
2608
 
2637
2609
        if (field->flags & UNSIGNED_FLAG) {
2638
2610
 
2752
2724
        Field*          field;
2753
2725
        ibool           is_null;
2754
2726
 
2755
 
        DBUG_ENTER("store_key_val_for_row");
2756
 
 
2757
2727
        /* The format for storing a key field in MySQL is the following:
2758
2728
 
2759
2729
        1. If the column can be NULL, then in the first byte we put 1 if the
2999
2969
 
3000
2970
        ut_a(buff <= buff_start + buff_len);
3001
2971
 
3002
 
        DBUG_RETURN((uint)(buff - buff_start));
 
2972
        return((uint)(buff - buff_start));
3003
2973
}
3004
2974
 
3005
2975
/******************************************************************
3380
3350
        ulint           sql_command;
3381
3351
        trx_t*          trx = thd_to_trx(user_thd);
3382
3352
 
3383
 
        DBUG_ENTER("ha_innobase::write_row");
3384
 
 
3385
3353
        if (prebuilt->trx != trx) {
3386
3354
          sql_print_error("The transaction object for the table handle is at "
3387
3355
                          "%p, but for the current thread it is at %p",
3572
3540
func_exit:
3573
3541
        innobase_active_small();
3574
3542
 
3575
 
        DBUG_RETURN(error);
 
3543
        return(error);
3576
3544
}
3577
3545
 
3578
3546
/**************************************************************************
3744
3712
        int             error = 0;
3745
3713
        trx_t*          trx = thd_to_trx(user_thd);
3746
3714
 
3747
 
        DBUG_ENTER("ha_innobase::update_row");
3748
 
 
3749
3715
        ut_a(prebuilt->trx == trx);
3750
3716
 
3751
3717
        if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
3808
3774
 
3809
3775
        innobase_active_small();
3810
3776
 
3811
 
        DBUG_RETURN(error);
 
3777
        return(error);
3812
3778
}
3813
3779
 
3814
3780
/**************************************************************************
3823
3789
        int             error = 0;
3824
3790
        trx_t*          trx = thd_to_trx(user_thd);
3825
3791
 
3826
 
        DBUG_ENTER("ha_innobase::delete_row");
3827
 
 
3828
3792
        ut_a(prebuilt->trx == trx);
3829
3793
 
3830
3794
        /* Only if the table has an AUTOINC column */
3873
3837
 
3874
3838
        innobase_active_small();
3875
3839
 
3876
 
        DBUG_RETURN(error);
 
3840
        return(error);
3877
3841
}
3878
3842
 
3879
3843
/**************************************************************************
3885
3849
ha_innobase::unlock_row(void)
3886
3850
/*=========================*/
3887
3851
{
3888
 
        DBUG_ENTER("ha_innobase::unlock_row");
3889
 
 
3890
3852
        /* Consistent read does not take any locks, thus there is
3891
3853
        nothing to unlock. */
3892
3854
 
3893
3855
        if (prebuilt->select_lock_type == LOCK_NONE) {
3894
 
                DBUG_VOID_RETURN;
 
3856
                return;
3895
3857
        }
3896
3858
 
3897
3859
        switch (prebuilt->row_read_type) {
3909
3871
                break;
3910
3872
        }
3911
3873
 
3912
 
        DBUG_VOID_RETURN;
 
3874
        return;
3913
3875
}
3914
3876
 
3915
3877
/* See handler.h and row0mysql.h for docs on this function. */
3952
3914
        bool sorted __attribute__((__unused__)))        /* in: 1 if result MUST be sorted according to index */
3953
3915
{
3954
3916
        int     error   = 0;
3955
 
        DBUG_ENTER("index_init");
3956
3917
 
3957
3918
        error = change_active_index(keynr);
3958
3919
 
3959
 
        DBUG_RETURN(error);
 
3920
        return(error);
3960
3921
}
3961
3922
 
3962
3923
/**********************************************************************
3967
3928
/*========================*/
3968
3929
{
3969
3930
        int     error   = 0;
3970
 
        DBUG_ENTER("index_end");
3971
3931
        active_index=MAX_KEY;
3972
3932
        in_range_check_pushed_down= FALSE;
3973
3933
        ds_mrr.dsmrr_close();
3974
 
        DBUG_RETURN(error);
 
3934
        return(error);
3975
3935
}
3976
3936
 
3977
3937
/*************************************************************************
4109
4069
        int             error;
4110
4070
        ulint           ret;
4111
4071
 
4112
 
        DBUG_ENTER("index_read");
4113
 
 
4114
4072
        ut_a(prebuilt->trx == thd_to_trx(user_thd));
4115
4073
 
4116
4074
        ha_statistic_increment(&SSV::ha_read_key_count);
4185
4143
                table->status = STATUS_NOT_FOUND;
4186
4144
        }
4187
4145
 
4188
 
        DBUG_RETURN(error);
 
4146
        return(error);
4189
4147
}
4190
4148
 
4191
4149
/***********************************************************************
4220
4178
        KEY*            key = 0;
4221
4179
        dict_index_t*   index = 0;
4222
4180
 
4223
 
        DBUG_ENTER("innobase_get_index");
4224
4181
        ha_statistic_increment(&SSV::ha_read_key_count);
4225
4182
 
4226
4183
        ut_ad(user_thd == ha_thd());
4243
4200
                        prebuilt->table->name);
4244
4201
        }
4245
4202
 
4246
 
        DBUG_RETURN(index);
 
4203
        return(index);
4247
4204
}
4248
4205
 
4249
4206
/************************************************************************
4257
4214
                        index, even if it was internally generated by
4258
4215
                        InnoDB */
4259
4216
{
4260
 
        DBUG_ENTER("change_active_index");
4261
 
 
4262
4217
        ut_ad(user_thd == ha_thd());
4263
4218
        ut_a(prebuilt->trx == thd_to_trx(user_thd));
4264
4219
 
4267
4222
        prebuilt->index = innobase_get_index(keynr);
4268
4223
 
4269
4224
        if (!prebuilt->index) {
4270
 
                DBUG_RETURN(1);
 
4225
                return(1);
4271
4226
        }
4272
4227
 
4273
4228
        assert(prebuilt->search_tuple != 0);
4285
4240
 
4286
4241
        build_template(prebuilt, user_thd, table, this, ROW_MYSQL_REC_FIELDS);
4287
4242
 
4288
 
        DBUG_RETURN(0);
 
4243
        return(0);
4289
4244
}
4290
4245
 
4291
4246
/**************************************************************************
4332
4287
        ulint           ret;
4333
4288
        int             error   = 0;
4334
4289
 
4335
 
        DBUG_ENTER("general_fetch");
4336
 
 
4337
4290
        ut_a(prebuilt->trx == thd_to_trx(user_thd));
4338
4291
 
4339
4292
        innodb_srv_conc_enter_innodb(prebuilt->trx);
4358
4311
                table->status = STATUS_NOT_FOUND;
4359
4312
        }
4360
4313
 
4361
 
        DBUG_RETURN(error);
 
4314
        return(error);
4362
4315
}
4363
4316
 
4364
4317
/***************************************************************************
4422
4375
{
4423
4376
        int     error;
4424
4377
 
4425
 
        DBUG_ENTER("index_first");
4426
4378
        ha_statistic_increment(&SSV::ha_read_first_count);
4427
4379
 
4428
4380
        error = index_read(buf, NULL, 0, HA_READ_AFTER_KEY);
4433
4385
                error = HA_ERR_END_OF_FILE;
4434
4386
        }
4435
4387
 
4436
 
        DBUG_RETURN(error);
 
4388
        return(error);
4437
4389
}
4438
4390
 
4439
4391
/************************************************************************
4448
4400
{
4449
4401
        int     error;
4450
4402
 
4451
 
        DBUG_ENTER("index_last");
4452
4403
        ha_statistic_increment(&SSV::ha_read_last_count);
4453
4404
 
4454
4405
        error = index_read(buf, NULL, 0, HA_READ_BEFORE_KEY);
4459
4410
                error = HA_ERR_END_OF_FILE;
4460
4411
        }
4461
4412
 
4462
 
        DBUG_RETURN(error);
 
4413
        return(error);
4463
4414
}
4464
4415
 
4465
4416
/********************************************************************
4518
4469
{
4519
4470
        int     error;
4520
4471
 
4521
 
        DBUG_ENTER("rnd_next");
4522
4472
        ha_statistic_increment(&SSV::ha_read_rnd_next_count);
4523
4473
 
4524
4474
        if (start_of_scan) {
4531
4481
                error = general_fetch(buf, ROW_SEL_NEXT, 0);
4532
4482
        }
4533
4483
 
4534
 
        DBUG_RETURN(error);
 
4484
        return(error);
4535
4485
}
4536
4486
 
4537
4487
/**************************************************************************
4548
4498
                        length of data in pos has to be ref_length */
4549
4499
{
4550
4500
        int             error;
4551
 
        DBUG_ENTER("rnd_pos");
4552
 
        DBUG_DUMP("key", pos, ref_length);
4553
4501
 
4554
4502
        ha_statistic_increment(&SSV::ha_read_rnd_count);
4555
4503
 
4560
4508
 
4561
4509
        error = index_read(buf, pos, ref_length, HA_READ_KEY_EXACT);
4562
4510
 
4563
 
        if (error) {
4564
 
                DBUG_PRINT("error", ("Got error: %d", error));
4565
 
        }
4566
 
 
4567
 
        DBUG_RETURN(error);
 
4511
        return(error);
4568
4512
}
4569
4513
 
4570
4514
/*************************************************************************
4663
4607
        ulint           charset_no;
4664
4608
        ulint           i;
4665
4609
 
4666
 
        DBUG_ENTER("create_table_def");
4667
 
        DBUG_PRINT("enter", ("table_name: %s", table_name));
4668
 
 
4669
4610
        n_cols = form->s->fields;
4670
4611
 
4671
4612
        /* We pass 0 as the space id, and determine at a lower level the space
4742
4683
 
4743
4684
        error = convert_error_code_to_mysql(error, NULL);
4744
4685
 
4745
 
        DBUG_RETURN(error);
 
4686
        return(error);
4746
4687
}
4747
4688
 
4748
4689
/*********************************************************************
4771
4712
        ulint           j;
4772
4713
        ulint*          field_lengths;
4773
4714
 
4774
 
        DBUG_ENTER("create_index");
4775
 
 
4776
4715
        key = form->key_info + key_num;
4777
4716
 
4778
4717
        n_fields = key->key_parts;
4869
4808
 
4870
4809
        my_free(field_lengths, MYF(0));
4871
4810
 
4872
 
        DBUG_RETURN(error);
 
4811
        return(error);
4873
4812
}
4874
4813
 
4875
4814
/*********************************************************************
4941
4880
        ib_longlong     auto_inc_value;
4942
4881
        ulint           flags;
4943
4882
 
4944
 
        DBUG_ENTER("ha_innobase::create");
4945
 
 
4946
 
        DBUG_ASSERT(thd != NULL);
 
4883
        assert(thd != NULL);
4947
4884
 
4948
4885
        if (form->s->fields > 1000) {
4949
4886
                /* The limit probably should be REC_MAX_N_FIELDS - 3 = 1020,
4950
4887
                but we play safe here */
4951
4888
 
4952
 
                DBUG_RETURN(HA_ERR_TO_BIG_ROW);
 
4889
                return(HA_ERR_TO_BIG_ROW);
4953
4890
        }
4954
4891
 
4955
4892
        /* Get the transaction associated with the current thd, or create one
5016
4953
        /* Our function row_get_mysql_key_number_for_index assumes
5017
4954
        the primary key is always number 0, if it exists */
5018
4955
 
5019
 
        DBUG_ASSERT(primary_key_no == -1 || primary_key_no == 0);
 
4956
        assert(primary_key_no == -1 || primary_key_no == 0);
5020
4957
 
5021
4958
        /* Create the keys */
5022
4959
 
5076
5013
 
5077
5014
        innobase_table = dict_table_get(norm_name, FALSE);
5078
5015
 
5079
 
        DBUG_ASSERT(innobase_table != 0);
 
5016
        assert(innobase_table != 0);
5080
5017
 
5081
5018
        if ((create_info->used_fields & HA_CREATE_USED_AUTO) &&
5082
5019
           (create_info->auto_increment_value != 0)) {
5102
5039
 
5103
5040
        trx_free_for_mysql(trx);
5104
5041
 
5105
 
        DBUG_RETURN(0);
 
5042
        return(0);
5106
5043
 
5107
5044
cleanup:
5108
5045
        innobase_commit_low(trx);
5111
5048
 
5112
5049
        trx_free_for_mysql(trx);
5113
5050
 
5114
 
        DBUG_RETURN(error);
 
5051
        return(error);
5115
5052
}
5116
5053
 
5117
5054
/*********************************************************************
5127
5064
        trx_t*          trx;
5128
5065
        int             err;
5129
5066
 
5130
 
        DBUG_ENTER("ha_innobase::discard_or_import_tablespace");
5131
 
 
5132
5067
        ut_a(prebuilt->trx);
5133
5068
        ut_a(prebuilt->trx->magic_n == TRX_MAGIC_N);
5134
5069
        ut_a(prebuilt->trx == thd_to_trx(ha_thd()));
5144
5079
 
5145
5080
        err = convert_error_code_to_mysql(err, NULL);
5146
5081
 
5147
 
        DBUG_RETURN(err);
 
5082
        return(err);
5148
5083
}
5149
5084
 
5150
5085
/*********************************************************************
5157
5092
{
5158
5093
        int             error;
5159
5094
 
5160
 
        DBUG_ENTER("ha_innobase::delete_all_rows");
5161
 
 
5162
5095
        /* Get the transaction associated with the current thd, or create one
5163
5096
        if not yet created, and update prebuilt->trx */
5164
5097
 
5168
5101
        fallback:
5169
5102
                /* We only handle TRUNCATE TABLE t as a special case.
5170
5103
                DELETE FROM t will have to use ha_innobase::delete_row(). */
5171
 
                DBUG_RETURN(my_errno=HA_ERR_WRONG_COMMAND);
 
5104
                return(my_errno=HA_ERR_WRONG_COMMAND);
5172
5105
        }
5173
5106
 
5174
5107
        /* Truncate the table in InnoDB */
5181
5114
 
5182
5115
        error = convert_error_code_to_mysql(error, NULL);
5183
5116
 
5184
 
        DBUG_RETURN(error);
 
5117
        return(error);
5185
5118
}
5186
5119
 
5187
5120
/*********************************************************************
5204
5137
        THD     *thd = ha_thd();
5205
5138
        char    norm_name[1000];
5206
5139
 
5207
 
        DBUG_ENTER("ha_innobase::delete_table");
5208
 
 
5209
5140
        /* Get the transaction associated with the current thd, or create one
5210
5141
        if not yet created */
5211
5142
 
5267
5198
 
5268
5199
        error = convert_error_code_to_mysql(error, NULL);
5269
5200
 
5270
 
        DBUG_RETURN(error);
 
5201
        return(error);
5271
5202
}
5272
5203
 
5273
5204
/*********************************************************************
5369
5300
        char    norm_to[1000];
5370
5301
        THD*    thd             = ha_thd();
5371
5302
 
5372
 
        DBUG_ENTER("ha_innobase::rename_table");
5373
 
 
5374
5303
        /* Get the transaction associated with the current thd, or create one
5375
5304
        if not yet created */
5376
5305
 
5424
5353
 
5425
5354
        error = convert_error_code_to_mysql(error, NULL);
5426
5355
 
5427
 
        DBUG_RETURN(error);
 
5356
        return(error);
5428
5357
}
5429
5358
 
5430
5359
/*************************************************************************
5457
5386
        void*           heap1;
5458
5387
        void*           heap2;
5459
5388
 
5460
 
        DBUG_ENTER("records_in_range");
5461
 
 
5462
5389
        ut_a(prebuilt->trx == thd_to_trx(ha_thd()));
5463
5390
 
5464
5391
        prebuilt->trx->op_info = (char*)"estimating records in index range";
5529
5456
                n_rows = 1;
5530
5457
        }
5531
5458
 
5532
 
        DBUG_RETURN((ha_rows) n_rows);
 
5459
        return((ha_rows) n_rows);
5533
5460
}
5534
5461
 
5535
5462
/*************************************************************************
5545
5472
        uint64_t        estimate;
5546
5473
        uint64_t        local_data_file_length;
5547
5474
 
5548
 
        DBUG_ENTER("estimate_rows_upper_bound");
5549
 
 
5550
5475
        /* We do not know if MySQL can call this function before calling
5551
5476
        external_lock(). To be safe, update the thd of the current table
5552
5477
        handle. */
5576
5501
 
5577
5502
        prebuilt->trx->op_info = (char*)"";
5578
5503
 
5579
 
        DBUG_RETURN((ha_rows) estimate);
 
5504
        return((ha_rows) estimate);
5580
5505
}
5581
5506
 
5582
5507
/*************************************************************************
5653
5578
        char            path[FN_REFLEN];
5654
5579
        os_file_stat_t  stat_info;
5655
5580
 
5656
 
        DBUG_ENTER("info");
5657
 
 
5658
5581
        /* If we are forcing recovery at a high level, we will suppress
5659
5582
        statistics calculation on tables, because that may crash the
5660
5583
        server if an index is badly corrupted. */
5666
5589
                stop, like it would do if it received the error code
5667
5590
                HA_ERR_CRASHED. */
5668
5591
 
5669
 
                DBUG_RETURN(0);
 
5592
                return(0);
5670
5593
        }
5671
5594
 
5672
5595
        /* We do not know if MySQL can call this function before calling
5851
5774
 
5852
5775
        prebuilt->trx->op_info = (char*)"";
5853
5776
 
5854
 
        DBUG_RETURN(0);
 
5777
        return(0);
5855
5778
}
5856
5779
 
5857
5780
/**************************************************************************
5900
5823
{
5901
5824
        ulint           ret;
5902
5825
 
5903
 
        DBUG_ASSERT(thd == ha_thd());
 
5826
        assert(thd == ha_thd());
5904
5827
        ut_a(prebuilt->trx);
5905
5828
        ut_a(prebuilt->trx->magic_n == TRX_MAGIC_N);
5906
5829
        ut_a(prebuilt->trx == thd_to_trx(thd));
6063
5986
{
6064
5987
  dict_foreign_t* foreign;
6065
5988
 
6066
 
  DBUG_ENTER("get_foreign_key_list");
6067
5989
  ut_a(prebuilt != NULL);
6068
5990
  update_thd(ha_thd());
6069
5991
  prebuilt->trx->op_info = (char*)"getting list of foreign keys";
6186
6108
  mutex_exit_noninline(&(dict_sys->mutex));
6187
6109
  prebuilt->trx->op_info = (char*)"";
6188
6110
 
6189
 
  DBUG_RETURN(0);
 
6111
  return(0);
6190
6112
}
6191
6113
 
6192
6114
/*********************************************************************
6200
6122
{
6201
6123
        bool    can_switch;
6202
6124
 
6203
 
        DBUG_ENTER("ha_innobase::can_switch_engines");
6204
 
 
6205
6125
        ut_a(prebuilt->trx == thd_to_trx(ha_thd()));
6206
6126
 
6207
6127
        prebuilt->trx->op_info =
6214
6134
        row_mysql_unlock_data_dictionary(prebuilt->trx);
6215
6135
        prebuilt->trx->op_info = "";
6216
6136
 
6217
 
        DBUG_RETURN(can_switch);
 
6137
        return(can_switch);
6218
6138
}
6219
6139
 
6220
6140
/***********************************************************************
6451
6371
{
6452
6372
        trx_t*          trx;
6453
6373
 
6454
 
        DBUG_ENTER("ha_innobase::external_lock");
6455
 
        DBUG_PRINT("enter",("lock_type: %d", lock_type));
6456
 
 
6457
6374
        update_thd(thd);
6458
6375
 
6459
6376
        /* Statement based binlogging does not work in isolation level
6474
6391
                                 tx_isolation_names[tx_isolation],
6475
6392
                                 binlog_format_names[binlog_format]);
6476
6393
                        my_error(ER_BINLOG_LOGGING_IMPOSSIBLE, MYF(0), buf);
6477
 
                        DBUG_RETURN(HA_ERR_LOGGING_IMPOSSIBLE);
 
6394
                        return(HA_ERR_LOGGING_IMPOSSIBLE);
6478
6395
                }
6479
6396
        }
6480
6397
 
6550
6467
                                if (error != DB_SUCCESS) {
6551
6468
                                        error = convert_error_code_to_mysql(
6552
6469
                                                (int) error, thd);
6553
 
                                        DBUG_RETURN((int) error);
 
6470
                                        return((int) error);
6554
6471
                                }
6555
6472
                        }
6556
6473
 
6560
6477
                trx->n_mysql_tables_in_use++;
6561
6478
                prebuilt->mysql_has_locked = TRUE;
6562
6479
 
6563
 
                DBUG_RETURN(0);
 
6480
                return(0);
6564
6481
        }
6565
6482
 
6566
6483
        /* MySQL is releasing a table lock */
6598
6515
                }
6599
6516
        }
6600
6517
 
6601
 
        DBUG_RETURN(0);
 
6518
        return(0);
6602
6519
}
6603
6520
 
6604
6521
/**********************************************************************
6614
6531
{
6615
6532
        trx_t*          trx;
6616
6533
 
6617
 
        DBUG_ENTER("ha_innobase::transactional_table_lock");
6618
 
        DBUG_PRINT("enter",("lock_type: %d", lock_type));
6619
 
 
6620
6534
        /* We do not know if MySQL can call this function before calling
6621
6535
        external_lock(). To be safe, update the thd of the current table
6622
6536
        handle. */
6636
6550
                        " http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n"
6637
6551
                        "InnoDB: how you can resolve the problem.\n",
6638
6552
                        prebuilt->table->name);
6639
 
                DBUG_RETURN(HA_ERR_CRASHED);
 
6553
                return(HA_ERR_CRASHED);
6640
6554
        }
6641
6555
 
6642
6556
        trx = prebuilt->trx;
6658
6572
"MySQL is trying to set transactional table lock with corrupted lock type\n"
6659
6573
"to table %s, lock type %d does not exist.\n",
6660
6574
                                prebuilt->table->name, lock_type);
6661
 
                DBUG_RETURN(HA_ERR_CRASHED);
 
6575
                return(HA_ERR_CRASHED);
6662
6576
        }
6663
6577
 
6664
6578
        /* MySQL is setting a new transactional table lock */
6677
6591
 
6678
6592
                if (error != DB_SUCCESS) {
6679
6593
                        error = convert_error_code_to_mysql((int) error, thd);
6680
 
                        DBUG_RETURN((int) error);
 
6594
                        return((int) error);
6681
6595
                }
6682
6596
 
6683
6597
                if (thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
6690
6604
                }
6691
6605
        }
6692
6606
 
6693
 
        DBUG_RETURN(0);
 
6607
        return(0);
6694
6608
}
6695
6609
 
6696
6610
/****************************************************************************
6726
6640
        ulint                   trx_list_start = ULINT_UNDEFINED;
6727
6641
        ulint                   trx_list_end = ULINT_UNDEFINED;
6728
6642
 
6729
 
        DBUG_ENTER("innodb_show_status");
6730
 
 
6731
6643
        trx = check_trx_exists(thd);
6732
6644
 
6733
6645
        innobase_release_stat_resources(trx);
6760
6672
 
6761
6673
        if (!(str = (char*) my_malloc(usable_len + 1, MYF(0)))) {
6762
6674
          mutex_exit_noninline(&srv_monitor_file_mutex);
6763
 
          DBUG_RETURN(TRUE);
 
6675
          return(TRUE);
6764
6676
        }
6765
6677
 
6766
6678
        rewind(srv_monitor_file);
6794
6706
        }
6795
6707
        my_free(str, MYF(0));
6796
6708
 
6797
 
        DBUG_RETURN(FALSE);
 
6709
        return(FALSE);
6798
6710
}
6799
6711
 
6800
6712
/****************************************************************************
6819
6731
        uint64_t rw_lock_wait_time= 0;
6820
6732
#endif /* UNIV_DEBUG */
6821
6733
        uint      hton_name_len= strlen(innobase_hton_name), buf1len, buf2len;
6822
 
        DBUG_ENTER("innodb_mutex_show_status");
6823
6734
 
6824
6735
        mutex_enter_noninline(&mutex_list_mutex);
6825
6736
 
6849
6760
                                                buf2, buf2len)) {
6850
6761
                                        mutex_exit_noninline(
6851
6762
                                                &mutex_list_mutex);
6852
 
                                        DBUG_RETURN(1);
 
6763
                                        return(1);
6853
6764
                                }
6854
6765
                        }
6855
6766
                }
6871
6782
                               hton_name_len, buf1, buf1len,
6872
6783
                               buf2, buf2len)) {
6873
6784
                        mutex_exit_noninline(&mutex_list_mutex);
6874
 
                        DBUG_RETURN(1);
 
6785
                        return(1);
6875
6786
                }
6876
6787
#endif /* UNIV_DEBUG */
6877
6788
 
6891
6802
 
6892
6803
        if (stat_print(thd, innobase_hton_name, hton_name_len,
6893
6804
                        STRING_WITH_LEN("rw_lock_mutexes"), buf2, buf2len)) {
6894
 
                DBUG_RETURN(1);
 
6805
                return(1);
6895
6806
        }
6896
6807
#endif /* UNIV_DEBUG */
6897
6808
 
6898
 
        DBUG_RETURN(FALSE);
 
6809
        return(FALSE);
6899
6810
}
6900
6811
 
6901
6812
static
7030
6941
                }
7031
6942
        }
7032
6943
 
7033
 
        DBUG_ASSERT(thd == current_thd);
 
6944
        assert(thd == current_thd);
7034
6945
        const bool in_lock_tables = thd_in_lock_tables(thd);
7035
6946
        const uint sql_command = thd_sql_command(thd);
7036
6947
 
7443
7354
/*==============================*/
7444
7355
        uint64_t        value)          /* in: new value for table autoinc */
7445
7356
{
7446
 
        DBUG_ENTER("ha_innobase::reset_auto_increment");
7447
 
 
7448
7357
        int     error;
7449
7358
 
7450
7359
        update_thd(ha_thd());
7454
7363
        if (error != DB_SUCCESS) {
7455
7364
                error = convert_error_code_to_mysql(error, user_thd);
7456
7365
 
7457
 
                DBUG_RETURN(error);
 
7366
                return(error);
7458
7367
        }
7459
7368
 
7460
7369
        innobase_reset_autoinc(value);
7461
7370
 
7462
 
        DBUG_RETURN(0);
 
7371
        return(0);
7463
7372
}
7464
7373
 
7465
7374
/* See comment in handler.cc */