diff options
Diffstat (limited to 'sql')
65 files changed, 3017 insertions, 1090 deletions
diff --git a/sql/Makefile.am b/sql/Makefile.am index 43a7617df52..cf7bc0a1452 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -142,7 +142,8 @@ sql_yacc.o: sql_yacc.cc sql_yacc.h $(HEADERS) # this avoid the rebuild of the built files in a source dist lex_hash.h: gen_lex_hash.cc lex.h $(MAKE) $(AM_MAKEFLAGS) gen_lex_hash$(EXEEXT) - ./gen_lex_hash$(EXEEXT) > $@ + ./gen_lex_hash$(EXEEXT) > $@-t + $(MV) $@-t $@ # For testing of udf_example.so; Works on platforms with gcc # (This is not part of our build process but only provided as an example) diff --git a/sql/examples/ha_tina.cc b/sql/examples/ha_tina.cc index 0091e1f40a0..a3b05d298c2 100644 --- a/sql/examples/ha_tina.cc +++ b/sql/examples/ha_tina.cc @@ -220,6 +220,18 @@ static int free_share(TINA_SHARE *share) } +bool tina_end() +{ + if (tina_init) + { + hash_free(&tina_open_tables); + VOID(pthread_mutex_destroy(&tina_mutex)); + } + tina_init= 0; + return FALSE; +} + + /* Finds the end of a line. Currently only supports files written on a UNIX OS. diff --git a/sql/examples/ha_tina.h b/sql/examples/ha_tina.h index d8cd0fa9cfe..266db1bc1fe 100644 --- a/sql/examples/ha_tina.h +++ b/sql/examples/ha_tina.h @@ -136,3 +136,5 @@ class ha_tina: public handler int find_current_row(byte *buf); int chain_append(); }; + +bool tina_end(); diff --git a/sql/field.cc b/sql/field.cc index e88b8b313e2..1b27e12e078 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3318,7 +3318,7 @@ int Field_double::store(double nr) else { double max_value; - if (dec >= NOT_FIXED_DEC) + if (not_fixed) { max_value= DBL_MAX; } @@ -5204,6 +5204,16 @@ uint Field_string::max_packed_col_length(uint max_length) return (max_length > 255 ? 2 : 1)+max_length; } +uint Field_string::get_key_image(char *buff, uint length, CHARSET_INFO *cs, + imagetype type_arg) +{ + uint bytes = my_charpos(cs, ptr, ptr + field_length, + length / field_charset->mbmaxlen); + memcpy(buff, ptr, bytes); + if (bytes < length) + bzero(buff + bytes, length - bytes); + return bytes; +} /**************************************************************************** ** VARCHAR type (Not available for the end user yet) @@ -5414,8 +5424,8 @@ uint Field_varstring::max_packed_col_length(uint max_length) return (max_length > 255 ? 2 : 1)+max_length; } -void Field_varstring::get_key_image(char *buff, uint length, CHARSET_INFO *cs, - imagetype type) +uint Field_varstring::get_key_image(char *buff, uint length, CHARSET_INFO *cs, + imagetype type) { uint f_length=uint2korr(ptr); if (f_length > length) @@ -5426,6 +5436,7 @@ void Field_varstring::get_key_image(char *buff, uint length, CHARSET_INFO *cs, if (f_length < length) bzero(buff+HA_KEY_BLOB_LENGTH+f_length, (length-f_length)); #endif + return HA_KEY_BLOB_LENGTH+f_length; } void Field_varstring::set_key_image(char *buff,uint length, CHARSET_INFO *cs) @@ -5724,8 +5735,8 @@ int Field_blob::cmp_binary(const char *a_ptr, const char *b_ptr, /* The following is used only when comparing a key */ -void Field_blob::get_key_image(char *buff,uint length, - CHARSET_INFO *cs, imagetype type) +uint Field_blob::get_key_image(char *buff,uint length, + CHARSET_INFO *cs, imagetype type) { uint32 blob_length= get_length(ptr); char *blob; @@ -5737,16 +5748,17 @@ void Field_blob::get_key_image(char *buff,uint length, MBR mbr; Geometry_buffer buffer; Geometry *gobj; + const uint image_length= SIZEOF_STORED_DOUBLE*4; if (blob_length < SRID_SIZE) { - bzero(buff, SIZEOF_STORED_DOUBLE*4); - return; + bzero(buff, image_length); + return image_length; } get_ptr(&blob); gobj= Geometry::construct(&buffer, blob, blob_length); if (gobj->get_mbr(&mbr, &dummy)) - bzero(buff, SIZEOF_STORED_DOUBLE*4); + bzero(buff, image_length); else { float8store(buff, mbr.xmin); @@ -5754,7 +5766,7 @@ void Field_blob::get_key_image(char *buff,uint length, float8store(buff+16, mbr.ymin); float8store(buff+24, mbr.ymax); } - return; + return image_length; } #endif /*HAVE_SPATIAL*/ @@ -5774,6 +5786,7 @@ void Field_blob::get_key_image(char *buff,uint length, } int2store(buff,length); memcpy(buff+HA_KEY_BLOB_LENGTH, blob, length); + return HA_KEY_BLOB_LENGTH+length; } void Field_blob::set_key_image(char *buff,uint length, CHARSET_INFO *cs) @@ -6021,8 +6034,8 @@ uint Field_blob::max_packed_col_length(uint max_length) #ifdef HAVE_SPATIAL -void Field_geom::get_key_image(char *buff, uint length, CHARSET_INFO *cs, - imagetype type) +uint Field_geom::get_key_image(char *buff, uint length, CHARSET_INFO *cs, + imagetype type) { char *blob; const char *dummy; @@ -6030,16 +6043,17 @@ void Field_geom::get_key_image(char *buff, uint length, CHARSET_INFO *cs, ulong blob_length= get_length(ptr); Geometry_buffer buffer; Geometry *gobj; + const uint image_length= SIZEOF_STORED_DOUBLE*4; if (blob_length < SRID_SIZE) { - bzero(buff, SIZEOF_STORED_DOUBLE*4); - return; + bzero(buff, image_length); + return image_length; } get_ptr(&blob); gobj= Geometry::construct(&buffer, blob, blob_length); if (gobj->get_mbr(&mbr, &dummy)) - bzero(buff, SIZEOF_STORED_DOUBLE*4); + bzero(buff, image_length); else { float8store(buff, mbr.xmin); @@ -6047,6 +6061,7 @@ void Field_geom::get_key_image(char *buff, uint length, CHARSET_INFO *cs, float8store(buff + 16, mbr.ymin); float8store(buff + 24, mbr.ymax); } + return image_length; } diff --git a/sql/field.h b/sql/field.h index e4991ba1961..20f1209a439 100644 --- a/sql/field.h +++ b/sql/field.h @@ -228,9 +228,43 @@ public: { memcpy(buff,ptr,length); } inline void set_image(char *buff,uint length, CHARSET_INFO *cs) { memcpy(ptr,buff,length); } - virtual void get_key_image(char *buff,uint length, CHARSET_INFO *cs, - imagetype type) - { get_image(buff,length,cs); } + + + /* + Copy a field part into an output buffer. + + SYNOPSIS + Field::get_key_image() + buff [out] output buffer + length output buffer size + cs charset, always same as this->charset(), + (to be removed in 5.x) + type itMBR for geometry blobs, otherwise itRAW + + DESCRIPTION + This function makes a copy of field part of size equal to or + less than "length" parameter value. + For fields of string types (CHAR, VARCHAR, TEXT) the rest of buffer + is padded by zero byte. + + NOTES + For variable length character fields (i.e. UTF-8) the "length" + parameter means a number of output buffer bytes as if all field + characters have maximal possible size (mbmaxlen). In the other words, + "length" parameter is a number of characters multiplied by + field_charset->mbmaxlen. + + RETURN + Number of copied bytes (excluding padded zero bytes -- see above). + */ + + virtual uint get_key_image(char *buff, uint length, + CHARSET_INFO *cs, + imagetype type) + { + get_image(buff,length,cs); + return length; + } virtual void set_key_image(char *buff,uint length, CHARSET_INFO *cs) { set_image(buff,length,cs); } inline longlong val_int_offset(uint row_offset) @@ -616,6 +650,7 @@ public: class Field_double :public Field_num { public: + my_bool not_fixed; Field_double(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, @@ -623,12 +658,20 @@ public: uint8 dec_arg,bool zero_arg,bool unsigned_arg) :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg, field_name_arg, table_arg, - dec_arg, zero_arg,unsigned_arg) + dec_arg, zero_arg, unsigned_arg), + not_fixed(dec_arg >= NOT_FIXED_DEC) {} Field_double(uint32 len_arg, bool maybe_null_arg, const char *field_name_arg, struct st_table *table_arg, uint8 dec_arg) - :Field_num((char*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, (uint) 0, - NONE, field_name_arg, table_arg,dec_arg,0,0) + :Field_num((char *) 0, len_arg, maybe_null_arg ? (uchar *) "" : 0, (uint) 0, + NONE, field_name_arg, table_arg,dec_arg, 0, 0), + not_fixed(dec_arg >= NOT_FIXED_DEC) + {} + Field_double(uint32 len_arg, bool maybe_null_arg, const char *field_name_arg, + struct st_table *table_arg, uint8 dec_arg, my_bool not_fixed_srg) + :Field_num((char *) 0, len_arg, maybe_null_arg ? (uchar *) "" : 0, (uint) 0, + NONE, field_name_arg, table_arg, dec_arg, 0, 0), + not_fixed(not_fixed_srg) {} enum_field_types type() const { return FIELD_TYPE_DOUBLE;} enum ha_base_keytype key_type() const { return HA_KEYTYPE_DOUBLE; } @@ -645,6 +688,7 @@ public: uint32 pack_length() const { return sizeof(double); } void sql_type(String &str) const; uint32 max_length() { return 53; } + uint size_of() const { return sizeof(*this); } }; @@ -937,6 +981,8 @@ public: enum_field_types real_type() const { return FIELD_TYPE_STRING; } bool has_charset(void) const { return charset() == &my_charset_bin ? FALSE : TRUE; } + virtual uint get_key_image(char *buff,uint length, CHARSET_INFO *cs, + imagetype type); }; @@ -971,7 +1017,7 @@ public: String *val_str(String*,String *); int cmp(const char *,const char*); void sort_string(char *buff,uint length); - void get_key_image(char *buff,uint length, CHARSET_INFO *cs, imagetype type); + uint get_key_image(char *buff,uint length, CHARSET_INFO *cs, imagetype type); void set_key_image(char *buff,uint length, CHARSET_INFO *cs); void sql_type(String &str) const; char *pack(char *to, const char *from, uint max_length=~(uint) 0); @@ -1050,7 +1096,7 @@ public: store_length(length); memcpy_fixed(ptr+packlength,&data,sizeof(char*)); } - void get_key_image(char *buff,uint length, CHARSET_INFO *cs, imagetype type); + uint get_key_image(char *buff,uint length, CHARSET_INFO *cs, imagetype type); void set_key_image(char *buff,uint length, CHARSET_INFO *cs); void sql_type(String &str) const; inline bool copy() @@ -1105,9 +1151,9 @@ public: int store(const char *to, uint length, CHARSET_INFO *charset); int store(double nr) { return 1; } int store(longlong nr) { return 1; } - int reset(void) { return !maybe_null(); } + int reset(void) { return !maybe_null() || Field_blob::reset(); } - void get_key_image(char *buff,uint length, CHARSET_INFO *cs,imagetype type); + uint get_key_image(char *buff,uint length, CHARSET_INFO *cs,imagetype type); void set_key_image(char *buff,uint length, CHARSET_INFO *cs); }; #endif /*HAVE_SPATIAL*/ diff --git a/sql/field_conv.cc b/sql/field_conv.cc index d61b3735c91..59b550572c3 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -605,6 +605,10 @@ void field_conv(Field *to,Field *from) from->charset() == to->charset() && to->table->db_low_byte_first == from->table->db_low_byte_first) { // Identical fields +#ifdef HAVE_purify + /* This may happen if one does 'UPDATE ... SET x=x' */ + if (to->ptr != from->ptr) +#endif memcpy(to->ptr,from->ptr,to->pack_length()); return; } diff --git a/sql/filesort.cc b/sql/filesort.cc index 63a8515020b..38a49e24263 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -387,7 +387,8 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, byte *ref_pos,*next_pos,ref_buff[MAX_REFLENGTH]; my_off_t record; TABLE *sort_form; - volatile my_bool *killed= ¤t_thd->killed; + THD *thd= current_thd; + volatile my_bool *killed= &thd->killed; handler *file; DBUG_ENTER("find_all_keys"); DBUG_PRINT("info",("using: %s",(select?select->quick?"ranges":"where":"every row"))); @@ -474,6 +475,9 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, } else file->unlock_row(); + /* It does not make sense to read more keys in case of a fatal error */ + if (thd->net.report_error) + DBUG_RETURN(HA_POS_ERROR); } (void) file->extra(HA_EXTRA_NO_CACHE); /* End cacheing of records */ if (!next_pos) diff --git a/sql/ha_blackhole.h b/sql/ha_blackhole.h index 177b59fa970..e5f5ee69a82 100644 --- a/sql/ha_blackhole.h +++ b/sql/ha_blackhole.h @@ -46,8 +46,7 @@ public: { return(HA_NULL_IN_KEY | HA_CAN_FULLTEXT | HA_CAN_SQL_HANDLER | HA_DUPP_POS | HA_CAN_INDEX_BLOBS | HA_AUTO_PART_KEY | - HA_FILE_BASED | HA_CAN_GEOMETRY | HA_READ_RND_SAME | - HA_CAN_INSERT_DELAYED); + HA_FILE_BASED | HA_CAN_GEOMETRY | HA_READ_RND_SAME); } ulong index_flags(uint inx, uint part, bool all_parts) const { diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc index 3e981087df7..dd3a84aaaee 100644 --- a/sql/ha_heap.cc +++ b/sql/ha_heap.cc @@ -549,7 +549,10 @@ int ha_heap::create(const char *name, TABLE *table_arg, seg->start= (uint) key_part->offset; seg->length= (uint) key_part->length; seg->flag = 0; - seg->charset= field->charset(); + if (field->flags & (ENUM_FLAG | SET_FLAG)) + seg->charset= &my_charset_bin; + else + seg->charset= field->charset(); if (field->null_ptr) { seg->null_bit= field->null_bit; diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 2e29d929352..ef44cbdbb32 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -91,6 +91,331 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type, return; } + +/* + Convert TABLE object to MyISAM key and column definition + + SYNOPSIS + table2myisam() + table_arg in TABLE object. + keydef_out out MyISAM key definition. + recinfo_out out MyISAM column definition. + records_out out Number of fields. + + DESCRIPTION + This function will allocate and initialize MyISAM key and column + definition for further use in mi_create or for a check for underlying + table conformance in merge engine. + + RETURN VALUE + 0 OK + !0 error code +*/ + +int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out, + MI_COLUMNDEF **recinfo_out, uint *records_out) +{ + uint i, j, recpos, minpos, fieldpos, temp_length, length; + uint options= table_arg->db_options_in_use; + enum ha_base_keytype type= HA_KEYTYPE_BINARY; + KEY *pos; + MI_KEYDEF *keydef; + MI_COLUMNDEF *recinfo, *recinfo_pos; + HA_KEYSEG *keyseg; + + DBUG_ENTER("table2myisam"); + if (!(my_multi_malloc(MYF(MY_WME), + recinfo_out, (table_arg->fields * 2 + 2) * sizeof(MI_COLUMNDEF), + keydef_out, table_arg->keys * sizeof(MI_KEYDEF), + &keyseg, + (table_arg->key_parts + table_arg->keys) * sizeof(HA_KEYSEG), + NullS))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); /* purecov: inspected */ + keydef= *keydef_out; + recinfo= *recinfo_out; + pos= table_arg->key_info; + for (i= 0; i < table_arg->keys; i++, pos++) + { + keydef[i].flag= (pos->flags & (HA_NOSAME | HA_FULLTEXT | HA_SPATIAL)); + keydef[i].key_alg= pos->algorithm == HA_KEY_ALG_UNDEF ? + (pos->flags & HA_SPATIAL ? HA_KEY_ALG_RTREE : HA_KEY_ALG_BTREE) : + pos->algorithm; + keydef[i].seg= keyseg; + keydef[i].keysegs= pos->key_parts; + for (j= 0; j < pos->key_parts; j++) + { + keydef[i].seg[j].flag= pos->key_part[j].key_part_flag; + Field *field= pos->key_part[j].field; + type= field->key_type(); + + if (options & HA_OPTION_PACK_KEYS || + (pos->flags & (HA_PACK_KEY | HA_BINARY_PACK_KEY | + HA_SPACE_PACK_USED))) + { + if (pos->key_part[j].length > 8 && + (type == HA_KEYTYPE_TEXT || + type == HA_KEYTYPE_NUM || + (type == HA_KEYTYPE_BINARY && !field->zero_pack()))) + { + /* No blobs here */ + if (j == 0) + keydef[i].flag|= HA_PACK_KEY; + if (!(field->flags & ZEROFILL_FLAG) && + (field->type() == FIELD_TYPE_STRING || + field->type() == FIELD_TYPE_VAR_STRING || + ((int) (pos->key_part[j].length - field->decimals())) >= 4)) + keydef[i].seg[j].flag|= HA_SPACE_PACK; + } + else if (j == 0 && (!(pos->flags & HA_NOSAME) || pos->key_length > 16)) + keydef[i].flag|= HA_BINARY_PACK_KEY; + } + keydef[i].seg[j].type= (int) type; + keydef[i].seg[j].start= pos->key_part[j].offset; + keydef[i].seg[j].length= pos->key_part[j].length; + keydef[i].seg[j].bit_start= keydef[i].seg[j].bit_end= 0; + keydef[i].seg[j].language= field->charset()->number; + + if (field->null_ptr) + { + keydef[i].seg[j].null_bit= field->null_bit; + keydef[i].seg[j].null_pos= (uint) (field->null_ptr- + (uchar*) table_arg->record[0]); + } + else + { + keydef[i].seg[j].null_bit= 0; + keydef[i].seg[j].null_pos= 0; + } + if (field->type() == FIELD_TYPE_BLOB || + field->type() == FIELD_TYPE_GEOMETRY) + { + keydef[i].seg[j].flag|= HA_BLOB_PART; + /* save number of bytes used to pack length */ + keydef[i].seg[j].bit_start= (uint) (field->pack_length() - + table_arg->blob_ptr_size); + } + } + keyseg+= pos->key_parts; + } + if (table_arg->found_next_number_field) + keydef[table_arg->next_number_index].flag|= HA_AUTO_KEY; + recpos= 0; + recinfo_pos= recinfo; + while (recpos < (uint) table_arg->reclength) + { + Field **field, *found= 0; + minpos= table_arg->reclength; + length= 0; + + for (field= table_arg->field; *field; field++) + { + if ((fieldpos= (*field)->offset()) >= recpos && + fieldpos <= minpos) + { + /* skip null fields */ + if (!(temp_length= (*field)->pack_length())) + continue; /* Skip null-fields */ + if (! found || fieldpos < minpos || + (fieldpos == minpos && temp_length < length)) + { + minpos= fieldpos; + found= *field; + length= temp_length; + } + } + } + DBUG_PRINT("loop", ("found: %lx recpos: %d minpos: %d length: %d", + (long) found, recpos, minpos, length)); + if (recpos != minpos) + { // Reserved space (Null bits?) + bzero((char*) recinfo_pos, sizeof(*recinfo_pos)); + recinfo_pos->type= (int) FIELD_NORMAL; + recinfo_pos++->length= (uint16) (minpos - recpos); + } + if (!found) + break; + + if (found->flags & BLOB_FLAG) + { + recinfo_pos->type= (int) FIELD_BLOB; + } + else if (!(options & HA_OPTION_PACK_RECORD)) + recinfo_pos->type= (int) FIELD_NORMAL; + else if (found->zero_pack()) + recinfo_pos->type= (int) FIELD_SKIP_ZERO; + else + recinfo_pos->type= (int) ((length <= 3 || + (found->flags & ZEROFILL_FLAG)) ? + FIELD_NORMAL : + found->type() == FIELD_TYPE_STRING || + found->type() == FIELD_TYPE_VAR_STRING ? + FIELD_SKIP_ENDSPACE : + FIELD_SKIP_PRESPACE); + if (found->null_ptr) + { + recinfo_pos->null_bit= found->null_bit; + recinfo_pos->null_pos= (uint) (found->null_ptr - + (uchar*) table_arg->record[0]); + } + else + { + recinfo_pos->null_bit= 0; + recinfo_pos->null_pos= 0; + } + (recinfo_pos++)->length= (uint16) length; + recpos= minpos + length; + DBUG_PRINT("loop", ("length: %d type: %d", + recinfo_pos[-1].length,recinfo_pos[-1].type)); + } + *records_out= (uint) (recinfo_pos - recinfo); + DBUG_RETURN(0); +} + + +/* + Check for underlying table conformance + + SYNOPSIS + check_definition() + t1_keyinfo in First table key definition + t1_recinfo in First table record definition + t1_keys in Number of keys in first table + t1_recs in Number of records in first table + t2_keyinfo in Second table key definition + t2_recinfo in Second table record definition + t2_keys in Number of keys in second table + t2_recs in Number of records in second table + strict in Strict check switch + + DESCRIPTION + This function compares two MyISAM definitions. By intention it was done + to compare merge table definition against underlying table definition. + It may also be used to compare dot-frm and MYI definitions of MyISAM + table as well to compare different MyISAM table definitions. + + For merge table it is not required that number of keys in merge table + must exactly match number of keys in underlying table. When calling this + function for underlying table conformance check, 'strict' flag must be + set to false, and converted merge definition must be passed as t1_*. + + Otherwise 'strict' flag must be set to 1 and it is not required to pass + converted dot-frm definition as t1_*. + + RETURN VALUE + 0 - Equal definitions. + 1 - Different definitions. + + TODO + - compare FULLTEXT keys; + - compare SPATIAL keys; + - compare FIELD_SKIP_ZERO which is converted to FIELD_NORMAL correctly + (should be corretly detected in table2myisam). +*/ + +int check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo, + uint t1_keys, uint t1_recs, + MI_KEYDEF *t2_keyinfo, MI_COLUMNDEF *t2_recinfo, + uint t2_keys, uint t2_recs, bool strict) +{ + uint i, j; + DBUG_ENTER("check_definition"); + if ((strict ? t1_keys != t2_keys : t1_keys > t2_keys)) + { + DBUG_PRINT("error", ("Number of keys differs: t1_keys=%u, t2_keys=%u", + t1_keys, t2_keys)); + DBUG_RETURN(1); + } + if (t1_recs != t2_recs) + { + DBUG_PRINT("error", ("Number of recs differs: t1_recs=%u, t2_recs=%u", + t1_recs, t2_recs)); + DBUG_RETURN(1); + } + for (i= 0; i < t1_keys; i++) + { + HA_KEYSEG *t1_keysegs= t1_keyinfo[i].seg; + HA_KEYSEG *t2_keysegs= t2_keyinfo[i].seg; + if (t1_keyinfo[i].flag & HA_FULLTEXT && t2_keyinfo[i].flag & HA_FULLTEXT) + continue; + else if (t1_keyinfo[i].flag & HA_FULLTEXT || + t2_keyinfo[i].flag & HA_FULLTEXT) + { + DBUG_PRINT("error", ("Key %d has different definition", i)); + DBUG_PRINT("error", ("t1_fulltext= %d, t2_fulltext=%d", + test(t1_keyinfo[i].flag & HA_FULLTEXT), + test(t2_keyinfo[i].flag & HA_FULLTEXT))); + DBUG_RETURN(1); + } + if (t1_keyinfo[i].flag & HA_SPATIAL && t2_keyinfo[i].flag & HA_SPATIAL) + continue; + else if (t1_keyinfo[i].flag & HA_SPATIAL || + t2_keyinfo[i].flag & HA_SPATIAL) + { + DBUG_PRINT("error", ("Key %d has different definition", i)); + DBUG_PRINT("error", ("t1_spatial= %d, t2_spatial=%d", + test(t1_keyinfo[i].flag & HA_SPATIAL), + test(t2_keyinfo[i].flag & HA_SPATIAL))); + DBUG_RETURN(1); + } + if (t1_keyinfo[i].keysegs != t2_keyinfo[i].keysegs || + t1_keyinfo[i].key_alg != t2_keyinfo[i].key_alg) + { + DBUG_PRINT("error", ("Key %d has different definition", i)); + DBUG_PRINT("error", ("t1_keysegs=%d, t1_key_alg=%d", + t1_keyinfo[i].keysegs, t1_keyinfo[i].key_alg)); + DBUG_PRINT("error", ("t2_keysegs=%d, t2_key_alg=%d", + t2_keyinfo[i].keysegs, t2_keyinfo[i].key_alg)); + DBUG_RETURN(1); + } + for (j= t1_keyinfo[i].keysegs; j--;) + { + if (t1_keysegs[j].type != t2_keysegs[j].type || + t1_keysegs[j].language != t2_keysegs[j].language || + t1_keysegs[j].null_bit != t2_keysegs[j].null_bit || + t1_keysegs[j].length != t2_keysegs[j].length) + { + DBUG_PRINT("error", ("Key segment %d (key %d) has different " + "definition", j, i)); + DBUG_PRINT("error", ("t1_type=%d, t1_language=%d, t1_null_bit=%d, " + "t1_length=%d", + t1_keysegs[j].type, t1_keysegs[j].language, + t1_keysegs[j].null_bit, t1_keysegs[j].length)); + DBUG_PRINT("error", ("t2_type=%d, t2_language=%d, t2_null_bit=%d, " + "t2_length=%d", + t2_keysegs[j].type, t2_keysegs[j].language, + t2_keysegs[j].null_bit, t2_keysegs[j].length)); + + DBUG_RETURN(1); + } + } + } + for (i= 0; i < t1_recs; i++) + { + MI_COLUMNDEF *t1_rec= &t1_recinfo[i]; + MI_COLUMNDEF *t2_rec= &t2_recinfo[i]; + /* + FIELD_SKIP_ZERO can be changed to FIELD_NORMAL in mi_create, + see NOTE1 in mi_create.c + */ + if ((t1_rec->type != t2_rec->type && + !(t1_rec->type == (int) FIELD_SKIP_ZERO && + t1_rec->length == 1 && + t2_rec->type == (int) FIELD_NORMAL)) || + t1_rec->length != t2_rec->length || + t1_rec->null_bit != t2_rec->null_bit) + { + DBUG_PRINT("error", ("Field %d has different definition", i)); + DBUG_PRINT("error", ("t1_type=%d, t1_length=%d, t1_null_bit=%d", + t1_rec->type, t1_rec->length, t1_rec->null_bit)); + DBUG_PRINT("error", ("t2_type=%d, t2_length=%d, t2_null_bit=%d", + t2_rec->type, t2_rec->length, t2_rec->null_bit)); + DBUG_RETURN(1); + } + } + DBUG_RETURN(0); +} + + extern "C" { volatile my_bool *killed_ptr(MI_CHECK *param) @@ -557,8 +882,8 @@ int ha_myisam::optimize(THD* thd, HA_CHECK_OPT *check_opt) param.sort_buffer_length= check_opt->sort_buffer_size; if ((error= repair(thd,param,1)) && param.retry_repair) { - sql_print_warning("Warning: Optimize table got errno %d, retrying", - my_errno); + sql_print_warning("Warning: Optimize table got errno %d on %s.%s, retrying", + my_errno, param.db_name, param.table_name); param.testflag&= ~T_REP_BY_SORT; error= repair(thd,param,1); } @@ -577,6 +902,22 @@ int ha_myisam::repair(THD *thd, MI_CHECK ¶m, bool optimize) ha_rows rows= file->state->records; DBUG_ENTER("ha_myisam::repair"); + /* + Normally this method is entered with a properly opened table. If the + repair fails, it can be repeated with more elaborate options. Under + special circumstances it can happen that a repair fails so that it + closed the data file and cannot re-open it. In this case file->dfile + is set to -1. We must not try another repair without an open data + file. (Bug #25289) + */ + if (file->dfile == -1) + { + sql_print_information("Retrying repair of: '%s' failed. " + "Please try REPAIR EXTENDED or myisamchk", + table->path); + DBUG_RETURN(HA_ADMIN_FAILED); + } + param.db_name = table->table_cache_key; param.table_name = table->table_name; param.tmpfile_createflag = O_RDWR | O_TRUNC; @@ -932,8 +1273,8 @@ int ha_myisam::enable_indexes(uint mode) param.tmpdir=&mysql_tmpdir_list; if ((error= (repair(thd,param,0) != HA_ADMIN_OK)) && param.retry_repair) { - sql_print_warning("Warning: Enabling keys got errno %d, retrying", - my_errno); + sql_print_warning("Warning: Enabling keys got errno %d on %s.%s, retrying", + my_errno, param.db_name, param.table_name); param.testflag&= ~(T_REP_BY_SORT | T_QUICK); error= (repair(thd,param,0) != HA_ADMIN_OK); } @@ -1345,181 +1686,30 @@ int ha_myisam::create(const char *name, register TABLE *table_arg, HA_CREATE_INFO *info) { int error; - uint i,j,recpos,minpos,fieldpos,temp_length,length, create_flags= 0; - bool found_real_auto_increment=0; - enum ha_base_keytype type; + uint create_flags= 0, options= table_arg->db_options_in_use, records; char buff[FN_REFLEN]; - KEY *pos; MI_KEYDEF *keydef; - MI_COLUMNDEF *recinfo,*recinfo_pos; - HA_KEYSEG *keyseg; - uint options=table_arg->db_options_in_use; - DBUG_ENTER("ha_myisam::create"); - - type=HA_KEYTYPE_BINARY; // Keep compiler happy - if (!(my_multi_malloc(MYF(MY_WME), - &recinfo,(table_arg->fields*2+2)*sizeof(MI_COLUMNDEF), - &keydef, table_arg->keys*sizeof(MI_KEYDEF), - &keyseg, - ((table_arg->key_parts + table_arg->keys) * - sizeof(HA_KEYSEG)), - NullS))) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); - - pos=table_arg->key_info; - for (i=0; i < table_arg->keys ; i++, pos++) - { - keydef[i].flag= (pos->flags & (HA_NOSAME | HA_FULLTEXT | HA_SPATIAL)); - keydef[i].key_alg= pos->algorithm == HA_KEY_ALG_UNDEF ? - (pos->flags & HA_SPATIAL ? HA_KEY_ALG_RTREE : HA_KEY_ALG_BTREE) : - pos->algorithm; - keydef[i].seg=keyseg; - keydef[i].keysegs=pos->key_parts; - for (j=0 ; j < pos->key_parts ; j++) - { - keydef[i].seg[j].flag=pos->key_part[j].key_part_flag; - Field *field=pos->key_part[j].field; - type=field->key_type(); - - if (options & HA_OPTION_PACK_KEYS || - (pos->flags & (HA_PACK_KEY | HA_BINARY_PACK_KEY | - HA_SPACE_PACK_USED))) - { - if (pos->key_part[j].length > 8 && - (type == HA_KEYTYPE_TEXT || - type == HA_KEYTYPE_NUM || - (type == HA_KEYTYPE_BINARY && !field->zero_pack()))) - { - /* No blobs here */ - if (j == 0) - keydef[i].flag|=HA_PACK_KEY; - if (!(field->flags & ZEROFILL_FLAG) && - (field->type() == FIELD_TYPE_STRING || - field->type() == FIELD_TYPE_VAR_STRING || - ((int) (pos->key_part[j].length - field->decimals())) - >= 4)) - keydef[i].seg[j].flag|=HA_SPACE_PACK; - } - else if (j == 0 && (!(pos->flags & HA_NOSAME) || pos->key_length > 16)) - keydef[i].flag|= HA_BINARY_PACK_KEY; - } - keydef[i].seg[j].type= (int) type; - keydef[i].seg[j].start= pos->key_part[j].offset; - keydef[i].seg[j].length= pos->key_part[j].length; - keydef[i].seg[j].bit_start=keydef[i].seg[j].bit_end=0; - keydef[i].seg[j].language = field->charset()->number; - - if (field->null_ptr) - { - keydef[i].seg[j].null_bit=field->null_bit; - keydef[i].seg[j].null_pos= (uint) (field->null_ptr- - (uchar*) table_arg->record[0]); - } - else - { - keydef[i].seg[j].null_bit=0; - keydef[i].seg[j].null_pos=0; - } - if (field->type() == FIELD_TYPE_BLOB || - field->type() == FIELD_TYPE_GEOMETRY) - { - keydef[i].seg[j].flag|=HA_BLOB_PART; - /* save number of bytes used to pack length */ - keydef[i].seg[j].bit_start= (uint) (field->pack_length() - - table_arg->blob_ptr_size); - } - } - keyseg+=pos->key_parts; - } - - if (table_arg->found_next_number_field) - { - keydef[table_arg->next_number_index].flag|= HA_AUTO_KEY; - found_real_auto_increment= table_arg->next_number_key_offset == 0; - } - - recpos=0; recinfo_pos=recinfo; - while (recpos < (uint) table_arg->reclength) - { - Field **field,*found=0; - minpos=table_arg->reclength; length=0; - - for (field=table_arg->field ; *field ; field++) - { - if ((fieldpos=(*field)->offset()) >= recpos && - fieldpos <= minpos) - { - /* skip null fields */ - if (!(temp_length= (*field)->pack_length())) - continue; /* Skip null-fields */ - if (! found || fieldpos < minpos || - (fieldpos == minpos && temp_length < length)) - { - minpos=fieldpos; found= *field; length=temp_length; - } - } - } - DBUG_PRINT("loop",("found: %lx recpos: %d minpos: %d length: %d", - found,recpos,minpos,length)); - if (recpos != minpos) - { // Reserved space (Null bits?) - bzero((char*) recinfo_pos,sizeof(*recinfo_pos)); - recinfo_pos->type=(int) FIELD_NORMAL; - recinfo_pos++->length= (uint16) (minpos-recpos); - } - if (! found) - break; - - if (found->flags & BLOB_FLAG) - { - recinfo_pos->type= (int) FIELD_BLOB; - } - else if (!(options & HA_OPTION_PACK_RECORD)) - recinfo_pos->type= (int) FIELD_NORMAL; - else if (found->zero_pack()) - recinfo_pos->type= (int) FIELD_SKIP_ZERO; - else - recinfo_pos->type= (int) ((length <= 3 || - (found->flags & ZEROFILL_FLAG)) ? - FIELD_NORMAL : - found->type() == FIELD_TYPE_STRING || - found->type() == FIELD_TYPE_VAR_STRING ? - FIELD_SKIP_ENDSPACE : - FIELD_SKIP_PRESPACE); - if (found->null_ptr) - { - recinfo_pos->null_bit=found->null_bit; - recinfo_pos->null_pos= (uint) (found->null_ptr- - (uchar*) table_arg->record[0]); - } - else - { - recinfo_pos->null_bit=0; - recinfo_pos->null_pos=0; - } - (recinfo_pos++) ->length=(uint16) length; - recpos=minpos+length; - DBUG_PRINT("loop",("length: %d type: %d", - recinfo_pos[-1].length,recinfo_pos[-1].type)); - - } + MI_COLUMNDEF *recinfo; MI_CREATE_INFO create_info; - bzero((char*) &create_info,sizeof(create_info)); - create_info.max_rows=table_arg->max_rows; - create_info.reloc_rows=table_arg->min_rows; - create_info.with_auto_increment=found_real_auto_increment; - create_info.auto_increment=(info->auto_increment_value ? - info->auto_increment_value -1 : - (ulonglong) 0); + DBUG_ENTER("ha_myisam::create"); + if ((error= table2myisam(table_arg, &keydef, &recinfo, &records))) + DBUG_RETURN(error); /* purecov: inspected */ + bzero((char*) &create_info, sizeof(create_info)); + create_info.max_rows= table_arg->max_rows; + create_info.reloc_rows= table_arg->min_rows; + create_info.with_auto_increment= table_arg->next_number_key_offset == 0; + create_info.auto_increment= (info->auto_increment_value ? + info->auto_increment_value -1 : + (ulonglong) 0); create_info.data_file_length= ((ulonglong) table_arg->max_rows * - table_arg->avg_row_length); - create_info.raid_type=info->raid_type; + table_arg->avg_row_length); + create_info.raid_type= info->raid_type; create_info.raid_chunks= (info->raid_chunks ? info->raid_chunks : - RAID_DEFAULT_CHUNKS); - create_info.raid_chunksize=(info->raid_chunksize ? info->raid_chunksize : - RAID_DEFAULT_CHUNKSIZE); + RAID_DEFAULT_CHUNKS); + create_info.raid_chunksize= (info->raid_chunksize ? info->raid_chunksize : + RAID_DEFAULT_CHUNKSIZE); create_info.data_file_name= info->data_file_name; - create_info.index_file_name=info->index_file_name; + create_info.index_file_name= info->index_file_name; if (info->options & HA_LEX_CREATE_TMP_TABLE) create_flags|= HA_CREATE_TMP_TABLE; @@ -1531,13 +1721,13 @@ int ha_myisam::create(const char *name, register TABLE *table_arg, create_flags|= HA_CREATE_DELAY_KEY_WRITE; /* TODO: Check that the following fn_format is really needed */ - error=mi_create(fn_format(buff,name,"","",2+4), - table_arg->keys,keydef, - (uint) (recinfo_pos-recinfo), recinfo, - 0, (MI_UNIQUEDEF*) 0, - &create_info, create_flags); - - my_free((gptr) recinfo,MYF(0)); + error= mi_create(fn_format(buff, name, "", "", + MY_UNPACK_FILENAME|MY_REPLACE_EXT), + table_arg->keys, keydef, + records, recinfo, + 0, (MI_UNIQUEDEF*) 0, + &create_info, create_flags); + my_free((gptr) recinfo, MYF(0)); DBUG_RETURN(error); } diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc index 1fed5cc35f0..53923add49a 100644 --- a/sql/ha_myisammrg.cc +++ b/sql/ha_myisammrg.cc @@ -32,6 +32,13 @@ ** MyISAM MERGE tables *****************************************************************************/ +extern int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out, + MI_COLUMNDEF **recinfo_out, uint *records_out); +extern int check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo, + uint t1_keys, uint t1_recs, + MI_KEYDEF *t2_keyinfo, MI_COLUMNDEF *t2_recinfo, + uint t2_keys, uint t2_recs, bool strict); + const char **ha_myisammrg::bas_ext() const { static const char *ext[]= { ".MRG", NullS }; return ext; } @@ -49,6 +56,12 @@ const char *ha_myisammrg::index_type(uint key_number) int ha_myisammrg::open(const char *name, int mode, uint test_if_locked) { + MI_KEYDEF *keyinfo; + MI_COLUMNDEF *recinfo; + MYRG_TABLE *u_table; + uint recs; + uint keys= table->keys; + int error; char name_buff[FN_REFLEN]; DBUG_PRINT("info", ("ha_myisammrg::open")); @@ -69,20 +82,45 @@ int ha_myisammrg::open(const char *name, int mode, uint test_if_locked) if (table->reclength != mean_rec_length && mean_rec_length) { - DBUG_PRINT("error",("reclength: %d mean_rec_length: %d", + DBUG_PRINT("error",("reclength: %d mean_rec_length: %lu", table->reclength, mean_rec_length)); + error= HA_ERR_WRONG_MRG_TABLE_DEF; goto err; } + if ((error= table2myisam(table, &keyinfo, &recinfo, &recs))) + { + /* purecov: begin inspected */ + DBUG_PRINT("error", ("Failed to convert TABLE object to MyISAM " + "key and column definition")); + goto err; + /* purecov: end */ + } + for (u_table= file->open_tables; u_table < file->end_table; u_table++) + { + if (check_definition(keyinfo, recinfo, keys, recs, + u_table->table->s->keyinfo, u_table->table->s->rec, + u_table->table->s->base.keys, + u_table->table->s->base.fields, false)) + { + my_free((gptr) recinfo, MYF(0)); + error= HA_ERR_WRONG_MRG_TABLE_DEF; + goto err; + } + } + my_free((gptr) recinfo, MYF(0)); #if !defined(BIG_TABLES) || SIZEOF_OFF_T == 4 /* Merge table has more than 2G rows */ if (table->crashed) + { + error= HA_ERR_WRONG_MRG_TABLE_DEF; goto err; + } #endif return (0); err: myrg_close(file); file=0; - return (my_errno= HA_ERR_WRONG_MRG_TABLE_DEF); + return (my_errno= error); } int ha_myisammrg::close(void) diff --git a/sql/ha_myisammrg.h b/sql/ha_myisammrg.h index 84eaae04590..84af55b262e 100644 --- a/sql/ha_myisammrg.h +++ b/sql/ha_myisammrg.h @@ -37,7 +37,7 @@ class ha_myisammrg: public handler { return (HA_REC_NOT_IN_SEQ | HA_AUTO_PART_KEY | HA_READ_RND_SAME | HA_NULL_IN_KEY | HA_CAN_INDEX_BLOBS | HA_FILE_BASED | - HA_CAN_INSERT_DELAYED | HA_ANY_INDEX_MAY_BE_UNIQUE); + HA_ANY_INDEX_MAY_BE_UNIQUE); } ulong index_flags(uint inx, uint part, bool all_parts) const { diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index fd9a5720e3d..d16e00f4e52 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -5373,7 +5373,7 @@ ndb_get_table_statistics(ha_ndbcluster* file, bool report_error, Ndb* ndb, retry: if(report_error) { - if (file) + if (file && pTrans) { reterr= file->ndb_err(pTrans); } diff --git a/sql/handler.cc b/sql/handler.cc index 0476b855e3c..82fff72f0da 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -341,6 +341,10 @@ int ha_panic(enum ha_panic_function flag) if (have_archive_db == SHOW_OPTION_YES) error|= archive_db_end(); #endif +#ifdef HAVE_CSV_DB + if (have_csv_db == SHOW_OPTION_YES) + error|= tina_end(); +#endif return error; } /* ha_panic */ diff --git a/sql/init.cc b/sql/init.cc index 4beb8db0c6f..5e1b6532c75 100644 --- a/sql/init.cc +++ b/sql/init.cc @@ -45,6 +45,12 @@ void unireg_init(ulong options) { /* It's used by filesort... */ log_10[i]= nr ; nr*= 10.0; } + /* Make a tab of powers of 0.1 */ + for (i= 0, nr= 0.1; i < array_elements(log_01); i++) + { + log_01[i]= nr; + nr*= 0.1; + } specialflag|=options; /* Set options from argv */ DBUG_VOID_RETURN; } diff --git a/sql/item.cc b/sql/item.cc index 45d7856b2c1..bf96fdf3f43 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -47,6 +47,7 @@ Item::Item(): collation.set(&my_charset_bin, DERIVATION_COERCIBLE); name= 0; decimals= 0; max_length= 0; + with_subselect= 0; /* Put item in free list so that we can free all items at end */ THD *thd= current_thd; @@ -1761,6 +1762,8 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) Item** res= find_item_in_list(this, thd->lex->current_select->item_list, &counter, REPORT_EXCEPT_NOT_FOUND, ¬_used); + if (!res) + return 1; if (res != (Item **)not_found_item) { if ((*res)->type() == Item::FIELD_ITEM) @@ -1771,7 +1774,18 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) use the field from the Item_field in the select list and leave the Item_field instance in place. */ - set_field((*((Item_field**)res))->field); + + Field *field= (*((Item_field**)res))->field; + + if (field == NULL) + { + /* The column to which we link isn't valid. */ + my_error(ER_BAD_FIELD_ERROR, MYF(0), (*res)->name, + current_thd->where); + return(1); + } + + set_field(field); return 0; } else @@ -2367,18 +2381,31 @@ longlong Item_varbinary::val_int() int Item_varbinary::save_in_field(Field *field, bool no_conversions) { - int error; field->set_notnull(); if (field->result_type() == STRING_RESULT) + return field->store(str_value.ptr(), str_value.length(), + collation.collation); + + ulonglong nr; + uint32 length= str_value.length(); + if (length > 8) { - error=field->store(str_value.ptr(),str_value.length(),collation.collation); + nr= field->flags & UNSIGNED_FLAG ? ULONGLONG_MAX : LONGLONG_MAX; + goto warn; } - else + nr= (ulonglong) val_int(); + if ((length == 8) && !(field->flags & UNSIGNED_FLAG) && (nr > LONGLONG_MAX)) { - longlong nr=val_int(); - error=field->store(nr); + nr= LONGLONG_MAX; + goto warn; } - return error; + return field->store((longlong) nr); + +warn: + if (!field->store((longlong) nr)) + field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, + 1); + return 1; } diff --git a/sql/item.h b/sql/item.h index ad8bea663f1..f2136c4997a 100644 --- a/sql/item.h +++ b/sql/item.h @@ -142,6 +142,9 @@ public: my_bool with_sum_func; my_bool fixed; /* If item fixed with fix_fields */ DTCollation collation; + my_bool with_subselect; /* If this item is a subselect or some + of its arguments is or contains a + subselect */ // alloc & destruct is done as start of select using sql_alloc Item(); diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 859b4e0ecc1..be44d490415 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -62,6 +62,42 @@ static void agg_result_type(Item_result *type, Item **items, uint nitems) /* + Compare row signature of two expressions + + SYNOPSIS: + cmp_row_type() + item1 the first expression + item2 the second expression + + DESCRIPTION + The function checks that two expressions have compatible row signatures + i.e. that the number of columns they return are the same and that if they + are both row expressions then each component from the first expression has + a row signature compatible with the signature of the corresponding component + of the second expression. + + RETURN VALUES + 1 type incompatibility has been detected + 0 otherwise +*/ + +static int cmp_row_type(Item* item1, Item* item2) +{ + uint n= item1->cols(); + if (item2->check_cols(n)) + return 1; + for (uint i=0; i<n; i++) + { + if (item2->el(i)->check_cols(item1->el(i)->cols()) || + (item1->el(i)->result_type() == ROW_RESULT && + cmp_row_type(item1->el(i), item2->el(i)))) + return 1; + } + return 0; +} + + +/* Aggregates result types from the array of items. SYNOPSIS: @@ -75,14 +111,32 @@ static void agg_result_type(Item_result *type, Item **items, uint nitems) This function aggregates result types from the array of items. Found type supposed to be used later for comparison of values of these items. Aggregation itself is performed by the item_cmp_type() function. + The function also checks compatibility of row signatures for the + submitted items (see the spec for the cmp_row_type function). + + RETURN VALUES + 1 type incompatibility has been detected + 0 otherwise */ -static void agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems) +static int agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems) { uint i; type[0]= items[0]->result_type(); for (i= 1 ; i < nitems ; i++) + { type[0]= item_cmp_type(type[0], items[i]->result_type()); + /* + When aggregating types of two row expressions we have to check + that they have the same cardinality and that each component + of the first row expression has a compatible row signature with + the signature of the corresponding component of the second row + expression. + */ + if (type[0] == ROW_RESULT && cmp_row_type(items[0], items[i])) + return 1; // error found: invalid usage of rows + } + return 0; } static void my_coll_agg_error(DTCollation &c1, DTCollation &c2, @@ -352,6 +406,17 @@ int Arg_comparator::set_compare_func(Item_bool_func2 *item, Item_result type) func= &Arg_comparator::compare_e_int_diff_signedness; } } + else if (type == REAL_RESULT) + { + if ((*a)->decimals < NOT_FIXED_DEC && (*b)->decimals < NOT_FIXED_DEC) + { + precision= 5 * log_01[max((*a)->decimals, (*b)->decimals)]; + if (func == &Arg_comparator::compare_real) + func= &Arg_comparator::compare_real_fixed; + else if (func == &Arg_comparator::compare_e_real) + func= &Arg_comparator::compare_e_real_fixed; + } + } return 0; } @@ -459,6 +524,44 @@ int Arg_comparator::compare_e_real() return test(val1 == val2); } + +int Arg_comparator::compare_real_fixed() +{ + /* + Fix yet another manifestation of Bug#2338. 'Volatile' will instruct + gcc to flush double values out of 80-bit Intel FPU registers before + performing the comparison. + */ + volatile double val1, val2; + val1= (*a)->val(); + if (!(*a)->null_value) + { + val2= (*b)->val(); + if (!(*b)->null_value) + { + owner->null_value= 0; + if (val1 == val2 || fabs(val1 - val2) < precision) + return 0; + if (val1 < val2) + return -1; + return 1; + } + } + owner->null_value= 1; + return -1; +} + + +int Arg_comparator::compare_e_real_fixed() +{ + double val1= (*a)->val(); + double val2= (*b)->val(); + if ((*a)->null_value || (*b)->null_value) + return test((*a)->null_value && (*b)->null_value); + return test(val1 == val2 || fabs(val1 - val2) < precision); +} + + int Arg_comparator::compare_int_signed() { longlong val1= (*a)->val_int(); @@ -577,17 +680,45 @@ int Arg_comparator::compare_e_int_diff_signedness() int Arg_comparator::compare_row() { int res= 0; + bool was_null= 0; (*a)->bring_value(); (*b)->bring_value(); uint n= (*a)->cols(); for (uint i= 0; i<n; i++) { - if ((res= comparators[i].compare())) - return res; + res= comparators[i].compare(); if (owner->null_value) - return -1; + { + // NULL was compared + switch (owner->functype()) { + case Item_func::NE_FUNC: + break; // NE never aborts on NULL even if abort_on_null is set + case Item_func::LT_FUNC: + case Item_func::LE_FUNC: + case Item_func::GT_FUNC: + case Item_func::GE_FUNC: + return -1; // <, <=, > and >= always fail on NULL + default: // EQ_FUNC + if (owner->abort_on_null) + return -1; // We do not need correct NULL returning + } + was_null= 1; + owner->null_value= 0; + res= 0; // continue comparison (maybe we will meet explicit difference) + } + else if (res) + return res; } - return res; + if (was_null) + { + /* + There was NULL(s) in comparison in some parts, but there was no + explicit difference in other parts, so we have to return NULL. + */ + owner->null_value= 1; + return -1; + } + return 0; } int Arg_comparator::compare_e_row() @@ -789,6 +920,26 @@ longlong Item_func_strcmp::val_int() } +bool Item_func_opt_neg::eq(const Item *item, bool binary_cmp) const +{ + /* Assume we don't have rtti */ + if (this == item) + return 1; + if (item->type() != FUNC_ITEM) + return 0; + Item_func *item_func=(Item_func*) item; + if (arg_count != item_func->arg_count || + functype() != item_func->functype()) + return 0; + if (negated != ((Item_func_opt_neg *) item_func)->negated) + return 0; + for (uint i=0; i < arg_count ; i++) + if (!args[i]->eq(item_func->arguments()[i], binary_cmp)) + return 0; + return 1; +} + + void Item_func_interval::fix_length_and_dec() { if (row->cols() > 8) @@ -915,7 +1066,8 @@ void Item_func_between::fix_length_and_dec() */ if (!args[0] || !args[1] || !args[2]) return; - agg_cmp_type(thd, &cmp_type, args, 3); + if ( agg_cmp_type(thd, &cmp_type, args, 3)) + return; if (cmp_type == STRING_RESULT && agg_arg_charsets(cmp_collation, args, 3, MY_COLL_CMP_CONV)) return; @@ -1463,7 +1615,8 @@ void Item_func_case::fix_length_and_dec() for (nagg= 0; nagg < ncases/2 ; nagg++) agg[nagg+1]= args[nagg*2]; nagg++; - agg_cmp_type(current_thd, &cmp_type, agg, nagg); + if (agg_cmp_type(current_thd, &cmp_type, agg, nagg)) + return; if ((cmp_type == STRING_RESULT) && agg_arg_charsets(cmp_collation, agg, nagg, MY_COLL_CMP_CONV)) return; @@ -1944,7 +2097,8 @@ void Item_func_in::fix_length_and_dec() uint const_itm= 1; THD *thd= current_thd; - agg_cmp_type(thd, &cmp_type, args, arg_count); + if (agg_cmp_type(thd, &cmp_type, args, arg_count)) + return; if (cmp_type == STRING_RESULT && agg_arg_charsets(cmp_collation, args, arg_count, MY_COLL_CMP_CONV)) @@ -2139,6 +2293,7 @@ Item_cond::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) and_tables_cache&= tmp_table_map; const_item_cache&= item->const_item(); with_sum_func= with_sum_func || item->with_sum_func; + with_subselect|= item->with_subselect; if (item->maybe_null) maybe_null=1; } @@ -2351,7 +2506,7 @@ longlong Item_func_isnull::val_int() Handle optimization if the argument can't be null This has to be here because of the test in update_used_tables(). */ - if (!used_tables_cache) + if (!used_tables_cache && !with_subselect) return cached_value; return args[0]->is_null() ? 1: 0; } @@ -2360,7 +2515,7 @@ longlong Item_is_not_null_test::val_int() { DBUG_ASSERT(fixed == 1); DBUG_ENTER("Item_is_not_null_test::val_int"); - if (!used_tables_cache) + if (!used_tables_cache && !with_subselect) { owner->was_null|= (!cached_value); DBUG_PRINT("info", ("cached :%d", cached_value)); @@ -2387,7 +2542,7 @@ void Item_is_not_null_test::update_used_tables() else { args[0]->update_used_tables(); - if (!(used_tables_cache=args[0]->used_tables())) + if (!(used_tables_cache=args[0]->used_tables()) && !with_subselect) { /* Remember if the value is always NULL or never NULL */ cached_value= (longlong) !args[0]->is_null(); diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 0e157fd412c..7dbbdc7a63b 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -33,6 +33,7 @@ class Arg_comparator: public Sql_alloc arg_cmp_func func; Item_bool_func2 *owner; Arg_comparator *comparators; // used only for compare_row() + double precision; public: DTCollation cmp_collation; @@ -77,6 +78,8 @@ public: int compare_e_int(); // compare args[0] & args[1] int compare_e_int_diff_signedness(); int compare_e_row(); // compare args[0] & args[1] + int compare_real_fixed(); + int compare_e_real_fixed(); static arg_cmp_func comparator_matrix [4][2]; @@ -203,10 +206,11 @@ class Item_bool_func2 :public Item_int_func protected: Arg_comparator cmp; String tmp_value1,tmp_value2; + bool abort_on_null; public: Item_bool_func2(Item *a,Item *b) - :Item_int_func(a,b), cmp(tmp_arg, tmp_arg+1) {} + :Item_int_func(a,b), cmp(tmp_arg, tmp_arg+1), abort_on_null(FALSE) {} void fix_length_and_dec(); void set_cmp_func() { @@ -219,6 +223,7 @@ public: bool is_null() { return test(args[0]->is_null() || args[1]->is_null()); } bool is_bool_func() { return 1; } CHARSET_INFO *compare_collation() { return cmp.cmp_collation.collation; } + void top_level_item() { abort_on_null= TRUE; } friend class Arg_comparator; }; @@ -402,6 +407,7 @@ public: negated= !negated; return this; } + bool eq(const Item *item, bool binary_cmp) const; }; @@ -843,7 +849,8 @@ public: else { args[0]->update_used_tables(); - if ((const_item_cache= !(used_tables_cache= args[0]->used_tables()))) + if ((const_item_cache= !(used_tables_cache= args[0]->used_tables())) && + !with_subselect) { /* Remember if the value is always NULL or never NULL */ cached_value= (longlong) args[0]->is_null(); diff --git a/sql/item_func.cc b/sql/item_func.cc index 117ae19137b..12bb6571369 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -177,6 +177,7 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) used_tables_cache|= item->used_tables(); not_null_tables_cache|= item->not_null_tables(); const_item_cache&= item->const_item(); + with_subselect|= item->with_subselect; } } fix_length_and_dec(); @@ -476,7 +477,8 @@ longlong Item_func_signed::val_int() longlong value; int error; - if (args[0]->cast_to_int_type() != STRING_RESULT) + if (args[0]->cast_to_int_type() != STRING_RESULT || + args[0]->result_as_longlong()) { value= args[0]->val_int(); null_value= args[0]->null_value; @@ -528,7 +530,8 @@ longlong Item_func_unsigned::val_int() return (longlong) (dvalue + (dvalue > 0 ? 0.5 : -0.5)); } - if (args[0]->cast_to_int_type() != STRING_RESULT) + if (args[0]->cast_to_int_type() != STRING_RESULT || + args[0]->result_as_longlong()) { value= args[0]->val_int(); null_value= args[0]->null_value; @@ -2239,7 +2242,11 @@ longlong Item_func_release_lock::val_int() } else { +#ifdef EMBEDDED_LIBRARY + if (ull->locked && pthread_equal(current_thd->real_id,ull->thread)) +#else if (ull->locked && pthread_equal(pthread_self(),ull->thread)) +#endif { result=1; // Release is ok item_user_lock_release(ull); @@ -2469,8 +2476,9 @@ bool Item_func_set_user_var::update_hash(void *ptr, uint length, char *pos= (char*) entry+ ALIGN_SIZE(sizeof(user_var_entry)); if (entry->value == pos) entry->value=0; - if (!(entry->value=(char*) my_realloc(entry->value, length, - MYF(MY_ALLOW_ZERO_PTR)))) + entry->value= (char*) my_realloc(entry->value, length, + MYF(MY_ALLOW_ZERO_PTR | MY_WME)); + if (!entry->value) goto err; } } @@ -3152,7 +3160,7 @@ bool Item_func_match::fix_index() for (keynr=0 ; keynr < table->keys ; keynr++) { if ((table->key_info[keynr].flags & HA_FULLTEXT) && - (table->keys_in_use_for_query.is_set(keynr))) + (table->keys_in_use.is_set(keynr))) { ft_to_key[fts]=keynr; ft_cnt[fts]=0; @@ -3243,7 +3251,7 @@ double Item_func_match::val() if (ft_handler == NULL) DBUG_RETURN(-1.0); - if (table->null_row) /* NULL row from an outer join */ + if (key != NO_SUCH_KEY && table->null_row) /* NULL row from an outer join */ return 0.0; if (join_key) diff --git a/sql/item_func.h b/sql/item_func.h index 467b88eda76..ebe3a589aa1 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -590,6 +590,31 @@ public: }; +/* + Objects of this class are used for ROLLUP queries to wrap up + each constant item referred to in GROUP BY list. +*/ + +class Item_func_rollup_const :public Item_func +{ +public: + Item_func_rollup_const(Item *a) :Item_func(a) + { name= a->name; } + double val() { return args[0]->val(); } + longlong val_int() { return args[0]->val_int(); } + String *val_str(String *str) { return args[0]->val_str(str); } + const char *func_name() const { return "rollup_const"; } + bool const_item() const { return 0; } + Item_result result_type() const { return args[0]->result_type(); } + void fix_length_and_dec() + { + collation= args[0]->collation; + max_length= args[0]->max_length; + decimals=args[0]->decimals; + } +}; + + class Item_func_length :public Item_int_func { String value; diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index 6bd2e65632f..6cb8c790319 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -30,6 +30,7 @@ void Item_geometry_func::fix_length_and_dec() collation.set(&my_charset_bin); decimals=0; max_length=MAX_BLOB_WIDTH; + maybe_null= 1; } @@ -109,6 +110,7 @@ String *Item_func_as_wkt::val_str(String *str) void Item_func_as_wkt::fix_length_and_dec() { max_length=MAX_BLOB_WIDTH; + maybe_null= 1; } @@ -356,7 +358,8 @@ String *Item_func_spatial_collection::val_str(String *str) for (i= 0; i < arg_count; ++i) { String *res= args[i]->val_str(&arg_value); - if (args[i]->null_value) + uint32 len; + if (args[i]->null_value || ((len= res->length()) < WKB_HEADER_SIZE)) goto err; if (coll_type == Geometry::wkb_geometrycollection) @@ -365,13 +368,12 @@ String *Item_func_spatial_collection::val_str(String *str) In the case of GeometryCollection we don't need any checkings for item types, so just copy them into target collection */ - if (str->append(res->ptr(), res->length(), (uint32) 512)) + if (str->append(res->ptr(), len, (uint32) 512)) goto err; } else { enum Geometry::wkbType wkb_type; - uint32 len=res->length(); const char *data= res->ptr() + 1; /* @@ -379,8 +381,6 @@ String *Item_func_spatial_collection::val_str(String *str) are of specific type, let's do this checking now */ - if (len < 5) - goto err; wkb_type= (Geometry::wkbType) uint4korr(data); data+= 4; len-= 5; @@ -502,9 +502,13 @@ longlong Item_func_spatial_rel::val_int() longlong Item_func_isempty::val_int() { DBUG_ASSERT(fixed == 1); - String tmp; - null_value=0; - return args[0]->null_value ? 1 : 0; + String tmp; + String *swkb= args[0]->val_str(&tmp); + Geometry_buffer buffer; + + null_value= args[0]->null_value || + !(Geometry::construct(&buffer, swkb->ptr(), swkb->length())); + return null_value ? 1 : 0; } @@ -512,10 +516,11 @@ longlong Item_func_issimple::val_int() { DBUG_ASSERT(fixed == 1); String tmp; - String *wkb=args[0]->val_str(&tmp); - - if ((null_value= (!wkb || args[0]->null_value))) - return 0; + String *swkb= args[0]->val_str(&tmp); + Geometry_buffer buffer; + + null_value= args[0]->null_value || + !(Geometry::construct(&buffer, swkb->ptr(), swkb->length())); /* TODO: Ramil or Holyfoot, add real IsSimple calculation */ return 0; } diff --git a/sql/item_geofunc.h b/sql/item_geofunc.h index a466b606dc1..2719cbb0bab 100644 --- a/sql/item_geofunc.h +++ b/sql/item_geofunc.h @@ -33,6 +33,7 @@ public: Item_geometry_func(List<Item> &list) :Item_str_func(list) {} void fix_length_and_dec(); enum_field_types field_type() const { return MYSQL_TYPE_GEOMETRY; } + bool is_null() { (void) val_int(); return null_value; } }; class Item_func_geometry_from_text: public Item_geometry_func @@ -80,6 +81,7 @@ public: void fix_length_and_dec() { max_length=20; // "GeometryCollection" is the most long + maybe_null= 1; }; }; @@ -221,6 +223,8 @@ public: } } void print(String *str) { Item_func::print(str); } + void fix_length_and_dec() { maybe_null= 1; } + bool is_null() { (void) val_int(); return null_value; } }; class Item_func_isempty: public Item_bool_func @@ -230,6 +234,7 @@ public: longlong val_int(); optimize_type select_optimize() const { return OPTIMIZE_NONE; } const char *func_name() const { return "isempty"; } + void fix_length_and_dec() { maybe_null= 1; } }; class Item_func_issimple: public Item_bool_func @@ -239,6 +244,7 @@ public: longlong val_int(); optimize_type select_optimize() const { return OPTIMIZE_NONE; } const char *func_name() const { return "issimple"; } + void fix_length_and_dec() { maybe_null= 1; } }; class Item_func_isclosed: public Item_bool_func @@ -248,6 +254,7 @@ public: longlong val_int(); optimize_type select_optimize() const { return OPTIMIZE_NONE; } const char *func_name() const { return "isclosed"; } + void fix_length_and_dec() { maybe_null= 1; } }; class Item_func_dimension: public Item_int_func @@ -257,7 +264,7 @@ public: Item_func_dimension(Item *a): Item_int_func(a) {} longlong val_int(); const char *func_name() const { return "dimension"; } - void fix_length_and_dec() { max_length=10; } + void fix_length_and_dec() { max_length= 10; maybe_null= 1; } }; class Item_func_x: public Item_real_func @@ -267,6 +274,11 @@ public: Item_func_x(Item *a): Item_real_func(a) {} double val(); const char *func_name() const { return "x"; } + void fix_length_and_dec() + { + Item_real_func::fix_length_and_dec(); + maybe_null= 1; + } }; @@ -277,6 +289,11 @@ public: Item_func_y(Item *a): Item_real_func(a) {} double val(); const char *func_name() const { return "y"; } + void fix_length_and_dec() + { + Item_real_func::fix_length_and_dec(); + maybe_null= 1; + } }; @@ -287,7 +304,7 @@ public: Item_func_numgeometries(Item *a): Item_int_func(a) {} longlong val_int(); const char *func_name() const { return "numgeometries"; } - void fix_length_and_dec() { max_length=10; } + void fix_length_and_dec() { max_length= 10; maybe_null= 1; } }; @@ -298,7 +315,7 @@ public: Item_func_numinteriorring(Item *a): Item_int_func(a) {} longlong val_int(); const char *func_name() const { return "numinteriorrings"; } - void fix_length_and_dec() { max_length=10; } + void fix_length_and_dec() { max_length= 10; maybe_null= 1; } }; @@ -309,7 +326,7 @@ public: Item_func_numpoints(Item *a): Item_int_func(a) {} longlong val_int(); const char *func_name() const { return "numpoints"; } - void fix_length_and_dec() { max_length=10; } + void fix_length_and_dec() { max_length= 10; maybe_null= 1; } }; @@ -320,6 +337,11 @@ public: Item_func_area(Item *a): Item_real_func(a) {} double val(); const char *func_name() const { return "area"; } + void fix_length_and_dec() + { + Item_real_func::fix_length_and_dec(); + maybe_null= 1; + } }; @@ -330,6 +352,11 @@ public: Item_func_glength(Item *a): Item_real_func(a) {} double val(); const char *func_name() const { return "glength"; } + void fix_length_and_dec() + { + Item_real_func::fix_length_and_dec(); + maybe_null= 1; + } }; @@ -340,7 +367,7 @@ public: Item_func_srid(Item *a): Item_int_func(a) {} longlong val_int(); const char *func_name() const { return "srid"; } - void fix_length_and_dec() { max_length= 10; } + void fix_length_and_dec() { max_length= 10; maybe_null= 1; } }; #define GEOM_NEW(obj_constructor) new obj_constructor diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index f7408cb5e9f..7c98f0c6380 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1583,6 +1583,19 @@ String *Item_func_encode::val_str(String *str) return res; } +void Item_func_encode::print(String *str) +{ + str->append(func_name()); + str->append('('); + args[0]->print(str); + str->append(','); + str->append('\''); + str->append(seed); + str->append('\''); + str->append(')'); +} + + String *Item_func_decode::val_str(String *str) { DBUG_ASSERT(fixed == 1); diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index b7cecad9516..4bd8574ff04 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -343,19 +343,24 @@ class Item_func_encode :public Item_str_func { protected: SQL_CRYPT sql_crypt; + String seed; public: - Item_func_encode(Item *a, char *seed): - Item_str_func(a),sql_crypt(seed) {} + Item_func_encode(Item *a, char *seed_arg): + Item_str_func(a), sql_crypt(seed_arg) + { + seed.copy(seed_arg, strlen(seed_arg), default_charset_info); + } String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "encode"; } + void print(String *str); }; class Item_func_decode :public Item_func_encode { public: - Item_func_decode(Item *a, char *seed): Item_func_encode(a,seed) {} + Item_func_decode(Item *a, char *seed_arg): Item_func_encode(a, seed_arg) {} String *val_str(String *); const char *func_name() const { return "decode"; } }; diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index cd1f8f83821..cdbcde8b56b 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -39,6 +39,7 @@ Item_subselect::Item_subselect(): engine(0), old_engine(0), used_tables_cache(0), have_to_be_excluded(0), const_item_cache(1), engine_changed(0), changed(0) { + with_subselect= 1; reset(); /* item value is NULL if select_subselect not changed this value @@ -201,6 +202,9 @@ bool Item_subselect::exec() mem root */ thd->mem_root= &thd->main_mem_root; + if (thd->net.report_error) + /* Do not execute subselect in case of a fatal error */ + return 1; res= engine->exec(); thd->mem_root= old_root; @@ -350,6 +354,7 @@ Item_singlerow_subselect::select_transformer(JOIN *join) */ !(select_lex->item_list.head()->type() == FIELD_ITEM || select_lex->item_list.head()->type() == REF_ITEM) && + !join->conds && !join->having && /* switch off this optimisation for prepare statement, because we do not rollback this changes @@ -374,8 +379,6 @@ Item_singlerow_subselect::select_transformer(JOIN *join) */ substitution->walk(&Item::remove_dependence_processor, (byte *) select_lex->outer_select()); - /* SELECT without FROM clause can't have WHERE or HAVING clause */ - DBUG_ASSERT(join->conds == 0 && join->having == 0); return RES_REDUCE; } return RES_OK; @@ -1796,6 +1799,22 @@ bool subselect_single_select_engine::no_tables() /* + Check statically whether the subquery can return NULL + + SINOPSYS + subselect_single_select_engine::may_be_null() + + RETURN + FALSE can guarantee that the subquery never return NULL + TRUE otherwise +*/ +bool subselect_single_select_engine::may_be_null() +{ + return ((no_tables() && !join->conds && !join->having) ? maybe_null : 1); +} + + +/* Report about presence of tables in subquery SINOPSYS diff --git a/sql/item_subselect.h b/sql/item_subselect.h index 7b064bfe92c..539dcc5676a 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -301,7 +301,7 @@ public: enum Item_result type() { return res_type; } enum_field_types field_type() { return res_field_type; } virtual void exclude()= 0; - bool may_be_null() { return maybe_null; }; + virtual bool may_be_null() { return maybe_null; }; virtual table_map upper_select_const_tables()= 0; static table_map calc_const_tables(TABLE_LIST *); virtual void print(String *str)= 0; @@ -335,6 +335,7 @@ public: void print (String *str); int change_item(Item_subselect *si, select_subselect *result); bool no_tables(); + bool may_be_null(); }; diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index d6465406c68..4bd3d68b9c1 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -595,16 +595,10 @@ bool make_date_time(DATE_TIME_FORMAT *format, TIME *l_time, uint weekday; ulong length; const char *ptr, *end; - MY_LOCALE *locale; THD *thd= current_thd; - char buf[128]; - String tmp(buf, sizeof(buf), thd->variables.character_set_results); - uint errors= 0; + MY_LOCALE *locale= thd->variables.lc_time_names; - tmp.length(0); str->length(0); - str->set_charset(&my_charset_bin); - locale = thd->variables.lc_time_names; if (l_time->neg) str->append("-", 1); @@ -618,41 +612,37 @@ bool make_date_time(DATE_TIME_FORMAT *format, TIME *l_time, { switch (*++ptr) { case 'M': - if (!l_time->month) - return 1; - tmp.copy(locale->month_names->type_names[l_time->month-1], - strlen(locale->month_names->type_names[l_time->month-1]), - system_charset_info, tmp.charset(), &errors); - str->append(tmp.ptr(), tmp.length()); - break; + if (!l_time->month) + return 1; + str->append(locale->month_names->type_names[l_time->month-1], + strlen(locale->month_names->type_names[l_time->month-1]), + system_charset_info); + break; case 'b': - if (!l_time->month) - return 1; - tmp.copy(locale->ab_month_names->type_names[l_time->month-1], - strlen(locale->ab_month_names->type_names[l_time->month-1]), - system_charset_info, tmp.charset(), &errors); - str->append(tmp.ptr(), tmp.length()); - break; + if (!l_time->month) + return 1; + str->append(locale->ab_month_names->type_names[l_time->month-1], + strlen(locale->ab_month_names->type_names[l_time->month-1]), + system_charset_info); + break; case 'W': - if (type == MYSQL_TIMESTAMP_TIME) - return 1; - weekday= calc_weekday(calc_daynr(l_time->year,l_time->month, - l_time->day),0); - tmp.copy(locale->day_names->type_names[weekday], - strlen(locale->day_names->type_names[weekday]), - system_charset_info, tmp.charset(), &errors); - str->append(tmp.ptr(), tmp.length()); - break; + if (type == MYSQL_TIMESTAMP_TIME) + return 1; + weekday= calc_weekday(calc_daynr(l_time->year,l_time->month, + l_time->day),0); + str->append(locale->day_names->type_names[weekday], + strlen(locale->day_names->type_names[weekday]), + system_charset_info); + break; case 'a': - if (type == MYSQL_TIMESTAMP_TIME) - return 1; - weekday=calc_weekday(calc_daynr(l_time->year,l_time->month, - l_time->day),0); - tmp.copy(locale->ab_day_names->type_names[weekday], - strlen(locale->ab_day_names->type_names[weekday]), - system_charset_info, tmp.charset(), &errors); - str->append(tmp.ptr(), tmp.length()); - break; + if (type == MYSQL_TIMESTAMP_TIME) + return 1; + weekday=calc_weekday(calc_daynr(l_time->year,l_time->month, + l_time->day),0); + str->append(locale->ab_day_names->type_names[weekday], + strlen(locale->ab_day_names->type_names[weekday]), + system_charset_info); + break; case 'D': if (type == MYSQL_TIMESTAMP_TIME) return 1; @@ -1638,8 +1628,9 @@ longlong Item_func_sec_to_time::val_int() void Item_func_date_format::fix_length_and_dec() { + THD* thd= current_thd; decimals=0; - collation.set(&my_charset_bin); + collation.set(thd->variables.collation_connection); if (args[1]->type() == STRING_ITEM) { // Optimize the normal case fixed_length=1; @@ -1653,17 +1644,14 @@ void Item_func_date_format::fix_length_and_dec() args[1]->collation.set( get_charset_by_csname(args[1]->collation.collation->csname, MY_CS_BINSORT,MYF(0)), DERIVATION_COERCIBLE); - /* - The result is a binary string (no reason to use collation->mbmaxlen - This is becasue make_date_time() only returns binary strings - */ - max_length= format_length(((Item_string*) args[1])->const_string()); + max_length= format_length(((Item_string*) args[1])->const_string()) * + collation.collation->mbmaxlen; } else { fixed_length=0; - /* The result is a binary string (no reason to use collation->mbmaxlen */ - max_length=min(args[1]->max_length,MAX_BLOB_WIDTH) * 10; + max_length= min(args[1]->max_length,MAX_BLOB_WIDTH) * 10 * + collation.collation->mbmaxlen; set_if_smaller(max_length,MAX_BLOB_WIDTH); } maybe_null=1; // If wrong date @@ -1783,6 +1771,7 @@ String *Item_func_date_format::val_str(String *str) date_time_format.format.length= format->length(); /* Create the result string */ + str->set_charset(collation.collation); if (!make_date_time(&date_time_format, &l_time, is_time_format ? MYSQL_TIMESTAMP_TIME : MYSQL_TIMESTAMP_DATE, @@ -2502,7 +2491,10 @@ longlong Item_date_typecast::val_int() DBUG_ASSERT(fixed == 1); TIME ltime; if (args[0]->get_date(<ime, TIME_FUZZY_DATE)) + { + null_value= 1; return 0; + } return (longlong) (ltime.year * 10000L + ltime.month * 100 + ltime.day); } diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 45cad627c05..2383b4f86ac 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -751,12 +751,19 @@ public: String *val_str(String *str); const char *cast_type() const { return "datetime"; } enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; } + void fix_length_and_dec() + { + Item_typecast_maybe_null::fix_length_and_dec(); + decimals= DATETIME_DEC; + } + Field *tmp_table_field(TABLE *t_arg) { return (new Field_datetime(maybe_null, name, t_arg, &my_charset_bin)); } bool result_as_longlong() { return TRUE; } longlong val_int(); + double val() { return (double) val_int(); } }; class Item_func_makedate :public Item_str_func diff --git a/sql/key.cc b/sql/key.cc index 7ddd40de2c9..5bb389fcb45 100644 --- a/sql/key.cc +++ b/sql/key.cc @@ -89,20 +89,21 @@ void key_copy(byte *key,TABLE *table,uint idx,uint key_length) } if (key_part->key_part_flag & HA_BLOB_PART) { - char *pos; - ulong blob_length=((Field_blob*) key_part->field)->get_length(); - key_length-=2; - ((Field_blob*) key_part->field)->get_ptr(&pos); - length=min(key_length,key_part->length); - set_if_smaller(blob_length,length); - int2store(key,(uint) blob_length); - key+=2; // Skip length info - memcpy(key,pos,blob_length); + key_length-= HA_KEY_BLOB_LENGTH; + length= min(key_length, key_part->length); + key_part->field->get_key_image((char *) key, length, + key_part->field->charset(), + Field::itRAW); + key+= HA_KEY_BLOB_LENGTH; } else { - length=min(key_length,key_part->length); - memcpy(key,table->record[0]+key_part->offset,(size_t) length); + length= min(key_length, key_part->length); + Field *field= key_part->field; + CHARSET_INFO *cs= field->charset(); + uint bytes= field->get_key_image((char *) key, length, cs, Field::itRAW); + if (bytes < length) + cs->cset->fill(cs, (char *) key + bytes, length - bytes, ' '); } key+=length; key_length-=length; diff --git a/sql/log.cc b/sql/log.cc index 7e97bfd0712..b91ec2b3dee 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1350,6 +1350,21 @@ COLLATION_CONNECTION=%u,COLLATION_DATABASE=%u,COLLATION_SERVER=%u", if (e.write(file)) goto err; } + /* + Use the same ONE_SHOT trick for making replication of lc_time_names. + */ + if (thd->variables.lc_time_names->number) // Not en_US + { + char buf[32]; + uint length= my_snprintf(buf, sizeof(buf), + "SET ONE_SHOT LC_TIME_NAMES=%u", + (uint) thd->variables.lc_time_names->number); + Query_log_event e(thd, buf, length, 0, FALSE); + e.set_log_pos(this); + e.error_code= 0; // This statement cannot fail (see [1]). + if (e.write(file)) + goto err; + } #endif if (thd->last_insert_id_used) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 8d6cdebe1f7..6bd60280399 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -59,6 +59,8 @@ void kill_one_thread(THD *thd, ulong id); bool net_request_file(NET* net, const char* fname); char* query_table_status(THD *thd,const char *db,const char *table_name); +void net_set_write_timeout(NET *net, uint timeout); +void net_set_read_timeout(NET *net, uint timeout); #define x_free(A) { my_free((gptr) (A),MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR)); } #define safeFree(x) { if(x) { my_free((gptr) x,MYF(0)); x = NULL; } } @@ -71,6 +73,7 @@ extern CHARSET_INFO *national_charset_info, *table_alias_charset; typedef struct my_locale_st { + uint number; const char *name; const char *description; const bool is_ascii; @@ -84,6 +87,7 @@ extern MY_LOCALE my_locale_en_US; extern MY_LOCALE *my_locales[]; MY_LOCALE *my_locale_by_name(const char *name); +MY_LOCALE *my_locale_by_number(uint number); /*************************************************************************** Configuration parameters @@ -422,6 +426,7 @@ struct Query_cache_query_flags ulong sql_mode; ulong max_sort_length; ulong group_concat_max_len; + ulong default_week_format; MY_LOCALE *lc_time_names; }; #define QUERY_CACHE_FLAGS_SIZE sizeof(Query_cache_query_flags) @@ -563,25 +568,22 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, uint &key_count, int select_field_count); int mysql_create_table(THD *thd,const char *db, const char *table_name, HA_CREATE_INFO *create_info, - List<create_field> &fields, List<Key> &keys, + Alter_info *alter_info, bool tmp_table, uint select_field_count); TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, const char *db, const char *name, - List<create_field> *extra_fields, - List<Key> *keys, + Alter_info *alter_info, List<Item> *items, MYSQL_LOCK **lock); int mysql_alter_table(THD *thd, char *new_db, char *new_name, HA_CREATE_INFO *create_info, TABLE_LIST *table_list, - List<create_field> &fields, - List<Key> &keys, + Alter_info *alter_info, uint order_num, ORDER *order, enum enum_duplicates handle_duplicates, - bool ignore, - ALTER_INFO *alter_info, bool do_send_ok=1); -int mysql_recreate_table(THD *thd, TABLE_LIST *table_list, bool do_send_ok); + bool ignore); +int mysql_recreate_table(THD *thd, TABLE_LIST *table_list); int mysql_create_like_table(THD *thd, TABLE_LIST *table, HA_CREATE_INFO *create_info, Table_ident *src_table); @@ -590,9 +592,6 @@ bool mysql_rename_table(enum db_type base, const char * old_name, const char *new_db, const char * new_name); -int mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys); -int mysql_drop_index(THD *thd, TABLE_LIST *table_list, - ALTER_INFO *alter_info); int mysql_prepare_update(THD *thd, TABLE_LIST *table_list, TABLE_LIST *update_table_list, Item **conds, uint order_num, ORDER *order); @@ -679,7 +678,8 @@ int get_quote_char_for_identifier(THD *thd, const char *name, uint length); void mysqld_list_fields(THD *thd,TABLE_LIST *table, const char *wild); int mysqld_dump_create_info(THD *thd, TABLE *table, int fd = -1); int mysqld_show_create(THD *thd, TABLE_LIST *table_list); -int mysqld_show_create_db(THD *thd, char *dbname, HA_CREATE_INFO *create); +int mysqld_show_create_db(THD *thd, char *dbname, + const HA_CREATE_INFO *create); void mysqld_list_processes(THD *thd,const char *user,bool verbose); int mysqld_show_status(THD *thd); @@ -861,6 +861,7 @@ bool open_log(MYSQL_LOG *log, const char *hostname, /* mysqld.cc */ extern void yyerror(const char*); +my_bool mysql_rm_tmp_tables(void); /* item_func.cc */ extern bool check_reserved_words(LEX_STRING *name); @@ -909,6 +910,7 @@ extern char glob_hostname[FN_REFLEN], mysql_home[FN_REFLEN]; extern char pidfile_name[FN_REFLEN], system_time_zone[30], *opt_init_file; extern char log_error_file[FN_REFLEN]; extern double log_10[32]; +extern double log_01[32]; extern ulonglong log_10_int[20]; extern ulonglong keybuff_size; extern ulong refresh_version,flush_version, thread_id,query_id,opened_tables; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index cd0ddc00624..51332053df6 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -210,12 +210,6 @@ inline void reset_floating_point_exceptions() } /* cplusplus */ - -#if defined(HAVE_LINUXTHREADS) -#define THR_KILL_SIGNAL SIGINT -#else -#define THR_KILL_SIGNAL SIGUSR2 // Can't use this with LinuxThreads -#endif #define MYSQL_KILL_SIGNAL SIGTERM #ifdef HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R @@ -361,6 +355,7 @@ ulong my_bind_addr; /* the address we bind to */ volatile ulong cached_thread_count= 0; double log_10[32]; /* 10 potences */ +double log_01[32]; time_t start_time; char mysql_home[FN_REFLEN], pidfile_name[FN_REFLEN], system_time_zone[30]; @@ -456,6 +451,7 @@ pthread_cond_t COND_refresh,COND_thread_count, COND_slave_stopped, pthread_cond_t COND_thread_cache,COND_flush_thread_cache; pthread_t signal_thread; pthread_attr_t connection_attrib; +static uint thr_kill_signal; /* replication parameters, if master_host is not NULL, we are a slave */ uint master_port= MYSQL_PORT, master_connect_retry = 60; @@ -626,7 +622,7 @@ static void close_connections(void) DBUG_PRINT("info",("Waiting for select thread")); #ifndef DONT_USE_THR_ALARM - if (pthread_kill(select_thread,THR_CLIENT_ALARM)) + if (pthread_kill(select_thread, thr_client_alarm)) break; // allready dead #endif set_timespec(abstime, 2); @@ -1074,7 +1070,10 @@ void clean_up(bool print_message) #endif #ifdef HAVE_OPENSSL if (ssl_acceptor_fd) + { + SSL_CTX_free(ssl_acceptor_fd->ssl_context); my_free((gptr) ssl_acceptor_fd, MYF(MY_ALLOW_ZERO_PTR)); + } #endif /* HAVE_OPENSSL */ #ifdef USE_REGEX my_regex_end(); @@ -1573,6 +1572,12 @@ void end_thread(THD *thd, bool put_in_cache) thd=thread_cache.get(); thd->real_id=pthread_self(); (void) thd->store_globals(); + /* + THD::mysys_var::abort is associated with physical thread rather + than with THD object. So we need to reset this flag before using + this thread for handling of new THD object/connection. + */ + thd->mysys_var->abort= 0; thd->thr_create_time= time(NULL); threads.append(thd); pthread_mutex_unlock(&LOCK_thread_count); @@ -1934,7 +1939,10 @@ static void check_data_home(const char *path) extern "C" sig_handler handle_segfault(int sig) { + time_t curr_time; + struct tm tm; THD *thd=current_thd; + /* Strictly speaking, one needs a mutex here but since we have got SIGSEGV already, things are a mess @@ -1948,11 +1956,17 @@ extern "C" sig_handler handle_segfault(int sig) } segfaulted = 1; + + curr_time= time(NULL); + localtime_r(&curr_time, &tm); + fprintf(stderr,"\ -mysqld got signal %d;\n\ +%02d%02d%02d %2d:%02d:%02d - mysqld got signal %d;\n\ This could be because you hit a bug. It is also possible that this binary\n\ or one of the libraries it was linked against is corrupt, improperly built,\n\ or misconfigured. This error can also be caused by malfunctioning hardware.\n", + tm.tm_year % 100, tm.tm_mon+1, tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec, sig); fprintf(stderr, "\ We will try our best to scrape up some info that will hopefully help diagnose\n\ @@ -2049,7 +2063,9 @@ static void init_signals(void) DBUG_ENTER("init_signals"); if (test_flags & TEST_SIGINT) - my_sigset(THR_KILL_SIGNAL,end_thread_signal); + { + my_sigset(thr_kill_signal, end_thread_signal); + } my_sigset(THR_SERVER_ALARM,print_signal_warning); // Should never be called! if (!(test_flags & TEST_NO_STACKTRACE) || (test_flags & TEST_CORE_ON_SIGNAL)) @@ -2104,10 +2120,13 @@ static void init_signals(void) #ifdef SIGTSTP sigaddset(&set,SIGTSTP); #endif - sigaddset(&set,THR_SERVER_ALARM); + if (thd_lib_detected != THD_LIB_LT) + sigaddset(&set,THR_SERVER_ALARM); if (test_flags & TEST_SIGINT) - sigdelset(&set,THR_KILL_SIGNAL); // May be SIGINT - sigdelset(&set,THR_CLIENT_ALARM); // For alarms + { + // May be SIGINT + sigdelset(&set, thr_kill_signal); + } sigprocmask(SIG_SETMASK,&set,NULL); pthread_sigmask(SIG_SETMASK,&set,NULL); DBUG_VOID_RETURN; @@ -2163,24 +2182,20 @@ extern "C" void *signal_hand(void *arg __attribute__((unused))) */ init_thr_alarm(max_connections + global_system_variables.max_insert_delayed_threads + 10); -#if SIGINT != THR_KILL_SIGNAL - if (test_flags & TEST_SIGINT) + if (thd_lib_detected != THD_LIB_LT && (test_flags & TEST_SIGINT)) { (void) sigemptyset(&set); // Setup up SIGINT for debug (void) sigaddset(&set,SIGINT); // For debugging (void) pthread_sigmask(SIG_UNBLOCK,&set,NULL); } -#endif (void) sigemptyset(&set); // Setup up SIGINT for debug #ifdef USE_ONE_SIGNAL_HAND (void) sigaddset(&set,THR_SERVER_ALARM); // For alarms #endif #ifndef IGNORE_SIGHUP_SIGQUIT (void) sigaddset(&set,SIGQUIT); -#if THR_CLIENT_ALARM != SIGHUP (void) sigaddset(&set,SIGHUP); #endif -#endif (void) sigaddset(&set,SIGTERM); (void) sigaddset(&set,SIGTSTP); @@ -3140,6 +3155,13 @@ int main(int argc, char **argv) MY_INIT(argv[0]); // init my_sys library & pthreads + /* Set signal used to kill MySQL */ +#if defined(SIGUSR2) + thr_kill_signal= thd_lib_detected == THD_LIB_LT ? SIGINT : SIGUSR2; +#else + thr_kill_signal= SIGINT; +#endif + #ifdef _CUSTOMSTARTUPCONFIG_ if (_cust_check_startup()) { @@ -3241,7 +3263,7 @@ we force server id to 2, but this MySQL server will not act as a slave."); */ error_handler_hook = my_message_sql; start_signal_handler(); // Creates pidfile - if (acl_init(opt_noacl) || + if (mysql_rm_tmp_tables() || acl_init(opt_noacl) || my_tz_init((THD *)0, default_tz_name, opt_bootstrap)) { abort_loop=1; @@ -3601,10 +3623,9 @@ static bool read_init_file(char *file_name) #ifndef EMBEDDED_LIBRARY static void create_new_thread(THD *thd) { + NET *net=&thd->net; DBUG_ENTER("create_new_thread"); - NET *net=&thd->net; // For easy ref - net->read_timeout = (uint) connect_timeout; if (protocol_version > 9) net->return_errno=1; @@ -3899,12 +3920,7 @@ extern "C" pthread_handler_decl(handle_connections_sockets, } if (sock == unix_sock) thd->host=(char*) my_localhost; -#ifdef __WIN__ - /* Set default wait_timeout */ - ulong wait_timeout= global_system_variables.net_wait_timeout * 1000; - (void) setsockopt(new_sock, SOL_SOCKET, SO_RCVTIMEO, (char*)&wait_timeout, - sizeof(wait_timeout)); -#endif + create_new_thread(thd); } diff --git a/sql/net_serv.cc b/sql/net_serv.cc index 08184537896..a5a05d381cd 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -491,7 +491,7 @@ net_real_write(NET *net,const char *packet,ulong len) thr_alarm(&alarmed,(uint) net->write_timeout,&alarm_buff); #else alarmed=0; - vio_timeout(net->vio, 1, net->write_timeout); + /* Write timeout is set in net_set_write_timeout */ #endif /* NO_ALARM */ pos=(char*) packet; end=pos+len; @@ -684,7 +684,7 @@ my_real_read(NET *net, ulong *complen) if (net_blocking) thr_alarm(&alarmed,net->read_timeout,&alarm_buff); #else - vio_timeout(net->vio, 0, net->read_timeout); + /* Read timeout is set in net_set_read_timeout */ #endif /* NO_ALARM */ pos = net->buff + net->where_b; /* net->packet -4 */ @@ -995,3 +995,26 @@ my_net_read(NET *net) return len; } + +void net_set_read_timeout(NET *net, uint timeout) +{ + DBUG_ENTER("net_set_read_timeout"); + DBUG_PRINT("enter", ("timeout: %d", timeout)); + net->read_timeout= timeout; +#ifdef NO_ALARM + vio_timeout(net->vio, 0, timeout); +#endif + DBUG_VOID_RETURN; +} + + +void net_set_write_timeout(NET *net, uint timeout) +{ + DBUG_ENTER("net_set_write_timeout"); + DBUG_PRINT("enter", ("timeout: %d", timeout)); + net->write_timeout= timeout; +#ifdef NO_ALARM + vio_timeout(net->vio, 1, timeout); +#endif + DBUG_VOID_RETURN; +} diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 06e42ff363f..01b366077b0 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -128,6 +128,89 @@ static char is_null_string[2]= {1,0}; - get_quick_select() - Walk the SEL_ARG, materialize the key intervals, and create QUICK_RANGE_SELECT object that will read records within these intervals. + + 4. SPACE COMPLEXITY NOTES + + SEL_ARG graph is a representation of an ordered disjoint sequence of + intervals over the ordered set of index tuple values. + + For multi-part keys, one can construct a WHERE expression such that its + list of intervals will be of combinatorial size. Here is an example: + + (keypart1 IN (1,2, ..., n1)) AND + (keypart2 IN (1,2, ..., n2)) AND + (keypart3 IN (1,2, ..., n3)) + + For this WHERE clause the list of intervals will have n1*n2*n3 intervals + of form + + (keypart1, keypart2, keypart3) = (k1, k2, k3), where 1 <= k{i} <= n{i} + + SEL_ARG graph structure aims to reduce the amount of required space by + "sharing" the elementary intervals when possible (the pic at the + beginning of this comment has examples of such sharing). The sharing may + prevent combinatorial blowup: + + There are WHERE clauses that have combinatorial-size interval lists but + will be represented by a compact SEL_ARG graph. + Example: + (keypartN IN (1,2, ..., n1)) AND + ... + (keypart2 IN (1,2, ..., n2)) AND + (keypart1 IN (1,2, ..., n3)) + + but not in all cases: + + - There are WHERE clauses that do have a compact SEL_ARG-graph + representation but get_mm_tree() and its callees will construct a + graph of combinatorial size. + Example: + (keypart1 IN (1,2, ..., n1)) AND + (keypart2 IN (1,2, ..., n2)) AND + ... + (keypartN IN (1,2, ..., n3)) + + - There are WHERE clauses for which the minimal possible SEL_ARG graph + representation will have combinatorial size. + Example: + By induction: Let's take any interval on some keypart in the middle: + + kp15=c0 + + Then let's AND it with this interval 'structure' from preceding and + following keyparts: + + (kp14=c1 AND kp16=c3) OR keypart14=c2) (*) + + We will obtain this SEL_ARG graph: + + kp14 $ kp15 $ kp16 + $ $ + +---------+ $ +---------+ $ +---------+ + | kp14=c1 |--$-->| kp15=c0 |--$-->| kp16=c3 | + +---------+ $ +---------+ $ +---------+ + | $ $ + +---------+ $ +---------+ $ + | kp14=c2 |--$-->| kp15=c0 | $ + +---------+ $ +---------+ $ + $ $ + + Note that we had to duplicate "kp15=c0" and there was no way to avoid + that. + The induction step: AND the obtained expression with another "wrapping" + expression like (*). + When the process ends because of the limit on max. number of keyparts + we'll have: + + WHERE clause length is O(3*#max_keyparts) + SEL_ARG graph size is O(2^(#max_keyparts/2)) + + (it is also possible to construct a case where instead of 2 in 2^n we + have a bigger constant, e.g. 4, and get a graph with 4^(31/2)= 2^31 + nodes) + + We avoid consuming too much memory by setting a limit on the number of + SEL_ARG object we can construct during one range analysis invocation. */ class SEL_ARG :public Sql_alloc @@ -158,6 +241,8 @@ public: enum leaf_color { BLACK,RED } color; enum Type { IMPOSSIBLE, MAYBE, MAYBE_KEY, KEY_RANGE } type; + enum { MAX_SEL_ARGS = 16000 }; + SEL_ARG() {} SEL_ARG(SEL_ARG &); SEL_ARG(Field *,const char *,const char *); @@ -227,7 +312,8 @@ public: return new SEL_ARG(field, part, min_value, arg->max_value, min_flag, arg->max_flag, maybe_flag | arg->maybe_flag); } - SEL_ARG *clone(SEL_ARG *new_parent,SEL_ARG **next); + SEL_ARG *clone(struct st_qsel_param *param, SEL_ARG *new_parent, + SEL_ARG **next); bool copy_min(SEL_ARG* arg) { // Get overlapping range @@ -365,7 +451,7 @@ public: { return parent->left == this ? &parent->left : &parent->right; } - SEL_ARG *clone_tree(); + SEL_ARG *clone_tree(struct st_qsel_param *param); }; @@ -391,6 +477,8 @@ typedef struct st_qsel_param { max_key[MAX_KEY_LENGTH+MAX_FIELD_WIDTH]; bool quick; // Don't calulate possible keys COND *cond; + /* Number of SEL_ARG objects allocated by SEL_ARG::clone_tree operations */ + uint alloced_sel_args; } PARAM; static SEL_TREE * get_mm_parts(PARAM *param,COND *cond_func,Field *field, @@ -413,8 +501,8 @@ static void print_quick(QUICK_SELECT *quick,const key_map* needed_reg); static SEL_TREE *tree_and(PARAM *param,SEL_TREE *tree1,SEL_TREE *tree2); static SEL_TREE *tree_or(PARAM *param,SEL_TREE *tree1,SEL_TREE *tree2); static SEL_ARG *sel_add(SEL_ARG *key1,SEL_ARG *key2); -static SEL_ARG *key_or(SEL_ARG *key1,SEL_ARG *key2); -static SEL_ARG *key_and(SEL_ARG *key1,SEL_ARG *key2,uint clone_flag); +static SEL_ARG *key_or(PARAM *param, SEL_ARG *key1,SEL_ARG *key2); +static SEL_ARG *key_and(PARAM *param, SEL_ARG *key1,SEL_ARG *key2,uint clone_flag); static bool get_range(SEL_ARG **e1,SEL_ARG **e2,SEL_ARG *root1); static bool get_quick_keys(PARAM *param,QUICK_SELECT *quick,KEY_PART *key, SEL_ARG *key_tree,char *min_key,uint min_key_flag, @@ -424,6 +512,7 @@ static bool eq_tree(SEL_ARG* a,SEL_ARG *b); static SEL_ARG null_element(SEL_ARG::IMPOSSIBLE); static bool null_part_in_key(KEY_PART *key_part, const char *key, uint length); + /*************************************************************************** ** Basic functions for SQL_SELECT and QUICK_SELECT ***************************************************************************/ @@ -568,12 +657,17 @@ SEL_ARG::SEL_ARG(Field *field_,uint8 part_,char *min_value_,char *max_value_, left=right= &null_element; } -SEL_ARG *SEL_ARG::clone(SEL_ARG *new_parent,SEL_ARG **next_arg) +SEL_ARG *SEL_ARG::clone(PARAM *param, SEL_ARG *new_parent, SEL_ARG **next_arg) { SEL_ARG *tmp; + + /* Bail out if we have already generated too many SEL_ARGs */ + if (++param->alloced_sel_args > MAX_SEL_ARGS) + return 0; + if (type != KEY_RANGE) { - if (!(tmp= new SEL_ARG(type))) + if (!(tmp= new (param->mem_root) SEL_ARG(type))) return 0; // out of memory tmp->prev= *next_arg; // Link into next/prev chain (*next_arg)->next=tmp; @@ -581,20 +675,21 @@ SEL_ARG *SEL_ARG::clone(SEL_ARG *new_parent,SEL_ARG **next_arg) } else { - if (!(tmp= new SEL_ARG(field,part, min_value,max_value, - min_flag, max_flag, maybe_flag))) + if (!(tmp= new (param->mem_root) SEL_ARG(field,part, min_value,max_value, + min_flag, max_flag, maybe_flag))) return 0; // OOM tmp->parent=new_parent; tmp->next_key_part=next_key_part; if (left != &null_element) - tmp->left=left->clone(tmp,next_arg); + if (!(tmp->left=left->clone(param, tmp, next_arg))) + return 0; // OOM tmp->prev= *next_arg; // Link into next/prev chain (*next_arg)->next=tmp; (*next_arg)= tmp; if (right != &null_element) - if (!(tmp->right= right->clone(tmp,next_arg))) + if (!(tmp->right= right->clone(param, tmp, next_arg))) return 0; // OOM } increment_use_count(1); @@ -672,11 +767,12 @@ static int sel_cmp(Field *field, char *a,char *b,uint8 a_flag,uint8 b_flag) } -SEL_ARG *SEL_ARG::clone_tree() +SEL_ARG *SEL_ARG::clone_tree(PARAM *param) { SEL_ARG tmp_link,*next_arg,*root; next_arg= &tmp_link; - root= clone((SEL_ARG *) 0, &next_arg); + if (!(root= clone(param, (SEL_ARG *) 0, &next_arg))) + return 0; next_arg->next=0; // Fix last link tmp_link.next->prev=0; // Fix first link if (root) // If not OOM @@ -890,6 +986,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, param.real_keynr[param.keys++]=idx; } param.key_parts_end=key_parts; + param.alloced_sel_args= 0; if ((tree=get_mm_tree(¶m,cond))) { @@ -991,7 +1088,8 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond) while ((item=li++)) { SEL_TREE *new_tree=get_mm_tree(param,item); - if (param->thd->is_fatal_error) + if (param->thd->is_fatal_error || + param->alloced_sel_args > SEL_ARG::MAX_SEL_ARGS) DBUG_RETURN(0); // out of memory tree=tree_and(param,tree,new_tree); if (tree && tree->type == SEL_TREE::IMPOSSIBLE) @@ -1524,7 +1622,7 @@ tree_and(PARAM *param,SEL_TREE *tree1,SEL_TREE *tree2) tree1->type=SEL_TREE::KEY_SMALLER; DBUG_RETURN(tree1); } - + /* Join the trees key per key */ SEL_ARG **key1,**key2,**end; for (key1= tree1->keys,key2= tree2->keys,end=key1+param->keys ; @@ -1537,12 +1635,13 @@ tree_and(PARAM *param,SEL_TREE *tree1,SEL_TREE *tree2) flag|=CLONE_KEY1_MAYBE; if (*key2 && !(*key2)->simple_key()) flag|=CLONE_KEY2_MAYBE; - *key1=key_and(*key1,*key2,flag); + *key1=key_and(param, *key1, *key2, flag); if (*key1 && (*key1)->type == SEL_ARG::IMPOSSIBLE) { tree1->type= SEL_TREE::IMPOSSIBLE; #ifdef EXTRA_DEBUG - (*key1)->test_use_count(*key1); + if (param->alloced_sel_args < SEL_ARG::MAX_SEL_ARGS) + (*key1)->test_use_count(*key1); #endif break; } @@ -1574,12 +1673,13 @@ tree_or(PARAM *param,SEL_TREE *tree1,SEL_TREE *tree2) for (key1= tree1->keys,key2= tree2->keys,end=key1+param->keys ; key1 != end ; key1++,key2++) { - *key1=key_or(*key1,*key2); + *key1= key_or(param, *key1, *key2); if (*key1) { result=tree1; // Added to tree1 #ifdef EXTRA_DEBUG - (*key1)->test_use_count(*key1); + if (param->alloced_sel_args < SEL_ARG::MAX_SEL_ARGS) + (*key1)->test_use_count(*key1); #endif } } @@ -1590,14 +1690,14 @@ tree_or(PARAM *param,SEL_TREE *tree1,SEL_TREE *tree2) /* And key trees where key1->part < key2 -> part */ static SEL_ARG * -and_all_keys(SEL_ARG *key1,SEL_ARG *key2,uint clone_flag) +and_all_keys(PARAM *param, SEL_ARG *key1, SEL_ARG *key2, uint clone_flag) { SEL_ARG *next; ulong use_count=key1->use_count; if (key1->elements != 1) { - key2->use_count+=key1->elements-1; + key2->use_count+=key1->elements-1; //psergey: why we don't count that key1 has n-k-p? key2->increment_use_count((int) key1->elements-1); } if (key1->type == SEL_ARG::MAYBE_KEY) @@ -1609,7 +1709,7 @@ and_all_keys(SEL_ARG *key1,SEL_ARG *key2,uint clone_flag) { if (next->next_key_part) { - SEL_ARG *tmp=key_and(next->next_key_part,key2,clone_flag); + SEL_ARG *tmp= key_and(param, next->next_key_part, key2, clone_flag); if (tmp && tmp->type == SEL_ARG::IMPOSSIBLE) { key1=key1->tree_delete(next); @@ -1618,6 +1718,8 @@ and_all_keys(SEL_ARG *key1,SEL_ARG *key2,uint clone_flag) next->next_key_part=tmp; if (use_count) next->increment_use_count(use_count); + if (param->alloced_sel_args > SEL_ARG::MAX_SEL_ARGS) + break; } else next->next_key_part=key2; @@ -1644,7 +1746,7 @@ and_all_keys(SEL_ARG *key1,SEL_ARG *key2,uint clone_flag) */ static SEL_ARG * -key_and(SEL_ARG *key1, SEL_ARG *key2, uint clone_flag) +key_and(PARAM *param, SEL_ARG *key1, SEL_ARG *key2, uint clone_flag) { if (!key1) return key2; @@ -1660,9 +1762,9 @@ key_and(SEL_ARG *key1, SEL_ARG *key2, uint clone_flag) // key1->part < key2->part key1->use_count--; if (key1->use_count > 0) - if (!(key1= key1->clone_tree())) + if (!(key1= key1->clone_tree(param))) return 0; // OOM - return and_all_keys(key1,key2,clone_flag); + return and_all_keys(param, key1, key2, clone_flag); } if (((clone_flag & CLONE_KEY2_MAYBE) && @@ -1680,14 +1782,14 @@ key_and(SEL_ARG *key1, SEL_ARG *key2, uint clone_flag) if (key1->use_count > 1) { key1->use_count--; - if (!(key1=key1->clone_tree())) + if (!(key1=key1->clone_tree(param))) return 0; // OOM key1->use_count++; } if (key1->type == SEL_ARG::MAYBE_KEY) { // Both are maybe key - key1->next_key_part=key_and(key1->next_key_part,key2->next_key_part, - clone_flag); + key1->next_key_part=key_and(param, key1->next_key_part, + key2->next_key_part, clone_flag); if (key1->next_key_part && key1->next_key_part->type == SEL_ARG::IMPOSSIBLE) return key1; @@ -1698,7 +1800,7 @@ key_and(SEL_ARG *key1, SEL_ARG *key2, uint clone_flag) if (key2->next_key_part) { key1->use_count--; // Incremented in and_all_keys - return and_all_keys(key1,key2,clone_flag); + return and_all_keys(param, key1, key2, clone_flag); } key2->use_count--; // Key2 doesn't have a tree } @@ -1727,7 +1829,8 @@ key_and(SEL_ARG *key1, SEL_ARG *key2, uint clone_flag) } else if (get_range(&e2,&e1,key2)) continue; - SEL_ARG *next=key_and(e1->next_key_part,e2->next_key_part,clone_flag); + SEL_ARG *next=key_and(param, e1->next_key_part, e2->next_key_part, + clone_flag); e1->increment_use_count(1); e2->increment_use_count(1); if (!next || next->type != SEL_ARG::IMPOSSIBLE) @@ -1775,7 +1878,7 @@ get_range(SEL_ARG **e1,SEL_ARG **e2,SEL_ARG *root1) static SEL_ARG * -key_or(SEL_ARG *key1,SEL_ARG *key2) +key_or(PARAM *param, SEL_ARG *key1,SEL_ARG *key2) { if (!key1) { @@ -1823,7 +1926,7 @@ key_or(SEL_ARG *key1,SEL_ARG *key2) { swap_variables(SEL_ARG *,key1,key2); } - if (key1->use_count > 0 || !(key1=key1->clone_tree())) + if (key1->use_count > 0 || !(key1=key1->clone_tree(param))) return 0; // OOM } @@ -1967,7 +2070,7 @@ key_or(SEL_ARG *key1,SEL_ARG *key2) { // tmp.min. <= x <= tmp.max tmp->maybe_flag|= key.maybe_flag; key.increment_use_count(key1->use_count+1); - tmp->next_key_part=key_or(tmp->next_key_part,key.next_key_part); + tmp->next_key_part= key_or(param, tmp->next_key_part, key.next_key_part); if (!cmp) // Key2 is ready break; key.copy_max_to_min(tmp); @@ -1998,7 +2101,7 @@ key_or(SEL_ARG *key1,SEL_ARG *key2) tmp->increment_use_count(key1->use_count+1); /* Increment key count as it may be used for next loop */ key.increment_use_count(1); - new_arg->next_key_part=key_or(tmp->next_key_part,key.next_key_part); + new_arg->next_key_part= key_or(param, tmp->next_key_part, key.next_key_part); key1=key1->insert(new_arg); break; } diff --git a/sql/opt_range.h b/sql/opt_range.h index 4d425604921..4b20d1fe0fe 100644 --- a/sql/opt_range.h +++ b/sql/opt_range.h @@ -90,6 +90,8 @@ public: int init() { key_part_info= head->key_info[index].key_part; + if (file->inited != handler::NONE) + file->ha_index_or_rnd_end(); return error=file->ha_index_init(index); } virtual int get_next(); diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index 412fc0dc037..f912d67fe06 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -68,9 +68,9 @@ static int maxmin_in_range(bool max_fl, Field* field, COND *cond); GROUP BY part. RETURN VALUES - 0 No errors - 1 if all items were resolved - -1 on impossible conditions + 0 no errors + 1 if all items were resolved + HA_ERR_KEY_NOT_FOUND on impossible conditions OR an error number from my_base.h HA_ERR_... if a deadlock or a lock wait timeout happens, for example */ @@ -216,7 +216,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds) if (error) { if (error == HA_ERR_KEY_NOT_FOUND || error == HA_ERR_END_OF_FILE) - return -1; // No rows matching WHERE + return HA_ERR_KEY_NOT_FOUND; // No rows matching WHERE /* HA_ERR_LOCK_DEADLOCK or some other error */ table->file->print_error(error, MYF(0)); return(error); @@ -303,7 +303,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds) if (error) { if (error == HA_ERR_KEY_NOT_FOUND || error == HA_ERR_END_OF_FILE) - return -1; // No rows matching WHERE + return HA_ERR_KEY_NOT_FOUND; // No rows matching WHERE /* HA_ERR_LOCK_DEADLOCK or some other error */ table->file->print_error(error, MYF(0)); return(error); diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index 61fd5d9bce4..4c8703226a6 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -57,6 +57,7 @@ static Slave_log_event* find_slave_event(IO_CACHE* log, functions like register_slave()) are working. */ +#if NOT_USED static int init_failsafe_rpl_thread(THD* thd) { DBUG_ENTER("init_failsafe_rpl_thread"); @@ -99,7 +100,7 @@ static int init_failsafe_rpl_thread(THD* thd) thd->set_time(); DBUG_RETURN(0); } - +#endif void change_rpl_status(RPL_STATUS from_status, RPL_STATUS to_status) { @@ -573,12 +574,14 @@ err: } +#if NOT_USED int find_recovery_captain(THD* thd, MYSQL* mysql) { return 0; } +#endif - +#if NOT_USED pthread_handler_decl(handle_failsafe_rpl,arg) { DBUG_ENTER("handle_failsafe_rpl"); @@ -626,7 +629,7 @@ err: pthread_exit(0); DBUG_RETURN(0); } - +#endif int show_slave_hosts(THD* thd) { diff --git a/sql/set_var.cc b/sql/set_var.cc index 71ca382f9d9..520ee5c9f70 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -490,7 +490,7 @@ static sys_var_rand_seed1 sys_rand_seed1("rand_seed1"); static sys_var_rand_seed2 sys_rand_seed2("rand_seed2"); static sys_var_thd_ulong sys_default_week_format("default_week_format", - &SV::default_week_format); + &SV::default_week_format); sys_var_thd_ulong sys_group_concat_max_len("group_concat_max_len", &SV::group_concat_max_len); @@ -992,7 +992,6 @@ bool update_sys_var_str(sys_var_str *var_str, rw_lock_t *var_mutex, return 0; } - static bool sys_update_init_connect(THD *thd, set_var *var) { return update_sys_var_str(&sys_init_connect, &LOCK_sys_init_connect, var); @@ -1032,6 +1031,11 @@ static bool sys_update_ftb_syntax(THD *thd, set_var * var) { strmake(ft_boolean_syntax, var->value->str_value.c_ptr(), sizeof(ft_boolean_syntax)-1); + +#ifdef HAVE_QUERY_CACHE + query_cache.flush(); +#endif /* HAVE_QUERY_CACHE */ + return 0; } @@ -1128,14 +1132,14 @@ static void fix_tx_isolation(THD *thd, enum_var_type type) static void fix_net_read_timeout(THD *thd, enum_var_type type) { if (type != OPT_GLOBAL) - thd->net.read_timeout=thd->variables.net_read_timeout; + net_set_read_timeout(&thd->net, thd->variables.net_read_timeout); } static void fix_net_write_timeout(THD *thd, enum_var_type type) { if (type != OPT_GLOBAL) - thd->net.write_timeout=thd->variables.net_write_timeout; + net_set_write_timeout(&thd->net, thd->variables.net_write_timeout); } static void fix_net_retry_count(THD *thd, enum_var_type type) @@ -2570,19 +2574,38 @@ void sys_var_thd_time_zone::set_default(THD *thd, enum_var_type type) bool sys_var_thd_lc_time_names::check(THD *thd, set_var *var) { - char *locale_str =var->value->str_value.c_ptr(); - MY_LOCALE *locale_match= my_locale_by_name(locale_str); + MY_LOCALE *locale_match; - if(locale_match == NULL) + if (var->value->result_type() == INT_RESULT) { - my_printf_error(ER_UNKNOWN_ERROR, "Unknown locale: '%s'", MYF(0), locale_str); - return 1; + if (!(locale_match= my_locale_by_number((uint) var->value->val_int()))) + { + char buf[20]; + int10_to_str((int) var->value->val_int(), buf, -10); + my_printf_error(ER_UNKNOWN_ERROR, "Unknown locale: '%s'", MYF(0), buf); + return 1; + } } - else + else // STRING_RESULT { - var->save_result.locale_value= locale_match; - return 0; + char buff[6]; + String str(buff, sizeof(buff), &my_charset_latin1), *res; + if (!(res=var->value->val_str(&str))) + { + my_error(ER_WRONG_VALUE_FOR_VAR, MYF(0), name, "NULL"); + return 1; + } + const char *locale_str= res->c_ptr(); + if (!(locale_match= my_locale_by_name(locale_str))) + { + my_printf_error(ER_UNKNOWN_ERROR, + "Unknown locale: '%s'", MYF(0), locale_str); + return 1; + } } + + var->save_result.locale_value= locale_match; + return 0; } diff --git a/sql/set_var.h b/sql/set_var.h index 1ae3a18111f..78b34963e9d 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -764,12 +764,16 @@ class sys_var_thd_lc_time_names :public sys_var_thd public: sys_var_thd_lc_time_names(const char *name_arg): sys_var_thd(name_arg) - {} + { +#if MYSQL_VERSION_ID < 50000 + no_support_one_shot= 0; +#endif + } bool check(THD *thd, set_var *var); SHOW_TYPE type() { return SHOW_CHAR; } bool check_update_type(Item_result type) { - return type != STRING_RESULT; /* Only accept strings */ + return ((type != STRING_RESULT) && (type != INT_RESULT)); } bool check_default(enum_var_type type) { return 0; } bool update(THD *thd, set_var *var); diff --git a/sql/share/charsets/hebrew.xml b/sql/share/charsets/hebrew.xml index 5bcf222a728..981f308bfb5 100644 --- a/sql/share/charsets/hebrew.xml +++ b/sql/share/charsets/hebrew.xml @@ -40,7 +40,7 @@ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 - 02 02 02 02 02 02 02 02 02 02 02 00 00 00 00 00 + 02 02 02 02 02 02 02 02 02 02 02 00 00 20 20 00 </map> </ctype> @@ -106,7 +106,7 @@ 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 2017 05D0 05D1 05D2 05D3 05D4 05D5 05D6 05D7 05D8 05D9 05DA 05DB 05DC 05DD 05DE 05DF -05E0 05E1 05E2 05E3 05E4 05E5 05E6 05E7 05E8 05E9 05EA 0000 0000 0000 0000 0000 +05E0 05E1 05E2 05E3 05E4 05E5 05E6 05E7 05E8 05E9 05EA 0000 0000 200E 200F 0000 </map> </unicode> diff --git a/sql/slave.cc b/sql/slave.cc index 6785e92b9f9..75b18f6f307 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2625,7 +2625,6 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type) */ thd->variables.max_allowed_packet= global_system_variables.max_allowed_packet + MAX_LOG_EVENT_HEADER; /* note, incr over the global not session var */ - thd->net.read_timeout = slave_net_timeout; thd->master_access= ~(ulong)0; thd->priv_user = 0; thd->slave_thread = 1; @@ -4284,6 +4283,13 @@ Log_event* next_event(RELAY_LOG_INFO* rli) hot_log=0; // Using old binary log } } + /* + As there is no guarantee that the relay is open (for example, an I/O + error during a write by the slave I/O thread may have closed it), we + have to test it. + */ + if (!my_b_inited(cur_log)) + goto err; #ifndef DBUG_OFF { char llbuf1[22], llbuf2[22]; diff --git a/sql/spatial.cc b/sql/spatial.cc index 684f7e9ecf3..4e17e766090 100644 --- a/sql/spatial.cc +++ b/sql/spatial.cc @@ -210,23 +210,24 @@ static uint32 wkb_get_uint(const char *ptr, Geometry::wkbByteOrder bo) } -int Geometry::create_from_wkb(Geometry_buffer *buffer, - const char *wkb, uint32 len, String *res) +Geometry *Geometry::create_from_wkb(Geometry_buffer *buffer, + const char *wkb, uint32 len, String *res) { uint32 geom_type; Geometry *geom; if (len < WKB_HEADER_SIZE) - return 1; + return NULL; geom_type= wkb_get_uint(wkb+1, (wkbByteOrder)wkb[0]); if (!(geom= create_by_typeid(buffer, (int) geom_type)) || res->reserve(WKB_HEADER_SIZE, 512)) - return 1; + return NULL; res->q_append((char) wkb_ndr); res->q_append(geom_type); - return geom->init_from_wkb(wkb+WKB_HEADER_SIZE, len - WKB_HEADER_SIZE, - (wkbByteOrder) wkb[0], res); + + return geom->init_from_wkb(wkb + WKB_HEADER_SIZE, len - WKB_HEADER_SIZE, + (wkbByteOrder) wkb[0], res) ? geom : NULL; } diff --git a/sql/spatial.h b/sql/spatial.h index 378233a2156..553544d4c3f 100644 --- a/sql/spatial.h +++ b/sql/spatial.h @@ -244,8 +244,8 @@ public: static Geometry *create_from_wkt(Geometry_buffer *buffer, Gis_read_stream *trs, String *wkt, bool init_stream=1); - static int create_from_wkb(Geometry_buffer *buffer, - const char *wkb, uint32 len, String *res); + static Geometry *create_from_wkb(Geometry_buffer *buffer, const char *wkb, + uint32 len, String *res); int as_wkt(String *wkt, const char **end) { uint32 len= get_class_info()->m_name.length; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index c60bed09cf9..2f7661182a6 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -34,7 +34,6 @@ HASH assign_cache; static int open_unireg_entry(THD *thd,TABLE *entry,const char *db, const char *name, const char *alias); static void free_cache_entry(TABLE *entry); -static void mysql_rm_tmp_tables(void); extern "C" byte *table_cache_key(const byte *record,uint *length, @@ -47,7 +46,6 @@ extern "C" byte *table_cache_key(const byte *record,uint *length, bool table_cache_init(void) { - mysql_rm_tmp_tables(); return hash_init(&open_cache, &my_charset_bin, table_cache_size+16, 0, 0,table_cache_key, (hash_free_key) free_cache_entry, 0) != 0; @@ -2520,11 +2518,14 @@ int setup_fields(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, { reg2 Item *item; List_iterator<Item> it(fields); + bool save_is_item_list_lookup; DBUG_ENTER("setup_fields"); thd->set_query_id=set_query_id; thd->allow_sum_func= allow_sum_func; thd->where="field list"; + save_is_item_list_lookup= thd->lex->current_select->is_item_list_lookup; + thd->lex->current_select->is_item_list_lookup= 0; /* To prevent fail on forward lookup we fill it with zerows, @@ -2545,7 +2546,10 @@ int setup_fields(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, { if (!item->fixed && item->fix_fields(thd, tables, it.ref()) || (item= *(it.ref()))->check_cols(1)) + { + thd->lex->current_select->is_item_list_lookup= save_is_item_list_lookup; DBUG_RETURN(-1); /* purecov: inspected */ + } if (ref) *(ref++)= item; if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM && @@ -2553,6 +2557,7 @@ int setup_fields(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, item->split_sum_func(thd, ref_pointer_array, *sum_func_list); thd->used_tables|=item->used_tables(); } + thd->lex->current_select->is_item_list_lookup= save_is_item_list_lookup; DBUG_RETURN(test(thd->net.report_error)); } @@ -2749,6 +2754,8 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds) { table_map not_null_tables= 0; Item_arena *arena= 0, backup; + bool save_is_item_list_lookup= thd->lex->current_select->is_item_list_lookup; + thd->lex->current_select->is_item_list_lookup= 0; DBUG_ENTER("setup_conds"); thd->set_query_id=1; @@ -2758,7 +2765,10 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds) thd->where="where clause"; if (!(*conds)->fixed && (*conds)->fix_fields(thd, tables, conds) || (*conds)->check_cols(1)) + { + thd->lex->current_select->is_item_list_lookup= save_is_item_list_lookup; DBUG_RETURN(1); + } not_null_tables= (*conds)->not_null_tables(); } @@ -2774,7 +2784,10 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds) if (!table->on_expr->fixed && table->on_expr->fix_fields(thd, tables, &table->on_expr) || table->on_expr->check_cols(1)) + { + thd->lex->current_select->is_item_list_lookup= save_is_item_list_lookup; DBUG_RETURN(1); + } thd->lex->current_select->cond_count++; /* @@ -2796,7 +2809,11 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds) } if ((*conds) && !(*conds)->fixed && (*conds)->fix_fields(thd, tables, conds)) + { + thd->lex->current_select->is_item_list_lookup= + save_is_item_list_lookup; DBUG_RETURN(1); + } } } if (table->natural_join) @@ -2848,7 +2865,11 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds) { if (!(*conds)->fixed && (*conds)->fix_fields(thd, tables, conds)) + { + thd->lex->current_select->is_item_list_lookup= + save_is_item_list_lookup; DBUG_RETURN(1); + } } } else @@ -2861,7 +2882,11 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds) { if (!table->on_expr->fixed && table->on_expr->fix_fields(thd, tables, &table->on_expr)) - DBUG_RETURN(1); + { + thd->lex->current_select->is_item_list_lookup= + save_is_item_list_lookup; + DBUG_RETURN(1); + } } } } @@ -2883,9 +2908,11 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds) */ thd->lex->current_select->where= *conds; } + thd->lex->current_select->is_item_list_lookup= save_is_item_list_lookup; DBUG_RETURN(test(thd->net.report_error)); err: + thd->lex->current_select->is_item_list_lookup= save_is_item_list_lookup; if (arena) thd->restore_backup_item_arena(arena, &backup); DBUG_RETURN(1); @@ -2940,14 +2967,20 @@ fill_record(Field **ptr,List<Item> &values, bool ignore_errors) } -static void mysql_rm_tmp_tables(void) +my_bool mysql_rm_tmp_tables(void) { uint i, idx; - char filePath[FN_REFLEN], *tmpdir; + char filePath[FN_REFLEN], *tmpdir, filePathCopy[FN_REFLEN]; MY_DIR *dirp; FILEINFO *file; + TABLE tmp_table; + THD *thd; DBUG_ENTER("mysql_rm_tmp_tables"); + if (!(thd= new THD)) + DBUG_RETURN(1); + thd->store_globals(); + for (i=0; i<=mysql_tmpdir_list.max; i++) { tmpdir=mysql_tmpdir_list.list[i]; @@ -2968,13 +3001,37 @@ static void mysql_rm_tmp_tables(void) if (!bcmp(file->name,tmp_file_prefix,tmp_file_prefix_length)) { - sprintf(filePath,"%s%s",tmpdir,file->name); - VOID(my_delete(filePath,MYF(MY_WME))); + char *ext= fn_ext(file->name); + uint ext_len= strlen(ext); + uint filePath_len= my_snprintf(filePath, sizeof(filePath), + "%s%s", tmpdir, file->name); + if (!bcmp(reg_ext, ext, ext_len)) + { + TABLE tmp_table; + if (!openfrm(filePath, "tmp_table", (uint) 0, + READ_KEYINFO | COMPUTE_TYPES | EXTRA_RECORD, + 0, &tmp_table)) + { + /* We should cut file extention before deleting of table */ + memcpy(filePathCopy, filePath, filePath_len - ext_len); + filePathCopy[filePath_len - ext_len]= 0; + tmp_table.file->delete_table(filePathCopy); + closefrm(&tmp_table); + } + } + /* + File can be already deleted by tmp_table.file->delete_table(). + So we hide error messages which happnes during deleting of these + files(MYF(0)). + */ + VOID(my_delete(filePath, MYF(0))); } } my_dirend(dirp); } - DBUG_VOID_RETURN; + delete thd; + my_pthread_setspecific_ptr(THR_THD, 0); + DBUG_RETURN(0); } diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index fc03e03dee7..ee26bda3307 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -813,6 +813,7 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used) flags.sql_mode= thd->variables.sql_mode; flags.max_sort_length= thd->variables.max_sort_length; flags.group_concat_max_len= thd->variables.group_concat_max_len; + flags.default_week_format= thd->variables.default_week_format; flags.lc_time_names= thd->variables.lc_time_names; STRUCT_LOCK(&structure_guard_mutex); @@ -1016,6 +1017,7 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length) flags.sql_mode= thd->variables.sql_mode; flags.max_sort_length= thd->variables.max_sort_length; flags.group_concat_max_len= thd->variables.group_concat_max_len; + flags.default_week_format= thd->variables.default_week_format; flags.lc_time_names= thd->variables.lc_time_names; memcpy((void *)(sql + (tot_length - QUERY_CACHE_FLAGS_SIZE)), &flags, QUERY_CACHE_FLAGS_SIZE); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index c8d90848f6e..b187d29021a 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1048,7 +1048,6 @@ bool select_export::send_data(List<Item> &items) } row_count++; Item *item; - char *buff_ptr=buff; uint used_length=0,items_left=items.elements; List_iterator_fast<Item> li(items); @@ -1148,19 +1147,18 @@ bool select_export::send_data(List<Item> &items) goto err; } } - buff_ptr=buff; // Place separators here if (res && (!exchange->opt_enclosed || result_type == STRING_RESULT)) { - memcpy(buff_ptr,exchange->enclosed->ptr(),exchange->enclosed->length()); - buff_ptr+=exchange->enclosed->length(); + if (my_b_write(&cache, (byte*) exchange->enclosed->ptr(), + exchange->enclosed->length())) + goto err; } if (--items_left) { - memcpy(buff_ptr,exchange->field_term->ptr(),field_term_length); - buff_ptr+=field_term_length; + if (my_b_write(&cache, (byte*) exchange->field_term->ptr(), + field_term_length)) + goto err; } - if (my_b_write(&cache,(byte*) buff,(uint) (buff_ptr-buff))) - goto err; } if (my_b_write(&cache,(byte*) exchange->line_term->ptr(), exchange->line_term->length())) diff --git a/sql/sql_class.h b/sql/sql_class.h index 05105bfc86a..db6f65cab55 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1293,20 +1293,21 @@ class select_create: public select_insert { ORDER *group; const char *db; const char *name; - List<create_field> *extra_fields; - List<Key> *keys; HA_CREATE_INFO *create_info; + Alter_info *alter_info; MYSQL_LOCK *lock; Field **field; public: select_create(const char *db_name, const char *table_name, - HA_CREATE_INFO *create_info_par, - List<create_field> &fields_par, - List<Key> &keys_par, - List<Item> &select_fields,enum_duplicates duplic, bool ignore) - :select_insert (NULL, &select_fields, duplic, ignore), db(db_name), - name(table_name), extra_fields(&fields_par),keys(&keys_par), - create_info(create_info_par), lock(0) + HA_CREATE_INFO *create_info_arg, + Alter_info *alter_info_arg, + List<Item> &select_fields, + enum_duplicates duplic, bool ignore) + :select_insert(NULL, &select_fields, duplic, ignore), + db(db_name), name(table_name), + create_info(create_info_arg), + alter_info(alter_info_arg), + lock(0) {} int prepare(List<Item> &list, SELECT_LEX_UNIT *u); void store_values(List<Item> &values); diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 1b00539ed71..b84b2f7eef4 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -142,7 +142,7 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, DBUG_RETURN(-1); // This will force out message } - if (!select && limit != HA_POS_ERROR) + if ((!select || table->quick_keys.is_clear_all()) && limit != HA_POS_ERROR) usable_index= get_index_for_order(table, (ORDER*)(order->first), limit); if (usable_index == MAX_KEY) diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index d6c746d5d5d..f5bbba742a5 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1805,7 +1805,7 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u) unit= u; table= create_table_from_items(thd, create_info, db, name, - extra_fields, keys, &values, &lock); + alter_info, &values, &lock); if (!table) DBUG_RETURN(-1); // abort() deletes table diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index dfe406c351e..270fdb3f20a 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1015,6 +1015,18 @@ int yylex(void *arg, void *yythd) } } + +Alter_info::Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root) + :drop_list(rhs.drop_list, mem_root), + alter_list(rhs.alter_list, mem_root), + key_list(rhs.key_list, mem_root), + create_list(rhs.create_list, mem_root), + flags(rhs.flags), + keys_onoff(rhs.keys_onoff), + tablespace_op(rhs.tablespace_op), + is_simple(rhs.is_simple) +{} + /* st_select_lex structures initialisations */ diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 12f89202e2d..7faeb8046c7 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -571,19 +571,61 @@ typedef class st_select_lex SELECT_LEX; #define ALTER_ORDER 64 #define ALTER_OPTIONS 128 -typedef struct st_alter_info +/** + @brief Parsing data for CREATE or ALTER TABLE. + + This structure contains a list of columns or indexes to be created, + altered or dropped. +*/ + +class Alter_info { +public: List<Alter_drop> drop_list; List<Alter_column> alter_list; + List<Key> key_list; + List<create_field> create_list; uint flags; enum enum_enable_or_disable keys_onoff; enum tablespace_op_type tablespace_op; bool is_simple; - st_alter_info(){clear();} - void clear(){keys_onoff= LEAVE_AS_IS;tablespace_op= NO_TABLESPACE_OP;} - void reset(){drop_list.empty();alter_list.empty();clear();} -} ALTER_INFO; + Alter_info() : + flags(0), + keys_onoff(LEAVE_AS_IS), + tablespace_op(NO_TABLESPACE_OP), + is_simple(1) + {} + void reset() + { + drop_list.empty(); + alter_list.empty(); + key_list.empty(); + create_list.empty(); + flags= 0; + keys_onoff= LEAVE_AS_IS; + tablespace_op= NO_TABLESPACE_OP; + is_simple= 1; + } + /** + Construct a copy of this object to be used for mysql_alter_table + and mysql_create_table. Historically, these two functions modify + their Alter_info arguments. This behaviour breaks re-execution of + prepared statements and stored procedures and is compensated by + always supplying a copy of Alter_info to these functions. + The constructed copy still shares key Key, Alter_drop, create_field + and Alter_column elements of the lists - these structures are not + modified and thus are not copied. + + @note You need to use check thd->is_fatal_error for out + of memory condition after calling this function. + */ + Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root); +private: + Alter_info &operator=(const Alter_info &rhs); // not implemented + Alter_info(const Alter_info &rhs); // not implemented +}; + /* The state of the lex parsing. This is saved in the THD struct */ @@ -620,8 +662,6 @@ typedef struct st_lex List<String> interval_list; List<LEX_USER> users_list; List<LEX_COLUMN> columns; - List<Key> key_list; - List<create_field> create_list; List<Item> *insert_list,field_list,value_list,update_list; List<List_item> many_values; List<set_var_base> var_list; @@ -654,7 +694,7 @@ typedef struct st_lex bool derived_tables; bool safe_to_cache_query; bool subqueries, ignore; - ALTER_INFO alter_info; + Alter_info alter_info; /* Prepared statements SQL syntax:*/ LEX_STRING prepared_stmt_name; /* Statement name (in all queries) */ /* diff --git a/sql/sql_list.h b/sql/sql_list.h index e799ecf3d6e..2075361a398 100644 --- a/sql/sql_list.h +++ b/sql/sql_list.h @@ -30,7 +30,7 @@ class Sql_alloc { public: - static void *operator new(size_t size) + static void *operator new(size_t size) throw () { return (void*) sql_alloc((uint) size); } @@ -38,7 +38,7 @@ public: { return (void*) sql_alloc((uint) size); } - static void *operator new(size_t size, MEM_ROOT *mem_root) + static void *operator new(size_t size, MEM_ROOT *mem_root) throw () { return (void*) alloc_root(mem_root, (uint) size); } static void operator delete(void *ptr, size_t size) { TRASH(ptr, size); } static void operator delete(void *ptr, MEM_ROOT *mem_root) @@ -66,21 +66,24 @@ public: pointer. */ -class list_node :public Sql_alloc + +/** + list_node - a node of a single-linked list. + @note We never call a destructor for instances of this class. +*/ + +struct list_node :public Sql_alloc { -public: list_node *next; void *info; list_node(void *info_par,list_node *next_par) :next(next_par),info(info_par) - {} + {} list_node() /* For end_of_list */ - { - info=0; - next= this; - } - friend class base_list; - friend class base_list_iterator; + { + info= 0; + next= this; + } }; @@ -96,11 +99,56 @@ public: inline void empty() { elements=0; first= &end_of_list; last=&first;} inline base_list() { empty(); } + /** + This is a shallow copy constructor that implicitly passes the ownership + from the source list to the new instance. The old instance is not + updated, so both objects end up sharing the same nodes. If one of + the instances then adds or removes a node, the other becomes out of + sync ('last' pointer), while still operational. Some old code uses and + relies on this behaviour. This logic is quite tricky: please do not use + it in any new code. + */ inline base_list(const base_list &tmp) :Sql_alloc() { - elements=tmp.elements; - first=tmp.first; - last=tmp.last; + elements= tmp.elements; + first= tmp.first; + last= elements ? tmp.last : &first; + } + /** + Construct a deep copy of the argument in memory root mem_root. + The elements themselves are copied by pointer. + */ + inline base_list(const base_list &rhs, MEM_ROOT *mem_root) + { + if (rhs.elements) + { + /* + It's okay to allocate an array of nodes at once: we never + call a destructor for list_node objects anyway. + */ + first= (list_node*) alloc_root(mem_root, + sizeof(list_node) * rhs.elements); + if (first) + { + elements= rhs.elements; + list_node *dst= first; + list_node *src= rhs.first; + for (; dst < first + elements - 1; dst++, src= src->next) + { + dst->info= src->info; + dst->next= dst + 1; + } + /* Copy the last node */ + dst->info= src->info; + dst->next= &end_of_list; + /* Setup 'last' member */ + last= &dst->next; + return; + } + } + elements= 0; + first= &end_of_list; + last= &first; } inline base_list(bool error) { } inline bool push_back(void *info) @@ -327,6 +375,8 @@ template <class T> class List :public base_list public: inline List() :base_list() {} inline List(const List<T> &tmp) :base_list(tmp) {} + inline List(const List<T> &tmp, MEM_ROOT *mem_root) : + base_list(tmp, mem_root) {} inline bool push_back(T *a) { return base_list::push_back(a); } inline bool push_front(T *a) { return base_list::push_front(a); } inline T* head() {return (T*) base_list::head(); } diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 5710f9c4c97..10124e5f5ff 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -353,7 +353,6 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, } sprintf(name, ER(ER_LOAD_INFO), (ulong) info.records, (ulong) info.deleted, (ulong) (info.records - info.copied), (ulong) thd->cuted_fields); - send_ok(thd,info.copied+info.deleted,0L,name); // on the slave thd->query is never initialized if (!thd->slave_thread) mysql_update_log.write(thd,thd->query,thd->query_length); @@ -378,6 +377,9 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, #endif /*!EMBEDDED_LIBRARY*/ if (transactional_table) error=ha_autocommit_or_rollback(thd,error); + + /* ok to client sent only after binlog write and engine commit */ + send_ok(thd, info.copied + info.deleted, 0L, name); err: if (thd->lock) { diff --git a/sql/sql_locale.cc b/sql/sql_locale.cc index 9dae55e4508..1f60c61ed46 100644 --- a/sql/sql_locale.cc +++ b/sql/sql_locale.cc @@ -24,17 +24,6 @@ #include "mysql_priv.h" -MY_LOCALE *my_locale_by_name(const char *name) -{ - MY_LOCALE **locale; - for( locale= my_locales; *locale != NULL; locale++) - { - if(!strcmp((*locale)->name, name)) - return *locale; - } - return NULL; -} - /***** LOCALE BEGIN ar_AE: Arabic - United Arab Emirates *****/ static const char *my_locale_month_names_ar_AE[13] = {"يناير","فبراير","مارس","أبريل","مايو","يونيو","يوليو","أغسطس","سبتمبر","أكتوبر","نوفمبر","ديسمبر", NullS }; @@ -53,7 +42,16 @@ static TYPELIB my_locale_typelib_day_names_ar_AE = static TYPELIB my_locale_typelib_ab_day_names_ar_AE = { array_elements(my_locale_ab_day_names_ar_AE)-1, "", my_locale_ab_day_names_ar_AE, NULL }; MY_LOCALE my_locale_ar_AE= - { "ar_AE", "Arabic - United Arab Emirates", FALSE, &my_locale_typelib_month_names_ar_AE, &my_locale_typelib_ab_month_names_ar_AE, &my_locale_typelib_day_names_ar_AE, &my_locale_typelib_ab_day_names_ar_AE }; +{ + 6, + "ar_AE", + "Arabic - United Arab Emirates", + FALSE, + &my_locale_typelib_month_names_ar_AE, + &my_locale_typelib_ab_month_names_ar_AE, + &my_locale_typelib_day_names_ar_AE, + &my_locale_typelib_ab_day_names_ar_AE +}; /***** LOCALE END ar_AE *****/ /***** LOCALE BEGIN ar_BH: Arabic - Bahrain *****/ @@ -74,7 +72,16 @@ static TYPELIB my_locale_typelib_day_names_ar_BH = static TYPELIB my_locale_typelib_ab_day_names_ar_BH = { array_elements(my_locale_ab_day_names_ar_BH)-1, "", my_locale_ab_day_names_ar_BH, NULL }; MY_LOCALE my_locale_ar_BH= - { "ar_BH", "Arabic - Bahrain", FALSE, &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, &my_locale_typelib_ab_day_names_ar_BH }; +{ + 7, + "ar_BH", + "Arabic - Bahrain", + FALSE, + &my_locale_typelib_month_names_ar_BH, + &my_locale_typelib_ab_month_names_ar_BH, + &my_locale_typelib_day_names_ar_BH, + &my_locale_typelib_ab_day_names_ar_BH +}; /***** LOCALE END ar_BH *****/ /***** LOCALE BEGIN ar_JO: Arabic - Jordan *****/ @@ -95,7 +102,16 @@ static TYPELIB my_locale_typelib_day_names_ar_JO = static TYPELIB my_locale_typelib_ab_day_names_ar_JO = { array_elements(my_locale_ab_day_names_ar_JO)-1, "", my_locale_ab_day_names_ar_JO, NULL }; MY_LOCALE my_locale_ar_JO= - { "ar_JO", "Arabic - Jordan", FALSE, &my_locale_typelib_month_names_ar_JO, &my_locale_typelib_ab_month_names_ar_JO, &my_locale_typelib_day_names_ar_JO, &my_locale_typelib_ab_day_names_ar_JO }; +{ + 8, + "ar_JO", + "Arabic - Jordan", + FALSE, + &my_locale_typelib_month_names_ar_JO, + &my_locale_typelib_ab_month_names_ar_JO, + &my_locale_typelib_day_names_ar_JO, + &my_locale_typelib_ab_day_names_ar_JO +}; /***** LOCALE END ar_JO *****/ /***** LOCALE BEGIN ar_SA: Arabic - Saudi Arabia *****/ @@ -116,7 +132,16 @@ static TYPELIB my_locale_typelib_day_names_ar_SA = static TYPELIB my_locale_typelib_ab_day_names_ar_SA = { array_elements(my_locale_ab_day_names_ar_SA)-1, "", my_locale_ab_day_names_ar_SA, NULL }; MY_LOCALE my_locale_ar_SA= - { "ar_SA", "Arabic - Saudi Arabia", FALSE, &my_locale_typelib_month_names_ar_SA, &my_locale_typelib_ab_month_names_ar_SA, &my_locale_typelib_day_names_ar_SA, &my_locale_typelib_ab_day_names_ar_SA }; +{ + 9, + "ar_SA", + "Arabic - Saudi Arabia", + FALSE, + &my_locale_typelib_month_names_ar_SA, + &my_locale_typelib_ab_month_names_ar_SA, + &my_locale_typelib_day_names_ar_SA, + &my_locale_typelib_ab_day_names_ar_SA +}; /***** LOCALE END ar_SA *****/ /***** LOCALE BEGIN ar_SY: Arabic - Syria *****/ @@ -137,7 +162,16 @@ static TYPELIB my_locale_typelib_day_names_ar_SY = static TYPELIB my_locale_typelib_ab_day_names_ar_SY = { array_elements(my_locale_ab_day_names_ar_SY)-1, "", my_locale_ab_day_names_ar_SY, NULL }; MY_LOCALE my_locale_ar_SY= - { "ar_SY", "Arabic - Syria", FALSE, &my_locale_typelib_month_names_ar_SY, &my_locale_typelib_ab_month_names_ar_SY, &my_locale_typelib_day_names_ar_SY, &my_locale_typelib_ab_day_names_ar_SY }; +{ + 10, + "ar_SY", + "Arabic - Syria", + FALSE, + &my_locale_typelib_month_names_ar_SY, + &my_locale_typelib_ab_month_names_ar_SY, + &my_locale_typelib_day_names_ar_SY, + &my_locale_typelib_ab_day_names_ar_SY +}; /***** LOCALE END ar_SY *****/ /***** LOCALE BEGIN be_BY: Belarusian - Belarus *****/ @@ -158,7 +192,16 @@ static TYPELIB my_locale_typelib_day_names_be_BY = static TYPELIB my_locale_typelib_ab_day_names_be_BY = { array_elements(my_locale_ab_day_names_be_BY)-1, "", my_locale_ab_day_names_be_BY, NULL }; MY_LOCALE my_locale_be_BY= - { "be_BY", "Belarusian - Belarus", FALSE, &my_locale_typelib_month_names_be_BY, &my_locale_typelib_ab_month_names_be_BY, &my_locale_typelib_day_names_be_BY, &my_locale_typelib_ab_day_names_be_BY }; +{ + 11, + "be_BY", + "Belarusian - Belarus", + FALSE, + &my_locale_typelib_month_names_be_BY, + &my_locale_typelib_ab_month_names_be_BY, + &my_locale_typelib_day_names_be_BY, + &my_locale_typelib_ab_day_names_be_BY +}; /***** LOCALE END be_BY *****/ /***** LOCALE BEGIN bg_BG: Bulgarian - Bulgaria *****/ @@ -179,7 +222,16 @@ static TYPELIB my_locale_typelib_day_names_bg_BG = static TYPELIB my_locale_typelib_ab_day_names_bg_BG = { array_elements(my_locale_ab_day_names_bg_BG)-1, "", my_locale_ab_day_names_bg_BG, NULL }; MY_LOCALE my_locale_bg_BG= - { "bg_BG", "Bulgarian - Bulgaria", FALSE, &my_locale_typelib_month_names_bg_BG, &my_locale_typelib_ab_month_names_bg_BG, &my_locale_typelib_day_names_bg_BG, &my_locale_typelib_ab_day_names_bg_BG }; +{ + 12, + "bg_BG", + "Bulgarian - Bulgaria", + FALSE, + &my_locale_typelib_month_names_bg_BG, + &my_locale_typelib_ab_month_names_bg_BG, + &my_locale_typelib_day_names_bg_BG, + &my_locale_typelib_ab_day_names_bg_BG +}; /***** LOCALE END bg_BG *****/ /***** LOCALE BEGIN ca_ES: Catalan - Catalan *****/ @@ -200,7 +252,16 @@ static TYPELIB my_locale_typelib_day_names_ca_ES = static TYPELIB my_locale_typelib_ab_day_names_ca_ES = { array_elements(my_locale_ab_day_names_ca_ES)-1, "", my_locale_ab_day_names_ca_ES, NULL }; MY_LOCALE my_locale_ca_ES= - { "ca_ES", "Catalan - Catalan", FALSE, &my_locale_typelib_month_names_ca_ES, &my_locale_typelib_ab_month_names_ca_ES, &my_locale_typelib_day_names_ca_ES, &my_locale_typelib_ab_day_names_ca_ES }; +{ + 13, + "ca_ES", + "Catalan - Catalan", + FALSE, + &my_locale_typelib_month_names_ca_ES, + &my_locale_typelib_ab_month_names_ca_ES, + &my_locale_typelib_day_names_ca_ES, + &my_locale_typelib_ab_day_names_ca_ES +}; /***** LOCALE END ca_ES *****/ /***** LOCALE BEGIN cs_CZ: Czech - Czech Republic *****/ @@ -221,7 +282,16 @@ static TYPELIB my_locale_typelib_day_names_cs_CZ = static TYPELIB my_locale_typelib_ab_day_names_cs_CZ = { array_elements(my_locale_ab_day_names_cs_CZ)-1, "", my_locale_ab_day_names_cs_CZ, NULL }; MY_LOCALE my_locale_cs_CZ= - { "cs_CZ", "Czech - Czech Republic", FALSE, &my_locale_typelib_month_names_cs_CZ, &my_locale_typelib_ab_month_names_cs_CZ, &my_locale_typelib_day_names_cs_CZ, &my_locale_typelib_ab_day_names_cs_CZ }; +{ + 14, + "cs_CZ", + "Czech - Czech Republic", + FALSE, + &my_locale_typelib_month_names_cs_CZ, + &my_locale_typelib_ab_month_names_cs_CZ, + &my_locale_typelib_day_names_cs_CZ, + &my_locale_typelib_ab_day_names_cs_CZ +}; /***** LOCALE END cs_CZ *****/ /***** LOCALE BEGIN da_DK: Danish - Denmark *****/ @@ -242,7 +312,16 @@ static TYPELIB my_locale_typelib_day_names_da_DK = static TYPELIB my_locale_typelib_ab_day_names_da_DK = { array_elements(my_locale_ab_day_names_da_DK)-1, "", my_locale_ab_day_names_da_DK, NULL }; MY_LOCALE my_locale_da_DK= - { "da_DK", "Danish - Denmark", FALSE, &my_locale_typelib_month_names_da_DK, &my_locale_typelib_ab_month_names_da_DK, &my_locale_typelib_day_names_da_DK, &my_locale_typelib_ab_day_names_da_DK }; +{ + 15, + "da_DK", + "Danish - Denmark", + FALSE, + &my_locale_typelib_month_names_da_DK, + &my_locale_typelib_ab_month_names_da_DK, + &my_locale_typelib_day_names_da_DK, + &my_locale_typelib_ab_day_names_da_DK +}; /***** LOCALE END da_DK *****/ /***** LOCALE BEGIN de_AT: German - Austria *****/ @@ -263,7 +342,16 @@ static TYPELIB my_locale_typelib_day_names_de_AT = static TYPELIB my_locale_typelib_ab_day_names_de_AT = { array_elements(my_locale_ab_day_names_de_AT)-1, "", my_locale_ab_day_names_de_AT, NULL }; MY_LOCALE my_locale_de_AT= - { "de_AT", "German - Austria", FALSE, &my_locale_typelib_month_names_de_AT, &my_locale_typelib_ab_month_names_de_AT, &my_locale_typelib_day_names_de_AT, &my_locale_typelib_ab_day_names_de_AT }; +{ + 16, + "de_AT", + "German - Austria", + FALSE, + &my_locale_typelib_month_names_de_AT, + &my_locale_typelib_ab_month_names_de_AT, + &my_locale_typelib_day_names_de_AT, + &my_locale_typelib_ab_day_names_de_AT +}; /***** LOCALE END de_AT *****/ /***** LOCALE BEGIN de_DE: German - Germany *****/ @@ -284,7 +372,16 @@ static TYPELIB my_locale_typelib_day_names_de_DE = static TYPELIB my_locale_typelib_ab_day_names_de_DE = { array_elements(my_locale_ab_day_names_de_DE)-1, "", my_locale_ab_day_names_de_DE, NULL }; MY_LOCALE my_locale_de_DE= - { "de_DE", "German - Germany", FALSE, &my_locale_typelib_month_names_de_DE, &my_locale_typelib_ab_month_names_de_DE, &my_locale_typelib_day_names_de_DE, &my_locale_typelib_ab_day_names_de_DE }; +{ + 4, + "de_DE", + "German - Germany", + FALSE, + &my_locale_typelib_month_names_de_DE, + &my_locale_typelib_ab_month_names_de_DE, + &my_locale_typelib_day_names_de_DE, + &my_locale_typelib_ab_day_names_de_DE +}; /***** LOCALE END de_DE *****/ /***** LOCALE BEGIN en_US: English - United States *****/ @@ -305,7 +402,16 @@ static TYPELIB my_locale_typelib_day_names_en_US = static TYPELIB my_locale_typelib_ab_day_names_en_US = { array_elements(my_locale_ab_day_names_en_US)-1, "", my_locale_ab_day_names_en_US, NULL }; MY_LOCALE my_locale_en_US= - { "en_US", "English - United States", TRUE, &my_locale_typelib_month_names_en_US, &my_locale_typelib_ab_month_names_en_US, &my_locale_typelib_day_names_en_US, &my_locale_typelib_ab_day_names_en_US }; +{ + 0, + "en_US", + "English - United States", + TRUE, + &my_locale_typelib_month_names_en_US, + &my_locale_typelib_ab_month_names_en_US, + &my_locale_typelib_day_names_en_US, + &my_locale_typelib_ab_day_names_en_US +}; /***** LOCALE END en_US *****/ /***** LOCALE BEGIN es_ES: Spanish - Spain *****/ @@ -326,7 +432,16 @@ static TYPELIB my_locale_typelib_day_names_es_ES = static TYPELIB my_locale_typelib_ab_day_names_es_ES = { array_elements(my_locale_ab_day_names_es_ES)-1, "", my_locale_ab_day_names_es_ES, NULL }; MY_LOCALE my_locale_es_ES= - { "es_ES", "Spanish - Spain", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES }; +{ + 17, + "es_ES", + "Spanish - Spain", + FALSE, + &my_locale_typelib_month_names_es_ES, + &my_locale_typelib_ab_month_names_es_ES, + &my_locale_typelib_day_names_es_ES, + &my_locale_typelib_ab_day_names_es_ES +}; /***** LOCALE END es_ES *****/ /***** LOCALE BEGIN et_EE: Estonian - Estonia *****/ @@ -347,7 +462,16 @@ static TYPELIB my_locale_typelib_day_names_et_EE = static TYPELIB my_locale_typelib_ab_day_names_et_EE = { array_elements(my_locale_ab_day_names_et_EE)-1, "", my_locale_ab_day_names_et_EE, NULL }; MY_LOCALE my_locale_et_EE= - { "et_EE", "Estonian - Estonia", FALSE, &my_locale_typelib_month_names_et_EE, &my_locale_typelib_ab_month_names_et_EE, &my_locale_typelib_day_names_et_EE, &my_locale_typelib_ab_day_names_et_EE }; +{ + 18, + "et_EE", + "Estonian - Estonia", + FALSE, + &my_locale_typelib_month_names_et_EE, + &my_locale_typelib_ab_month_names_et_EE, + &my_locale_typelib_day_names_et_EE, + &my_locale_typelib_ab_day_names_et_EE +}; /***** LOCALE END et_EE *****/ /***** LOCALE BEGIN eu_ES: Basque - Basque *****/ @@ -368,7 +492,16 @@ static TYPELIB my_locale_typelib_day_names_eu_ES = static TYPELIB my_locale_typelib_ab_day_names_eu_ES = { array_elements(my_locale_ab_day_names_eu_ES)-1, "", my_locale_ab_day_names_eu_ES, NULL }; MY_LOCALE my_locale_eu_ES= - { "eu_ES", "Basque - Basque", TRUE, &my_locale_typelib_month_names_eu_ES, &my_locale_typelib_ab_month_names_eu_ES, &my_locale_typelib_day_names_eu_ES, &my_locale_typelib_ab_day_names_eu_ES }; +{ + 19, + "eu_ES", + "Basque - Basque", + TRUE, + &my_locale_typelib_month_names_eu_ES, + &my_locale_typelib_ab_month_names_eu_ES, + &my_locale_typelib_day_names_eu_ES, + &my_locale_typelib_ab_day_names_eu_ES +}; /***** LOCALE END eu_ES *****/ /***** LOCALE BEGIN fi_FI: Finnish - Finland *****/ @@ -389,7 +522,16 @@ static TYPELIB my_locale_typelib_day_names_fi_FI = static TYPELIB my_locale_typelib_ab_day_names_fi_FI = { array_elements(my_locale_ab_day_names_fi_FI)-1, "", my_locale_ab_day_names_fi_FI, NULL }; MY_LOCALE my_locale_fi_FI= - { "fi_FI", "Finnish - Finland", FALSE, &my_locale_typelib_month_names_fi_FI, &my_locale_typelib_ab_month_names_fi_FI, &my_locale_typelib_day_names_fi_FI, &my_locale_typelib_ab_day_names_fi_FI }; +{ + 20, + "fi_FI", + "Finnish - Finland", + FALSE, + &my_locale_typelib_month_names_fi_FI, + &my_locale_typelib_ab_month_names_fi_FI, + &my_locale_typelib_day_names_fi_FI, + &my_locale_typelib_ab_day_names_fi_FI +}; /***** LOCALE END fi_FI *****/ /***** LOCALE BEGIN fo_FO: Faroese - Faroe Islands *****/ @@ -410,7 +552,16 @@ static TYPELIB my_locale_typelib_day_names_fo_FO = static TYPELIB my_locale_typelib_ab_day_names_fo_FO = { array_elements(my_locale_ab_day_names_fo_FO)-1, "", my_locale_ab_day_names_fo_FO, NULL }; MY_LOCALE my_locale_fo_FO= - { "fo_FO", "Faroese - Faroe Islands", FALSE, &my_locale_typelib_month_names_fo_FO, &my_locale_typelib_ab_month_names_fo_FO, &my_locale_typelib_day_names_fo_FO, &my_locale_typelib_ab_day_names_fo_FO }; +{ + 21, + "fo_FO", + "Faroese - Faroe Islands", + FALSE, + &my_locale_typelib_month_names_fo_FO, + &my_locale_typelib_ab_month_names_fo_FO, + &my_locale_typelib_day_names_fo_FO, + &my_locale_typelib_ab_day_names_fo_FO +}; /***** LOCALE END fo_FO *****/ /***** LOCALE BEGIN fr_FR: French - France *****/ @@ -431,7 +582,16 @@ static TYPELIB my_locale_typelib_day_names_fr_FR = static TYPELIB my_locale_typelib_ab_day_names_fr_FR = { array_elements(my_locale_ab_day_names_fr_FR)-1, "", my_locale_ab_day_names_fr_FR, NULL }; MY_LOCALE my_locale_fr_FR= - { "fr_FR", "French - France", FALSE, &my_locale_typelib_month_names_fr_FR, &my_locale_typelib_ab_month_names_fr_FR, &my_locale_typelib_day_names_fr_FR, &my_locale_typelib_ab_day_names_fr_FR }; +{ + 5, + "fr_FR", + "French - France", + FALSE, + &my_locale_typelib_month_names_fr_FR, + &my_locale_typelib_ab_month_names_fr_FR, + &my_locale_typelib_day_names_fr_FR, + &my_locale_typelib_ab_day_names_fr_FR +}; /***** LOCALE END fr_FR *****/ /***** LOCALE BEGIN gl_ES: Galician - Galician *****/ @@ -452,7 +612,16 @@ static TYPELIB my_locale_typelib_day_names_gl_ES = static TYPELIB my_locale_typelib_ab_day_names_gl_ES = { array_elements(my_locale_ab_day_names_gl_ES)-1, "", my_locale_ab_day_names_gl_ES, NULL }; MY_LOCALE my_locale_gl_ES= - { "gl_ES", "Galician - Galician", FALSE, &my_locale_typelib_month_names_gl_ES, &my_locale_typelib_ab_month_names_gl_ES, &my_locale_typelib_day_names_gl_ES, &my_locale_typelib_ab_day_names_gl_ES }; +{ + 22, + "gl_ES", + "Galician - Galician", + FALSE, + &my_locale_typelib_month_names_gl_ES, + &my_locale_typelib_ab_month_names_gl_ES, + &my_locale_typelib_day_names_gl_ES, + &my_locale_typelib_ab_day_names_gl_ES +}; /***** LOCALE END gl_ES *****/ /***** LOCALE BEGIN gu_IN: Gujarati - India *****/ @@ -473,7 +642,16 @@ static TYPELIB my_locale_typelib_day_names_gu_IN = static TYPELIB my_locale_typelib_ab_day_names_gu_IN = { array_elements(my_locale_ab_day_names_gu_IN)-1, "", my_locale_ab_day_names_gu_IN, NULL }; MY_LOCALE my_locale_gu_IN= - { "gu_IN", "Gujarati - India", FALSE, &my_locale_typelib_month_names_gu_IN, &my_locale_typelib_ab_month_names_gu_IN, &my_locale_typelib_day_names_gu_IN, &my_locale_typelib_ab_day_names_gu_IN }; +{ + 23, + "gu_IN", + "Gujarati - India", + FALSE, + &my_locale_typelib_month_names_gu_IN, + &my_locale_typelib_ab_month_names_gu_IN, + &my_locale_typelib_day_names_gu_IN, + &my_locale_typelib_ab_day_names_gu_IN +}; /***** LOCALE END gu_IN *****/ /***** LOCALE BEGIN he_IL: Hebrew - Israel *****/ @@ -494,7 +672,16 @@ static TYPELIB my_locale_typelib_day_names_he_IL = static TYPELIB my_locale_typelib_ab_day_names_he_IL = { array_elements(my_locale_ab_day_names_he_IL)-1, "", my_locale_ab_day_names_he_IL, NULL }; MY_LOCALE my_locale_he_IL= - { "he_IL", "Hebrew - Israel", FALSE, &my_locale_typelib_month_names_he_IL, &my_locale_typelib_ab_month_names_he_IL, &my_locale_typelib_day_names_he_IL, &my_locale_typelib_ab_day_names_he_IL }; +{ + 24, + "he_IL", + "Hebrew - Israel", + FALSE, + &my_locale_typelib_month_names_he_IL, + &my_locale_typelib_ab_month_names_he_IL, + &my_locale_typelib_day_names_he_IL, + &my_locale_typelib_ab_day_names_he_IL +}; /***** LOCALE END he_IL *****/ /***** LOCALE BEGIN hi_IN: Hindi - India *****/ @@ -515,7 +702,16 @@ static TYPELIB my_locale_typelib_day_names_hi_IN = static TYPELIB my_locale_typelib_ab_day_names_hi_IN = { array_elements(my_locale_ab_day_names_hi_IN)-1, "", my_locale_ab_day_names_hi_IN, NULL }; MY_LOCALE my_locale_hi_IN= - { "hi_IN", "Hindi - India", FALSE, &my_locale_typelib_month_names_hi_IN, &my_locale_typelib_ab_month_names_hi_IN, &my_locale_typelib_day_names_hi_IN, &my_locale_typelib_ab_day_names_hi_IN }; +{ + 25, + "hi_IN", + "Hindi - India", + FALSE, + &my_locale_typelib_month_names_hi_IN, + &my_locale_typelib_ab_month_names_hi_IN, + &my_locale_typelib_day_names_hi_IN, + &my_locale_typelib_ab_day_names_hi_IN +}; /***** LOCALE END hi_IN *****/ /***** LOCALE BEGIN hr_HR: Croatian - Croatia *****/ @@ -536,7 +732,16 @@ static TYPELIB my_locale_typelib_day_names_hr_HR = static TYPELIB my_locale_typelib_ab_day_names_hr_HR = { array_elements(my_locale_ab_day_names_hr_HR)-1, "", my_locale_ab_day_names_hr_HR, NULL }; MY_LOCALE my_locale_hr_HR= - { "hr_HR", "Croatian - Croatia", FALSE, &my_locale_typelib_month_names_hr_HR, &my_locale_typelib_ab_month_names_hr_HR, &my_locale_typelib_day_names_hr_HR, &my_locale_typelib_ab_day_names_hr_HR }; +{ + 26, + "hr_HR", + "Croatian - Croatia", + FALSE, + &my_locale_typelib_month_names_hr_HR, + &my_locale_typelib_ab_month_names_hr_HR, + &my_locale_typelib_day_names_hr_HR, + &my_locale_typelib_ab_day_names_hr_HR +}; /***** LOCALE END hr_HR *****/ /***** LOCALE BEGIN hu_HU: Hungarian - Hungary *****/ @@ -557,7 +762,16 @@ static TYPELIB my_locale_typelib_day_names_hu_HU = static TYPELIB my_locale_typelib_ab_day_names_hu_HU = { array_elements(my_locale_ab_day_names_hu_HU)-1, "", my_locale_ab_day_names_hu_HU, NULL }; MY_LOCALE my_locale_hu_HU= - { "hu_HU", "Hungarian - Hungary", FALSE, &my_locale_typelib_month_names_hu_HU, &my_locale_typelib_ab_month_names_hu_HU, &my_locale_typelib_day_names_hu_HU, &my_locale_typelib_ab_day_names_hu_HU }; +{ + 27, + "hu_HU", + "Hungarian - Hungary", + FALSE, + &my_locale_typelib_month_names_hu_HU, + &my_locale_typelib_ab_month_names_hu_HU, + &my_locale_typelib_day_names_hu_HU, + &my_locale_typelib_ab_day_names_hu_HU +}; /***** LOCALE END hu_HU *****/ /***** LOCALE BEGIN id_ID: Indonesian - Indonesia *****/ @@ -578,7 +792,16 @@ static TYPELIB my_locale_typelib_day_names_id_ID = static TYPELIB my_locale_typelib_ab_day_names_id_ID = { array_elements(my_locale_ab_day_names_id_ID)-1, "", my_locale_ab_day_names_id_ID, NULL }; MY_LOCALE my_locale_id_ID= - { "id_ID", "Indonesian - Indonesia", TRUE, &my_locale_typelib_month_names_id_ID, &my_locale_typelib_ab_month_names_id_ID, &my_locale_typelib_day_names_id_ID, &my_locale_typelib_ab_day_names_id_ID }; +{ + 28, + "id_ID", + "Indonesian - Indonesia", + TRUE, + &my_locale_typelib_month_names_id_ID, + &my_locale_typelib_ab_month_names_id_ID, + &my_locale_typelib_day_names_id_ID, + &my_locale_typelib_ab_day_names_id_ID +}; /***** LOCALE END id_ID *****/ /***** LOCALE BEGIN is_IS: Icelandic - Iceland *****/ @@ -599,7 +822,16 @@ static TYPELIB my_locale_typelib_day_names_is_IS = static TYPELIB my_locale_typelib_ab_day_names_is_IS = { array_elements(my_locale_ab_day_names_is_IS)-1, "", my_locale_ab_day_names_is_IS, NULL }; MY_LOCALE my_locale_is_IS= - { "is_IS", "Icelandic - Iceland", FALSE, &my_locale_typelib_month_names_is_IS, &my_locale_typelib_ab_month_names_is_IS, &my_locale_typelib_day_names_is_IS, &my_locale_typelib_ab_day_names_is_IS }; +{ + 29, + "is_IS", + "Icelandic - Iceland", + FALSE, + &my_locale_typelib_month_names_is_IS, + &my_locale_typelib_ab_month_names_is_IS, + &my_locale_typelib_day_names_is_IS, + &my_locale_typelib_ab_day_names_is_IS +}; /***** LOCALE END is_IS *****/ /***** LOCALE BEGIN it_CH: Italian - Switzerland *****/ @@ -620,7 +852,16 @@ static TYPELIB my_locale_typelib_day_names_it_CH = static TYPELIB my_locale_typelib_ab_day_names_it_CH = { array_elements(my_locale_ab_day_names_it_CH)-1, "", my_locale_ab_day_names_it_CH, NULL }; MY_LOCALE my_locale_it_CH= - { "it_CH", "Italian - Switzerland", FALSE, &my_locale_typelib_month_names_it_CH, &my_locale_typelib_ab_month_names_it_CH, &my_locale_typelib_day_names_it_CH, &my_locale_typelib_ab_day_names_it_CH }; +{ + 30, + "it_CH", + "Italian - Switzerland", + FALSE, + &my_locale_typelib_month_names_it_CH, + &my_locale_typelib_ab_month_names_it_CH, + &my_locale_typelib_day_names_it_CH, + &my_locale_typelib_ab_day_names_it_CH +}; /***** LOCALE END it_CH *****/ /***** LOCALE BEGIN ja_JP: Japanese - Japan *****/ @@ -641,7 +882,16 @@ static TYPELIB my_locale_typelib_day_names_ja_JP = static TYPELIB my_locale_typelib_ab_day_names_ja_JP = { array_elements(my_locale_ab_day_names_ja_JP)-1, "", my_locale_ab_day_names_ja_JP, NULL }; MY_LOCALE my_locale_ja_JP= - { "ja_JP", "Japanese - Japan", FALSE, &my_locale_typelib_month_names_ja_JP, &my_locale_typelib_ab_month_names_ja_JP, &my_locale_typelib_day_names_ja_JP, &my_locale_typelib_ab_day_names_ja_JP }; +{ + 2, + "ja_JP", + "Japanese - Japan", + FALSE, + &my_locale_typelib_month_names_ja_JP, + &my_locale_typelib_ab_month_names_ja_JP, + &my_locale_typelib_day_names_ja_JP, + &my_locale_typelib_ab_day_names_ja_JP +}; /***** LOCALE END ja_JP *****/ /***** LOCALE BEGIN ko_KR: Korean - Korea *****/ @@ -662,7 +912,16 @@ static TYPELIB my_locale_typelib_day_names_ko_KR = static TYPELIB my_locale_typelib_ab_day_names_ko_KR = { array_elements(my_locale_ab_day_names_ko_KR)-1, "", my_locale_ab_day_names_ko_KR, NULL }; MY_LOCALE my_locale_ko_KR= - { "ko_KR", "Korean - Korea", FALSE, &my_locale_typelib_month_names_ko_KR, &my_locale_typelib_ab_month_names_ko_KR, &my_locale_typelib_day_names_ko_KR, &my_locale_typelib_ab_day_names_ko_KR }; +{ + 31, + "ko_KR", + "Korean - Korea", + FALSE, + &my_locale_typelib_month_names_ko_KR, + &my_locale_typelib_ab_month_names_ko_KR, + &my_locale_typelib_day_names_ko_KR, + &my_locale_typelib_ab_day_names_ko_KR +}; /***** LOCALE END ko_KR *****/ /***** LOCALE BEGIN lt_LT: Lithuanian - Lithuania *****/ @@ -683,7 +942,16 @@ static TYPELIB my_locale_typelib_day_names_lt_LT = static TYPELIB my_locale_typelib_ab_day_names_lt_LT = { array_elements(my_locale_ab_day_names_lt_LT)-1, "", my_locale_ab_day_names_lt_LT, NULL }; MY_LOCALE my_locale_lt_LT= - { "lt_LT", "Lithuanian - Lithuania", FALSE, &my_locale_typelib_month_names_lt_LT, &my_locale_typelib_ab_month_names_lt_LT, &my_locale_typelib_day_names_lt_LT, &my_locale_typelib_ab_day_names_lt_LT }; +{ + 32, + "lt_LT", + "Lithuanian - Lithuania", + FALSE, + &my_locale_typelib_month_names_lt_LT, + &my_locale_typelib_ab_month_names_lt_LT, + &my_locale_typelib_day_names_lt_LT, + &my_locale_typelib_ab_day_names_lt_LT +}; /***** LOCALE END lt_LT *****/ /***** LOCALE BEGIN lv_LV: Latvian - Latvia *****/ @@ -704,7 +972,16 @@ static TYPELIB my_locale_typelib_day_names_lv_LV = static TYPELIB my_locale_typelib_ab_day_names_lv_LV = { array_elements(my_locale_ab_day_names_lv_LV)-1, "", my_locale_ab_day_names_lv_LV, NULL }; MY_LOCALE my_locale_lv_LV= - { "lv_LV", "Latvian - Latvia", FALSE, &my_locale_typelib_month_names_lv_LV, &my_locale_typelib_ab_month_names_lv_LV, &my_locale_typelib_day_names_lv_LV, &my_locale_typelib_ab_day_names_lv_LV }; +{ + 33, + "lv_LV", + "Latvian - Latvia", + FALSE, + &my_locale_typelib_month_names_lv_LV, + &my_locale_typelib_ab_month_names_lv_LV, + &my_locale_typelib_day_names_lv_LV, + &my_locale_typelib_ab_day_names_lv_LV +}; /***** LOCALE END lv_LV *****/ /***** LOCALE BEGIN mk_MK: Macedonian - FYROM *****/ @@ -725,7 +1002,16 @@ static TYPELIB my_locale_typelib_day_names_mk_MK = static TYPELIB my_locale_typelib_ab_day_names_mk_MK = { array_elements(my_locale_ab_day_names_mk_MK)-1, "", my_locale_ab_day_names_mk_MK, NULL }; MY_LOCALE my_locale_mk_MK= - { "mk_MK", "Macedonian - FYROM", FALSE, &my_locale_typelib_month_names_mk_MK, &my_locale_typelib_ab_month_names_mk_MK, &my_locale_typelib_day_names_mk_MK, &my_locale_typelib_ab_day_names_mk_MK }; +{ + 34, + "mk_MK", + "Macedonian - FYROM", + FALSE, + &my_locale_typelib_month_names_mk_MK, + &my_locale_typelib_ab_month_names_mk_MK, + &my_locale_typelib_day_names_mk_MK, + &my_locale_typelib_ab_day_names_mk_MK +}; /***** LOCALE END mk_MK *****/ /***** LOCALE BEGIN mn_MN: Mongolia - Mongolian *****/ @@ -746,7 +1032,16 @@ static TYPELIB my_locale_typelib_day_names_mn_MN = static TYPELIB my_locale_typelib_ab_day_names_mn_MN = { array_elements(my_locale_ab_day_names_mn_MN)-1, "", my_locale_ab_day_names_mn_MN, NULL }; MY_LOCALE my_locale_mn_MN= - { "mn_MN", "Mongolia - Mongolian", FALSE, &my_locale_typelib_month_names_mn_MN, &my_locale_typelib_ab_month_names_mn_MN, &my_locale_typelib_day_names_mn_MN, &my_locale_typelib_ab_day_names_mn_MN }; +{ + 35, + "mn_MN", + "Mongolia - Mongolian", + FALSE, + &my_locale_typelib_month_names_mn_MN, + &my_locale_typelib_ab_month_names_mn_MN, + &my_locale_typelib_day_names_mn_MN, + &my_locale_typelib_ab_day_names_mn_MN +}; /***** LOCALE END mn_MN *****/ /***** LOCALE BEGIN ms_MY: Malay - Malaysia *****/ @@ -767,7 +1062,16 @@ static TYPELIB my_locale_typelib_day_names_ms_MY = static TYPELIB my_locale_typelib_ab_day_names_ms_MY = { array_elements(my_locale_ab_day_names_ms_MY)-1, "", my_locale_ab_day_names_ms_MY, NULL }; MY_LOCALE my_locale_ms_MY= - { "ms_MY", "Malay - Malaysia", TRUE, &my_locale_typelib_month_names_ms_MY, &my_locale_typelib_ab_month_names_ms_MY, &my_locale_typelib_day_names_ms_MY, &my_locale_typelib_ab_day_names_ms_MY }; +{ + 36, + "ms_MY", + "Malay - Malaysia", + TRUE, + &my_locale_typelib_month_names_ms_MY, + &my_locale_typelib_ab_month_names_ms_MY, + &my_locale_typelib_day_names_ms_MY, + &my_locale_typelib_ab_day_names_ms_MY +}; /***** LOCALE END ms_MY *****/ /***** LOCALE BEGIN nb_NO: Norwegian(Bokml) - Norway *****/ @@ -788,7 +1092,16 @@ static TYPELIB my_locale_typelib_day_names_nb_NO = static TYPELIB my_locale_typelib_ab_day_names_nb_NO = { array_elements(my_locale_ab_day_names_nb_NO)-1, "", my_locale_ab_day_names_nb_NO, NULL }; MY_LOCALE my_locale_nb_NO= - { "nb_NO", "Norwegian(Bokml) - Norway", FALSE, &my_locale_typelib_month_names_nb_NO, &my_locale_typelib_ab_month_names_nb_NO, &my_locale_typelib_day_names_nb_NO, &my_locale_typelib_ab_day_names_nb_NO }; +{ + 37, + "nb_NO", + "Norwegian(Bokml) - Norway", + FALSE, + &my_locale_typelib_month_names_nb_NO, + &my_locale_typelib_ab_month_names_nb_NO, + &my_locale_typelib_day_names_nb_NO, + &my_locale_typelib_ab_day_names_nb_NO +}; /***** LOCALE END nb_NO *****/ /***** LOCALE BEGIN nl_NL: Dutch - The Netherlands *****/ @@ -809,7 +1122,16 @@ static TYPELIB my_locale_typelib_day_names_nl_NL = static TYPELIB my_locale_typelib_ab_day_names_nl_NL = { array_elements(my_locale_ab_day_names_nl_NL)-1, "", my_locale_ab_day_names_nl_NL, NULL }; MY_LOCALE my_locale_nl_NL= - { "nl_NL", "Dutch - The Netherlands", TRUE, &my_locale_typelib_month_names_nl_NL, &my_locale_typelib_ab_month_names_nl_NL, &my_locale_typelib_day_names_nl_NL, &my_locale_typelib_ab_day_names_nl_NL }; +{ + 38, + "nl_NL", + "Dutch - The Netherlands", + TRUE, + &my_locale_typelib_month_names_nl_NL, + &my_locale_typelib_ab_month_names_nl_NL, + &my_locale_typelib_day_names_nl_NL, + &my_locale_typelib_ab_day_names_nl_NL +}; /***** LOCALE END nl_NL *****/ /***** LOCALE BEGIN pl_PL: Polish - Poland *****/ @@ -830,7 +1152,16 @@ static TYPELIB my_locale_typelib_day_names_pl_PL = static TYPELIB my_locale_typelib_ab_day_names_pl_PL = { array_elements(my_locale_ab_day_names_pl_PL)-1, "", my_locale_ab_day_names_pl_PL, NULL }; MY_LOCALE my_locale_pl_PL= - { "pl_PL", "Polish - Poland", FALSE, &my_locale_typelib_month_names_pl_PL, &my_locale_typelib_ab_month_names_pl_PL, &my_locale_typelib_day_names_pl_PL, &my_locale_typelib_ab_day_names_pl_PL }; +{ + 39, + "pl_PL", + "Polish - Poland", + FALSE, + &my_locale_typelib_month_names_pl_PL, + &my_locale_typelib_ab_month_names_pl_PL, + &my_locale_typelib_day_names_pl_PL, + &my_locale_typelib_ab_day_names_pl_PL +}; /***** LOCALE END pl_PL *****/ /***** LOCALE BEGIN pt_BR: Portugese - Brazil *****/ @@ -851,7 +1182,16 @@ static TYPELIB my_locale_typelib_day_names_pt_BR = static TYPELIB my_locale_typelib_ab_day_names_pt_BR = { array_elements(my_locale_ab_day_names_pt_BR)-1, "", my_locale_ab_day_names_pt_BR, NULL }; MY_LOCALE my_locale_pt_BR= - { "pt_BR", "Portugese - Brazil", FALSE, &my_locale_typelib_month_names_pt_BR, &my_locale_typelib_ab_month_names_pt_BR, &my_locale_typelib_day_names_pt_BR, &my_locale_typelib_ab_day_names_pt_BR }; +{ + 40, + "pt_BR", + "Portugese - Brazil", + FALSE, + &my_locale_typelib_month_names_pt_BR, + &my_locale_typelib_ab_month_names_pt_BR, + &my_locale_typelib_day_names_pt_BR, + &my_locale_typelib_ab_day_names_pt_BR +}; /***** LOCALE END pt_BR *****/ /***** LOCALE BEGIN pt_PT: Portugese - Portugal *****/ @@ -872,7 +1212,16 @@ static TYPELIB my_locale_typelib_day_names_pt_PT = static TYPELIB my_locale_typelib_ab_day_names_pt_PT = { array_elements(my_locale_ab_day_names_pt_PT)-1, "", my_locale_ab_day_names_pt_PT, NULL }; MY_LOCALE my_locale_pt_PT= - { "pt_PT", "Portugese - Portugal", FALSE, &my_locale_typelib_month_names_pt_PT, &my_locale_typelib_ab_month_names_pt_PT, &my_locale_typelib_day_names_pt_PT, &my_locale_typelib_ab_day_names_pt_PT }; +{ + 41, + "pt_PT", + "Portugese - Portugal", + FALSE, + &my_locale_typelib_month_names_pt_PT, + &my_locale_typelib_ab_month_names_pt_PT, + &my_locale_typelib_day_names_pt_PT, + &my_locale_typelib_ab_day_names_pt_PT +}; /***** LOCALE END pt_PT *****/ /***** LOCALE BEGIN ro_RO: Romanian - Romania *****/ @@ -893,7 +1242,16 @@ static TYPELIB my_locale_typelib_day_names_ro_RO = static TYPELIB my_locale_typelib_ab_day_names_ro_RO = { array_elements(my_locale_ab_day_names_ro_RO)-1, "", my_locale_ab_day_names_ro_RO, NULL }; MY_LOCALE my_locale_ro_RO= - { "ro_RO", "Romanian - Romania", FALSE, &my_locale_typelib_month_names_ro_RO, &my_locale_typelib_ab_month_names_ro_RO, &my_locale_typelib_day_names_ro_RO, &my_locale_typelib_ab_day_names_ro_RO }; +{ + 42, + "ro_RO", + "Romanian - Romania", + FALSE, + &my_locale_typelib_month_names_ro_RO, + &my_locale_typelib_ab_month_names_ro_RO, + &my_locale_typelib_day_names_ro_RO, + &my_locale_typelib_ab_day_names_ro_RO +}; /***** LOCALE END ro_RO *****/ /***** LOCALE BEGIN ru_RU: Russian - Russia *****/ @@ -914,7 +1272,16 @@ static TYPELIB my_locale_typelib_day_names_ru_RU = static TYPELIB my_locale_typelib_ab_day_names_ru_RU = { array_elements(my_locale_ab_day_names_ru_RU)-1, "", my_locale_ab_day_names_ru_RU, NULL }; MY_LOCALE my_locale_ru_RU= - { "ru_RU", "Russian - Russia", FALSE, &my_locale_typelib_month_names_ru_RU, &my_locale_typelib_ab_month_names_ru_RU, &my_locale_typelib_day_names_ru_RU, &my_locale_typelib_ab_day_names_ru_RU }; +{ + 43, + "ru_RU", + "Russian - Russia", + FALSE, + &my_locale_typelib_month_names_ru_RU, + &my_locale_typelib_ab_month_names_ru_RU, + &my_locale_typelib_day_names_ru_RU, + &my_locale_typelib_ab_day_names_ru_RU +}; /***** LOCALE END ru_RU *****/ /***** LOCALE BEGIN ru_UA: Russian - Ukraine *****/ @@ -935,7 +1302,16 @@ static TYPELIB my_locale_typelib_day_names_ru_UA = static TYPELIB my_locale_typelib_ab_day_names_ru_UA = { array_elements(my_locale_ab_day_names_ru_UA)-1, "", my_locale_ab_day_names_ru_UA, NULL }; MY_LOCALE my_locale_ru_UA= - { "ru_UA", "Russian - Ukraine", FALSE, &my_locale_typelib_month_names_ru_UA, &my_locale_typelib_ab_month_names_ru_UA, &my_locale_typelib_day_names_ru_UA, &my_locale_typelib_ab_day_names_ru_UA }; +{ + 44, + "ru_UA", + "Russian - Ukraine", + FALSE, + &my_locale_typelib_month_names_ru_UA, + &my_locale_typelib_ab_month_names_ru_UA, + &my_locale_typelib_day_names_ru_UA, + &my_locale_typelib_ab_day_names_ru_UA +}; /***** LOCALE END ru_UA *****/ /***** LOCALE BEGIN sk_SK: Slovak - Slovakia *****/ @@ -956,7 +1332,16 @@ static TYPELIB my_locale_typelib_day_names_sk_SK = static TYPELIB my_locale_typelib_ab_day_names_sk_SK = { array_elements(my_locale_ab_day_names_sk_SK)-1, "", my_locale_ab_day_names_sk_SK, NULL }; MY_LOCALE my_locale_sk_SK= - { "sk_SK", "Slovak - Slovakia", FALSE, &my_locale_typelib_month_names_sk_SK, &my_locale_typelib_ab_month_names_sk_SK, &my_locale_typelib_day_names_sk_SK, &my_locale_typelib_ab_day_names_sk_SK }; +{ + 45, + "sk_SK", + "Slovak - Slovakia", + FALSE, + &my_locale_typelib_month_names_sk_SK, + &my_locale_typelib_ab_month_names_sk_SK, + &my_locale_typelib_day_names_sk_SK, + &my_locale_typelib_ab_day_names_sk_SK +}; /***** LOCALE END sk_SK *****/ /***** LOCALE BEGIN sl_SI: Slovenian - Slovenia *****/ @@ -977,7 +1362,16 @@ static TYPELIB my_locale_typelib_day_names_sl_SI = static TYPELIB my_locale_typelib_ab_day_names_sl_SI = { array_elements(my_locale_ab_day_names_sl_SI)-1, "", my_locale_ab_day_names_sl_SI, NULL }; MY_LOCALE my_locale_sl_SI= - { "sl_SI", "Slovenian - Slovenia", FALSE, &my_locale_typelib_month_names_sl_SI, &my_locale_typelib_ab_month_names_sl_SI, &my_locale_typelib_day_names_sl_SI, &my_locale_typelib_ab_day_names_sl_SI }; +{ + 46, + "sl_SI", + "Slovenian - Slovenia", + FALSE, + &my_locale_typelib_month_names_sl_SI, + &my_locale_typelib_ab_month_names_sl_SI, + &my_locale_typelib_day_names_sl_SI, + &my_locale_typelib_ab_day_names_sl_SI +}; /***** LOCALE END sl_SI *****/ /***** LOCALE BEGIN sq_AL: Albanian - Albania *****/ @@ -998,7 +1392,16 @@ static TYPELIB my_locale_typelib_day_names_sq_AL = static TYPELIB my_locale_typelib_ab_day_names_sq_AL = { array_elements(my_locale_ab_day_names_sq_AL)-1, "", my_locale_ab_day_names_sq_AL, NULL }; MY_LOCALE my_locale_sq_AL= - { "sq_AL", "Albanian - Albania", FALSE, &my_locale_typelib_month_names_sq_AL, &my_locale_typelib_ab_month_names_sq_AL, &my_locale_typelib_day_names_sq_AL, &my_locale_typelib_ab_day_names_sq_AL }; +{ + 47, + "sq_AL", + "Albanian - Albania", + FALSE, + &my_locale_typelib_month_names_sq_AL, + &my_locale_typelib_ab_month_names_sq_AL, + &my_locale_typelib_day_names_sq_AL, + &my_locale_typelib_ab_day_names_sq_AL +}; /***** LOCALE END sq_AL *****/ /***** LOCALE BEGIN sr_YU: Servian - Yugoslavia *****/ @@ -1019,7 +1422,16 @@ static TYPELIB my_locale_typelib_day_names_sr_YU = static TYPELIB my_locale_typelib_ab_day_names_sr_YU = { array_elements(my_locale_ab_day_names_sr_YU)-1, "", my_locale_ab_day_names_sr_YU, NULL }; MY_LOCALE my_locale_sr_YU= - { "sr_YU", "Servian - Yugoslavia", FALSE, &my_locale_typelib_month_names_sr_YU, &my_locale_typelib_ab_month_names_sr_YU, &my_locale_typelib_day_names_sr_YU, &my_locale_typelib_ab_day_names_sr_YU }; +{ + 48, + "sr_YU", + "Servian - Yugoslavia", + FALSE, + &my_locale_typelib_month_names_sr_YU, + &my_locale_typelib_ab_month_names_sr_YU, + &my_locale_typelib_day_names_sr_YU, + &my_locale_typelib_ab_day_names_sr_YU +}; /***** LOCALE END sr_YU *****/ /***** LOCALE BEGIN sv_SE: Swedish - Sweden *****/ @@ -1040,7 +1452,16 @@ static TYPELIB my_locale_typelib_day_names_sv_SE = static TYPELIB my_locale_typelib_ab_day_names_sv_SE = { array_elements(my_locale_ab_day_names_sv_SE)-1, "", my_locale_ab_day_names_sv_SE, NULL }; MY_LOCALE my_locale_sv_SE= - { "sv_SE", "Swedish - Sweden", FALSE, &my_locale_typelib_month_names_sv_SE, &my_locale_typelib_ab_month_names_sv_SE, &my_locale_typelib_day_names_sv_SE, &my_locale_typelib_ab_day_names_sv_SE }; +{ + 3, + "sv_SE", + "Swedish - Sweden", + FALSE, + &my_locale_typelib_month_names_sv_SE, + &my_locale_typelib_ab_month_names_sv_SE, + &my_locale_typelib_day_names_sv_SE, + &my_locale_typelib_ab_day_names_sv_SE +}; /***** LOCALE END sv_SE *****/ /***** LOCALE BEGIN ta_IN: Tamil - India *****/ @@ -1061,7 +1482,16 @@ static TYPELIB my_locale_typelib_day_names_ta_IN = static TYPELIB my_locale_typelib_ab_day_names_ta_IN = { array_elements(my_locale_ab_day_names_ta_IN)-1, "", my_locale_ab_day_names_ta_IN, NULL }; MY_LOCALE my_locale_ta_IN= - { "ta_IN", "Tamil - India", FALSE, &my_locale_typelib_month_names_ta_IN, &my_locale_typelib_ab_month_names_ta_IN, &my_locale_typelib_day_names_ta_IN, &my_locale_typelib_ab_day_names_ta_IN }; +{ + 49, + "ta_IN", + "Tamil - India", + FALSE, + &my_locale_typelib_month_names_ta_IN, + &my_locale_typelib_ab_month_names_ta_IN, + &my_locale_typelib_day_names_ta_IN, + &my_locale_typelib_ab_day_names_ta_IN +}; /***** LOCALE END ta_IN *****/ /***** LOCALE BEGIN te_IN: Telugu - India *****/ @@ -1082,7 +1512,16 @@ static TYPELIB my_locale_typelib_day_names_te_IN = static TYPELIB my_locale_typelib_ab_day_names_te_IN = { array_elements(my_locale_ab_day_names_te_IN)-1, "", my_locale_ab_day_names_te_IN, NULL }; MY_LOCALE my_locale_te_IN= - { "te_IN", "Telugu - India", FALSE, &my_locale_typelib_month_names_te_IN, &my_locale_typelib_ab_month_names_te_IN, &my_locale_typelib_day_names_te_IN, &my_locale_typelib_ab_day_names_te_IN }; +{ + 50, + "te_IN", + "Telugu - India", + FALSE, + &my_locale_typelib_month_names_te_IN, + &my_locale_typelib_ab_month_names_te_IN, + &my_locale_typelib_day_names_te_IN, + &my_locale_typelib_ab_day_names_te_IN +}; /***** LOCALE END te_IN *****/ /***** LOCALE BEGIN th_TH: Thai - Thailand *****/ @@ -1103,7 +1542,16 @@ static TYPELIB my_locale_typelib_day_names_th_TH = static TYPELIB my_locale_typelib_ab_day_names_th_TH = { array_elements(my_locale_ab_day_names_th_TH)-1, "", my_locale_ab_day_names_th_TH, NULL }; MY_LOCALE my_locale_th_TH= - { "th_TH", "Thai - Thailand", FALSE, &my_locale_typelib_month_names_th_TH, &my_locale_typelib_ab_month_names_th_TH, &my_locale_typelib_day_names_th_TH, &my_locale_typelib_ab_day_names_th_TH }; +{ + 51, + "th_TH", + "Thai - Thailand", + FALSE, + &my_locale_typelib_month_names_th_TH, + &my_locale_typelib_ab_month_names_th_TH, + &my_locale_typelib_day_names_th_TH, + &my_locale_typelib_ab_day_names_th_TH +}; /***** LOCALE END th_TH *****/ /***** LOCALE BEGIN tr_TR: Turkish - Turkey *****/ @@ -1124,7 +1572,16 @@ static TYPELIB my_locale_typelib_day_names_tr_TR = static TYPELIB my_locale_typelib_ab_day_names_tr_TR = { array_elements(my_locale_ab_day_names_tr_TR)-1, "", my_locale_ab_day_names_tr_TR, NULL }; MY_LOCALE my_locale_tr_TR= - { "tr_TR", "Turkish - Turkey", FALSE, &my_locale_typelib_month_names_tr_TR, &my_locale_typelib_ab_month_names_tr_TR, &my_locale_typelib_day_names_tr_TR, &my_locale_typelib_ab_day_names_tr_TR }; +{ + 52, + "tr_TR", + "Turkish - Turkey", + FALSE, + &my_locale_typelib_month_names_tr_TR, + &my_locale_typelib_ab_month_names_tr_TR, + &my_locale_typelib_day_names_tr_TR, + &my_locale_typelib_ab_day_names_tr_TR +}; /***** LOCALE END tr_TR *****/ /***** LOCALE BEGIN uk_UA: Ukrainian - Ukraine *****/ @@ -1145,7 +1602,16 @@ static TYPELIB my_locale_typelib_day_names_uk_UA = static TYPELIB my_locale_typelib_ab_day_names_uk_UA = { array_elements(my_locale_ab_day_names_uk_UA)-1, "", my_locale_ab_day_names_uk_UA, NULL }; MY_LOCALE my_locale_uk_UA= - { "uk_UA", "Ukrainian - Ukraine", FALSE, &my_locale_typelib_month_names_uk_UA, &my_locale_typelib_ab_month_names_uk_UA, &my_locale_typelib_day_names_uk_UA, &my_locale_typelib_ab_day_names_uk_UA }; +{ + 53, + "uk_UA", + "Ukrainian - Ukraine", + FALSE, + &my_locale_typelib_month_names_uk_UA, + &my_locale_typelib_ab_month_names_uk_UA, + &my_locale_typelib_day_names_uk_UA, + &my_locale_typelib_ab_day_names_uk_UA +}; /***** LOCALE END uk_UA *****/ /***** LOCALE BEGIN ur_PK: Urdu - Pakistan *****/ @@ -1166,7 +1632,16 @@ static TYPELIB my_locale_typelib_day_names_ur_PK = static TYPELIB my_locale_typelib_ab_day_names_ur_PK = { array_elements(my_locale_ab_day_names_ur_PK)-1, "", my_locale_ab_day_names_ur_PK, NULL }; MY_LOCALE my_locale_ur_PK= - { "ur_PK", "Urdu - Pakistan", FALSE, &my_locale_typelib_month_names_ur_PK, &my_locale_typelib_ab_month_names_ur_PK, &my_locale_typelib_day_names_ur_PK, &my_locale_typelib_ab_day_names_ur_PK }; +{ + 54, + "ur_PK", + "Urdu - Pakistan", + FALSE, + &my_locale_typelib_month_names_ur_PK, + &my_locale_typelib_ab_month_names_ur_PK, + &my_locale_typelib_day_names_ur_PK, + &my_locale_typelib_ab_day_names_ur_PK +}; /***** LOCALE END ur_PK *****/ /***** LOCALE BEGIN vi_VN: Vietnamese - Vietnam *****/ @@ -1187,7 +1662,16 @@ static TYPELIB my_locale_typelib_day_names_vi_VN = static TYPELIB my_locale_typelib_ab_day_names_vi_VN = { array_elements(my_locale_ab_day_names_vi_VN)-1, "", my_locale_ab_day_names_vi_VN, NULL }; MY_LOCALE my_locale_vi_VN= - { "vi_VN", "Vietnamese - Vietnam", FALSE, &my_locale_typelib_month_names_vi_VN, &my_locale_typelib_ab_month_names_vi_VN, &my_locale_typelib_day_names_vi_VN, &my_locale_typelib_ab_day_names_vi_VN }; +{ + 55, + "vi_VN", + "Vietnamese - Vietnam", + FALSE, + &my_locale_typelib_month_names_vi_VN, + &my_locale_typelib_ab_month_names_vi_VN, + &my_locale_typelib_day_names_vi_VN, + &my_locale_typelib_ab_day_names_vi_VN +}; /***** LOCALE END vi_VN *****/ /***** LOCALE BEGIN zh_CN: Chinese - Peoples Republic of China *****/ @@ -1208,7 +1692,16 @@ static TYPELIB my_locale_typelib_day_names_zh_CN = static TYPELIB my_locale_typelib_ab_day_names_zh_CN = { array_elements(my_locale_ab_day_names_zh_CN)-1, "", my_locale_ab_day_names_zh_CN, NULL }; MY_LOCALE my_locale_zh_CN= - { "zh_CN", "Chinese - Peoples Republic of China", FALSE, &my_locale_typelib_month_names_zh_CN, &my_locale_typelib_ab_month_names_zh_CN, &my_locale_typelib_day_names_zh_CN, &my_locale_typelib_ab_day_names_zh_CN }; +{ + 56, + "zh_CN", + "Chinese - Peoples Republic of China", + FALSE, + &my_locale_typelib_month_names_zh_CN, + &my_locale_typelib_ab_month_names_zh_CN, + &my_locale_typelib_day_names_zh_CN, + &my_locale_typelib_ab_day_names_zh_CN +}; /***** LOCALE END zh_CN *****/ /***** LOCALE BEGIN zh_TW: Chinese - Taiwan *****/ @@ -1229,269 +1722,753 @@ static TYPELIB my_locale_typelib_day_names_zh_TW = static TYPELIB my_locale_typelib_ab_day_names_zh_TW = { array_elements(my_locale_ab_day_names_zh_TW)-1, "", my_locale_ab_day_names_zh_TW, NULL }; MY_LOCALE my_locale_zh_TW= - { "zh_TW", "Chinese - Taiwan", FALSE, &my_locale_typelib_month_names_zh_TW, &my_locale_typelib_ab_month_names_zh_TW, &my_locale_typelib_day_names_zh_TW, &my_locale_typelib_ab_day_names_zh_TW }; +{ + 57, + "zh_TW", + "Chinese - Taiwan", + FALSE, + &my_locale_typelib_month_names_zh_TW, + &my_locale_typelib_ab_month_names_zh_TW, + &my_locale_typelib_day_names_zh_TW, + &my_locale_typelib_ab_day_names_zh_TW +}; /***** LOCALE END zh_TW *****/ /***** LOCALE BEGIN ar_DZ: Arabic - Algeria *****/ MY_LOCALE my_locale_ar_DZ= - { "ar_DZ", "Arabic - Algeria", FALSE, &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, &my_locale_typelib_ab_day_names_ar_BH }; +{ + 58, + "ar_DZ", + "Arabic - Algeria", + FALSE, + &my_locale_typelib_month_names_ar_BH, + &my_locale_typelib_ab_month_names_ar_BH, + &my_locale_typelib_day_names_ar_BH, + &my_locale_typelib_ab_day_names_ar_BH +}; /***** LOCALE END ar_DZ *****/ /***** LOCALE BEGIN ar_EG: Arabic - Egypt *****/ MY_LOCALE my_locale_ar_EG= - { "ar_EG", "Arabic - Egypt", FALSE, &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, &my_locale_typelib_ab_day_names_ar_BH }; +{ + 59, + "ar_EG", + "Arabic - Egypt", + FALSE, + &my_locale_typelib_month_names_ar_BH, + &my_locale_typelib_ab_month_names_ar_BH, + &my_locale_typelib_day_names_ar_BH, + &my_locale_typelib_ab_day_names_ar_BH +}; /***** LOCALE END ar_EG *****/ /***** LOCALE BEGIN ar_IN: Arabic - Iran *****/ MY_LOCALE my_locale_ar_IN= - { "ar_IN", "Arabic - Iran", FALSE, &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, &my_locale_typelib_ab_day_names_ar_BH }; +{ + 60, + "ar_IN", + "Arabic - Iran", + FALSE, + &my_locale_typelib_month_names_ar_BH, + &my_locale_typelib_ab_month_names_ar_BH, + &my_locale_typelib_day_names_ar_BH, + &my_locale_typelib_ab_day_names_ar_BH +}; /***** LOCALE END ar_IN *****/ /***** LOCALE BEGIN ar_IQ: Arabic - Iraq *****/ MY_LOCALE my_locale_ar_IQ= - { "ar_IQ", "Arabic - Iraq", FALSE, &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, &my_locale_typelib_ab_day_names_ar_BH }; +{ + 61, + "ar_IQ", + "Arabic - Iraq", + FALSE, + &my_locale_typelib_month_names_ar_BH, + &my_locale_typelib_ab_month_names_ar_BH, + &my_locale_typelib_day_names_ar_BH, + &my_locale_typelib_ab_day_names_ar_BH +}; /***** LOCALE END ar_IQ *****/ /***** LOCALE BEGIN ar_KW: Arabic - Kuwait *****/ MY_LOCALE my_locale_ar_KW= - { "ar_KW", "Arabic - Kuwait", FALSE, &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, &my_locale_typelib_ab_day_names_ar_BH }; +{ + 62, + "ar_KW", + "Arabic - Kuwait", + FALSE, + &my_locale_typelib_month_names_ar_BH, + &my_locale_typelib_ab_month_names_ar_BH, + &my_locale_typelib_day_names_ar_BH, + &my_locale_typelib_ab_day_names_ar_BH +}; /***** LOCALE END ar_KW *****/ /***** LOCALE BEGIN ar_LB: Arabic - Lebanon *****/ MY_LOCALE my_locale_ar_LB= - { "ar_LB", "Arabic - Lebanon", FALSE, &my_locale_typelib_month_names_ar_JO, &my_locale_typelib_ab_month_names_ar_JO, &my_locale_typelib_day_names_ar_JO, &my_locale_typelib_ab_day_names_ar_JO }; +{ + 63, + "ar_LB", + "Arabic - Lebanon", + FALSE, + &my_locale_typelib_month_names_ar_JO, + &my_locale_typelib_ab_month_names_ar_JO, + &my_locale_typelib_day_names_ar_JO, + &my_locale_typelib_ab_day_names_ar_JO +}; /***** LOCALE END ar_LB *****/ /***** LOCALE BEGIN ar_LY: Arabic - Libya *****/ MY_LOCALE my_locale_ar_LY= - { "ar_LY", "Arabic - Libya", FALSE, &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, &my_locale_typelib_ab_day_names_ar_BH }; +{ + 64, + "ar_LY", + "Arabic - Libya", + FALSE, + &my_locale_typelib_month_names_ar_BH, + &my_locale_typelib_ab_month_names_ar_BH, + &my_locale_typelib_day_names_ar_BH, + &my_locale_typelib_ab_day_names_ar_BH +}; /***** LOCALE END ar_LY *****/ /***** LOCALE BEGIN ar_MA: Arabic - Morocco *****/ MY_LOCALE my_locale_ar_MA= - { "ar_MA", "Arabic - Morocco", FALSE, &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, &my_locale_typelib_ab_day_names_ar_BH }; +{ + 65, + "ar_MA", + "Arabic - Morocco", + FALSE, + &my_locale_typelib_month_names_ar_BH, + &my_locale_typelib_ab_month_names_ar_BH, + &my_locale_typelib_day_names_ar_BH, + &my_locale_typelib_ab_day_names_ar_BH +}; /***** LOCALE END ar_MA *****/ /***** LOCALE BEGIN ar_OM: Arabic - Oman *****/ MY_LOCALE my_locale_ar_OM= - { "ar_OM", "Arabic - Oman", FALSE, &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, &my_locale_typelib_ab_day_names_ar_BH }; +{ + 66, + "ar_OM", + "Arabic - Oman", + FALSE, + &my_locale_typelib_month_names_ar_BH, + &my_locale_typelib_ab_month_names_ar_BH, + &my_locale_typelib_day_names_ar_BH, + &my_locale_typelib_ab_day_names_ar_BH +}; /***** LOCALE END ar_OM *****/ /***** LOCALE BEGIN ar_QA: Arabic - Qatar *****/ MY_LOCALE my_locale_ar_QA= - { "ar_QA", "Arabic - Qatar", FALSE, &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, &my_locale_typelib_ab_day_names_ar_BH }; +{ + 67, + "ar_QA", + "Arabic - Qatar", + FALSE, + &my_locale_typelib_month_names_ar_BH, + &my_locale_typelib_ab_month_names_ar_BH, + &my_locale_typelib_day_names_ar_BH, + &my_locale_typelib_ab_day_names_ar_BH +}; /***** LOCALE END ar_QA *****/ /***** LOCALE BEGIN ar_SD: Arabic - Sudan *****/ MY_LOCALE my_locale_ar_SD= - { "ar_SD", "Arabic - Sudan", FALSE, &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, &my_locale_typelib_ab_day_names_ar_BH }; +{ + 68, + "ar_SD", + "Arabic - Sudan", + FALSE, + &my_locale_typelib_month_names_ar_BH, + &my_locale_typelib_ab_month_names_ar_BH, + &my_locale_typelib_day_names_ar_BH, + &my_locale_typelib_ab_day_names_ar_BH +}; /***** LOCALE END ar_SD *****/ /***** LOCALE BEGIN ar_TN: Arabic - Tunisia *****/ MY_LOCALE my_locale_ar_TN= - { "ar_TN", "Arabic - Tunisia", FALSE, &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, &my_locale_typelib_ab_day_names_ar_BH }; +{ + 69, + "ar_TN", + "Arabic - Tunisia", + FALSE, + &my_locale_typelib_month_names_ar_BH, + &my_locale_typelib_ab_month_names_ar_BH, + &my_locale_typelib_day_names_ar_BH, + &my_locale_typelib_ab_day_names_ar_BH +}; /***** LOCALE END ar_TN *****/ /***** LOCALE BEGIN ar_YE: Arabic - Yemen *****/ MY_LOCALE my_locale_ar_YE= - { "ar_YE", "Arabic - Yemen", FALSE, &my_locale_typelib_month_names_ar_BH, &my_locale_typelib_ab_month_names_ar_BH, &my_locale_typelib_day_names_ar_BH, &my_locale_typelib_ab_day_names_ar_BH }; +{ + 70, + "ar_YE", + "Arabic - Yemen", + FALSE, + &my_locale_typelib_month_names_ar_BH, + &my_locale_typelib_ab_month_names_ar_BH, + &my_locale_typelib_day_names_ar_BH, + &my_locale_typelib_ab_day_names_ar_BH +}; /***** LOCALE END ar_YE *****/ /***** LOCALE BEGIN de_BE: German - Belgium *****/ MY_LOCALE my_locale_de_BE= - { "de_BE", "German - Belgium", FALSE, &my_locale_typelib_month_names_de_DE, &my_locale_typelib_ab_month_names_de_DE, &my_locale_typelib_day_names_de_DE, &my_locale_typelib_ab_day_names_de_DE }; +{ + 71, + "de_BE", + "German - Belgium", + FALSE, + &my_locale_typelib_month_names_de_DE, + &my_locale_typelib_ab_month_names_de_DE, + &my_locale_typelib_day_names_de_DE, + &my_locale_typelib_ab_day_names_de_DE +}; /***** LOCALE END de_BE *****/ /***** LOCALE BEGIN de_CH: German - Switzerland *****/ MY_LOCALE my_locale_de_CH= - { "de_CH", "German - Switzerland", FALSE, &my_locale_typelib_month_names_de_DE, &my_locale_typelib_ab_month_names_de_DE, &my_locale_typelib_day_names_de_DE, &my_locale_typelib_ab_day_names_de_DE }; +{ + 72, + "de_CH", + "German - Switzerland", + FALSE, + &my_locale_typelib_month_names_de_DE, + &my_locale_typelib_ab_month_names_de_DE, + &my_locale_typelib_day_names_de_DE, + &my_locale_typelib_ab_day_names_de_DE +}; /***** LOCALE END de_CH *****/ /***** LOCALE BEGIN de_LU: German - Luxembourg *****/ MY_LOCALE my_locale_de_LU= - { "de_LU", "German - Luxembourg", FALSE, &my_locale_typelib_month_names_de_DE, &my_locale_typelib_ab_month_names_de_DE, &my_locale_typelib_day_names_de_DE, &my_locale_typelib_ab_day_names_de_DE }; +{ + 73, + "de_LU", + "German - Luxembourg", + FALSE, + &my_locale_typelib_month_names_de_DE, + &my_locale_typelib_ab_month_names_de_DE, + &my_locale_typelib_day_names_de_DE, + &my_locale_typelib_ab_day_names_de_DE +}; /***** LOCALE END de_LU *****/ /***** LOCALE BEGIN en_AU: English - Australia *****/ MY_LOCALE my_locale_en_AU= - { "en_AU", "English - Australia", TRUE, &my_locale_typelib_month_names_en_US, &my_locale_typelib_ab_month_names_en_US, &my_locale_typelib_day_names_en_US, &my_locale_typelib_ab_day_names_en_US }; +{ + 74, + "en_AU", + "English - Australia", + TRUE, + &my_locale_typelib_month_names_en_US, + &my_locale_typelib_ab_month_names_en_US, + &my_locale_typelib_day_names_en_US, + &my_locale_typelib_ab_day_names_en_US +}; /***** LOCALE END en_AU *****/ /***** LOCALE BEGIN en_CA: English - Canada *****/ MY_LOCALE my_locale_en_CA= - { "en_CA", "English - Canada", TRUE, &my_locale_typelib_month_names_en_US, &my_locale_typelib_ab_month_names_en_US, &my_locale_typelib_day_names_en_US, &my_locale_typelib_ab_day_names_en_US }; +{ + 75, + "en_CA", + "English - Canada", + TRUE, + &my_locale_typelib_month_names_en_US, + &my_locale_typelib_ab_month_names_en_US, + &my_locale_typelib_day_names_en_US, + &my_locale_typelib_ab_day_names_en_US +}; /***** LOCALE END en_CA *****/ /***** LOCALE BEGIN en_GB: English - United Kingdom *****/ MY_LOCALE my_locale_en_GB= - { "en_GB", "English - United Kingdom", TRUE, &my_locale_typelib_month_names_en_US, &my_locale_typelib_ab_month_names_en_US, &my_locale_typelib_day_names_en_US, &my_locale_typelib_ab_day_names_en_US }; +{ + 1, + "en_GB", + "English - United Kingdom", + TRUE, + &my_locale_typelib_month_names_en_US, + &my_locale_typelib_ab_month_names_en_US, + &my_locale_typelib_day_names_en_US, + &my_locale_typelib_ab_day_names_en_US +}; /***** LOCALE END en_GB *****/ /***** LOCALE BEGIN en_IN: English - India *****/ MY_LOCALE my_locale_en_IN= - { "en_IN", "English - India", TRUE, &my_locale_typelib_month_names_en_US, &my_locale_typelib_ab_month_names_en_US, &my_locale_typelib_day_names_en_US, &my_locale_typelib_ab_day_names_en_US }; +{ + 76, + "en_IN", + "English - India", + TRUE, + &my_locale_typelib_month_names_en_US, + &my_locale_typelib_ab_month_names_en_US, + &my_locale_typelib_day_names_en_US, + &my_locale_typelib_ab_day_names_en_US +}; /***** LOCALE END en_IN *****/ /***** LOCALE BEGIN en_NZ: English - New Zealand *****/ MY_LOCALE my_locale_en_NZ= - { "en_NZ", "English - New Zealand", TRUE, &my_locale_typelib_month_names_en_US, &my_locale_typelib_ab_month_names_en_US, &my_locale_typelib_day_names_en_US, &my_locale_typelib_ab_day_names_en_US }; +{ + 77, + "en_NZ", + "English - New Zealand", + TRUE, + &my_locale_typelib_month_names_en_US, + &my_locale_typelib_ab_month_names_en_US, + &my_locale_typelib_day_names_en_US, + &my_locale_typelib_ab_day_names_en_US +}; /***** LOCALE END en_NZ *****/ /***** LOCALE BEGIN en_PH: English - Philippines *****/ MY_LOCALE my_locale_en_PH= - { "en_PH", "English - Philippines", TRUE, &my_locale_typelib_month_names_en_US, &my_locale_typelib_ab_month_names_en_US, &my_locale_typelib_day_names_en_US, &my_locale_typelib_ab_day_names_en_US }; +{ + 78, + "en_PH", + "English - Philippines", + TRUE, + &my_locale_typelib_month_names_en_US, + &my_locale_typelib_ab_month_names_en_US, + &my_locale_typelib_day_names_en_US, + &my_locale_typelib_ab_day_names_en_US +}; /***** LOCALE END en_PH *****/ /***** LOCALE BEGIN en_ZA: English - South Africa *****/ MY_LOCALE my_locale_en_ZA= - { "en_ZA", "English - South Africa", TRUE, &my_locale_typelib_month_names_en_US, &my_locale_typelib_ab_month_names_en_US, &my_locale_typelib_day_names_en_US, &my_locale_typelib_ab_day_names_en_US }; +{ + 79, + "en_ZA", + "English - South Africa", + TRUE, + &my_locale_typelib_month_names_en_US, + &my_locale_typelib_ab_month_names_en_US, + &my_locale_typelib_day_names_en_US, + &my_locale_typelib_ab_day_names_en_US +}; /***** LOCALE END en_ZA *****/ /***** LOCALE BEGIN en_ZW: English - Zimbabwe *****/ MY_LOCALE my_locale_en_ZW= - { "en_ZW", "English - Zimbabwe", TRUE, &my_locale_typelib_month_names_en_US, &my_locale_typelib_ab_month_names_en_US, &my_locale_typelib_day_names_en_US, &my_locale_typelib_ab_day_names_en_US }; +{ + 80, + "en_ZW", + "English - Zimbabwe", + TRUE, + &my_locale_typelib_month_names_en_US, + &my_locale_typelib_ab_month_names_en_US, + &my_locale_typelib_day_names_en_US, + &my_locale_typelib_ab_day_names_en_US +}; /***** LOCALE END en_ZW *****/ /***** LOCALE BEGIN es_AR: Spanish - Argentina *****/ MY_LOCALE my_locale_es_AR= - { "es_AR", "Spanish - Argentina", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES }; +{ + 81, + "es_AR", + "Spanish - Argentina", + FALSE, + &my_locale_typelib_month_names_es_ES, + &my_locale_typelib_ab_month_names_es_ES, + &my_locale_typelib_day_names_es_ES, + &my_locale_typelib_ab_day_names_es_ES +}; /***** LOCALE END es_AR *****/ /***** LOCALE BEGIN es_BO: Spanish - Bolivia *****/ MY_LOCALE my_locale_es_BO= - { "es_BO", "Spanish - Bolivia", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES }; +{ + 82, + "es_BO", + "Spanish - Bolivia", + FALSE, + &my_locale_typelib_month_names_es_ES, + &my_locale_typelib_ab_month_names_es_ES, + &my_locale_typelib_day_names_es_ES, + &my_locale_typelib_ab_day_names_es_ES +}; /***** LOCALE END es_BO *****/ /***** LOCALE BEGIN es_CL: Spanish - Chile *****/ MY_LOCALE my_locale_es_CL= - { "es_CL", "Spanish - Chile", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES }; +{ + 83, + "es_CL", + "Spanish - Chile", + FALSE, + &my_locale_typelib_month_names_es_ES, + &my_locale_typelib_ab_month_names_es_ES, + &my_locale_typelib_day_names_es_ES, + &my_locale_typelib_ab_day_names_es_ES +}; /***** LOCALE END es_CL *****/ /***** LOCALE BEGIN es_CO: Spanish - Columbia *****/ MY_LOCALE my_locale_es_CO= - { "es_CO", "Spanish - Columbia", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES }; +{ + 84, + "es_CO", + "Spanish - Columbia", + FALSE, + &my_locale_typelib_month_names_es_ES, + &my_locale_typelib_ab_month_names_es_ES, + &my_locale_typelib_day_names_es_ES, + &my_locale_typelib_ab_day_names_es_ES +}; /***** LOCALE END es_CO *****/ /***** LOCALE BEGIN es_CR: Spanish - Costa Rica *****/ MY_LOCALE my_locale_es_CR= - { "es_CR", "Spanish - Costa Rica", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES }; +{ + 85, + "es_CR", + "Spanish - Costa Rica", + FALSE, + &my_locale_typelib_month_names_es_ES, + &my_locale_typelib_ab_month_names_es_ES, + &my_locale_typelib_day_names_es_ES, + &my_locale_typelib_ab_day_names_es_ES +}; /***** LOCALE END es_CR *****/ /***** LOCALE BEGIN es_DO: Spanish - Dominican Republic *****/ MY_LOCALE my_locale_es_DO= - { "es_DO", "Spanish - Dominican Republic", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES }; +{ + 86, + "es_DO", + "Spanish - Dominican Republic", + FALSE, + &my_locale_typelib_month_names_es_ES, + &my_locale_typelib_ab_month_names_es_ES, + &my_locale_typelib_day_names_es_ES, + &my_locale_typelib_ab_day_names_es_ES +}; /***** LOCALE END es_DO *****/ /***** LOCALE BEGIN es_EC: Spanish - Ecuador *****/ MY_LOCALE my_locale_es_EC= - { "es_EC", "Spanish - Ecuador", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES }; +{ + 87, + "es_EC", + "Spanish - Ecuador", + FALSE, + &my_locale_typelib_month_names_es_ES, + &my_locale_typelib_ab_month_names_es_ES, + &my_locale_typelib_day_names_es_ES, + &my_locale_typelib_ab_day_names_es_ES +}; /***** LOCALE END es_EC *****/ /***** LOCALE BEGIN es_GT: Spanish - Guatemala *****/ MY_LOCALE my_locale_es_GT= - { "es_GT", "Spanish - Guatemala", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES }; +{ + 88, + "es_GT", + "Spanish - Guatemala", + FALSE, + &my_locale_typelib_month_names_es_ES, + &my_locale_typelib_ab_month_names_es_ES, + &my_locale_typelib_day_names_es_ES, + &my_locale_typelib_ab_day_names_es_ES +}; /***** LOCALE END es_GT *****/ /***** LOCALE BEGIN es_HN: Spanish - Honduras *****/ MY_LOCALE my_locale_es_HN= - { "es_HN", "Spanish - Honduras", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES }; +{ + 89, + "es_HN", + "Spanish - Honduras", + FALSE, + &my_locale_typelib_month_names_es_ES, + &my_locale_typelib_ab_month_names_es_ES, + &my_locale_typelib_day_names_es_ES, + &my_locale_typelib_ab_day_names_es_ES +}; /***** LOCALE END es_HN *****/ /***** LOCALE BEGIN es_MX: Spanish - Mexico *****/ MY_LOCALE my_locale_es_MX= - { "es_MX", "Spanish - Mexico", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES }; +{ + 90, + "es_MX", + "Spanish - Mexico", + FALSE, + &my_locale_typelib_month_names_es_ES, + &my_locale_typelib_ab_month_names_es_ES, + &my_locale_typelib_day_names_es_ES, + &my_locale_typelib_ab_day_names_es_ES +}; /***** LOCALE END es_MX *****/ /***** LOCALE BEGIN es_NI: Spanish - Nicaragua *****/ MY_LOCALE my_locale_es_NI= - { "es_NI", "Spanish - Nicaragua", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES }; +{ + 91, + "es_NI", + "Spanish - Nicaragua", + FALSE, + &my_locale_typelib_month_names_es_ES, + &my_locale_typelib_ab_month_names_es_ES, + &my_locale_typelib_day_names_es_ES, + &my_locale_typelib_ab_day_names_es_ES +}; /***** LOCALE END es_NI *****/ /***** LOCALE BEGIN es_PA: Spanish - Panama *****/ MY_LOCALE my_locale_es_PA= - { "es_PA", "Spanish - Panama", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES }; +{ + 92, + "es_PA", + "Spanish - Panama", + FALSE, + &my_locale_typelib_month_names_es_ES, + &my_locale_typelib_ab_month_names_es_ES, + &my_locale_typelib_day_names_es_ES, + &my_locale_typelib_ab_day_names_es_ES +}; /***** LOCALE END es_PA *****/ /***** LOCALE BEGIN es_PE: Spanish - Peru *****/ MY_LOCALE my_locale_es_PE= - { "es_PE", "Spanish - Peru", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES }; +{ + 93, + "es_PE", + "Spanish - Peru", + FALSE, + &my_locale_typelib_month_names_es_ES, + &my_locale_typelib_ab_month_names_es_ES, + &my_locale_typelib_day_names_es_ES, + &my_locale_typelib_ab_day_names_es_ES +}; /***** LOCALE END es_PE *****/ /***** LOCALE BEGIN es_PR: Spanish - Puerto Rico *****/ MY_LOCALE my_locale_es_PR= - { "es_PR", "Spanish - Puerto Rico", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES }; +{ + 94, + "es_PR", + "Spanish - Puerto Rico", + FALSE, + &my_locale_typelib_month_names_es_ES, + &my_locale_typelib_ab_month_names_es_ES, + &my_locale_typelib_day_names_es_ES, + &my_locale_typelib_ab_day_names_es_ES +}; /***** LOCALE END es_PR *****/ /***** LOCALE BEGIN es_PY: Spanish - Paraguay *****/ MY_LOCALE my_locale_es_PY= - { "es_PY", "Spanish - Paraguay", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES }; +{ + 95, + "es_PY", + "Spanish - Paraguay", + FALSE, + &my_locale_typelib_month_names_es_ES, + &my_locale_typelib_ab_month_names_es_ES, + &my_locale_typelib_day_names_es_ES, + &my_locale_typelib_ab_day_names_es_ES +}; /***** LOCALE END es_PY *****/ /***** LOCALE BEGIN es_SV: Spanish - El Salvador *****/ MY_LOCALE my_locale_es_SV= - { "es_SV", "Spanish - El Salvador", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES }; +{ + 96, + "es_SV", + "Spanish - El Salvador", + FALSE, + &my_locale_typelib_month_names_es_ES, + &my_locale_typelib_ab_month_names_es_ES, + &my_locale_typelib_day_names_es_ES, + &my_locale_typelib_ab_day_names_es_ES +}; /***** LOCALE END es_SV *****/ /***** LOCALE BEGIN es_US: Spanish - United States *****/ MY_LOCALE my_locale_es_US= - { "es_US", "Spanish - United States", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES }; +{ + 97, + "es_US", + "Spanish - United States", + FALSE, + &my_locale_typelib_month_names_es_ES, + &my_locale_typelib_ab_month_names_es_ES, + &my_locale_typelib_day_names_es_ES, + &my_locale_typelib_ab_day_names_es_ES +}; /***** LOCALE END es_US *****/ /***** LOCALE BEGIN es_UY: Spanish - Uruguay *****/ MY_LOCALE my_locale_es_UY= - { "es_UY", "Spanish - Uruguay", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES }; +{ + 98, + "es_UY", + "Spanish - Uruguay", + FALSE, + &my_locale_typelib_month_names_es_ES, + &my_locale_typelib_ab_month_names_es_ES, + &my_locale_typelib_day_names_es_ES, + &my_locale_typelib_ab_day_names_es_ES +}; /***** LOCALE END es_UY *****/ /***** LOCALE BEGIN es_VE: Spanish - Venezuela *****/ MY_LOCALE my_locale_es_VE= - { "es_VE", "Spanish - Venezuela", FALSE, &my_locale_typelib_month_names_es_ES, &my_locale_typelib_ab_month_names_es_ES, &my_locale_typelib_day_names_es_ES, &my_locale_typelib_ab_day_names_es_ES }; +{ + 99, + "es_VE", + "Spanish - Venezuela", + FALSE, + &my_locale_typelib_month_names_es_ES, + &my_locale_typelib_ab_month_names_es_ES, + &my_locale_typelib_day_names_es_ES, + &my_locale_typelib_ab_day_names_es_ES +}; /***** LOCALE END es_VE *****/ /***** LOCALE BEGIN fr_BE: French - Belgium *****/ MY_LOCALE my_locale_fr_BE= - { "fr_BE", "French - Belgium", FALSE, &my_locale_typelib_month_names_fr_FR, &my_locale_typelib_ab_month_names_fr_FR, &my_locale_typelib_day_names_fr_FR, &my_locale_typelib_ab_day_names_fr_FR }; +{ + 100, + "fr_BE", + "French - Belgium", + FALSE, + &my_locale_typelib_month_names_fr_FR, + &my_locale_typelib_ab_month_names_fr_FR, + &my_locale_typelib_day_names_fr_FR, + &my_locale_typelib_ab_day_names_fr_FR +}; /***** LOCALE END fr_BE *****/ /***** LOCALE BEGIN fr_CA: French - Canada *****/ MY_LOCALE my_locale_fr_CA= - { "fr_CA", "French - Canada", FALSE, &my_locale_typelib_month_names_fr_FR, &my_locale_typelib_ab_month_names_fr_FR, &my_locale_typelib_day_names_fr_FR, &my_locale_typelib_ab_day_names_fr_FR }; +{ + 101, + "fr_CA", + "French - Canada", + FALSE, + &my_locale_typelib_month_names_fr_FR, + &my_locale_typelib_ab_month_names_fr_FR, + &my_locale_typelib_day_names_fr_FR, + &my_locale_typelib_ab_day_names_fr_FR +}; /***** LOCALE END fr_CA *****/ /***** LOCALE BEGIN fr_CH: French - Switzerland *****/ MY_LOCALE my_locale_fr_CH= - { "fr_CH", "French - Switzerland", FALSE, &my_locale_typelib_month_names_fr_FR, &my_locale_typelib_ab_month_names_fr_FR, &my_locale_typelib_day_names_fr_FR, &my_locale_typelib_ab_day_names_fr_FR }; +{ + 102, + "fr_CH", + "French - Switzerland", + FALSE, + &my_locale_typelib_month_names_fr_FR, + &my_locale_typelib_ab_month_names_fr_FR, + &my_locale_typelib_day_names_fr_FR, + &my_locale_typelib_ab_day_names_fr_FR +}; /***** LOCALE END fr_CH *****/ /***** LOCALE BEGIN fr_LU: French - Luxembourg *****/ MY_LOCALE my_locale_fr_LU= - { "fr_LU", "French - Luxembourg", FALSE, &my_locale_typelib_month_names_fr_FR, &my_locale_typelib_ab_month_names_fr_FR, &my_locale_typelib_day_names_fr_FR, &my_locale_typelib_ab_day_names_fr_FR }; +{ + 103, + "fr_LU", + "French - Luxembourg", + FALSE, + &my_locale_typelib_month_names_fr_FR, + &my_locale_typelib_ab_month_names_fr_FR, + &my_locale_typelib_day_names_fr_FR, + &my_locale_typelib_ab_day_names_fr_FR +}; /***** LOCALE END fr_LU *****/ /***** LOCALE BEGIN it_IT: Italian - Italy *****/ MY_LOCALE my_locale_it_IT= - { "it_IT", "Italian - Italy", FALSE, &my_locale_typelib_month_names_it_CH, &my_locale_typelib_ab_month_names_it_CH, &my_locale_typelib_day_names_it_CH, &my_locale_typelib_ab_day_names_it_CH }; +{ + 104, + "it_IT", + "Italian - Italy", + FALSE, + &my_locale_typelib_month_names_it_CH, + &my_locale_typelib_ab_month_names_it_CH, + &my_locale_typelib_day_names_it_CH, + &my_locale_typelib_ab_day_names_it_CH +}; /***** LOCALE END it_IT *****/ /***** LOCALE BEGIN nl_BE: Dutch - Belgium *****/ MY_LOCALE my_locale_nl_BE= - { "nl_BE", "Dutch - Belgium", TRUE, &my_locale_typelib_month_names_nl_NL, &my_locale_typelib_ab_month_names_nl_NL, &my_locale_typelib_day_names_nl_NL, &my_locale_typelib_ab_day_names_nl_NL }; +{ + 105, + "nl_BE", + "Dutch - Belgium", + TRUE, + &my_locale_typelib_month_names_nl_NL, + &my_locale_typelib_ab_month_names_nl_NL, + &my_locale_typelib_day_names_nl_NL, + &my_locale_typelib_ab_day_names_nl_NL +}; /***** LOCALE END nl_BE *****/ /***** LOCALE BEGIN no_NO: Norwegian - Norway *****/ MY_LOCALE my_locale_no_NO= - { "no_NO", "Norwegian - Norway", FALSE, &my_locale_typelib_month_names_nb_NO, &my_locale_typelib_ab_month_names_nb_NO, &my_locale_typelib_day_names_nb_NO, &my_locale_typelib_ab_day_names_nb_NO }; +{ + 106, + "no_NO", + "Norwegian - Norway", + FALSE, + &my_locale_typelib_month_names_nb_NO, + &my_locale_typelib_ab_month_names_nb_NO, + &my_locale_typelib_day_names_nb_NO, + &my_locale_typelib_ab_day_names_nb_NO +}; /***** LOCALE END no_NO *****/ /***** LOCALE BEGIN sv_FI: Swedish - Finland *****/ MY_LOCALE my_locale_sv_FI= - { "sv_FI", "Swedish - Finland", FALSE, &my_locale_typelib_month_names_sv_SE, &my_locale_typelib_ab_month_names_sv_SE, &my_locale_typelib_day_names_sv_SE, &my_locale_typelib_ab_day_names_sv_SE }; +{ + 107, + "sv_FI", + "Swedish - Finland", + FALSE, + &my_locale_typelib_month_names_sv_SE, + &my_locale_typelib_ab_month_names_sv_SE, + &my_locale_typelib_day_names_sv_SE, + &my_locale_typelib_ab_day_names_sv_SE +}; /***** LOCALE END sv_FI *****/ /***** LOCALE BEGIN zh_HK: Chinese - Hong Kong SAR *****/ MY_LOCALE my_locale_zh_HK= - { "zh_HK", "Chinese - Hong Kong SAR", FALSE, &my_locale_typelib_month_names_zh_CN, &my_locale_typelib_ab_month_names_zh_CN, &my_locale_typelib_day_names_zh_CN, &my_locale_typelib_ab_day_names_zh_CN }; +{ + 108, + "zh_HK", + "Chinese - Hong Kong SAR", + FALSE, + &my_locale_typelib_month_names_zh_CN, + &my_locale_typelib_ab_month_names_zh_CN, + &my_locale_typelib_day_names_zh_CN, + &my_locale_typelib_ab_day_names_zh_CN +}; /***** LOCALE END zh_HK *****/ + +/* + The list of all locales. + Note, locales must be ordered according to their + numbers to make my_locale_by_number() work fast. + Some debug asserts below check this. +*/ MY_LOCALE *my_locales[]= { &my_locale_en_US, @@ -1605,3 +2582,31 @@ MY_LOCALE *my_locales[]= &my_locale_zh_HK, NULL }; + + +MY_LOCALE *my_locale_by_number(uint number) +{ + MY_LOCALE *locale; + if (number >= array_elements(my_locales) - 1) + return NULL; + locale= my_locales[number]; + // Check that locale is on its correct position in the array + DBUG_ASSERT(locale == my_locales[locale->number]); + return locale; +} + + +MY_LOCALE *my_locale_by_name(const char *name) +{ + MY_LOCALE **locale; + for (locale= my_locales; *locale != NULL; locale++) + { + if (!my_strcasecmp(&my_charset_latin1, (*locale)->name, name)) + { + // Check that locale is on its correct position in the array + DBUG_ASSERT((*locale) == my_locales[(*locale)->number]); + return *locale; + } + } + return NULL; +} diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 19add72c23e..659926bdea3 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -867,7 +867,7 @@ static int check_connection(THD *thd) return(ER_HANDSHAKE_ERROR); } DBUG_PRINT("info", ("IO layer change in progress...")); - if (sslaccept(ssl_acceptor_fd, net->vio, thd->variables.net_wait_timeout)) + if (sslaccept(ssl_acceptor_fd, net->vio, net->read_timeout)) { DBUG_PRINT("error", ("Failed to read user information (pkt_len= %lu)", pkt_len)); @@ -897,7 +897,6 @@ static int check_connection(THD *thd) if ((thd->client_capabilities & CLIENT_TRANSACTIONS) && opt_using_transactions) net->return_status= &thd->server_status; - net->read_timeout=(uint) thd->variables.net_read_timeout; char *user= end; char *passwd= strend(user)+1; @@ -1029,6 +1028,10 @@ pthread_handler_decl(handle_one_connection,arg) NET *net= &thd->net; thd->thread_stack= (char*) &thd; + /* Use "connect_timeout" value during connection phase */ + net_set_read_timeout(net, connect_timeout); + net_set_write_timeout(net, connect_timeout); + if ((error=check_connection(thd))) { // Wrong permissions if (error > 0) @@ -1058,6 +1061,11 @@ pthread_handler_decl(handle_one_connection,arg) if (thd->query_error) thd->killed= 1; } + + /* Connect completed, set read/write timeouts back to tdefault */ + net_set_read_timeout(net, thd->variables.net_read_timeout); + net_set_write_timeout(net, thd->variables.net_write_timeout); + while (!net->error && net->vio != 0 && !thd->killed) { if (do_command(thd)) @@ -1175,6 +1183,7 @@ extern "C" pthread_handler_decl(handle_bootstrap,arg) free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC)); break; } + thd->set_time(); mysql_parse(thd,thd->query,length); close_thread_tables(thd); // Free tables if (thd->is_fatal_error) @@ -1261,7 +1270,7 @@ err: #ifndef EMBEDDED_LIBRARY /* - Read one command from socket and execute it (query or simple command). + Read one command from connection and execute it (query or simple command). This function is called in loop from thread function. SYNOPSIS do_command() @@ -1272,24 +1281,26 @@ err: bool do_command(THD *thd) { - char *packet; - uint old_timeout; + char *packet= 0; ulong packet_length; - NET *net; + NET *net= &thd->net; enum enum_server_command command; DBUG_ENTER("do_command"); - net= &thd->net; /* indicator of uninitialized lex => normal flow of errors handling (see my_message_sql) */ thd->lex->current_select= 0; - packet=0; - old_timeout=net->read_timeout; - // Wait max for 8 hours - net->read_timeout=(uint) thd->variables.net_wait_timeout; + /* + This thread will do a blocking read from the client which + will be interrupted when the next command is received from + the client, the connection is closed or "net_wait_timeout" + number of seconds has passed + */ + net_set_read_timeout(net, thd->variables.net_wait_timeout); + thd->clear_error(); // Clear error message net_new_transaction(net); @@ -1318,7 +1329,10 @@ bool do_command(THD *thd) vio_description(net->vio), command, command_name[command])); } - net->read_timeout=old_timeout; // restore it + + /* Restore read timeout value */ + net_set_read_timeout(net, thd->variables.net_read_timeout); + /* packet_length contains length of data, as it was stored in packet header. In case of malformed header, packet_length can be zero. @@ -1958,6 +1972,7 @@ static void reset_one_shot_variables(THD *thd) thd->update_charset(); thd->variables.time_zone= global_system_variables.time_zone; + thd->variables.lc_time_names= &my_locale_en_US; thd->one_shot_set= 0; } @@ -2478,19 +2493,42 @@ mysql_execute_command(THD *thd) } /* Skip first table, which is the table we are creating */ TABLE_LIST *create_table, *create_table_local; + /* + Code below (especially in mysql_create_table() and select_create + methods) may modify HA_CREATE_INFO structure in LEX, so we have to + use a copy of this structure to make execution prepared statement- + safe. A shallow copy is enough as this code won't modify any memory + referenced from this structure. + */ + HA_CREATE_INFO create_info(lex->create_info); + Alter_info alter_info(lex->alter_info, thd->mem_root); + + if (thd->is_fatal_error) + { + /* out of memory when creating a copy of alter_info */ + res= 1; + goto unsent_create_error; + } tables= lex->unlink_first_table(tables, &create_table, &create_table_local); if ((res= create_table_precheck(thd, tables, create_table))) goto unsent_create_error; + create_info.alias= create_table->alias; #ifndef HAVE_READLINK - lex->create_info.data_file_name=lex->create_info.index_file_name=0; + if (create_info.data_file_name) + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, + "DATA DIRECTORY option ignored"); + if (create_info.index_file_name) + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, + "INDEX DIRECTORY option ignored"); + create_info.data_file_name= create_info.index_file_name= NULL; #else /* Fix names if symlinked tables */ - if (append_file_to_dir(thd, &lex->create_info.data_file_name, + if (append_file_to_dir(thd, &create_info.data_file_name, create_table->real_name) || - append_file_to_dir(thd,&lex->create_info.index_file_name, + append_file_to_dir(thd, &create_info.index_file_name, create_table->real_name)) { res=-1; @@ -2501,14 +2539,14 @@ mysql_execute_command(THD *thd) If we are using SET CHARSET without DEFAULT, add an implicite DEFAULT to not confuse old users. (This may change). */ - if ((lex->create_info.used_fields & + if ((create_info.used_fields & (HA_CREATE_USED_DEFAULT_CHARSET | HA_CREATE_USED_CHARSET)) == HA_CREATE_USED_CHARSET) { - lex->create_info.used_fields&= ~HA_CREATE_USED_CHARSET; - lex->create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET; - lex->create_info.default_table_charset= lex->create_info.table_charset; - lex->create_info.table_charset= 0; + create_info.used_fields&= ~HA_CREATE_USED_CHARSET; + create_info.used_fields|= HA_CREATE_USED_DEFAULT_CHARSET; + create_info.default_table_charset= create_info.table_charset; + create_info.table_charset= 0; } /* The create-select command will open and read-lock the select table @@ -2542,11 +2580,14 @@ mysql_execute_command(THD *thd) if (!(res=open_and_lock_tables(thd,tables))) { res= -1; // If error + /* + select_create is currently not re-execution friendly and + needs to be created for every execution of a PS/SP. + */ if ((result=new select_create(create_table->db, create_table->real_name, - &lex->create_info, - lex->create_list, - lex->key_list, + &create_info, + &alter_info, select_lex->item_list, lex->duplicates, lex->ignore))) { @@ -2558,22 +2599,18 @@ mysql_execute_command(THD *thd) res=handle_select(thd, lex, result); select_lex->resolve_mode= SELECT_LEX::NOMATTER_MODE; } - //reset for PS - lex->create_list.empty(); - lex->key_list.empty(); } } else // regular create { if (lex->name) - res= mysql_create_like_table(thd, create_table, &lex->create_info, + res= mysql_create_like_table(thd, create_table, &create_info, (Table_ident *)lex->name); else { - res= mysql_create_table(thd,create_table->db, - create_table->real_name, &lex->create_info, - lex->create_list, - lex->key_list,0,0); + res= mysql_create_table(thd, create_table->db, + create_table->real_name, &create_info, + &alter_info, 0, 0); } if (!res) send_ok(thd); @@ -2591,15 +2628,49 @@ unsent_create_error: break; } case SQLCOM_CREATE_INDEX: + /* Fall through */ + case SQLCOM_DROP_INDEX: + /* + CREATE INDEX and DROP INDEX are implemented by calling ALTER + TABLE with proper arguments. This isn't very fast but it + should work for most cases. + + In the future ALTER TABLE will notice that only added + indexes and create these one by one for the existing table + without having to do a full rebuild. + + One should normally create all indexes with CREATE TABLE or + ALTER TABLE. + */ + { + Alter_info alter_info(lex->alter_info, thd->mem_root); + HA_CREATE_INFO create_info; + + if (thd->is_fatal_error) /* out of memory creating a copy of alter_info*/ + goto error; + if (check_one_table_access(thd, INDEX_ACL, tables)) goto error; /* purecov: inspected */ thd->enable_slow_log= opt_log_slow_admin_statements; if (end_active_trans(thd)) - res= -1; - else - res = mysql_create_index(thd, tables, lex->key_list); - break; + goto error; + /* + Currently CREATE INDEX or DROP INDEX cause a full table rebuild + and thus classify as slow administrative statements just like + ALTER TABLE. + */ + thd->enable_slow_log= opt_log_slow_admin_statements; + bzero((char*) &create_info, sizeof(create_info)); + create_info.db_type= DB_TYPE_DEFAULT; + create_info.row_type= ROW_TYPE_NOT_USED; + create_info.default_table_charset= thd->variables.collation_database; + + res= mysql_alter_table(thd, tables->db, tables->real_name, + &create_info, tables, &alter_info, + 0, (ORDER*)0, DUP_ERROR, 0); + break; + } #ifdef HAVE_REPLICATION case SQLCOM_SLAVE_START: { @@ -2642,6 +2713,17 @@ unsent_create_error: #else { ulong priv=0; + /* + Code in mysql_alter_table() may modify its HA_CREATE_INFO argument, + so we have to use a copy of this structure to make execution + prepared statement- safe. A shallow copy is enough as no memory + referenced from this structure will be modified. + */ + HA_CREATE_INFO create_info(lex->create_info); + Alter_info alter_info(lex->alter_info, thd->mem_root); + + if (thd->is_fatal_error) /* out of memory creating a copy of alter_info */ + goto error; if (lex->name && (!lex->name[0] || strlen(lex->name) > NAME_LEN)) { net_printf(thd, ER_WRONG_TABLE_NAME, lex->name); @@ -2655,7 +2737,7 @@ unsent_create_error: default database if the new name is not explicitly qualified by a database. (Bug #11493) */ - if (lex->alter_info.flags & ALTER_RENAME) + if (alter_info.flags & ALTER_RENAME) { if (! thd->db) { @@ -2671,7 +2753,7 @@ unsent_create_error: check_access(thd,INSERT_ACL | CREATE_ACL,select_lex->db,&priv,0,0)|| check_merge_table_access(thd, tables->db, (TABLE_LIST *) - lex->create_info.merge_list.first)) + create_info.merge_list.first)) goto error; /* purecov: inspected */ if (grant_option) { @@ -2690,26 +2772,26 @@ unsent_create_error: } } /* Don't yet allow changing of symlinks with ALTER TABLE */ - if (lex->create_info.data_file_name) + if (create_info.data_file_name) push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, "DATA DIRECTORY option ignored"); - if (lex->create_info.index_file_name) + if (create_info.index_file_name) push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, "INDEX DIRECTORY option ignored"); - lex->create_info.data_file_name=lex->create_info.index_file_name=0; + create_info.data_file_name= create_info.index_file_name= NULL; /* ALTER TABLE ends previous transaction */ if (end_active_trans(thd)) res= -1; else { thd->enable_slow_log= opt_log_slow_admin_statements; - res= mysql_alter_table(thd, select_lex->db, lex->name, - &lex->create_info, - tables, lex->create_list, - lex->key_list, - select_lex->order_list.elements, + res= mysql_alter_table(thd, select_lex->db, lex->name, + &create_info, + tables, + &alter_info, + select_lex->order_list.elements, (ORDER *) select_lex->order_list.first, - lex->duplicates, lex->ignore, &lex->alter_info); + lex->duplicates, lex->ignore); } break; } @@ -2736,7 +2818,7 @@ unsent_create_error: old_list=table[0]; new_list=table->next[0]; old_list.next=new_list.next=0; - if (check_grant(thd, ALTER_ACL, &old_list, 0, UINT_MAX, 0) || + if (check_grant(thd, ALTER_ACL | DROP_ACL, &old_list, 0, UINT_MAX, 0) || (!test_all_bits(table->next->grant.privilege, INSERT_ACL | CREATE_ACL) && check_grant(thd, INSERT_ACL | CREATE_ACL, &new_list, 0, @@ -2846,7 +2928,7 @@ unsent_create_error: goto error; /* purecov: inspected */ thd->enable_slow_log= opt_log_slow_admin_statements; res= (specialflag & (SPECIAL_SAFE_MODE | SPECIAL_NO_NEW_FUNC)) ? - mysql_recreate_table(thd, tables, 1) : + mysql_recreate_table(thd, tables) : mysql_optimize_table(thd, tables, &lex->check_opt); /* ! we write after unlocking the table */ if (!res && !lex->no_write_to_binlog) @@ -3123,14 +3205,6 @@ unsent_create_error: res= mysql_rm_table(thd,tables,lex->drop_if_exists, lex->drop_temporary); } break; - case SQLCOM_DROP_INDEX: - if (check_one_table_access(thd, INDEX_ACL, tables)) - goto error; /* purecov: inspected */ - if (end_active_trans(thd)) - res= -1; - else - res = mysql_drop_index(thd, tables, &lex->alter_info); - break; case SQLCOM_SHOW_DATABASES: #if defined(DONT_ALLOW_SHOW_COMMANDS) send_error(thd,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */ @@ -3363,6 +3437,12 @@ purposes internal to the MySQL server", MYF(0)); break; case SQLCOM_CREATE_DB: { + /* + As mysql_create_db() may modify HA_CREATE_INFO structure passed to + it, we need to use a copy of LEX::create_info to make execution + prepared statement- safe. + */ + HA_CREATE_INFO create_info(lex->create_info); if (end_active_trans(thd)) { res= -1; @@ -3393,7 +3473,7 @@ purposes internal to the MySQL server", MYF(0)); if (check_access(thd,CREATE_ACL,lex->name,0,1,0)) break; res= mysql_create_db(thd,(lower_case_table_names == 2 ? alias : lex->name), - &lex->create_info, 0); + &create_info, 0); break; } case SQLCOM_DROP_DB: @@ -4443,15 +4523,17 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, if (type_modifier & PRI_KEY_FLAG) { lex->col_list.push_back(new key_part_spec(field_name,0)); - lex->key_list.push_back(new Key(Key::PRIMARY, NullS, HA_KEY_ALG_UNDEF, - 0, lex->col_list)); + lex->alter_info.key_list.push_back(new Key(Key::PRIMARY, NullS, + HA_KEY_ALG_UNDEF, 0, + lex->col_list)); lex->col_list.empty(); } if (type_modifier & (UNIQUE_FLAG | UNIQUE_KEY_FLAG)) { lex->col_list.push_back(new key_part_spec(field_name,0)); - lex->key_list.push_back(new Key(Key::UNIQUE, NullS, HA_KEY_ALG_UNDEF, 0, - lex->col_list)); + lex->alter_info.key_list.push_back(new Key(Key::UNIQUE, NullS, + HA_KEY_ALG_UNDEF, 0, + lex->col_list)); lex->col_list.empty(); } @@ -4571,8 +4653,14 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, new_field->length++; } break; - case FIELD_TYPE_STRING: case FIELD_TYPE_VAR_STRING: + if (new_field->length < 4) + { + new_field->sql_type= FIELD_TYPE_STRING; + break; + } + /* fall through */ + case FIELD_TYPE_STRING: if (new_field->length <= MAX_FIELD_CHARLENGTH || default_value) break; /* Convert long CHAR() and VARCHAR columns to TEXT or BLOB */ @@ -4778,7 +4866,7 @@ bool add_field_to_list(THD *thd, char *field_name, enum_field_types type, new_field->sql_type, new_field->length); new_field->char_length= new_field->length; - lex->create_list.push_back(new_field); + lex->alter_info.create_list.push_back(new_field); lex->last_field=new_field; DBUG_RETURN(0); } @@ -5459,57 +5547,6 @@ Item * all_any_subquery_creator(Item *left_expr, /* - CREATE INDEX and DROP INDEX are implemented by calling ALTER TABLE with - the proper arguments. This isn't very fast but it should work for most - cases. - - In the future ALTER TABLE will notice that only added indexes - and create these one by one for the existing table without having to do - a full rebuild. - - One should normally create all indexes with CREATE TABLE or ALTER TABLE. -*/ - -int mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys) -{ - List<create_field> fields; - ALTER_INFO alter_info; - alter_info.flags= ALTER_ADD_INDEX; - alter_info.is_simple= 0; - HA_CREATE_INFO create_info; - DBUG_ENTER("mysql_create_index"); - bzero((char*) &create_info,sizeof(create_info)); - create_info.db_type=DB_TYPE_DEFAULT; - create_info.default_table_charset= thd->variables.collation_database; - create_info.row_type= ROW_TYPE_NOT_USED; - DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->real_name, - &create_info, table_list, - fields, keys, 0, (ORDER*)0, - DUP_ERROR, 0, &alter_info)); -} - - -int mysql_drop_index(THD *thd, TABLE_LIST *table_list, ALTER_INFO *alter_info) -{ - List<create_field> fields; - List<Key> keys; - HA_CREATE_INFO create_info; - DBUG_ENTER("mysql_drop_index"); - bzero((char*) &create_info,sizeof(create_info)); - create_info.db_type=DB_TYPE_DEFAULT; - create_info.default_table_charset= thd->variables.collation_database; - create_info.row_type= ROW_TYPE_NOT_USED; - alter_info->clear(); - alter_info->flags= ALTER_DROP_INDEX; - alter_info->is_simple= 0; - DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->real_name, - &create_info, table_list, - fields, keys, 0, (ORDER*)0, - DUP_ERROR, 0, alter_info)); -} - - -/* Multi update query pre-check SYNOPSIS @@ -5791,7 +5828,6 @@ int create_table_precheck(THD *thd, TABLE_LIST *tables, want_priv= ((lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) ? CREATE_TMP_ACL : CREATE_ACL); - lex->create_info.alias= create_table->alias; if (check_access(thd, want_priv, create_table->db, &create_table->grant.privilege, 0, 0) || check_merge_table_access(thd, create_table->db, diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 2688841d96c..b5aed0bbc4e 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1063,7 +1063,6 @@ static int mysql_test_select(Prepared_statement *stmt, int result= 1; DBUG_ENTER("mysql_test_select"); -#ifndef NO_EMBEDDED_ACCESS_CHECKS ulong privilege= lex->exchange ? SELECT_ACL | FILE_ACL : SELECT_ACL; if (tables) { @@ -1072,7 +1071,6 @@ static int mysql_test_select(Prepared_statement *stmt, } else if (check_access(thd, privilege, any_db,0,0,0)) DBUG_RETURN(1); -#endif if (!lex->result && !(lex->result= new (stmt->mem_root) select_send)) { @@ -1783,8 +1781,9 @@ static void reset_stmt_params(Prepared_statement *stmt) packet_length Query string length, including terminator character. */ -void mysql_stmt_execute(THD *thd, char *packet, uint packet_length) +void mysql_stmt_execute(THD *thd, char *packet_arg, uint packet_length) { + uchar *packet= (uchar*)packet_arg; // GCC 4.0.1 workaround ulong stmt_id= uint4korr(packet); /* Query text for binary log, or empty string if the query is not put into @@ -1792,7 +1791,7 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length) */ String expanded_query; #ifndef EMBEDDED_LIBRARY - uchar *packet_end= (uchar *) packet + packet_length - 1; + uchar *packet_end= packet + packet_length - 1; #endif Prepared_statement *stmt; DBUG_ENTER("mysql_stmt_execute"); @@ -1818,9 +1817,9 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length) #ifndef EMBEDDED_LIBRARY if (stmt->param_count) { - uchar *null_array= (uchar *) packet; - if (setup_conversion_functions(stmt, (uchar **) &packet, packet_end) || - stmt->set_params(stmt, null_array, (uchar *) packet, packet_end, + uchar *null_array= packet; + if (setup_conversion_functions(stmt, &packet, packet_end) || + stmt->set_params(stmt, null_array, packet, packet_end, &expanded_query)) goto set_params_data_err; } diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index a20f2a6506c..f83313a8fd8 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -89,8 +89,8 @@ static int send_file(THD *thd) The client might be slow loading the data, give him wait_timeout to do the job */ - old_timeout = thd->net.read_timeout; - thd->net.read_timeout = thd->variables.net_wait_timeout; + old_timeout= net->read_timeout; + net_set_read_timeout(net, thd->variables.net_wait_timeout); /* We need net_flush here because the client will not know it needs to send @@ -134,7 +134,7 @@ static int send_file(THD *thd) error = 0; err: - thd->net.read_timeout = old_timeout; + net_set_read_timeout(net, old_timeout); if (fd >= 0) (void) my_close(fd, MYF(0)); if (errmsg) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 0254e8f56dc..8b5664a7f96 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -265,6 +265,7 @@ JOIN::prepare(Item ***rref_pointer_array, select_lex->join= this; union_part= (unit_arg->first_select()->next_select() != 0); + thd->lex->current_select->is_item_list_lookup= 1; /* Check that all tables, fields, conds and order are ok */ if (setup_tables(tables_list) || @@ -531,23 +532,25 @@ JOIN::optimize() { int res; /* - opt_sum_query() returns -1 if no rows match to the WHERE conditions, - or 1 if all items were resolved, or 0, or an error number HA_ERR_... + opt_sum_query() returns HA_ERR_KEY_NOT_FOUND if no rows match + to the WHERE conditions, + or 1 if all items were resolved, + or 0, or an error number HA_ERR_... */ if ((res=opt_sum_query(tables_list, all_fields, conds))) { + if (res == HA_ERR_KEY_NOT_FOUND) + { + zero_result_cause= "No matching min/max row"; + error=0; + DBUG_RETURN(0); + } if (res > 1) { thd->fatal_error(); error= res; DBUG_RETURN(1); } - if (res < 0) - { - zero_result_cause= "No matching min/max row"; - error=0; - DBUG_RETURN(0); - } zero_result_cause= "Select tables optimized away"; tables_list= 0; // All tables resolved /* @@ -631,6 +634,12 @@ JOIN::optimize() DBUG_PRINT("error",("Error: make_select() failed")); DBUG_RETURN(1); } + if (conds &&!outer_join && const_table_map != found_const_table_map && + (select_options & SELECT_DESCRIBE) && + select_lex->master_unit() == &thd->lex->unit) // upper level SELECT + { + conds=new Item_int((longlong) 0,1); // Always false + } if (make_join_select(this, select, conds)) { zero_result_cause= @@ -644,6 +653,13 @@ JOIN::optimize() { ORDER *org_order= order; order=remove_const(this, order,conds,1, &simple_order); + if (thd->net.report_error) + { + error= 1; + DBUG_PRINT("error",("Error from remove_const")); + DBUG_RETURN(1); + } + /* If we are using ORDER BY NULL or ORDER BY const_expression, return result in any order (even if we are using a GROUP BY) @@ -747,6 +763,12 @@ JOIN::optimize() group_list= remove_const(this, (old_group_list= group_list), conds, rollup.state == ROLLUP::STATE_NONE, &simple_group); + if (thd->net.report_error) + { + error= 1; + DBUG_PRINT("error",("Error from remove_const")); + DBUG_RETURN(1); + } if (old_group_list && !group_list) select_distinct= 0; } @@ -763,6 +785,12 @@ JOIN::optimize() { group_list= procedure->group= remove_const(this, procedure->group, conds, 1, &simple_group); + if (thd->net.report_error) + { + error= 1; + DBUG_PRINT("error",("Error from remove_const")); + DBUG_RETURN(1); + } calc_group_buffer(this, group_list); } @@ -3917,14 +3945,17 @@ make_join_readinfo(JOIN *join, uint options) disable join cache because it will change the ordering of the results. Code handles sort table that is at any location (not only first after the const tables) despite the fact that it's currently prohibited. + We must disable join cache if the first non-const table alone is + ordered. If there is a temp table the ordering is done as a last + operation and doesn't prevent join cache usage. */ - if (!ordered_set && - (table == join->sort_by_table && + if (!ordered_set && !join->need_tmp && + ((table == join->sort_by_table && (!join->order || join->skip_sort_order || test_if_skip_sort_order(tab, join->order, join->select_limit, 1)) ) || - (join->sort_by_table == (TABLE *) 1 && i != join->const_tables)) + (join->sort_by_table == (TABLE *) 1 && i != join->const_tables))) ordered_set= 1; switch (tab->type) { @@ -4428,6 +4459,8 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond, *simple_order=0; // Must do a temp table to sort else if (!(order_tables & not_const_tables)) { + if (order->item[0]->with_subselect) + order->item[0]->val_str(&order->item[0]->str_value); DBUG_PRINT("info",("removing: %s", order->item[0]->full_name())); continue; // skip const item } @@ -5006,6 +5039,8 @@ static Field* create_tmp_field_from_field(THD *thd, Field* org_field, new_field->flags&= ~NOT_NULL_FLAG; // Because of outer join if (org_field->type() == FIELD_TYPE_VAR_STRING) table->db_create_options|= HA_OPTION_PACK_RECORD; + else if (org_field->type() == FIELD_TYPE_DOUBLE) + ((Field_double *) new_field)->not_fixed= TRUE; } return new_field; } @@ -5045,7 +5080,7 @@ static Field* create_tmp_field_from_item(THD *thd, Item *item, TABLE *table, switch (item->result_type()) { case REAL_RESULT: new_field=new Field_double(item->max_length, maybe_null, - item->name, table, item->decimals); + item->name, table, item->decimals, TRUE); break; case INT_RESULT: new_field=new Field_longlong(item->max_length, maybe_null, @@ -5136,8 +5171,8 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, return new Field_string(sizeof(double)+sizeof(longlong), 0, item->name,table,&my_charset_bin); else - return new Field_double(item_sum->max_length,maybe_null, - item->name, table, item_sum->decimals); + return new Field_double(item_sum->max_length, maybe_null, + item->name, table, item_sum->decimals, TRUE); case Item_sum::VARIANCE_FUNC: /* Place for sum & count */ case Item_sum::STD_FUNC: if (group) @@ -5145,7 +5180,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, 0, item->name,table,&my_charset_bin); else return new Field_double(item_sum->max_length, maybe_null, - item->name,table,item_sum->decimals); + item->name, table, item_sum->decimals, TRUE); case Item_sum::UNIQUE_USERS_FUNC: return new Field_long(9,maybe_null,item->name,table,1); case Item_sum::MIN_FUNC: @@ -5160,8 +5195,8 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, default: switch (item_sum->result_type()) { case REAL_RESULT: - return new Field_double(item_sum->max_length,maybe_null, - item->name,table,item_sum->decimals); + return new Field_double(item_sum->max_length, maybe_null, + item->name, table, item_sum->decimals, TRUE); case INT_RESULT: return new Field_longlong(item_sum->max_length,maybe_null, item->name,table,item->unsigned_flag); @@ -8677,16 +8712,12 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, 'it' reassigned in if condition because fix_field can change it. */ - thd->lex->current_select->is_item_list_lookup= 1; if (!it->fixed && (it->fix_fields(thd, tables, order->item) || (it= *order->item)->check_cols(1) || thd->is_fatal_error)) - { - thd->lex->current_select->is_item_list_lookup= 0; return 1; // Wrong field - } - thd->lex->current_select->is_item_list_lookup= 0; + uint el= all_fields.elements; all_fields.push_front(it); // Add new field to field list ref_pointer_array[el]= it; @@ -9732,7 +9763,7 @@ bool JOIN::rollup_init() for (j=0 ; j < fields_list.elements ; j++) rollup.fields[i].push_back(rollup.null_items[i]); } - List_iterator_fast<Item> it(all_fields); + List_iterator<Item> it(all_fields); Item *item; while ((item= it++)) { @@ -9745,6 +9776,32 @@ bool JOIN::rollup_init() { item->maybe_null= 1; found_in_group= 1; + if (item->const_item()) + { + /* + For ROLLUP queries each constant item referenced in GROUP BY list + is wrapped up into an Item_func object yielding the same value + as the constant item. The objects of the wrapper class are never + considered as constant items and besides they inherit all + properties of the Item_result_field class. + This wrapping allows us to ensure writing constant items + into temporary tables whenever the result of the ROLLUP + operation has to be written into a temporary table, e.g. when + ROLLUP is used together with DISTINCT in the SELECT list. + Usually when creating temporary tables for a intermidiate + result we do not include fields for constant expressions. + */ + Item* new_item= new Item_func_rollup_const(item); + if (!new_item) + return 1; + new_item->fix_fields(thd,0, (Item **) 0); + thd->change_item_tree(it.ref(), new_item); + for (ORDER *tmp= group_tmp; tmp; tmp= tmp->next) + { + if (*tmp->item == item) + thd->change_item_tree(tmp->item, new_item); + } + } } } if (item->type() == Item::FUNC_ITEM && !found_in_group) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 41e145790e9..bf0e254d3e4 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -714,16 +714,7 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild, if (verbose) protocol->store(field->has_charset() ? field->charset()->name : "NULL", system_charset_info); - /* - Even if TIMESTAMP field can't contain NULL as its value it - will accept NULL if you will try to insert such value and will - convert NULL value to current TIMESTAMP. So YES here means - that NULL is allowed for assignment (but may be won't be - returned). - */ - pos=(byte*) ((flags & NOT_NULL_FLAG) && - field->type() != FIELD_TYPE_TIMESTAMP ? - "" : "YES"); + pos= (byte*) ((flags & NOT_NULL_FLAG) ? "" : "YES"); protocol->store((const char*) pos, system_charset_info); pos=(byte*) ((field->flags & PRI_KEY_FLAG) ? "PRI" : (field->flags & UNIQUE_KEY_FLAG) ? "UNI" : @@ -845,7 +836,7 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) } int mysqld_show_create_db(THD *thd, char *dbname, - HA_CREATE_INFO *create_info) + const HA_CREATE_INFO *create_info) { int length; char path[FN_REFLEN]; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index f82dd627101..0316d6a3c10 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -456,8 +456,7 @@ void calculate_interval_lengths(CHARSET_INFO *cs, TYPELIB *interval, mysql_prepare_table() thd Thread object create_info Create information (like MAX_ROWS) - fields List of fields to create - keys List of keys to create + alter_info List of columns and indexes to create DESCRIPTION Prepares the table and key structures for table creation. @@ -468,8 +467,8 @@ void calculate_interval_lengths(CHARSET_INFO *cs, TYPELIB *interval, */ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, - List<create_field> &fields, - List<Key> &keys, bool tmp_table, uint &db_options, + Alter_info *alter_info, + bool tmp_table, uint &db_options, handler *file, KEY *&key_info_buffer, uint *key_count, int select_field_count) { @@ -482,10 +481,11 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, int timestamps= 0, timestamps_with_niladic= 0; int field_no,dup_no; int select_field_pos,auto_increment=0; + List_iterator<create_field> it(alter_info->create_list); + List_iterator<create_field> it2(alter_info->create_list); DBUG_ENTER("mysql_prepare_table"); - List_iterator<create_field> it(fields),it2(fields); - select_field_pos=fields.elements - select_field_count; + select_field_pos= alter_info->create_list.elements - select_field_count; null_fields=blob_columns=0; for (field_no=0; (sql_field=it++) ; field_no++) @@ -883,7 +883,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, /* Create keys */ - List_iterator<Key> key_iterator(keys), key_iterator2(keys); + List_iterator<Key> key_iterator(alter_info->key_list); + List_iterator<Key> key_iterator2(alter_info->key_list); uint key_parts=0, fk_key_count=0; bool primary_key=0,unique_key=0; Key *key, *key2; @@ -1333,23 +1334,27 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, SYNOPSIS mysql_create_table() - thd Thread object - db Database - table_name Table name - create_info Create information (like MAX_ROWS) - fields List of fields to create - keys List of keys to create - tmp_table Set to 1 if this is an internal temporary table - (From ALTER TABLE) + thd Thread object + db Database + table_name Table name + create_info [in/out] Create information (like MAX_ROWS) + alter_info [in/out] List of columns and indexes to create + tmp_table Set to 1 if this is an internal temporary table + (From ALTER TABLE) DESCRIPTION - If one creates a temporary table, this is automaticly opened + If one creates a temporary table, this is automatically opened no_log is needed for the case of CREATE ... SELECT, as the logging will be done later in sql_insert.cc select_field_count is also used for CREATE ... SELECT, and must be zero for standard create of table. + Note that structures passed as 'create_info' and 'alter_info' parameters + may be modified by this function. It is responsibility of the caller to + make a copy of create_info in order to provide correct execution in + prepared statements/stored routines. + RETURN VALUES 0 ok -1 error @@ -1357,8 +1362,8 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, int mysql_create_table(THD *thd,const char *db, const char *table_name, HA_CREATE_INFO *create_info, - List<create_field> &fields, - List<Key> &keys,bool tmp_table, + Alter_info *alter_info, + bool tmp_table, uint select_field_count) { char path[FN_REFLEN]; @@ -1371,7 +1376,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, DBUG_ENTER("mysql_create_table"); /* Check for duplicate fields and check type of table to create */ - if (!fields.elements) + if (!alter_info->create_list.elements) { my_error(ER_TABLE_MUST_HAVE_COLUMNS,MYF(0)); DBUG_RETURN(-1); @@ -1423,10 +1428,10 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, create_info->default_table_charset= db_info.default_table_charset; } - if (mysql_prepare_table(thd, create_info, fields, - keys, tmp_table, db_options, file, - key_info_buffer, &key_count, - select_field_count)) + if (mysql_prepare_table(thd, create_info, alter_info, tmp_table, + db_options, file, + key_info_buffer, &key_count, + select_field_count)) DBUG_RETURN(-1); /* Check if table exists */ @@ -1503,8 +1508,8 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, create_info->table_options=db_options; if (rea_create_table(thd, path, db, table_name, - create_info, fields, key_count, - key_info_buffer)) + create_info, alter_info->create_list, + key_count, key_info_buffer)) goto end; if (create_info->options & HA_LEX_CREATE_TMP_TABLE) { @@ -1592,8 +1597,7 @@ make_unique_key_name(const char *field_name,KEY *start,KEY *end) TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, const char *db, const char *name, - List<create_field> *extra_fields, - List<Key> *keys, + Alter_info *alter_info, List<Item> *items, MYSQL_LOCK **lock) { @@ -1627,7 +1631,7 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, ((Item_field *)item)->field : (Field*) 0)))) DBUG_RETURN(0); - extra_fields->push_back(cr_field); + alter_info->create_list.push_back(cr_field); } /* create and lock table */ /* QQ: create and open should be done atomic ! */ @@ -1641,8 +1645,8 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, open_table(). */ tmp_disable_binlog(thd); - if (!mysql_create_table(thd,db,name,create_info,*extra_fields, - *keys,0,select_field_count)) + if (!mysql_create_table(thd, db, name, create_info, alter_info, + 0, select_field_count)) { if (!(table=open_table(thd,db,name,name,(bool*) 0))) quick_rm_table(create_info->db_type,db,table_case_name(create_info,name)); @@ -2146,6 +2150,7 @@ send_result_message: case HA_ADMIN_TRY_ALTER: { + my_bool save_no_send_ok= thd->net.no_send_ok; /* This is currently used only by InnoDB. ha_innobase::optimize() answers "try with alter", so here we close the table, do an ALTER TABLE, @@ -2155,7 +2160,9 @@ send_result_message: TABLE_LIST *save_next= table->next; table->next= 0; tmp_disable_binlog(thd); // binlogging is done by caller if wanted - result_code= mysql_recreate_table(thd, table, 0); + thd->net.no_send_ok= TRUE; + result_code= mysql_recreate_table(thd, table); + thd->net.no_send_ok= save_no_send_ok; reenable_binlog(thd); close_thread_tables(thd); if (!result_code) // recreation went ok @@ -2635,206 +2642,6 @@ err: } -#ifdef NOT_USED -/* - CREATE INDEX and DROP INDEX are implemented by calling ALTER TABLE with - the proper arguments. This isn't very fast but it should work for most - cases. - One should normally create all indexes with CREATE TABLE or ALTER TABLE. -*/ - -int mysql_create_indexes(THD *thd, TABLE_LIST *table_list, List<Key> &keys) -{ - List<create_field> fields; - List<Alter_drop> drop; - List<Alter_column> alter; - HA_CREATE_INFO create_info; - int rc; - uint idx; - uint db_options; - uint key_count; - TABLE *table; - Field **f_ptr; - KEY *key_info_buffer; - char path[FN_REFLEN+1]; - DBUG_ENTER("mysql_create_index"); - - /* - Try to use online generation of index. - This requires that all indexes can be created online. - Otherwise, the old alter table procedure is executed. - - Open the table to have access to the correct table handler. - */ - if (!(table=open_ltable(thd,table_list,TL_WRITE_ALLOW_READ))) - DBUG_RETURN(-1); - - /* - The add_index method takes an array of KEY structs for the new indexes. - Preparing a new table structure generates this array. - It needs a list with all fields of the table, which does not need to - be correct in every respect. The field names are important. - */ - for (f_ptr= table->field; *f_ptr; f_ptr++) - { - create_field *c_fld= new create_field(*f_ptr, *f_ptr); - c_fld->unireg_check= Field::NONE; /*avoid multiple auto_increments*/ - fields.push_back(c_fld); - } - bzero((char*) &create_info,sizeof(create_info)); - create_info.db_type=DB_TYPE_DEFAULT; - create_info.default_table_charset= thd->variables.collation_database; - db_options= 0; - if (mysql_prepare_table(thd, &create_info, fields, - keys, /*tmp_table*/ 0, db_options, table->file, - key_info_buffer, key_count, - /*select_field_count*/ 0)) - DBUG_RETURN(-1); - - /* - Check if all keys can be generated with the add_index method. - If anyone cannot, then take the old way. - */ - for (idx=0; idx< key_count; idx++) - { - DBUG_PRINT("info", ("creating index %s", key_info_buffer[idx].name)); - if (!(table->file->index_ddl_flags(key_info_buffer+idx)& - (HA_DDL_ONLINE| HA_DDL_WITH_LOCK))) - break ; - } - if ((idx < key_count)|| !key_count) - { - /* Re-initialize the create_info, which was changed by prepare table. */ - bzero((char*) &create_info,sizeof(create_info)); - create_info.db_type=DB_TYPE_DEFAULT; - create_info.default_table_charset= thd->variables.collation_database; - /* Cleanup the fields list. We do not want to create existing fields. */ - fields.delete_elements(); - if (real_alter_table(thd, table_list->db, table_list->real_name, - &create_info, table_list, table, - fields, keys, drop, alter, 0, (ORDER*)0, - ALTER_ADD_INDEX, DUP_ERROR)) - /* Don't need to free((gptr) key_info_buffer);*/ - DBUG_RETURN(-1); - } - else - { - if (table->file->add_index(table, key_info_buffer, key_count)|| - build_table_path(path, sizeof(path), table_list->db, - (lower_case_table_names == 2) ? - table_list->alias : table_list->real_name, - reg_ext) == 0 || - mysql_create_frm(thd, path, &create_info, - fields, key_count, key_info_buffer, table->file)) - /* don't need to free((gptr) key_info_buffer);*/ - DBUG_RETURN(-1); - } - /* don't need to free((gptr) key_info_buffer);*/ - DBUG_RETURN(0); -} - - -int mysql_drop_indexes(THD *thd, TABLE_LIST *table_list, - List<Alter_drop> &drop) -{ - List<create_field> fields; - List<Key> keys; - List<Alter_column> alter; - HA_CREATE_INFO create_info; - uint idx; - uint db_options; - uint key_count; - uint *key_numbers; - TABLE *table; - Field **f_ptr; - KEY *key_info; - KEY *key_info_buffer; - char path[FN_REFLEN]; - DBUG_ENTER("mysql_drop_index"); - - /* - Try to use online generation of index. - This requires that all indexes can be created online. - Otherwise, the old alter table procedure is executed. - - Open the table to have access to the correct table handler. - */ - if (!(table=open_ltable(thd,table_list,TL_WRITE_ALLOW_READ))) - DBUG_RETURN(-1); - - /* - The drop_index method takes an array of key numbers. - It cannot get more entries than keys in the table. - */ - key_numbers= (uint*) thd->alloc(sizeof(uint*)*table->keys); - key_count= 0; - - /* - Get the number of each key and check if it can be created online. - */ - List_iterator<Alter_drop> drop_it(drop); - Alter_drop *drop_key; - while ((drop_key= drop_it++)) - { - /* Find the key in the table. */ - key_info=table->key_info; - for (idx=0; idx< table->keys; idx++, key_info++) - { - if (!my_strcasecmp(system_charset_info, key_info->name, drop_key->name)) - break; - } - if (idx>= table->keys) - { - my_error(ER_CANT_DROP_FIELD_OR_KEY, MYF(0), drop_key->name); - /*don't need to free((gptr) key_numbers);*/ - DBUG_RETURN(-1); - } - /* - Check if the key can be generated with the add_index method. - If anyone cannot, then take the old way. - */ - DBUG_PRINT("info", ("dropping index %s", table->key_info[idx].name)); - if (!(table->file->index_ddl_flags(table->key_info+idx)& - (HA_DDL_ONLINE| HA_DDL_WITH_LOCK))) - break ; - key_numbers[key_count++]= idx; - } - - bzero((char*) &create_info,sizeof(create_info)); - create_info.db_type=DB_TYPE_DEFAULT; - create_info.default_table_charset= thd->variables.collation_database; - - if ((drop_key)|| (drop.elements<= 0)) - { - if (real_alter_table(thd, table_list->db, table_list->real_name, - &create_info, table_list, table, - fields, keys, drop, alter, 0, (ORDER*)0, - ALTER_DROP_INDEX, DUP_ERROR)) - /*don't need to free((gptr) key_numbers);*/ - DBUG_RETURN(-1); - } - else - { - db_options= 0; - if (table->file->drop_index(table, key_numbers, key_count)|| - mysql_prepare_table(thd, &create_info, fields, - keys, /*tmp_table*/ 0, db_options, table->file, - key_info_buffer, key_count, - /*select_field_count*/ 0)|| - build_table_path(path, sizeof(path), table_list->db, - (lower_case_table_names == 2) ? - table_list->alias : table_list->real_name, - reg_ext) == 0 || - mysql_create_frm(thd, path, &create_info, - fields, key_count, key_info_buffer, table->file)) - /*don't need to free((gptr) key_numbers);*/ - DBUG_RETURN(-1); - } - - /*don't need to free((gptr) key_numbers);*/ - DBUG_RETURN(0); -} -#endif /* NOT_USED */ /* @@ -2887,15 +2694,21 @@ bool alter_table_manage_keys(TABLE *table, int indexes_were_disabled, /* Alter table + + + NOTE + The structures passed as 'create_info' and 'alter_info' parameters may + be modified by this function. It is responsibility of the caller to make + a copy of create_info in order to provide correct execution in prepared + statements/stored routines. */ int mysql_alter_table(THD *thd,char *new_db, char *new_name, HA_CREATE_INFO *create_info, TABLE_LIST *table_list, - List<create_field> &fields, List<Key> &keys, + Alter_info *alter_info, uint order_num, ORDER *order, - enum enum_duplicates handle_duplicates, bool ignore, - ALTER_INFO *alter_info, bool do_send_ok) + enum enum_duplicates handle_duplicates, bool ignore) { TABLE *table,*new_table; int error; @@ -3064,8 +2877,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, Query_log_event qinfo(thd, thd->query, thd->query_length, 0, FALSE); mysql_bin_log.write(&qinfo); } - if (do_send_ok) - send_ok(thd); + send_ok(thd); } else if (error > 0) { @@ -3091,10 +2903,9 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, restore_record(table,default_values); // Empty record for DEFAULT List_iterator<Alter_drop> drop_it(alter_info->drop_list); - List_iterator<create_field> def_it(fields); + List_iterator<create_field> def_it(alter_info->create_list); List_iterator<Alter_column> alter_it(alter_info->alter_list); - List<create_field> create_list; // Add new fields here - List<Key> key_list; // Add new keys here + Alter_info new_info; // Add new columns and indexes here create_field *def; /* @@ -3140,13 +2951,13 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, def->field=field; if (!def->after) { - create_list.push_back(def); + new_info.create_list.push_back(def); def_it.remove(); } } else { // Use old field value - create_list.push_back(def=new create_field(field,field)); + new_info.create_list.push_back(def= new create_field(field, field)); alter_it.rewind(); // Change default if ALTER Alter_column *alter; while ((alter=alter_it++)) @@ -3167,7 +2978,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, } } def_it.rewind(); - List_iterator<create_field> find_it(create_list); + List_iterator<create_field> find_it(new_info.create_list); while ((def=def_it++)) // Add new columns { if (def->change && ! def->field) @@ -3176,9 +2987,9 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, DBUG_RETURN(-1); } if (!def->after) - create_list.push_back(def); + new_info.create_list.push_back(def); else if (def->after == first_keyword) - create_list.push_front(def); + new_info.create_list.push_front(def); else { create_field *find; @@ -3202,7 +3013,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, table_name); DBUG_RETURN(-1); } - if (!create_list.elements) + if (!new_info.create_list.elements) { my_error(ER_CANT_REMOVE_ALL_FIELDS,MYF(0)); DBUG_RETURN(-1); @@ -3213,8 +3024,8 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, for which some fields exists. */ - List_iterator<Key> key_it(keys); - List_iterator<create_field> field_it(create_list); + List_iterator<Key> key_it(alter_info->key_list); + List_iterator<create_field> field_it(new_info.create_list); List<key_part_spec> key_parts; KEY *key_info=table->key_info; @@ -3272,24 +3083,37 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, key_part_length)); } if (key_parts.elements) - key_list.push_back(new Key(key_info->flags & HA_SPATIAL ? Key::SPATIAL : - (key_info->flags & HA_NOSAME ? - (!my_strcasecmp(system_charset_info, - key_name, primary_key_name) ? - Key::PRIMARY : Key::UNIQUE) : - (key_info->flags & HA_FULLTEXT ? - Key::FULLTEXT : Key::MULTIPLE)), - key_name, - key_info->algorithm, - test(key_info->flags & HA_GENERATED_KEY), - key_parts)); + { + Key *key; + enum Key::Keytype key_type; + + if (key_info->flags & HA_SPATIAL) + key_type= Key::SPATIAL; + else if (key_info->flags & HA_NOSAME) + { + if (! my_strcasecmp(system_charset_info, key_name, primary_key_name)) + key_type= Key::PRIMARY; + else + key_type= Key::UNIQUE; + } + else if (key_info->flags & HA_FULLTEXT) + key_type= Key::FULLTEXT; + else + key_type= Key::MULTIPLE; + + key= new Key(key_type, key_name, + key_info->algorithm, + test(key_info->flags & HA_GENERATED_KEY), + key_parts); + new_info.key_list.push_back(key); + } } { Key *key; while ((key=key_it++)) // Add new keys { if (key->type != Key::FOREIGN_KEY) - key_list.push_back(key); + new_info.key_list.push_back(key); if (key->name && !my_strcasecmp(system_charset_info,key->name,primary_key_name)) { @@ -3393,7 +3217,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, /* We don't log the statement, it will be logged later. */ tmp_disable_binlog(thd); error= mysql_create_table(thd, new_db, tmp_name, - create_info,create_list,key_list,1,0); + create_info, &new_info, 1, 0); reenable_binlog(thd); if (error) DBUG_RETURN(error); @@ -3422,10 +3246,10 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, next_insert_id=thd->next_insert_id; // Remember for loggin copied=deleted=0; if (!new_table->is_view) - error=copy_data_between_tables(table,new_table,create_list, - handle_duplicates, ignore, - order_num, order, &copied, &deleted, - alter_info->keys_onoff); + error= copy_data_between_tables(table, new_table, new_info.create_list, + handle_duplicates, ignore, + order_num, order, &copied, &deleted, + alter_info->keys_onoff); /* No need to have call to alter_table_manage_keys() in the else because in 4.1 we always copy data, except for views. In 5.0 it could happen @@ -3637,8 +3461,7 @@ end_temporary: my_snprintf(tmp_name, sizeof(tmp_name), ER(ER_INSERT_INFO), (ulong) (copied + deleted), (ulong) deleted, (ulong) thd->cuted_fields); - if (do_send_ok) - send_ok(thd,copied+deleted,0L,tmp_name); + send_ok(thd, copied + deleted, 0L, tmp_name); thd->some_tables_deleted=0; DBUG_RETURN(0); @@ -3828,30 +3651,26 @@ copy_data_between_tables(TABLE *from,TABLE *to, mysql_recreate_table() thd Thread handler tables Tables to recreate - do_send_ok If we should send_ok() or leave it to caller RETURN Like mysql_alter_table(). */ -int mysql_recreate_table(THD *thd, TABLE_LIST *table_list, - bool do_send_ok) +int mysql_recreate_table(THD *thd, TABLE_LIST *table_list) { - DBUG_ENTER("mysql_recreate_table"); LEX *lex= thd->lex; HA_CREATE_INFO create_info; - lex->create_list.empty(); - lex->key_list.empty(); - lex->col_list.empty(); - lex->alter_info.reset(); - lex->alter_info.is_simple= 0; // Force full recreate + Alter_info alter_info; + + DBUG_ENTER("mysql_recreate_table"); + bzero((char*) &create_info,sizeof(create_info)); create_info.db_type=DB_TYPE_DEFAULT; create_info.row_type=ROW_TYPE_DEFAULT; create_info.default_table_charset=default_charset_info; + alter_info.is_simple= 0; // Force full recreate DBUG_RETURN(mysql_alter_table(thd, NullS, NullS, &create_info, - table_list, lex->create_list, - lex->key_list, 0, (ORDER *) 0, - DUP_ERROR, 0, &lex->alter_info, do_send_ok)); + table_list, &alter_info, + 0, (ORDER *) 0, DUP_ERROR, 0)); } diff --git a/sql/sql_union.cc b/sql/sql_union.cc index f3f814831f5..615d060a5a8 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -135,6 +135,11 @@ st_select_lex_unit::init_prepare_fake_select_lex(THD *thd) fake_select_lex->table_list.link_in_list((byte *)&result_table_list, (byte **) &result_table_list.next); + for (ORDER *order= (ORDER *) global_parameters->order_list.first; + order; + order= order->next) + order->item= &order->item_ptr; + return options_tmp; } diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index c6f4307f1ea..b72caac46a0 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1021,8 +1021,7 @@ create: TL_READ_NO_INSERT: TL_READ))) YYABORT; - lex->create_list.empty(); - lex->key_list.empty(); + lex->alter_info.reset(); lex->col_list.empty(); lex->change=NullS; bzero((char*) &lex->create_info,sizeof(lex->create_info)); @@ -1040,16 +1039,18 @@ create: if (!lex->current_select->add_table_to_list(lex->thd, $7, NULL, TL_OPTION_UPDATING)) YYABORT; - lex->create_list.empty(); - lex->key_list.empty(); + lex->alter_info.reset(); + lex->alter_info.is_simple= 0; + lex->alter_info.flags= ALTER_ADD_INDEX; lex->col_list.empty(); lex->change=NullS; } '(' key_list ')' { LEX *lex=Lex; + Key *key= new Key($2, $4.str, $5, 0, lex->col_list); - lex->key_list.push_back(new Key($2,$4.str, $5, 0, lex->col_list)); + lex->alter_info.key_list.push_back(key); lex->col_list.empty(); } | CREATE DATABASE opt_if_not_exists ident @@ -1305,29 +1306,34 @@ key_def: key_type opt_ident key_alg '(' key_list ')' { LEX *lex=Lex; - lex->key_list.push_back(new Key($1,$2, $3, 0, lex->col_list)); + Key *key= new Key($1, $2, $3, 0, lex->col_list); + lex->alter_info.key_list.push_back(key); + lex->col_list.empty(); /* Alloced by sql_alloc */ } | opt_constraint constraint_key_type opt_ident key_alg '(' key_list ')' { LEX *lex=Lex; const char *key_name= $3 ? $3:$1; - lex->key_list.push_back(new Key($2, key_name, $4, 0, - lex->col_list)); + Key *key= new Key($2, key_name, $4, 0, lex->col_list); + lex->alter_info.key_list.push_back(key); lex->col_list.empty(); /* Alloced by sql_alloc */ } | opt_constraint FOREIGN KEY_SYM opt_ident '(' key_list ')' references { LEX *lex=Lex; - lex->key_list.push_back(new foreign_key($4 ? $4:$1, lex->col_list, - $8, - lex->ref_list, - lex->fk_delete_opt, - lex->fk_update_opt, - lex->fk_match_option)); - lex->key_list.push_back(new Key(Key::MULTIPLE, $4 ? $4 : $1, - HA_KEY_ALG_UNDEF, 1, - lex->col_list)); + const char *key_name= $4 ? $4 : $1; + Key *key= new foreign_key(key_name, lex->col_list, + $8, + lex->ref_list, + lex->fk_delete_opt, + lex->fk_update_opt, + lex->fk_match_option); + lex->alter_info.key_list.push_back(key); + key= new Key(Key::MULTIPLE, key_name, + HA_KEY_ALG_UNDEF, 1, + lex->col_list); + lex->alter_info.key_list.push_back(key); lex->col_list.empty(); /* Alloced by sql_alloc */ } | constraint opt_check_constraint @@ -1850,8 +1856,6 @@ alter: if (!lex->select_lex.add_table_to_list(thd, $4, NULL, TL_OPTION_UPDATING)) YYABORT; - lex->create_list.empty(); - lex->key_list.empty(); lex->col_list.empty(); lex->select_lex.init_order(); lex->select_lex.db=lex->name=0; @@ -1859,9 +1863,7 @@ alter: lex->create_info.db_type= DB_TYPE_DEFAULT; lex->create_info.default_table_charset= NULL; lex->create_info.row_type= ROW_TYPE_NOT_USED; - lex->alter_info.reset(); - lex->alter_info.is_simple= 1; - lex->alter_info.flags= 0; + lex->alter_info.reset(); } alter_list {} @@ -2019,7 +2021,7 @@ alter_list_item: lex->alter_info.is_simple= 0; lex->alter_info.flags|= ALTER_OPTIONS; } - | order_clause + | alter_order_clause { LEX *lex=Lex; lex->alter_info.is_simple= 0; @@ -3779,6 +3781,29 @@ olap_opt: ; /* + Order by statement in ALTER TABLE +*/ + +alter_order_clause: + ORDER_SYM BY alter_order_list + ; + +alter_order_list: + alter_order_list ',' alter_order_item + | alter_order_item + ; + +alter_order_item: + simple_ident order_dir + { + THD *thd= YYTHD; + bool ascending= ($2 == 1) ? true : false; + if (add_order_to_list(thd, $1, ascending)) + YYABORT; + } + ; + +/* Order by statement in select */ @@ -4030,7 +4055,9 @@ drop: { LEX *lex=Lex; lex->sql_command= SQLCOM_DROP_INDEX; - lex->alter_info.drop_list.empty(); + lex->alter_info.reset(); + lex->alter_info.is_simple= 0; + lex->alter_info.flags= ALTER_DROP_INDEX; lex->alter_info.drop_list.push_back(new Alter_drop(Alter_drop::KEY, $3.str)); if (!lex->current_select->add_table_to_list(lex->thd, $5, NULL, @@ -5899,7 +5926,8 @@ opt_table: | table_ident { LEX *lex=Lex; - if (!lex->current_select->add_table_to_list(lex->thd, $1,NULL,0)) + if (!lex->current_select->add_table_to_list(lex->thd, $1,NULL, + TL_OPTION_UPDATING)) YYABORT; if (lex->grant == GLOBAL_ACLS) lex->grant = TABLE_ACLS & ~GRANT_ACL; diff --git a/sql/table.cc b/sql/table.cc index dab2f978327..a85da8395e7 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -393,17 +393,6 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, { char *val= (char*) interval->type_names[count]; interval->type_lengths[count]= strlen(val); - /* - Replace all ',' symbols with NAMES_SEP_CHAR. - See the comment in unireg.cc, pack_fields() function - for details. - */ - for (uint cnt= 0 ; cnt < interval->type_lengths[count] ; cnt++) - { - char c= val[cnt]; - if (c == ',') - val[cnt]= NAMES_SEP_CHAR; - } } interval->type_lengths[count]= 0; } diff --git a/sql/unireg.cc b/sql/unireg.cc index 4e1a68ae90f..e5ee0222f20 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -657,29 +657,48 @@ static bool pack_fields(File file, List<create_field> &create_fields, { if (field->interval_id > int_count) { - int_count=field->interval_id; - tmp.append(NAMES_SEP_CHAR); - for (const char **pos=field->interval->type_names ; *pos ; pos++) - { - char *val= (char*) *pos; - uint str_len= strlen(val); - /* - Note, hack: in old frm NAMES_SEP_CHAR is used to separate - names in the interval (ENUM/SET). To allow names to contain - NAMES_SEP_CHAR, we replace it with a comma before writing frm. - Backward conversion is done during frm file opening, - See table.cc, openfrm() function - */ - for (uint cnt= 0 ; cnt < str_len ; cnt++) + unsigned char sep= 0; + unsigned char occ[256]; + uint i; + unsigned char *val= NULL; + + bzero(occ, sizeof(occ)); + + for (i=0; (val= (unsigned char*) field->interval->type_names[i]); i++) + for (uint j = 0; j < field->interval->type_lengths[i]; j++) + occ[(unsigned int) (val[j])]= 1; + + if (!occ[(unsigned char)NAMES_SEP_CHAR]) + sep= (unsigned char) NAMES_SEP_CHAR; + else if (!occ[(unsigned int)',']) + sep= ','; + else + { + for (uint i=1; i<256; i++) + { + if(!occ[i]) + { + sep= i; + break; + } + } + + if(!sep) /* disaster, enum uses all characters, none left as separator */ { - char c= val[cnt]; - if (c == NAMES_SEP_CHAR) - val[cnt]= ','; + my_message(ER_WRONG_FIELD_TERMINATORS,ER(ER_WRONG_FIELD_TERMINATORS), + MYF(0)); + DBUG_RETURN(1); } - tmp.append(*pos); - tmp.append(NAMES_SEP_CHAR); - } - tmp.append('\0'); // End of intervall + } + + int_count= field->interval_id; + tmp.append(sep); + for (const char **pos=field->interval->type_names ; *pos ; pos++) + { + tmp.append(*pos); + tmp.append(sep); + } + tmp.append('\0'); // End of intervall } } if (my_write(file,(byte*) tmp.ptr(),tmp.length(),MYF_RW)) |