mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
SQL: hide implicitly added columns from SELECT *
This commit is contained in:
committed by
Aleksey Midenkov
parent
70168978fc
commit
e094228631
@@ -193,6 +193,7 @@ enum enum_indicator_type
|
|||||||
#define WITHOUT_SYSTEM_VERSIONING_FLAG (1 << 29) /* column that doesn't support
|
#define WITHOUT_SYSTEM_VERSIONING_FLAG (1 << 29) /* column that doesn't support
|
||||||
system versioning when table
|
system versioning when table
|
||||||
itself supports it*/
|
itself supports it*/
|
||||||
|
#define HIDDEN_FLAG (1 << 31) /* hide from SELECT * */
|
||||||
|
|
||||||
#define REFRESH_GRANT (1ULL << 0) /* Refresh grant tables */
|
#define REFRESH_GRANT (1ULL << 0) /* Refresh grant tables */
|
||||||
#define REFRESH_LOG (1ULL << 1) /* Start on new log file */
|
#define REFRESH_LOG (1ULL << 1) /* Start on new log file */
|
||||||
|
@@ -241,6 +241,21 @@ RJ2_x1 y1 x2 y2
|
|||||||
1 3 1 2
|
1 3 1 2
|
||||||
NULL NULL 2 1
|
NULL NULL 2 1
|
||||||
NULL NULL 3 1
|
NULL NULL 3 1
|
||||||
|
create table t1(
|
||||||
|
A int
|
||||||
|
) with system versioning engine=myisam;
|
||||||
|
insert into t1 values(1);
|
||||||
|
select * from t1;
|
||||||
|
A
|
||||||
|
1
|
||||||
|
create or replace table t1(
|
||||||
|
A int
|
||||||
|
) with system versioning engine=innodb;
|
||||||
|
insert into t1 values(1);
|
||||||
|
select * from t1;
|
||||||
|
A
|
||||||
|
1
|
||||||
|
drop table t1;
|
||||||
call verify_vtq;
|
call verify_vtq;
|
||||||
No A B C D
|
No A B C D
|
||||||
1 1 1 1 1
|
1 1 1 1 1
|
||||||
@@ -251,6 +266,7 @@ No A B C D
|
|||||||
6 1 1 1 1
|
6 1 1 1 1
|
||||||
7 1 1 1 1
|
7 1 1 1 1
|
||||||
8 1 1 1 1
|
8 1 1 1 1
|
||||||
|
9 1 1 1 1
|
||||||
drop procedure test_01;
|
drop procedure test_01;
|
||||||
drop procedure test_02;
|
drop procedure test_02;
|
||||||
drop procedure verify_vtq;
|
drop procedure verify_vtq;
|
||||||
|
@@ -89,6 +89,22 @@ call test_01('bigint unsigned', 'innodb', 'commit_ts(sys_start)');
|
|||||||
call test_02('timestamp(6)', 'myisam', 'sys_start');
|
call test_02('timestamp(6)', 'myisam', 'sys_start');
|
||||||
call test_02('bigint unsigned', 'innodb', 'commit_ts(sys_start)');
|
call test_02('bigint unsigned', 'innodb', 'commit_ts(sys_start)');
|
||||||
|
|
||||||
|
# Test wildcard expansion on hidden fields.
|
||||||
|
create table t1(
|
||||||
|
A int
|
||||||
|
) with system versioning engine=myisam;
|
||||||
|
insert into t1 values(1);
|
||||||
|
select * from t1;
|
||||||
|
|
||||||
|
create or replace table t1(
|
||||||
|
A int
|
||||||
|
) with system versioning engine=innodb;
|
||||||
|
insert into t1 values(1);
|
||||||
|
select * from t1;
|
||||||
|
|
||||||
|
drop table t1;
|
||||||
|
# End test wildcard expansion.
|
||||||
|
|
||||||
call verify_vtq;
|
call verify_vtq;
|
||||||
|
|
||||||
drop procedure test_01;
|
drop procedure test_01;
|
||||||
|
@@ -4281,6 +4281,8 @@ bool check_expression(Virtual_column_info *vcol, const char *name,
|
|||||||
#define FIELDFLAG_BITFIELD 512U // mangled with decimals!
|
#define FIELDFLAG_BITFIELD 512U // mangled with decimals!
|
||||||
#define FIELDFLAG_BLOB 1024U // mangled with decimals!
|
#define FIELDFLAG_BLOB 1024U // mangled with decimals!
|
||||||
#define FIELDFLAG_GEOM 2048U // mangled with decimals!
|
#define FIELDFLAG_GEOM 2048U // mangled with decimals!
|
||||||
|
// Do not show field in SELECT *. Hope GEOM field is never hidden.
|
||||||
|
#define FIELDFLAG_HIDDEN 2048U
|
||||||
|
|
||||||
#define FIELDFLAG_TREAT_BIT_AS_CHAR 4096U /* use Field_bit_as_char */
|
#define FIELDFLAG_TREAT_BIT_AS_CHAR 4096U /* use Field_bit_as_char */
|
||||||
#define FIELDFLAG_LONG_DECIMAL 8192U
|
#define FIELDFLAG_LONG_DECIMAL 8192U
|
||||||
@@ -4312,5 +4314,6 @@ bool check_expression(Virtual_column_info *vcol, const char *name,
|
|||||||
#define f_bit_as_char(x) ((x) & FIELDFLAG_TREAT_BIT_AS_CHAR)
|
#define f_bit_as_char(x) ((x) & FIELDFLAG_TREAT_BIT_AS_CHAR)
|
||||||
#define f_is_hex_escape(x) ((x) & FIELDFLAG_HEX_ESCAPE)
|
#define f_is_hex_escape(x) ((x) & FIELDFLAG_HEX_ESCAPE)
|
||||||
#define f_without_system_versioning(x) ((x) & FIELDFLAG_WITHOUT_SYSTEM_VERSIONING)
|
#define f_without_system_versioning(x) ((x) & FIELDFLAG_WITHOUT_SYSTEM_VERSIONING)
|
||||||
|
#define f_hidden(x) ((x) & FIELDFLAG_HIDDEN)
|
||||||
|
|
||||||
#endif /* FIELD_INCLUDED */
|
#endif /* FIELD_INCLUDED */
|
||||||
|
4160
sql/field.h.orig
Normal file
4160
sql/field.h.orig
Normal file
File diff suppressed because it is too large
Load Diff
@@ -6570,16 +6570,16 @@ static bool create_sys_trx_field(THD *thd, const char *field_name,
|
|||||||
memset(f, 0, sizeof(*f));
|
memset(f, 0, sizeof(*f));
|
||||||
f->field_name= field_name;
|
f->field_name= field_name;
|
||||||
f->charset= system_charset_info;
|
f->charset= system_charset_info;
|
||||||
|
f->flags= NOT_NULL_FLAG | HIDDEN_FLAG;
|
||||||
if (integer_fields)
|
if (integer_fields)
|
||||||
{
|
{
|
||||||
f->sql_type= MYSQL_TYPE_LONGLONG;
|
f->sql_type= MYSQL_TYPE_LONGLONG;
|
||||||
f->flags= UNSIGNED_FLAG | NOT_NULL_FLAG;
|
f->flags|= UNSIGNED_FLAG;
|
||||||
f->length= MY_INT64_NUM_DECIMAL_DIGITS;
|
f->length= MY_INT64_NUM_DECIMAL_DIGITS;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
f->sql_type= MYSQL_TYPE_TIMESTAMP2;
|
f->sql_type= MYSQL_TYPE_TIMESTAMP2;
|
||||||
f->flags= NOT_NULL_FLAG;
|
|
||||||
f->length= 6;
|
f->length= 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -7568,6 +7568,14 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
|
|||||||
if (!(item= field_iterator.create_item(thd)))
|
if (!(item= field_iterator.create_item(thd)))
|
||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
|
|
||||||
|
if (item->type() == Item::FIELD_ITEM)
|
||||||
|
{
|
||||||
|
Item_field *f= static_cast<Item_field *>(item);
|
||||||
|
DBUG_ASSERT(f->field);
|
||||||
|
if (f->field->flags & HIDDEN_FLAG)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* cache the table for the Item_fields inserted by expanding stars */
|
/* cache the table for the Item_fields inserted by expanding stars */
|
||||||
if (item->type() == Item::FIELD_ITEM && tables->cacheable_table)
|
if (item->type() == Item::FIELD_ITEM && tables->cacheable_table)
|
||||||
((Item_field *)item)->cached_table= tables;
|
((Item_field *)item)->cached_table= tables;
|
||||||
|
@@ -2991,6 +2991,8 @@ bool Column_definition::prepare_create_field(uint *blob_columns,
|
|||||||
pack_flag|= FIELDFLAG_NO_DEFAULT;
|
pack_flag|= FIELDFLAG_NO_DEFAULT;
|
||||||
if (flags & WITHOUT_SYSTEM_VERSIONING_FLAG)
|
if (flags & WITHOUT_SYSTEM_VERSIONING_FLAG)
|
||||||
pack_flag|= FIELDFLAG_WITHOUT_SYSTEM_VERSIONING;
|
pack_flag|= FIELDFLAG_WITHOUT_SYSTEM_VERSIONING;
|
||||||
|
if (flags & HIDDEN_FLAG)
|
||||||
|
pack_flag|= FIELDFLAG_HIDDEN;
|
||||||
DBUG_RETURN(false);
|
DBUG_RETURN(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2020,6 +2020,9 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write,
|
|||||||
if (f_without_system_versioning(pack_flag))
|
if (f_without_system_versioning(pack_flag))
|
||||||
reg_field->flags|= WITHOUT_SYSTEM_VERSIONING_FLAG;
|
reg_field->flags|= WITHOUT_SYSTEM_VERSIONING_FLAG;
|
||||||
|
|
||||||
|
if (f_hidden(pack_flag))
|
||||||
|
reg_field->flags|= HIDDEN_FLAG;
|
||||||
|
|
||||||
if (reg_field->unireg_check == Field::NEXT_NUMBER)
|
if (reg_field->unireg_check == Field::NEXT_NUMBER)
|
||||||
share->found_next_number_field= field_ptr;
|
share->found_next_number_field= field_ptr;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user