mariadb/tests
Alexander Barkov f6138883b1 MDEV-11672 mysql_list_field() returns wrong default values for VIEW
The problem happened because Item_ident_for_show::field_type() always
returned MYSQL_TYPE_DOUBLE and ignored the actual data type of the
referenced Field. As a result, the execution always used
Item_ident_for_show::val_real() to send the default value of the field,
so most default values for non-numeric types were displayed as '0'.

This patch:
1. Cleanup:
   a. Removes Send_field::charsetnr, as it's been unused since
      introduction of Item::charset_for_protocol() in MySQL-5.5.
   b. Adds the "const" qualifier to Field::char_length().
      This is needed for (5.a), see below.

2. Introduces a new virtual method Type_handler::charset_for_protocol(),
   returning item->collation.collation for string data types, or
   &my_charset_bin for non-string data types.

3. Changes Item::charset_for_protocol() from virtual to non-virtual.
   It now calls type_handler()->charset_for_protocol().
   As a good side effect, duplicate code in Item::charset_for_protocol() and
   Item_temporal_hybrid_func::charset_for_protocol() is now gone.

4. Fixes Item_ident_for_show::field_type() to correctly return
   its data type according to the data type of the referenced field.
   This actually fixes the problem reported in MDEV-11672.
   Now the default value is sent using a correct method, e.g.
   val_str() for VARCHAR/TEXT, or val_int() for INT/BIGINT.
   This required additional changes:
   a. in DBUG_ASSERT in Protocol::store(const char *,size_t,CHARSET_INFO),
      This method is now used by mysqld_list_fields(), which
      (unlike normal SELECT queries) does not set
      field_types/field_pos/field_count.
   b. Item_ident_for_show::Item_ident_for_show() now set standard attributes
      (collation, decimals, max_length, unsigned_flag) according to the
      referenced field, to make charset_for_protocol() return the correct
      value and to make mysqld_list_fields() correctly send default
      values.

5. In order to share the code between Item_field::set_field() and
   Item_ident_for_show::Item_ident_for_show():
   a. Introduces a new method Type_std_attributes::set(const Field*)
   b. To make (a) possible, moves Item::fix_char_length() from Item
      to Type_std_attributes, also moves char_to_byte_length_safe()
      from item.h to sql_type.h
   c. Additionally, moves Item::fix_length_and_charset() and
      Item::max_char_length() from Item to Type_std_attributes.
      This is not directly needed for the fix and is done just for symmetry
      with fix_char_length(), as these three methods are directly related
      to each other.
2016-12-29 07:40:49 +04:00
..
async_queries.c Fix spelling: occurred, execute, which etc 2016-03-04 02:09:37 +02:00
auto_increment.res
auto_increment.tst
big_record.pl Updated/added copyright headers 2011-06-30 17:46:53 +02:00
bug25714.c Fixes to get all test to run on MacosX Lion 10.7 2015-11-29 17:51:23 +02:00
check_async_queries.pl MWL#192: Non-blocking client API for libmysqlclient. 2011-09-20 12:49:25 +02:00
CMakeLists.txt Add C/C as a submodule in libmariadb/ 2016-09-12 17:46:35 +02:00
connect_test.c Updated/added copyright headers 2014-01-06 10:52:35 +05:30
consistent_snapshot.pl MWL#116: Efficient group commit: PBXT part 2010-10-15 15:42:06 +02:00
deadlock_test.c Updated/added copyright header. Added line "use is subject to license terms" 2014-02-17 18:19:04 +05:30
drop_test.pl Updated/added copyright header. Added line "use is subject to license terms" 2014-02-17 18:19:04 +05:30
export.pl Updated/added copyright header. Added line "use is subject to license terms" 2014-02-17 18:19:04 +05:30
fork2_test.pl Updated/added copyright header. Added line "use is subject to license terms" 2014-02-17 18:19:04 +05:30
fork_big.pl Changing the copyright headers a bit to be complaint with the standards 2014-08-27 16:06:50 +02:00
fork_big2.pl mysql-5.5.41 merge 2014-12-19 11:35:44 +01:00
function.res Arjens LOG functions changes with small changes and tests added to mysql-test 2002-07-17 12:11:48 +04:00
function.tst Arjens LOG functions changes with small changes and tests added to mysql-test 2002-07-17 12:11:48 +04:00
grant.pl Initail merge with MySQL 5.1 (XtraDB still needs to be merged) 2011-11-21 19:13:14 +02:00
grant.res Merge with 4.0.18 2004-02-11 00:06:46 +01:00
index_corrupt.pl Updated/added copyright header. Added line "use is subject to license terms" 2014-02-17 18:19:04 +05:30
insert_and_repair.pl Updated/added copyright header. Added line "use is subject to license terms" 2014-02-17 18:19:04 +05:30
insert_test.c Updated/added copyright headers 2014-01-06 10:52:35 +05:30
list_test.c Updated/added copyright headers 2014-01-06 10:52:35 +05:30
lock_test.pl Updated/added copyright header. Added line "use is subject to license terms" 2014-02-17 18:19:04 +05:30
lock_test.res
mail_to_db.pl This patch removes the remaining TYPE= code from MySQL. It cleans up a number of tests where it was being called still (and failing). Also I cleaned up all of the extra scripts so that they now work. 2006-02-12 13:26:30 -08:00
myisam-big-rows.tst A follow-up on WL#5154 and WL#5182: remove forgotten options. 2010-03-03 22:22:02 +03:00
mysql_client_fw.c MDEV-9293 - Use MariaDB's Connector/C in server 2016-08-25 16:27:57 +02:00
mysql_client_test.c MDEV-11672 mysql_list_field() returns wrong default values for VIEW 2016-12-29 07:40:49 +04:00
nonblock-wrappers.h After-review changes 2016-09-12 17:51:50 +02:00
pmail.pl Updated/added copyright header. Added line "use is subject to license terms" 2014-02-17 18:19:04 +05:30
rename_test.pl Updated/added copyright header. Added line "use is subject to license terms" 2014-02-17 18:19:04 +05:30
restore-lock.smack
select_test.c Updated/added copyright headers 2014-01-06 10:52:35 +05:30
showdb_test.c Updated/added copyright headers 2014-01-06 10:52:35 +05:30
ssl_test.c Updated/added copyright headers 2014-01-06 10:52:35 +05:30
table_types.pl Updated/added copyright header. Added line "use is subject to license terms" 2014-02-17 18:19:04 +05:30
test_delayed_insert.pl Updated/added copyright header. Added line "use is subject to license terms" 2014-02-17 18:19:04 +05:30
thread_test.c mysql-5.5.18 merge 2011-11-03 19:17:05 +01:00
truncate.pl Updated/added copyright header. Added line "use is subject to license terms" 2014-02-17 18:19:04 +05:30