summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2019-02-21 21:44:44 +0400
committerAlexander Barkov <bar@mariadb.com>2019-02-25 12:29:42 +0400
commitb25ad1bc47d2db600ab241d889f9f8f9e775b99d (patch)
tree52de378bed623d6f90cffb3d5d011ba6ee2c3668 /tests
parent1ab2e7573a378144fc120e97e8218081d17cfa89 (diff)
downloadmariadb-git-b25ad1bc47d2db600ab241d889f9f8f9e775b99d.tar.gz
MDEV-18408 Assertion `0' failed in Item::val_native_result / Timestamp_or_zero_datetime_native_null::Timestamp_or_zero_datetime_native_null upon mysqld_list_fields after crash recovery
The problem happened because Item_ident_for_show did not implement val_native(). Solution: - Removing class Item_ident_for_show - Implementing a new method Protocol::send_list_fields() instead, which accepts a List<Field> instead of List<Item> as input. Now no any Item creation is done during mysqld_list_fields(). Adding helper methods, to reuse the code easier: - Moved a part of Protocol::send_result_set_metadata(), responsible for sending an individual field metadata, into a new method Protocol_text::store_field_metadata(). Reusing it in both send_list_fields() and send_result_set_metadata(). - Adding Protocol_text::store_field_metadata() - Adding Protocol_text::store_field_metadata_for_list_fields() Note, this patch also automatically fixed another bug: MDEV-18685 mysql_list_fields() returns DEFAULT 0 instead of DEFAULT NULL for view columns The reason for this bug was that Item_ident_for_show::val_xxx() and get_date() did not check field->is_null() before calling field->val_xxx()/get_date(). Now the default value is correctly sent by Protocol_text::store(Field*).
Diffstat (limited to 'tests')
-rw-r--r--tests/mysql_client_test.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 2d238d84d54..6d17fa74005 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -8467,6 +8467,43 @@ static void test_list_fields_default()
}
+/**
+ Note, this test covers MDEV-18408 and MDEV-18685
+*/
+
+static void test_mdev18408()
+{
+ MYSQL_RES *result;
+ int rc;
+ myheader("test_mdev18408s");
+
+ rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
+ myquery(rc);
+
+ rc= mysql_query(mysql, "DROP VIEW IF EXISTS v1");
+ myquery(rc);
+
+ rc= mysql_query(mysql, "CREATE TABLE t1 (c1 TIMESTAMP NULL DEFAULT NULL)");
+ myquery(rc);
+
+ rc= mysql_query(mysql, "CREATE VIEW v1 AS SELECT c1 FROM t1");
+ myquery(rc);
+
+ result= mysql_list_fields(mysql, "v1", NULL);
+ mytest(result);
+
+ rc= my_process_result_set(result);
+ DIE_UNLESS(rc == 0);
+
+ verify_prepare_field(result, 0, "c1", "c1", MYSQL_TYPE_TIMESTAMP,
+ "v1", "v1", current_db, 19, 0);
+
+ mysql_free_result(result);
+ myquery(mysql_query(mysql, "DROP VIEW v1"));
+ myquery(mysql_query(mysql, "DROP TABLE t1"));
+}
+
+
static void test_bug19671()
{
MYSQL_RES *result;
@@ -8493,7 +8530,7 @@ static void test_bug19671()
DIE_UNLESS(rc == 0);
verify_prepare_field(result, 0, "f1", "f1", MYSQL_TYPE_LONG,
- "v1", "v1", current_db, 11, "0");
+ "v1", "v1", current_db, 11, NULL);
mysql_free_result(result);
myquery(mysql_query(mysql, "drop view v1"));
@@ -20977,6 +21014,7 @@ static struct my_tests_st my_tests[]= {
{ "test_bulk_delete", test_bulk_delete },
#endif
{ "test_explain_meta", test_explain_meta },
+ { "test_mdev18408", test_mdev18408 },
{ 0, 0 }
};