mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
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*).
This commit is contained in:
@@ -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 }
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user