mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 02:05:57 +01:00
Merge sgluhov@bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/gluh/MySQL/Merge/5.0-kt sql/set_var.cc: Auto merged sql/sql_parse.cc: Auto merged
This commit is contained in:
commit
b5f89708eb
18 changed files with 229 additions and 129 deletions
|
@ -22,6 +22,7 @@ extern const char *not_error_sqlstate;
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern CHARSET_INFO *default_client_charset_info;
|
||||
MYSQL_FIELD *unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
|
||||
my_bool default_value, uint server_capabilities);
|
||||
void free_rows(MYSQL_DATA *cur);
|
||||
|
|
|
@ -37,6 +37,8 @@ extern "C"
|
|||
int check_user(THD *thd, enum enum_server_command command,
|
||||
const char *passwd, uint passwd_len, const char *db,
|
||||
bool check_count);
|
||||
void thd_init_client_charset(THD *thd, uint cs_number);
|
||||
|
||||
C_MODE_START
|
||||
|
||||
#include <mysql.h>
|
||||
|
@ -600,11 +602,14 @@ err:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
#ifdef NO_EMBEDDED_ACCESS_CHECKS
|
||||
int check_embedded_connection(MYSQL *mysql)
|
||||
{
|
||||
int result;
|
||||
THD *thd= (THD*)mysql->thd;
|
||||
thd_init_client_charset(thd, mysql->charset->number);
|
||||
thd->update_charset();
|
||||
Security_context *sctx= thd->security_ctx;
|
||||
sctx->host_or_ip= sctx->host= (char*) my_localhost;
|
||||
strmake(sctx->priv_host, (char*) my_localhost, MAX_HOSTNAME-1);
|
||||
|
@ -623,6 +628,8 @@ int check_embedded_connection(MYSQL *mysql)
|
|||
char scramble_buff[SCRAMBLE_LENGTH];
|
||||
int passwd_len;
|
||||
|
||||
thd_init_client_charset(thd, mysql->charset->number);
|
||||
thd->update_charset();
|
||||
if (mysql->options.client_ip)
|
||||
{
|
||||
sctx->host= my_strdup(mysql->options.client_ip, MYF(0));
|
||||
|
|
|
@ -90,49 +90,7 @@ static void end_server(MYSQL *mysql)
|
|||
}
|
||||
|
||||
|
||||
static int mysql_init_charset(MYSQL *mysql)
|
||||
{
|
||||
char charset_name_buff[16], *charset_name;
|
||||
|
||||
if ((charset_name=mysql->options.charset_name))
|
||||
{
|
||||
const char *save=charsets_dir;
|
||||
if (mysql->options.charset_dir)
|
||||
charsets_dir=mysql->options.charset_dir;
|
||||
mysql->charset=get_charset_by_name(mysql->options.charset_name,
|
||||
MYF(MY_WME));
|
||||
charsets_dir=save;
|
||||
}
|
||||
else if (mysql->server_language)
|
||||
{
|
||||
charset_name=charset_name_buff;
|
||||
sprintf(charset_name,"%d",mysql->server_language); /* In case of errors */
|
||||
mysql->charset=get_charset((uint8) mysql->server_language, MYF(MY_WME));
|
||||
}
|
||||
else
|
||||
mysql->charset=default_charset_info;
|
||||
|
||||
if (!mysql->charset)
|
||||
{
|
||||
mysql->net.last_errno=CR_CANT_READ_CHARSET;
|
||||
strmov(mysql->net.sqlstate, "HY0000");
|
||||
if (mysql->options.charset_dir)
|
||||
sprintf(mysql->net.last_error,ER(mysql->net.last_errno),
|
||||
charset_name ? charset_name : "unknown",
|
||||
mysql->options.charset_dir);
|
||||
else
|
||||
{
|
||||
char cs_dir_name[FN_REFLEN];
|
||||
get_charsets_dir(cs_dir_name);
|
||||
sprintf(mysql->net.last_error,ER(mysql->net.last_errno),
|
||||
charset_name ? charset_name : "unknown",
|
||||
cs_dir_name);
|
||||
}
|
||||
return mysql->net.last_errno;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mysql_init_character_set(MYSQL *mysql);
|
||||
|
||||
MYSQL * STDCALL
|
||||
mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
|
||||
|
@ -222,10 +180,10 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
|
|||
|
||||
init_embedded_mysql(mysql, client_flag, db_name);
|
||||
|
||||
if (check_embedded_connection(mysql))
|
||||
if (mysql_init_character_set(mysql))
|
||||
goto error;
|
||||
|
||||
if (mysql_init_charset(mysql))
|
||||
if (check_embedded_connection(mysql))
|
||||
goto error;
|
||||
|
||||
mysql->server_status= SERVER_STATUS_AUTOCOMMIT;
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
show variables like 'collation_server';
|
||||
Variable_name Value
|
||||
collation_server ucs2_unicode_ci
|
||||
show variables like "%character_set_ser%";
|
||||
Variable_name Value
|
||||
character_set_server ucs2
|
||||
|
|
|
@ -694,3 +694,13 @@ alter table t1 add primary key pti(pt);
|
|||
ERROR 42000: BLOB/TEXT column 'pt' used in key specification without a key length
|
||||
alter table t1 add primary key pti(pt(20));
|
||||
drop table t1;
|
||||
create table t1 (g GEOMETRY);
|
||||
select * from t1;
|
||||
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
|
||||
def test t1 t1 g g 255 4294967295 0 Y 144 0 63
|
||||
g
|
||||
select asbinary(g) from t1;
|
||||
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
|
||||
def asbinary(g) 252 8192 0 Y 128 0 63
|
||||
asbinary(g)
|
||||
drop table t1;
|
||||
|
|
|
@ -369,11 +369,11 @@ show keys from v4;
|
|||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
|
||||
select * from information_schema.views where TABLE_NAME like "v%";
|
||||
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE
|
||||
NULL test v0 select sql_no_cache `schemata`.`SCHEMA_NAME` AS `c` from `information_schema`.`schemata` NONE NO root@localhost DEFINER
|
||||
NULL test v1 select sql_no_cache `tables`.`TABLE_NAME` AS `c` from `information_schema`.`tables` where (`tables`.`TABLE_NAME` = _utf8'v1') NONE NO root@localhost DEFINER
|
||||
NULL test v2 select sql_no_cache `columns`.`COLUMN_NAME` AS `c` from `information_schema`.`columns` where (`columns`.`TABLE_NAME` = _utf8'v2') NONE NO root@localhost DEFINER
|
||||
NULL test v3 select sql_no_cache `character_sets`.`CHARACTER_SET_NAME` AS `c` from `information_schema`.`character_sets` where (`character_sets`.`CHARACTER_SET_NAME` like _utf8'latin1%') NONE NO root@localhost DEFINER
|
||||
NULL test v4 select sql_no_cache `collations`.`COLLATION_NAME` AS `c` from `information_schema`.`collations` where (`collations`.`COLLATION_NAME` like _utf8'latin1%') NONE NO root@localhost DEFINER
|
||||
NULL test v0 /* ALGORITHM=UNDEFINED */ select sql_no_cache `schemata`.`SCHEMA_NAME` AS `c` from `information_schema`.`schemata` NONE NO root@localhost DEFINER
|
||||
NULL test v1 /* ALGORITHM=UNDEFINED */ select sql_no_cache `tables`.`TABLE_NAME` AS `c` from `information_schema`.`tables` where (`tables`.`TABLE_NAME` = _utf8'v1') NONE NO root@localhost DEFINER
|
||||
NULL test v2 /* ALGORITHM=UNDEFINED */ select sql_no_cache `columns`.`COLUMN_NAME` AS `c` from `information_schema`.`columns` where (`columns`.`TABLE_NAME` = _utf8'v2') NONE NO root@localhost DEFINER
|
||||
NULL test v3 /* ALGORITHM=UNDEFINED */ select sql_no_cache `character_sets`.`CHARACTER_SET_NAME` AS `c` from `information_schema`.`character_sets` where (`character_sets`.`CHARACTER_SET_NAME` like _utf8'latin1%') NONE NO root@localhost DEFINER
|
||||
NULL test v4 /* ALGORITHM=UNDEFINED */ select sql_no_cache `collations`.`COLLATION_NAME` AS `c` from `information_schema`.`collations` where (`collations`.`COLLATION_NAME` like _utf8'latin1%') NONE NO root@localhost DEFINER
|
||||
drop view v0, v1, v2, v3, v4;
|
||||
create table t1 (a int);
|
||||
grant select,update,insert on t1 to mysqltest_1@localhost;
|
||||
|
@ -464,9 +464,9 @@ create view v2 (c) as select a from t1 WITH LOCAL CHECK OPTION;
|
|||
create view v3 (c) as select a from t1 WITH CASCADED CHECK OPTION;
|
||||
select * from information_schema.views;
|
||||
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE
|
||||
NULL test v1 select `test`.`t1`.`a` AS `c` from `test`.`t1` CASCADED YES root@localhost DEFINER
|
||||
NULL test v2 select `test`.`t1`.`a` AS `c` from `test`.`t1` LOCAL YES root@localhost DEFINER
|
||||
NULL test v3 select `test`.`t1`.`a` AS `c` from `test`.`t1` CASCADED YES root@localhost DEFINER
|
||||
NULL test v1 /* ALGORITHM=UNDEFINED */ select `test`.`t1`.`a` AS `c` from `test`.`t1` CASCADED YES root@localhost DEFINER
|
||||
NULL test v2 /* ALGORITHM=UNDEFINED */ select `test`.`t1`.`a` AS `c` from `test`.`t1` LOCAL YES root@localhost DEFINER
|
||||
NULL test v3 /* ALGORITHM=UNDEFINED */ select `test`.`t1`.`a` AS `c` from `test`.`t1` CASCADED YES root@localhost DEFINER
|
||||
grant select (a) on test.t1 to joe@localhost with grant option;
|
||||
select * from INFORMATION_SCHEMA.COLUMN_PRIVILEGES;
|
||||
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
|
||||
|
@ -1121,7 +1121,7 @@ select * from information_schema.views
|
|||
where table_name='v1' or table_name='v2';
|
||||
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE
|
||||
NULL test v1 NONE YES root@localhost DEFINER
|
||||
NULL test v2 select 1 AS `1` NONE NO mysqltest_1@localhost DEFINER
|
||||
NULL test v2 /* ALGORITHM=UNDEFINED */ select 1 AS `1` NONE NO mysqltest_1@localhost DEFINER
|
||||
drop view v1, v2;
|
||||
drop table t1;
|
||||
drop user mysqltest_1@localhost;
|
||||
|
|
|
@ -421,6 +421,28 @@ set tmp_table_size=100;
|
|||
set tx_isolation="READ-COMMITTED";
|
||||
set wait_timeout=100;
|
||||
set log_warnings=1;
|
||||
select @@session.insert_id;
|
||||
@@session.insert_id
|
||||
1
|
||||
set @save_insert_id=@@session.insert_id;
|
||||
set session insert_id=20;
|
||||
select @@session.insert_id;
|
||||
@@session.insert_id
|
||||
20
|
||||
set session last_insert_id=100;
|
||||
select @@session.insert_id;
|
||||
@@session.insert_id
|
||||
20
|
||||
select @@session.last_insert_id;
|
||||
@@session.last_insert_id
|
||||
100
|
||||
select @@session.insert_id;
|
||||
@@session.insert_id
|
||||
20
|
||||
set @@session.insert_id=@save_insert_id;
|
||||
select @@session.insert_id;
|
||||
@@session.insert_id
|
||||
1
|
||||
create table t1 (a int not null auto_increment, primary key(a));
|
||||
create table t2 (a int not null auto_increment, primary key(a));
|
||||
insert into t1 values(null),(null),(null);
|
||||
|
|
|
@ -1 +1 @@
|
|||
--default-character-set=ucs2 --default-collation=ucs2_unicode_ci
|
||||
--default-collation=ucs2_unicode_ci --default-character-set=ucs2
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
#
|
||||
# MySQL Bug#15276: MySQL ignores collation-server
|
||||
#
|
||||
show variables like 'collation_server';
|
||||
|
||||
#
|
||||
# Bug#18004 Connecting crashes server when default charset is UCS2
|
||||
#
|
||||
|
|
|
@ -409,3 +409,10 @@ create table t1(pt GEOMETRY);
|
|||
alter table t1 add primary key pti(pt);
|
||||
alter table t1 add primary key pti(pt(20));
|
||||
drop table t1;
|
||||
|
||||
--enable_metadata
|
||||
create table t1 (g GEOMETRY);
|
||||
select * from t1;
|
||||
select asbinary(g) from t1;
|
||||
--disable_metadata
|
||||
drop table t1;
|
||||
|
|
|
@ -301,6 +301,22 @@ set tx_isolation="READ-COMMITTED";
|
|||
set wait_timeout=100;
|
||||
set log_warnings=1;
|
||||
|
||||
#
|
||||
# Bugs: #20392: INSERT_ID session variable has weird value
|
||||
#
|
||||
select @@session.insert_id;
|
||||
set @save_insert_id=@@session.insert_id;
|
||||
set session insert_id=20;
|
||||
select @@session.insert_id;
|
||||
|
||||
set session last_insert_id=100;
|
||||
select @@session.insert_id;
|
||||
select @@session.last_insert_id;
|
||||
select @@session.insert_id;
|
||||
|
||||
set @@session.insert_id=@save_insert_id;
|
||||
select @@session.insert_id;
|
||||
|
||||
#
|
||||
# key buffer
|
||||
#
|
||||
|
|
|
@ -245,6 +245,22 @@ void setEnvString(char *ret, const char *name, const char *value)
|
|||
DBUG_VOID_RETURN ;
|
||||
}
|
||||
|
||||
/*
|
||||
my_paramter_handler
|
||||
Invalid paramter handler we will use instead of the one "baked" into the CRT
|
||||
for MSC v8. This one just prints out what invalid parameter was encountered.
|
||||
By providing this routine, routines like lseek will return -1 when we expect them
|
||||
to instead of crash.
|
||||
*/
|
||||
void my_parameter_handler(const wchar_t * expression, const wchar_t * function,
|
||||
const wchar_t * file, unsigned int line,
|
||||
uintptr_t pReserved)
|
||||
{
|
||||
DBUG_PRINT("my",("Expression: %s function: %s file: %s, line: %d",
|
||||
expression, function, file, line));
|
||||
}
|
||||
|
||||
|
||||
static void my_win_init(void)
|
||||
{
|
||||
HKEY hSoftMysql ;
|
||||
|
@ -262,12 +278,18 @@ static void my_win_init(void)
|
|||
|
||||
setlocale(LC_CTYPE, ""); /* To get right sortorder */
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1300)
|
||||
#if defined(_MSC_VER)
|
||||
#if _MSC_VER < 1300
|
||||
/*
|
||||
Clear the OS system variable TZ and avoid the 100% CPU usage
|
||||
Only for old versions of Visual C++
|
||||
*/
|
||||
_putenv( "TZ=" );
|
||||
#endif
|
||||
#if _MSC_VER >= 1400
|
||||
/* this is required to make crt functions return -1 appropriately */
|
||||
_set_invalid_parameter_handler(my_parameter_handler);
|
||||
#endif
|
||||
#endif
|
||||
_tzset();
|
||||
|
||||
|
|
|
@ -130,6 +130,8 @@ static void mysql_close_free(MYSQL *mysql);
|
|||
static int wait_for_data(my_socket fd, uint timeout);
|
||||
#endif
|
||||
|
||||
CHARSET_INFO *default_client_charset_info = &my_charset_latin1;
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
A modified version of connect(). my_connect() allows you to specify
|
||||
|
@ -1431,7 +1433,7 @@ mysql_init(MYSQL *mysql)
|
|||
bzero((char*) (mysql), sizeof(*(mysql)));
|
||||
mysql->options.connect_timeout= CONNECT_TIMEOUT;
|
||||
mysql->last_used_con= mysql->next_slave= mysql->master = mysql;
|
||||
mysql->charset=default_charset_info;
|
||||
mysql->charset=default_client_charset_info;
|
||||
strmov(mysql->net.sqlstate, not_error_sqlstate);
|
||||
/*
|
||||
By default, we are a replication pivot. The caller must reset it
|
||||
|
@ -1660,7 +1662,51 @@ static MYSQL_METHODS client_methods=
|
|||
#endif
|
||||
};
|
||||
|
||||
MYSQL *
|
||||
C_MODE_START
|
||||
int mysql_init_character_set(MYSQL *mysql)
|
||||
{
|
||||
NET *net= &mysql->net;
|
||||
/* Set character set */
|
||||
if (!mysql->options.charset_name &&
|
||||
!(mysql->options.charset_name=
|
||||
my_strdup(MYSQL_DEFAULT_CHARSET_NAME,MYF(MY_WME))))
|
||||
return 1;
|
||||
|
||||
{
|
||||
const char *save= charsets_dir;
|
||||
if (mysql->options.charset_dir)
|
||||
charsets_dir=mysql->options.charset_dir;
|
||||
mysql->charset=get_charset_by_csname(mysql->options.charset_name,
|
||||
MY_CS_PRIMARY, MYF(MY_WME));
|
||||
charsets_dir= save;
|
||||
}
|
||||
|
||||
if (!mysql->charset)
|
||||
{
|
||||
net->last_errno=CR_CANT_READ_CHARSET;
|
||||
strmov(net->sqlstate, unknown_sqlstate);
|
||||
if (mysql->options.charset_dir)
|
||||
my_snprintf(net->last_error, sizeof(net->last_error)-1,
|
||||
ER(net->last_errno),
|
||||
mysql->options.charset_name,
|
||||
mysql->options.charset_dir);
|
||||
else
|
||||
{
|
||||
char cs_dir_name[FN_REFLEN];
|
||||
get_charsets_dir(cs_dir_name);
|
||||
my_snprintf(net->last_error, sizeof(net->last_error)-1,
|
||||
ER(net->last_errno),
|
||||
mysql->options.charset_name,
|
||||
cs_dir_name);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
C_MODE_END
|
||||
|
||||
|
||||
MYSQL * STDCALL
|
||||
CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
|
||||
const char *passwd, const char *db,
|
||||
uint port, const char *unix_socket,ulong client_flag)
|
||||
|
@ -1997,42 +2043,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
|
|||
goto error;
|
||||
}
|
||||
|
||||
/* Set character set */
|
||||
if (!mysql->options.charset_name &&
|
||||
!(mysql->options.charset_name=
|
||||
my_strdup(MYSQL_DEFAULT_CHARSET_NAME,MYF(MY_WME))))
|
||||
if (mysql_init_character_set(mysql))
|
||||
goto error;
|
||||
|
||||
{
|
||||
const char *save= charsets_dir;
|
||||
if (mysql->options.charset_dir)
|
||||
charsets_dir=mysql->options.charset_dir;
|
||||
mysql->charset=get_charset_by_csname(mysql->options.charset_name,
|
||||
MY_CS_PRIMARY, MYF(MY_WME));
|
||||
charsets_dir= save;
|
||||
}
|
||||
|
||||
if (!mysql->charset)
|
||||
{
|
||||
net->last_errno=CR_CANT_READ_CHARSET;
|
||||
strmov(net->sqlstate, unknown_sqlstate);
|
||||
if (mysql->options.charset_dir)
|
||||
my_snprintf(net->last_error, sizeof(net->last_error)-1,
|
||||
ER(net->last_errno),
|
||||
mysql->options.charset_name,
|
||||
mysql->options.charset_dir);
|
||||
else
|
||||
{
|
||||
char cs_dir_name[FN_REFLEN];
|
||||
get_charsets_dir(cs_dir_name);
|
||||
my_snprintf(net->last_error, sizeof(net->last_error)-1,
|
||||
ER(net->last_errno),
|
||||
mysql->options.charset_name,
|
||||
cs_dir_name);
|
||||
}
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
/* Save connection information */
|
||||
if (!my_multi_malloc(MYF(0),
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
Item_geometry_func(Item *a,Item *b,Item *c) :Item_str_func(a,b,c) {}
|
||||
Item_geometry_func(List<Item> &list) :Item_str_func(list) {}
|
||||
void fix_length_and_dec();
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_GEOMETRY; }
|
||||
};
|
||||
|
||||
class Item_func_geometry_from_text: public Item_geometry_func
|
||||
|
@ -67,6 +68,7 @@ public:
|
|||
Item_func_as_wkb(Item *a): Item_geometry_func(a) {}
|
||||
const char *func_name() const { return "aswkb"; }
|
||||
String *val_str(String *);
|
||||
enum_field_types field_type() const { return MYSQL_TYPE_BLOB; }
|
||||
};
|
||||
|
||||
class Item_func_geometry_type: public Item_str_func
|
||||
|
|
|
@ -314,6 +314,7 @@ static char *default_character_set_name;
|
|||
static char *character_set_filesystem_name;
|
||||
static char *my_bind_addr_str;
|
||||
static char *default_collation_name;
|
||||
static char compiled_default_collation_name[]= MYSQL_DEFAULT_COLLATION_NAME;
|
||||
static char mysql_data_home_buff[2];
|
||||
static struct passwd *user_info;
|
||||
static I_List<THD> thread_cache;
|
||||
|
@ -6382,7 +6383,7 @@ static void mysql_init_variables(void)
|
|||
/* Variables in libraries */
|
||||
charsets_dir= 0;
|
||||
default_character_set_name= (char*) MYSQL_DEFAULT_CHARSET_NAME;
|
||||
default_collation_name= (char*) MYSQL_DEFAULT_COLLATION_NAME;
|
||||
default_collation_name= compiled_default_collation_name;
|
||||
sys_charset_system.value= (char*) system_charset_info->csname;
|
||||
character_set_filesystem_name= (char*) "binary";
|
||||
|
||||
|
@ -6544,7 +6545,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
|
|||
strmake(mysql_home,argument,sizeof(mysql_home)-1);
|
||||
break;
|
||||
case 'C':
|
||||
default_collation_name= 0;
|
||||
if (default_collation_name == compiled_default_collation_name)
|
||||
default_collation_name= 0;
|
||||
break;
|
||||
case 'l':
|
||||
opt_log=1;
|
||||
|
|
|
@ -2578,7 +2578,7 @@ bool sys_var_insert_id::update(THD *thd, set_var *var)
|
|||
byte *sys_var_insert_id::value_ptr(THD *thd, enum_var_type type,
|
||||
LEX_STRING *base)
|
||||
{
|
||||
return (byte*) &thd->current_insert_id;
|
||||
return (byte*) &thd->next_insert_id;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -771,6 +771,37 @@ static void reset_mqh(LEX_USER *lu, bool get_them= 0)
|
|||
#endif /* NO_EMBEDDED_ACCESS_CHECKS */
|
||||
}
|
||||
|
||||
void thd_init_client_charset(THD *thd, uint cs_number)
|
||||
{
|
||||
/*
|
||||
Use server character set and collation if
|
||||
- opt_character_set_client_handshake is not set
|
||||
- client has not specified a character set
|
||||
- client character set is the same as the servers
|
||||
- client character set doesn't exists in server
|
||||
*/
|
||||
if (!opt_character_set_client_handshake ||
|
||||
!(thd->variables.character_set_client= get_charset(cs_number, MYF(0))) ||
|
||||
!my_strcasecmp(&my_charset_latin1,
|
||||
global_system_variables.character_set_client->name,
|
||||
thd->variables.character_set_client->name))
|
||||
{
|
||||
thd->variables.character_set_client=
|
||||
global_system_variables.character_set_client;
|
||||
thd->variables.collation_connection=
|
||||
global_system_variables.collation_connection;
|
||||
thd->variables.character_set_results=
|
||||
global_system_variables.character_set_results;
|
||||
}
|
||||
else
|
||||
{
|
||||
thd->variables.character_set_results=
|
||||
thd->variables.collation_connection=
|
||||
thd->variables.character_set_client;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Perform handshake, authorize client and update thd ACL variables.
|
||||
SYNOPSIS
|
||||
|
@ -906,33 +937,7 @@ static int check_connection(THD *thd)
|
|||
thd->client_capabilities|= ((ulong) uint2korr(net->read_pos+2)) << 16;
|
||||
thd->max_client_packet_length= uint4korr(net->read_pos+4);
|
||||
DBUG_PRINT("info", ("client_character_set: %d", (uint) net->read_pos[8]));
|
||||
/*
|
||||
Use server character set and collation if
|
||||
- opt_character_set_client_handshake is not set
|
||||
- client has not specified a character set
|
||||
- client character set is the same as the servers
|
||||
- client character set doesn't exists in server
|
||||
*/
|
||||
if (!opt_character_set_client_handshake ||
|
||||
!(thd->variables.character_set_client=
|
||||
get_charset((uint) net->read_pos[8], MYF(0))) ||
|
||||
!my_strcasecmp(&my_charset_latin1,
|
||||
global_system_variables.character_set_client->name,
|
||||
thd->variables.character_set_client->name))
|
||||
{
|
||||
thd->variables.character_set_client=
|
||||
global_system_variables.character_set_client;
|
||||
thd->variables.collation_connection=
|
||||
global_system_variables.collation_connection;
|
||||
thd->variables.character_set_results=
|
||||
global_system_variables.character_set_results;
|
||||
}
|
||||
else
|
||||
{
|
||||
thd->variables.character_set_results=
|
||||
thd->variables.collation_connection=
|
||||
thd->variables.character_set_client;
|
||||
}
|
||||
thd_init_client_charset(thd, (uint) net->read_pos[8]);
|
||||
thd->update_charset();
|
||||
end= (char*) net->read_pos+32;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,8 @@ static TYPELIB grant_types = { sizeof(grant_names)/sizeof(char **),
|
|||
|
||||
static int
|
||||
store_create_info(THD *thd, TABLE_LIST *table_list, String *packet);
|
||||
static void
|
||||
append_algorithm(TABLE_LIST *table, String *buff);
|
||||
static int
|
||||
view_store_create_info(THD *thd, TABLE_LIST *table, String *buff);
|
||||
static bool schema_table_store_record(THD *thd, TABLE *table);
|
||||
|
@ -1098,6 +1100,28 @@ store_create_info(THD *thd, TABLE_LIST *table_list, String *packet)
|
|||
|
||||
void
|
||||
view_store_options(THD *thd, TABLE_LIST *table, String *buff)
|
||||
{
|
||||
append_algorithm(table, buff);
|
||||
append_definer(thd, buff, &table->definer.user, &table->definer.host);
|
||||
if (table->view_suid)
|
||||
buff->append(STRING_WITH_LEN("SQL SECURITY DEFINER "));
|
||||
else
|
||||
buff->append(STRING_WITH_LEN("SQL SECURITY INVOKER "));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Append DEFINER clause to the given buffer.
|
||||
|
||||
SYNOPSIS
|
||||
append_definer()
|
||||
thd [in] thread handle
|
||||
buffer [inout] buffer to hold DEFINER clause
|
||||
definer_user [in] user name part of definer
|
||||
definer_host [in] host name part of definer
|
||||
*/
|
||||
|
||||
static void append_algorithm(TABLE_LIST *table, String *buff)
|
||||
{
|
||||
buff->append(STRING_WITH_LEN("ALGORITHM="));
|
||||
switch ((int8)table->algorithm) {
|
||||
|
@ -1113,11 +1137,6 @@ view_store_options(THD *thd, TABLE_LIST *table, String *buff)
|
|||
default:
|
||||
DBUG_ASSERT(0); // never should happen
|
||||
}
|
||||
append_definer(thd, buff, &table->definer.user, &table->definer.host);
|
||||
if (table->view_suid)
|
||||
buff->append(STRING_WITH_LEN("SQL SECURITY DEFINER "));
|
||||
else
|
||||
buff->append(STRING_WITH_LEN("SQL SECURITY INVOKER "));
|
||||
}
|
||||
|
||||
|
||||
|
@ -3105,7 +3124,16 @@ static int get_schema_views_record(THD *thd, struct st_table_list *tables,
|
|||
table->field[1]->store(tables->view_db.str, tables->view_db.length, cs);
|
||||
table->field[2]->store(tables->view_name.str, tables->view_name.length, cs);
|
||||
if (grant & SHOW_VIEW_ACL)
|
||||
table->field[3]->store(tables->query.str, tables->query.length, cs);
|
||||
{
|
||||
char buff[2048];
|
||||
String qwe_str(buff, sizeof(buff), cs);
|
||||
qwe_str.length(0);
|
||||
qwe_str.append(STRING_WITH_LEN("/* "));
|
||||
append_algorithm(tables, &qwe_str);
|
||||
qwe_str.append(STRING_WITH_LEN("*/ "));
|
||||
qwe_str.append(tables->query.str, tables->query.length);
|
||||
table->field[3]->store(qwe_str.ptr(), qwe_str.length(), cs);
|
||||
}
|
||||
|
||||
if (tables->with_check != VIEW_CHECK_NONE)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue