Commit db4b7677 authored by unknown's avatar unknown

MDEV-4995: mariadb_dyncol_column_count returns error when passing an empty dynamic column

An empty string processing added to mariadb_dyncol_column_count().
parent 232eb75b
...@@ -4327,6 +4327,10 @@ mariadb_dyncol_column_count(DYNAMIC_COLUMN *str, uint *column_count) ...@@ -4327,6 +4327,10 @@ mariadb_dyncol_column_count(DYNAMIC_COLUMN *str, uint *column_count)
DYN_HEADER header; DYN_HEADER header;
enum enum_dyncol_func_result rc; enum enum_dyncol_func_result rc;
*(column_count)= 0;
if (str->length == 0)
return ER_DYNCOL_OK;
if ((rc= init_read_hdr(&header, str)) < 0) if ((rc= init_read_hdr(&header, str)) < 0)
return rc; return rc;
*column_count= header.column_count; *column_count= header.column_count;
......
...@@ -606,7 +606,7 @@ void test_empty_string() ...@@ -606,7 +606,7 @@ void test_empty_string()
dynamic_column_column_free(&str); dynamic_column_column_free(&str);
} }
void test_mdev_4994() static void test_mdev_4994()
{ {
DYNAMIC_COLUMN dyncol; DYNAMIC_COLUMN dyncol;
LEX_STRING key= {0,0}; LEX_STRING key= {0,0};
...@@ -621,6 +621,17 @@ void test_mdev_4994() ...@@ -621,6 +621,17 @@ void test_mdev_4994()
dynamic_column_column_free(&dyncol); dynamic_column_column_free(&dyncol);
} }
static void test_mdev_4995()
{
DYNAMIC_COLUMN dyncol;
uint column_count= 5;
int rc;
dynamic_column_initialize(&dyncol);
rc= mariadb_dyncol_column_count(&dyncol,&column_count);
ok( (rc == ER_DYNCOL_OK), "%s", "test_mdev_4995");
}
void test_update_many(uint *column_numbers, uint *column_values, void test_update_many(uint *column_numbers, uint *column_values,
uint column_count, uint column_count,
...@@ -686,7 +697,7 @@ int main(int argc __attribute__((unused)), char **argv) ...@@ -686,7 +697,7 @@ int main(int argc __attribute__((unused)), char **argv)
char *big_string= (char *)malloc(1024*1024); char *big_string= (char *)malloc(1024*1024);
MY_INIT(argv[0]); MY_INIT(argv[0]);
plan(61); plan(62);
if (!big_string) if (!big_string)
exit(1); exit(1);
...@@ -818,6 +829,7 @@ int main(int argc __attribute__((unused)), char **argv) ...@@ -818,6 +829,7 @@ int main(int argc __attribute__((unused)), char **argv)
result_numbers, result_values, 3); result_numbers, result_values, 3);
} }
test_mdev_4994(); test_mdev_4994();
test_mdev_4995();
my_end(0); my_end(0);
return exit_status(); return exit_status();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment