mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Bug#12337762 : MYSQL_LIST_FIELDS() RETURNS WRONG CHARSET FOR CHAR/VARCHAR/TEXT
COLUMNS IN VIEWS Issue: charset value for a Column, returned by MYSQL_LIST_FIELDS(), was not same for Table and View. This was because, for view, field charset was not being returned. Solution: Added definition of function "charset_for_protocol()" in calss Item_ident_for_show to return field charset value.
This commit is contained in:
@@ -1672,6 +1672,8 @@ public:
|
|||||||
String *val_str(String *str) { return field->val_str(str); }
|
String *val_str(String *str) { return field->val_str(str); }
|
||||||
my_decimal *val_decimal(my_decimal *dec) { return field->val_decimal(dec); }
|
my_decimal *val_decimal(my_decimal *dec) { return field->val_decimal(dec); }
|
||||||
void make_field(Send_field *tmp_field);
|
void make_field(Send_field *tmp_field);
|
||||||
|
CHARSET_INFO *charset_for_protocol(void) const
|
||||||
|
{ return field->charset_for_protocol(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -19588,6 +19588,81 @@ static void test_bug11766854()
|
|||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Bug#12337762: 60075: MYSQL_LIST_FIELDS() RETURNS WRONG CHARSET FOR
|
||||||
|
CHAR/VARCHAR/TEXT COLUMNS IN VIEWS
|
||||||
|
*/
|
||||||
|
static void test_bug12337762()
|
||||||
|
{
|
||||||
|
int rc,i=0;
|
||||||
|
MYSQL_RES *result;
|
||||||
|
MYSQL_FIELD *field;
|
||||||
|
unsigned int tab_charsetnr[3]= {0};
|
||||||
|
|
||||||
|
DBUG_ENTER("test_bug12337762");
|
||||||
|
myheader("test_bug12337762");
|
||||||
|
|
||||||
|
/*
|
||||||
|
Creating table with specific charset.
|
||||||
|
*/
|
||||||
|
rc= mysql_query(mysql, "drop table if exists charset_tab");
|
||||||
|
rc= mysql_query(mysql, "create table charset_tab("\
|
||||||
|
"txt1 varchar(32) character set Latin1,"\
|
||||||
|
"txt2 varchar(32) character set Latin1 collate latin1_bin,"\
|
||||||
|
"txt3 varchar(32) character set utf8 collate utf8_bin"\
|
||||||
|
")");
|
||||||
|
|
||||||
|
DIE_UNLESS(rc == 0);
|
||||||
|
DIE_IF(mysql_errno(mysql));
|
||||||
|
|
||||||
|
/*
|
||||||
|
Creating view from table created earlier.
|
||||||
|
*/
|
||||||
|
rc= mysql_query(mysql, "drop view if exists charset_view");
|
||||||
|
rc= mysql_query(mysql, "create view charset_view as "\
|
||||||
|
"select * from charset_tab;");
|
||||||
|
DIE_UNLESS(rc == 0);
|
||||||
|
DIE_IF(mysql_errno(mysql));
|
||||||
|
|
||||||
|
/*
|
||||||
|
Checking field information for table.
|
||||||
|
*/
|
||||||
|
result= mysql_list_fields(mysql, "charset_tab", NULL);
|
||||||
|
DIE_IF(mysql_errno(mysql));
|
||||||
|
i=0;
|
||||||
|
while((field= mysql_fetch_field(result)))
|
||||||
|
{
|
||||||
|
printf("field name %s\n", field->name);
|
||||||
|
printf("field table %s\n", field->table);
|
||||||
|
printf("field type %d\n", field->type);
|
||||||
|
printf("field charset %d\n", field->charsetnr);
|
||||||
|
tab_charsetnr[i++]= field->charsetnr;
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
mysql_free_result(result);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Checking field information for view.
|
||||||
|
*/
|
||||||
|
result= mysql_list_fields(mysql, "charset_view", NULL);
|
||||||
|
DIE_IF(mysql_errno(mysql));
|
||||||
|
i=0;
|
||||||
|
while((field= mysql_fetch_field(result)))
|
||||||
|
{
|
||||||
|
printf("field name %s\n", field->name);
|
||||||
|
printf("field table %s\n", field->table);
|
||||||
|
printf("field type %d\n", field->type);
|
||||||
|
printf("field charset %d\n", field->charsetnr);
|
||||||
|
printf("\n");
|
||||||
|
/*
|
||||||
|
charset value for field must be same for both, view and table.
|
||||||
|
*/
|
||||||
|
DIE_UNLESS(field->charsetnr == tab_charsetnr[i++]);
|
||||||
|
}
|
||||||
|
mysql_free_result(result);
|
||||||
|
|
||||||
|
DBUG_VOID_RETURN;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Read and parse arguments and MySQL options from my.cnf
|
Read and parse arguments and MySQL options from my.cnf
|
||||||
@@ -19933,6 +20008,7 @@ static struct my_tests_st my_tests[]= {
|
|||||||
{ "test_bug57058", test_bug57058 },
|
{ "test_bug57058", test_bug57058 },
|
||||||
{ "test_bug56976", test_bug56976 },
|
{ "test_bug56976", test_bug56976 },
|
||||||
{ "test_bug11766854", test_bug11766854 },
|
{ "test_bug11766854", test_bug11766854 },
|
||||||
|
{ "test_bug12337762", test_bug12337762 },
|
||||||
{ 0, 0 }
|
{ 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -20071,29 +20147,29 @@ int main(int argc, char **argv)
|
|||||||
if (!argc)
|
if (!argc)
|
||||||
{
|
{
|
||||||
for (fptr= my_tests; fptr->name; fptr++)
|
for (fptr= my_tests; fptr->name; fptr++)
|
||||||
(*fptr->function)();
|
(*fptr->function)();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for ( ; *argv ; argv++)
|
for ( ; *argv ; argv++)
|
||||||
{
|
{
|
||||||
for (fptr= my_tests; fptr->name; fptr++)
|
for (fptr= my_tests; fptr->name; fptr++)
|
||||||
{
|
{
|
||||||
if (!strcmp(fptr->name, *argv))
|
if (!strcmp(fptr->name, *argv))
|
||||||
{
|
{
|
||||||
(*fptr->function)();
|
(*fptr->function)();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!fptr->name)
|
if (!fptr->name)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "\n\nGiven test not found: '%s'\n", *argv);
|
fprintf(stderr, "\n\nGiven test not found: '%s'\n", *argv);
|
||||||
fprintf(stderr, "See legal test names with %s -T\n\nAborting!\n",
|
fprintf(stderr, "See legal test names with %s -T\n\nAborting!\n",
|
||||||
my_progname);
|
my_progname);
|
||||||
client_disconnect(mysql, 1);
|
client_disconnect(mysql, 1);
|
||||||
free_defaults(defaults_argv);
|
free_defaults(defaults_argv);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user