Commit fe9dc5e7 authored by monty@narttu.mysql.fi's avatar monty@narttu.mysql.fi

Add column names for metadata when running mysql with -T

Change metadata info so that that MIN() and code MAX() reports that they can return NULL. Bug #324
parent 16504220
......@@ -1580,11 +1580,12 @@ print_field_types(MYSQL_RES *result)
MYSQL_FIELD *field;
while ((field = mysql_fetch_field(result)))
{
tee_fprintf(PAGER,"%s '%s' %d %d %d %d %d\n",
tee_fprintf(PAGER,"Name: '%s'\nTable: '%s'\nType: %d\nLength: %d\nMax length: %d\nIs_null: %d\nFlags: %d\nDecimals: %d\n\n",
field->name,
field->table ? "" : field->table,
(int) field->type,
field->length, field->max_length,
field->length, field->max_length,
!IS_NOT_NULL(field->flags),
field->flags, field->decimals);
}
tee_puts("", PAGER);
......
......@@ -212,6 +212,12 @@ select * from t1;
type_bool type_tiny type_short type_mediumint type_bigint type_decimal type_numeric empty_char type_char type_varchar type_timestamp type_date type_time type_datetime type_year type_enum type_set type_tinyblob type_blob type_medium_blob type_long_blob
0 1 NULL NULL NULL NULL NULL NULL NULL NULL 20030207100001 0000-00-00 00:00:00 0000-00-00 00:00:00 NULL NULL NULL NULL NULL NULL NULL
drop table t1;
create table t1 (a int not null);
create table t2 select max(a) from t1;
show columns from t2;
Field Type Null Key Default Extra
max(a) bigint(20) YES NULL
drop table t1,t2;
create table t1 (c decimal, d double, f float, r real);
show columns from t1;
Field Type Null Key Default Extra
......
......@@ -114,6 +114,13 @@ insert into t1 (type_timestamp) values ("2003-02-07 10:00:01");
select * from t1;
drop table t1;
#
# Check metadata
#
create table t1 (a int not null);
create table t2 select max(a) from t1;
show columns from t2;
drop table t1,t2;
# Check auto conversions of types
......
......@@ -46,7 +46,11 @@ Item_sum::Item_sum(List<Item> &list)
void Item_sum::make_field(Send_field *tmp_field)
{
if (args[0]->type() == Item::FIELD_ITEM && keep_field_type())
{
((Item_field*) args[0])->field->make_field(tmp_field);
if (maybe_null)
tmp_field->flags&= ~NOT_NULL_FLAG;
}
else
{
tmp_field->flags=0;
......@@ -158,7 +162,8 @@ Item_sum_hybrid::fix_fields(THD *thd,TABLE_LIST *tables)
else
max_length=item->max_length;
decimals=item->decimals;
maybe_null=item->maybe_null;
/* MIN/MAX can return NULL for empty set indepedent of the used column */
maybe_null= 1;
binary=item->binary;
unsigned_flag=item->unsigned_flag;
result_field=0;
......
......@@ -165,7 +165,6 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
}
else
{
read_file_from_client=0;
#ifdef DONT_ALLOW_FULL_LOAD_DATA_PATHS
ex->file_name+=dirname_length(ex->file_name);
#endif
......
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