~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to storage/innodb_plugin/dict/dict0dict.c

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-06-21 15:31:05 UTC
  • mfrom: (1.1.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20100621153105-pbbz3t6nyrf9t2zq
Tags: upstream-5.1.48
ImportĀ upstreamĀ versionĀ 5.1.48

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
 
83
83
/** array of mutexes protecting dict_index_t::stat_n_diff_key_vals[] */
84
84
#define DICT_INDEX_STAT_MUTEX_SIZE      32
85
 
mutex_t dict_index_stat_mutex[DICT_INDEX_STAT_MUTEX_SIZE];
 
85
static mutex_t  dict_index_stat_mutex[DICT_INDEX_STAT_MUTEX_SIZE];
86
86
 
87
87
/*******************************************************************//**
88
88
Tries to find column names for the index and sets the col field of the
3008
3008
char*
3009
3009
dict_strip_comments(
3010
3010
/*================*/
3011
 
        const char*     sql_string)     /*!< in: SQL string */
 
3011
        const char*     sql_string,     /*!< in: SQL string */
 
3012
        size_t          sql_length)     /*!< in: length of sql_string */
3012
3013
{
3013
3014
        char*           str;
3014
3015
        const char*     sptr;
 
3016
        const char*     eptr    = sql_string + sql_length;
3015
3017
        char*           ptr;
3016
3018
        /* unclosed quote character (0 if none) */
3017
3019
        char            quote   = 0;
3018
3020
 
3019
 
        str = mem_alloc(strlen(sql_string) + 1);
 
3021
        str = mem_alloc(sql_length + 1);
3020
3022
 
3021
3023
        sptr = sql_string;
3022
3024
        ptr = str;
3023
3025
 
3024
3026
        for (;;) {
3025
3027
scan_more:
3026
 
                if (*sptr == '\0') {
 
3028
                if (sptr >= eptr || *sptr == '\0') {
 
3029
end_of_string:
3027
3030
                        *ptr = '\0';
3028
3031
 
3029
 
                        ut_a(ptr <= str + strlen(sql_string));
 
3032
                        ut_a(ptr <= str + sql_length);
3030
3033
 
3031
3034
                        return(str);
3032
3035
                }
3045
3048
                           || (sptr[0] == '-' && sptr[1] == '-'
3046
3049
                               && sptr[2] == ' ')) {
3047
3050
                        for (;;) {
 
3051
                                if (++sptr >= eptr) {
 
3052
                                        goto end_of_string;
 
3053
                                }
 
3054
 
3048
3055
                                /* In Unix a newline is 0x0A while in Windows
3049
3056
                                it is 0x0D followed by 0x0A */
3050
3057
 
3051
 
                                if (*sptr == (char)0x0A
3052
 
                                    || *sptr == (char)0x0D
3053
 
                                    || *sptr == '\0') {
3054
 
 
 
3058
                                switch (*sptr) {
 
3059
                                case (char) 0X0A:
 
3060
                                case (char) 0x0D:
 
3061
                                case '\0':
3055
3062
                                        goto scan_more;
3056
3063
                                }
3057
 
 
3058
 
                                sptr++;
3059
3064
                        }
3060
3065
                } else if (!quote && *sptr == '/' && *(sptr + 1) == '*') {
 
3066
                        sptr += 2;
3061
3067
                        for (;;) {
3062
 
                                if (*sptr == '*' && *(sptr + 1) == '/') {
3063
 
 
3064
 
                                        sptr += 2;
3065
 
 
3066
 
                                        goto scan_more;
 
3068
                                if (sptr >= eptr) {
 
3069
                                        goto end_of_string;
3067
3070
                                }
3068
3071
 
3069
 
                                if (*sptr == '\0') {
3070
 
 
 
3072
                                switch (*sptr) {
 
3073
                                case '\0':
3071
3074
                                        goto scan_more;
 
3075
                                case '*':
 
3076
                                        if (sptr[1] == '/') {
 
3077
                                                sptr += 2;
 
3078
                                                goto scan_more;
 
3079
                                        }
3072
3080
                                }
3073
3081
 
3074
3082
                                sptr++;
3749
3757
                                        name before it: test.table2; the
3750
3758
                                        default database id the database of
3751
3759
                                        parameter name */
 
3760
        size_t          sql_length,     /*!< in: length of sql_string */
3752
3761
        const char*     name,           /*!< in: table full name in the
3753
3762
                                        normalized form
3754
3763
                                        database_name/table_name */
3763
3772
        ut_a(trx);
3764
3773
        ut_a(trx->mysql_thd);
3765
3774
 
3766
 
        str = dict_strip_comments(sql_string);
 
3775
        str = dict_strip_comments(sql_string, sql_length);
3767
3776
        heap = mem_heap_create(10000);
3768
3777
 
3769
3778
        err = dict_create_foreign_constraints_low(
3796
3805
        dict_foreign_t*         foreign;
3797
3806
        ibool                   success;
3798
3807
        char*                   str;
 
3808
        size_t                  len;
3799
3809
        const char*             ptr;
3800
3810
        const char*             id;
3801
3811
        FILE*                   ef      = dict_foreign_err_file;
3810
3820
 
3811
3821
        *constraints_to_drop = mem_heap_alloc(heap, 1000 * sizeof(char*));
3812
3822
 
3813
 
        str = dict_strip_comments(*(trx->mysql_query_str));
 
3823
        ptr = innobase_get_stmt(trx->mysql_thd, &len);
 
3824
 
 
3825
        str = dict_strip_comments(ptr, len);
 
3826
 
3814
3827
        ptr = str;
3815
3828
 
3816
3829
        ut_ad(mutex_own(&(dict_sys->mutex)));