~ubuntu-branches/ubuntu/trusty/mariadb-5.5/trusty-proposed

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): James Page, Otto Kekäläinen
  • Date: 2014-02-17 16:51:52 UTC
  • mfrom: (2.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20140217165152-k315d3175g865kkx
Tags: 5.5.35-1
[ Otto Kekäläinen ]
* New upstream release, fixing the following security issues:
  - Buffer overflow in client/mysql.cc (Closes: #737597).
    - CVE-2014-0001
  - http://www.oracle.com/technetwork/topics/security/cpujan2014-1972949.html
    - CVE-2013-5891
    - CVE-2013-5908
    - CVE-2014-0386
    - CVE-2014-0393
    - CVE-2014-0401
    - CVE-2014-0402
    - CVE-2014-0412
    - CVE-2014-0420
    - CVE-2014-0437
* Upstream https://mariadb.atlassian.net/browse/MDEV-4902
  fixes compatibility with Bison 3.0 (Closes: #733002)
* Updated Russian debconf translation (Closes: #734426)
* Updated Japanese debconf translation (Closes: #735284)
* Updated French debconf translation (Closes: #736480)
* Renamed SONAME properly (Closes: #732967)

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
#include <innodb_priv.h>
54
54
#include <mysql/psi/psi.h>
55
55
#include <my_sys.h>
 
56
#include <my_check_opt.h>
56
57
 
57
58
#ifdef _WIN32
58
59
#include <io.h>
90
91
#include "ha_prototypes.h"
91
92
#include "ut0mem.h"
92
93
#include "ibuf0ibuf.h"
 
94
 
 
95
enum_tx_isolation thd_get_trx_isolation(const THD* thd);
 
96
 
93
97
}
94
98
 
95
99
#include "ha_innodb.h"
103
107
static mysql_mutex_t innobase_share_mutex;
104
108
/** to force correct commit order in binlog */
105
109
static ulong commit_threads = 0;
106
 
static mysql_mutex_t commit_threads_m;
107
110
static mysql_cond_t commit_cond;
108
111
static mysql_mutex_t commit_cond_m;
109
112
static bool innodb_inited = 0;
221
224
/* Keys to register pthread mutexes/cond in the current file with
222
225
performance schema */
223
226
static mysql_pfs_key_t  innobase_share_mutex_key;
224
 
static mysql_pfs_key_t  commit_threads_m_key;
225
227
static mysql_pfs_key_t  commit_cond_mutex_key;
226
228
static mysql_pfs_key_t  commit_cond_key;
227
229
 
228
230
static PSI_mutex_info   all_pthread_mutexes[] = {
229
 
        {&commit_threads_m_key, "commit_threads_m", 0},
230
231
        {&commit_cond_mutex_key, "commit_cond_mutex", 0},
231
232
        {&innobase_share_mutex_key, "innobase_share_mutex", 0}
232
233
};
398
399
/*=======================*/
399
400
        uint    flags);
400
401
 
 
402
/******************************************************************//**
 
403
Maps a MySQL trx isolation level code to the InnoDB isolation level code
 
404
@return InnoDB isolation level */
 
405
static inline
 
406
ulint
 
407
innobase_map_isolation_level(
 
408
/*=========================*/
 
409
        enum_tx_isolation       iso);   /*!< in: MySQL isolation level code */
 
410
 
401
411
static const char innobase_hton_name[]= "InnoDB";
402
412
 
403
413
/*************************************************************//**
763
773
}
764
774
 
765
775
/******************************************************************//**
766
 
Releases possible search latch and InnoDB thread FIFO ticket. These should
767
 
be released at each SQL statement end, and also when mysqld passes the
768
 
control to the client. It does no harm to release these also in the middle
769
 
of an SQL statement. */
 
776
Force a thread to leave InnoDB even if it has spare tickets. */
770
777
static inline
771
778
void
772
 
innobase_release_stat_resources(
773
 
/*============================*/
774
 
        trx_t*  trx)    /*!< in: transaction object */
 
779
innodb_srv_conc_force_exit_innodb(
 
780
/*==============================*/
 
781
        trx_t*  trx)    /*!< in: transaction handle */
775
782
{
776
 
        if (trx->has_search_latch) {
777
 
                trx_search_latch_release_if_reserved(trx);
778
 
        }
 
783
#ifdef UNIV_SYNC_DEBUG
 
784
        ut_ad(!sync_thread_levels_nonempty_trx(trx->has_search_latch));
 
785
#endif /* UNIV_SYNC_DEBUG */
779
786
 
780
787
        if (trx->declared_to_be_inside_innodb) {
781
 
                /* Release our possible ticket in the FIFO */
782
788
 
783
789
                srv_conc_force_exit_innodb(trx);
784
790
        }
889
895
 
890
896
        trx = thd_to_trx(thd);
891
897
 
892
 
        if (trx) {
893
 
                innobase_release_stat_resources(trx);
 
898
        if (trx != NULL) {
 
899
                trx_search_latch_release_if_reserved(trx);
894
900
        }
 
901
 
895
902
        return(0);
896
903
}
897
904
 
1201
1208
        strconvert(cs, from, system_charset_info, to, (uint) len, &errors);
1202
1209
}
1203
1210
 
 
1211
/**********************************************************************
 
1212
Converts an identifier from my_charset_filename to UTF-8 charset.
 
1213
@return result string length, as returned by strconvert() */
 
1214
extern "C"
 
1215
uint
 
1216
innobase_convert_to_system_charset(
 
1217
/*===============================*/
 
1218
        char*           to,     /* out: converted identifier */
 
1219
        const char*     from,   /* in: identifier to convert */
 
1220
        ulint           len,    /* in: length of 'to', in bytes */
 
1221
        uint*           errors) /* out: error return */
 
1222
{
 
1223
        CHARSET_INFO*   cs1 = &my_charset_filename;
 
1224
        CHARSET_INFO*   cs2 = system_charset_info;
 
1225
 
 
1226
        return(strconvert(cs1, from, cs2, to, len, errors));
 
1227
}
 
1228
 
1204
1229
/******************************************************************//**
1205
1230
Compares NUL-terminated UTF-8 strings case insensitively.
1206
1231
@return 0 if a=b, <0 if a<b, >1 if a>b */
1844
1869
                mutex_exit(&kernel_mutex);
1845
1870
        }
1846
1871
 
1847
 
        innobase_release_stat_resources(trx);
 
1872
        trx_search_latch_release_if_reserved(trx);
 
1873
        innodb_srv_conc_force_exit_innodb(trx);
1848
1874
 
1849
1875
        if (!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
1850
1876
 
2157
2183
        /* Initialize the prebuilt struct much like it would be inited in
2158
2184
        external_lock */
2159
2185
 
2160
 
        innobase_release_stat_resources(prebuilt->trx);
 
2186
        trx_search_latch_release_if_reserved(prebuilt->trx);
 
2187
        innodb_srv_conc_force_exit_innodb(prebuilt->trx);
2161
2188
 
2162
2189
        /* If the transaction is not started yet, start it */
2163
2190
 
2234
2261
        innobase_hton->start_consistent_snapshot=innobase_start_trx_and_assign_read_view;
2235
2262
        innobase_hton->flush_logs=innobase_flush_logs;
2236
2263
        innobase_hton->show_status=innobase_show_status;
2237
 
        innobase_hton->flags=HTON_NO_FLAGS;
 
2264
        innobase_hton->flags=HTON_EXTENDED_KEYS;
2238
2265
        innobase_hton->release_temporary_latches=innobase_release_temporary_latches;
2239
2266
        innobase_hton->alter_table_flags = innobase_alter_table_flags;
2240
2267
        innobase_hton->kill_query = innobase_kill_query;
2593
2620
        mysql_mutex_init(innobase_share_mutex_key,
2594
2621
                         &innobase_share_mutex,
2595
2622
                         MY_MUTEX_INIT_FAST);
2596
 
        mysql_mutex_init(commit_threads_m_key,
2597
 
                         &commit_threads_m, MY_MUTEX_INIT_FAST);
2598
2623
        mysql_mutex_init(commit_cond_mutex_key,
2599
2624
                         &commit_cond_m, MY_MUTEX_INIT_FAST);
2600
2625
        mysql_cond_init(commit_cond_key, &commit_cond, NULL);
2642
2667
                srv_free_paths_and_sizes();
2643
2668
                my_free(internal_innobase_data_file_path);
2644
2669
                mysql_mutex_destroy(&innobase_share_mutex);
2645
 
                mysql_mutex_destroy(&commit_threads_m);
2646
2670
                mysql_mutex_destroy(&commit_cond_m);
2647
2671
                mysql_cond_destroy(&commit_cond);
2648
2672
        }
2728
2752
        search latch. Since we will reserve the kernel mutex, we have to
2729
2753
        release the search system latch first to obey the latching order. */
2730
2754
 
2731
 
        innobase_release_stat_resources(trx);
 
2755
        trx_search_latch_release_if_reserved(trx);
 
2756
        innodb_srv_conc_force_exit_innodb(trx);
2732
2757
 
2733
2758
        /* If the transaction is not started yet, start it */
2734
2759
 
2735
2760
        trx_start_if_not_started(trx);
2736
2761
 
2737
 
        /* Assign a read view if the transaction does not have it yet */
 
2762
        /* Assign a read view if the transaction does not have it yet.
 
2763
        Do this only if transaction is using REPEATABLE READ isolation
 
2764
        level. */
 
2765
        trx->isolation_level = innobase_map_isolation_level(
 
2766
                thd_get_trx_isolation(thd));
2738
2767
 
2739
 
        trx_assign_read_view(trx);
 
2768
        if (trx->isolation_level == TRX_ISO_REPEATABLE_READ) {
 
2769
                trx_assign_read_view(trx);
 
2770
        } else {
 
2771
                push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
 
2772
                                    HA_ERR_UNSUPPORTED,
 
2773
                                    "InnoDB: WITH CONSISTENT SNAPSHOT "
 
2774
                                    "was ignored because this phrase "
 
2775
                                    "can only be used with "
 
2776
                                    "REPEATABLE READ isolation level.");
 
2777
        }
2740
2778
 
2741
2779
        /* Set the MySQL flag to mark that there is an active transaction */
2742
2780
 
2961
2999
        reserve the kernel mutex, we have to release the search system latch
2962
3000
        first to obey the latching order. */
2963
3001
 
2964
 
        innobase_release_stat_resources(trx);
 
3002
        trx_search_latch_release_if_reserved(trx);
 
3003
        innodb_srv_conc_force_exit_innodb(trx);
2965
3004
 
2966
3005
        trx->n_autoinc_rows = 0; /* Reset the number AUTO-INC rows required */
2967
3006
 
3001
3040
        reserve the kernel mutex, we have to release the search system latch
3002
3041
        first to obey the latching order. */
3003
3042
 
3004
 
        innobase_release_stat_resources(trx);
 
3043
        trx_search_latch_release_if_reserved(trx);
 
3044
        innodb_srv_conc_force_exit_innodb(trx);
3005
3045
 
3006
3046
        /* If we had reserved the auto-inc lock for some table (if
3007
3047
        we come here to roll back the latest SQL statement) we
3041
3081
        reserve the kernel mutex, we have to release the search system latch
3042
3082
        first to obey the latching order. */
3043
3083
 
3044
 
        innobase_release_stat_resources(trx);
 
3084
        trx_search_latch_release_if_reserved(trx);
 
3085
        innodb_srv_conc_force_exit_innodb(trx);
3045
3086
 
3046
3087
        /* TODO: use provided savepoint data area to store savepoint data */
3047
3088
 
3116
3157
        reserve the kernel mutex, we have to release the search system latch
3117
3158
        first to obey the latching order. */
3118
3159
 
3119
 
        innobase_release_stat_resources(trx);
 
3160
        trx_search_latch_release_if_reserved(trx);
 
3161
        innodb_srv_conc_force_exit_innodb(trx);
3120
3162
 
3121
3163
        /* Cannot happen outside of transaction */
3122
3164
        DBUG_ASSERT(trx_is_registered_for_2pc(trx));
3903
3945
int
3904
3946
ha_innobase::open(
3905
3947
/*==============*/
3906
 
        const char*     name,           /*!< in: table name */
3907
 
        int             mode,           /*!< in: not used */
3908
 
        uint            test_if_locked) /*!< in: not used */
 
3948
        const char*             name,           /*!< in: table name */
 
3949
        int                     mode,           /*!< in: not used */
 
3950
        uint                    test_if_locked) /*!< in: not used */
3909
3951
{
3910
 
        dict_table_t*   ib_table;
3911
 
        char            norm_name[1000];
3912
 
        THD*            thd;
3913
 
        char*           is_part = NULL;
3914
 
        ibool           par_case_name_set = FALSE;
3915
 
        char            par_case_name[MAX_FULL_NAME_LEN + 1];
 
3952
        dict_table_t*           ib_table;
 
3953
        char                    norm_name[1000];
 
3954
        THD*                    thd;
 
3955
        char*                   is_part = NULL;
 
3956
        ibool                   par_case_name_set = FALSE;
 
3957
        char                    par_case_name[MAX_FULL_NAME_LEN + 1];
 
3958
        dict_err_ignore_t       ignore_err = DICT_ERR_IGNORE_NONE;
3916
3959
 
3917
3960
        DBUG_ENTER("ha_innobase::open");
3918
3961
 
3949
3992
        is_part = strstr(norm_name, "#P#");
3950
3993
#endif /* __WIN__ */
3951
3994
 
 
3995
        /* Check whether FOREIGN_KEY_CHECKS is set to 0. If so, the table
 
3996
        can be opened even if some FK indexes are missing. If not, the table
 
3997
        can't be opened in the same situation */
 
3998
        if (thd_test_options(thd, OPTION_NO_FOREIGN_KEY_CHECKS)) {
 
3999
                ignore_err = DICT_ERR_IGNORE_FK_NOKEY;
 
4000
        }
 
4001
 
3952
4002
        /* Get pointer to a table object in InnoDB dictionary cache */
3953
 
        ib_table = dict_table_get(norm_name, TRUE);
 
4003
        ib_table = dict_table_get(norm_name, TRUE, ignore_err);
3954
4004
 
3955
4005
        if (NULL == ib_table) {
3956
4006
                if (is_part) {
3994
4044
                                }
3995
4045
 
3996
4046
                                ib_table = dict_table_get(
3997
 
                                        par_case_name, FALSE);
 
4047
                                        par_case_name, FALSE, ignore_err);
3998
4048
                        }
3999
4049
                        if (ib_table) {
4000
4050
#ifndef __WIN__
7387
7437
 
7388
7438
        log_buffer_flush_to_disk();
7389
7439
 
7390
 
        innobase_table = dict_table_get(norm_name, FALSE);
 
7440
        innobase_table = dict_table_get(norm_name, FALSE,
 
7441
                                        DICT_ERR_IGNORE_NONE);
7391
7442
 
7392
7443
        DBUG_ASSERT(innobase_table != 0);
7393
7444
 
7834
7885
        /* There exists possibility of not being able to find requested
7835
7886
        index due to inconsistency between MySQL and InoDB dictionary info.
7836
7887
        Necessary message should have been printed in innobase_get_index() */
 
7888
        if (prebuilt->table->ibd_file_missing) {
 
7889
                n_rows = HA_POS_ERROR;
 
7890
                goto func_exit;
 
7891
        }
7837
7892
        if (UNIV_UNLIKELY(!index)) {
7838
7893
                n_rows = HA_POS_ERROR;
7839
7894
                goto func_exit;
8211
8266
 
8212
8267
                        prebuilt->trx->op_info = "updating table statistics";
8213
8268
 
 
8269
                        DEBUG_SYNC_C("info_before_stats_update");
 
8270
 
8214
8271
                        dict_update_statistics(
8215
8272
                                ib_table,
8216
8273
                                FALSE, /* update even if initialized */
8560
8617
ha_innobase::check(
8561
8618
/*===============*/
8562
8619
        THD*            thd,            /*!< in: user thread handle */
8563
 
        HA_CHECK_OPT*   check_opt)      /*!< in: check options, currently
8564
 
                                        ignored */
 
8620
        HA_CHECK_OPT*   check_opt)      /*!< in: check options */
8565
8621
{
8566
8622
        dict_index_t*   index;
8567
8623
        ulint           n_rows;
8618
8674
        do additional check */
8619
8675
        prebuilt->table->corrupted = FALSE;
8620
8676
 
8621
 
        /* Enlarge the fatal lock wait timeout during CHECK TABLE. */
8622
 
        mutex_enter(&kernel_mutex);
8623
 
        srv_fatal_semaphore_wait_threshold += SRV_SEMAPHORE_WAIT_EXTENSION;
8624
 
        mutex_exit(&kernel_mutex);
8625
 
 
8626
8677
        for (index = dict_table_get_first_index(prebuilt->table);
8627
8678
             index != NULL;
8628
8679
             index = dict_table_get_next_index(index)) {
8635
8686
 
8636
8687
                /* If this is an index being created, break */
8637
8688
                if (*index->name == TEMP_INDEX_PREFIX) {
8638
 
                        break;
8639
 
                }  else if (!btr_validate_index(index, prebuilt->trx)) {
8640
 
                        is_ok = FALSE;
8641
 
 
8642
 
                        innobase_format_name(
8643
 
                                index_name, sizeof index_name,
8644
 
                                prebuilt->index->name, TRUE);
8645
 
 
8646
 
                        push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
8647
 
                                            ER_NOT_KEYFILE,
8648
 
                                            "InnoDB: The B-tree of"
8649
 
                                            " index %s is corrupted.",
8650
 
                                            index_name);
8651
8689
                        continue;
8652
8690
                }
 
8691
                if (!(check_opt->flags & T_QUICK)) {
 
8692
                        /* Enlarge the fatal lock wait timeout during
 
8693
                        CHECK TABLE. */
 
8694
                        mutex_enter(&kernel_mutex);
 
8695
                        srv_fatal_semaphore_wait_threshold +=
 
8696
                                SRV_SEMAPHORE_WAIT_EXTENSION;
 
8697
                        mutex_exit(&kernel_mutex);
 
8698
 
 
8699
                        ibool   valid = TRUE;
 
8700
                        valid = btr_validate_index(index, prebuilt->trx);
 
8701
 
 
8702
                        /* Restore the fatal lock wait timeout after
 
8703
                        CHECK TABLE. */
 
8704
                        mutex_enter(&kernel_mutex);
 
8705
                        srv_fatal_semaphore_wait_threshold -=
 
8706
                                SRV_SEMAPHORE_WAIT_EXTENSION;
 
8707
                        mutex_exit(&kernel_mutex);
 
8708
 
 
8709
                        if (!valid) {
 
8710
                                is_ok = FALSE;
 
8711
 
 
8712
                                innobase_format_name(
 
8713
                                        index_name, sizeof index_name,
 
8714
                                        index->name, TRUE);
 
8715
                                push_warning_printf(thd,
 
8716
                                        MYSQL_ERROR::WARN_LEVEL_WARN,
 
8717
                                        ER_NOT_KEYFILE,
 
8718
                                        "InnoDB: The B-tree of"
 
8719
                                        " index %s is corrupted.",
 
8720
                                        index_name);
 
8721
 
 
8722
                                continue;
 
8723
                        }
 
8724
                }
8653
8725
 
8654
8726
                /* Instead of invoking change_active_index(), set up
8655
8727
                a dummy template for non-locking reads, disabling
8729
8801
                                            (ulong) n_rows,
8730
8802
                                            (ulong) n_rows_in_table);
8731
8803
                        is_ok = FALSE;
 
8804
                        row_mysql_lock_data_dictionary(prebuilt->trx);
 
8805
                        dict_set_corrupted(index);
 
8806
                        row_mysql_unlock_data_dictionary(prebuilt->trx);
8732
8807
                }
8733
8808
        }
8734
8809
 
8749
8824
        /* Restore the original isolation level */
8750
8825
        prebuilt->trx->isolation_level = old_isolation_level;
8751
8826
 
8752
 
        /* We validate also the whole adaptive hash index for all tables
8753
 
        at every CHECK TABLE */
 
8827
#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG
 
8828
        /* We validate the whole adaptive hash index for all tables
 
8829
        at every CHECK TABLE only when QUICK flag is not present. */
8754
8830
 
8755
 
        if (!btr_search_validate()) {
 
8831
        if (!(check_opt->flags & T_QUICK) && !btr_search_validate()) {
8756
8832
                push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
8757
8833
                             ER_NOT_KEYFILE,
8758
8834
                             "InnoDB: The adaptive hash index is corrupted.");
8759
8835
                is_ok = FALSE;
8760
8836
        }
8761
 
 
8762
 
        /* Restore the fatal lock wait timeout after CHECK TABLE. */
8763
 
        mutex_enter(&kernel_mutex);
8764
 
        srv_fatal_semaphore_wait_threshold -= SRV_SEMAPHORE_WAIT_EXTENSION;
8765
 
        mutex_exit(&kernel_mutex);
8766
 
 
 
8837
#endif /* defined UNIV_AHI_DEBUG || defined UNIV_DEBUG */
8767
8838
        prebuilt->trx->op_info = "";
8768
8839
        if (thd_kill_level(user_thd)) {
8769
8840
                my_error(ER_QUERY_INTERRUPTED, MYF(0));
9273
9344
        that may not be the case. We MUST release the search latch before an
9274
9345
        INSERT, for example. */
9275
9346
 
9276
 
        innobase_release_stat_resources(trx);
 
9347
        trx_search_latch_release_if_reserved(trx);
 
9348
        innodb_srv_conc_force_exit_innodb(trx);
9277
9349
 
9278
9350
        /* Reset the AUTOINC statement level counter for multi-row INSERTs. */
9279
9351
        trx->n_autoinc_rows = 0;
9468
9540
        may reserve the kernel mutex, we have to release the search
9469
9541
        system latch first to obey the latching order. */
9470
9542
 
9471
 
        innobase_release_stat_resources(trx);
 
9543
        trx_search_latch_release_if_reserved(trx);
 
9544
        innodb_srv_conc_force_exit_innodb(trx);
9472
9545
 
9473
9546
        /* If the MySQL lock count drops to zero we know that the current SQL
9474
9547
        statement has ended */
9615
9688
        const long              MAX_STATUS_SIZE = 1048576;
9616
9689
        ulint                   trx_list_start = ULINT_UNDEFINED;
9617
9690
        ulint                   trx_list_end = ULINT_UNDEFINED;
9618
 
        bool res;
 
9691
        bool                    ret_val;
9619
9692
 
9620
9693
        DBUG_ENTER("innodb_show_status");
9621
9694
        DBUG_ASSERT(hton == innodb_hton_ptr);
9622
9695
 
9623
9696
        trx = check_trx_exists(thd);
9624
9697
 
9625
 
        innobase_release_stat_resources(trx);
 
9698
        trx_search_latch_release_if_reserved(trx);
 
9699
        innodb_srv_conc_force_exit_innodb(trx);
9626
9700
 
9627
9701
        /* We let the InnoDB Monitor to output at most MAX_STATUS_SIZE
9628
9702
        bytes of text. */
9679
9753
 
9680
9754
        mutex_exit(&srv_monitor_file_mutex);
9681
9755
 
9682
 
        res= stat_print(thd, innobase_hton_name,
9683
 
                        (uint) strlen(innobase_hton_name),
9684
 
                        STRING_WITH_LEN(""), str, flen);
 
9756
        ret_val= stat_print(thd, innobase_hton_name,
 
9757
                                (uint) strlen(innobase_hton_name),
 
9758
                                STRING_WITH_LEN(""), str, flen);
9685
9759
 
9686
9760
        my_free(str);
9687
9761
 
9688
 
        DBUG_RETURN(res);
 
9762
        DBUG_RETURN(ret_val);
9689
9763
}
9690
9764
 
9691
9765
/************************************************************************//**
10623
10697
        reserve the kernel mutex, we have to release the search system latch
10624
10698
        first to obey the latching order. */
10625
10699
 
10626
 
        innobase_release_stat_resources(trx);
 
10700
        trx_search_latch_release_if_reserved(trx);
 
10701
        innodb_srv_conc_force_exit_innodb(trx);
10627
10702
 
10628
10703
        if (!trx_is_registered_for_2pc(trx) && trx_is_started(trx)) {
10629
10704
 
12106
12181
                }
12107
12182
        }
12108
12183
}
12109
 
 
12110
12184
#endif /* UNIV_COMPILE_TEST_FUNCS */
12111
12185
 
12112
12186
/**********************************************************************
12113
 
Converts an identifier from my_charset_filename to UTF-8 charset. */
 
12187
Converts an identifier from my_charset_filename to UTF-8 charset.
 
12188
@return result string length, as returned by strconvert() */
12114
12189
extern "C"
12115
12190
uint
12116
12191
innobase_convert_to_filename_charset(
12120
12195
        ulint           len)    /* in: length of 'to', in bytes */
12121
12196
{
12122
12197
        uint            errors;
12123
 
        uint            rlen;
12124
12198
        CHARSET_INFO*   cs_to = &my_charset_filename;
12125
12199
        CHARSET_INFO*   cs_from = system_charset_info;
12126
12200
 
12127
 
        rlen = strconvert(cs_from, from, cs_to, to, len, &errors);
12128
 
 
12129
 
        if (errors) {
12130
 
                fprintf(stderr, "InnoDB: There was a problem in converting"
12131
 
                        "'%s' in charset %s to charset %s", from, cs_from->name,
12132
 
                        cs_to->name);
12133
 
        }
12134
 
 
12135
 
        return(rlen);
12136
 
}
12137
 
 
12138
 
/**********************************************************************
12139
 
Converts an identifier from my_charset_filename to UTF-8 charset. */
12140
 
extern "C"
12141
 
uint
12142
 
innobase_convert_to_system_charset(
12143
 
/*===============================*/
12144
 
        char*           to,     /* out: converted identifier */
12145
 
        const char*     from,   /* in: identifier to convert */
12146
 
        ulint           len,    /* in: length of 'to', in bytes */
12147
 
        uint*           errors) /* out: error return */
12148
 
{
12149
 
        uint            rlen;
12150
 
        CHARSET_INFO*   cs1 = &my_charset_filename;
12151
 
        CHARSET_INFO*   cs2 = system_charset_info;
12152
 
 
12153
 
        rlen = strconvert(cs1, from, cs2, to, len, errors);
12154
 
 
12155
 
        if (*errors) {
12156
 
                fprintf(stderr, "InnoDB: There was a problem in converting"
12157
 
                        "'%s' in charset %s to charset %s", from, cs1->name,
12158
 
                        cs2->name);
12159
 
        }
12160
 
 
12161
 
        return(rlen);
 
12201
        return(strconvert(cs_from, from, cs_to, to, len, &errors));
12162
12202
}