Changing field::field_name and Item::name to LEX_CSTRING

Benefits of this patch:
- Removed a lot of calls to strlen(), especially for field_string
- Strings generated by parser are now const strings, less chance of
  accidently changing a string
- Removed a lot of calls with LEX_STRING as parameter (changed to pointer)
- More uniform code
- Item::name_length was not kept up to date. Now fixed
- Several bugs found and fixed (Access to null pointers,
  access of freed memory, wrong arguments to printf like functions)
- Removed a lot of casts from (const char*) to (char*)

Changes:
- This caused some ABI changes
  - lex_string_set now uses LEX_CSTRING
  - Some fucntions are now taking const char* instead of char*
- Create_field::change and after changed to LEX_CSTRING
- handler::connect_string, comment and engine_name() changed to LEX_CSTRING
- Checked printf() related calls to find bugs. Found and fixed several
  errors in old code.
- A lot of changes from LEX_STRING to LEX_CSTRING, especially related to
  parsing and events.
- Some changes from LEX_STRING and LEX_STRING & to LEX_CSTRING*
- Some changes for char* to const char*
- Added printf argument checking for my_snprintf()
- Introduced null_clex_str, star_clex_string, temp_lex_str to simplify
  code
- Added item_empty_name and item_used_name to be able to distingush between
  items that was given an empty name and items that was not given a name
  This is used in sql_yacc.yy to know when to give an item a name.
- select table_name."*' is not anymore same as table_name.*
- removed not used function Item::rename()
- Added comparision of item->name_length before some calls to
  my_strcasecmp() to speed up comparison
- Moved Item_sp_variable::make_field() from item.h to item.cc
- Some minimal code changes to avoid copying to const char *
- Fixed wrong error message in wsrep_mysql_parse()
- Fixed wrong code in find_field_in_natural_join() where real_item() was
  set when it shouldn't
- ER_ERROR_ON_RENAME was used with extra arguments.
- Removed some (wrong) ER_OUTOFMEMORY, as alloc_root will already
  give the error.

TODO:
- Check possible unsafe casts in plugin/auth_examples/qa_auth_interface.c
- Change code to not modify LEX_CSTRING for database name
  (as part of lower_case_table_names)
This commit is contained in:
Monty 2017-04-23 19:39:57 +03:00
parent cba84469eb
commit 5a759d31f7
233 changed files with 4155 additions and 3794 deletions

View File

@ -212,11 +212,6 @@ extern ulonglong strtoull(const char *str, char **ptr, int base);
#define USTRING_WITH_LEN(X) ((uchar*) X), ((size_t) (sizeof(X) - 1)) #define USTRING_WITH_LEN(X) ((uchar*) X), ((size_t) (sizeof(X) - 1))
#define C_STRING_WITH_LEN(X) ((char *) (X)), ((size_t) (sizeof(X) - 1)) #define C_STRING_WITH_LEN(X) ((char *) (X)), ((size_t) (sizeof(X) - 1))
struct st_mysql_const_lex_string
{
const char *str;
size_t length;
};
typedef struct st_mysql_const_lex_string LEX_CSTRING; typedef struct st_mysql_const_lex_string LEX_CSTRING;
/* A variant with const and unsigned */ /* A variant with const and unsigned */
@ -227,15 +222,15 @@ struct st_mysql_const_unsigned_lex_string
}; };
typedef struct st_mysql_const_unsigned_lex_string LEX_CUSTRING; typedef struct st_mysql_const_unsigned_lex_string LEX_CUSTRING;
static inline void lex_string_set(LEX_STRING *lex_str, const char *c_str) static inline void lex_string_set(LEX_CSTRING *lex_str, const char *c_str)
{ {
lex_str->str= (char *) c_str; lex_str->str= c_str;
lex_str->length= strlen(c_str); lex_str->length= strlen(c_str);
} }
static inline void lex_string_set3(LEX_STRING *lex_str, const char *c_str, static inline void lex_string_set3(LEX_CSTRING *lex_str, const char *c_str,
size_t len) size_t len)
{ {
lex_str->str= (char *) c_str; lex_str->str= c_str;
lex_str->length= len; lex_str->length= len;
} }

View File

@ -173,8 +173,10 @@ static inline my_bool validate_timestamp_range(const MYSQL_TIME *t)
} }
/* Can't include mysqld_error.h, it needs mysys to build, thus hardcode 2 error values here. */ /* Can't include mysqld_error.h, it needs mysys to build, thus hardcode 2 error values here. */
#ifndef ER_WARN_DATA_OUT_OF_RANGE
#define ER_WARN_DATA_OUT_OF_RANGE 1264 #define ER_WARN_DATA_OUT_OF_RANGE 1264
#define ER_WARN_INVALID_TIMESTAMP 1299 #define ER_WARN_INVALID_TIMESTAMP 1299
#endif
my_time_t my_time_t
my_system_gmt_sec(const MYSQL_TIME *t, long *my_timezone, uint *error_code); my_system_gmt_sec(const MYSQL_TIME *t, long *my_timezone, uint *error_code);

View File

@ -136,7 +136,7 @@ typedef struct st_udf_args
char **args; char **args;
unsigned long *lengths; unsigned long *lengths;
char *maybe_null; char *maybe_null;
char **attributes; const char **attributes;
unsigned long *attribute_lengths; unsigned long *attribute_lengths;
void *extension; void *extension;
} UDF_ARGS; } UDF_ARGS;

View File

@ -141,7 +141,8 @@ extern struct my_snprintf_service_st {
size_t (*my_snprintf_type)(char*, size_t, const char*, ...); size_t (*my_snprintf_type)(char*, size_t, const char*, ...);
size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list); size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list);
} *my_snprintf_service; } *my_snprintf_service;
size_t my_snprintf(char* to, size_t n, const char* fmt, ...); size_t my_snprintf(char* to, size_t n, const char* fmt, ...)
;
size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap); size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap);
extern struct progress_report_service_st { extern struct progress_report_service_st {
void (*thd_progress_init_func)(void* thd, unsigned int max_stage); void (*thd_progress_init_func)(void* thd, unsigned int max_stage);
@ -233,13 +234,20 @@ struct st_mysql_lex_string
size_t length; size_t length;
}; };
typedef struct st_mysql_lex_string MYSQL_LEX_STRING; typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
struct st_mysql_const_lex_string
{
const char *str;
size_t length;
};
typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING;
extern struct thd_alloc_service_st { extern struct thd_alloc_service_st {
void *(*thd_alloc_func)(void*, unsigned int); void *(*thd_alloc_func)(void*, unsigned int);
void *(*thd_calloc_func)(void*, unsigned int); void *(*thd_calloc_func)(void*, unsigned int);
char *(*thd_strdup_func)(void*, const char *); char *(*thd_strdup_func)(void*, const char *);
char *(*thd_strmake_func)(void*, const char *, unsigned int); char *(*thd_strmake_func)(void*, const char *, unsigned int);
void *(*thd_memdup_func)(void*, const void*, unsigned int); void *(*thd_memdup_func)(void*, const void*, unsigned int);
MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *, MYSQL_CONST_LEX_STRING *(*thd_make_lex_string_func)(void*,
MYSQL_CONST_LEX_STRING *,
const char *, unsigned int, int); const char *, unsigned int, int);
} *thd_alloc_service; } *thd_alloc_service;
void *thd_alloc(void* thd, unsigned int size); void *thd_alloc(void* thd, unsigned int size);
@ -247,9 +255,10 @@ void *thd_calloc(void* thd, unsigned int size);
char *thd_strdup(void* thd, const char *str); char *thd_strdup(void* thd, const char *str);
char *thd_strmake(void* thd, const char *str, unsigned int size); char *thd_strmake(void* thd, const char *str, unsigned int size);
void *thd_memdup(void* thd, const void* str, unsigned int size); void *thd_memdup(void* thd, const void* str, unsigned int size);
MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str, MYSQL_CONST_LEX_STRING
const char *str, unsigned int size, *thd_make_lex_string(void* thd, MYSQL_CONST_LEX_STRING *lex_str,
int allocate_lex_string); const char *str, unsigned int size,
int allocate_lex_string);
extern struct thd_autoinc_service_st { extern struct thd_autoinc_service_st {
void (*thd_get_autoinc_func)(const void* thd, void (*thd_get_autoinc_func)(const void* thd,
unsigned long* off, unsigned long* inc); unsigned long* off, unsigned long* inc);

View File

@ -51,7 +51,7 @@ typedef struct st_mysql_server_auth_info
User name as sent by the client and shown in USER(). User name as sent by the client and shown in USER().
NULL if the client packet with the user name was not received yet. NULL if the client packet with the user name was not received yet.
*/ */
char *user_name; const char *user_name;
/** /**
Length of user_name Length of user_name

View File

@ -141,7 +141,8 @@ extern struct my_snprintf_service_st {
size_t (*my_snprintf_type)(char*, size_t, const char*, ...); size_t (*my_snprintf_type)(char*, size_t, const char*, ...);
size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list); size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list);
} *my_snprintf_service; } *my_snprintf_service;
size_t my_snprintf(char* to, size_t n, const char* fmt, ...); size_t my_snprintf(char* to, size_t n, const char* fmt, ...)
;
size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap); size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap);
extern struct progress_report_service_st { extern struct progress_report_service_st {
void (*thd_progress_init_func)(void* thd, unsigned int max_stage); void (*thd_progress_init_func)(void* thd, unsigned int max_stage);
@ -233,13 +234,20 @@ struct st_mysql_lex_string
size_t length; size_t length;
}; };
typedef struct st_mysql_lex_string MYSQL_LEX_STRING; typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
struct st_mysql_const_lex_string
{
const char *str;
size_t length;
};
typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING;
extern struct thd_alloc_service_st { extern struct thd_alloc_service_st {
void *(*thd_alloc_func)(void*, unsigned int); void *(*thd_alloc_func)(void*, unsigned int);
void *(*thd_calloc_func)(void*, unsigned int); void *(*thd_calloc_func)(void*, unsigned int);
char *(*thd_strdup_func)(void*, const char *); char *(*thd_strdup_func)(void*, const char *);
char *(*thd_strmake_func)(void*, const char *, unsigned int); char *(*thd_strmake_func)(void*, const char *, unsigned int);
void *(*thd_memdup_func)(void*, const void*, unsigned int); void *(*thd_memdup_func)(void*, const void*, unsigned int);
MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *, MYSQL_CONST_LEX_STRING *(*thd_make_lex_string_func)(void*,
MYSQL_CONST_LEX_STRING *,
const char *, unsigned int, int); const char *, unsigned int, int);
} *thd_alloc_service; } *thd_alloc_service;
void *thd_alloc(void* thd, unsigned int size); void *thd_alloc(void* thd, unsigned int size);
@ -247,9 +255,10 @@ void *thd_calloc(void* thd, unsigned int size);
char *thd_strdup(void* thd, const char *str); char *thd_strdup(void* thd, const char *str);
char *thd_strmake(void* thd, const char *str, unsigned int size); char *thd_strmake(void* thd, const char *str, unsigned int size);
void *thd_memdup(void* thd, const void* str, unsigned int size); void *thd_memdup(void* thd, const void* str, unsigned int size);
MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str, MYSQL_CONST_LEX_STRING
const char *str, unsigned int size, *thd_make_lex_string(void* thd, MYSQL_CONST_LEX_STRING *lex_str,
int allocate_lex_string); const char *str, unsigned int size,
int allocate_lex_string);
extern struct thd_autoinc_service_st { extern struct thd_autoinc_service_st {
void (*thd_get_autoinc_func)(const void* thd, void (*thd_get_autoinc_func)(const void* thd,
unsigned long* off, unsigned long* inc); unsigned long* off, unsigned long* inc);
@ -501,7 +510,7 @@ typedef struct st_plugin_vio
} MYSQL_PLUGIN_VIO; } MYSQL_PLUGIN_VIO;
typedef struct st_mysql_server_auth_info typedef struct st_mysql_server_auth_info
{ {
char *user_name; const char *user_name;
unsigned int user_name_length; unsigned int user_name_length;
const char *auth_string; const char *auth_string;
unsigned long auth_string_length; unsigned long auth_string_length;

View File

@ -141,7 +141,8 @@ extern struct my_snprintf_service_st {
size_t (*my_snprintf_type)(char*, size_t, const char*, ...); size_t (*my_snprintf_type)(char*, size_t, const char*, ...);
size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list); size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list);
} *my_snprintf_service; } *my_snprintf_service;
size_t my_snprintf(char* to, size_t n, const char* fmt, ...); size_t my_snprintf(char* to, size_t n, const char* fmt, ...)
;
size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap); size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap);
extern struct progress_report_service_st { extern struct progress_report_service_st {
void (*thd_progress_init_func)(void* thd, unsigned int max_stage); void (*thd_progress_init_func)(void* thd, unsigned int max_stage);
@ -233,13 +234,20 @@ struct st_mysql_lex_string
size_t length; size_t length;
}; };
typedef struct st_mysql_lex_string MYSQL_LEX_STRING; typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
struct st_mysql_const_lex_string
{
const char *str;
size_t length;
};
typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING;
extern struct thd_alloc_service_st { extern struct thd_alloc_service_st {
void *(*thd_alloc_func)(void*, unsigned int); void *(*thd_alloc_func)(void*, unsigned int);
void *(*thd_calloc_func)(void*, unsigned int); void *(*thd_calloc_func)(void*, unsigned int);
char *(*thd_strdup_func)(void*, const char *); char *(*thd_strdup_func)(void*, const char *);
char *(*thd_strmake_func)(void*, const char *, unsigned int); char *(*thd_strmake_func)(void*, const char *, unsigned int);
void *(*thd_memdup_func)(void*, const void*, unsigned int); void *(*thd_memdup_func)(void*, const void*, unsigned int);
MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *, MYSQL_CONST_LEX_STRING *(*thd_make_lex_string_func)(void*,
MYSQL_CONST_LEX_STRING *,
const char *, unsigned int, int); const char *, unsigned int, int);
} *thd_alloc_service; } *thd_alloc_service;
void *thd_alloc(void* thd, unsigned int size); void *thd_alloc(void* thd, unsigned int size);
@ -247,9 +255,10 @@ void *thd_calloc(void* thd, unsigned int size);
char *thd_strdup(void* thd, const char *str); char *thd_strdup(void* thd, const char *str);
char *thd_strmake(void* thd, const char *str, unsigned int size); char *thd_strmake(void* thd, const char *str, unsigned int size);
void *thd_memdup(void* thd, const void* str, unsigned int size); void *thd_memdup(void* thd, const void* str, unsigned int size);
MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str, MYSQL_CONST_LEX_STRING
const char *str, unsigned int size, *thd_make_lex_string(void* thd, MYSQL_CONST_LEX_STRING *lex_str,
int allocate_lex_string); const char *str, unsigned int size,
int allocate_lex_string);
extern struct thd_autoinc_service_st { extern struct thd_autoinc_service_st {
void (*thd_get_autoinc_func)(const void* thd, void (*thd_get_autoinc_func)(const void* thd,
unsigned long* off, unsigned long* inc); unsigned long* off, unsigned long* inc);

View File

@ -141,7 +141,8 @@ extern struct my_snprintf_service_st {
size_t (*my_snprintf_type)(char*, size_t, const char*, ...); size_t (*my_snprintf_type)(char*, size_t, const char*, ...);
size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list); size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list);
} *my_snprintf_service; } *my_snprintf_service;
size_t my_snprintf(char* to, size_t n, const char* fmt, ...); size_t my_snprintf(char* to, size_t n, const char* fmt, ...)
;
size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap); size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap);
extern struct progress_report_service_st { extern struct progress_report_service_st {
void (*thd_progress_init_func)(void* thd, unsigned int max_stage); void (*thd_progress_init_func)(void* thd, unsigned int max_stage);
@ -233,13 +234,20 @@ struct st_mysql_lex_string
size_t length; size_t length;
}; };
typedef struct st_mysql_lex_string MYSQL_LEX_STRING; typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
struct st_mysql_const_lex_string
{
const char *str;
size_t length;
};
typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING;
extern struct thd_alloc_service_st { extern struct thd_alloc_service_st {
void *(*thd_alloc_func)(void*, unsigned int); void *(*thd_alloc_func)(void*, unsigned int);
void *(*thd_calloc_func)(void*, unsigned int); void *(*thd_calloc_func)(void*, unsigned int);
char *(*thd_strdup_func)(void*, const char *); char *(*thd_strdup_func)(void*, const char *);
char *(*thd_strmake_func)(void*, const char *, unsigned int); char *(*thd_strmake_func)(void*, const char *, unsigned int);
void *(*thd_memdup_func)(void*, const void*, unsigned int); void *(*thd_memdup_func)(void*, const void*, unsigned int);
MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *, MYSQL_CONST_LEX_STRING *(*thd_make_lex_string_func)(void*,
MYSQL_CONST_LEX_STRING *,
const char *, unsigned int, int); const char *, unsigned int, int);
} *thd_alloc_service; } *thd_alloc_service;
void *thd_alloc(void* thd, unsigned int size); void *thd_alloc(void* thd, unsigned int size);
@ -247,9 +255,10 @@ void *thd_calloc(void* thd, unsigned int size);
char *thd_strdup(void* thd, const char *str); char *thd_strdup(void* thd, const char *str);
char *thd_strmake(void* thd, const char *str, unsigned int size); char *thd_strmake(void* thd, const char *str, unsigned int size);
void *thd_memdup(void* thd, const void* str, unsigned int size); void *thd_memdup(void* thd, const void* str, unsigned int size);
MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str, MYSQL_CONST_LEX_STRING
const char *str, unsigned int size, *thd_make_lex_string(void* thd, MYSQL_CONST_LEX_STRING *lex_str,
int allocate_lex_string); const char *str, unsigned int size,
int allocate_lex_string);
extern struct thd_autoinc_service_st { extern struct thd_autoinc_service_st {
void (*thd_get_autoinc_func)(const void* thd, void (*thd_get_autoinc_func)(const void* thd,
unsigned long* off, unsigned long* inc); unsigned long* off, unsigned long* inc);

View File

@ -42,8 +42,8 @@ struct st_mariadb_password_validation
Function provided by the plugin which should perform password validation Function provided by the plugin which should perform password validation
and return 0 if the password has passed the validation. and return 0 if the password has passed the validation.
*/ */
int (*validate_password)(MYSQL_LEX_STRING *username, int (*validate_password)(MYSQL_CONST_LEX_STRING *username,
MYSQL_LEX_STRING *password); MYSQL_CONST_LEX_STRING *password);
}; };
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -141,7 +141,8 @@ extern struct my_snprintf_service_st {
size_t (*my_snprintf_type)(char*, size_t, const char*, ...); size_t (*my_snprintf_type)(char*, size_t, const char*, ...);
size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list); size_t (*my_vsnprintf_type)(char *, size_t, const char*, va_list);
} *my_snprintf_service; } *my_snprintf_service;
size_t my_snprintf(char* to, size_t n, const char* fmt, ...); size_t my_snprintf(char* to, size_t n, const char* fmt, ...)
;
size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap); size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap);
extern struct progress_report_service_st { extern struct progress_report_service_st {
void (*thd_progress_init_func)(void* thd, unsigned int max_stage); void (*thd_progress_init_func)(void* thd, unsigned int max_stage);
@ -233,13 +234,20 @@ struct st_mysql_lex_string
size_t length; size_t length;
}; };
typedef struct st_mysql_lex_string MYSQL_LEX_STRING; typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
struct st_mysql_const_lex_string
{
const char *str;
size_t length;
};
typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING;
extern struct thd_alloc_service_st { extern struct thd_alloc_service_st {
void *(*thd_alloc_func)(void*, unsigned int); void *(*thd_alloc_func)(void*, unsigned int);
void *(*thd_calloc_func)(void*, unsigned int); void *(*thd_calloc_func)(void*, unsigned int);
char *(*thd_strdup_func)(void*, const char *); char *(*thd_strdup_func)(void*, const char *);
char *(*thd_strmake_func)(void*, const char *, unsigned int); char *(*thd_strmake_func)(void*, const char *, unsigned int);
void *(*thd_memdup_func)(void*, const void*, unsigned int); void *(*thd_memdup_func)(void*, const void*, unsigned int);
MYSQL_LEX_STRING *(*thd_make_lex_string_func)(void*, MYSQL_LEX_STRING *, MYSQL_CONST_LEX_STRING *(*thd_make_lex_string_func)(void*,
MYSQL_CONST_LEX_STRING *,
const char *, unsigned int, int); const char *, unsigned int, int);
} *thd_alloc_service; } *thd_alloc_service;
void *thd_alloc(void* thd, unsigned int size); void *thd_alloc(void* thd, unsigned int size);
@ -247,9 +255,10 @@ void *thd_calloc(void* thd, unsigned int size);
char *thd_strdup(void* thd, const char *str); char *thd_strdup(void* thd, const char *str);
char *thd_strmake(void* thd, const char *str, unsigned int size); char *thd_strmake(void* thd, const char *str, unsigned int size);
void *thd_memdup(void* thd, const void* str, unsigned int size); void *thd_memdup(void* thd, const void* str, unsigned int size);
MYSQL_LEX_STRING *thd_make_lex_string(void* thd, MYSQL_LEX_STRING *lex_str, MYSQL_CONST_LEX_STRING
const char *str, unsigned int size, *thd_make_lex_string(void* thd, MYSQL_CONST_LEX_STRING *lex_str,
int allocate_lex_string); const char *str, unsigned int size,
int allocate_lex_string);
extern struct thd_autoinc_service_st { extern struct thd_autoinc_service_st {
void (*thd_get_autoinc_func)(const void* thd, void (*thd_get_autoinc_func)(const void* thd,
unsigned long* off, unsigned long* inc); unsigned long* off, unsigned long* inc);
@ -487,6 +496,6 @@ void thd_wakeup_subsequent_commits(void* thd, int wakeup_error);
struct st_mariadb_password_validation struct st_mariadb_password_validation
{ {
int interface_version; int interface_version;
int (*validate_password)(MYSQL_LEX_STRING *username, int (*validate_password)(MYSQL_CONST_LEX_STRING *username,
MYSQL_LEX_STRING *password); MYSQL_CONST_LEX_STRING *password);
}; };

View File

@ -92,9 +92,22 @@ extern struct my_snprintf_service_st {
#else #else
size_t my_snprintf(char* to, size_t n, const char* fmt, ...); #ifndef ATTRIBUTE_FORMAT
#define ATTRIBUTE_FORMAT_DEFINED
#define ATTRIBUTE_FORMAT(A,B,C)
#endif
#ifdef MYSQL_ABI_CHECK
#undef ATTRIBUTE_FORMAT
#define ATTRIBUTE_FORMAT(A,B,C)
#endif
size_t my_snprintf(char* to, size_t n, const char* fmt, ...)
ATTRIBUTE_FORMAT(printf, 3, 4);
size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap); size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap);
#ifdef ATTRIBUTE_FORMAT_DEFINED
#undef ATTRIBUTE_FORMAT_DEFINED
#undef ATTRIBUTE_FORMAT
#endif
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -42,13 +42,21 @@ struct st_mysql_lex_string
}; };
typedef struct st_mysql_lex_string MYSQL_LEX_STRING; typedef struct st_mysql_lex_string MYSQL_LEX_STRING;
struct st_mysql_const_lex_string
{
const char *str;
size_t length;
};
typedef struct st_mysql_const_lex_string MYSQL_CONST_LEX_STRING;
extern struct thd_alloc_service_st { extern struct thd_alloc_service_st {
void *(*thd_alloc_func)(MYSQL_THD, unsigned int); void *(*thd_alloc_func)(MYSQL_THD, unsigned int);
void *(*thd_calloc_func)(MYSQL_THD, unsigned int); void *(*thd_calloc_func)(MYSQL_THD, unsigned int);
char *(*thd_strdup_func)(MYSQL_THD, const char *); char *(*thd_strdup_func)(MYSQL_THD, const char *);
char *(*thd_strmake_func)(MYSQL_THD, const char *, unsigned int); char *(*thd_strmake_func)(MYSQL_THD, const char *, unsigned int);
void *(*thd_memdup_func)(MYSQL_THD, const void*, unsigned int); void *(*thd_memdup_func)(MYSQL_THD, const void*, unsigned int);
MYSQL_LEX_STRING *(*thd_make_lex_string_func)(MYSQL_THD, MYSQL_LEX_STRING *, MYSQL_CONST_LEX_STRING *(*thd_make_lex_string_func)(MYSQL_THD,
MYSQL_CONST_LEX_STRING *,
const char *, unsigned int, int); const char *, unsigned int, int);
} *thd_alloc_service; } *thd_alloc_service;
@ -115,9 +123,10 @@ void *thd_memdup(MYSQL_THD thd, const void* str, unsigned int size);
@see thd_alloc() @see thd_alloc()
*/ */
MYSQL_LEX_STRING *thd_make_lex_string(MYSQL_THD thd, MYSQL_LEX_STRING *lex_str, MYSQL_CONST_LEX_STRING
const char *str, unsigned int size, *thd_make_lex_string(MYSQL_THD thd, MYSQL_CONST_LEX_STRING *lex_str,
int allocate_lex_string); const char *str, unsigned int size,
int allocate_lex_string);
#endif #endif

View File

@ -634,7 +634,7 @@ typedef struct st_udf_args
char **args; /* Pointer to argument */ char **args; /* Pointer to argument */
unsigned long *lengths; /* Length of string arguments */ unsigned long *lengths; /* Length of string arguments */
char *maybe_null; /* Set to 1 for all maybe_null args */ char *maybe_null; /* Set to 1 for all maybe_null args */
char **attributes; /* Pointer to attribute name */ const char **attributes; /* Pointer to attribute name */
unsigned long *attribute_lengths; /* Length of attribute arguments */ unsigned long *attribute_lengths; /* Length of attribute arguments */
void *extension; void *extension;
} UDF_ARGS; } UDF_ARGS;

View File

@ -742,7 +742,7 @@ emb_transfer_connect_attrs(MYSQL *mysql)
int check_embedded_connection(MYSQL *mysql, const char *db) int check_embedded_connection(MYSQL *mysql, const char *db)
{ {
int result; int result;
LEX_STRING db_str = { (char*)db, db ? strlen(db) : 0 }; LEX_CSTRING db_str = { db, safe_strlen(db) };
THD *thd= (THD*)mysql->thd; THD *thd= (THD*)mysql->thd;
/* the server does the same as the client */ /* the server does the same as the client */
@ -1046,12 +1046,14 @@ bool Protocol::send_result_set_metadata(List<Item> *list, uint flags)
strlen(server_field.db_name), cs, thd_cs); strlen(server_field.db_name), cs, thd_cs);
client_field->table= dup_str_aux(field_alloc, server_field.table_name, client_field->table= dup_str_aux(field_alloc, server_field.table_name,
strlen(server_field.table_name), cs, thd_cs); strlen(server_field.table_name), cs, thd_cs);
client_field->name= dup_str_aux(field_alloc, server_field.col_name, client_field->name= dup_str_aux(field_alloc, server_field.col_name.str,
strlen(server_field.col_name), cs, thd_cs); server_field.col_name.length, cs, thd_cs);
client_field->org_table= dup_str_aux(field_alloc, server_field.org_table_name, client_field->org_table= dup_str_aux(field_alloc, server_field.org_table_name,
strlen(server_field.org_table_name), cs, thd_cs); strlen(server_field.org_table_name), cs, thd_cs);
client_field->org_name= dup_str_aux(field_alloc, server_field.org_col_name, client_field->org_name= dup_str_aux(field_alloc,
strlen(server_field.org_col_name), cs, thd_cs); server_field.org_col_name.str,
server_field.org_col_name.length,
cs, thd_cs);
if (item->charset_for_protocol() == &my_charset_bin || thd_cs == NULL) if (item->charset_for_protocol() == &my_charset_bin || thd_cs == NULL)
{ {
/* No conversion */ /* No conversion */

View File

@ -362,7 +362,6 @@
memory "loss" from _dl_init 2 memory "loss" from _dl_init 2
Memcheck:Leak Memcheck:Leak
fun:malloc fun:malloc
fun:pool
... ...
fun:call_init* fun:call_init*
fun:_dl_init fun:_dl_init

View File

@ -68,7 +68,7 @@ static int qa_auth_interface (MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *inf
else if (strcmp(info->user_name, "qa_test_2_user")== 0) else if (strcmp(info->user_name, "qa_test_2_user")== 0)
{ {
/* Overwriting not intended, but with effect on USER() */ /* Overwriting not intended, but with effect on USER() */
strcpy(info->user_name, "user_name"); strcpy((char*) info->user_name, "user_name");
info->user_name_length= 9; info->user_name_length= 9;
/* Overwriting not intended, effect not visible */ /* Overwriting not intended, effect not visible */
strcpy((char *)info->auth_string, "auth_string"); strcpy((char *)info->auth_string, "auth_string");
@ -107,7 +107,7 @@ static int qa_auth_interface (MYSQL_PLUGIN_VIO *vio, MYSQL_SERVER_AUTH_INFO *inf
else if (strcmp(info->user_name, "qa_test_5_user")== 0) else if (strcmp(info->user_name, "qa_test_5_user")== 0)
{ {
/* This assignment has no effect.*/ /* This assignment has no effect.*/
strcpy(info->user_name, ""); strcpy((char*) info->user_name, "");
info->user_name_length= 0; info->user_name_length= 0;
/* This assignment has no effect.*/ /* This assignment has no effect.*/
strcpy((char *)info->auth_string, ""); strcpy((char *)info->auth_string, "");

View File

@ -93,8 +93,8 @@ static COND* make_cond(THD *thd, TABLE_LIST *tables, LEX_STRING *filter)
{ {
Item_cond_or *res= NULL; Item_cond_or *res= NULL;
Name_resolution_context nrc; Name_resolution_context nrc;
const char *db= tables->db, *table= tables->alias, const char *db= tables->db, *table= tables->alias;
*field= tables->table->field[0]->field_name; LEX_CSTRING *field= &tables->table->field[0]->field_name;
CHARSET_INFO *cs= &my_charset_latin1; CHARSET_INFO *cs= &my_charset_latin1;
if (!filter->str) if (!filter->str)

View File

@ -1085,8 +1085,8 @@ dbcontext::parse_fields(TABLE *const table, const char *str,
Field **fld = 0; Field **fld = 0;
size_t j = 0; size_t j = 0;
for (fld = table->field; *fld; ++fld, ++j) { for (fld = table->field; *fld; ++fld, ++j) {
DBG_FLD(fprintf(stderr, "f %s\n", (*fld)->field_name)); DBG_FLD(fprintf(stderr, "f %s\n", (*fld)->field_name.str));
string_ref fn((*fld)->field_name, strlen((*fld)->field_name)); string_ref fn((*fld)->field_name.str, (*fld)->field_name.length);
if (fn == fldnms[i]) { if (fn == fldnms[i]) {
break; break;
} }
@ -1096,7 +1096,7 @@ dbcontext::parse_fields(TABLE *const table, const char *str,
std::string(fldnms[i].begin(), fldnms[i].size()).c_str())); std::string(fldnms[i].begin(), fldnms[i].size()).c_str()));
return false; return false;
} }
DBG_FLD(fprintf(stderr, "FLD %s %zu\n", (*fld)->field_name, j)); DBG_FLD(fprintf(stderr, "FLD %s %zu\n", (*fld)->field_name.str, j));
flds.push_back(j); flds.push_back(j);
} }
return true; return true;

View File

@ -142,7 +142,7 @@ static int qc_info_fill_table(THD *thd, TABLE_LIST *tables,
size_t flags_length; size_t flags_length;
const char *key, *db; const char *key, *db;
size_t key_length, db_length; size_t key_length, db_length;
LEX_STRING sql_mode_str; LEX_CSTRING sql_mode_str;
const String *tz; const String *tz;
CHARSET_INFO *cs_client; CHARSET_INFO *cs_client;
CHARSET_INFO *cs_result; CHARSET_INFO *cs_result;

View File

@ -23,7 +23,8 @@
static unsigned min_length, min_digits, min_letters, min_others; static unsigned min_length, min_digits, min_letters, min_others;
static int validate(MYSQL_LEX_STRING *username, MYSQL_LEX_STRING *password) static int validate(MYSQL_CONST_LEX_STRING *username,
MYSQL_CONST_LEX_STRING *password)
{ {
unsigned digits=0 , uppers=0 , lowers=0, others=0, length= password->length; unsigned digits=0 , uppers=0 , lowers=0, others=0, length= password->length;
const char *ptr= password->str, *end= ptr + length; const char *ptr= password->str, *end= ptr + length;

View File

@ -119,7 +119,7 @@ static bool report_unknown_option(THD *thd, engine_option_value *val,
#define value_ptr(STRUCT,OPT) ((char*)(STRUCT) + (OPT)->offset) #define value_ptr(STRUCT,OPT) ((char*)(STRUCT) + (OPT)->offset)
static bool set_one_value(ha_create_table_option *opt, static bool set_one_value(ha_create_table_option *opt,
THD *thd, const LEX_STRING *value, void *base, THD *thd, const LEX_CSTRING *value, void *base,
bool suppress_warning, bool suppress_warning,
MEM_ROOT *root) MEM_ROOT *root)
{ {
@ -311,7 +311,7 @@ bool parse_option_list(THD* thd, handlerton *hton, void *option_struct_arg,
} }
if (!seen || (opt->var && !last->value.str)) if (!seen || (opt->var && !last->value.str))
{ {
LEX_STRING default_val= null_lex_str; LEX_CSTRING default_val= null_clex_str;
/* /*
Okay, here's the logic for sysvar options: Okay, here's the logic for sysvar options:
@ -348,9 +348,9 @@ bool parse_option_list(THD* thd, handlerton *hton, void *option_struct_arg,
{ {
char buf[256]; char buf[256];
String sbuf(buf, sizeof(buf), system_charset_info), *str; String sbuf(buf, sizeof(buf), system_charset_info), *str;
if ((str= sysvar->val_str(&sbuf, thd, OPT_SESSION, &null_lex_str))) if ((str= sysvar->val_str(&sbuf, thd, OPT_SESSION, &null_clex_str)))
{ {
LEX_STRING name= { const_cast<char*>(opt->name), opt->name_length }; LEX_CSTRING name= { opt->name, opt->name_length };
default_val.str= strmake_root(root, str->ptr(), str->length()); default_val.str= strmake_root(root, str->ptr(), str->length());
default_val.length= str->length(); default_val.length= str->length();
val= new (root) engine_option_value(name, default_val, val= new (root) engine_option_value(name, default_val,
@ -688,7 +688,7 @@ uchar *engine_option_value::frm_read(const uchar *buff, const uchar *buff_end,
engine_option_value **start, engine_option_value **start,
engine_option_value **end, MEM_ROOT *root) engine_option_value **end, MEM_ROOT *root)
{ {
LEX_STRING name, value; LEX_CSTRING name, value;
uint len; uint len;
#define need_buff(N) if (buff + (N) >= buff_end) return NULL #define need_buff(N) if (buff + (N) >= buff_end) return NULL

View File

@ -29,8 +29,8 @@ enum { ENGINE_OPTION_MAX_LENGTH=32767 };
class engine_option_value: public Sql_alloc class engine_option_value: public Sql_alloc
{ {
public: public:
LEX_STRING name; LEX_CSTRING name;
LEX_STRING value; LEX_CSTRING value;
engine_option_value *next; ///< parser puts them in a FIFO linked list engine_option_value *next; ///< parser puts them in a FIFO linked list
bool parsed; ///< to detect unrecognized options bool parsed; ///< to detect unrecognized options
bool quoted_value; ///< option=VAL vs. option='VAL' bool quoted_value; ///< option=VAL vs. option='VAL'
@ -42,28 +42,30 @@ class engine_option_value: public Sql_alloc
{ {
link(start, end); link(start, end);
} }
engine_option_value(LEX_STRING &name_arg, LEX_STRING &value_arg, bool quoted, engine_option_value(LEX_CSTRING &name_arg, LEX_CSTRING &value_arg,
bool quoted,
engine_option_value **start, engine_option_value **end) : engine_option_value **start, engine_option_value **end) :
name(name_arg), value(value_arg), name(name_arg), value(value_arg),
next(NULL), parsed(false), quoted_value(quoted) next(NULL), parsed(false), quoted_value(quoted)
{ {
link(start, end); link(start, end);
} }
engine_option_value(LEX_STRING &name_arg, engine_option_value(LEX_CSTRING &name_arg,
engine_option_value **start, engine_option_value **end) : engine_option_value **start, engine_option_value **end) :
name(name_arg), value(null_lex_str), name(name_arg), value(null_clex_str),
next(NULL), parsed(false), quoted_value(false) next(NULL), parsed(false), quoted_value(false)
{ {
link(start, end); link(start, end);
} }
engine_option_value(LEX_STRING &name_arg, ulonglong value_arg, engine_option_value(LEX_CSTRING &name_arg, ulonglong value_arg,
engine_option_value **start, engine_option_value **end, engine_option_value **start, engine_option_value **end,
MEM_ROOT *root) : MEM_ROOT *root) :
name(name_arg), next(NULL), parsed(false), quoted_value(false) name(name_arg), next(NULL), parsed(false), quoted_value(false)
{ {
if ((value.str= (char *)alloc_root(root, 22))) char *str;
if ((value.str= str= (char *)alloc_root(root, 22)))
{ {
value.length= longlong10_to_str(value_arg, value.str, 10) - value.str; value.length= longlong10_to_str(value_arg, str, 10) - str;
link(start, end); link(start, end);
} }
} }

View File

@ -44,7 +44,7 @@ static int read_string(File file, uchar**to, size_t length)
@param[in] path path to FRM file. @param[in] path path to FRM file.
@param[in/out] engine_name table engine name (length < NAME_CHAR_LEN) @param[in/out] engine_name table engine name (length < NAME_CHAR_LEN)
engine_name is a LEX_STRING, where engine_name->str must point to engine_name is a LEX_CSTRING, where engine_name->str must point to
a buffer of at least NAME_CHAR_LEN+1 bytes. a buffer of at least NAME_CHAR_LEN+1 bytes.
@param[out] is_sequence 1 if table is a SEQUENCE, 0 otherwise @param[out] is_sequence 1 if table is a SEQUENCE, 0 otherwise
@ -55,7 +55,7 @@ static int read_string(File file, uchar**to, size_t length)
@retval TABLE_TYPE_VIEW view @retval TABLE_TYPE_VIEW view
*/ */
Table_type dd_frm_type(THD *thd, char *path, LEX_STRING *engine_name, Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name,
bool *is_sequence) bool *is_sequence)
{ {
File file; File file;
@ -132,8 +132,14 @@ Table_type dd_frm_type(THD *thd, char *path, LEX_STRING *engine_name,
{ {
uint len= uint2korr(next_chunk); uint len= uint2korr(next_chunk);
if (len <= NAME_CHAR_LEN) if (len <= NAME_CHAR_LEN)
strmake(engine_name->str, (char*)next_chunk + 2, {
/*
The following cast is safe as the caller has allocated buffer
and it's up to this function to generate the name.
*/
strmake((char*) engine_name->str, (char*)next_chunk + 2,
engine_name->length= len); engine_name->length= len);
}
} }
} }

View File

@ -38,7 +38,7 @@ enum Table_type
To check whether it's an frm of a view, use dd_frm_is_view(). To check whether it's an frm of a view, use dd_frm_is_view().
*/ */
enum Table_type dd_frm_type(THD *thd, char *path, LEX_STRING *engine_name, enum Table_type dd_frm_type(THD *thd, char *path, LEX_CSTRING *engine_name,
bool *is_sequence); bool *is_sequence);
static inline bool dd_frm_is_view(THD *thd, char *path) static inline bool dd_frm_is_view(THD *thd, char *path)

View File

@ -171,13 +171,13 @@ Event_creation_ctx::load_from_db(THD *thd,
*/ */
bool bool
Event_queue_element_for_exec::init(LEX_STRING db, LEX_STRING n) Event_queue_element_for_exec::init(LEX_CSTRING db, LEX_CSTRING n)
{ {
if (!(dbname.str= my_strndup(db.str, dbname.length= db.length, MYF(MY_WME)))) if (!(dbname.str= my_strndup(db.str, dbname.length= db.length, MYF(MY_WME))))
return TRUE; return TRUE;
if (!(name.str= my_strndup(n.str, name.length= n.length, MYF(MY_WME)))) if (!(name.str= my_strndup(n.str, name.length= n.length, MYF(MY_WME))))
{ {
my_free(dbname.str); my_free(const_cast<char*>(dbname.str));
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
@ -193,8 +193,8 @@ Event_queue_element_for_exec::init(LEX_STRING db, LEX_STRING n)
Event_queue_element_for_exec::~Event_queue_element_for_exec() Event_queue_element_for_exec::~Event_queue_element_for_exec()
{ {
my_free(dbname.str); my_free(const_cast<char*>(dbname.str));
my_free(name.str); my_free(const_cast<char*>(name.str));
} }
@ -233,7 +233,7 @@ Event_basic::~Event_basic()
/* /*
Short function to load a char column into a LEX_STRING Short function to load a char column into a LEX_CSTRING
SYNOPSIS SYNOPSIS
Event_basic::load_string_field() Event_basic::load_string_field()
@ -249,7 +249,7 @@ Event_basic::load_string_fields(Field **fields, ...)
bool ret= FALSE; bool ret= FALSE;
va_list args; va_list args;
enum enum_events_table_field field_name; enum enum_events_table_field field_name;
LEX_STRING *field_value; LEX_CSTRING *field_value;
DBUG_ENTER("Event_basic::load_string_fields"); DBUG_ENTER("Event_basic::load_string_fields");
@ -257,7 +257,7 @@ Event_basic::load_string_fields(Field **fields, ...)
field_name= (enum enum_events_table_field) va_arg(args, int); field_name= (enum enum_events_table_field) va_arg(args, int);
while (field_name < ET_FIELD_COUNT) while (field_name < ET_FIELD_COUNT)
{ {
field_value= va_arg(args, LEX_STRING *); field_value= va_arg(args, LEX_CSTRING *);
if ((field_value->str= get_field(&mem_root, fields[field_name])) == NullS) if ((field_value->str= get_field(&mem_root, fields[field_name])) == NullS)
{ {
ret= TRUE; ret= TRUE;
@ -274,9 +274,9 @@ Event_basic::load_string_fields(Field **fields, ...)
bool bool
Event_basic::load_time_zone(THD *thd, const LEX_STRING tz_name) Event_basic::load_time_zone(THD *thd, const LEX_CSTRING *tz_name)
{ {
String str(tz_name.str, &my_charset_latin1); String str(tz_name->str, &my_charset_latin1);
time_zone= my_tz_find(thd, &str); time_zone= my_tz_find(thd, &str);
return (time_zone == NULL); return (time_zone == NULL);
@ -391,9 +391,9 @@ Event_timed::init()
bool bool
Event_job_data::load_from_row(THD *thd, TABLE *table) Event_job_data::load_from_row(THD *thd, TABLE *table)
{ {
char *ptr; const char *ptr;
size_t len; size_t len;
LEX_STRING tz_name; LEX_CSTRING tz_name;
DBUG_ENTER("Event_job_data::load_from_row"); DBUG_ENTER("Event_job_data::load_from_row");
@ -412,7 +412,7 @@ Event_job_data::load_from_row(THD *thd, TABLE *table)
ET_FIELD_COUNT)) ET_FIELD_COUNT))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
if (load_time_zone(thd, tz_name)) if (load_time_zone(thd, &tz_name))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
Event_creation_ctx::load_from_db(thd, &mem_root, dbname.str, name.str, table, Event_creation_ctx::load_from_db(thd, &mem_root, dbname.str, name.str, table,
@ -452,9 +452,9 @@ Event_job_data::load_from_row(THD *thd, TABLE *table)
bool bool
Event_queue_element::load_from_row(THD *thd, TABLE *table) Event_queue_element::load_from_row(THD *thd, TABLE *table)
{ {
char *ptr; const char *ptr;
MYSQL_TIME time; MYSQL_TIME time;
LEX_STRING tz_name; LEX_CSTRING tz_name;
DBUG_ENTER("Event_queue_element::load_from_row"); DBUG_ENTER("Event_queue_element::load_from_row");
@ -472,7 +472,7 @@ Event_queue_element::load_from_row(THD *thd, TABLE *table)
ET_FIELD_COUNT)) ET_FIELD_COUNT))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
if (load_time_zone(thd, tz_name)) if (load_time_zone(thd, &tz_name))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
starts_null= table->field[ET_FIELD_STARTS]->is_null(); starts_null= table->field[ET_FIELD_STARTS]->is_null();
@ -519,7 +519,7 @@ Event_queue_element::load_from_row(THD *thd, TABLE *table)
int i; int i;
char buff[MAX_FIELD_WIDTH]; char buff[MAX_FIELD_WIDTH];
String str(buff, sizeof(buff), &my_charset_bin); String str(buff, sizeof(buff), &my_charset_bin);
LEX_STRING tmp; LEX_CSTRING tmp;
table->field[ET_FIELD_TRANSIENT_INTERVAL]->val_str(&str); table->field[ET_FIELD_TRANSIENT_INTERVAL]->val_str(&str);
if (!(tmp.length= str.length())) if (!(tmp.length= str.length()))
@ -590,7 +590,7 @@ Event_queue_element::load_from_row(THD *thd, TABLE *table)
bool bool
Event_timed::load_from_row(THD *thd, TABLE *table) Event_timed::load_from_row(THD *thd, TABLE *table)
{ {
char *ptr; const char *ptr;
size_t len; size_t len;
DBUG_ENTER("Event_timed::load_from_row"); DBUG_ENTER("Event_timed::load_from_row");
@ -1203,7 +1203,7 @@ Event_timed::get_create_event(THD *thd, String *buf)
buf->append(STRING_WITH_LEN(" ON SCHEDULE EVERY ")); buf->append(STRING_WITH_LEN(" ON SCHEDULE EVERY "));
buf->append(expr_buf); buf->append(expr_buf);
buf->append(' '); buf->append(' ');
LEX_STRING *ival= &interval_type_to_name[interval]; LEX_CSTRING *ival= &interval_type_to_name[interval];
buf->append(ival->str, ival->length); buf->append(ival->str, ival->length);
if (!starts_null) if (!starts_null)
@ -1249,7 +1249,7 @@ Event_timed::get_create_event(THD *thd, String *buf)
bool bool
Event_job_data::construct_sp_sql(THD *thd, String *sp_sql) Event_job_data::construct_sp_sql(THD *thd, String *sp_sql)
{ {
LEX_STRING buffer; LEX_CSTRING buffer;
const uint STATIC_SQL_LENGTH= 44; const uint STATIC_SQL_LENGTH= 44;
DBUG_ENTER("Event_job_data::construct_sp_sql"); DBUG_ENTER("Event_job_data::construct_sp_sql");
@ -1298,7 +1298,7 @@ Event_job_data::construct_sp_sql(THD *thd, String *sp_sql)
bool bool
Event_job_data::construct_drop_event_sql(THD *thd, String *sp_sql) Event_job_data::construct_drop_event_sql(THD *thd, String *sp_sql)
{ {
LEX_STRING buffer; LEX_CSTRING buffer;
const uint STATIC_SQL_LENGTH= 14; const uint STATIC_SQL_LENGTH= 14;
DBUG_ENTER("Event_job_data::construct_drop_event_sql"); DBUG_ENTER("Event_job_data::construct_drop_event_sql");
@ -1478,7 +1478,7 @@ end:
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL); WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL);
} }
ret= Events::drop_event(thd, dbname, name, FALSE); ret= Events::drop_event(thd, &dbname, &name, FALSE);
WSREP_TO_ISOLATION_END; WSREP_TO_ISOLATION_END;
@ -1519,9 +1519,9 @@ end:
*/ */
bool bool
event_basic_db_equal(LEX_STRING db, Event_basic *et) event_basic_db_equal(const LEX_CSTRING *db, Event_basic *et)
{ {
return !sortcmp_lex_string(et->dbname, db, system_charset_info); return !sortcmp_lex_string(&et->dbname, db, system_charset_info);
} }
@ -1540,10 +1540,11 @@ event_basic_db_equal(LEX_STRING db, Event_basic *et)
*/ */
bool bool
event_basic_identifier_equal(LEX_STRING db, LEX_STRING name, Event_basic *b) event_basic_identifier_equal(const LEX_CSTRING *db, const LEX_CSTRING *name,
Event_basic *b)
{ {
return !sortcmp_lex_string(name, b->name, system_charset_info) && return !sortcmp_lex_string(name, &b->name, system_charset_info) &&
!sortcmp_lex_string(db, b->dbname, system_charset_info); !sortcmp_lex_string(db, &b->dbname, system_charset_info);
} }
/** /**

View File

@ -37,10 +37,10 @@ public:
~Event_queue_element_for_exec(); ~Event_queue_element_for_exec();
bool bool
init(LEX_STRING dbname, LEX_STRING name); init(LEX_CSTRING dbname, LEX_CSTRING name);
LEX_STRING dbname; LEX_CSTRING dbname;
LEX_STRING name; LEX_CSTRING name;
bool dropped; bool dropped;
THD *thd; THD *thd;
@ -58,9 +58,9 @@ protected:
public: public:
LEX_STRING dbname; LEX_CSTRING dbname;
LEX_STRING name; LEX_CSTRING name;
LEX_STRING definer;// combination of user and host LEX_CSTRING definer;// combination of user and host
Time_zone *time_zone; Time_zone *time_zone;
@ -75,7 +75,7 @@ protected:
load_string_fields(Field **fields, ...); load_string_fields(Field **fields, ...);
bool bool
load_time_zone(THD *thd, const LEX_STRING tz_name); load_time_zone(THD *thd, const LEX_CSTRING *tz_name);
}; };
@ -122,12 +122,12 @@ class Event_timed : public Event_queue_element
void operator=(Event_timed &); void operator=(Event_timed &);
public: public:
LEX_STRING body; LEX_CSTRING body;
LEX_STRING definer_user; LEX_CSTRING definer_user;
LEX_STRING definer_host; LEX_CSTRING definer_host;
LEX_STRING comment; LEX_CSTRING comment;
ulonglong created; ulonglong created;
ulonglong modified; ulonglong modified;
@ -135,7 +135,7 @@ public:
sql_mode_t sql_mode; sql_mode_t sql_mode;
class Stored_program_creation_ctx *creation_ctx; class Stored_program_creation_ctx *creation_ctx;
LEX_STRING body_utf8; LEX_CSTRING body_utf8;
Event_timed(); Event_timed();
virtual ~Event_timed(); virtual ~Event_timed();
@ -154,9 +154,9 @@ public:
class Event_job_data : public Event_basic class Event_job_data : public Event_basic
{ {
public: public:
LEX_STRING body; LEX_CSTRING body;
LEX_STRING definer_user; LEX_CSTRING definer_user;
LEX_STRING definer_host; LEX_CSTRING definer_host;
sql_mode_t sql_mode; sql_mode_t sql_mode;
@ -182,11 +182,12 @@ private:
/* Compares only the schema part of the identifier */ /* Compares only the schema part of the identifier */
bool bool
event_basic_db_equal(LEX_STRING db, Event_basic *et); event_basic_db_equal(const LEX_CSTRING *db, Event_basic *et);
/* Compares the whole identifier*/ /* Compares the whole identifier*/
bool bool
event_basic_identifier_equal(LEX_STRING db, LEX_STRING name, Event_basic *b); event_basic_identifier_equal(const LEX_CSTRING *db, const LEX_CSTRING *name,
Event_basic *b);
/** /**
@} (End of group Event_Scheduler) @} (End of group Event_Scheduler)

View File

@ -368,14 +368,14 @@ mysql_event_fill_row(THD *thd,
if (rs) if (rs)
{ {
my_error(ER_EVENT_STORE_FAILED, MYF(0), fields[f_num]->field_name, rs); my_error(ER_EVENT_STORE_FAILED, MYF(0), fields[f_num]->field_name.str, rs);
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
err_truncate: err_truncate:
my_error(ER_EVENT_DATA_TOO_LONG, MYF(0), fields[f_num]->field_name); my_error(ER_EVENT_DATA_TOO_LONG, MYF(0), fields[f_num]->field_name.str);
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
@ -670,7 +670,7 @@ Event_db_repository::create_event(THD *thd, Event_parse_data *parse_data,
parse_data->name.str)); parse_data->name.str));
DBUG_PRINT("info", ("check existance of an event with the same name")); DBUG_PRINT("info", ("check existance of an event with the same name"));
if (!find_named_event(parse_data->dbname, parse_data->name, table)) if (!find_named_event(&parse_data->dbname, &parse_data->name, table))
{ {
if (thd->lex->create_info.or_replace()) if (thd->lex->create_info.or_replace())
{ {
@ -768,8 +768,8 @@ end:
bool bool
Event_db_repository::update_event(THD *thd, Event_parse_data *parse_data, Event_db_repository::update_event(THD *thd, Event_parse_data *parse_data,
LEX_STRING *new_dbname, LEX_CSTRING *new_dbname,
LEX_STRING *new_name) LEX_CSTRING *new_name)
{ {
CHARSET_INFO *scs= system_charset_info; CHARSET_INFO *scs= system_charset_info;
TABLE *table= NULL; TABLE *table= NULL;
@ -802,7 +802,7 @@ Event_db_repository::update_event(THD *thd, Event_parse_data *parse_data,
if (new_name) if (new_name)
{ {
DBUG_PRINT("info", ("rename to: %s@%s", new_dbname->str, new_name->str)); DBUG_PRINT("info", ("rename to: %s@%s", new_dbname->str, new_name->str));
if (!find_named_event(*new_dbname, *new_name, table)) if (!find_named_event(new_dbname, new_name, table))
{ {
my_error(ER_EVENT_ALREADY_EXISTS, MYF(0), new_name->str); my_error(ER_EVENT_ALREADY_EXISTS, MYF(0), new_name->str);
goto end; goto end;
@ -814,7 +814,7 @@ Event_db_repository::update_event(THD *thd, Event_parse_data *parse_data,
overwrite the key and SE will tell us that it cannot find the already found overwrite the key and SE will tell us that it cannot find the already found
row (copied into record[1] later row (copied into record[1] later
*/ */
if (find_named_event(parse_data->dbname, parse_data->name, table)) if (find_named_event(&parse_data->dbname, &parse_data->name, table))
{ {
my_error(ER_EVENT_DOES_NOT_EXIST, MYF(0), parse_data->name.str); my_error(ER_EVENT_DOES_NOT_EXIST, MYF(0), parse_data->name.str);
goto end; goto end;
@ -878,7 +878,8 @@ end:
*/ */
bool bool
Event_db_repository::drop_event(THD *thd, LEX_STRING db, LEX_STRING name, Event_db_repository::drop_event(THD *thd, const LEX_CSTRING *db,
const LEX_CSTRING *name,
bool drop_if_exists) bool drop_if_exists)
{ {
TABLE *table= NULL; TABLE *table= NULL;
@ -891,7 +892,7 @@ Event_db_repository::drop_event(THD *thd, LEX_STRING db, LEX_STRING name,
int ret= 1; int ret= 1;
DBUG_ENTER("Event_db_repository::drop_event"); DBUG_ENTER("Event_db_repository::drop_event");
DBUG_PRINT("enter", ("%s@%s", db.str, name.str)); DBUG_PRINT("enter", ("%s@%s", db->str, name->str));
if (open_event_table(thd, TL_WRITE, &table)) if (open_event_table(thd, TL_WRITE, &table))
goto end; goto end;
@ -906,13 +907,13 @@ Event_db_repository::drop_event(THD *thd, LEX_STRING db, LEX_STRING name,
/* Event not found */ /* Event not found */
if (!drop_if_exists) if (!drop_if_exists)
{ {
my_error(ER_EVENT_DOES_NOT_EXIST, MYF(0), name.str); my_error(ER_EVENT_DOES_NOT_EXIST, MYF(0), name->str);
goto end; goto end;
} }
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
ER_SP_DOES_NOT_EXIST, ER_THD(thd, ER_SP_DOES_NOT_EXIST), ER_SP_DOES_NOT_EXIST, ER_THD(thd, ER_SP_DOES_NOT_EXIST),
"Event", name.str); "Event", name->str);
ret= 0; ret= 0;
end: end:
@ -939,12 +940,13 @@ end:
*/ */
bool bool
Event_db_repository::find_named_event(LEX_STRING db, LEX_STRING name, Event_db_repository::find_named_event(const LEX_CSTRING *db,
const LEX_CSTRING *name,
TABLE *table) TABLE *table)
{ {
uchar key[MAX_KEY_LENGTH]; uchar key[MAX_KEY_LENGTH];
DBUG_ENTER("Event_db_repository::find_named_event"); DBUG_ENTER("Event_db_repository::find_named_event");
DBUG_PRINT("enter", ("name: %.*s", (int) name.length, name.str)); DBUG_PRINT("enter", ("name: %.*s", (int) name->length, name->str));
/* /*
Create key to find row. We have to use field->store() to be able to Create key to find row. We have to use field->store() to be able to
@ -953,16 +955,16 @@ Event_db_repository::find_named_event(LEX_STRING db, LEX_STRING name,
'db' and 'name' and the first key is the primary key over the 'db' and 'name' and the first key is the primary key over the
same fields. same fields.
*/ */
if (db.length > table->field[ET_FIELD_DB]->field_length || if (db->length > table->field[ET_FIELD_DB]->field_length ||
name.length > table->field[ET_FIELD_NAME]->field_length || name->length > table->field[ET_FIELD_NAME]->field_length ||
table->s->keys == 0 || table->s->keys == 0 ||
table->key_info[0].user_defined_key_parts != 2 || table->key_info[0].user_defined_key_parts != 2 ||
table->key_info[0].key_part[0].fieldnr != ET_FIELD_DB+1 || table->key_info[0].key_part[0].fieldnr != ET_FIELD_DB+1 ||
table->key_info[0].key_part[1].fieldnr != ET_FIELD_NAME+1) table->key_info[0].key_part[1].fieldnr != ET_FIELD_NAME+1)
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
table->field[ET_FIELD_DB]->store(db.str, db.length, &my_charset_bin); table->field[ET_FIELD_DB]->store(db->str, db->length, &my_charset_bin);
table->field[ET_FIELD_NAME]->store(name.str, name.length, &my_charset_bin); table->field[ET_FIELD_NAME]->store(name->str, name->length, &my_charset_bin);
key_copy(key, table->record[0], table->key_info, table->key_info->key_length); key_copy(key, table->record[0], table->key_info, table->key_info->key_length);
@ -989,7 +991,7 @@ Event_db_repository::find_named_event(LEX_STRING db, LEX_STRING name,
*/ */
void void
Event_db_repository::drop_schema_events(THD *thd, LEX_STRING schema) Event_db_repository::drop_schema_events(THD *thd, const LEX_CSTRING *schema)
{ {
int ret= 0; int ret= 0;
TABLE *table= NULL; TABLE *table= NULL;
@ -997,7 +999,7 @@ Event_db_repository::drop_schema_events(THD *thd, LEX_STRING schema)
enum enum_events_table_field field= ET_FIELD_DB; enum enum_events_table_field field= ET_FIELD_DB;
MDL_savepoint mdl_savepoint= thd->mdl_context.mdl_savepoint(); MDL_savepoint mdl_savepoint= thd->mdl_context.mdl_savepoint();
DBUG_ENTER("Event_db_repository::drop_schema_events"); DBUG_ENTER("Event_db_repository::drop_schema_events");
DBUG_PRINT("enter", ("field=%d schema=%s", field, schema.str)); DBUG_PRINT("enter", ("field: %d schema: %s", field, schema->str));
if (open_event_table(thd, TL_WRITE, &table)) if (open_event_table(thd, TL_WRITE, &table))
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
@ -1013,12 +1015,12 @@ Event_db_repository::drop_schema_events(THD *thd, LEX_STRING schema)
/* et_field may be NULL if the table is corrupted or out of memory */ /* et_field may be NULL if the table is corrupted or out of memory */
if (et_field) if (et_field)
{ {
LEX_STRING et_field_lex= { et_field, strlen(et_field) }; LEX_CSTRING et_field_lex= { et_field, strlen(et_field) };
DBUG_PRINT("info", ("Current event %s name=%s", et_field, DBUG_PRINT("info", ("Current event %s name=%s", et_field,
get_field(thd->mem_root, get_field(thd->mem_root,
table->field[ET_FIELD_NAME]))); table->field[ET_FIELD_NAME])));
if (!sortcmp_lex_string(et_field_lex, schema, system_charset_info)) if (!sortcmp_lex_string(&et_field_lex, schema, system_charset_info))
{ {
DBUG_PRINT("info", ("Dropping")); DBUG_PRINT("info", ("Dropping"));
if ((ret= table->file->ha_delete_row(table->record[0]))) if ((ret= table->file->ha_delete_row(table->record[0])))
@ -1051,8 +1053,9 @@ end:
*/ */
bool bool
Event_db_repository::load_named_event(THD *thd, LEX_STRING dbname, Event_db_repository::load_named_event(THD *thd, const LEX_CSTRING *dbname,
LEX_STRING name, Event_basic *etn) const LEX_CSTRING *name,
Event_basic *etn)
{ {
bool ret; bool ret;
ulonglong saved_mode= thd->variables.sql_mode; ulonglong saved_mode= thd->variables.sql_mode;
@ -1061,7 +1064,7 @@ Event_db_repository::load_named_event(THD *thd, LEX_STRING dbname,
DBUG_ENTER("Event_db_repository::load_named_event"); DBUG_ENTER("Event_db_repository::load_named_event");
DBUG_PRINT("enter",("thd: 0x%lx name: %*s", (long) thd, DBUG_PRINT("enter",("thd: 0x%lx name: %*s", (long) thd,
(int) name.length, name.str)); (int) name->length, name->str));
event_table.init_one_table("mysql", 5, "event", 5, "event", TL_READ); event_table.init_one_table("mysql", 5, "event", 5, "event", TL_READ);
@ -1084,7 +1087,7 @@ Event_db_repository::load_named_event(THD *thd, LEX_STRING dbname,
} }
if ((ret= find_named_event(dbname, name, event_table.table))) if ((ret= find_named_event(dbname, name, event_table.table)))
my_error(ER_EVENT_DOES_NOT_EXIST, MYF(0), name.str); my_error(ER_EVENT_DOES_NOT_EXIST, MYF(0), name->str);
else if ((ret= etn->load_from_row(thd, event_table.table))) else if ((ret= etn->load_from_row(thd, event_table.table)))
my_error(ER_CANNOT_LOAD_FROM_TABLE_V2, MYF(0), "mysql", "event"); my_error(ER_CANNOT_LOAD_FROM_TABLE_V2, MYF(0), "mysql", "event");
@ -1106,8 +1109,8 @@ Event_db_repository::load_named_event(THD *thd, LEX_STRING dbname,
bool bool
Event_db_repository:: Event_db_repository::
update_timing_fields_for_event(THD *thd, update_timing_fields_for_event(THD *thd,
LEX_STRING event_db_name, const LEX_CSTRING *event_db_name,
LEX_STRING event_name, const LEX_CSTRING *event_name,
my_time_t last_executed, my_time_t last_executed,
ulonglong status) ulonglong status)
{ {
@ -1211,7 +1214,7 @@ Event_db_repository::check_system_tables(THD *thd)
else else
{ {
if (tables.table->s->fields < event_priv_column_position || if (tables.table->s->fields < event_priv_column_position ||
strncmp(tables.table->field[event_priv_column_position]->field_name, strncmp(tables.table->field[event_priv_column_position]->field_name.str,
STRING_WITH_LEN("Event_priv"))) STRING_WITH_LEN("Event_priv")))
{ {
sql_print_error("mysql.user has no `Event_priv` column at position %d", sql_print_error("mysql.user has no `Event_priv` column at position %d",

View File

@ -77,20 +77,24 @@ public:
create_event(THD *thd, Event_parse_data *parse_data, create_event(THD *thd, Event_parse_data *parse_data,
bool *event_already_exists); bool *event_already_exists);
bool bool
update_event(THD *thd, Event_parse_data *parse_data, LEX_STRING *new_dbname, update_event(THD *thd, Event_parse_data *parse_data, LEX_CSTRING *new_dbname,
LEX_STRING *new_name); LEX_CSTRING *new_name);
bool bool
drop_event(THD *thd, LEX_STRING db, LEX_STRING name, bool drop_if_exists); drop_event(THD *thd, const LEX_CSTRING *db, const LEX_CSTRING *name,
bool drop_if_exists);
void void
drop_schema_events(THD *thd, LEX_STRING schema); drop_schema_events(THD *thd, const LEX_CSTRING *schema);
bool bool
find_named_event(LEX_STRING db, LEX_STRING name, TABLE *table); find_named_event(const LEX_CSTRING *db, const LEX_CSTRING *name,
TABLE *table);
bool bool
load_named_event(THD *thd, LEX_STRING dbname, LEX_STRING name, Event_basic *et); load_named_event(THD *thd, const LEX_CSTRING *dbname,
const LEX_CSTRING *name,
Event_basic *et);
static bool static bool
open_event_table(THD *thd, enum thr_lock_type lock_type, TABLE **table); open_event_table(THD *thd, enum thr_lock_type lock_type, TABLE **table);
@ -100,8 +104,8 @@ public:
bool bool
update_timing_fields_for_event(THD *thd, update_timing_fields_for_event(THD *thd,
LEX_STRING event_db_name, const LEX_CSTRING *event_db_name,
LEX_STRING event_name, const LEX_CSTRING *event_name,
my_time_t last_executed, my_time_t last_executed,
ulonglong status); ulonglong status);
public: public:

View File

@ -528,7 +528,7 @@ Event_parse_data::init_definer(THD *thd)
const char *definer_host= thd->lex->definer->host.str; const char *definer_host= thd->lex->definer->host.str;
size_t definer_user_len= thd->lex->definer->user.length; size_t definer_user_len= thd->lex->definer->user.length;
size_t definer_host_len= thd->lex->definer->host.length; size_t definer_host_len= thd->lex->definer->host.length;
char *tmp;
DBUG_PRINT("info",("init definer_user thd->mem_root: 0x%lx " DBUG_PRINT("info",("init definer_user thd->mem_root: 0x%lx "
"definer_user: 0x%lx", (long) thd->mem_root, "definer_user: 0x%lx", (long) thd->mem_root,
(long) definer_user)); (long) definer_user));
@ -536,15 +536,14 @@ Event_parse_data::init_definer(THD *thd)
/* + 1 for @ */ /* + 1 for @ */
DBUG_PRINT("info",("init definer as whole")); DBUG_PRINT("info",("init definer as whole"));
definer.length= definer_user_len + definer_host_len + 1; definer.length= definer_user_len + definer_host_len + 1;
definer.str= (char*) thd->alloc(definer.length + 1); definer.str= tmp= (char*) thd->alloc(definer.length + 1);
DBUG_PRINT("info",("copy the user")); DBUG_PRINT("info",("copy the user"));
memcpy(definer.str, definer_user, definer_user_len); strmake(tmp, definer_user, definer_user_len);
definer.str[definer_user_len]= '@'; tmp[definer_user_len]= '@';
DBUG_PRINT("info",("copy the host")); DBUG_PRINT("info",("copy the host"));
memcpy(definer.str + definer_user_len + 1, definer_host, definer_host_len); strmake(tmp + definer_user_len + 1, definer_host, definer_host_len);
definer.str[definer.length]= '\0';
DBUG_PRINT("info",("definer [%s] initted", definer.str)); DBUG_PRINT("info",("definer [%s] initted", definer.str));
DBUG_VOID_RETURN; DBUG_VOID_RETURN;

View File

@ -66,10 +66,10 @@ public:
bool body_changed; bool body_changed;
LEX_STRING dbname; LEX_CSTRING dbname;
LEX_STRING name; LEX_CSTRING name;
LEX_STRING definer;// combination of user and host LEX_CSTRING definer;// combination of user and host
LEX_STRING comment; LEX_CSTRING comment;
Item* item_starts; Item* item_starts;
Item* item_ends; Item* item_ends;

View File

@ -238,11 +238,13 @@ Event_queue::create_event(THD *thd, Event_queue_element *new_element,
*/ */
void void
Event_queue::update_event(THD *thd, LEX_STRING dbname, LEX_STRING name, Event_queue::update_event(THD *thd, const LEX_CSTRING *dbname,
const LEX_CSTRING *name,
Event_queue_element *new_element) Event_queue_element *new_element)
{ {
DBUG_ENTER("Event_queue::update_event"); DBUG_ENTER("Event_queue::update_event");
DBUG_PRINT("enter", ("thd: 0x%lx et=[%s.%s]", (long) thd, dbname.str, name.str)); DBUG_PRINT("enter", ("thd: %p et: [%s.%s]", thd, dbname->str,
name->str));
if ((new_element->status == Event_parse_data::DISABLED) || if ((new_element->status == Event_parse_data::DISABLED) ||
(new_element->status == Event_parse_data::SLAVESIDE_DISABLED)) (new_element->status == Event_parse_data::SLAVESIDE_DISABLED))
@ -287,11 +289,12 @@ Event_queue::update_event(THD *thd, LEX_STRING dbname, LEX_STRING name,
*/ */
void void
Event_queue::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name) Event_queue::drop_event(THD *thd, const LEX_CSTRING *dbname,
const LEX_CSTRING *name)
{ {
DBUG_ENTER("Event_queue::drop_event"); DBUG_ENTER("Event_queue::drop_event");
DBUG_PRINT("enter", ("thd: 0x%lx db :%s name: %s", (long) thd, DBUG_PRINT("enter", ("thd: %p db: %s name: %s", thd,
dbname.str, name.str)); dbname->str, name->str));
LOCK_QUEUE_DATA(); LOCK_QUEUE_DATA();
find_n_remove_event(dbname, name); find_n_remove_event(dbname, name);
@ -325,12 +328,12 @@ Event_queue::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name)
*/ */
void void
Event_queue::drop_matching_events(THD *thd, LEX_STRING pattern, Event_queue::drop_matching_events(THD *thd, const LEX_CSTRING *pattern,
bool (*comparator)(LEX_STRING, Event_basic *)) bool (*comparator)(const LEX_CSTRING *, Event_basic *))
{ {
uint i; uint i;
DBUG_ENTER("Event_queue::drop_matching_events"); DBUG_ENTER("Event_queue::drop_matching_events");
DBUG_PRINT("enter", ("pattern=%s", pattern.str)); DBUG_PRINT("enter", ("pattern: %s", pattern->str));
for (i= queue_first_element(&queue) ; for (i= queue_first_element(&queue) ;
i <= queue_last_element(&queue) ; i <= queue_last_element(&queue) ;
@ -380,7 +383,7 @@ Event_queue::drop_matching_events(THD *thd, LEX_STRING pattern,
*/ */
void void
Event_queue::drop_schema_events(THD *thd, LEX_STRING schema) Event_queue::drop_schema_events(THD *thd, const LEX_CSTRING *schema)
{ {
DBUG_ENTER("Event_queue::drop_schema_events"); DBUG_ENTER("Event_queue::drop_schema_events");
LOCK_QUEUE_DATA(); LOCK_QUEUE_DATA();
@ -404,7 +407,8 @@ Event_queue::drop_schema_events(THD *thd, LEX_STRING schema)
*/ */
void void
Event_queue::find_n_remove_event(LEX_STRING db, LEX_STRING name) Event_queue::find_n_remove_event(const LEX_CSTRING *db,
const LEX_CSTRING *name)
{ {
uint i; uint i;
DBUG_ENTER("Event_queue::find_n_remove_event"); DBUG_ENTER("Event_queue::find_n_remove_event");
@ -414,7 +418,7 @@ Event_queue::find_n_remove_event(LEX_STRING db, LEX_STRING name)
i++) i++)
{ {
Event_queue_element *et= (Event_queue_element *) queue_element(&queue, i); Event_queue_element *et= (Event_queue_element *) queue_element(&queue, i);
DBUG_PRINT("info", ("[%s.%s]==[%s.%s]?", db.str, name.str, DBUG_PRINT("info", ("[%s.%s]==[%s.%s]?", db->str, name->str,
et->dbname.str, et->name.str)); et->dbname.str, et->name.str));
if (event_basic_identifier_equal(db, name, et)) if (event_basic_identifier_equal(db, name, et))
{ {
@ -683,7 +687,7 @@ end:
Event_db_repository *db_repository= Events::get_db_repository(); Event_db_repository *db_repository= Events::get_db_repository();
(void) db_repository->update_timing_fields_for_event(thd, (void) db_repository->update_timing_fields_for_event(thd,
(*event_name)->dbname, (*event_name)->name, &(*event_name)->dbname, &(*event_name)->name,
last_executed, (ulonglong) status); last_executed, (ulonglong) status);
} }

View File

@ -31,7 +31,7 @@ extern PSI_cond_key key_COND_queue_state;
#endif /* HAVE_PSI_INTERFACE */ #endif /* HAVE_PSI_INTERFACE */
#include "queues.h" // QUEUE #include "queues.h" // QUEUE
#include "sql_string.h" /* LEX_STRING */ #include "sql_string.h" /* LEX_CSTRING */
#include "my_time.h" /* my_time_t, interval_type */ #include "my_time.h" /* my_time_t, interval_type */
class Event_basic; class Event_basic;
@ -60,14 +60,14 @@ public:
bool *created); bool *created);
void void
update_event(THD *thd, LEX_STRING dbname, LEX_STRING name, update_event(THD *thd, const LEX_CSTRING *dbname, const LEX_CSTRING *name,
Event_queue_element *new_element); Event_queue_element *new_element);
void void
drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name); drop_event(THD *thd, const LEX_CSTRING *dbname, const LEX_CSTRING *name);
void void
drop_schema_events(THD *thd, LEX_STRING schema); drop_schema_events(THD *thd, const LEX_CSTRING *schema);
void void
recalculate_activation_times(THD *thd); recalculate_activation_times(THD *thd);
@ -98,12 +98,12 @@ private:
const char *src_func, const char *src_file, uint src_line); const char *src_func, const char *src_file, uint src_line);
void void
find_n_remove_event(LEX_STRING db, LEX_STRING name); find_n_remove_event(const LEX_CSTRING *db, const LEX_CSTRING *name);
void void
drop_matching_events(THD *thd, LEX_STRING pattern, drop_matching_events(THD *thd, const LEX_CSTRING *pattern,
bool (*)(LEX_STRING, Event_basic *)); bool (*)(const LEX_CSTRING*, Event_basic *));
void void

View File

@ -301,7 +301,7 @@ Event_worker_thread::run(THD *thd, Event_queue_element_for_exec *event)
if (res) if (res)
goto end; goto end;
if ((res= db_repository->load_named_event(thd, event->dbname, event->name, if ((res= db_repository->load_named_event(thd, &event->dbname, &event->name,
&job_data))) &job_data)))
{ {
DBUG_PRINT("error", ("Got error from load_named_event")); DBUG_PRINT("error", ("Got error from load_named_event"));

View File

@ -99,10 +99,11 @@ ulong Events::inited;
1 s > t 1 s > t
*/ */
int sortcmp_lex_string(LEX_STRING s, LEX_STRING t, CHARSET_INFO *cs) int sortcmp_lex_string(const LEX_CSTRING *s, const LEX_CSTRING *t,
const CHARSET_INFO *cs)
{ {
return cs->coll->strnncollsp(cs, (uchar *) s.str,s.length, return cs->coll->strnncollsp(cs, (uchar *) s->str, s->length,
(uchar *) t.str,t.length); (uchar *) t->str, t->length);
} }
@ -352,7 +353,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data)
save_binlog_format= thd->set_current_stmt_binlog_format_stmt(); save_binlog_format= thd->set_current_stmt_binlog_format_stmt();
if (thd->lex->create_info.or_replace() && event_queue) if (thd->lex->create_info.or_replace() && event_queue)
event_queue->drop_event(thd, parse_data->dbname, parse_data->name); event_queue->drop_event(thd, &parse_data->dbname, &parse_data->name);
/* On error conditions my_error() is called so no need to handle here */ /* On error conditions my_error() is called so no need to handle here */
if (!(ret= db_repository->create_event(thd, parse_data, if (!(ret= db_repository->create_event(thd, parse_data,
@ -365,12 +366,12 @@ Events::create_event(THD *thd, Event_parse_data *parse_data)
{ {
if (!(new_element= new Event_queue_element())) if (!(new_element= new Event_queue_element()))
ret= TRUE; // OOM ret= TRUE; // OOM
else if ((ret= db_repository->load_named_event(thd, parse_data->dbname, else if ((ret= db_repository->load_named_event(thd, &parse_data->dbname,
parse_data->name, &parse_data->name,
new_element))) new_element)))
{ {
if (!db_repository->drop_event(thd, parse_data->dbname, if (!db_repository->drop_event(thd, &parse_data->dbname,
parse_data->name, TRUE)) &parse_data->name, TRUE))
dropped= 1; dropped= 1;
delete new_element; delete new_element;
} }
@ -438,7 +439,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data)
bool bool
Events::update_event(THD *thd, Event_parse_data *parse_data, Events::update_event(THD *thd, Event_parse_data *parse_data,
LEX_STRING *new_dbname, LEX_STRING *new_name) LEX_CSTRING *new_dbname, LEX_CSTRING *new_name)
{ {
int ret; int ret;
enum_binlog_format save_binlog_format; enum_binlog_format save_binlog_format;
@ -468,9 +469,9 @@ Events::update_event(THD *thd, Event_parse_data *parse_data,
if (new_dbname) /* It's a rename */ if (new_dbname) /* It's a rename */
{ {
/* Check that the new and the old names differ. */ /* Check that the new and the old names differ. */
if ( !sortcmp_lex_string(parse_data->dbname, *new_dbname, if ( !sortcmp_lex_string(&parse_data->dbname, new_dbname,
system_charset_info) && system_charset_info) &&
!sortcmp_lex_string(parse_data->name, *new_name, !sortcmp_lex_string(&parse_data->name, new_name,
system_charset_info)) system_charset_info))
{ {
my_error(ER_EVENT_SAME_NAME, MYF(0)); my_error(ER_EVENT_SAME_NAME, MYF(0));
@ -511,12 +512,12 @@ Events::update_event(THD *thd, Event_parse_data *parse_data,
if (!(ret= db_repository->update_event(thd, parse_data, if (!(ret= db_repository->update_event(thd, parse_data,
new_dbname, new_name))) new_dbname, new_name)))
{ {
LEX_STRING dbname= new_dbname ? *new_dbname : parse_data->dbname; LEX_CSTRING dbname= new_dbname ? *new_dbname : parse_data->dbname;
LEX_STRING name= new_name ? *new_name : parse_data->name; LEX_CSTRING name= new_name ? *new_name : parse_data->name;
if (!(new_element= new Event_queue_element())) if (!(new_element= new Event_queue_element()))
ret= TRUE; // OOM ret= TRUE; // OOM
else if ((ret= db_repository->load_named_event(thd, dbname, name, else if ((ret= db_repository->load_named_event(thd, &dbname, &name,
new_element))) new_element)))
delete new_element; delete new_element;
else else
@ -528,7 +529,7 @@ Events::update_event(THD *thd, Event_parse_data *parse_data,
it right away. it right away.
*/ */
if (event_queue) if (event_queue)
event_queue->update_event(thd, parse_data->dbname, parse_data->name, event_queue->update_event(thd, &parse_data->dbname, &parse_data->name,
new_element); new_element);
/* Binlog the alter event. */ /* Binlog the alter event. */
DBUG_ASSERT(thd->query() && thd->query_length()); DBUG_ASSERT(thd->query() && thd->query_length());
@ -566,7 +567,8 @@ Events::update_event(THD *thd, Event_parse_data *parse_data,
*/ */
bool bool
Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists) Events::drop_event(THD *thd, const LEX_CSTRING *dbname,
const LEX_CSTRING *name, bool if_exists)
{ {
int ret; int ret;
enum_binlog_format save_binlog_format; enum_binlog_format save_binlog_format;
@ -575,7 +577,7 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists)
if (check_if_system_tables_error()) if (check_if_system_tables_error())
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
if (check_access(thd, EVENT_ACL, dbname.str, NULL, NULL, 0, 0)) if (check_access(thd, EVENT_ACL, dbname->str, NULL, NULL, 0, 0))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
/* /*
@ -585,7 +587,7 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists)
save_binlog_format= thd->set_current_stmt_binlog_format_stmt(); save_binlog_format= thd->set_current_stmt_binlog_format_stmt();
if (lock_object_name(thd, MDL_key::EVENT, if (lock_object_name(thd, MDL_key::EVENT,
dbname.str, name.str)) dbname->str, name->str))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
/* On error conditions my_error() is called so no need to handle here */ /* On error conditions my_error() is called so no need to handle here */
if (!(ret= db_repository->drop_event(thd, dbname, name, if_exists))) if (!(ret= db_repository->drop_event(thd, dbname, name, if_exists)))
@ -614,9 +616,9 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists)
*/ */
void void
Events::drop_schema_events(THD *thd, char *db) Events::drop_schema_events(THD *thd, const char *db)
{ {
LEX_STRING const db_lex= { db, strlen(db) }; const LEX_CSTRING db_lex= { db, strlen(db) };
DBUG_ENTER("Events::drop_schema_events"); DBUG_ENTER("Events::drop_schema_events");
DBUG_PRINT("enter", ("dropping events from %s", db)); DBUG_PRINT("enter", ("dropping events from %s", db));
@ -628,8 +630,8 @@ Events::drop_schema_events(THD *thd, char *db)
are damaged, as intended. are damaged, as intended.
*/ */
if (event_queue) if (event_queue)
event_queue->drop_schema_events(thd, db_lex); event_queue->drop_schema_events(thd, &db_lex);
db_repository->drop_schema_events(thd, db_lex); db_repository->drop_schema_events(thd, &db_lex);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -646,7 +648,7 @@ send_show_create_event(THD *thd, Event_timed *et, Protocol *protocol)
char show_str_buf[10 * STRING_BUFFER_USUAL_SIZE]; char show_str_buf[10 * STRING_BUFFER_USUAL_SIZE];
String show_str(show_str_buf, sizeof(show_str_buf), system_charset_info); String show_str(show_str_buf, sizeof(show_str_buf), system_charset_info);
List<Item> field_list; List<Item> field_list;
LEX_STRING sql_mode; LEX_CSTRING sql_mode;
const String *tz_name; const String *tz_name;
MEM_ROOT *mem_root= thd->mem_root; MEM_ROOT *mem_root= thd->mem_root;
DBUG_ENTER("send_show_create_event"); DBUG_ENTER("send_show_create_event");
@ -729,18 +731,19 @@ send_show_create_event(THD *thd, Event_timed *et, Protocol *protocol)
*/ */
bool bool
Events::show_create_event(THD *thd, LEX_STRING dbname, LEX_STRING name) Events::show_create_event(THD *thd, const LEX_CSTRING *dbname,
const LEX_CSTRING *name)
{ {
Event_timed et; Event_timed et;
bool ret; bool ret;
DBUG_ENTER("Events::show_create_event"); DBUG_ENTER("Events::show_create_event");
DBUG_PRINT("enter", ("name: %s@%s", dbname.str, name.str)); DBUG_PRINT("enter", ("name: %s@%s", dbname->str, name->str));
if (check_if_system_tables_error()) if (check_if_system_tables_error())
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
if (check_access(thd, EVENT_ACL, dbname.str, NULL, NULL, 0, 0)) if (check_access(thd, EVENT_ACL, dbname->str, NULL, NULL, 0, 0))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
/* /*
@ -781,8 +784,9 @@ Events::show_create_event(THD *thd, LEX_STRING dbname, LEX_STRING name)
int int
Events::fill_schema_events(THD *thd, TABLE_LIST *tables, COND * /* cond */) Events::fill_schema_events(THD *thd, TABLE_LIST *tables, COND * /* cond */)
{ {
char *db= NULL; const char *db= NULL;
int ret; int ret;
char db_tmp[SAFE_NAME_LEN];
DBUG_ENTER("Events::fill_schema_events"); DBUG_ENTER("Events::fill_schema_events");
/* /*
@ -806,10 +810,7 @@ Events::fill_schema_events(THD *thd, TABLE_LIST *tables, COND * /* cond */)
check_access(thd, EVENT_ACL, thd->lex->select_lex.db, check_access(thd, EVENT_ACL, thd->lex->select_lex.db,
NULL, NULL, 0, 0)) NULL, NULL, 0, 0))
DBUG_RETURN(1); DBUG_RETURN(1);
db= thd->lex->select_lex.db; db= normalize_db_name(thd->lex->select_lex.db, db_tmp, sizeof(db_tmp));
if (lower_case_table_names)
my_casedn_str(system_charset_info, db);
} }
ret= db_repository->fill_schema_events(thd, tables, db); ret= db_repository->fill_schema_events(thd, tables, db);

View File

@ -36,7 +36,7 @@ extern PSI_stage_info stage_waiting_on_empty_queue;
extern PSI_stage_info stage_waiting_for_next_activation; extern PSI_stage_info stage_waiting_for_next_activation;
extern PSI_stage_info stage_waiting_for_scheduler_to_stop; extern PSI_stage_info stage_waiting_for_scheduler_to_stop;
#include "sql_string.h" /* LEX_STRING */ #include "sql_string.h" /* LEX_CSTRING */
#include "my_time.h" /* interval_type */ #include "my_time.h" /* interval_type */
class Event_db_repository; class Event_db_repository;
@ -48,7 +48,8 @@ class THD;
typedef class Item COND; typedef class Item COND;
int int
sortcmp_lex_string(LEX_STRING s, LEX_STRING t, CHARSET_INFO *cs); sortcmp_lex_string(const LEX_CSTRING *s, const LEX_CSTRING *t,
const CHARSET_INFO *cs);
/** /**
@brief A facade to the functionality of the Event Scheduler. @brief A facade to the functionality of the Event Scheduler.
@ -109,16 +110,18 @@ public:
static bool static bool
update_event(THD *thd, Event_parse_data *parse_data, update_event(THD *thd, Event_parse_data *parse_data,
LEX_STRING *new_dbname, LEX_STRING *new_name); LEX_CSTRING *new_dbname, LEX_CSTRING *new_name);
static bool static bool
drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists); drop_event(THD *thd, const LEX_CSTRING *dbname, const LEX_CSTRING *name,
bool if_exists);
static void static void
drop_schema_events(THD *thd, char *db); drop_schema_events(THD *thd, const char *db);
static bool static bool
show_create_event(THD *thd, LEX_STRING dbname, LEX_STRING name); show_create_event(THD *thd, const LEX_CSTRING *dbname,
const LEX_CSTRING *name);
/* Needed for both SHOW CREATE EVENT and INFORMATION_SCHEMA */ /* Needed for both SHOW CREATE EVENT and INFORMATION_SCHEMA */
static int static int

View File

@ -51,6 +51,7 @@
*****************************************************************************/ *****************************************************************************/
static const char *zero_timestamp="0000-00-00 00:00:00.000000"; static const char *zero_timestamp="0000-00-00 00:00:00.000000";
LEX_CSTRING temp_lex_str= {"temp", 4};
/* number of bytes to store second_part part of the TIMESTAMP(N) */ /* number of bytes to store second_part part of the TIMESTAMP(N) */
static uint sec_part_bytes[MAX_DATETIME_PRECISION+1]= { 0, 1, 1, 2, 2, 3, 3 }; static uint sec_part_bytes[MAX_DATETIME_PRECISION+1]= { 0, 1, 1, 2, 2, 3, 3 };
@ -1297,7 +1298,7 @@ warn:
*/ */
Field_num::Field_num(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg, Field_num::Field_num(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg, uchar null_bit_arg, utype unireg_check_arg,
const char *field_name_arg, const LEX_CSTRING *field_name_arg,
uint8 dec_arg, bool zero_arg, bool unsigned_arg) uint8 dec_arg, bool zero_arg, bool unsigned_arg)
:Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, :Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg), unireg_check_arg, field_name_arg),
@ -1627,9 +1628,9 @@ String *Field::val_int_as_str(String *val_buffer, bool unsigned_val)
/// This is used as a table name when the table structure is not set up /// This is used as a table name when the table structure is not set up
Field::Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg, Field::Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,
uchar null_bit_arg, uchar null_bit_arg,
utype unireg_check_arg, const char *field_name_arg) utype unireg_check_arg, const LEX_CSTRING *field_name_arg)
:ptr(ptr_arg), null_ptr(null_ptr_arg), table(0), orig_table(0), :ptr(ptr_arg), null_ptr(null_ptr_arg), table(0), orig_table(0),
table_name(0), field_name(field_name_arg), option_list(0), table_name(0), field_name(*field_name_arg), option_list(0),
option_struct(0), key_start(0), part_of_key(0), option_struct(0), key_start(0), part_of_key(0),
part_of_key_not_clustered(0), part_of_sortkey(0), part_of_key_not_clustered(0), part_of_sortkey(0),
unireg_check(unireg_check_arg), field_length(length_arg), unireg_check(unireg_check_arg), field_length(length_arg),
@ -1888,7 +1889,7 @@ void Field::make_field(Send_field *field)
else else
{ {
field->table_name= ""; field->table_name= "";
field->org_col_name= ""; field->org_col_name= empty_clex_str;
} }
field->col_name= field_name; field->col_name= field_name;
field->length=field_length; field->length=field_length;
@ -1995,13 +1996,14 @@ bool Field_num::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate)
longlong nr= val_int(); longlong nr= val_int();
bool neg= !(flags & UNSIGNED_FLAG) && nr < 0; bool neg= !(flags & UNSIGNED_FLAG) && nr < 0;
return int_to_datetime_with_warn(neg, neg ? -nr : nr, ltime, fuzzydate, return int_to_datetime_with_warn(neg, neg ? -nr : nr, ltime, fuzzydate,
field_name); field_name.str);
} }
Field_str::Field_str(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg, Field_str::Field_str(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg, uchar null_bit_arg, utype unireg_check_arg,
const char *field_name_arg, CHARSET_INFO *charset_arg) const LEX_CSTRING *field_name_arg,
CHARSET_INFO *charset_arg)
:Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, :Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg) unireg_check_arg, field_name_arg)
{ {
@ -2896,7 +2898,7 @@ Field_new_decimal::Field_new_decimal(uchar *ptr_arg,
uint32 len_arg, uchar *null_ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, uchar null_bit_arg,
enum utype unireg_check_arg, enum utype unireg_check_arg,
const char *field_name_arg, const LEX_CSTRING *field_name_arg,
uint8 dec_arg,bool zero_arg, uint8 dec_arg,bool zero_arg,
bool unsigned_arg) bool unsigned_arg)
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
@ -2912,7 +2914,7 @@ Field_new_decimal::Field_new_decimal(uchar *ptr_arg,
Field_new_decimal::Field_new_decimal(uint32 len_arg, Field_new_decimal::Field_new_decimal(uint32 len_arg,
bool maybe_null_arg, bool maybe_null_arg,
const char *name, const LEX_CSTRING *name,
uint8 dec_arg, uint8 dec_arg,
bool unsigned_arg) bool unsigned_arg)
:Field_num((uchar*) 0, len_arg, :Field_num((uchar*) 0, len_arg,
@ -2932,7 +2934,6 @@ Field *Field_new_decimal::create_from_item(MEM_ROOT *mem_root, Item *item)
uint8 dec= item->decimals; uint8 dec= item->decimals;
uint8 intg= item->decimal_precision() - dec; uint8 intg= item->decimal_precision() - dec;
uint32 len= item->max_char_length(); uint32 len= item->max_char_length();
DBUG_ASSERT (item->result_type() == DECIMAL_RESULT); DBUG_ASSERT (item->result_type() == DECIMAL_RESULT);
/* /*
@ -2967,7 +2968,7 @@ Field *Field_new_decimal::create_from_item(MEM_ROOT *mem_root, Item *item)
len= required_length; len= required_length;
} }
return new (mem_root) return new (mem_root)
Field_new_decimal(len, item->maybe_null, item->name, Field_new_decimal(len, item->maybe_null, &item->name,
dec, item->unsigned_flag); dec, item->unsigned_flag);
} }
@ -3272,7 +3273,7 @@ bool Field_new_decimal::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate)
{ {
my_decimal value; my_decimal value;
return decimal_to_datetime_with_warn(val_decimal(&value), return decimal_to_datetime_with_warn(val_decimal(&value),
ltime, fuzzydate, field_name); ltime, fuzzydate, field_name.str);
} }
@ -3442,7 +3443,8 @@ Item *Field_new_decimal::get_equal_const_item(THD *thd, const Context &ctx,
Field_time::get_equal_const_item(). Field_time::get_equal_const_item().
*/ */
my_decimal_round(E_DEC_FATAL_ERROR, val, decimals(), true, &val_buffer2); my_decimal_round(E_DEC_FATAL_ERROR, val, decimals(), true, &val_buffer2);
return new (thd->mem_root) Item_decimal(thd, field_name, &val_buffer2, return new (thd->mem_root) Item_decimal(thd, field_name.str,
&val_buffer2,
decimals(), field_length); decimals(), field_length);
} }
break; break;
@ -4734,7 +4736,7 @@ bool Field_real::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate)
{ {
ASSERT_COLUMN_MARKED_FOR_READ; ASSERT_COLUMN_MARKED_FOR_READ;
double nr= val_real(); double nr= val_real();
return double_to_datetime_with_warn(nr, ltime, fuzzydate, field_name); return double_to_datetime_with_warn(nr, ltime, fuzzydate, field_name.str);
} }
@ -4889,7 +4891,7 @@ void Field_double::sql_type(String &res) const
Field_timestamp::Field_timestamp(uchar *ptr_arg, uint32 len_arg, Field_timestamp::Field_timestamp(uchar *ptr_arg, uint32 len_arg,
uchar *null_ptr_arg, uchar null_bit_arg, uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg, enum utype unireg_check_arg,
const char *field_name_arg, const LEX_CSTRING *field_name_arg,
TABLE_SHARE *share) TABLE_SHARE *share)
:Field_temporal(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, :Field_temporal(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg) unireg_check_arg, field_name_arg)
@ -5849,7 +5851,7 @@ bool Field_time::check_zero_in_date_with_warn(ulonglong fuzzydate)
THD *thd= get_thd(); THD *thd= get_thd();
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WARN_DATA_OUT_OF_RANGE, ER_WARN_DATA_OUT_OF_RANGE,
ER_THD(thd, ER_WARN_DATA_OUT_OF_RANGE), field_name, ER_THD(thd, ER_WARN_DATA_OUT_OF_RANGE), field_name.str,
thd->get_stmt_da()->current_row_for_warning()); thd->get_stmt_da()->current_row_for_warning());
return true; return true;
} }
@ -6230,7 +6232,7 @@ bool Field_year::get_date(MYSQL_TIME *ltime,ulonglong fuzzydate)
if (tmp || field_length != 4) if (tmp || field_length != 4)
tmp+= 1900; tmp+= 1900;
return int_to_datetime_with_warn(false, tmp * 10000, return int_to_datetime_with_warn(false, tmp * 10000,
ltime, fuzzydate, field_name); ltime, fuzzydate, field_name.str);
} }
@ -7086,7 +7088,7 @@ check_field_for_37426(const void *param_arg)
Check_field_param *param= (Check_field_param*) param_arg; Check_field_param *param= (Check_field_param*) param_arg;
DBUG_ASSERT(param->field->real_type() == MYSQL_TYPE_STRING); DBUG_ASSERT(param->field->real_type() == MYSQL_TYPE_STRING);
DBUG_PRINT("debug", ("Field %s - type: %d, size: %d", DBUG_PRINT("debug", ("Field %s - type: %d, size: %d",
param->field->field_name, param->field->field_name.str,
param->field->real_type(), param->field->real_type(),
param->field->row_pack_length())); param->field->row_pack_length()));
return param->field->row_pack_length() > 255; return param->field->row_pack_length() > 255;
@ -7168,7 +7170,8 @@ uchar *Field_string::pack(uchar *to, const uchar *from, uint max_length)
{ {
uint length= MY_MIN(field_length,max_length); uint length= MY_MIN(field_length,max_length);
uint local_char_length= max_length/field_charset->mbmaxlen; uint local_char_length= max_length/field_charset->mbmaxlen;
DBUG_PRINT("debug", ("Packing field '%s' - length: %u ", field_name, length)); DBUG_PRINT("debug", ("Packing field '%s' - length: %u ", field_name.str,
length));
if (length > local_char_length) if (length > local_char_length)
local_char_length= my_charpos(field_charset, from, from+length, local_char_length= my_charpos(field_charset, from, from+length,
@ -7340,7 +7343,7 @@ Field *Field_string::make_new_field(MEM_ROOT *root, TABLE *new_table,
if (type() != MYSQL_TYPE_VAR_STRING || keep_type) if (type() != MYSQL_TYPE_VAR_STRING || keep_type)
field= Field::make_new_field(root, new_table, keep_type); field= Field::make_new_field(root, new_table, keep_type);
else if ((field= new (root) Field_varstring(field_length, maybe_null(), else if ((field= new (root) Field_varstring(field_length, maybe_null(),
field_name, &field_name,
new_table->s, charset()))) new_table->s, charset())))
{ {
/* /*
@ -7811,7 +7814,8 @@ void Field_varstring::hash(ulong *nr, ulong *nr2)
****************************************************************************/ ****************************************************************************/
Field_blob::Field_blob(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, Field_blob::Field_blob(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg,
const LEX_CSTRING *field_name_arg,
TABLE_SHARE *share, uint blob_pack_length, TABLE_SHARE *share, uint blob_pack_length,
CHARSET_INFO *cs) CHARSET_INFO *cs)
:Field_longstr(ptr_arg, BLOB_PACK_LENGTH_TO_MAX_LENGH(blob_pack_length), :Field_longstr(ptr_arg, BLOB_PACK_LENGTH_TO_MAX_LENGH(blob_pack_length),
@ -8165,8 +8169,10 @@ Field *Field_blob::new_key_field(MEM_ROOT *root, TABLE *new_table,
uchar *new_null_ptr, uint new_null_bit) uchar *new_null_ptr, uint new_null_bit)
{ {
Field_varstring *res= new (root) Field_varstring(new_ptr, length, 2, Field_varstring *res= new (root) Field_varstring(new_ptr, length, 2,
new_null_ptr, new_null_bit, Field::NONE, new_null_ptr,
field_name, table->s, charset()); new_null_bit, Field::NONE,
&field_name,
table->s, charset());
res->init(new_table); res->init(new_table);
return res; return res;
} }
@ -8517,7 +8523,7 @@ int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs)
my_error(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD, MYF(0), my_error(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD, MYF(0),
Geometry::ci_collection[geom_type]->m_name.str, Geometry::ci_collection[geom_type]->m_name.str,
Geometry::ci_collection[wkb_type]->m_name.str, Geometry::ci_collection[wkb_type]->m_name.str,
field_name, field_name.str,
(ulong) table->in_use->get_stmt_da()-> (ulong) table->in_use->get_stmt_da()->
current_row_for_warning()); current_row_for_warning());
goto err_exit; goto err_exit;
@ -9104,7 +9110,8 @@ bool Field_enum::can_optimize_keypart_ref(const Item_bool_func *cond,
Field_bit::Field_bit(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, Field_bit::Field_bit(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, uchar *bit_ptr_arg, uchar bit_ofs_arg, uchar null_bit_arg, uchar *bit_ptr_arg, uchar bit_ofs_arg,
enum utype unireg_check_arg, const char *field_name_arg) enum utype unireg_check_arg,
const LEX_CSTRING *field_name_arg)
: Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, : Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg), unireg_check_arg, field_name_arg),
bit_ptr(bit_ptr_arg), bit_ofs(bit_ofs_arg), bit_len(len_arg & 7), bit_ptr(bit_ptr_arg), bit_ofs(bit_ofs_arg), bit_len(len_arg & 7),
@ -9619,7 +9626,7 @@ void Field_bit::set_default()
Field_bit_as_char::Field_bit_as_char(uchar *ptr_arg, uint32 len_arg, Field_bit_as_char::Field_bit_as_char(uchar *ptr_arg, uint32 len_arg,
uchar *null_ptr_arg, uchar null_bit_arg, uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg, enum utype unireg_check_arg,
const char *field_name_arg) const LEX_CSTRING *field_name_arg)
:Field_bit(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, 0, 0, :Field_bit(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, 0, 0,
unireg_check_arg, field_name_arg) unireg_check_arg, field_name_arg)
{ {
@ -9880,7 +9887,7 @@ void Column_definition::create_length_to_internal_length(void)
} }
bool check_expression(Virtual_column_info *vcol, const char *name, bool check_expression(Virtual_column_info *vcol, LEX_CSTRING *name,
enum_vcol_info_type type) enum_vcol_info_type type)
{ {
@ -9888,7 +9895,7 @@ bool check_expression(Virtual_column_info *vcol, const char *name,
Item::vcol_func_processor_result res; Item::vcol_func_processor_result res;
if (!vcol->name.length) if (!vcol->name.length)
vcol->name.str= const_cast<char*>(name); vcol->name= *name;
/* /*
Walk through the Item tree checking if all items are valid Walk through the Item tree checking if all items are valid
@ -9905,7 +9912,7 @@ bool check_expression(Virtual_column_info *vcol, const char *name,
if (ret || (res.errors & filter)) if (ret || (res.errors & filter))
{ {
my_error(ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED, MYF(0), res.name, my_error(ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED, MYF(0), res.name,
vcol_type_name(type), name); vcol_type_name(type), name->str);
return TRUE; return TRUE;
} }
/* /*
@ -9930,19 +9937,19 @@ bool Column_definition::check(THD *thd)
{ {
DBUG_ASSERT(vcol_info->expr); DBUG_ASSERT(vcol_info->expr);
vcol_info->set_field_type(sql_type); vcol_info->set_field_type(sql_type);
if (check_expression(vcol_info, field_name, vcol_info->stored_in_db if (check_expression(vcol_info, &field_name, vcol_info->stored_in_db
? VCOL_GENERATED_STORED : VCOL_GENERATED_VIRTUAL)) ? VCOL_GENERATED_STORED : VCOL_GENERATED_VIRTUAL))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
if (check_constraint && if (check_constraint &&
check_expression(check_constraint, field_name, VCOL_CHECK_FIELD)) check_expression(check_constraint, &field_name, VCOL_CHECK_FIELD))
DBUG_RETURN(1); DBUG_RETURN(1);
if (default_value) if (default_value)
{ {
Item *def_expr= default_value->expr; Item *def_expr= default_value->expr;
if (check_expression(default_value, field_name, VCOL_DEFAULT)) if (check_expression(default_value, &field_name, VCOL_DEFAULT))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
/* Constant's are stored in the 'empty_record', except for blobs */ /* Constant's are stored in the 'empty_record', except for blobs */
@ -9953,7 +9960,7 @@ bool Column_definition::check(THD *thd)
default_value= 0; default_value= 0;
if ((flags & (NOT_NULL_FLAG | AUTO_INCREMENT_FLAG)) == NOT_NULL_FLAG) if ((flags & (NOT_NULL_FLAG | AUTO_INCREMENT_FLAG)) == NOT_NULL_FLAG)
{ {
my_error(ER_INVALID_DEFAULT, MYF(0), field_name); my_error(ER_INVALID_DEFAULT, MYF(0), field_name.str);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
} }
@ -9962,7 +9969,7 @@ bool Column_definition::check(THD *thd)
if (default_value && (flags & AUTO_INCREMENT_FLAG)) if (default_value && (flags & AUTO_INCREMENT_FLAG))
{ {
my_error(ER_INVALID_DEFAULT, MYF(0), field_name); my_error(ER_INVALID_DEFAULT, MYF(0), field_name.str);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
@ -9988,7 +9995,7 @@ bool Column_definition::check(THD *thd)
if (mysql_type_to_time_type(sql_type) != MYSQL_TIMESTAMP_DATETIME || if (mysql_type_to_time_type(sql_type) != MYSQL_TIMESTAMP_DATETIME ||
on_update->decimals < length) on_update->decimals < length)
{ {
my_error(ER_INVALID_ON_UPDATE, MYF(0), field_name); my_error(ER_INVALID_ON_UPDATE, MYF(0), field_name.str);
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
unireg_check= unireg_check == Field::NONE ? Field::TIMESTAMP_UN_FIELD unireg_check= unireg_check == Field::NONE ? Field::TIMESTAMP_UN_FIELD
@ -10031,19 +10038,19 @@ bool Column_definition::check(THD *thd)
if (decimals >= NOT_FIXED_DEC) if (decimals >= NOT_FIXED_DEC)
{ {
my_error(ER_TOO_BIG_SCALE, MYF(0), static_cast<ulonglong>(decimals), my_error(ER_TOO_BIG_SCALE, MYF(0), static_cast<ulonglong>(decimals),
field_name, static_cast<ulong>(NOT_FIXED_DEC - 1)); field_name.str, static_cast<uint>(NOT_FIXED_DEC - 1));
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
my_decimal_trim(&length, &decimals); my_decimal_trim(&length, &decimals);
if (length > DECIMAL_MAX_PRECISION) if (length > DECIMAL_MAX_PRECISION)
{ {
my_error(ER_TOO_BIG_PRECISION, MYF(0), length, field_name, my_error(ER_TOO_BIG_PRECISION, MYF(0), length, field_name.str,
DECIMAL_MAX_PRECISION); DECIMAL_MAX_PRECISION);
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
if (length < decimals) if (length < decimals)
{ {
my_error(ER_M_BIGGER_THAN_D, MYF(0), field_name); my_error(ER_M_BIGGER_THAN_D, MYF(0), field_name.str);
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
length= length=
@ -10083,13 +10090,13 @@ bool Column_definition::check(THD *thd)
if (length < decimals && if (length < decimals &&
decimals != NOT_FIXED_DEC) decimals != NOT_FIXED_DEC)
{ {
my_error(ER_M_BIGGER_THAN_D, MYF(0), field_name); my_error(ER_M_BIGGER_THAN_D, MYF(0), field_name.str);
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
if (decimals != NOT_FIXED_DEC && decimals >= FLOATING_POINT_DECIMALS) if (decimals != NOT_FIXED_DEC && decimals >= FLOATING_POINT_DECIMALS)
{ {
my_error(ER_TOO_BIG_SCALE, MYF(0), static_cast<ulonglong>(decimals), my_error(ER_TOO_BIG_SCALE, MYF(0), static_cast<ulonglong>(decimals),
field_name, static_cast<ulong>(FLOATING_POINT_DECIMALS-1)); field_name.str, static_cast<uint>(FLOATING_POINT_DECIMALS-1));
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
break; break;
@ -10103,13 +10110,13 @@ bool Column_definition::check(THD *thd)
if (length < decimals && if (length < decimals &&
decimals != NOT_FIXED_DEC) decimals != NOT_FIXED_DEC)
{ {
my_error(ER_M_BIGGER_THAN_D, MYF(0), field_name); my_error(ER_M_BIGGER_THAN_D, MYF(0), field_name.str);
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
if (decimals != NOT_FIXED_DEC && decimals >= FLOATING_POINT_DECIMALS) if (decimals != NOT_FIXED_DEC && decimals >= FLOATING_POINT_DECIMALS)
{ {
my_error(ER_TOO_BIG_SCALE, MYF(0), static_cast<ulonglong>(decimals), my_error(ER_TOO_BIG_SCALE, MYF(0), static_cast<ulonglong>(decimals),
field_name, static_cast<ulong>(FLOATING_POINT_DECIMALS-1)); field_name.str, static_cast<uint>(FLOATING_POINT_DECIMALS-1));
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
break; break;
@ -10117,7 +10124,7 @@ bool Column_definition::check(THD *thd)
case MYSQL_TYPE_TIMESTAMP2: case MYSQL_TYPE_TIMESTAMP2:
if (length > MAX_DATETIME_PRECISION) if (length > MAX_DATETIME_PRECISION)
{ {
my_error(ER_TOO_BIG_PRECISION, MYF(0), length, field_name, my_error(ER_TOO_BIG_PRECISION, MYF(0), length, field_name.str,
MAX_DATETIME_PRECISION); MAX_DATETIME_PRECISION);
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
@ -10135,7 +10142,7 @@ bool Column_definition::check(THD *thd)
case MYSQL_TYPE_TIME2: case MYSQL_TYPE_TIME2:
if (length > MAX_DATETIME_PRECISION) if (length > MAX_DATETIME_PRECISION)
{ {
my_error(ER_TOO_BIG_PRECISION, MYF(0), length, field_name, my_error(ER_TOO_BIG_PRECISION, MYF(0), length, field_name.str,
MAX_DATETIME_PRECISION); MAX_DATETIME_PRECISION);
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
@ -10145,7 +10152,7 @@ bool Column_definition::check(THD *thd)
case MYSQL_TYPE_DATETIME2: case MYSQL_TYPE_DATETIME2:
if (length > MAX_DATETIME_PRECISION) if (length > MAX_DATETIME_PRECISION)
{ {
my_error(ER_TOO_BIG_PRECISION, MYF(0), length, field_name, my_error(ER_TOO_BIG_PRECISION, MYF(0), length, field_name.str,
MAX_DATETIME_PRECISION); MAX_DATETIME_PRECISION);
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
@ -10167,7 +10174,7 @@ bool Column_definition::check(THD *thd)
length= 1; length= 1;
if (length > MAX_BIT_FIELD_LENGTH) if (length > MAX_BIT_FIELD_LENGTH)
{ {
my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0), field_name, my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0), field_name.str,
static_cast<ulong>(MAX_BIT_FIELD_LENGTH)); static_cast<ulong>(MAX_BIT_FIELD_LENGTH));
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
@ -10213,18 +10220,19 @@ bool Column_definition::check(THD *thd)
sql_type == MYSQL_TYPE_STRING) ? ER_TOO_BIG_FIELDLENGTH : sql_type == MYSQL_TYPE_STRING) ? ER_TOO_BIG_FIELDLENGTH :
ER_TOO_BIG_DISPLAYWIDTH, ER_TOO_BIG_DISPLAYWIDTH,
MYF(0), MYF(0),
field_name, max_field_charlength); /* purecov: inspected */ field_name.str, max_field_charlength); /* purecov: inspected */
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
else if (length > MAX_FIELD_BLOBLENGTH) else if (length > MAX_FIELD_BLOBLENGTH)
{ {
my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0), field_name, MAX_FIELD_BLOBLENGTH); my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0), field_name.str,
MAX_FIELD_BLOBLENGTH);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
if ((~allowed_type_modifier) & flags & conditional_type_modifiers) if ((~allowed_type_modifier) & flags & conditional_type_modifiers)
{ {
my_error(ER_WRONG_FIELD_SPEC, MYF(0), field_name); my_error(ER_WRONG_FIELD_SPEC, MYF(0), field_name.str);
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
@ -10327,7 +10335,7 @@ Field *make_field(TABLE_SHARE *share,
Field::geometry_type geom_type, uint srid, Field::geometry_type geom_type, uint srid,
Field::utype unireg_check, Field::utype unireg_check,
TYPELIB *interval, TYPELIB *interval,
const char *field_name) const LEX_CSTRING *field_name)
{ {
uchar *UNINIT_VAR(bit_ptr); uchar *UNINIT_VAR(bit_ptr);
uchar UNINIT_VAR(bit_offset); uchar UNINIT_VAR(bit_offset);
@ -10806,7 +10814,7 @@ Field::set_warning(Sql_condition::enum_warning_level level, uint code,
if (thd->count_cuted_fields) if (thd->count_cuted_fields)
{ {
thd->cuted_fields+= cut_increment; thd->cuted_fields+= cut_increment;
push_warning_printf(thd, level, code, ER_THD(thd, code), field_name, push_warning_printf(thd, level, code, ER_THD(thd, code), field_name.str,
thd->get_stmt_da()->current_row_for_warning()); thd->get_stmt_da()->current_row_for_warning());
return 0; return 0;
} }
@ -10839,7 +10847,7 @@ void Field::set_datetime_warning(Sql_condition::enum_warning_level level,
{ {
THD *thd= get_thd(); THD *thd= get_thd();
if (thd->really_abort_on_warning() && level >= Sql_condition::WARN_LEVEL_WARN) if (thd->really_abort_on_warning() && level >= Sql_condition::WARN_LEVEL_WARN)
make_truncated_value_warning(thd, level, str, ts_type, field_name); make_truncated_value_warning(thd, level, str, ts_type, field_name.str);
else else
set_warning(level, code, cuted_increment); set_warning(level, code, cuted_increment);
} }
@ -10852,7 +10860,7 @@ void Field::set_warning_truncated_wrong_value(const char *type_arg,
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_TRUNCATED_WRONG_VALUE_FOR_FIELD, ER_TRUNCATED_WRONG_VALUE_FOR_FIELD,
ER_THD(thd, ER_TRUNCATED_WRONG_VALUE_FOR_FIELD), ER_THD(thd, ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),
type_arg, value, field_name, type_arg, value, field_name.str,
static_cast<ulong>(thd->get_stmt_da()-> static_cast<ulong>(thd->get_stmt_da()->
current_row_for_warning())); current_row_for_warning()));
} }
@ -10921,7 +10929,7 @@ bool Field::validate_value_in_record_with_warn(THD *thd, const uchar *record)
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_INVALID_DEFAULT_VALUE_FOR_FIELD, ER_INVALID_DEFAULT_VALUE_FOR_FIELD,
ER_THD(thd, ER_INVALID_DEFAULT_VALUE_FOR_FIELD), ER_THD(thd, ER_INVALID_DEFAULT_VALUE_FOR_FIELD),
ErrConvString(&tmp).ptr(), field_name); ErrConvString(&tmp).ptr(), field_name.str);
} }
dbug_tmp_restore_column_map(table->read_set, old_map); dbug_tmp_restore_column_map(table->read_set, old_map);
return rc; return rc;
@ -10956,7 +10964,7 @@ bool Field::save_in_field_default_value(bool view_error_processing)
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_NO_DEFAULT_FOR_FIELD, ER_NO_DEFAULT_FOR_FIELD,
ER_THD(thd, ER_NO_DEFAULT_FOR_FIELD), ER_THD(thd, ER_NO_DEFAULT_FOR_FIELD),
field_name); field_name.str);
} }
return 1; return 1;
} }

View File

@ -608,7 +608,7 @@ public:
bool stored_in_db; bool stored_in_db;
bool utf8; /* Already in utf8 */ bool utf8; /* Already in utf8 */
Item *expr; Item *expr;
LEX_STRING name; /* Name of constraint */ LEX_CSTRING name; /* Name of constraint */
uint flags; uint flags;
Virtual_column_info() Virtual_column_info()
@ -686,12 +686,12 @@ public:
*/ */
TABLE *table; // Pointer for table TABLE *table; // Pointer for table
TABLE *orig_table; // Pointer to original table TABLE *orig_table; // Pointer to original table
const char * const *table_name; const char * const *table_name; // Pointer to alias in TABLE
const char *field_name; LEX_CSTRING field_name;
LEX_CSTRING comment;
/** reference to the list of options or NULL */ /** reference to the list of options or NULL */
engine_option_value *option_list; engine_option_value *option_list;
ha_field_option_struct *option_struct; /* structure with parsed options */ ha_field_option_struct *option_struct; /* structure with parsed options */
LEX_STRING comment;
/* Field is part of the following keys */ /* Field is part of the following keys */
key_map key_start, part_of_key, part_of_key_not_clustered; key_map key_start, part_of_key, part_of_key_not_clustered;
@ -780,7 +780,7 @@ public:
Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg, Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg, uchar null_bit_arg, utype unireg_check_arg,
const char *field_name_arg); const LEX_CSTRING *field_name_arg);
virtual ~Field() {} virtual ~Field() {}
DTCollation dtcollation() const DTCollation dtcollation() const
@ -824,6 +824,8 @@ public:
enum_check_fields check_level); enum_check_fields check_level);
int store(const LEX_STRING *ls, CHARSET_INFO *cs) int store(const LEX_STRING *ls, CHARSET_INFO *cs)
{ return store(ls->str, ls->length, cs); } { return store(ls->str, ls->length, cs); }
int store(const LEX_CSTRING *ls, CHARSET_INFO *cs)
{ return store(ls->str, ls->length, cs); }
virtual double val_real(void)=0; virtual double val_real(void)=0;
virtual longlong val_int(void)=0; virtual longlong val_int(void)=0;
virtual bool val_bool(void)= 0; virtual bool val_bool(void)= 0;
@ -1310,7 +1312,7 @@ protected:
{ {
return set_warning(Sql_condition::WARN_LEVEL_NOTE, code, cuted_increment); return set_warning(Sql_condition::WARN_LEVEL_NOTE, code, cuted_increment);
} }
void set_datetime_warning(Sql_condition::enum_warning_level, uint code, void set_datetime_warning(Sql_condition::enum_warning_level, uint code,
const ErrConv *str, timestamp_type ts_type, const ErrConv *str, timestamp_type ts_type,
int cuted_increment) const; int cuted_increment) const;
void set_datetime_warning(uint code, void set_datetime_warning(uint code,
@ -1526,7 +1528,7 @@ protected:
return to + size; return to + size;
} }
const uchar *unpack_int(uchar* to, const uchar *from, const uchar *unpack_int(uchar* to, const uchar *from,
const uchar *from_end, size_t size) const uchar *from_end, size_t size)
{ {
if (from + size > from_end) if (from + size > from_end)
@ -1585,7 +1587,7 @@ public:
bool zerofill,unsigned_flag; // Purify cannot handle bit fields bool zerofill,unsigned_flag; // Purify cannot handle bit fields
Field_num(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg, Field_num(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg, uchar null_bit_arg, utype unireg_check_arg,
const char *field_name_arg, const LEX_CSTRING *field_name_arg,
uint8 dec_arg, bool zero_arg, bool unsigned_arg); uint8 dec_arg, bool zero_arg, bool unsigned_arg);
enum Item_result result_type () const { return INT_RESULT; } enum Item_result result_type () const { return INT_RESULT; }
enum Derivation derivation(void) const { return DERIVATION_NUMERIC; } enum Derivation derivation(void) const { return DERIVATION_NUMERIC; }
@ -1649,7 +1651,7 @@ public:
const Item_equal *item_equal); const Item_equal *item_equal);
Field_str(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg, Field_str(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg, uchar null_bit_arg, utype unireg_check_arg,
const char *field_name_arg, CHARSET_INFO *charset); const LEX_CSTRING *field_name_arg, CHARSET_INFO *charset);
Item_result result_type () const { return STRING_RESULT; } Item_result result_type () const { return STRING_RESULT; }
uint decimals() const { return NOT_FIXED_DEC; } uint decimals() const { return NOT_FIXED_DEC; }
int save_in_field(Field *to) { return save_in_field_str(to); } int save_in_field(Field *to) { return save_in_field_str(to); }
@ -1717,7 +1719,7 @@ protected:
public: public:
Field_longstr(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, Field_longstr(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg, uchar null_bit_arg, utype unireg_check_arg,
const char *field_name_arg, CHARSET_INFO *charset_arg) const LEX_CSTRING *field_name_arg, CHARSET_INFO *charset_arg)
:Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg, :Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg,
field_name_arg, charset_arg) field_name_arg, charset_arg)
{} {}
@ -1752,7 +1754,7 @@ public:
Field_real(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, Field_real(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg, uchar null_bit_arg, utype unireg_check_arg,
const char *field_name_arg, const LEX_CSTRING *field_name_arg,
uint8 dec_arg, bool zero_arg, bool unsigned_arg) uint8 dec_arg, bool zero_arg, bool unsigned_arg)
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg, :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg,
field_name_arg, dec_arg, zero_arg, unsigned_arg), field_name_arg, dec_arg, zero_arg, unsigned_arg),
@ -1789,7 +1791,7 @@ class Field_decimal :public Field_real {
public: public:
Field_decimal(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, Field_decimal(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
uint8 dec_arg,bool zero_arg,bool unsigned_arg) uint8 dec_arg,bool zero_arg,bool unsigned_arg)
:Field_real(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, :Field_real(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, unireg_check_arg, field_name_arg,
@ -1837,10 +1839,11 @@ public:
*/ */
Field_new_decimal(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, Field_new_decimal(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg,
const LEX_CSTRING *field_name_arg,
uint8 dec_arg, bool zero_arg, bool unsigned_arg); uint8 dec_arg, bool zero_arg, bool unsigned_arg);
Field_new_decimal(uint32 len_arg, bool maybe_null_arg, Field_new_decimal(uint32 len_arg, bool maybe_null_arg,
const char *field_name_arg, uint8 dec_arg, const LEX_CSTRING *field_name_arg, uint8 dec_arg,
bool unsigned_arg); bool unsigned_arg);
enum_field_types type() const { return MYSQL_TYPE_NEWDECIMAL;} enum_field_types type() const { return MYSQL_TYPE_NEWDECIMAL;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; } enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
@ -1903,7 +1906,7 @@ class Field_tiny :public Field_num {
public: public:
Field_tiny(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, Field_tiny(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
bool zero_arg, bool unsigned_arg) bool zero_arg, bool unsigned_arg)
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, unireg_check_arg, field_name_arg,
@ -1947,13 +1950,14 @@ class Field_short :public Field_num {
public: public:
Field_short(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, Field_short(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
bool zero_arg, bool unsigned_arg) bool zero_arg, bool unsigned_arg)
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, unireg_check_arg, field_name_arg,
0, zero_arg,unsigned_arg) 0, zero_arg,unsigned_arg)
{} {}
Field_short(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg, Field_short(uint32 len_arg,bool maybe_null_arg,
const LEX_CSTRING *field_name_arg,
bool unsigned_arg) bool unsigned_arg)
:Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0, :Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg, 0, 0, unsigned_arg) NONE, field_name_arg, 0, 0, unsigned_arg)
@ -1987,7 +1991,7 @@ class Field_medium :public Field_num {
public: public:
Field_medium(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, Field_medium(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
bool zero_arg, bool unsigned_arg) bool zero_arg, bool unsigned_arg)
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, unireg_check_arg, field_name_arg,
@ -2021,13 +2025,14 @@ class Field_long :public Field_num {
public: public:
Field_long(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, Field_long(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
bool zero_arg, bool unsigned_arg) bool zero_arg, bool unsigned_arg)
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, unireg_check_arg, field_name_arg,
0, zero_arg,unsigned_arg) 0, zero_arg,unsigned_arg)
{} {}
Field_long(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg, Field_long(uint32 len_arg,bool maybe_null_arg,
const LEX_CSTRING *field_name_arg,
bool unsigned_arg) bool unsigned_arg)
:Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0, :Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg,0,0,unsigned_arg) NONE, field_name_arg,0,0,unsigned_arg)
@ -2066,15 +2071,15 @@ class Field_longlong :public Field_num {
public: public:
Field_longlong(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, Field_longlong(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
bool zero_arg, bool unsigned_arg) bool zero_arg, bool unsigned_arg)
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, :Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, unireg_check_arg, field_name_arg,
0, zero_arg,unsigned_arg) 0, zero_arg,unsigned_arg)
{} {}
Field_longlong(uint32 len_arg,bool maybe_null_arg, Field_longlong(uint32 len_arg,bool maybe_null_arg,
const char *field_name_arg, const LEX_CSTRING *field_name_arg,
bool unsigned_arg) bool unsigned_arg)
:Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0, :Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg,0,0,unsigned_arg) NONE, field_name_arg,0,0,unsigned_arg)
{} {}
@ -2115,7 +2120,7 @@ class Field_float :public Field_real {
public: public:
Field_float(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, Field_float(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
uint8 dec_arg,bool zero_arg,bool unsigned_arg) uint8 dec_arg,bool zero_arg,bool unsigned_arg)
:Field_real(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, :Field_real(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, unireg_check_arg, field_name_arg,
@ -2124,8 +2129,8 @@ public:
if (dec_arg >= FLOATING_POINT_DECIMALS) if (dec_arg >= FLOATING_POINT_DECIMALS)
dec_arg= NOT_FIXED_DEC; dec_arg= NOT_FIXED_DEC;
} }
Field_float(uint32 len_arg, bool maybe_null_arg, const char *field_name_arg, Field_float(uint32 len_arg, bool maybe_null_arg,
uint8 dec_arg) const LEX_CSTRING *field_name_arg, uint8 dec_arg)
:Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, (uint) 0, :Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, (uint) 0,
NONE, field_name_arg, dec_arg, 0, 0) NONE, field_name_arg, dec_arg, 0, 0)
{ {
@ -2156,7 +2161,7 @@ class Field_double :public Field_real {
public: public:
Field_double(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, Field_double(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
uint8 dec_arg,bool zero_arg,bool unsigned_arg) uint8 dec_arg,bool zero_arg,bool unsigned_arg)
:Field_real(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, :Field_real(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, unireg_check_arg, field_name_arg,
@ -2165,15 +2170,16 @@ public:
if (dec_arg >= FLOATING_POINT_DECIMALS) if (dec_arg >= FLOATING_POINT_DECIMALS)
dec_arg= NOT_FIXED_DEC; dec_arg= NOT_FIXED_DEC;
} }
Field_double(uint32 len_arg, bool maybe_null_arg, const char *field_name_arg, Field_double(uint32 len_arg, bool maybe_null_arg,
uint8 dec_arg) const LEX_CSTRING *field_name_arg, uint8 dec_arg)
:Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "" : 0, (uint) 0, :Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "" : 0, (uint) 0,
NONE, field_name_arg, dec_arg, 0, 0) NONE, field_name_arg, dec_arg, 0, 0)
{ {
if (dec_arg >= FLOATING_POINT_DECIMALS) if (dec_arg >= FLOATING_POINT_DECIMALS)
dec_arg= NOT_FIXED_DEC; dec_arg= NOT_FIXED_DEC;
} }
Field_double(uint32 len_arg, bool maybe_null_arg, const char *field_name_arg, Field_double(uint32 len_arg, bool maybe_null_arg,
const LEX_CSTRING *field_name_arg,
uint8 dec_arg, bool not_fixed_arg) uint8 dec_arg, bool not_fixed_arg)
:Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "" : 0, (uint) 0, :Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "" : 0, (uint) 0,
NONE, field_name_arg, dec_arg, 0, 0) NONE, field_name_arg, dec_arg, 0, 0)
@ -2214,7 +2220,7 @@ class Field_null :public Field_str {
static uchar null[1]; static uchar null[1];
public: public:
Field_null(uchar *ptr_arg, uint32 len_arg, Field_null(uchar *ptr_arg, uint32 len_arg,
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
CHARSET_INFO *cs) CHARSET_INFO *cs)
:Field_str(ptr_arg, len_arg, null, 1, :Field_str(ptr_arg, len_arg, null, 1,
unireg_check_arg, field_name_arg, cs) unireg_check_arg, field_name_arg, cs)
@ -2265,7 +2271,7 @@ protected:
public: public:
Field_temporal(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg, Field_temporal(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg, uchar null_bit_arg, utype unireg_check_arg,
const char *field_name_arg) const LEX_CSTRING *field_name_arg)
:Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg, :Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg,
field_name_arg) field_name_arg)
{ flags|= BINARY_FLAG; } { flags|= BINARY_FLAG; }
@ -2344,7 +2350,7 @@ public:
Field_temporal_with_date(uchar *ptr_arg, uint32 len_arg, Field_temporal_with_date(uchar *ptr_arg, uint32 len_arg,
uchar *null_ptr_arg, uchar null_bit_arg, uchar *null_ptr_arg, uchar null_bit_arg,
utype unireg_check_arg, utype unireg_check_arg,
const char *field_name_arg) const LEX_CSTRING *field_name_arg)
:Field_temporal(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, :Field_temporal(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg) unireg_check_arg, field_name_arg)
{} {}
@ -2364,7 +2370,8 @@ protected:
public: public:
Field_timestamp(uchar *ptr_arg, uint32 len_arg, Field_timestamp(uchar *ptr_arg, uint32 len_arg,
uchar *null_ptr_arg, uchar null_bit_arg, uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg,
const LEX_CSTRING *field_name_arg,
TABLE_SHARE *share); TABLE_SHARE *share);
enum_field_types type() const { return MYSQL_TYPE_TIMESTAMP;} enum_field_types type() const { return MYSQL_TYPE_TIMESTAMP;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; } enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
@ -2433,7 +2440,7 @@ public:
Field_timestamp_with_dec(uchar *ptr_arg, Field_timestamp_with_dec(uchar *ptr_arg,
uchar *null_ptr_arg, uchar null_bit_arg, uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg, enum utype unireg_check_arg,
const char *field_name_arg, const LEX_CSTRING *field_name_arg,
TABLE_SHARE *share, uint dec_arg) : TABLE_SHARE *share, uint dec_arg) :
Field_timestamp(ptr_arg, Field_timestamp(ptr_arg,
MAX_DATETIME_WIDTH + dec_arg + MY_TEST(dec_arg), null_ptr_arg, MAX_DATETIME_WIDTH + dec_arg + MY_TEST(dec_arg), null_ptr_arg,
@ -2467,7 +2474,7 @@ public:
Field_timestamp_hires(uchar *ptr_arg, Field_timestamp_hires(uchar *ptr_arg,
uchar *null_ptr_arg, uchar null_bit_arg, uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg, enum utype unireg_check_arg,
const char *field_name_arg, const LEX_CSTRING *field_name_arg,
TABLE_SHARE *share, uint dec_arg) : TABLE_SHARE *share, uint dec_arg) :
Field_timestamp_with_dec(ptr_arg, null_ptr_arg, null_bit_arg, Field_timestamp_with_dec(ptr_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, share, dec_arg) unireg_check_arg, field_name_arg, share, dec_arg)
@ -2495,7 +2502,7 @@ public:
Field_timestampf(uchar *ptr_arg, Field_timestampf(uchar *ptr_arg,
uchar *null_ptr_arg, uchar null_bit_arg, uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg, enum utype unireg_check_arg,
const char *field_name_arg, const LEX_CSTRING *field_name_arg,
TABLE_SHARE *share, uint dec_arg) : TABLE_SHARE *share, uint dec_arg) :
Field_timestamp_with_dec(ptr_arg, null_ptr_arg, null_bit_arg, Field_timestamp_with_dec(ptr_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, share, dec_arg) unireg_check_arg, field_name_arg, share, dec_arg)
@ -2527,7 +2534,7 @@ class Field_year :public Field_tiny {
public: public:
Field_year(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, Field_year(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg) enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg)
:Field_tiny(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, :Field_tiny(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, 1, 1) unireg_check_arg, field_name_arg, 1, 1)
{} {}
@ -2573,7 +2580,7 @@ class Field_date :public Field_temporal_with_date {
bool get_TIME(MYSQL_TIME *ltime, const uchar *pos, ulonglong fuzzydate) const; bool get_TIME(MYSQL_TIME *ltime, const uchar *pos, ulonglong fuzzydate) const;
public: public:
Field_date(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, Field_date(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg) enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg)
:Field_temporal_with_date(ptr_arg, MAX_DATE_WIDTH, null_ptr_arg, null_bit_arg, :Field_temporal_with_date(ptr_arg, MAX_DATE_WIDTH, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg) {} unireg_check_arg, field_name_arg) {}
enum_field_types type() const { return MYSQL_TYPE_DATE;} enum_field_types type() const { return MYSQL_TYPE_DATE;}
@ -2608,7 +2615,7 @@ class Field_newdate :public Field_temporal_with_date {
bool get_TIME(MYSQL_TIME *ltime, const uchar *pos, ulonglong fuzzydate) const; bool get_TIME(MYSQL_TIME *ltime, const uchar *pos, ulonglong fuzzydate) const;
public: public:
Field_newdate(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, Field_newdate(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg) enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg)
:Field_temporal_with_date(ptr_arg, MAX_DATE_WIDTH, null_ptr_arg, null_bit_arg, :Field_temporal_with_date(ptr_arg, MAX_DATE_WIDTH, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg) unireg_check_arg, field_name_arg)
{} {}
@ -2647,7 +2654,7 @@ protected:
public: public:
Field_time(uchar *ptr_arg, uint length_arg, uchar *null_ptr_arg, Field_time(uchar *ptr_arg, uint length_arg, uchar *null_ptr_arg,
uchar null_bit_arg, enum utype unireg_check_arg, uchar null_bit_arg, enum utype unireg_check_arg,
const char *field_name_arg) const LEX_CSTRING *field_name_arg)
:Field_temporal(ptr_arg, length_arg, null_ptr_arg, null_bit_arg, :Field_temporal(ptr_arg, length_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg), curdays(0) unireg_check_arg, field_name_arg), curdays(0)
{} {}
@ -2699,7 +2706,8 @@ protected:
uint dec; uint dec;
public: public:
Field_time_with_dec(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, Field_time_with_dec(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg,
const LEX_CSTRING *field_name_arg,
uint dec_arg) uint dec_arg)
:Field_time(ptr_arg, MIN_TIME_WIDTH + dec_arg + MY_TEST(dec_arg), :Field_time(ptr_arg, MIN_TIME_WIDTH + dec_arg + MY_TEST(dec_arg),
null_ptr_arg, null_bit_arg, unireg_check_arg, field_name_arg), null_ptr_arg, null_bit_arg, unireg_check_arg, field_name_arg),
@ -2723,7 +2731,7 @@ class Field_time_hires :public Field_time_with_dec {
void store_TIME(MYSQL_TIME *ltime); void store_TIME(MYSQL_TIME *ltime);
public: public:
Field_time_hires(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, Field_time_hires(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
uint dec_arg) uint dec_arg)
:Field_time_with_dec(ptr_arg, null_ptr_arg, :Field_time_with_dec(ptr_arg, null_ptr_arg,
null_bit_arg, unireg_check_arg, field_name_arg, null_bit_arg, unireg_check_arg, field_name_arg,
@ -2754,7 +2762,7 @@ class Field_timef :public Field_time_with_dec {
} }
public: public:
Field_timef(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, Field_timef(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
uint dec_arg) uint dec_arg)
:Field_time_with_dec(ptr_arg, null_ptr_arg, :Field_time_with_dec(ptr_arg, null_ptr_arg,
null_bit_arg, unireg_check_arg, field_name_arg, null_bit_arg, unireg_check_arg, field_name_arg,
@ -2796,7 +2804,7 @@ class Field_datetime :public Field_temporal_with_date {
public: public:
Field_datetime(uchar *ptr_arg, uint length_arg, uchar *null_ptr_arg, Field_datetime(uchar *ptr_arg, uint length_arg, uchar *null_ptr_arg,
uchar null_bit_arg, enum utype unireg_check_arg, uchar null_bit_arg, enum utype unireg_check_arg,
const char *field_name_arg) const LEX_CSTRING *field_name_arg)
:Field_temporal_with_date(ptr_arg, length_arg, null_ptr_arg, null_bit_arg, :Field_temporal_with_date(ptr_arg, length_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg) unireg_check_arg, field_name_arg)
{ {
@ -2853,7 +2861,7 @@ protected:
public: public:
Field_datetime_with_dec(uchar *ptr_arg, uchar *null_ptr_arg, Field_datetime_with_dec(uchar *ptr_arg, uchar *null_ptr_arg,
uchar null_bit_arg, enum utype unireg_check_arg, uchar null_bit_arg, enum utype unireg_check_arg,
const char *field_name_arg, uint dec_arg) const LEX_CSTRING *field_name_arg, uint dec_arg)
:Field_datetime(ptr_arg, MAX_DATETIME_WIDTH + dec_arg + MY_TEST(dec_arg), :Field_datetime(ptr_arg, MAX_DATETIME_WIDTH + dec_arg + MY_TEST(dec_arg),
null_ptr_arg, null_bit_arg, unireg_check_arg, null_ptr_arg, null_bit_arg, unireg_check_arg,
field_name_arg), dec(dec_arg) field_name_arg), dec(dec_arg)
@ -2889,7 +2897,7 @@ class Field_datetime_hires :public Field_datetime_with_dec {
public: public:
Field_datetime_hires(uchar *ptr_arg, uchar *null_ptr_arg, Field_datetime_hires(uchar *ptr_arg, uchar *null_ptr_arg,
uchar null_bit_arg, enum utype unireg_check_arg, uchar null_bit_arg, enum utype unireg_check_arg,
const char *field_name_arg, uint dec_arg) const LEX_CSTRING *field_name_arg, uint dec_arg)
:Field_datetime_with_dec(ptr_arg, null_ptr_arg, null_bit_arg, :Field_datetime_with_dec(ptr_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, dec_arg) unireg_check_arg, field_name_arg, dec_arg)
{ {
@ -2917,7 +2925,7 @@ class Field_datetimef :public Field_datetime_with_dec {
public: public:
Field_datetimef(uchar *ptr_arg, uchar *null_ptr_arg, Field_datetimef(uchar *ptr_arg, uchar *null_ptr_arg,
uchar null_bit_arg, enum utype unireg_check_arg, uchar null_bit_arg, enum utype unireg_check_arg,
const char *field_name_arg, uint dec_arg) const LEX_CSTRING *field_name_arg, uint dec_arg)
:Field_datetime_with_dec(ptr_arg, null_ptr_arg, null_bit_arg, :Field_datetime_with_dec(ptr_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, dec_arg) unireg_check_arg, field_name_arg, dec_arg)
{} {}
@ -2947,7 +2955,8 @@ public:
static inline Field_timestamp * static inline Field_timestamp *
new_Field_timestamp(MEM_ROOT *root,uchar *ptr, uchar *null_ptr, uchar null_bit, new_Field_timestamp(MEM_ROOT *root,uchar *ptr, uchar *null_ptr, uchar null_bit,
enum Field::utype unireg_check, const char *field_name, enum Field::utype unireg_check,
const LEX_CSTRING *field_name,
TABLE_SHARE *share, uint dec) TABLE_SHARE *share, uint dec)
{ {
if (dec==0) if (dec==0)
@ -2963,7 +2972,7 @@ new_Field_timestamp(MEM_ROOT *root,uchar *ptr, uchar *null_ptr, uchar null_bit,
static inline Field_time * static inline Field_time *
new_Field_time(MEM_ROOT *root, uchar *ptr, uchar *null_ptr, uchar null_bit, new_Field_time(MEM_ROOT *root, uchar *ptr, uchar *null_ptr, uchar null_bit,
enum Field::utype unireg_check, const char *field_name, enum Field::utype unireg_check, const LEX_CSTRING *field_name,
uint dec) uint dec)
{ {
if (dec == 0) if (dec == 0)
@ -2979,7 +2988,7 @@ new_Field_time(MEM_ROOT *root, uchar *ptr, uchar *null_ptr, uchar null_bit,
static inline Field_datetime * static inline Field_datetime *
new_Field_datetime(MEM_ROOT *root, uchar *ptr, uchar *null_ptr, uchar null_bit, new_Field_datetime(MEM_ROOT *root, uchar *ptr, uchar *null_ptr, uchar null_bit,
enum Field::utype unireg_check, enum Field::utype unireg_check,
const char *field_name, uint dec) const LEX_CSTRING *field_name, uint dec)
{ {
if (dec == 0) if (dec == 0)
return new (root) return new (root)
@ -3002,12 +3011,13 @@ public:
bool can_alter_field_type; bool can_alter_field_type;
Field_string(uchar *ptr_arg, uint32 len_arg,uchar *null_ptr_arg, Field_string(uchar *ptr_arg, uint32 len_arg,uchar *null_ptr_arg,
uchar null_bit_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
CHARSET_INFO *cs) CHARSET_INFO *cs)
:Field_longstr(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, :Field_longstr(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, cs), unireg_check_arg, field_name_arg, cs),
can_alter_field_type(1) {}; can_alter_field_type(1) {};
Field_string(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg, Field_string(uint32 len_arg,bool maybe_null_arg,
const LEX_CSTRING *field_name_arg,
CHARSET_INFO *cs) CHARSET_INFO *cs)
:Field_longstr((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, 0, :Field_longstr((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
NONE, field_name_arg, cs), NONE, field_name_arg, cs),
@ -3091,7 +3101,7 @@ public:
Field_varstring(uchar *ptr_arg, Field_varstring(uchar *ptr_arg,
uint32 len_arg, uint length_bytes_arg, uint32 len_arg, uint length_bytes_arg,
uchar *null_ptr_arg, uchar null_bit_arg, uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
TABLE_SHARE *share, CHARSET_INFO *cs) TABLE_SHARE *share, CHARSET_INFO *cs)
:Field_longstr(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, :Field_longstr(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, cs), unireg_check_arg, field_name_arg, cs),
@ -3100,7 +3110,7 @@ public:
share->varchar_fields++; share->varchar_fields++;
} }
Field_varstring(uint32 len_arg,bool maybe_null_arg, Field_varstring(uint32 len_arg,bool maybe_null_arg,
const char *field_name_arg, const LEX_CSTRING *field_name_arg,
TABLE_SHARE *share, CHARSET_INFO *cs) TABLE_SHARE *share, CHARSET_INFO *cs)
:Field_longstr((uchar*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0, 0, :Field_longstr((uchar*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
NONE, field_name_arg, cs), NONE, field_name_arg, cs),
@ -3168,6 +3178,8 @@ private:
}; };
extern LEX_CSTRING temp_lex_str;
class Field_blob :public Field_longstr { class Field_blob :public Field_longstr {
protected: protected:
/** /**
@ -3190,9 +3202,9 @@ protected:
static void do_conv_blob(Copy_field *copy); static void do_conv_blob(Copy_field *copy);
public: public:
Field_blob(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, Field_blob(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
TABLE_SHARE *share, uint blob_pack_length, CHARSET_INFO *cs); TABLE_SHARE *share, uint blob_pack_length, CHARSET_INFO *cs);
Field_blob(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg, Field_blob(uint32 len_arg,bool maybe_null_arg, const LEX_CSTRING *field_name_arg,
CHARSET_INFO *cs) CHARSET_INFO *cs)
:Field_longstr((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, 0, :Field_longstr((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
NONE, field_name_arg, cs), NONE, field_name_arg, cs),
@ -3200,7 +3212,8 @@ public:
{ {
flags|= BLOB_FLAG; flags|= BLOB_FLAG;
} }
Field_blob(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg, Field_blob(uint32 len_arg,bool maybe_null_arg,
const LEX_CSTRING *field_name_arg,
CHARSET_INFO *cs, bool set_packlength) CHARSET_INFO *cs, bool set_packlength)
:Field_longstr((uchar*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0, 0, :Field_longstr((uchar*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
NONE, field_name_arg, cs) NONE, field_name_arg, cs)
@ -3215,7 +3228,8 @@ public:
} }
} }
Field_blob(uint32 packlength_arg) Field_blob(uint32 packlength_arg)
:Field_longstr((uchar*) 0, 0, (uchar*) "", 0, NONE, "temp", system_charset_info), :Field_longstr((uchar*) 0, 0, (uchar*) "", 0, NONE, &temp_lex_str,
system_charset_info),
packlength(packlength_arg) {} packlength(packlength_arg) {}
/* Note that the default copy constructor is used, in clone() */ /* Note that the default copy constructor is used, in clone() */
enum_field_types type() const { return MYSQL_TYPE_BLOB;} enum_field_types type() const { return MYSQL_TYPE_BLOB;}
@ -3397,13 +3411,13 @@ public:
enum storage_type storage; enum storage_type storage;
Field_geom(uchar *ptr_arg, uchar *null_ptr_arg, uint null_bit_arg, Field_geom(uchar *ptr_arg, uchar *null_ptr_arg, uint null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
TABLE_SHARE *share, uint blob_pack_length, TABLE_SHARE *share, uint blob_pack_length,
enum geometry_type geom_type_arg, uint field_srid) enum geometry_type geom_type_arg, uint field_srid)
:Field_blob(ptr_arg, null_ptr_arg, null_bit_arg, unireg_check_arg, :Field_blob(ptr_arg, null_ptr_arg, null_bit_arg, unireg_check_arg,
field_name_arg, share, blob_pack_length, &my_charset_bin) field_name_arg, share, blob_pack_length, &my_charset_bin)
{ geom_type= geom_type_arg; srid= field_srid; } { geom_type= geom_type_arg; srid= field_srid; }
Field_geom(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg, Field_geom(uint32 len_arg,bool maybe_null_arg, const LEX_CSTRING *field_name_arg,
TABLE_SHARE *share, enum geometry_type geom_type_arg) TABLE_SHARE *share, enum geometry_type geom_type_arg)
:Field_blob(len_arg, maybe_null_arg, field_name_arg, &my_charset_bin) :Field_blob(len_arg, maybe_null_arg, field_name_arg, &my_charset_bin)
{ geom_type= geom_type_arg; srid= 0; } { geom_type= geom_type_arg; srid= 0; }
@ -3454,7 +3468,7 @@ public:
TYPELIB *typelib; TYPELIB *typelib;
Field_enum(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, Field_enum(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
uint packlength_arg, uint packlength_arg,
TYPELIB *typelib_arg, TYPELIB *typelib_arg,
CHARSET_INFO *charset_arg) CHARSET_INFO *charset_arg)
@ -3551,7 +3565,7 @@ class Field_set :public Field_enum {
public: public:
Field_set(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, Field_set(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg,
uint32 packlength_arg, uint32 packlength_arg,
TYPELIB *typelib_arg, CHARSET_INFO *charset_arg) TYPELIB *typelib_arg, CHARSET_INFO *charset_arg)
:Field_enum(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, :Field_enum(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
@ -3600,7 +3614,7 @@ public:
uint bytes_in_rec; uint bytes_in_rec;
Field_bit(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, Field_bit(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, uchar *bit_ptr_arg, uchar bit_ofs_arg, uchar null_bit_arg, uchar *bit_ptr_arg, uchar bit_ofs_arg,
enum utype unireg_check_arg, const char *field_name_arg); enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg);
enum_field_types type() const { return MYSQL_TYPE_BIT; } enum_field_types type() const { return MYSQL_TYPE_BIT; }
enum ha_base_keytype key_type() const { return HA_KEYTYPE_BIT; } enum ha_base_keytype key_type() const { return HA_KEYTYPE_BIT; }
uint32 key_length() const { return (uint32) (field_length + 7) / 8; } uint32 key_length() const { return (uint32) (field_length + 7) / 8; }
@ -3736,7 +3750,7 @@ class Field_bit_as_char: public Field_bit {
public: public:
Field_bit_as_char(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, Field_bit_as_char(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg); enum utype unireg_check_arg, const LEX_CSTRING *field_name_arg);
enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; } enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
uint size_of() const { return sizeof(*this); } uint size_of() const { return sizeof(*this); }
int store(const char *to, uint length, CHARSET_INFO *charset); int store(const char *to, uint length, CHARSET_INFO *charset);
@ -3747,8 +3761,7 @@ public:
}; };
extern const LEX_STRING null_lex_str; extern const LEX_CSTRING null_clex_str;
Field *make_field(TABLE_SHARE *share, MEM_ROOT *mem_root, Field *make_field(TABLE_SHARE *share, MEM_ROOT *mem_root,
uchar *ptr, uint32 field_length, uchar *ptr, uint32 field_length,
@ -3757,7 +3770,7 @@ Field *make_field(TABLE_SHARE *share, MEM_ROOT *mem_root,
CHARSET_INFO *cs, CHARSET_INFO *cs,
Field::geometry_type geom_type, uint srid, Field::geometry_type geom_type, uint srid,
Field::utype unireg_check, Field::utype unireg_check,
TYPELIB *interval, const char *field_name); TYPELIB *interval, const LEX_CSTRING *field_name);
/* /*
Create field class for CREATE TABLE Create field class for CREATE TABLE
@ -3803,8 +3816,8 @@ class Column_definition: public Sql_alloc
} }
} }
public: public:
const char *field_name; LEX_CSTRING field_name;
LEX_STRING comment; // Comment for field LEX_CSTRING comment; // Comment for field
Item *on_update; // ON UPDATE NOW() Item *on_update; // ON UPDATE NOW()
enum enum_field_types sql_type; enum enum_field_types sql_type;
/* /*
@ -3839,7 +3852,7 @@ public:
*check_constraint; // Check constraint *check_constraint; // Check constraint
Column_definition(): Column_definition():
comment(null_lex_str), comment(null_clex_str),
on_update(NULL), sql_type(MYSQL_TYPE_NULL), length(0), decimals(0), on_update(NULL), sql_type(MYSQL_TYPE_NULL), length(0), decimals(0),
flags(0), pack_length(0), key_length(0), unireg_check(Field::NONE), flags(0), pack_length(0), key_length(0), unireg_check(Field::NONE),
interval(0), charset(&my_charset_bin), interval(0), charset(&my_charset_bin),
@ -3850,9 +3863,9 @@ public:
interval_list.empty(); interval_list.empty();
} }
Column_definition(const char *name, enum_field_types type): Column_definition(LEX_CSTRING *name, enum_field_types type):
field_name(name), field_name(*name),
comment(null_lex_str), comment(null_clex_str),
on_update(NULL), sql_type(type), length(0), decimals(0), on_update(NULL), sql_type(type), length(0), decimals(0),
flags(0), pack_length(0), key_length(0), unireg_check(Field::NONE), flags(0), pack_length(0), key_length(0), unireg_check(Field::NONE),
interval(0), charset(&my_charset_bin), interval(0), charset(&my_charset_bin),
@ -3926,7 +3939,7 @@ public:
Field *make_field(TABLE_SHARE *share, MEM_ROOT *mem_root, Field *make_field(TABLE_SHARE *share, MEM_ROOT *mem_root,
uchar *ptr, uchar *null_pos, uchar null_bit, uchar *ptr, uchar *null_pos, uchar null_bit,
const char *field_name_arg) const const LEX_CSTRING *field_name_arg) const
{ {
return ::make_field(share, mem_root, ptr, return ::make_field(share, mem_root, ptr,
(uint32)length, null_pos, null_bit, (uint32)length, null_pos, null_bit,
@ -3935,7 +3948,7 @@ public:
field_name_arg); field_name_arg);
} }
Field *make_field(TABLE_SHARE *share, MEM_ROOT *mem_root, Field *make_field(TABLE_SHARE *share, MEM_ROOT *mem_root,
const char *field_name_arg) const LEX_CSTRING *field_name_arg)
{ {
return make_field(share, mem_root, (uchar *) 0, (uchar *) "", 0, return make_field(share, mem_root, (uchar *) 0, (uchar *) "", 0,
field_name_arg); field_name_arg);
@ -3964,7 +3977,7 @@ public:
class Row_definition_list: public List<class Spvar_definition> class Row_definition_list: public List<class Spvar_definition>
{ {
public: public:
inline bool eq_name(const Spvar_definition *def, const char *name) const; inline bool eq_name(const Spvar_definition *def, const LEX_CSTRING *name) const;
/** /**
Find a ROW field by name. Find a ROW field by name.
@param [IN] name - the name @param [IN] name - the name
@ -3972,7 +3985,7 @@ public:
@retval NULL - the ROW field was not found @retval NULL - the ROW field was not found
@retval !NULL - the pointer to the found ROW field @retval !NULL - the pointer to the found ROW field
*/ */
Spvar_definition *find_row_field_by_name(const char *name, uint *offset) const Spvar_definition *find_row_field_by_name(const LEX_CSTRING *name, uint *offset) const
{ {
// Cast-off the "const" qualifier // Cast-off the "const" qualifier
List_iterator<Spvar_definition> it(*((List<Spvar_definition>*)this)); List_iterator<Spvar_definition> it(*((List<Spvar_definition>*)this));
@ -4061,7 +4074,7 @@ public:
Find a ROW field by name. Find a ROW field by name.
See Row_field_list::find_row_field_by_name() for details. See Row_field_list::find_row_field_by_name() for details.
*/ */
Spvar_definition *find_row_field_by_name(const char *name, uint *offset) const Spvar_definition *find_row_field_by_name(const LEX_CSTRING *name, uint *offset) const
{ {
DBUG_ASSERT(m_row_field_definitions); DBUG_ASSERT(m_row_field_definitions);
return m_row_field_definitions->find_row_field_by_name(name, offset); return m_row_field_definitions->find_row_field_by_name(name, offset);
@ -4089,17 +4102,17 @@ public:
inline bool Row_definition_list::eq_name(const Spvar_definition *def, inline bool Row_definition_list::eq_name(const Spvar_definition *def,
const char *name) const const LEX_CSTRING *name) const
{ {
return my_strcasecmp(system_charset_info, def->field_name, name) == 0; return def->field_name.length == name->length && my_strcasecmp(system_charset_info, def->field_name.str, name->str) == 0;
} }
class Create_field :public Column_definition class Create_field :public Column_definition
{ {
public: public:
const char *change; // If done with alter table LEX_CSTRING change; // If done with alter table
const char *after; // Put column after this one LEX_CSTRING after; // Put column after this one
Field *field; // For alter table Field *field; // For alter table
TYPELIB *save_interval; // Temporary copy for the above TYPELIB *save_interval; // Temporary copy for the above
// Used only for UCS2 intervals // Used only for UCS2 intervals
@ -4111,16 +4124,20 @@ public:
bool create_if_not_exists; // Used in ALTER TABLE IF NOT EXISTS bool create_if_not_exists; // Used in ALTER TABLE IF NOT EXISTS
Create_field(): Create_field():
Column_definition(), change(0), after(0), Column_definition(),
field(0), option_struct(NULL), field(0), option_struct(NULL),
create_if_not_exists(false) create_if_not_exists(false)
{ } {
change= after= null_clex_str;
}
Create_field(THD *thd, Field *old_field, Field *orig_field): Create_field(THD *thd, Field *old_field, Field *orig_field):
Column_definition(thd, old_field, orig_field), Column_definition(thd, old_field, orig_field),
change(old_field->field_name), after(0), change(old_field->field_name),
field(old_field), option_struct(old_field->option_struct), field(old_field), option_struct(old_field->option_struct),
create_if_not_exists(false) create_if_not_exists(false)
{ } {
after= null_clex_str;
}
/* Used to make a clone of this object for ALTER/CREATE TABLE */ /* Used to make a clone of this object for ALTER/CREATE TABLE */
Create_field *clone(MEM_ROOT *mem_root) const; Create_field *clone(MEM_ROOT *mem_root) const;
}; };
@ -4134,7 +4151,7 @@ class Send_field :public Sql_alloc {
public: public:
const char *db_name; const char *db_name;
const char *table_name,*org_table_name; const char *table_name,*org_table_name;
const char *col_name,*org_col_name; LEX_CSTRING col_name, org_col_name;
ulong length; ulong length;
uint flags, decimals; uint flags, decimals;
enum_field_types type; enum_field_types type;
@ -4188,7 +4205,7 @@ uint32 calc_pack_length(enum_field_types type,uint32 length);
int set_field_to_null(Field *field); int set_field_to_null(Field *field);
int set_field_to_null_with_conversions(Field *field, bool no_conversions); int set_field_to_null_with_conversions(Field *field, bool no_conversions);
int convert_null_to_field_value_or_error(Field *field); int convert_null_to_field_value_or_error(Field *field);
bool check_expression(Virtual_column_info *vcol, const char *name, bool check_expression(Virtual_column_info *vcol, LEX_CSTRING *name,
enum_vcol_info_type type); enum_vcol_info_type type);
/* /*

View File

@ -125,7 +125,7 @@ static int set_bad_null_error(Field *field, int err)
return 0; return 0;
case CHECK_FIELD_ERROR_FOR_NULL: case CHECK_FIELD_ERROR_FOR_NULL:
if (!field->table->in_use->no_errors) if (!field->table->in_use->no_errors)
my_error(ER_BAD_NULL_ERROR, MYF(0), field->field_name); my_error(ER_BAD_NULL_ERROR, MYF(0), field->field_name.str);
return -1; return -1;
} }
DBUG_ASSERT(0); // impossible DBUG_ASSERT(0); // impossible

View File

@ -569,7 +569,8 @@ const char* dbug_print_table_row(TABLE *table)
else else
output.append(","); output.append(",");
output.append((*pfield)->field_name? (*pfield)->field_name: "NULL"); output.append((*pfield)->field_name.str ?
(*pfield)->field_name.str: "NULL");
} }
output.append(")=("); output.append(")=(");
@ -620,7 +621,8 @@ static void dbug_print_record(TABLE *table, bool print_rowid)
fprintf(DBUG_FILE, "record ("); fprintf(DBUG_FILE, "record (");
for (pfield= table->field; *pfield ; pfield++) for (pfield= table->field; *pfield ; pfield++)
fprintf(DBUG_FILE, "%s%s", (*pfield)->field_name, (pfield[1])? ", ":""); fprintf(DBUG_FILE, "%s%s", (*pfield)->field_name.str,
(pfield[1])? ", ":"");
fprintf(DBUG_FILE, ") = "); fprintf(DBUG_FILE, ") = ");
fprintf(DBUG_FILE, "("); fprintf(DBUG_FILE, "(");

View File

@ -1512,8 +1512,8 @@ int ha_partition::prepare_new_partition(TABLE *tbl,
That file name may be different from part_name, which will be That file name may be different from part_name, which will be
attached in append_file_to_dir(). attached in append_file_to_dir().
*/ */
truncate_partition_filename(p_elem->data_file_name); truncate_partition_filename((char*) p_elem->data_file_name);
truncate_partition_filename(p_elem->index_file_name); truncate_partition_filename((char*) p_elem->index_file_name);
if ((error= set_up_table_before_create(tbl, part_name, create_info, p_elem))) if ((error= set_up_table_before_create(tbl, part_name, create_info, p_elem)))
goto error_create; goto error_create;
@ -2086,7 +2086,7 @@ void ha_partition::update_create_info(HA_CREATE_INFO *create_info)
my_bool from_alter = (create_info->data_file_name == (const char*) -1); my_bool from_alter = (create_info->data_file_name == (const char*) -1);
create_info->data_file_name= create_info->index_file_name = NULL; create_info->data_file_name= create_info->index_file_name = NULL;
create_info->connect_string= null_lex_str; create_info->connect_string= null_clex_str;
/* /*
We do not need to update the individual partition DATA DIRECTORY settings We do not need to update the individual partition DATA DIRECTORY settings
@ -2957,27 +2957,29 @@ bool ha_partition::read_par_file(const char *name)
m_file_buffer= file_buffer; // Will be freed in clear_handler_file() m_file_buffer= file_buffer; // Will be freed in clear_handler_file()
m_name_buffer_ptr= (char*) (tot_name_len_offset + PAR_WORD_SIZE); m_name_buffer_ptr= (char*) (tot_name_len_offset + PAR_WORD_SIZE);
if (!(m_connect_string= (LEX_STRING*) if (!(m_connect_string= (LEX_CSTRING*)
alloc_root(&m_mem_root, m_tot_parts * sizeof(LEX_STRING)))) alloc_root(&m_mem_root, m_tot_parts * sizeof(LEX_CSTRING))))
goto err2; goto err2;
bzero(m_connect_string, m_tot_parts * sizeof(LEX_STRING)); bzero(m_connect_string, m_tot_parts * sizeof(LEX_CSTRING));
/* Read connection arguments (for federated X engine) */ /* Read connection arguments (for federated X engine) */
for (i= 0; i < m_tot_parts; i++) for (i= 0; i < m_tot_parts; i++)
{ {
LEX_STRING connect_string; LEX_CSTRING connect_string;
uchar buffer[4]; uchar buffer[4];
char *tmp;
if (my_read(file, buffer, 4, MYF(MY_NABP))) if (my_read(file, buffer, 4, MYF(MY_NABP)))
{ {
/* No extra options; Probably not a federatedx engine */ /* No extra options; Probably not a federatedx engine */
break; break;
} }
connect_string.length= uint4korr(buffer); connect_string.length= uint4korr(buffer);
connect_string.str= (char*) alloc_root(&m_mem_root, connect_string.length+1); connect_string.str= tmp= (char*) alloc_root(&m_mem_root,
connect_string.length+1);
if (my_read(file, (uchar*) connect_string.str, connect_string.length, if (my_read(file, (uchar*) connect_string.str, connect_string.length,
MYF(MY_NABP))) MYF(MY_NABP)))
break; break;
connect_string.str[connect_string.length]= 0; tmp[connect_string.length]= 0;
m_connect_string[i]= connect_string; m_connect_string[i]= connect_string;
} }
@ -7951,7 +7953,7 @@ void ha_partition::append_row_to_str(String &str)
{ {
Field *field= key_part->field; Field *field= key_part->field;
str.append(" "); str.append(" ");
str.append(field->field_name); str.append(&field->field_name);
str.append(":"); str.append(":");
field_unpack(&str, field, rec, 0, false); field_unpack(&str, field, rec, 0, false);
} }
@ -7971,7 +7973,7 @@ void ha_partition::append_row_to_str(String &str)
{ {
Field *field= *field_ptr; Field *field= *field_ptr;
str.append(" "); str.append(" ");
str.append(field->field_name); str.append(&field->field_name);
str.append(":"); str.append(":");
field_unpack(&str, field, rec, 0, false); field_unpack(&str, field, rec, 0, false);
} }

View File

@ -144,7 +144,7 @@ private:
handler **m_new_file; // Array of references to new handlers handler **m_new_file; // Array of references to new handlers
handler **m_reorged_file; // Reorganised partitions handler **m_reorged_file; // Reorganised partitions
handler **m_added_file; // Added parts kept for errors handler **m_added_file; // Added parts kept for errors
LEX_STRING *m_connect_string; LEX_CSTRING *m_connect_string;
partition_info *m_part_info; // local reference to partition partition_info *m_part_info; // local reference to partition
Field **m_part_field_array; // Part field array locally to save acc Field **m_part_field_array; // Part field array locally to save acc
uchar *m_ordered_rec_buffer; // Row and key buffer for ord. idx scan uchar *m_ordered_rec_buffer; // Row and key buffer for ord. idx scan
@ -429,7 +429,8 @@ public:
virtual THR_LOCK_DATA **store_lock(THD * thd, THR_LOCK_DATA ** to, virtual THR_LOCK_DATA **store_lock(THD * thd, THR_LOCK_DATA ** to,
enum thr_lock_type lock_type); enum thr_lock_type lock_type);
virtual int external_lock(THD * thd, int lock_type); virtual int external_lock(THD * thd, int lock_type);
LEX_STRING *engine_name() { return hton_name(table->part_info->default_engine_type); } LEX_CSTRING *engine_name()
{ return hton_name(table->part_info->default_engine_type); }
/* /*
When table is locked a statement is started by calling start_stmt When table is locked a statement is started by calling start_stmt
instead of external_lock instead of external_lock

View File

@ -304,8 +304,8 @@ int ha_sequence::external_lock(THD *thd, int lock_type)
void ha_sequence::print_error(int error, myf errflag) void ha_sequence::print_error(int error, myf errflag)
{ {
char *sequence_db= table_share->db.str; const char *sequence_db= table_share->db.str;
char *sequence_name= table_share->table_name.str; const char *sequence_name= table_share->table_name.str;
DBUG_ENTER("ha_sequence::print_error"); DBUG_ENTER("ha_sequence::print_error");
switch (error) { switch (error) {
@ -321,8 +321,7 @@ void ha_sequence::print_error(int error, myf errflag)
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
case HA_ERR_WRONG_COMMAND: case HA_ERR_WRONG_COMMAND:
my_error(ER_ILLEGAL_HA, MYF(0), "SEQUENCE", table_share->db.str, my_error(ER_ILLEGAL_HA, MYF(0), "SEQUENCE", sequence_db, sequence_name);
table_share->table_name.str);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
file->print_error(error, errflag); file->print_error(error, errflag);

View File

@ -82,7 +82,7 @@ public:
{ return HA_CACHE_TBL_NOCACHE; } { return HA_CACHE_TBL_NOCACHE; }
void print_error(int error, myf errflag); void print_error(int error, myf errflag);
int info(uint); int info(uint);
LEX_STRING *engine_name() { return hton_name(file->ht); } LEX_CSTRING *engine_name() { return hton_name(file->ht); }
int external_lock(THD *thd, int lock_type); int external_lock(THD *thd, int lock_type);
/* Functions that are directly mapped to the underlying handler */ /* Functions that are directly mapped to the underlying handler */

View File

@ -76,12 +76,12 @@ ulong total_ha_2pc= 0;
/* size of savepoint storage area (see ha_init) */ /* size of savepoint storage area (see ha_init) */
ulong savepoint_alloc_size= 0; ulong savepoint_alloc_size= 0;
static const LEX_STRING sys_table_aliases[]= static const LEX_CSTRING sys_table_aliases[]=
{ {
{ C_STRING_WITH_LEN("INNOBASE") }, { C_STRING_WITH_LEN("INNODB") }, { STRING_WITH_LEN("INNOBASE") }, { STRING_WITH_LEN("INNODB") },
{ C_STRING_WITH_LEN("HEAP") }, { C_STRING_WITH_LEN("MEMORY") }, { STRING_WITH_LEN("HEAP") }, { STRING_WITH_LEN("MEMORY") },
{ C_STRING_WITH_LEN("MERGE") }, { C_STRING_WITH_LEN("MRG_MYISAM") }, { STRING_WITH_LEN("MERGE") }, { STRING_WITH_LEN("MRG_MYISAM") },
{ C_STRING_WITH_LEN("Maria") }, { C_STRING_WITH_LEN("Aria") }, { STRING_WITH_LEN("Maria") }, { STRING_WITH_LEN("Aria") },
{NullS, 0} {NullS, 0}
}; };
@ -160,9 +160,10 @@ handlerton *ha_default_tmp_handlerton(THD *thd)
RETURN RETURN
pointer to storage engine plugin handle pointer to storage engine plugin handle
*/ */
plugin_ref ha_resolve_by_name(THD *thd, const LEX_STRING *name, bool tmp_table) plugin_ref ha_resolve_by_name(THD *thd, const LEX_CSTRING *name,
bool tmp_table)
{ {
const LEX_STRING *table_alias; const LEX_CSTRING *table_alias;
plugin_ref plugin; plugin_ref plugin;
redo: redo:
@ -405,7 +406,7 @@ static int full_discover_for_existence(handlerton *, const char *, const char *)
static int ext_based_existence(handlerton *, const char *, const char *) static int ext_based_existence(handlerton *, const char *, const char *)
{ return 0; } { return 0; }
static int hton_ext_based_table_discovery(handlerton *hton, LEX_STRING *db, static int hton_ext_based_table_discovery(handlerton *hton, LEX_CSTRING *db,
MY_DIR *dir, handlerton::discovered_list *result) MY_DIR *dir, handlerton::discovered_list *result)
{ {
/* /*
@ -2429,7 +2430,7 @@ err:
return NULL; return NULL;
} }
LEX_STRING *handler::engine_name() LEX_CSTRING *handler::engine_name()
{ {
return hton_name(ht); return hton_name(ht);
} }
@ -3601,7 +3602,7 @@ void handler::print_error(int error, myf errflag)
break; break;
case HA_ERR_AUTOINC_ERANGE: case HA_ERR_AUTOINC_ERANGE:
textno= error; textno= error;
my_error(textno, errflag, table->next_number_field->field_name, my_error(textno, errflag, table->next_number_field->field_name.str,
table->in_use->get_stmt_da()->current_row_for_warning()); table->in_use->get_stmt_da()->current_row_for_warning());
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
break; break;
@ -5080,11 +5081,12 @@ bool ha_table_exists(THD *thd, const char *db, const char *table_name,
if (hton) if (hton)
{ {
char engine_buf[NAME_CHAR_LEN + 1]; char engine_buf[NAME_CHAR_LEN + 1];
LEX_STRING engine= { engine_buf, 0 }; LEX_CSTRING engine= { engine_buf, 0 };
if (dd_frm_type(thd, path, &engine, is_sequence) != TABLE_TYPE_VIEW) if (dd_frm_type(thd, path, &engine, is_sequence) != TABLE_TYPE_VIEW)
{ {
plugin_ref p= plugin_lock_by_name(thd, &engine, MYSQL_STORAGE_ENGINE_PLUGIN); plugin_ref p= plugin_lock_by_name(thd, &engine,
MYSQL_STORAGE_ENGINE_PLUGIN);
*hton= p ? plugin_hton(p) : NULL; *hton= p ? plugin_hton(p) : NULL;
if (*hton) if (*hton)
// verify that the table really exists // verify that the table really exists
@ -5146,7 +5148,7 @@ static int cmp_file_names(const void *a, const void *b)
return my_strnncoll(cs, (uchar*)aa, strlen(aa), (uchar*)bb, strlen(bb)); return my_strnncoll(cs, (uchar*)aa, strlen(aa), (uchar*)bb, strlen(bb));
} }
static int cmp_table_names(LEX_STRING * const *a, LEX_STRING * const *b) static int cmp_table_names(LEX_CSTRING * const *a, LEX_CSTRING * const *b)
{ {
return my_strnncoll(&my_charset_bin, (uchar*)((*a)->str), (*a)->length, return my_strnncoll(&my_charset_bin, (uchar*)((*a)->str), (*a)->length,
(uchar*)((*b)->str), (*b)->length); (uchar*)((*b)->str), (*b)->length);
@ -5155,8 +5157,8 @@ static int cmp_table_names(LEX_STRING * const *a, LEX_STRING * const *b)
} }
Discovered_table_list::Discovered_table_list(THD *thd_arg, Discovered_table_list::Discovered_table_list(THD *thd_arg,
Dynamic_array<LEX_STRING*> *tables_arg, Dynamic_array<LEX_CSTRING*> *tables_arg,
const LEX_STRING *wild_arg) : const LEX_CSTRING *wild_arg) :
thd(thd_arg), with_temps(false), tables(tables_arg) thd(thd_arg), with_temps(false), tables(tables_arg)
{ {
if (wild_arg->str && wild_arg->str[0]) if (wild_arg->str && wild_arg->str[0])
@ -5180,7 +5182,7 @@ bool Discovered_table_list::add_table(const char *tname, size_t tlen)
wild_prefix, wild_one, wild_many)) wild_prefix, wild_one, wild_many))
return 0; return 0;
LEX_STRING *name= thd->make_lex_string(tname, tlen); LEX_CSTRING *name= thd->make_clex_string(tname, tlen);
if (!name || tables->append(name)) if (!name || tables->append(name))
return 1; return 1;
return 0; return 0;
@ -5206,11 +5208,11 @@ void Discovered_table_list::sort()
void Discovered_table_list::remove_duplicates() void Discovered_table_list::remove_duplicates()
{ {
LEX_STRING **src= tables->front(); LEX_CSTRING **src= tables->front();
LEX_STRING **dst= src; LEX_CSTRING **dst= src;
while (++dst <= tables->back()) while (++dst <= tables->back())
{ {
LEX_STRING *s= *src, *d= *dst; LEX_CSTRING *s= *src, *d= *dst;
DBUG_ASSERT(strncmp(s->str, d->str, MY_MIN(s->length, d->length)) <= 0); DBUG_ASSERT(strncmp(s->str, d->str, MY_MIN(s->length, d->length)) <= 0);
if ((s->length != d->length || strncmp(s->str, d->str, d->length))) if ((s->length != d->length || strncmp(s->str, d->str, d->length)))
{ {
@ -5224,7 +5226,7 @@ void Discovered_table_list::remove_duplicates()
struct st_discover_names_args struct st_discover_names_args
{ {
LEX_STRING *db; LEX_CSTRING *db;
MY_DIR *dirp; MY_DIR *dirp;
Discovered_table_list *result; Discovered_table_list *result;
uint possible_duplicates; uint possible_duplicates;
@ -5269,7 +5271,7 @@ static my_bool discover_names(THD *thd, plugin_ref plugin,
for DROP DATABASE (as it needs to know and delete non-table files). for DROP DATABASE (as it needs to know and delete non-table files).
*/ */
int ha_discover_table_names(THD *thd, LEX_STRING *db, MY_DIR *dirp, int ha_discover_table_names(THD *thd, LEX_CSTRING *db, MY_DIR *dirp,
Discovered_table_list *result, bool reusable) Discovered_table_list *result, bool reusable)
{ {
int error; int error;
@ -5619,7 +5621,7 @@ bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat)
{ {
if (db_type->state != SHOW_OPTION_YES) if (db_type->state != SHOW_OPTION_YES)
{ {
const LEX_STRING *name= hton_name(db_type); const LEX_CSTRING *name= hton_name(db_type);
result= stat_print(thd, name->str, name->length, result= stat_print(thd, name->str, name->length,
"", 0, "DISABLED", 8) ? 1 : 0; "", 0, "DISABLED", 8) ? 1 : 0;
} }
@ -6497,7 +6499,7 @@ int del_global_index_stats_for_table(THD *thd, uchar* cache_key, uint cache_key_
/* Remove a table from global table statistics */ /* Remove a table from global table statistics */
int del_global_table_stat(THD *thd, LEX_STRING *db, LEX_STRING *table) int del_global_table_stat(THD *thd, LEX_CSTRING *db, LEX_CSTRING *table)
{ {
TABLE_STATS *table_stats; TABLE_STATS *table_stats;
int res = 0; int res = 0;

View File

@ -1341,7 +1341,7 @@ struct handlerton
Returns 0 on success and 1 on error. Returns 0 on success and 1 on error.
*/ */
int (*discover_table_names)(handlerton *hton, LEX_STRING *db, MY_DIR *dir, int (*discover_table_names)(handlerton *hton, LEX_CSTRING *db, MY_DIR *dir,
discovered_list *result); discovered_list *result);
/* /*
@ -1387,7 +1387,7 @@ struct handlerton
}; };
static inline LEX_STRING *hton_name(const handlerton *hton) static inline LEX_CSTRING *hton_name(const handlerton *hton)
{ {
return &(hton2plugin[hton->slot]->name); return &(hton2plugin[hton->slot]->name);
} }
@ -1670,9 +1670,9 @@ struct Table_scope_and_contents_source_st
{ {
CHARSET_INFO *table_charset; CHARSET_INFO *table_charset;
LEX_CUSTRING tabledef_version; LEX_CUSTRING tabledef_version;
LEX_STRING connect_string; LEX_CSTRING connect_string;
LEX_CSTRING comment;
const char *password, *tablespace; const char *password, *tablespace;
LEX_STRING comment;
const char *data_file_name, *index_file_name; const char *data_file_name, *index_file_name;
const char *alias; const char *alias;
ulonglong max_rows,min_rows; ulonglong max_rows,min_rows;
@ -2167,8 +2167,8 @@ typedef struct st_key_create_information
{ {
enum ha_key_alg algorithm; enum ha_key_alg algorithm;
ulong block_size; ulong block_size;
LEX_STRING parser_name; LEX_CSTRING parser_name;
LEX_STRING comment; LEX_CSTRING comment;
/** /**
A flag to determine if we will check for duplicate indexes. A flag to determine if we will check for duplicate indexes.
This typically means that the key information was specified This typically means that the key information was specified
@ -3523,7 +3523,7 @@ public:
cached cached
*/ */
virtual my_bool register_query_cache_table(THD *thd, char *table_key, virtual my_bool register_query_cache_table(THD *thd, const char *table_key,
uint key_length, uint key_length,
qc_engine_callback qc_engine_callback
*engine_callback, *engine_callback,
@ -3952,7 +3952,7 @@ public:
return 0; return 0;
} }
virtual LEX_STRING *engine_name(); virtual LEX_CSTRING *engine_name();
TABLE* get_table() { return table; } TABLE* get_table() { return table; }
TABLE_SHARE* get_table_share() { return table_share; } TABLE_SHARE* get_table_share() { return table_share; }
@ -4256,7 +4256,7 @@ extern const char *myisam_stats_method_names[];
extern ulong total_ha, total_ha_2pc; extern ulong total_ha, total_ha_2pc;
/* lookups */ /* lookups */
plugin_ref ha_resolve_by_name(THD *thd, const LEX_STRING *name, bool tmp_table); plugin_ref ha_resolve_by_name(THD *thd, const LEX_CSTRING *name, bool tmp_table);
plugin_ref ha_lock_engine(THD *thd, const handlerton *hton); plugin_ref ha_lock_engine(THD *thd, const handlerton *hton);
handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type); handlerton *ha_resolve_by_legacy_type(THD *thd, enum legacy_db_type db_type);
handler *get_new_handler(TABLE_SHARE *share, MEM_ROOT *alloc, handler *get_new_handler(TABLE_SHARE *share, MEM_ROOT *alloc,
@ -4324,11 +4324,11 @@ class Discovered_table_list: public handlerton::discovered_list
const char *wild, *wend; const char *wild, *wend;
bool with_temps; // whether to include temp tables in the result bool with_temps; // whether to include temp tables in the result
public: public:
Dynamic_array<LEX_STRING*> *tables; Dynamic_array<LEX_CSTRING*> *tables;
Discovered_table_list(THD *thd_arg, Dynamic_array<LEX_STRING*> *tables_arg, Discovered_table_list(THD *thd_arg, Dynamic_array<LEX_CSTRING*> *tables_arg,
const LEX_STRING *wild_arg); const LEX_CSTRING *wild_arg);
Discovered_table_list(THD *thd_arg, Dynamic_array<LEX_STRING*> *tables_arg) Discovered_table_list(THD *thd_arg, Dynamic_array<LEX_CSTRING*> *tables_arg)
: thd(thd_arg), wild(NULL), with_temps(true), tables(tables_arg) {} : thd(thd_arg), wild(NULL), with_temps(true), tables(tables_arg) {}
~Discovered_table_list() {} ~Discovered_table_list() {}
@ -4340,7 +4340,7 @@ public:
}; };
int ha_discover_table(THD *thd, TABLE_SHARE *share); int ha_discover_table(THD *thd, TABLE_SHARE *share);
int ha_discover_table_names(THD *thd, LEX_STRING *db, MY_DIR *dirp, int ha_discover_table_names(THD *thd, LEX_CSTRING *db, MY_DIR *dirp,
Discovered_table_list *result, bool reusable); Discovered_table_list *result, bool reusable);
bool ha_table_exists(THD *thd, const char *db, const char *table_name, bool ha_table_exists(THD *thd, const char *db, const char *table_name,
handlerton **hton= 0, bool *is_sequence= 0); handlerton **hton= 0, bool *is_sequence= 0);
@ -4423,5 +4423,5 @@ void print_keydup_error(TABLE *table, KEY *key, const char *msg, myf errflag);
void print_keydup_error(TABLE *table, KEY *key, myf errflag); void print_keydup_error(TABLE *table, KEY *key, myf errflag);
int del_global_index_stat(THD *thd, TABLE* table, KEY* key_info); int del_global_index_stat(THD *thd, TABLE* table, KEY* key_info);
int del_global_table_stat(THD *thd, LEX_STRING *db, LEX_STRING *table); int del_global_table_stat(THD *thd, LEX_CSTRING *db, LEX_CSTRING *table);
#endif /* HANDLER_INCLUDED */ #endif /* HANDLER_INCLUDED */

File diff suppressed because it is too large Load Diff

View File

@ -111,6 +111,7 @@ bool mark_unsupported_function(const char *w1, const char *w2,
#define FULL_EXTRACTION_FL (1 << 7) #define FULL_EXTRACTION_FL (1 << 7)
#define EXTRACTION_MASK (NO_EXTRACTION_FL | FULL_EXTRACTION_FL) #define EXTRACTION_MASK (NO_EXTRACTION_FL | FULL_EXTRACTION_FL)
extern const char *item_empty_name;
void dummy_error_processor(THD *thd, void *data); void dummy_error_processor(THD *thd, void *data);
@ -376,7 +377,7 @@ class Rewritable_query_parameter
/* /*
Byte length of parameter name in the statement. This is not Byte length of parameter name in the statement. This is not
Item::name_length because name_length contains byte length of UTF8-encoded Item::name.length because name.length contains byte length of UTF8-encoded
name, but the query string is in the client charset. name, but the query string is in the client charset.
*/ */
uint len_in_query; uint len_in_query;
@ -591,9 +592,9 @@ public:
*/ */
String *val_str() { return val_str(&str_value); } String *val_str() { return val_str(&str_value); }
char * name; /* Name from select */ LEX_CSTRING name; /* Name of item */
/* Original item name (if it was renamed)*/ /* Original item name (if it was renamed)*/
char * orig_name; const char *orig_name;
/** /**
Intrusive list pointer for free list. If not null, points to the next Intrusive list pointer for free list. If not null, points to the next
Item on some Query_arena's free list. For instance, stored procedures Item on some Query_arena's free list. For instance, stored procedures
@ -602,12 +603,6 @@ public:
@see Query_arena::free_list @see Query_arena::free_list
*/ */
Item *next; Item *next;
/*
TODO: convert name and name_length fields into LEX_STRING to keep them in
sync (see bug #11829681/60295 etc). Then also remove some strlen(name)
calls.
*/
uint name_length; /* Length of name */
int marker; int marker;
bool maybe_null; /* If item may be null */ bool maybe_null; /* If item may be null */
bool in_rollup; /* If used in GROUP BY list bool in_rollup; /* If used in GROUP BY list
@ -639,13 +634,13 @@ public:
virtual ~Item() virtual ~Item()
{ {
#ifdef EXTRA_DEBUG #ifdef EXTRA_DEBUG
name=0; name.str= 0;
name.length= 0;
#endif #endif
} /*lint -e1509 */ } /*lint -e1509 */
void set_name(THD *thd, const char *str, uint length, CHARSET_INFO *cs); void set_name(THD *thd, const char *str, uint length, CHARSET_INFO *cs);
void set_name_no_truncate(THD *thd, const char *str, uint length, void set_name_no_truncate(THD *thd, const char *str, uint length,
CHARSET_INFO *cs); CHARSET_INFO *cs);
void rename(char *new_name);
void init_make_field(Send_field *tmp_field,enum enum_field_types type); void init_make_field(Send_field *tmp_field,enum enum_field_types type);
virtual void cleanup(); virtual void cleanup();
virtual void make_field(THD *thd, Send_field *field); virtual void make_field(THD *thd, Send_field *field);
@ -1091,9 +1086,9 @@ public:
virtual Field *get_tmp_table_field() { return 0; } virtual Field *get_tmp_table_field() { return 0; }
virtual Field *create_field_for_create_select(TABLE *table); virtual Field *create_field_for_create_select(TABLE *table);
virtual Field *create_field_for_schema(THD *thd, TABLE *table); virtual Field *create_field_for_schema(THD *thd, TABLE *table);
virtual const char *full_name() const { return name ? name : "???"; } virtual const char *full_name() const { return name.str ? name.str : "???"; }
const char *field_name_or_null() const char *field_name_or_null()
{ return real_item()->type() == Item::FIELD_ITEM ? name : NULL; } { return real_item()->type() == Item::FIELD_ITEM ? name.str : NULL; }
/* /*
*result* family of methods is analog of *val* family (see above) but *result* family of methods is analog of *val* family (see above) but
@ -1629,7 +1624,7 @@ public:
// Row emulation // Row emulation
virtual uint cols() { return 1; } virtual uint cols() { return 1; }
virtual Item* element_index(uint i) { return this; } virtual Item* element_index(uint i) { return this; }
virtual bool element_index_by_name(uint *idx, const LEX_STRING &name) const virtual bool element_index_by_name(uint *idx, const LEX_CSTRING &name) const
{ {
return true; // Error return true; // Error
} }
@ -2076,7 +2071,10 @@ public:
done again between subsequent executions of a prepared statement. done again between subsequent executions of a prepared statement.
*/ */
if (orig_name) if (orig_name)
name= orig_name; {
name.str= orig_name;
name.length= strlen(orig_name);
}
} }
}; };
@ -2099,7 +2097,7 @@ protected:
bool fix_fields_from_item(THD *thd, Item **, const Item *); bool fix_fields_from_item(THD *thd, Item **, const Item *);
public: public:
LEX_STRING m_name; LEX_CSTRING m_name;
public: public:
#ifndef DBUG_OFF #ifndef DBUG_OFF
@ -2111,7 +2109,7 @@ public:
#endif #endif
public: public:
Item_sp_variable(THD *thd, char *sp_var_name_str, uint sp_var_name_length); Item_sp_variable(THD *thd, const LEX_CSTRING *sp_var_name);
public: public:
bool fix_fields(THD *thd, Item **)= 0; bool fix_fields(THD *thd, Item **)= 0;
@ -2123,7 +2121,7 @@ public:
bool is_null(); bool is_null();
public: public:
inline void make_field(THD *thd, Send_field *field); void make_field(THD *thd, Send_field *field);
inline bool const_item() const; inline bool const_item() const;
@ -2139,17 +2137,6 @@ public:
Item_sp_variable inline implementation. Item_sp_variable inline implementation.
*****************************************************************************/ *****************************************************************************/
inline void Item_sp_variable::make_field(THD *thd, Send_field *field)
{
Item *it= this_item();
if (name)
it->set_name(thd, name, (uint) strlen(name), system_charset_info);
else
it->set_name(thd, m_name.str, (uint) m_name.length, system_charset_info);
it->make_field(thd, field);
}
inline bool Item_sp_variable::const_item() const inline bool Item_sp_variable::const_item() const
{ {
return TRUE; return TRUE;
@ -2183,7 +2170,7 @@ protected:
bool append_value_for_log(THD *thd, String *str); bool append_value_for_log(THD *thd, String *str);
public: public:
Item_splocal(THD *thd, const LEX_STRING &sp_var_name, uint sp_var_idx, Item_splocal(THD *thd, const LEX_CSTRING *sp_var_name, uint sp_var_idx,
enum_field_types sp_var_type, enum_field_types sp_var_type,
uint pos_in_q= 0, uint len_in_q= 0); uint pos_in_q= 0, uint len_in_q= 0);
@ -2195,7 +2182,7 @@ public:
virtual void print(String *str, enum_query_type query_type); virtual void print(String *str, enum_query_type query_type);
public: public:
inline const LEX_STRING *my_name() const; inline const LEX_CSTRING *my_name() const;
inline uint get_var_idx() const; inline uint get_var_idx() const;
@ -2234,7 +2221,7 @@ public:
class Item_splocal_row: public Item_splocal class Item_splocal_row: public Item_splocal
{ {
public: public:
Item_splocal_row(THD *thd, const LEX_STRING &sp_var_name, Item_splocal_row(THD *thd, const LEX_CSTRING *sp_var_name,
uint sp_var_idx, uint pos_in_q, uint len_in_q) uint sp_var_idx, uint pos_in_q, uint len_in_q)
:Item_splocal(thd, sp_var_name, sp_var_idx, MYSQL_TYPE_NULL, :Item_splocal(thd, sp_var_name, sp_var_idx, MYSQL_TYPE_NULL,
pos_in_q, len_in_q) pos_in_q, len_in_q)
@ -2253,7 +2240,7 @@ class Item_splocal_with_delayed_data_type: public Item_splocal
{ {
public: public:
Item_splocal_with_delayed_data_type(THD *thd, Item_splocal_with_delayed_data_type(THD *thd,
const LEX_STRING &sp_var_name, const LEX_CSTRING *sp_var_name,
uint sp_var_idx, uint sp_var_idx,
uint pos_in_q, uint len_in_q) uint pos_in_q, uint len_in_q)
:Item_splocal(thd, sp_var_name, sp_var_idx, MYSQL_TYPE_NULL, :Item_splocal(thd, sp_var_name, sp_var_idx, MYSQL_TYPE_NULL,
@ -2287,19 +2274,19 @@ public:
class Item_splocal_row_field :public Item_splocal class Item_splocal_row_field :public Item_splocal
{ {
protected: protected:
LEX_STRING m_field_name; LEX_CSTRING m_field_name;
uint m_field_idx; uint m_field_idx;
bool set_value(THD *thd, sp_rcontext *ctx, Item **it); bool set_value(THD *thd, sp_rcontext *ctx, Item **it);
public: public:
Item_splocal_row_field(THD *thd, Item_splocal_row_field(THD *thd,
const LEX_STRING &sp_var_name, const LEX_CSTRING *sp_var_name,
const LEX_STRING &sp_field_name, const LEX_CSTRING *sp_field_name,
uint sp_var_idx, uint sp_field_idx, uint sp_var_idx, uint sp_field_idx,
enum_field_types sp_var_type, enum_field_types sp_var_type,
uint pos_in_q= 0, uint len_in_q= 0) uint pos_in_q= 0, uint len_in_q= 0)
:Item_splocal(thd, sp_var_name, sp_var_idx, sp_var_type, :Item_splocal(thd, sp_var_name, sp_var_idx, sp_var_type,
pos_in_q, len_in_q), pos_in_q, len_in_q),
m_field_name(sp_field_name), m_field_name(*sp_field_name),
m_field_idx(sp_field_idx) m_field_idx(sp_field_idx)
{ } { }
bool fix_fields(THD *thd, Item **); bool fix_fields(THD *thd, Item **);
@ -2316,8 +2303,8 @@ class Item_splocal_row_field_by_name :public Item_splocal_row_field
bool set_value(THD *thd, sp_rcontext *ctx, Item **it); bool set_value(THD *thd, sp_rcontext *ctx, Item **it);
public: public:
Item_splocal_row_field_by_name(THD *thd, Item_splocal_row_field_by_name(THD *thd,
const LEX_STRING &sp_var_name, const LEX_CSTRING *sp_var_name,
const LEX_STRING &sp_field_name, const LEX_CSTRING *sp_field_name,
uint sp_var_idx, uint sp_var_idx,
enum_field_types sp_var_type, enum_field_types sp_var_type,
uint pos_in_q= 0, uint len_in_q= 0) uint pos_in_q= 0, uint len_in_q= 0)
@ -2334,7 +2321,7 @@ public:
Item_splocal inline implementation. Item_splocal inline implementation.
*****************************************************************************/ *****************************************************************************/
inline const LEX_STRING *Item_splocal::my_name() const inline const LEX_CSTRING *Item_splocal::my_name() const
{ {
return &m_name; return &m_name;
} }
@ -2512,13 +2499,13 @@ protected:
*/ */
const char *orig_db_name; const char *orig_db_name;
const char *orig_table_name; const char *orig_table_name;
const char *orig_field_name; LEX_CSTRING orig_field_name;
public: public:
Name_resolution_context *context; Name_resolution_context *context;
const char *db_name; const char *db_name;
const char *table_name; const char *table_name;
const char *field_name; LEX_CSTRING field_name;
bool alias_name_used; /* true if item was resolved against alias */ bool alias_name_used; /* true if item was resolved against alias */
/* /*
Cached value of index for this field in table->field array, used by prep. Cached value of index for this field in table->field array, used by prep.
@ -2548,9 +2535,9 @@ public:
bool can_be_depended; bool can_be_depended;
Item_ident(THD *thd, Name_resolution_context *context_arg, Item_ident(THD *thd, Name_resolution_context *context_arg,
const char *db_name_arg, const char *table_name_arg, const char *db_name_arg, const char *table_name_arg,
const char *field_name_arg); const LEX_CSTRING *field_name_arg);
Item_ident(THD *thd, Item_ident *item); Item_ident(THD *thd, Item_ident *item);
Item_ident(THD *thd, TABLE_LIST *view_arg, const char *field_name_arg); Item_ident(THD *thd, TABLE_LIST *view_arg, const LEX_CSTRING *field_name_arg);
const char *full_name() const; const char *full_name() const;
void cleanup(); void cleanup();
st_select_lex *get_depended_from() const; st_select_lex *get_depended_from() const;
@ -2611,7 +2598,7 @@ public:
bool any_privileges; bool any_privileges;
Item_field(THD *thd, Name_resolution_context *context_arg, Item_field(THD *thd, Name_resolution_context *context_arg,
const char *db_arg,const char *table_name_arg, const char *db_arg,const char *table_name_arg,
const char *field_name_arg); const LEX_CSTRING *field_name_arg);
/* /*
Constructor needed to process subselect with temporary tables (see Item) Constructor needed to process subselect with temporary tables (see Item)
*/ */
@ -2735,7 +2722,7 @@ public:
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
context= 0; context= 0;
return mark_unsupported_function(field_name, arg, VCOL_FIELD_REF); return mark_unsupported_function(field_name.str, arg, VCOL_FIELD_REF);
} }
void cleanup(); void cleanup();
Item_equal *get_item_equal() { return item_equal; } Item_equal *get_item_equal() { return item_equal; }
@ -2793,7 +2780,7 @@ public:
Item_result result_type() const{ return ROW_RESULT ; } Item_result result_type() const{ return ROW_RESULT ; }
Item_result cmp_type() const { return ROW_RESULT; } Item_result cmp_type() const { return ROW_RESULT; }
uint cols() { return arg_count; } uint cols() { return arg_count; }
bool element_index_by_name(uint *idx, const LEX_STRING &name) const; bool element_index_by_name(uint *idx, const LEX_CSTRING &name) const;
Item* element_index(uint i) { return arg_count ? args[i] : this; } Item* element_index(uint i) { return arg_count ? args[i] : this; }
Item** addr(uint i) { return arg_count ? args + i : NULL; } Item** addr(uint i) { return arg_count ? args + i : NULL; }
bool check_cols(uint c) bool check_cols(uint c)
@ -2851,12 +2838,13 @@ public:
class Item_null :public Item_basic_constant class Item_null :public Item_basic_constant
{ {
public: public:
Item_null(THD *thd, char *name_par=0, CHARSET_INFO *cs= &my_charset_bin): Item_null(THD *thd, const char *name_par=0, CHARSET_INFO *cs= &my_charset_bin):
Item_basic_constant(thd) Item_basic_constant(thd)
{ {
maybe_null= null_value= TRUE; maybe_null= null_value= TRUE;
max_length= 0; max_length= 0;
name= name_par ? name_par : (char*) "NULL"; name.str= name_par ? name_par : "NULL";
name.length= strlen(name.str);
fixed= 1; fixed= 1;
collation.set(cs, DERIVATION_IGNORABLE, MY_REPERTOIRE_ASCII); collation.set(cs, DERIVATION_IGNORABLE, MY_REPERTOIRE_ASCII);
} }
@ -3056,7 +3044,7 @@ public:
enum Item_result cmp_type () const enum Item_result cmp_type () const
{ return Type_handler_hybrid_field_type::cmp_type(); } { return Type_handler_hybrid_field_type::cmp_type(); }
Item_param(THD *thd, char *name_arg, Item_param(THD *thd, const LEX_CSTRING *name_arg,
uint pos_in_query_arg, uint len_in_query_arg); uint pos_in_query_arg, uint len_in_query_arg);
enum Type type() const enum Type type() const
@ -3182,7 +3170,11 @@ public:
{ max_length=length; fixed= 1; unsigned_flag= 1; } { max_length=length; fixed= 1; unsigned_flag= 1; }
Item_int(THD *thd, const char *str_arg,longlong i,uint length): Item_int(THD *thd, const char *str_arg,longlong i,uint length):
Item_num(thd), value(i) Item_num(thd), value(i)
{ max_length=length; name=(char*) str_arg; fixed= 1; } {
max_length=length;
name.str= str_arg; name.length= safe_strlen(name.str);
fixed= 1;
}
Item_int(THD *thd, const char *str_arg, uint length=64); Item_int(THD *thd, const char *str_arg, uint length=64);
enum Type type() const { return INT_ITEM; } enum Type type() const { return INT_ITEM; }
enum Item_result result_type () const { return INT_RESULT; } enum Item_result result_type () const { return INT_RESULT; }
@ -3288,16 +3280,17 @@ public:
class Item_float :public Item_num class Item_float :public Item_num
{ {
char *presentation; const char *presentation;
public: public:
double value; double value;
Item_float(THD *thd, const char *str_arg, uint length); Item_float(THD *thd, const char *str_arg, uint length);
Item_float(THD *thd, const char *str, double val_arg, uint decimal_par, Item_float(THD *thd, const char *str, double val_arg, uint decimal_par,
uint length): Item_num(thd), value(val_arg) uint length): Item_num(thd), value(val_arg)
{ {
presentation= name=(char*) str; presentation= name.str= str;
name.length= safe_strlen(str);
decimals=(uint8) decimal_par; decimals=(uint8) decimal_par;
max_length=length; max_length= length;
fixed= 1; fixed= 1;
} }
Item_float(THD *thd, double value_par, uint decimal_par): Item_float(THD *thd, double value_par, uint decimal_par):
@ -3423,7 +3416,7 @@ public:
{ {
str_value.set_or_copy_aligned(str, length, cs); str_value.set_or_copy_aligned(str, length, cs);
fix_from_value(dv, Metadata(&str_value)); fix_from_value(dv, Metadata(&str_value));
set_name(thd, name_par, 0, system_charset_info); set_name(thd, name_par, safe_strlen(name_par), system_charset_info);
} }
Item_string(THD *thd, const char *name_par, const char *str, uint length, Item_string(THD *thd, const char *name_par, const char *str, uint length,
CHARSET_INFO *cs, Derivation dv, uint repertoire): CHARSET_INFO *cs, Derivation dv, uint repertoire):
@ -3431,7 +3424,7 @@ public:
{ {
str_value.set_or_copy_aligned(str, length, cs); str_value.set_or_copy_aligned(str, length, cs);
fix_from_value(dv, Metadata(&str_value, repertoire)); fix_from_value(dv, Metadata(&str_value, repertoire));
set_name(thd, name_par, 0, system_charset_info); set_name(thd, name_par, safe_strlen(name_par), system_charset_info);
} }
void print_value(String *to) const void print_value(String *to) const
{ {
@ -3459,7 +3452,7 @@ public:
{ {
return const_charset_converter(thd, tocs, true); return const_charset_converter(thd, tocs, true);
} }
inline void append(char *str, uint length) inline void append(const char *str, uint length)
{ {
str_value.append(str, length); str_value.append(str, length);
max_length= str_value.numchars() * collation.collation->mbmaxlen; max_length= str_value.numchars() * collation.collation->mbmaxlen;
@ -3494,7 +3487,7 @@ public:
String *check_well_formed_result(bool send_error) String *check_well_formed_result(bool send_error)
{ return Item::check_well_formed_result(&str_value, send_error); } { return Item::check_well_formed_result(&str_value, send_error); }
enum_field_types odbc_temporal_literal_type(const LEX_STRING *type_str) const enum_field_types odbc_temporal_literal_type(const LEX_CSTRING *type_str) const
{ {
/* /*
If string is a reasonably short pure ASCII string literal, If string is a reasonably short pure ASCII string literal,
@ -3641,7 +3634,7 @@ class Item_blob :public Item_partition_func_safe_string
{ {
public: public:
Item_blob(THD *thd, const char *name_arg, uint length): Item_blob(THD *thd, const char *name_arg, uint length):
Item_partition_func_safe_string(thd, name_arg, strlen(name_arg), &my_charset_bin) Item_partition_func_safe_string(thd, name_arg, safe_strlen(name_arg), &my_charset_bin)
{ max_length= length; } { max_length= length; }
enum Type type() const { return TYPE_HOLDER; } enum Type type() const { return TYPE_HOLDER; }
enum_field_types field_type() const { return MYSQL_TYPE_BLOB; } enum_field_types field_type() const { return MYSQL_TYPE_BLOB; }
@ -3669,7 +3662,11 @@ public:
CHARSET_INFO *cs= NULL): CHARSET_INFO *cs= NULL):
Item_partition_func_safe_string(thd, "", 0, Item_partition_func_safe_string(thd, "", 0,
cs ? cs : &my_charset_utf8_general_ci) cs ? cs : &my_charset_utf8_general_ci)
{ name=(char*) header; max_length= length * collation.collation->mbmaxlen; } {
name.str= header;
name.length= strlen(name.str);
max_length= length * collation.collation->mbmaxlen;
}
void make_field(THD *thd, Send_field *field); void make_field(THD *thd, Send_field *field);
}; };
@ -4237,7 +4234,7 @@ public:
bool reference_trough_name; bool reference_trough_name;
Item_ref(THD *thd, Name_resolution_context *context_arg, Item_ref(THD *thd, Name_resolution_context *context_arg,
const char *db_arg, const char *table_name_arg, const char *db_arg, const char *table_name_arg,
const char *field_name_arg): const LEX_CSTRING *field_name_arg):
Item_ident(thd, context_arg, db_arg, table_name_arg, field_name_arg), Item_ident(thd, context_arg, db_arg, table_name_arg, field_name_arg),
set_properties_only(0), ref(0), reference_trough_name(1) {} set_properties_only(0), ref(0), reference_trough_name(1) {}
/* /*
@ -4255,10 +4252,10 @@ public:
with Bar, and if we have a more broader set of problems like this. with Bar, and if we have a more broader set of problems like this.
*/ */
Item_ref(THD *thd, Name_resolution_context *context_arg, Item **item, Item_ref(THD *thd, Name_resolution_context *context_arg, Item **item,
const char *table_name_arg, const char *field_name_arg, const char *table_name_arg, const LEX_CSTRING *field_name_arg,
bool alias_name_used_arg= FALSE); bool alias_name_used_arg= FALSE);
Item_ref(THD *thd, TABLE_LIST *view_arg, Item **item, Item_ref(THD *thd, TABLE_LIST *view_arg, Item **item,
const char *field_name_arg, bool alias_name_used_arg= FALSE); const LEX_CSTRING *field_name_arg, bool alias_name_used_arg= FALSE);
/* Constructor need to process subselect with temporary tables (see Item) */ /* Constructor need to process subselect with temporary tables (see Item) */
Item_ref(THD *thd, Item_ref *item) Item_ref(THD *thd, Item_ref *item)
@ -4436,7 +4433,7 @@ class Item_direct_ref :public Item_ref
public: public:
Item_direct_ref(THD *thd, Name_resolution_context *context_arg, Item **item, Item_direct_ref(THD *thd, Name_resolution_context *context_arg, Item **item,
const char *table_name_arg, const char *table_name_arg,
const char *field_name_arg, const LEX_CSTRING *field_name_arg,
bool alias_name_used_arg= FALSE): bool alias_name_used_arg= FALSE):
Item_ref(thd, context_arg, item, table_name_arg, Item_ref(thd, context_arg, item, table_name_arg,
field_name_arg, alias_name_used_arg) field_name_arg, alias_name_used_arg)
@ -4444,7 +4441,7 @@ public:
/* Constructor need to process subselect with temporary tables (see Item) */ /* Constructor need to process subselect with temporary tables (see Item) */
Item_direct_ref(THD *thd, Item_direct_ref *item) : Item_ref(thd, item) {} Item_direct_ref(THD *thd, Item_direct_ref *item) : Item_ref(thd, item) {}
Item_direct_ref(THD *thd, TABLE_LIST *view_arg, Item **item, Item_direct_ref(THD *thd, TABLE_LIST *view_arg, Item **item,
const char *field_name_arg, const LEX_CSTRING *field_name_arg,
bool alias_name_used_arg= FALSE): bool alias_name_used_arg= FALSE):
Item_ref(thd, view_arg, item, field_name_arg, Item_ref(thd, view_arg, item, field_name_arg,
alias_name_used_arg) alias_name_used_arg)
@ -4482,7 +4479,7 @@ class Item_direct_ref_to_ident :public Item_direct_ref
public: public:
Item_direct_ref_to_ident(THD *thd, Item_ident *item): Item_direct_ref_to_ident(THD *thd, Item_ident *item):
Item_direct_ref(thd, item->context, (Item**)&item, item->table_name, Item_direct_ref(thd, item->context, (Item**)&item, item->table_name,
item->field_name, FALSE) &item->field_name, FALSE)
{ {
ident= item; ident= item;
ref= (Item**)&ident; ref= (Item**)&ident;
@ -4669,7 +4666,7 @@ public:
Item_direct_view_ref(THD *thd, Name_resolution_context *context_arg, Item_direct_view_ref(THD *thd, Name_resolution_context *context_arg,
Item **item, Item **item,
const char *table_name_arg, const char *table_name_arg,
const char *field_name_arg, LEX_CSTRING *field_name_arg,
TABLE_LIST *view_arg): TABLE_LIST *view_arg):
Item_direct_ref(thd, context_arg, item, table_name_arg, field_name_arg), Item_direct_ref(thd, context_arg, item, table_name_arg, field_name_arg),
item_equal(0), view(view_arg), item_equal(0), view(view_arg),
@ -4821,7 +4818,7 @@ public:
Item_outer_ref(THD *thd, Name_resolution_context *context_arg, Item_outer_ref(THD *thd, Name_resolution_context *context_arg,
Item_field *outer_field_arg): Item_field *outer_field_arg):
Item_direct_ref(thd, context_arg, 0, outer_field_arg->table_name, Item_direct_ref(thd, context_arg, 0, outer_field_arg->table_name,
outer_field_arg->field_name), &outer_field_arg->field_name),
outer_ref(outer_field_arg), in_sum_func(0), outer_ref(outer_field_arg), in_sum_func(0),
found_in_select_list(0), found_in_group_by(0) found_in_select_list(0), found_in_group_by(0)
{ {
@ -4830,7 +4827,7 @@ public:
fixed= 0; /* reset flag set in set_properties() */ fixed= 0; /* reset flag set in set_properties() */
} }
Item_outer_ref(THD *thd, Name_resolution_context *context_arg, Item **item, Item_outer_ref(THD *thd, Name_resolution_context *context_arg, Item **item,
const char *table_name_arg, const char *field_name_arg, const char *table_name_arg, LEX_CSTRING *field_name_arg,
bool alias_name_used_arg): bool alias_name_used_arg):
Item_direct_ref(thd, context_arg, item, table_name_arg, field_name_arg, Item_direct_ref(thd, context_arg, item, table_name_arg, field_name_arg,
alias_name_used_arg), alias_name_used_arg),
@ -4871,7 +4868,8 @@ protected:
public: public:
Item_ref_null_helper(THD *thd, Name_resolution_context *context_arg, Item_ref_null_helper(THD *thd, Name_resolution_context *context_arg,
Item_in_subselect* master, Item **item, Item_in_subselect* master, Item **item,
const char *table_name_arg, const char *field_name_arg): const char *table_name_arg,
const LEX_CSTRING *field_name_arg):
Item_ref(thd, context_arg, item, table_name_arg, field_name_arg), Item_ref(thd, context_arg, item, table_name_arg, field_name_arg),
owner(master) {} owner(master) {}
void save_val(Field *to); void save_val(Field *to);
@ -4974,7 +4972,7 @@ protected:
item= i; item= i;
null_value=maybe_null=item->maybe_null; null_value=maybe_null=item->maybe_null;
Type_std_attributes::set(item); Type_std_attributes::set(item);
name=item->name; name= item->name;
set_handler_by_field_type(item->field_type()); set_handler_by_field_type(item->field_type());
fixed= item->fixed; fixed= item->fixed;
} }
@ -5263,15 +5261,15 @@ public:
Item *arg; Item *arg;
Item_default_value(THD *thd, Name_resolution_context *context_arg) Item_default_value(THD *thd, Name_resolution_context *context_arg)
:Item_field(thd, context_arg, (const char *)NULL, (const char *)NULL, :Item_field(thd, context_arg, (const char *)NULL, (const char *)NULL,
(const char *)NULL), &null_clex_str),
arg(NULL) {} arg(NULL) {}
Item_default_value(THD *thd, Name_resolution_context *context_arg, Item *a) Item_default_value(THD *thd, Name_resolution_context *context_arg, Item *a)
:Item_field(thd, context_arg, (const char *)NULL, (const char *)NULL, :Item_field(thd, context_arg, (const char *)NULL, (const char *)NULL,
(const char *)NULL), &null_clex_str),
arg(a) {} arg(a) {}
Item_default_value(THD *thd, Name_resolution_context *context_arg, Field *a) Item_default_value(THD *thd, Name_resolution_context *context_arg, Field *a)
:Item_field(thd, context_arg, (const char *)NULL, (const char *)NULL, :Item_field(thd, context_arg, (const char *)NULL, (const char *)NULL,
(const char *)NULL), &null_clex_str),
arg(NULL) {} arg(NULL) {}
enum Type type() const { return DEFAULT_VALUE_ITEM; } enum Type type() const { return DEFAULT_VALUE_ITEM; }
bool eq(const Item *item, bool binary_cmp) const; bool eq(const Item *item, bool binary_cmp) const;
@ -5354,7 +5352,7 @@ public:
Item *arg; Item *arg;
Item_insert_value(THD *thd, Name_resolution_context *context_arg, Item *a) Item_insert_value(THD *thd, Name_resolution_context *context_arg, Item *a)
:Item_field(thd, context_arg, (const char *)NULL, (const char *)NULL, :Item_field(thd, context_arg, (const char *)NULL, (const char *)NULL,
(const char *)NULL), &null_clex_str),
arg(a) {} arg(a) {}
bool eq(const Item *item, bool binary_cmp) const; bool eq(const Item *item, bool binary_cmp) const;
bool fix_fields(THD *, Item **); bool fix_fields(THD *, Item **);
@ -5415,7 +5413,7 @@ public:
Item_trigger_field(THD *thd, Name_resolution_context *context_arg, Item_trigger_field(THD *thd, Name_resolution_context *context_arg,
row_version_type row_ver_arg, row_version_type row_ver_arg,
const char *field_name_arg, const LEX_CSTRING *field_name_arg,
ulong priv, const bool ro) ulong priv, const bool ro)
:Item_field(thd, context_arg, :Item_field(thd, context_arg,
(const char *)NULL, (const char *)NULL, field_name_arg), (const char *)NULL, (const char *)NULL, field_name_arg),

File diff suppressed because it is too large Load Diff

View File

@ -56,7 +56,7 @@ public:
@param item_list The list of arguments to the function, can be NULL @param item_list The list of arguments to the function, can be NULL
@return An item representing the parsed function call, or NULL @return An item representing the parsed function call, or NULL
*/ */
virtual Item *create_func(THD *thd, LEX_STRING name, List<Item> *item_list) = 0; virtual Item *create_func(THD *thd, LEX_CSTRING *name, List<Item> *item_list) = 0;
protected: protected:
/** Constructor */ /** Constructor */
@ -83,7 +83,8 @@ public:
@param item_list The list of arguments to the function, can be NULL @param item_list The list of arguments to the function, can be NULL
@return An item representing the parsed function call @return An item representing the parsed function call
*/ */
virtual Item *create_func(THD *thd, LEX_STRING name, List<Item> *item_list); virtual Item *create_func(THD *thd, LEX_CSTRING *name,
List<Item> *item_list);
/** /**
The builder create method, for qualified functions. The builder create method, for qualified functions.
@ -94,7 +95,7 @@ public:
@param item_list The list of arguments to the function, can be NULL @param item_list The list of arguments to the function, can be NULL
@return An item representing the parsed function call @return An item representing the parsed function call
*/ */
virtual Item *create_with_db(THD *thd, LEX_STRING db, LEX_STRING name, virtual Item *create_with_db(THD *thd, LEX_CSTRING *db, LEX_CSTRING *name,
bool use_explicit_name, bool use_explicit_name,
List<Item> *item_list) = 0; List<Item> *item_list) = 0;
@ -112,7 +113,8 @@ protected:
@param name The native function name @param name The native function name
@return The native function builder associated with the name, or NULL @return The native function builder associated with the name, or NULL
*/ */
extern Create_func * find_native_function_builder(THD *thd, LEX_STRING name); extern Create_func *find_native_function_builder(THD *thd,
const LEX_CSTRING *name);
/** /**
@ -131,7 +133,8 @@ extern Create_qfunc * find_qualified_function_builder(THD *thd);
class Create_udf_func : public Create_func class Create_udf_func : public Create_func
{ {
public: public:
virtual Item *create_func(THD *thd, LEX_STRING name, List<Item> *item_list); virtual Item *create_func(THD *thd, LEX_CSTRING *name,
List<Item> *item_list);
/** /**
The builder create method, for User Defined Functions. The builder create method, for User Defined Functions.

View File

@ -59,7 +59,7 @@
#define sp_restore_security_context(A,B) while (0) {} #define sp_restore_security_context(A,B) while (0) {}
#endif #endif
bool check_reserved_words(LEX_STRING *name) bool check_reserved_words(const LEX_CSTRING *name)
{ {
if (!my_strcasecmp(system_charset_info, name->str, "GLOBAL") || if (!my_strcasecmp(system_charset_info, name->str, "GLOBAL") ||
!my_strcasecmp(system_charset_info, name->str, "LOCAL") || !my_strcasecmp(system_charset_info, name->str, "LOCAL") ||
@ -1106,7 +1106,7 @@ err:
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_WARN_DATA_OUT_OF_RANGE, ER_WARN_DATA_OUT_OF_RANGE,
ER_THD(thd, ER_WARN_DATA_OUT_OF_RANGE), ER_THD(thd, ER_WARN_DATA_OUT_OF_RANGE),
name, 1L); name.str, 1L);
return dec; return dec;
} }
@ -1149,7 +1149,7 @@ double Item_double_typecast::val_real()
Sql_condition::WARN_LEVEL_WARN, Sql_condition::WARN_LEVEL_WARN,
ER_WARN_DATA_OUT_OF_RANGE, ER_WARN_DATA_OUT_OF_RANGE,
ER_THD(thd, ER_WARN_DATA_OUT_OF_RANGE), ER_THD(thd, ER_WARN_DATA_OUT_OF_RANGE),
name, 1); name.str, (ulong) 1);
if (error < 0) if (error < 0)
{ {
null_value= 1; // Illegal value null_value= 1; // Illegal value
@ -3291,7 +3291,7 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func,
!(f_args.maybe_null= (char*) thd->alloc(arg_count * sizeof(char))) || !(f_args.maybe_null= (char*) thd->alloc(arg_count * sizeof(char))) ||
!(num_buffer= (char*) thd->alloc(arg_count * !(num_buffer= (char*) thd->alloc(arg_count *
ALIGN_SIZE(sizeof(double)))) || ALIGN_SIZE(sizeof(double)))) ||
!(f_args.attributes= (char**) thd->alloc(arg_count * !(f_args.attributes= (const char**) thd->alloc(arg_count *
sizeof(char *))) || sizeof(char *))) ||
!(f_args.attribute_lengths= (ulong*) thd->alloc(arg_count * !(f_args.attribute_lengths= (ulong*) thd->alloc(arg_count *
sizeof(long)))) sizeof(long))))
@ -3321,8 +3321,8 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func,
f_args.lengths[i]= arguments[i]->max_length; f_args.lengths[i]= arguments[i]->max_length;
f_args.maybe_null[i]= (char) arguments[i]->maybe_null; f_args.maybe_null[i]= (char) arguments[i]->maybe_null;
f_args.attributes[i]= arguments[i]->name; f_args.attributes[i]= arguments[i]->name.str;
f_args.attribute_lengths[i]= arguments[i]->name_length; f_args.attribute_lengths[i]= arguments[i]->name.length;
if (arguments[i]->const_item()) if (arguments[i]->const_item())
{ {
@ -3690,7 +3690,7 @@ longlong Item_master_pos_wait::val_int()
longlong pos = (ulong)args[1]->val_int(); longlong pos = (ulong)args[1]->val_int();
longlong timeout = (arg_count>=3) ? args[2]->val_int() : 0 ; longlong timeout = (arg_count>=3) ? args[2]->val_int() : 0 ;
String connection_name_buff; String connection_name_buff;
LEX_STRING connection_name; LEX_CSTRING connection_name;
Master_info *mi= NULL; Master_info *mi= NULL;
if (arg_count >= 4) if (arg_count >= 4)
{ {
@ -3698,7 +3698,7 @@ longlong Item_master_pos_wait::val_int()
if (!(con= args[3]->val_str(&connection_name_buff))) if (!(con= args[3]->val_str(&connection_name_buff)))
goto err; goto err;
connection_name.str= (char*) con->ptr(); connection_name.str= con->ptr();
connection_name.length= con->length(); connection_name.length= con->length();
if (check_master_connection_name(&connection_name)) if (check_master_connection_name(&connection_name))
{ {
@ -4398,16 +4398,16 @@ bool Item_func_user_var::check_vcol_func_processor(void *arg)
#define extra_size sizeof(double) #define extra_size sizeof(double)
user_var_entry *get_variable(HASH *hash, LEX_STRING &name, user_var_entry *get_variable(HASH *hash, LEX_CSTRING *name,
bool create_if_not_exists) bool create_if_not_exists)
{ {
user_var_entry *entry; user_var_entry *entry;
if (!(entry = (user_var_entry*) my_hash_search(hash, (uchar*) name.str, if (!(entry = (user_var_entry*) my_hash_search(hash, (uchar*) name->str,
name.length)) && name->length)) &&
create_if_not_exists) create_if_not_exists)
{ {
uint size=ALIGN_SIZE(sizeof(user_var_entry))+name.length+1+extra_size; uint size=ALIGN_SIZE(sizeof(user_var_entry))+name->length+1+extra_size;
if (!my_hash_inited(hash)) if (!my_hash_inited(hash))
return 0; return 0;
if (!(entry = (user_var_entry*) my_malloc(size, if (!(entry = (user_var_entry*) my_malloc(size,
@ -4416,7 +4416,7 @@ user_var_entry *get_variable(HASH *hash, LEX_STRING &name,
return 0; return 0;
entry->name.str=(char*) entry+ ALIGN_SIZE(sizeof(user_var_entry))+ entry->name.str=(char*) entry+ ALIGN_SIZE(sizeof(user_var_entry))+
extra_size; extra_size;
entry->name.length=name.length; entry->name.length=name->length;
entry->value=0; entry->value=0;
entry->length=0; entry->length=0;
entry->update_query_id=0; entry->update_query_id=0;
@ -4434,7 +4434,7 @@ user_var_entry *get_variable(HASH *hash, LEX_STRING &name,
*/ */
entry->used_query_id=current_thd->query_id; entry->used_query_id=current_thd->query_id;
entry->type=STRING_RESULT; entry->type=STRING_RESULT;
memcpy(entry->name.str, name.str, name.length+1); memcpy((char*) entry->name.str, name->str, name->length+1);
if (my_hash_insert(hash,(uchar*) entry)) if (my_hash_insert(hash,(uchar*) entry))
{ {
my_free(entry); my_free(entry);
@ -4456,7 +4456,7 @@ bool Item_func_set_user_var::set_entry(THD *thd, bool create_if_not_exists)
{ {
if (m_var_entry && thd->thread_id == entry_thread_id) if (m_var_entry && thd->thread_id == entry_thread_id)
goto end; // update entry->update_query_id for PS goto end; // update entry->update_query_id for PS
if (!(m_var_entry= get_variable(&thd->user_vars, name, create_if_not_exists))) if (!(m_var_entry= get_variable(&thd->user_vars, &name, create_if_not_exists)))
{ {
entry_thread_id= 0; entry_thread_id= 0;
return TRUE; return TRUE;
@ -5090,8 +5090,8 @@ void Item_func_set_user_var::make_field(THD *thd, Send_field *tmp_field)
{ {
result_field->make_field(tmp_field); result_field->make_field(tmp_field);
DBUG_ASSERT(tmp_field->table_name != 0); DBUG_ASSERT(tmp_field->table_name != 0);
if (Item::name) if (Item::name.str)
tmp_field->col_name=Item::name; // Use user supplied name tmp_field->col_name= Item::name; // Use user supplied name
} }
else else
Item::make_field(thd, tmp_field); Item::make_field(thd, tmp_field);
@ -5259,7 +5259,7 @@ longlong Item_func_get_user_var::val_int()
static int static int
get_var_with_binlog(THD *thd, enum_sql_command sql_command, get_var_with_binlog(THD *thd, enum_sql_command sql_command,
LEX_STRING &name, user_var_entry **out_entry) LEX_CSTRING *name, user_var_entry **out_entry)
{ {
BINLOG_USER_VAR_EVENT *user_var_event; BINLOG_USER_VAR_EVENT *user_var_event;
user_var_entry *var_entry; user_var_entry *var_entry;
@ -5385,7 +5385,7 @@ void Item_func_get_user_var::fix_length_and_dec()
decimals=NOT_FIXED_DEC; decimals=NOT_FIXED_DEC;
max_length=MAX_BLOB_WIDTH; max_length=MAX_BLOB_WIDTH;
error= get_var_with_binlog(thd, thd->lex->sql_command, name, &m_var_entry); error= get_var_with_binlog(thd, thd->lex->sql_command, &name, &m_var_entry);
/* /*
If the variable didn't exist it has been created as a STRING-type. If the variable didn't exist it has been created as a STRING-type.
@ -5462,7 +5462,8 @@ bool Item_func_get_user_var::eq(const Item *item, bool binary_cmp) const
bool Item_func_get_user_var::set_value(THD *thd, bool Item_func_get_user_var::set_value(THD *thd,
sp_rcontext * /*ctx*/, Item **it) sp_rcontext * /*ctx*/, Item **it)
{ {
Item_func_set_user_var *suv= new (thd->mem_root) Item_func_set_user_var(thd, get_name(), *it); LEX_CSTRING tmp_name= get_name();
Item_func_set_user_var *suv= new (thd->mem_root) Item_func_set_user_var(thd, &tmp_name, *it);
/* /*
Item_func_set_user_var is not fixed after construction, call Item_func_set_user_var is not fixed after construction, call
fix_fields(). fix_fields().
@ -5476,7 +5477,7 @@ bool Item_user_var_as_out_param::fix_fields(THD *thd, Item **ref)
DBUG_ASSERT(fixed == 0); DBUG_ASSERT(fixed == 0);
DBUG_ASSERT(thd->lex->exchange); DBUG_ASSERT(thd->lex->exchange);
if (Item::fix_fields(thd, ref) || if (Item::fix_fields(thd, ref) ||
!(entry= get_variable(&thd->user_vars, name, 1))) !(entry= get_variable(&thd->user_vars, &name, 1)))
return TRUE; return TRUE;
entry->type= STRING_RESULT; entry->type= STRING_RESULT;
/* /*
@ -5543,7 +5544,7 @@ void Item_user_var_as_out_param::print_for_load(THD *thd, String *str)
Item_func_get_system_var:: Item_func_get_system_var::
Item_func_get_system_var(THD *thd, sys_var *var_arg, enum_var_type var_type_arg, Item_func_get_system_var(THD *thd, sys_var *var_arg, enum_var_type var_type_arg,
LEX_STRING *component_arg, const char *name_arg, LEX_CSTRING *component_arg, const char *name_arg,
size_t name_len_arg): size_t name_len_arg):
Item_func(thd), var(var_arg), var_type(var_type_arg), Item_func(thd), var(var_arg), var_type(var_type_arg),
orig_var_type(var_type_arg), component(*component_arg), cache_present(0) orig_var_type(var_type_arg), component(*component_arg), cache_present(0)
@ -5650,8 +5651,8 @@ void Item_func_get_system_var::fix_length_and_dec()
void Item_func_get_system_var::print(String *str, enum_query_type query_type) void Item_func_get_system_var::print(String *str, enum_query_type query_type)
{ {
if (name_length) if (name.length)
str->append(name, name_length); str->append(name.str, name.length);
else else
{ {
str->append(STRING_WITH_LEN("@@")); str->append(STRING_WITH_LEN("@@"));
@ -6211,11 +6212,11 @@ longlong Item_func_bit_xor::val_int()
*/ */
Item *get_system_var(THD *thd, enum_var_type var_type, LEX_STRING name, Item *get_system_var(THD *thd, enum_var_type var_type, LEX_CSTRING name,
LEX_STRING component) LEX_CSTRING component)
{ {
sys_var *var; sys_var *var;
LEX_STRING *base_name, *component_name; LEX_CSTRING *base_name, *component_name;
if (component.str) if (component.str)
{ {
@ -6318,7 +6319,7 @@ Item_func_sp::func_name() const
} }
void my_missing_function_error(const LEX_STRING &token, const char *func_name) void my_missing_function_error(const LEX_CSTRING &token, const char *func_name)
{ {
if (token.length && is_lex_native_function (&token)) if (token.length && is_lex_native_function (&token))
my_error(ER_FUNC_INEXISTENT_NAME_COLLISION, MYF(0), func_name); my_error(ER_FUNC_INEXISTENT_NAME_COLLISION, MYF(0), func_name);
@ -6348,7 +6349,6 @@ void my_missing_function_error(const LEX_STRING &token, const char *func_name)
bool bool
Item_func_sp::init_result_field(THD *thd) Item_func_sp::init_result_field(THD *thd)
{ {
LEX_STRING empty_name= { C_STRING_WITH_LEN("") };
TABLE_SHARE *share; TABLE_SHARE *share;
DBUG_ENTER("Item_func_sp::init_result_field"); DBUG_ENTER("Item_func_sp::init_result_field");
@ -6374,11 +6374,10 @@ Item_func_sp::init_result_field(THD *thd)
dummy_table->maybe_null = maybe_null; dummy_table->maybe_null = maybe_null;
dummy_table->in_use= thd; dummy_table->in_use= thd;
dummy_table->copy_blobs= TRUE; dummy_table->copy_blobs= TRUE;
share->table_cache_key = empty_name; share->table_cache_key= empty_clex_str;
share->table_name = empty_name; share->table_name= empty_clex_str;
if (!(sp_result_field= m_sp->create_result_field(max_length, name, if (!(sp_result_field= m_sp->create_result_field(max_length, &name, dummy_table)))
dummy_table)))
{ {
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
@ -6531,8 +6530,11 @@ Item_func_sp::make_field(THD *thd, Send_field *tmp_field)
DBUG_ENTER("Item_func_sp::make_field"); DBUG_ENTER("Item_func_sp::make_field");
DBUG_ASSERT(sp_result_field); DBUG_ASSERT(sp_result_field);
sp_result_field->make_field(tmp_field); sp_result_field->make_field(tmp_field);
if (name) if (name.str)
{
DBUG_ASSERT(name.length == strlen(name.str));
tmp_field->col_name= name; tmp_field->col_name= name;
}
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }

View File

@ -745,12 +745,12 @@ public:
class Item_func_cursor_int_attr: public Item_int_func class Item_func_cursor_int_attr: public Item_int_func
{ {
protected: protected:
LEX_STRING m_cursor_name; LEX_CSTRING m_cursor_name;
uint m_cursor_offset; uint m_cursor_offset;
class sp_cursor *get_open_cursor_or_error(); class sp_cursor *get_open_cursor_or_error();
public: public:
Item_func_cursor_int_attr(THD *thd, const LEX_STRING name, uint offset) Item_func_cursor_int_attr(THD *thd, const LEX_CSTRING *name, uint offset)
:Item_int_func(thd), m_cursor_name(name), m_cursor_offset(offset) :Item_int_func(thd), m_cursor_name(*name), m_cursor_offset(offset)
{ } { }
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
@ -763,7 +763,7 @@ public:
class Item_func_cursor_isopen: public Item_func_cursor_int_attr class Item_func_cursor_isopen: public Item_func_cursor_int_attr
{ {
public: public:
Item_func_cursor_isopen(THD *thd, const LEX_STRING name, uint offset) Item_func_cursor_isopen(THD *thd, const LEX_CSTRING *name, uint offset)
:Item_func_cursor_int_attr(thd, name, offset) { } :Item_func_cursor_int_attr(thd, name, offset) { }
const char *func_name() const { return "%ISOPEN"; } const char *func_name() const { return "%ISOPEN"; }
void fix_length_and_dec() { max_length= 1; } void fix_length_and_dec() { max_length= 1; }
@ -776,7 +776,7 @@ public:
class Item_func_cursor_found: public Item_func_cursor_int_attr class Item_func_cursor_found: public Item_func_cursor_int_attr
{ {
public: public:
Item_func_cursor_found(THD *thd, const LEX_STRING name, uint offset) Item_func_cursor_found(THD *thd, const LEX_CSTRING *name, uint offset)
:Item_func_cursor_int_attr(thd, name, offset) { } :Item_func_cursor_int_attr(thd, name, offset) { }
const char *func_name() const { return "%FOUND"; } const char *func_name() const { return "%FOUND"; }
void fix_length_and_dec() { max_length= 1; maybe_null= true; } void fix_length_and_dec() { max_length= 1; maybe_null= true; }
@ -789,7 +789,7 @@ public:
class Item_func_cursor_notfound: public Item_func_cursor_int_attr class Item_func_cursor_notfound: public Item_func_cursor_int_attr
{ {
public: public:
Item_func_cursor_notfound(THD *thd, const LEX_STRING name, uint offset) Item_func_cursor_notfound(THD *thd, const LEX_CSTRING *name, uint offset)
:Item_func_cursor_int_attr(thd, name, offset) { } :Item_func_cursor_int_attr(thd, name, offset) { }
const char *func_name() const { return "%NOTFOUND"; } const char *func_name() const { return "%NOTFOUND"; }
void fix_length_and_dec() { max_length= 1; maybe_null= true; } void fix_length_and_dec() { max_length= 1; maybe_null= true; }
@ -802,7 +802,7 @@ public:
class Item_func_cursor_rowcount: public Item_func_cursor_int_attr class Item_func_cursor_rowcount: public Item_func_cursor_int_attr
{ {
public: public:
Item_func_cursor_rowcount(THD *thd, const LEX_STRING name, uint offset) Item_func_cursor_rowcount(THD *thd, const LEX_CSTRING *name, uint offset)
:Item_func_cursor_int_attr(thd, name, offset) { } :Item_func_cursor_int_attr(thd, name, offset) { }
const char *func_name() const { return "%ROWCOUNT"; } const char *func_name() const { return "%ROWCOUNT"; }
longlong val_int(); longlong val_int();
@ -1534,7 +1534,6 @@ public:
Item_func_rollup_const(THD *thd, Item *a): Item_func(thd, a) Item_func_rollup_const(THD *thd, Item *a): Item_func(thd, a)
{ {
name= a->name; name= a->name;
name_length= a->name_length;
} }
double val_real() { return args[0]->val_real(); } double val_real() { return args[0]->val_real(); }
longlong val_int() { return args[0]->val_int(); } longlong val_int() { return args[0]->val_int(); }
@ -2187,11 +2186,11 @@ class Item_func_user_var :public Item_hybrid_func
protected: protected:
user_var_entry *m_var_entry; user_var_entry *m_var_entry;
public: public:
LEX_STRING name; // keep it public LEX_CSTRING name; // keep it public
Item_func_user_var(THD *thd, LEX_STRING a) Item_func_user_var(THD *thd, const LEX_CSTRING *a)
:Item_hybrid_func(thd), m_var_entry(NULL), name(a) { } :Item_hybrid_func(thd), m_var_entry(NULL), name(*a) { }
Item_func_user_var(THD *thd, LEX_STRING a, Item *b) Item_func_user_var(THD *thd, const LEX_CSTRING *a, Item *b)
:Item_hybrid_func(thd, b), m_var_entry(NULL), name(a) { } :Item_hybrid_func(thd, b), m_var_entry(NULL), name(*a) { }
Item_func_user_var(THD *thd, Item_func_user_var *item) Item_func_user_var(THD *thd, Item_func_user_var *item)
:Item_hybrid_func(thd, item), :Item_hybrid_func(thd, item),
m_var_entry(item->m_var_entry), name(item->name) { } m_var_entry(item->m_var_entry), name(item->name) { }
@ -2225,7 +2224,7 @@ class Item_func_set_user_var :public Item_func_user_var
} save_result; } save_result;
public: public:
Item_func_set_user_var(THD *thd, LEX_STRING a, Item *b): Item_func_set_user_var(THD *thd, const LEX_CSTRING *a, Item *b):
Item_func_user_var(thd, a, b), Item_func_user_var(thd, a, b),
entry_thread_id(0) entry_thread_id(0)
{} {}
@ -2294,10 +2293,10 @@ class Item_func_get_user_var :public Item_func_user_var,
private Settable_routine_parameter private Settable_routine_parameter
{ {
public: public:
Item_func_get_user_var(THD *thd, LEX_STRING a): Item_func_get_user_var(THD *thd, const LEX_CSTRING *a):
Item_func_user_var(thd, a) {} Item_func_user_var(thd, a) {}
enum Functype functype() const { return GUSERVAR_FUNC; } enum Functype functype() const { return GUSERVAR_FUNC; }
LEX_STRING get_name() { return name; } LEX_CSTRING get_name() { return name; }
double val_real(); double val_real();
longlong val_int(); longlong val_int();
my_decimal *val_decimal(my_decimal*); my_decimal *val_decimal(my_decimal*);
@ -2337,11 +2336,12 @@ public:
*/ */
class Item_user_var_as_out_param :public Item class Item_user_var_as_out_param :public Item
{ {
LEX_STRING name; LEX_CSTRING name;
user_var_entry *entry; user_var_entry *entry;
public: public:
Item_user_var_as_out_param(THD *thd, LEX_STRING a): Item(thd), name(a) Item_user_var_as_out_param(THD *thd, const LEX_CSTRING *a)
{ set_name(thd, a.str, 0, system_charset_info); } :Item(thd), name(*a)
{ set_name(thd, a->str, a->length, system_charset_info); }
/* We should return something different from FIELD_ITEM here */ /* We should return something different from FIELD_ITEM here */
enum Type type() const { return STRING_ITEM;} enum Type type() const { return STRING_ITEM;}
double val_real(); double val_real();
@ -2369,7 +2369,7 @@ class Item_func_get_system_var :public Item_func
{ {
sys_var *var; sys_var *var;
enum_var_type var_type, orig_var_type; enum_var_type var_type, orig_var_type;
LEX_STRING component; LEX_CSTRING component;
longlong cached_llval; longlong cached_llval;
double cached_dval; double cached_dval;
String cached_strval; String cached_strval;
@ -2380,7 +2380,7 @@ class Item_func_get_system_var :public Item_func
public: public:
Item_func_get_system_var(THD *thd, sys_var *var_arg, Item_func_get_system_var(THD *thd, sys_var *var_arg,
enum_var_type var_type_arg, enum_var_type var_type_arg,
LEX_STRING *component_arg, const char *name_arg, LEX_CSTRING *component_arg, const char *name_arg,
size_t name_len_arg); size_t name_len_arg);
enum Functype functype() const { return GSYSVAR_FUNC; } enum Functype functype() const { return GSYSVAR_FUNC; }
void update_null_value(); void update_null_value();
@ -2890,9 +2890,9 @@ public:
}; };
Item *get_system_var(THD *thd, enum_var_type var_type, LEX_STRING name, Item *get_system_var(THD *thd, enum_var_type var_type, LEX_CSTRING name,
LEX_STRING component); LEX_CSTRING component);
extern bool check_reserved_words(LEX_STRING *name); extern bool check_reserved_words(const LEX_CSTRING *name);
Item *find_date_time_item(Item **args, uint nargs, uint col); Item *find_date_time_item(Item **args, uint nargs, uint col);
double my_double_round(double value, longlong dec, bool dec_unsigned, double my_double_round(double value, longlong dec, bool dec_unsigned,
bool truncate); bool truncate);

View File

@ -43,7 +43,7 @@
Field *Item_geometry_func::create_field_for_create_select(TABLE *t_arg) Field *Item_geometry_func::create_field_for_create_select(TABLE *t_arg)
{ {
Field *result; Field *result;
if ((result= new Field_geom(max_length, maybe_null, name, t_arg->s, if ((result= new Field_geom(max_length, maybe_null, &name, t_arg->s,
get_geometry_type()))) get_geometry_type())))
result->init(t_arg); result->init(t_arg);
return result; return result;

View File

@ -450,7 +450,7 @@ String *Item_func_from_base64::val_str(String *str)
THD *thd= current_thd; THD *thd= current_thd;
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_BAD_BASE64_DATA, ER_THD(thd, ER_BAD_BASE64_DATA), ER_BAD_BASE64_DATA, ER_THD(thd, ER_BAD_BASE64_DATA),
end_ptr - res->ptr()); (int) (end_ptr - res->ptr()));
goto err; goto err;
} }

View File

@ -44,7 +44,7 @@
double get_post_group_estimate(JOIN* join, double join_op_rows); double get_post_group_estimate(JOIN* join, double join_op_rows);
const char *exists_outer_expr_name= "<exists outer expr>"; LEX_CSTRING exists_outer_expr_name= { STRING_WITH_LEN("<exists outer expr>") };
int check_and_do_in_subquery_rewrites(JOIN *join); int check_and_do_in_subquery_rewrites(JOIN *join);
@ -290,7 +290,6 @@ bool Item_subselect::fix_fields(THD *thd_param, Item **ref)
(*ref)= substitution; (*ref)= substitution;
substitution->name= name; substitution->name= name;
substitution->name_length= name_length;
if (have_to_be_excluded) if (have_to_be_excluded)
engine->exclude(); engine->exclude();
substitution= 0; substitution= 0;
@ -1879,8 +1878,8 @@ Item_in_subselect::single_value_transformer(JOIN *join)
*/ */
expr= new (thd->mem_root) Item_direct_ref(thd, &select_lex->context, expr= new (thd->mem_root) Item_direct_ref(thd, &select_lex->context,
(Item**)optimizer->get_cache(), (Item**)optimizer->get_cache(),
(char *)"<no matter>", "<no matter>",
(char *)in_left_expr_name); &in_left_expr_name);
} }
DBUG_RETURN(false); DBUG_RETURN(false);
@ -2103,6 +2102,8 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
if (join_having || select_lex->with_sum_func || if (join_having || select_lex->with_sum_func ||
select_lex->group_list.elements) select_lex->group_list.elements)
{ {
const char *tmp= this->full_name();
LEX_CSTRING field_name= {tmp, safe_strlen(tmp)};
Item *item= func->create(thd, expr, Item *item= func->create(thd, expr,
new (thd->mem_root) Item_ref_null_helper( new (thd->mem_root) Item_ref_null_helper(
thd, thd,
@ -2111,7 +2112,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
&select_lex-> &select_lex->
ref_pointer_array[0], ref_pointer_array[0],
(char *)"<ref>", (char *)"<ref>",
this->full_name())); &field_name));
if (!abort_on_null && left_expr->maybe_null) if (!abort_on_null && left_expr->maybe_null)
{ {
/* /*
@ -2123,7 +2124,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
} }
if (!join_having) if (!join_having)
item->name= (char*) in_having_cond; item->name= in_having_cond;
if (fix_having(item, select_lex)) if (fix_having(item, select_lex))
DBUG_RETURN(true); DBUG_RETURN(true);
*having_item= item; *having_item= item;
@ -2148,7 +2149,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
get_cond_guard(0)))) get_cond_guard(0))))
DBUG_RETURN(true); DBUG_RETURN(true);
} }
having->name= (char*) in_having_cond; having->name= in_having_cond;
if (fix_having(having, select_lex)) if (fix_having(having, select_lex))
DBUG_RETURN(true); DBUG_RETURN(true);
*having_item= having; *having_item= having;
@ -2173,7 +2174,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
single_value_transformer but there is no corresponding action in single_value_transformer but there is no corresponding action in
row_value_transformer? row_value_transformer?
*/ */
item->name= (char *) in_additional_cond; item->name= in_additional_cond;
if (!item->fixed && item->fix_fields(thd, 0)) if (!item->fixed && item->fix_fields(thd, 0))
DBUG_RETURN(true); DBUG_RETURN(true);
*where_item= item; *where_item= item;
@ -2182,6 +2183,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
{ {
if (select_lex->master_unit()->is_unit_op()) if (select_lex->master_unit()->is_unit_op())
{ {
LEX_CSTRING field_name= {STRING_WITH_LEN("<result>") };
Item *new_having= Item *new_having=
func->create(thd, expr, func->create(thd, expr,
new (thd->mem_root) Item_ref_null_helper(thd, new (thd->mem_root) Item_ref_null_helper(thd,
@ -2189,7 +2191,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
this, this,
&select_lex->ref_pointer_array[0], &select_lex->ref_pointer_array[0],
(char *)"<no matter>", (char *)"<no matter>",
(char *)"<result>")); &field_name));
if (!abort_on_null && left_expr->maybe_null) if (!abort_on_null && left_expr->maybe_null)
{ {
disable_cond_guard_for_const_null_left_expr(0); disable_cond_guard_for_const_null_left_expr(0);
@ -2198,7 +2200,7 @@ Item_in_subselect::create_single_in_to_exists_cond(JOIN *join,
DBUG_RETURN(true); DBUG_RETURN(true);
} }
new_having->name= (char*) in_having_cond; new_having->name= in_having_cond;
if (fix_having(new_having, select_lex)) if (fix_having(new_having, select_lex))
DBUG_RETURN(true); DBUG_RETURN(true);
*having_item= new_having; *having_item= new_having;
@ -2345,7 +2347,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
bool is_having_used= (join_having || select_lex->with_sum_func || bool is_having_used= (join_having || select_lex->with_sum_func ||
select_lex->group_list.first || select_lex->group_list.first ||
!select_lex->table_list.elements); !select_lex->table_list.elements);
LEX_CSTRING list_ref= { STRING_WITH_LEN("<list ref>")};
DBUG_ENTER("Item_in_subselect::create_row_in_to_exists_cond"); DBUG_ENTER("Item_in_subselect::create_row_in_to_exists_cond");
DBUG_ASSERT(thd == join->thd); DBUG_ASSERT(thd == join->thd);
@ -2367,6 +2369,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
if (select_lex->ref_pointer_array[i]-> if (select_lex->ref_pointer_array[i]->
check_cols(left_expr->element_index(i)->cols())) check_cols(left_expr->element_index(i)->cols()))
DBUG_RETURN(true); DBUG_RETURN(true);
Item *item_eq= Item *item_eq=
new (thd->mem_root) new (thd->mem_root)
Item_func_eq(thd, new (thd->mem_root) Item_func_eq(thd, new (thd->mem_root)
@ -2374,12 +2377,12 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
(*optimizer->get_cache())-> (*optimizer->get_cache())->
addr(i), addr(i),
(char *)"<no matter>", (char *)"<no matter>",
(char *)in_left_expr_name), &in_left_expr_name),
new (thd->mem_root) new (thd->mem_root)
Item_ref(thd, &select_lex->context, Item_ref(thd, &select_lex->context,
&select_lex->ref_pointer_array[i], &select_lex->ref_pointer_array[i],
(char *)"<no matter>", (char *)"<no matter>",
(char *)"<list ref>")); &list_ref));
Item *item_isnull= Item *item_isnull=
new (thd->mem_root) new (thd->mem_root)
Item_func_isnull(thd, Item_func_isnull(thd,
@ -2387,7 +2390,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
Item_ref(thd, &select_lex->context, Item_ref(thd, &select_lex->context,
&select_lex->ref_pointer_array[i], &select_lex->ref_pointer_array[i],
(char *)"<no matter>", (char *)"<no matter>",
(char *)"<list ref>")); &list_ref));
Item *col_item= new (thd->mem_root) Item *col_item= new (thd->mem_root)
Item_cond_or(thd, item_eq, item_isnull); Item_cond_or(thd, item_eq, item_isnull);
if (!abort_on_null && left_expr->element_index(i)->maybe_null) if (!abort_on_null && left_expr->element_index(i)->maybe_null)
@ -2407,7 +2410,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
&select_lex-> &select_lex->
ref_pointer_array[i], ref_pointer_array[i],
(char *)"<no matter>", (char *)"<no matter>",
(char *)"<list ref>")); &list_ref));
if (!abort_on_null && left_expr->element_index(i)->maybe_null) if (!abort_on_null && left_expr->element_index(i)->maybe_null)
{ {
disable_cond_guard_for_const_null_left_expr(i); disable_cond_guard_for_const_null_left_expr(i);
@ -2441,13 +2444,13 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
(*optimizer->get_cache())-> (*optimizer->get_cache())->
addr(i), addr(i),
(char *)"<no matter>", (char *)"<no matter>",
(char *)in_left_expr_name), &in_left_expr_name),
new (thd->mem_root) new (thd->mem_root)
Item_direct_ref(thd, &select_lex->context, Item_direct_ref(thd, &select_lex->context,
&select_lex-> &select_lex->
ref_pointer_array[i], ref_pointer_array[i],
(char *)"<no matter>", (char *)"<no matter>",
(char *)"<list ref>")); &list_ref));
if (!abort_on_null && select_lex->ref_pointer_array[i]->maybe_null) if (!abort_on_null && select_lex->ref_pointer_array[i]->maybe_null)
{ {
Item *having_col_item= Item *having_col_item=
@ -2457,8 +2460,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
Item_ref(thd, &select_lex->context, Item_ref(thd, &select_lex->context,
&select_lex->ref_pointer_array[i], &select_lex->ref_pointer_array[i],
(char *)"<no matter>", (char *)"<no matter>",
(char *)"<list ref>")); &list_ref));
item_isnull= new (thd->mem_root) item_isnull= new (thd->mem_root)
Item_func_isnull(thd, Item_func_isnull(thd,
@ -2467,7 +2469,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
&select_lex-> &select_lex->
ref_pointer_array[i], ref_pointer_array[i],
(char *)"<no matter>", (char *)"<no matter>",
(char *)"<list ref>")); &list_ref));
item= new (thd->mem_root) Item_cond_or(thd, item, item_isnull); item= new (thd->mem_root) Item_cond_or(thd, item, item_isnull);
if (left_expr->element_index(i)->maybe_null) if (left_expr->element_index(i)->maybe_null)
{ {
@ -2501,7 +2503,7 @@ Item_in_subselect::create_row_in_to_exists_cond(JOIN * join,
if (*having_item) if (*having_item)
{ {
if (!join_having) if (!join_having)
(*having_item)->name= (char*) in_having_cond; (*having_item)->name= in_having_cond;
if (fix_having(*having_item, select_lex)) if (fix_having(*having_item, select_lex))
DBUG_RETURN(true); DBUG_RETURN(true);
(*having_item)->top_level_item(); (*having_item)->top_level_item();
@ -2976,7 +2978,7 @@ bool Item_exists_subselect::exists2in_processor(void *opt_arg)
Item_direct_ref(thd, &first_select->context, Item_direct_ref(thd, &first_select->context,
(Item**)optimizer->get_cache(), (Item**)optimizer->get_cache(),
(char *)"<no matter>", (char *)"<no matter>",
(char *)in_left_expr_name); &in_left_expr_name);
if (in_subs->fix_fields(thd, optimizer->arguments() + 1)) if (in_subs->fix_fields(thd, optimizer->arguments() + 1))
{ {
res= TRUE; res= TRUE;
@ -3047,7 +3049,7 @@ bool Item_exists_subselect::exists2in_processor(void *opt_arg)
&unit->outer_select()->context, &unit->outer_select()->context,
optimizer->arguments(), optimizer->arguments(),
(char *)"<no matter>", (char *)"<no matter>",
(char *)exists_outer_expr_name)), &exists_outer_expr_name)),
optimizer) : optimizer) :
(Item *)optimizer); (Item *)optimizer);
} }
@ -3071,7 +3073,7 @@ bool Item_exists_subselect::exists2in_processor(void *opt_arg)
&unit->outer_select()->context, &unit->outer_select()->context,
optimizer->arguments()[0]->addr(i), optimizer->arguments()[0]->addr(i),
(char *)"<no matter>", (char *)"<no matter>",
(char *)exists_outer_expr_name)), &exists_outer_expr_name)),
thd->mem_root); thd->mem_root);
} }
} }
@ -4333,7 +4335,7 @@ void subselect_union_engine::print(String *str, enum_query_type query_type)
void subselect_uniquesubquery_engine::print(String *str, void subselect_uniquesubquery_engine::print(String *str,
enum_query_type query_type) enum_query_type query_type)
{ {
char *table_name= tab->table->s->table_name.str; const char *table_name= tab->table->s->table_name.str;
str->append(STRING_WITH_LEN("<primary_index_lookup>(")); str->append(STRING_WITH_LEN("<primary_index_lookup>("));
tab->ref.items[0]->print(str, query_type); tab->ref.items[0]->print(str, query_type);
str->append(STRING_WITH_LEN(" in ")); str->append(STRING_WITH_LEN(" in "));
@ -4890,7 +4892,7 @@ bool subselect_hash_sj_engine::init(List<Item> *tmp_columns, uint subquery_id)
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
char buf[32]; char buf[32];
uint len= my_snprintf(buf, sizeof(buf), "<subquery%d>", subquery_id); uint len= my_snprintf(buf, sizeof(buf), "<subquery%u>", subquery_id);
char *name; char *name;
if (!(name= (char*)thd->alloc(len + 1))) if (!(name= (char*)thd->alloc(len + 1)))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
@ -5933,10 +5935,10 @@ void Ordered_key::print(String *str)
str->append(", ("); str->append(", (");
for (i= 0; i < key_column_count - 1; i++) for (i= 0; i < key_column_count - 1; i++)
{ {
str->append(key_columns[i]->field->field_name); str->append(&key_columns[i]->field->field_name);
str->append(", "); str->append(", ");
} }
str->append(key_columns[i]->field->field_name); str->append(&key_columns[i]->field->field_name);
str->append("), "); str->append("), ");
str->append("null_bitmap: (bits="); str->append("null_bitmap: (bits=");

View File

@ -1208,9 +1208,8 @@ Field *Item_sum_hybrid::create_tmp_field(bool group, TABLE *table)
if (args[0]->type() == Item::FIELD_ITEM) if (args[0]->type() == Item::FIELD_ITEM)
{ {
field= ((Item_field*) args[0])->field; field= ((Item_field*) args[0])->field;
if ((field= create_tmp_field_from_field(table->in_use, field, &name,
if ((field= create_tmp_field_from_field(table->in_use, field, name, table, table, NULL)))
NULL)))
field->flags&= ~NOT_NULL_FLAG; field->flags&= ~NOT_NULL_FLAG;
return field; return field;
} }
@ -1223,18 +1222,25 @@ Field *Item_sum_hybrid::create_tmp_field(bool group, TABLE *table)
mem_root= table->in_use->mem_root; mem_root= table->in_use->mem_root;
switch (args[0]->field_type()) { switch (args[0]->field_type()) {
case MYSQL_TYPE_DATE: case MYSQL_TYPE_DATE:
{
field= new (mem_root) field= new (mem_root)
Field_newdate(0, maybe_null ? (uchar*)"" : 0, 0, Field::NONE, name); Field_newdate(0, maybe_null ? (uchar*)"" : 0, 0, Field::NONE,
&name);
break; break;
}
case MYSQL_TYPE_TIME: case MYSQL_TYPE_TIME:
{
field= new_Field_time(mem_root, 0, maybe_null ? (uchar*)"" : 0, 0, field= new_Field_time(mem_root, 0, maybe_null ? (uchar*)"" : 0, 0,
Field::NONE, name, decimals); Field::NONE, &name, decimals);
break; break;
}
case MYSQL_TYPE_TIMESTAMP: case MYSQL_TYPE_TIMESTAMP:
case MYSQL_TYPE_DATETIME: case MYSQL_TYPE_DATETIME:
{
field= new_Field_datetime(mem_root, 0, maybe_null ? (uchar*)"" : 0, 0, field= new_Field_datetime(mem_root, 0, maybe_null ? (uchar*)"" : 0, 0,
Field::NONE, name, decimals); Field::NONE, &name, decimals);
break; break;
}
default: default:
return Item_sum::create_tmp_field(group, table); return Item_sum::create_tmp_field(group, table);
} }
@ -1676,13 +1682,15 @@ Field *Item_sum_avg::create_tmp_field(bool group, TABLE *table)
field= new (mem_root) field= new (mem_root)
Field_string(((Item_sum_avg::result_type() == DECIMAL_RESULT) ? Field_string(((Item_sum_avg::result_type() == DECIMAL_RESULT) ?
dec_bin_size : sizeof(double)) + sizeof(longlong), dec_bin_size : sizeof(double)) + sizeof(longlong),
0, name, &my_charset_bin); 0, &name, &my_charset_bin);
} }
else if (Item_sum_avg::result_type() == DECIMAL_RESULT) else if (Item_sum_avg::result_type() == DECIMAL_RESULT)
field= Field_new_decimal::create_from_item(mem_root, this); field= Field_new_decimal::create_from_item(mem_root, this);
else else
field= new (mem_root) Field_double(max_length, maybe_null, name, decimals, {
TRUE); field= new (mem_root) Field_double(max_length, maybe_null, &name,
decimals, TRUE);
}
if (field) if (field)
field->init(table); field->init(table);
return field; return field;
@ -1910,10 +1918,12 @@ Field *Item_sum_variance::create_tmp_field(bool group, TABLE *table)
The easiest way is to do this is to store both value in a string The easiest way is to do this is to store both value in a string
and unpack on access. and unpack on access.
*/ */
field= new Field_string(sizeof(double)*2 + sizeof(longlong), 0, name, &my_charset_bin); field= new Field_string(sizeof(double)*2 + sizeof(longlong), 0,
&name, &my_charset_bin);
} }
else else
field= new Field_double(max_length, maybe_null, name, decimals, TRUE); field= new Field_double(max_length, maybe_null, &name, decimals,
TRUE);
if (field != NULL) if (field != NULL)
field->init(table); field->init(table);
@ -3356,13 +3366,13 @@ Field *Item_func_group_concat::make_string_field(TABLE *table_arg)
{ {
Field *field; Field *field;
DBUG_ASSERT(collation.collation); DBUG_ASSERT(collation.collation);
if (too_big_for_varchar()) if (too_big_for_varchar())
field= new Field_blob(max_length, field= new Field_blob(max_length,
maybe_null, name, collation.collation, TRUE); maybe_null, &name, collation.collation, TRUE);
else else
field= new Field_varstring(max_length, field= new Field_varstring(max_length,
maybe_null, name, table_arg->s, maybe_null, &name, table_arg->s, collation.collation);
collation.collation);
if (field) if (field)
field->init(table_arg); field->init(table_arg);

View File

@ -1239,7 +1239,7 @@ public:
void save_in_result_field(bool no_conversions) { DBUG_ASSERT(0); } void save_in_result_field(bool no_conversions) { DBUG_ASSERT(0); }
bool check_vcol_func_processor(void *arg) bool check_vcol_func_processor(void *arg)
{ {
return mark_unsupported_function(name, arg, VCOL_IMPOSSIBLE); return mark_unsupported_function(name.str, arg, VCOL_IMPOSSIBLE);
} }
}; };

View File

@ -13,7 +13,7 @@ Item_window_func::resolve_window_name(THD *thd)
return false; return false;
} }
DBUG_ASSERT(window_name != NULL && window_spec == NULL); DBUG_ASSERT(window_name != NULL && window_spec == NULL);
char *ref_name= window_name->str; const char *ref_name= window_name->str;
/* !TODO: Add the code to resolve ref_name in outer queries */ /* !TODO: Add the code to resolve ref_name in outer queries */
/* /*
@ -26,7 +26,7 @@ Item_window_func::resolve_window_name(THD *thd)
Window_spec *win_spec; Window_spec *win_spec;
while((win_spec= it++)) while((win_spec= it++))
{ {
char *win_spec_name= win_spec->name(); const char *win_spec_name= win_spec->name();
if (win_spec_name && if (win_spec_name &&
my_strcasecmp(system_charset_info, ref_name, win_spec_name) == 0) my_strcasecmp(system_charset_info, ref_name, win_spec_name) == 0)
{ {

View File

@ -690,12 +690,12 @@ class Item_window_func : public Item_func_or_sum
{ {
/* Window function parameters as we've got them from the parser */ /* Window function parameters as we've got them from the parser */
public: public:
LEX_STRING *window_name; LEX_CSTRING *window_name;
public: public:
Window_spec *window_spec; Window_spec *window_spec;
public: public:
Item_window_func(THD *thd, Item_sum *win_func, LEX_STRING *win_name) Item_window_func(THD *thd, Item_sum *win_func, LEX_CSTRING *win_name)
: Item_func_or_sum(thd, (Item *) win_func), : Item_func_or_sum(thd, (Item *) win_func),
window_name(win_name), window_spec(NULL), window_name(win_name), window_spec(NULL),
force_return_blank(true), force_return_blank(true),

View File

@ -2594,7 +2594,7 @@ my_xpath_parse_QName(MY_XPATH *xpath)
static int static int
my_xpath_parse_VariableReference(MY_XPATH *xpath) my_xpath_parse_VariableReference(MY_XPATH *xpath)
{ {
LEX_STRING name; LEX_CSTRING name;
int user_var; int user_var;
const char *dollar_pos; const char *dollar_pos;
THD *thd= xpath->thd; THD *thd= xpath->thd;
@ -2609,7 +2609,7 @@ my_xpath_parse_VariableReference(MY_XPATH *xpath)
name.str= (char*) xpath->prevtok.beg; name.str= (char*) xpath->prevtok.beg;
if (user_var) if (user_var)
xpath->item= new (thd->mem_root) Item_func_get_user_var(thd, name); xpath->item= new (thd->mem_root) Item_func_get_user_var(thd, &name);
else else
{ {
sp_variable *spv; sp_variable *spv;
@ -2617,10 +2617,10 @@ my_xpath_parse_VariableReference(MY_XPATH *xpath)
LEX *lex; LEX *lex;
if ((lex= thd->lex) && if ((lex= thd->lex) &&
(spc= lex->spcont) && (spc= lex->spcont) &&
(spv= spc->find_variable(name, false))) (spv= spc->find_variable(&name, false)))
{ {
Item_splocal *splocal= new (thd->mem_root) Item_splocal *splocal= new (thd->mem_root)
Item_splocal(thd, name, spv->offset, spv->sql_type(), 0); Item_splocal(thd, &name, spv->offset, spv->sql_type(), 0);
#ifndef DBUG_OFF #ifndef DBUG_OFF
if (splocal) if (splocal)
splocal->m_sp= lex->sphead; splocal->m_sp= lex->sphead;

View File

@ -99,11 +99,11 @@ void NAMED_ILIST::delete_elements(void (*free_element)(const char *name, uchar*)
/* Key cache functions */ /* Key cache functions */
LEX_STRING default_key_cache_base= {C_STRING_WITH_LEN("default")}; LEX_CSTRING default_key_cache_base= {C_STRING_WITH_LEN("default")};
KEY_CACHE zero_key_cache; ///< @@nonexistent_cache.param->value_ptr() points here KEY_CACHE zero_key_cache; ///< @@nonexistent_cache.param->value_ptr() points here
KEY_CACHE *get_key_cache(const LEX_STRING *cache_name) KEY_CACHE *get_key_cache(const LEX_CSTRING *cache_name)
{ {
if (!cache_name || ! cache_name->length) if (!cache_name || ! cache_name->length)
cache_name= &default_key_cache_base; cache_name= &default_key_cache_base;
@ -145,10 +145,10 @@ KEY_CACHE *create_key_cache(const char *name, uint length)
KEY_CACHE *get_or_create_key_cache(const char *name, uint length) KEY_CACHE *get_or_create_key_cache(const char *name, uint length)
{ {
LEX_STRING key_cache_name; LEX_CSTRING key_cache_name;
KEY_CACHE *key_cache; KEY_CACHE *key_cache;
key_cache_name.str= (char *) name; key_cache_name.str= name;
key_cache_name.length= length; key_cache_name.length= length;
if (!(key_cache= get_key_cache(&key_cache_name))) if (!(key_cache= get_key_cache(&key_cache_name)))
key_cache= create_key_cache(name, length); key_cache= create_key_cache(name, length);

View File

@ -35,12 +35,12 @@ class NAMED_ILIST: public I_List<NAMED_ILINK>
}; };
/* For key cache */ /* For key cache */
extern LEX_STRING default_key_cache_base; extern LEX_CSTRING default_key_cache_base;
extern KEY_CACHE zero_key_cache; extern KEY_CACHE zero_key_cache;
extern NAMED_ILIST key_caches; extern NAMED_ILIST key_caches;
KEY_CACHE *create_key_cache(const char *name, uint length); KEY_CACHE *create_key_cache(const char *name, uint length);
KEY_CACHE *get_key_cache(const LEX_STRING *cache_name); KEY_CACHE *get_key_cache(const LEX_CSTRING *cache_name);
KEY_CACHE *get_or_create_key_cache(const char *name, uint length); KEY_CACHE *get_or_create_key_cache(const char *name, uint length);
void free_key_cache(const char *name, KEY_CACHE *key_cache); void free_key_cache(const char *name, KEY_CACHE *key_cache);
bool process_key_caches(process_key_cache_t func, void *param); bool process_key_caches(process_key_cache_t func, void *param);

View File

@ -1012,7 +1012,7 @@ int Log_to_csv_event_handler::
{ {
TABLE_LIST table_list; TABLE_LIST table_list;
TABLE *table; TABLE *table;
LEX_STRING *UNINIT_VAR(log_name); LEX_CSTRING *UNINIT_VAR(log_name);
int result; int result;
Open_tables_backup open_tables_backup; Open_tables_backup open_tables_backup;

View File

@ -587,7 +587,7 @@ pretty_print_str(String *packet, const char *str, int len)
*/ */
static char *load_data_tmp_prefix(char *name, static char *load_data_tmp_prefix(char *name,
LEX_STRING *connection_name) LEX_CSTRING *connection_name)
{ {
name= strmov(name, PREFIX_SQL_LOAD); name= strmov(name, PREFIX_SQL_LOAD);
if (connection_name->length) if (connection_name->length)
@ -623,7 +623,7 @@ static char *load_data_tmp_prefix(char *name,
static char *slave_load_file_stem(char *buf, uint file_id, static char *slave_load_file_stem(char *buf, uint file_id,
int event_server_id, const char *ext, int event_server_id, const char *ext,
LEX_STRING *connection_name) LEX_CSTRING *connection_name)
{ {
char *res; char *res;
res= buf+ unpack_dirname(buf, slave_load_tmpdir); res= buf+ unpack_dirname(buf, slave_load_tmpdir);
@ -644,7 +644,7 @@ static char *slave_load_file_stem(char *buf, uint file_id,
Delete all temporary files used for SQL_LOAD. Delete all temporary files used for SQL_LOAD.
*/ */
static void cleanup_load_tmpdir(LEX_STRING *connection_name) static void cleanup_load_tmpdir(LEX_CSTRING *connection_name)
{ {
MY_DIR *dirp; MY_DIR *dirp;
FILEINFO *file; FILEINFO *file;
@ -3821,8 +3821,8 @@ bool Query_log_event::write()
if (thd && thd->need_binlog_invoker()) if (thd && thd->need_binlog_invoker())
{ {
LEX_STRING user; LEX_CSTRING user;
LEX_STRING host; LEX_CSTRING host;
memset(&user, 0, sizeof(user)); memset(&user, 0, sizeof(user));
memset(&host, 0, sizeof(host)); memset(&host, 0, sizeof(host));
@ -3845,7 +3845,7 @@ bool Query_log_event::write()
else else
{ {
user.str= ctx->priv_role; user.str= ctx->priv_role;
host= empty_lex_str; host= empty_clex_str;
} }
user.length= strlen(user.str); user.length= strlen(user.str);
} }
@ -4499,22 +4499,20 @@ Query_log_event::Query_log_event(const char* buf, uint event_len,
if (user.length) if (user.length)
{ {
copy_str_and_move((const char **)&(user.str), &start, user.length); copy_str_and_move(&user.str, &start, user.length);
} }
else else
{ {
user.str= (char *) start++; user.str= (char*) start;
user.str[0]= '\0'; *(start++)= 0;
} }
if (host.length) if (host.length)
{ copy_str_and_move(&host.str, &start, host.length);
copy_str_and_move((const char **)&(host.str), &start, host.length);
}
else else
{ {
host.str= (char *) start++; host.str= (char*) start;
host.str[0]= '\0'; *(start++)= 0;
} }
/** /**
@ -6559,9 +6557,9 @@ Load_log_event::Load_log_event(THD *thd_arg, sql_exchange *ex,
while ((item = li++)) while ((item = li++))
{ {
num_fields++; num_fields++;
uchar len = (uchar) strlen(item->name); uchar len= (uchar) item->name.length;
field_block_len += len + 1; field_block_len += len + 1;
fields_buf.append(item->name, len + 1); fields_buf.append(item->name.str, len + 1);
field_lens_buf.append((char*)&len, 1); field_lens_buf.append((char*)&len, 1);
} }
@ -6787,9 +6785,10 @@ void Load_log_event::set_fields(const char* affected_db,
const char* field = fields; const char* field = fields;
for (i= 0; i < num_fields; i++) for (i= 0; i < num_fields; i++)
{ {
LEX_CSTRING field_name= {field, field_lens[i] };
field_list.push_back(new (thd->mem_root) field_list.push_back(new (thd->mem_root)
Item_field(thd, context, affected_db, table_name, Item_field(thd, context, affected_db, table_name,
field), &field_name),
thd->mem_root); thd->mem_root);
field+= field_lens[i] + 1; field+= field_lens[i] + 1;
} }
@ -8906,7 +8905,7 @@ int User_var_log_event::do_apply_event(rpl_group_info *rgi)
if (!(charset= get_charset(charset_number, MYF(MY_WME)))) if (!(charset= get_charset(charset_number, MYF(MY_WME))))
DBUG_RETURN(1); DBUG_RETURN(1);
LEX_STRING user_var_name; LEX_CSTRING user_var_name;
user_var_name.str= name; user_var_name.str= name;
user_var_name.length= name_len; user_var_name.length= name_len;
double real_val; double real_val;
@ -8949,7 +8948,7 @@ int User_var_log_event::do_apply_event(rpl_group_info *rgi)
} }
} }
Item_func_set_user_var *e= new (thd->mem_root) Item_func_set_user_var(thd, user_var_name, it); Item_func_set_user_var *e= new (thd->mem_root) Item_func_set_user_var(thd, &user_var_name, it);
/* /*
Item_func_set_user_var can't substitute something else on its place => Item_func_set_user_var can't substitute something else on its place =>
0 can be passed as last argument (reference on item) 0 can be passed as last argument (reference on item)
@ -8966,7 +8965,7 @@ int User_var_log_event::do_apply_event(rpl_group_info *rgi)
a single record and with a single column. Thus, like a single record and with a single column. Thus, like
a column value, it could always have IMPLICIT derivation. a column value, it could always have IMPLICIT derivation.
*/ */
e->update_hash(val, val_len, type, charset, e->update_hash((void*) val, val_len, type, charset,
(flags & User_var_log_event::UNSIGNED_F)); (flags & User_var_log_event::UNSIGNED_F));
if (!is_deferred()) if (!is_deferred())
free_root(thd->mem_root, 0); free_root(thd->mem_root, 0);

View File

@ -2013,8 +2013,8 @@ protected:
*/ */
class Query_log_event: public Log_event class Query_log_event: public Log_event
{ {
LEX_STRING user; LEX_CSTRING user;
LEX_STRING host; LEX_CSTRING host;
protected: protected:
Log_event::Byte* data_buf; Log_event::Byte* data_buf;
public: public:
@ -3041,9 +3041,9 @@ public:
UNDEF_F= 0, UNDEF_F= 0,
UNSIGNED_F= 1 UNSIGNED_F= 1
}; };
char *name; const char *name;
uint name_len; uint name_len;
char *val; const char *val;
ulong val_len; ulong val_len;
Item_result type; Item_result type;
uint charset_number; uint charset_number;
@ -3052,8 +3052,8 @@ public:
#ifdef MYSQL_SERVER #ifdef MYSQL_SERVER
bool deferred; bool deferred;
query_id_t query_id; query_id_t query_id;
User_var_log_event(THD* thd_arg, char *name_arg, uint name_len_arg, User_var_log_event(THD* thd_arg, const char *name_arg, uint name_len_arg,
char *val_arg, ulong val_len_arg, Item_result type_arg, const char *val_arg, ulong val_len_arg, Item_result type_arg,
uint charset_number_arg, uchar flags_arg, uint charset_number_arg, uchar flags_arg,
bool using_trans, bool direct) bool using_trans, bool direct)
:Log_event(thd_arg, 0, using_trans), :Log_event(thd_arg, 0, using_trans),

View File

@ -297,6 +297,7 @@ static TYPELIB tc_heuristic_recover_typelib=
const char *first_keyword= "first", *binary_keyword= "BINARY"; const char *first_keyword= "first", *binary_keyword= "BINARY";
const char *my_localhost= "localhost", *delayed_user= "DELAYED"; const char *my_localhost= "localhost", *delayed_user= "DELAYED";
const char *quoted_string= "%`s";
bool opt_large_files= sizeof(my_off_t) > 4; bool opt_large_files= sizeof(my_off_t) > 4;
static my_bool opt_autocommit; ///< for --autocommit command-line option static my_bool opt_autocommit; ///< for --autocommit command-line option
@ -629,10 +630,10 @@ my_bool encrypt_binlog;
my_bool encrypt_tmp_disk_tables, encrypt_tmp_files; my_bool encrypt_tmp_disk_tables, encrypt_tmp_files;
/** name of reference on left expression in rewritten IN subquery */ /** name of reference on left expression in rewritten IN subquery */
const char *in_left_expr_name= "<left expr>"; const LEX_CSTRING in_left_expr_name= {STRING_WITH_LEN("<left expr>") };
/** name of additional condition */ /** name of additional condition */
const char *in_additional_cond= "<IN COND>"; const LEX_CSTRING in_having_cond= {STRING_WITH_LEN("<IN HAVING>") };
const char *in_having_cond= "<IN HAVING>"; const LEX_CSTRING in_additional_cond= {STRING_WITH_LEN("<IN COND>") };
/** Number of connection errors when selecting on the listening port */ /** Number of connection errors when selecting on the listening port */
ulong connection_errors_select= 0; ulong connection_errors_select= 0;
@ -4884,7 +4885,7 @@ static int init_default_storage_engine_impl(const char *opt_name,
return 0; return 0;
} }
LEX_STRING name= { engine_name, strlen(engine_name) }; LEX_CSTRING name= { engine_name, strlen(engine_name) };
plugin_ref plugin; plugin_ref plugin;
handlerton *hton; handlerton *hton;
if ((plugin= ha_resolve_by_name(0, &name, false))) if ((plugin= ha_resolve_by_name(0, &name, false)))
@ -5323,7 +5324,7 @@ static int init_server_components()
else else
{ {
/* fall back to the log files if tables are not present */ /* fall back to the log files if tables are not present */
LEX_STRING csv_name={C_STRING_WITH_LEN("csv")}; LEX_CSTRING csv_name={STRING_WITH_LEN("csv")};
if (!plugin_is_ready(&csv_name, MYSQL_STORAGE_ENGINE_PLUGIN)) if (!plugin_is_ready(&csv_name, MYSQL_STORAGE_ENGINE_PLUGIN))
{ {
/* purecov: begin inspected */ /* purecov: begin inspected */

View File

@ -237,7 +237,7 @@ extern const char *first_keyword, *delayed_user, *binary_keyword;
extern MYSQL_PLUGIN_IMPORT const char *my_localhost; extern MYSQL_PLUGIN_IMPORT const char *my_localhost;
extern MYSQL_PLUGIN_IMPORT const char **errmesg; /* Error messages */ extern MYSQL_PLUGIN_IMPORT const char **errmesg; /* Error messages */
extern const char *myisam_recover_options_str; extern const char *myisam_recover_options_str;
extern const char *in_left_expr_name, *in_additional_cond, *in_having_cond; extern const LEX_CSTRING in_left_expr_name, in_additional_cond, in_having_cond;
extern SHOW_VAR status_vars[]; extern SHOW_VAR status_vars[];
extern struct system_variables max_system_variables; extern struct system_variables max_system_variables;
extern struct system_status_var global_status_var; extern struct system_status_var global_status_var;
@ -270,6 +270,7 @@ extern my_bool encrypt_binlog;
extern my_bool encrypt_tmp_disk_tables, encrypt_tmp_files; extern my_bool encrypt_tmp_disk_tables, encrypt_tmp_files;
extern ulong encryption_algorithm; extern ulong encryption_algorithm;
extern const char *encryption_algorithm_names[]; extern const char *encryption_algorithm_names[];
extern const char *quoted_string;
#ifdef HAVE_PSI_INTERFACE #ifdef HAVE_PSI_INTERFACE
#ifdef HAVE_MMAP #ifdef HAVE_MMAP

View File

@ -4398,7 +4398,7 @@ static void print_partitioning_index(KEY_PART *parts, KEY_PART *parts_end)
fprintf(DBUG_FILE, "partitioning INDEX("); fprintf(DBUG_FILE, "partitioning INDEX(");
for (KEY_PART *p=parts; p != parts_end; p++) for (KEY_PART *p=parts; p != parts_end; p++)
{ {
fprintf(DBUG_FILE, "%s%s", p==parts?"":" ,", p->field->field_name); fprintf(DBUG_FILE, "%s%s", p==parts?"":" ,", p->field->field_name.str);
} }
fputs(");\n", DBUG_FILE); fputs(");\n", DBUG_FILE);
DBUG_UNLOCK_FILE; DBUG_UNLOCK_FILE;
@ -4437,7 +4437,7 @@ static void dbug_print_segment_range(SEL_ARG *arg, KEY_PART *part)
fputs(" <= ", DBUG_FILE); fputs(" <= ", DBUG_FILE);
} }
fprintf(DBUG_FILE, "%s", part->field->field_name); fprintf(DBUG_FILE, "%s", part->field->field_name.str);
if (!(arg->max_flag & NO_MAX_RANGE)) if (!(arg->max_flag & NO_MAX_RANGE))
{ {
@ -4476,7 +4476,7 @@ static void dbug_print_singlepoint_range(SEL_ARG **start, uint num)
for (SEL_ARG **arg= start; arg != end; arg++) for (SEL_ARG **arg= start; arg != end; arg++)
{ {
Field *field= (*arg)->field; Field *field= (*arg)->field;
fprintf(DBUG_FILE, "%s%s=", (arg==start)?"":", ", field->field_name); fprintf(DBUG_FILE, "%s%s=", (arg==start)?"":", ", field->field_name.str);
dbug_print_field(field); dbug_print_field(field);
} }
fputs("\n", DBUG_FILE); fputs("\n", DBUG_FILE);

View File

@ -4019,12 +4019,13 @@ SJ_TMP_TABLE::create_sj_weedout_tmp_table(THD *thd)
/* Create the field */ /* Create the field */
{ {
LEX_CSTRING field_name= {STRING_WITH_LEN("rowids") };
/* /*
For the sake of uniformity, always use Field_varstring (altough we could For the sake of uniformity, always use Field_varstring (altough we could
use Field_string for shorter keys) use Field_string for shorter keys)
*/ */
field= new Field_varstring(uniq_tuple_length_arg, FALSE, "rowids", share, field= new Field_varstring(uniq_tuple_length_arg, FALSE, &field_name,
&my_charset_bin); share, &my_charset_bin);
if (!field) if (!field)
DBUG_RETURN(0); DBUG_RETURN(0);
field->table= table; field->table= table;
@ -4894,7 +4895,7 @@ int rewrite_to_index_subquery_engine(JOIN *join)
{ {
Item *where= join->conds; Item *where= join->conds;
if (join_tab[0].type == JT_EQ_REF && if (join_tab[0].type == JT_EQ_REF &&
join_tab[0].ref.items[0]->name == in_left_expr_name) join_tab[0].ref.items[0]->name.str == in_left_expr_name.str)
{ {
remove_subq_pushed_predicates(join, &where); remove_subq_pushed_predicates(join, &where);
save_index_subquery_explain_info(join_tab, where); save_index_subquery_explain_info(join_tab, where);
@ -4908,7 +4909,7 @@ int rewrite_to_index_subquery_engine(JOIN *join)
where))); where)));
} }
else if (join_tab[0].type == JT_REF && else if (join_tab[0].type == JT_REF &&
join_tab[0].ref.items[0]->name == in_left_expr_name) join_tab[0].ref.items[0]->name.str == in_left_expr_name.str)
{ {
remove_subq_pushed_predicates(join, &where); remove_subq_pushed_predicates(join, &where);
save_index_subquery_explain_info(join_tab, where); save_index_subquery_explain_info(join_tab, where);
@ -4924,8 +4925,8 @@ int rewrite_to_index_subquery_engine(JOIN *join)
0))); 0)));
} }
} else if (join_tab[0].type == JT_REF_OR_NULL && } else if (join_tab[0].type == JT_REF_OR_NULL &&
join_tab[0].ref.items[0]->name == in_left_expr_name && join_tab[0].ref.items[0]->name.str == in_left_expr_name.str &&
join->having->name == in_having_cond) join->having->name.str == in_having_cond.str)
{ {
join_tab[0].type= JT_INDEX_SUBQUERY; join_tab[0].type= JT_INDEX_SUBQUERY;
join->error= 0; join->error= 0;
@ -4956,7 +4957,7 @@ int rewrite_to_index_subquery_engine(JOIN *join)
static Item *remove_additional_cond(Item* conds) static Item *remove_additional_cond(Item* conds)
{ {
if (conds->name == in_additional_cond) if (conds->name.str == in_additional_cond.str)
return 0; return 0;
if (conds->type() == Item::COND_ITEM) if (conds->type() == Item::COND_ITEM)
{ {
@ -4965,7 +4966,7 @@ static Item *remove_additional_cond(Item* conds)
Item *item; Item *item;
while ((item= li++)) while ((item= li++))
{ {
if (item->name == in_additional_cond) if (item->name.str == in_additional_cond.str)
{ {
li.remove(); li.remove();
if (cnd->argument_list()->elements == 1) if (cnd->argument_list()->elements == 1)

View File

@ -1843,7 +1843,7 @@ void Dep_analysis_context::dbug_print_deps()
(long)(eq_mod - equality_mods), (long)(eq_mod - equality_mods),
str.c_ptr(), str.c_ptr(),
eq_mod->field->table->table->alias.c_ptr(), eq_mod->field->table->table->alias.c_ptr(),
eq_mod->field->field->field_name); eq_mod->field->field->field_name.str);
} }
else else
{ {
@ -1867,7 +1867,7 @@ void Dep_analysis_context::dbug_print_deps()
{ {
fprintf(DBUG_FILE, " field %s.%s ->", fprintf(DBUG_FILE, " field %s.%s ->",
table_dep->table->alias.c_ptr(), table_dep->table->alias.c_ptr(),
field_dep->field->field_name); field_dep->field->field_name.str);
uint ofs= field_dep->bitmap_offset; uint ofs= field_dep->bitmap_offset;
for (uint bit= ofs; bit < ofs + n_equality_mods; bit++) for (uint bit= ofs; bit < ofs + n_equality_mods; bit++)
{ {

View File

@ -136,7 +136,7 @@ static ulonglong view_algo_from_frm(ulonglong val)
static my_bool static my_bool
write_parameter(IO_CACHE *file, uchar* base, File_option *parameter) write_parameter(IO_CACHE *file, const uchar* base, File_option *parameter)
{ {
char num_buf[20]; // buffer for numeric operations char num_buf[20]; // buffer for numeric operations
// string for numeric operations // string for numeric operations
@ -248,8 +248,9 @@ write_parameter(IO_CACHE *file, uchar* base, File_option *parameter)
my_bool my_bool
sql_create_definition_file(const LEX_STRING *dir, const LEX_STRING *file_name, sql_create_definition_file(const LEX_CSTRING *dir,
const LEX_STRING *type, const LEX_CSTRING *file_name,
const LEX_CSTRING *type,
uchar* base, File_option *parameters) uchar* base, File_option *parameters)
{ {
File handler; File handler;
@ -399,7 +400,7 @@ my_bool rename_in_schema_file(THD *thd,
*/ */
File_parser * File_parser *
sql_parse_prepare(const LEX_STRING *file_name, MEM_ROOT *mem_root, sql_parse_prepare(const LEX_CSTRING *file_name, MEM_ROOT *mem_root,
bool bad_format_errors) bool bad_format_errors)
{ {
MY_STAT stat_info; MY_STAT stat_info;
@ -598,13 +599,13 @@ read_escaped_string(const char *ptr, const char *eol, LEX_STRING *str)
const char * const char *
parse_escaped_string(const char *ptr, const char *end, MEM_ROOT *mem_root, parse_escaped_string(const char *ptr, const char *end, MEM_ROOT *mem_root,
LEX_STRING *str) LEX_CSTRING *str)
{ {
const char *eol= strchr(ptr, '\n'); const char *eol= strchr(ptr, '\n');
if (eol == 0 || eol >= end || if (eol == 0 || eol >= end ||
!(str->str= (char*) alloc_root(mem_root, (eol - ptr) + 1)) || !(str->str= (char*) alloc_root(mem_root, (eol - ptr) + 1)) ||
read_escaped_string(ptr, eol, str)) read_escaped_string(ptr, eol, (LEX_STRING*) str))
return 0; return 0;
return eol+1; return eol+1;
@ -802,7 +803,7 @@ File_parser::parse(uchar* base, MEM_ROOT *mem_root,
case FILE_OPTIONS_ESTRING: case FILE_OPTIONS_ESTRING:
{ {
if (!(ptr= parse_escaped_string(ptr, end, mem_root, if (!(ptr= parse_escaped_string(ptr, end, mem_root,
(LEX_STRING *) (LEX_CSTRING *)
(base + parameter->offset)))) (base + parameter->offset))))
{ {
my_error(ER_FPARSER_ERROR_IN_PARAMETER, MYF(0), my_error(ER_FPARSER_ERROR_IN_PARAMETER, MYF(0),

View File

@ -42,7 +42,7 @@ enum file_opt_type {
struct File_option struct File_option
{ {
LEX_STRING name; /**< Name of the option */ LEX_CSTRING name; /**< Name of the option */
my_ptrdiff_t offset; /**< offset to base address of value */ my_ptrdiff_t offset; /**< offset to base address of value */
file_opt_type type; /**< Option type */ file_opt_type type; /**< Option type */
}; };
@ -82,15 +82,16 @@ bool get_file_options_ulllist(const char *&ptr, const char *end,
const char * const char *
parse_escaped_string(const char *ptr, const char *end, MEM_ROOT *mem_root, parse_escaped_string(const char *ptr, const char *end, MEM_ROOT *mem_root,
LEX_STRING *str); LEX_CSTRING *str);
class File_parser; class File_parser;
File_parser *sql_parse_prepare(const LEX_STRING *file_name, File_parser *sql_parse_prepare(const LEX_CSTRING *file_name,
MEM_ROOT *mem_root, bool bad_format_errors); MEM_ROOT *mem_root, bool bad_format_errors);
my_bool my_bool
sql_create_definition_file(const LEX_STRING *dir, const LEX_STRING *file_name, sql_create_definition_file(const LEX_CSTRING *dir,
const LEX_STRING *type, const LEX_CSTRING *file_name,
const LEX_CSTRING *type,
uchar* base, File_option *parameters); uchar* base, File_option *parameters);
my_bool rename_in_schema_file(THD *thd, my_bool rename_in_schema_file(THD *thd,
const char *schema, const char *old_name, const char *schema, const char *old_name,
@ -99,19 +100,19 @@ my_bool rename_in_schema_file(THD *thd,
class File_parser: public Sql_alloc class File_parser: public Sql_alloc
{ {
char *start, *end; char *start, *end;
LEX_STRING file_type; LEX_CSTRING file_type;
bool content_ok; bool content_ok;
public: public:
File_parser() :start(0), end(0), content_ok(0) File_parser() :start(0), end(0), content_ok(0)
{ file_type.str= 0; file_type.length= 0; } { file_type.str= 0; file_type.length= 0; }
bool ok() { return content_ok; } bool ok() { return content_ok; }
const LEX_STRING *type() const { return &file_type; } const LEX_CSTRING *type() const { return &file_type; }
my_bool parse(uchar* base, MEM_ROOT *mem_root, my_bool parse(uchar* base, MEM_ROOT *mem_root,
struct File_option *parameters, uint required, struct File_option *parameters, uint required,
Unknown_key_hook *hook) const; Unknown_key_hook *hook) const;
friend File_parser *sql_parse_prepare(const LEX_STRING *file_name, friend File_parser *sql_parse_prepare(const LEX_CSTRING *file_name,
MEM_ROOT *mem_root, MEM_ROOT *mem_root,
bool bad_format_errors); bool bad_format_errors);
}; };

View File

@ -96,14 +96,14 @@ public:
ha_rows part_max_rows; ha_rows part_max_rows;
ha_rows part_min_rows; ha_rows part_min_rows;
longlong range_value; longlong range_value;
char *partition_name; const char *partition_name;
char *tablespace_name; const char *tablespace_name;
struct st_ddl_log_memory_entry *log_entry; struct st_ddl_log_memory_entry *log_entry;
char* part_comment; const char* part_comment;
char* data_file_name; const char* data_file_name;
char* index_file_name; const char* index_file_name;
handlerton *engine_type; handlerton *engine_type;
LEX_STRING connect_string; LEX_CSTRING connect_string;
enum partition_state part_state; enum partition_state part_state;
uint16 nodegroup_id; uint16 nodegroup_id;
bool has_null_value; bool has_null_value;
@ -115,7 +115,7 @@ public:
partition_name(NULL), tablespace_name(NULL), partition_name(NULL), tablespace_name(NULL),
log_entry(NULL), part_comment(NULL), log_entry(NULL), part_comment(NULL),
data_file_name(NULL), index_file_name(NULL), data_file_name(NULL), index_file_name(NULL),
engine_type(NULL), connect_string(null_lex_str), part_state(PART_NORMAL), engine_type(NULL), connect_string(null_clex_str), part_state(PART_NORMAL),
nodegroup_id(UNDEF_NODEGROUP), has_null_value(FALSE), nodegroup_id(UNDEF_NODEGROUP), has_null_value(FALSE),
signed_flag(FALSE), max_value(FALSE) signed_flag(FALSE), max_value(FALSE)
{ {
@ -129,7 +129,7 @@ public:
data_file_name(part_elem->data_file_name), data_file_name(part_elem->data_file_name),
index_file_name(part_elem->index_file_name), index_file_name(part_elem->index_file_name),
engine_type(part_elem->engine_type), engine_type(part_elem->engine_type),
connect_string(null_lex_str), connect_string(null_clex_str),
part_state(part_elem->part_state), part_state(part_elem->part_state),
nodegroup_id(part_elem->nodegroup_id), nodegroup_id(part_elem->nodegroup_id),
has_null_value(FALSE) has_null_value(FALSE)

View File

@ -562,10 +562,11 @@ bool partition_info::set_up_defaults_for_partitioning(THD *thd, handler *file,
Check that the user haven't defined the same field twice in Check that the user haven't defined the same field twice in
key or column list partitioning. key or column list partitioning.
*/ */
char* partition_info::find_duplicate_field()
const char* partition_info::find_duplicate_field()
{ {
char *field_name_outer, *field_name_inner; const char *field_name_outer, *field_name_inner;
List_iterator<char> it_outer(part_field_list); List_iterator<const char> it_outer(part_field_list);
uint num_fields= part_field_list.elements; uint num_fields= part_field_list.elements;
uint i,j; uint i,j;
DBUG_ENTER("partition_info::find_duplicate_field"); DBUG_ENTER("partition_info::find_duplicate_field");
@ -573,7 +574,7 @@ char* partition_info::find_duplicate_field()
for (i= 0; i < num_fields; i++) for (i= 0; i < num_fields; i++)
{ {
field_name_outer= it_outer++; field_name_outer= it_outer++;
List_iterator<char> it_inner(part_field_list); List_iterator<const char> it_inner(part_field_list);
for (j= 0; j < num_fields; j++) for (j= 0; j < num_fields; j++)
{ {
field_name_inner= it_inner++; field_name_inner= it_inner++;
@ -1382,7 +1383,7 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type,
handlerton *table_engine= default_engine_type; handlerton *table_engine= default_engine_type;
uint i, tot_partitions; uint i, tot_partitions;
bool result= TRUE, table_engine_set; bool result= TRUE, table_engine_set;
char *same_name; const char *same_name;
DBUG_ENTER("partition_info::check_partition_info"); DBUG_ENTER("partition_info::check_partition_info");
DBUG_ASSERT(default_engine_type != partition_hton); DBUG_ASSERT(default_engine_type != partition_hton);
@ -2649,9 +2650,9 @@ bool partition_info::has_same_partitioning(partition_info *new_part_info)
} }
/* Check that it will use the same fields in KEY (fields) list. */ /* Check that it will use the same fields in KEY (fields) list. */
List_iterator<char> old_field_name_it(part_field_list); List_iterator<const char> old_field_name_it(part_field_list);
List_iterator<char> new_field_name_it(new_part_info->part_field_list); List_iterator<const char> new_field_name_it(new_part_info->part_field_list);
char *old_name, *new_name; const char *old_name, *new_name;
while ((old_name= old_field_name_it++)) while ((old_name= old_field_name_it++))
{ {
new_name= new_field_name_it++; new_name= new_field_name_it++;
@ -2664,9 +2665,9 @@ bool partition_info::has_same_partitioning(partition_info *new_part_info)
if (is_sub_partitioned()) if (is_sub_partitioned())
{ {
/* Check that it will use the same fields in KEY subpart fields list. */ /* Check that it will use the same fields in KEY subpart fields list. */
List_iterator<char> old_field_name_it(subpart_field_list); List_iterator<const char> old_field_name_it(subpart_field_list);
List_iterator<char> new_field_name_it(new_part_info->subpart_field_list); List_iterator<const char> new_field_name_it(new_part_info->subpart_field_list);
char *old_name, *new_name; const char *old_name, *new_name;
while ((old_name= old_field_name_it++)) while ((old_name= old_field_name_it++))
{ {
new_name= new_field_name_it++; new_name= new_field_name_it++;

View File

@ -43,8 +43,8 @@ public:
List<partition_element> partitions; List<partition_element> partitions;
List<partition_element> temp_partitions; List<partition_element> temp_partitions;
List<char> part_field_list; List<const char> part_field_list;
List<char> subpart_field_list; List<const char> subpart_field_list;
/* /*
If there is no subpartitioning, use only this func to get partition ids. If there is no subpartitioning, use only this func to get partition ids.
@ -306,7 +306,7 @@ public:
bool set_up_defaults_for_partitioning(THD *thd, handler *file, bool set_up_defaults_for_partitioning(THD *thd, handler *file,
HA_CREATE_INFO *info, HA_CREATE_INFO *info,
uint start_no); uint start_no);
char *find_duplicate_field(); const char *find_duplicate_field();
char *find_duplicate_name(); char *find_duplicate_name();
bool check_engine_mix(handlerton *engine_type, bool default_engine); bool check_engine_mix(handlerton *engine_type, bool default_engine);
bool check_range_constants(THD *thd); bool check_range_constants(THD *thd);

View File

@ -89,7 +89,7 @@ setup_procedure(THD *thd,ORDER *param,select_result *result,
for (i=0 ; i < array_elements(sql_procs) ; i++) for (i=0 ; i < array_elements(sql_procs) ; i++)
{ {
if (!my_strcasecmp(system_charset_info, if (!my_strcasecmp(system_charset_info,
(*param->item)->name,sql_procs[i].name)) (*param->item)->name.str, sql_procs[i].name))
{ {
Procedure *proc=(*sql_procs[i].init)(thd,param,result,field_list); Procedure *proc=(*sql_procs[i].init)(thd,param,result,field_list);
*error= !proc; *error= !proc;

View File

@ -40,7 +40,8 @@ class Item_proc :public Item
public: public:
Item_proc(THD *thd, const char *name_par): Item(thd) Item_proc(THD *thd, const char *name_par): Item(thd)
{ {
this->name=(char*) name_par; this->name.str= name_par;
this->name.length= strlen(name_par);
} }
enum Type type() const { return Item::PROC_ITEM; } enum Type type() const { return Item::PROC_ITEM; }
virtual void set(double nr)=0; virtual void set(double nr)=0;

View File

@ -840,9 +840,9 @@ bool Protocol::send_result_set_metadata(List<Item> *list, uint flags)
cs, thd_charset) || cs, thd_charset) ||
prot.store(field.org_table_name, (uint) strlen(field.org_table_name), prot.store(field.org_table_name, (uint) strlen(field.org_table_name),
cs, thd_charset) || cs, thd_charset) ||
prot.store(field.col_name, (uint) strlen(field.col_name), prot.store(field.col_name.str, (uint) field.col_name.length,
cs, thd_charset) || cs, thd_charset) ||
prot.store(field.org_col_name, (uint) strlen(field.org_col_name), prot.store(field.org_col_name.str, (uint) field.org_col_name.length,
cs, thd_charset) || cs, thd_charset) ||
local_packet->realloc(local_packet->length()+12)) local_packet->realloc(local_packet->length()+12))
goto err; goto err;
@ -898,7 +898,7 @@ bool Protocol::send_result_set_metadata(List<Item> *list, uint flags)
{ {
if (prot.store(field.table_name, (uint) strlen(field.table_name), if (prot.store(field.table_name, (uint) strlen(field.table_name),
cs, thd_charset) || cs, thd_charset) ||
prot.store(field.col_name, (uint) strlen(field.col_name), prot.store(field.col_name.str, (uint) field.col_name.length,
cs, thd_charset) || cs, thd_charset) ||
local_packet->realloc(local_packet->length()+10)) local_packet->realloc(local_packet->length()+10))
goto err; goto err;

View File

@ -981,24 +981,24 @@ rpl_slave_state::domain_to_gtid(uint32 domain_id, rpl_gtid *out_gtid)
Returns 0 on ok, non-zero on parse error. Returns 0 on ok, non-zero on parse error.
*/ */
static int static int
gtid_parser_helper(char **ptr, char *end, rpl_gtid *out_gtid) gtid_parser_helper(const char **ptr, const char *end, rpl_gtid *out_gtid)
{ {
char *q; char *q;
char *p= *ptr; const char *p= *ptr;
uint64 v1, v2, v3; uint64 v1, v2, v3;
int err= 0; int err= 0;
q= end; q= (char*) end;
v1= (uint64)my_strtoll10(p, &q, &err); v1= (uint64)my_strtoll10(p, &q, &err);
if (err != 0 || v1 > (uint32)0xffffffff || q == end || *q != '-') if (err != 0 || v1 > (uint32)0xffffffff || q == end || *q != '-')
return 1; return 1;
p= q+1; p= q+1;
q= end; q= (char*) end;
v2= (uint64)my_strtoll10(p, &q, &err); v2= (uint64)my_strtoll10(p, &q, &err);
if (err != 0 || v2 > (uint32)0xffffffff || q == end || *q != '-') if (err != 0 || v2 > (uint32)0xffffffff || q == end || *q != '-')
return 1; return 1;
p= q+1; p= q+1;
q= end; q= (char*) end;
v3= (uint64)my_strtoll10(p, &q, &err); v3= (uint64)my_strtoll10(p, &q, &err);
if (err != 0) if (err != 0)
return 1; return 1;
@ -1014,8 +1014,8 @@ gtid_parser_helper(char **ptr, char *end, rpl_gtid *out_gtid)
rpl_gtid * rpl_gtid *
gtid_parse_string_to_list(const char *str, size_t str_len, uint32 *out_len) gtid_parse_string_to_list(const char *str, size_t str_len, uint32 *out_len)
{ {
char *p= const_cast<char *>(str); const char *p= const_cast<char *>(str);
char *end= p + str_len; const char *end= p + str_len;
uint32 len= 0, alloc_len= 5; uint32 len= 0, alloc_len= 5;
rpl_gtid *list= NULL; rpl_gtid *list= NULL;
@ -1060,10 +1060,10 @@ gtid_parse_string_to_list(const char *str, size_t str_len, uint32 *out_len)
Returns 0 if ok, non-zero if error. Returns 0 if ok, non-zero if error.
*/ */
int int
rpl_slave_state::load(THD *thd, char *state_from_master, size_t len, rpl_slave_state::load(THD *thd, const char *state_from_master, size_t len,
bool reset, bool in_statement) bool reset, bool in_statement)
{ {
char *end= state_from_master + len; const char *end= state_from_master + len;
if (reset) if (reset)
{ {
@ -1500,7 +1500,7 @@ rpl_binlog_state::read_from_iocache(IO_CACHE *src)
{ {
/* 10-digit - 10-digit - 20-digit \n \0 */ /* 10-digit - 10-digit - 20-digit \n \0 */
char buf[10+1+10+1+20+1+1]; char buf[10+1+10+1+20+1+1];
char *p, *end; const char *p, *end;
rpl_gtid gtid; rpl_gtid gtid;
int res= 0; int res= 0;
@ -1763,9 +1763,9 @@ slave_connection_state::~slave_connection_state()
*/ */
int int
slave_connection_state::load(char *slave_request, size_t len) slave_connection_state::load(const char *slave_request, size_t len)
{ {
char *p, *end; const char *p, *end;
uchar *rec; uchar *rec;
rpl_gtid *gtid; rpl_gtid *gtid;
const entry *e; const entry *e;
@ -1779,7 +1779,7 @@ slave_connection_state::load(char *slave_request, size_t len)
{ {
if (!(rec= (uchar *)my_malloc(sizeof(entry), MYF(MY_WME)))) if (!(rec= (uchar *)my_malloc(sizeof(entry), MYF(MY_WME))))
{ {
my_error(ER_OUTOFMEMORY, MYF(0), sizeof(*gtid)); my_error(ER_OUTOFMEMORY, MYF(0), (int) sizeof(*gtid));
return 1; return 1;
} }
gtid= &((entry *)rec)->gtid; gtid= &((entry *)rec)->gtid;
@ -2399,7 +2399,7 @@ gtid_waiting::get_entry(uint32 domain_id)
if (!(e= (hash_element *)my_malloc(sizeof(*e), MYF(MY_WME)))) if (!(e= (hash_element *)my_malloc(sizeof(*e), MYF(MY_WME))))
{ {
my_error(ER_OUTOFMEMORY, MYF(0), sizeof(*e)); my_error(ER_OUTOFMEMORY, MYF(0), (int) sizeof(*e));
return NULL; return NULL;
} }

View File

@ -181,7 +181,7 @@ struct rpl_slave_state
bool sort); bool sort);
int tostring(String *dest, rpl_gtid *extra_gtids, uint32 num_extra); int tostring(String *dest, rpl_gtid *extra_gtids, uint32 num_extra);
bool domain_to_gtid(uint32 domain_id, rpl_gtid *out_gtid); bool domain_to_gtid(uint32 domain_id, rpl_gtid *out_gtid);
int load(THD *thd, char *state_from_master, size_t len, bool reset, int load(THD *thd, const char *state_from_master, size_t len, bool reset,
bool in_statement); bool in_statement);
bool is_empty(); bool is_empty();
@ -287,7 +287,7 @@ struct slave_connection_state
~slave_connection_state(); ~slave_connection_state();
void reset() { my_hash_reset(&hash); } void reset() { my_hash_reset(&hash); }
int load(char *slave_request, size_t len); int load(const char *slave_request, size_t len);
int load(const rpl_gtid *gtid_list, uint32 count); int load(const rpl_gtid *gtid_list, uint32 count);
int load(rpl_slave_state *state, rpl_gtid *extra_gtids, uint32 num_extra); int load(rpl_slave_state *state, rpl_gtid *extra_gtids, uint32 num_extra);
rpl_gtid *find(uint32 domain_id); rpl_gtid *find(uint32 domain_id);

View File

@ -28,7 +28,7 @@
static void init_master_log_pos(Master_info* mi); static void init_master_log_pos(Master_info* mi);
Master_info::Master_info(LEX_STRING *connection_name_arg, Master_info::Master_info(LEX_CSTRING *connection_name_arg,
bool is_slave_recovery) bool is_slave_recovery)
:Slave_reporting_capability("I/O"), :Slave_reporting_capability("I/O"),
ssl(0), ssl_verify_server_cert(1), fd(-1), io_thd(0), ssl(0), ssl_verify_server_cert(1), fd(-1), io_thd(0),
@ -44,6 +44,7 @@ Master_info::Master_info(LEX_STRING *connection_name_arg,
in_start_all_slaves(0), in_stop_all_slaves(0), in_start_all_slaves(0), in_stop_all_slaves(0),
users(0), killed(0) users(0), killed(0)
{ {
char *tmp;
host[0] = 0; user[0] = 0; password[0] = 0; host[0] = 0; user[0] = 0; password[0] = 0;
ssl_ca[0]= 0; ssl_capath[0]= 0; ssl_cert[0]= 0; ssl_ca[0]= 0; ssl_capath[0]= 0; ssl_cert[0]= 0;
ssl_cipher[0]= 0; ssl_key[0]= 0; ssl_cipher[0]= 0; ssl_key[0]= 0;
@ -55,16 +56,14 @@ Master_info::Master_info(LEX_STRING *connection_name_arg,
*/ */
connection_name.length= cmp_connection_name.length= connection_name.length= cmp_connection_name.length=
connection_name_arg->length; connection_name_arg->length;
if ((connection_name.str= (char*) my_malloc(connection_name_arg->length*2+2, if ((connection_name.str= tmp= (char*)
MYF(MY_WME)))) my_malloc(connection_name_arg->length*2+2, MYF(MY_WME))))
{ {
cmp_connection_name.str= (connection_name.str + strmake(tmp, connection_name_arg->str, connection_name.length);
connection_name_arg->length+1); tmp+= connection_name_arg->length+1;
strmake(connection_name.str, connection_name_arg->str, cmp_connection_name.str= tmp;
connection_name.length); memcpy(tmp, connection_name_arg->str, connection_name.length+1);
memcpy(cmp_connection_name.str, connection_name_arg->str, my_casedn_str(system_charset_info, tmp);
connection_name.length+1);
my_casedn_str(system_charset_info, cmp_connection_name.str);
} }
/* /*
When MySQL restarted, all Rpl_filter settings which aren't in the my.cnf When MySQL restarted, all Rpl_filter settings which aren't in the my.cnf
@ -124,7 +123,7 @@ Master_info::~Master_info()
#endif #endif
rpl_filters.delete_element(connection_name.str, connection_name.length, rpl_filters.delete_element(connection_name.str, connection_name.length,
(void (*)(const char*, uchar*)) free_rpl_filter); (void (*)(const char*, uchar*)) free_rpl_filter);
my_free(connection_name.str); my_free(const_cast<char*>(connection_name.str));
delete_dynamic(&ignore_server_ids); delete_dynamic(&ignore_server_ids);
mysql_mutex_destroy(&run_lock); mysql_mutex_destroy(&run_lock);
mysql_mutex_destroy(&data_lock); mysql_mutex_destroy(&data_lock);
@ -901,7 +900,7 @@ void free_key_master_info(Master_info *mi)
1 error 1 error
*/ */
bool check_master_connection_name(LEX_STRING *name) bool check_master_connection_name(LEX_CSTRING *name)
{ {
if (name->length >= MAX_CONNECTION_NAME) if (name->length >= MAX_CONNECTION_NAME)
return 1; return 1;
@ -931,7 +930,7 @@ bool check_master_connection_name(LEX_STRING *name)
void create_logfile_name_with_suffix(char *res_file_name, size_t length, void create_logfile_name_with_suffix(char *res_file_name, size_t length,
const char *info_file, bool append, const char *info_file, bool append,
LEX_STRING *suffix) LEX_CSTRING *suffix)
{ {
char buff[MAX_CONNECTION_NAME+1], char buff[MAX_CONNECTION_NAME+1],
res[MAX_CONNECTION_NAME * MAX_FILENAME_MBWIDTH+1], *p; res[MAX_CONNECTION_NAME * MAX_FILENAME_MBWIDTH+1], *p;
@ -1124,7 +1123,7 @@ bool Master_info_index::init_all_master_info()
while (!init_strvar_from_file(sign, sizeof(sign), while (!init_strvar_from_file(sign, sizeof(sign),
&index_file, NULL)) &index_file, NULL))
{ {
LEX_STRING connection_name; LEX_CSTRING connection_name;
Master_info *mi; Master_info *mi;
char buf_master_info_file[FN_REFLEN]; char buf_master_info_file[FN_REFLEN];
char buf_relay_log_info_file[FN_REFLEN]; char buf_relay_log_info_file[FN_REFLEN];
@ -1253,7 +1252,7 @@ error:
/* Write new master.info to master.info.index File */ /* Write new master.info to master.info.index File */
bool Master_info_index::write_master_name_to_index_file(LEX_STRING *name, bool Master_info_index::write_master_name_to_index_file(LEX_CSTRING *name,
bool do_sync) bool do_sync)
{ {
DBUG_ASSERT(my_b_inited(&index_file) != 0); DBUG_ASSERT(my_b_inited(&index_file) != 0);
@ -1290,7 +1289,7 @@ bool Master_info_index::write_master_name_to_index_file(LEX_STRING *name,
WARN_LEVEL_ERROR-> Issue error if not exists WARN_LEVEL_ERROR-> Issue error if not exists
*/ */
Master_info *get_master_info(const LEX_STRING *connection_name, Master_info *get_master_info(const LEX_CSTRING *connection_name,
Sql_condition::enum_warning_level warning) Sql_condition::enum_warning_level warning)
{ {
Master_info *mi; Master_info *mi;
@ -1356,7 +1355,7 @@ void Master_info::release()
*/ */
Master_info * Master_info *
Master_info_index::get_master_info(const LEX_STRING *connection_name, Master_info_index::get_master_info(const LEX_CSTRING *connection_name,
Sql_condition::enum_warning_level warning) Sql_condition::enum_warning_level warning)
{ {
Master_info *mi; Master_info *mi;
@ -1387,7 +1386,7 @@ Master_info_index::get_master_info(const LEX_STRING *connection_name,
/* Check Master_host & Master_port is duplicated or not */ /* Check Master_host & Master_port is duplicated or not */
bool Master_info_index::check_duplicate_master_info(LEX_STRING *name_arg, bool Master_info_index::check_duplicate_master_info(LEX_CSTRING *name_arg,
const char *host, const char *host,
uint port) uint port)
{ {
@ -1917,7 +1916,7 @@ char *Domain_id_filter::as_string(enum_list_type type)
{ {
ulong domain_id; ulong domain_id;
get_dynamic(ids, (void *) &domain_id, i); get_dynamic(ids, (void *) &domain_id, i);
cur_len+= my_snprintf(buf + cur_len, sz, " %u", domain_id); cur_len+= my_snprintf(buf + cur_len, sz, " %lu", domain_id);
sz-= cur_len; sz-= cur_len;
} }
return buf; return buf;

View File

@ -172,7 +172,7 @@ class Master_info : public Slave_reporting_capability
USE_GTID_NO= 0, USE_GTID_CURRENT_POS= 1, USE_GTID_SLAVE_POS= 2 USE_GTID_NO= 0, USE_GTID_CURRENT_POS= 1, USE_GTID_SLAVE_POS= 2
}; };
Master_info(LEX_STRING *connection_name, bool is_slave_recovery); Master_info(LEX_CSTRING *connection_name, bool is_slave_recovery);
~Master_info(); ~Master_info();
bool shall_ignore_server_id(ulong s_id); bool shall_ignore_server_id(ulong s_id);
void clear_in_memory_info(bool all); void clear_in_memory_info(bool all);
@ -197,8 +197,8 @@ class Master_info : public Slave_reporting_capability
char host[HOSTNAME_LENGTH*SYSTEM_CHARSET_MBMAXLEN+1]; char host[HOSTNAME_LENGTH*SYSTEM_CHARSET_MBMAXLEN+1];
char user[USERNAME_LENGTH+1]; char user[USERNAME_LENGTH+1];
char password[MAX_PASSWORD_LENGTH*SYSTEM_CHARSET_MBMAXLEN+1]; char password[MAX_PASSWORD_LENGTH*SYSTEM_CHARSET_MBMAXLEN+1];
LEX_STRING connection_name; /* User supplied connection name */ LEX_CSTRING connection_name; /* User supplied connection name */
LEX_STRING cmp_connection_name; /* Connection name in lower case */ LEX_CSTRING cmp_connection_name; /* Connection name in lower case */
bool ssl; // enables use of SSL connection if true bool ssl; // enables use of SSL connection if true
char ssl_ca[FN_REFLEN], ssl_capath[FN_REFLEN], ssl_cert[FN_REFLEN]; char ssl_ca[FN_REFLEN], ssl_capath[FN_REFLEN], ssl_cert[FN_REFLEN];
char ssl_cipher[FN_REFLEN], ssl_key[FN_REFLEN]; char ssl_cipher[FN_REFLEN], ssl_key[FN_REFLEN];
@ -342,14 +342,14 @@ public:
HASH master_info_hash; HASH master_info_hash;
bool init_all_master_info(); bool init_all_master_info();
bool write_master_name_to_index_file(LEX_STRING *connection_name, bool write_master_name_to_index_file(LEX_CSTRING *connection_name,
bool do_sync); bool do_sync);
bool check_duplicate_master_info(LEX_STRING *connection_name, bool check_duplicate_master_info(LEX_CSTRING *connection_name,
const char *host, uint port); const char *host, uint port);
bool add_master_info(Master_info *mi, bool write_to_file); bool add_master_info(Master_info *mi, bool write_to_file);
bool remove_master_info(Master_info *mi); bool remove_master_info(Master_info *mi);
Master_info *get_master_info(const LEX_STRING *connection_name, Master_info *get_master_info(const LEX_CSTRING *connection_name,
Sql_condition::enum_warning_level warning); Sql_condition::enum_warning_level warning);
bool start_all_slaves(THD *thd); bool start_all_slaves(THD *thd);
bool stop_all_slaves(THD *thd); bool stop_all_slaves(THD *thd);
@ -366,13 +366,13 @@ public:
}; };
Master_info *get_master_info(const LEX_STRING *connection_name, Master_info *get_master_info(const LEX_CSTRING *connection_name,
Sql_condition::enum_warning_level warning); Sql_condition::enum_warning_level warning);
bool check_master_connection_name(LEX_STRING *name); bool check_master_connection_name(LEX_CSTRING *name);
void create_logfile_name_with_suffix(char *res_file_name, size_t length, void create_logfile_name_with_suffix(char *res_file_name, size_t length,
const char *info_file, const char *info_file,
bool append, bool append,
LEX_STRING *suffix); LEX_CSTRING *suffix);
uchar *get_key_master_info(Master_info *mi, size_t *length, uchar *get_key_master_info(Master_info *mi, size_t *length,
my_bool not_used __attribute__((unused))); my_bool not_used __attribute__((unused)));

View File

@ -107,7 +107,7 @@ pack_row(TABLE *table, MY_BITMAP const* cols,
field->max_data_length()); field->max_data_length());
DBUG_PRINT("debug", ("field: %s; real_type: %d, pack_ptr: 0x%lx;" DBUG_PRINT("debug", ("field: %s; real_type: %d, pack_ptr: 0x%lx;"
" pack_ptr':0x%lx; bytes: %d", " pack_ptr':0x%lx; bytes: %d",
field->field_name, field->real_type(), field->field_name.str, field->real_type(),
(ulong) old_pack_ptr, (ulong) pack_ptr, (ulong) old_pack_ptr, (ulong) pack_ptr,
(int) (pack_ptr - old_pack_ptr))); (int) (pack_ptr - old_pack_ptr)));
DBUG_DUMP("packed_data", old_pack_ptr, pack_ptr - old_pack_ptr); DBUG_DUMP("packed_data", old_pack_ptr, pack_ptr - old_pack_ptr);
@ -254,7 +254,7 @@ unpack_row(rpl_group_info *rgi,
conv_field ? conv_field : *field_ptr; conv_field ? conv_field : *field_ptr;
DBUG_PRINT("debug", ("Conversion %srequired for field '%s' (#%ld)", DBUG_PRINT("debug", ("Conversion %srequired for field '%s' (#%ld)",
conv_field ? "" : "not ", conv_field ? "" : "not ",
(*field_ptr)->field_name, (*field_ptr)->field_name.str,
(long) (field_ptr - begin_ptr))); (long) (field_ptr - begin_ptr)));
DBUG_ASSERT(f != NULL); DBUG_ASSERT(f != NULL);
@ -305,7 +305,7 @@ unpack_row(rpl_group_info *rgi,
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_BAD_NULL_ERROR, ER_BAD_NULL_ERROR,
ER_THD(thd, ER_BAD_NULL_ERROR), ER_THD(thd, ER_BAD_NULL_ERROR),
f->field_name); f->field_name.str);
} }
} }
else else
@ -323,7 +323,7 @@ unpack_row(rpl_group_info *rgi,
pack_ptr= f->unpack(f->ptr, pack_ptr, row_end, metadata); pack_ptr= f->unpack(f->ptr, pack_ptr, row_end, metadata);
DBUG_PRINT("debug", ("field: %s; metadata: 0x%x;" DBUG_PRINT("debug", ("field: %s; metadata: 0x%x;"
" pack_ptr: 0x%lx; pack_ptr': 0x%lx; bytes: %d", " pack_ptr: 0x%lx; pack_ptr': 0x%lx; bytes: %d",
f->field_name, metadata, f->field_name.str, metadata,
(ulong) old_pack_ptr, (ulong) pack_ptr, (ulong) old_pack_ptr, (ulong) pack_ptr,
(int) (pack_ptr - old_pack_ptr))); (int) (pack_ptr - old_pack_ptr)));
if (!pack_ptr) if (!pack_ptr)
@ -338,7 +338,7 @@ unpack_row(rpl_group_info *rgi,
WSREP_WARN("ROW event unpack field: %s metadata: 0x%x;" WSREP_WARN("ROW event unpack field: %s metadata: 0x%x;"
" pack_ptr: 0x%lx; conv_table %p conv_field %p table %s" " pack_ptr: 0x%lx; conv_table %p conv_field %p table %s"
" row_end: 0x%lx", " row_end: 0x%lx",
f->field_name, metadata, f->field_name.str, metadata,
(ulong) old_pack_ptr, conv_table, conv_field, (ulong) old_pack_ptr, conv_table, conv_field,
(table_found) ? "found" : "not found", (ulong)row_end (table_found) ? "found" : "not found", (ulong)row_end
); );
@ -347,7 +347,7 @@ unpack_row(rpl_group_info *rgi,
rgi->rli->report(ERROR_LEVEL, ER_SLAVE_CORRUPT_EVENT, rgi->rli->report(ERROR_LEVEL, ER_SLAVE_CORRUPT_EVENT,
rgi->gtid_info(), rgi->gtid_info(),
"Could not read field '%s' of table '%s.%s'", "Could not read field '%s' of table '%s.%s'",
f->field_name, table->s->db.str, f->field_name.str, table->s->db.str,
table->s->table_name.str); table->s->table_name.str);
DBUG_RETURN(HA_ERR_CORRUPT_EVENT); DBUG_RETURN(HA_ERR_CORRUPT_EVENT);
} }
@ -370,7 +370,7 @@ unpack_row(rpl_group_info *rgi,
conv_field->sql_type(source_type); conv_field->sql_type(source_type);
conv_field->val_str(&value_string); conv_field->val_str(&value_string);
DBUG_PRINT("debug", ("Copying field '%s' of type '%s' with value '%s'", DBUG_PRINT("debug", ("Copying field '%s' of type '%s' with value '%s'",
(*field_ptr)->field_name, (*field_ptr)->field_name.str,
source_type.c_ptr_safe(), value_string.c_ptr_safe())); source_type.c_ptr_safe(), value_string.c_ptr_safe()));
#endif #endif
copy.set(*field_ptr, f, TRUE); copy.set(*field_ptr, f, TRUE);
@ -381,7 +381,7 @@ unpack_row(rpl_group_info *rgi,
(*field_ptr)->sql_type(target_type); (*field_ptr)->sql_type(target_type);
(*field_ptr)->val_str(&value_string); (*field_ptr)->val_str(&value_string);
DBUG_PRINT("debug", ("Value of field '%s' of type '%s' is now '%s'", DBUG_PRINT("debug", ("Value of field '%s' of type '%s' is now '%s'",
(*field_ptr)->field_name, (*field_ptr)->field_name.str,
target_type.c_ptr_safe(), value_string.c_ptr_safe())); target_type.c_ptr_safe(), value_string.c_ptr_safe()));
#endif #endif
} }
@ -489,7 +489,7 @@ int prepare_record(TABLE *const table, const uint skip, const bool check)
Sql_condition::WARN_LEVEL_WARN, Sql_condition::WARN_LEVEL_WARN,
ER_NO_DEFAULT_FOR_FIELD, ER_NO_DEFAULT_FOR_FIELD,
ER_THD(thd, ER_NO_DEFAULT_FOR_FIELD), ER_THD(thd, ER_NO_DEFAULT_FOR_FIELD),
f->field_name); f->field_name.str);
} }
} }

View File

@ -143,7 +143,7 @@ unpack_row_old(rpl_group_info *rgi,
{ {
rgi->rli->report(ERROR_LEVEL, ER_SLAVE_CORRUPT_EVENT, NULL, rgi->rli->report(ERROR_LEVEL, ER_SLAVE_CORRUPT_EVENT, NULL,
"Could not read field `%s` of table `%s`.`%s`", "Could not read field `%s` of table `%s`.`%s`",
f->field_name, table->s->db.str, f->field_name.str, table->s->db.str,
table->s->table_name.str); table->s->table_name.str);
return(ER_SLAVE_CORRUPT_EVENT); return(ER_SLAVE_CORRUPT_EVENT);
} }
@ -186,7 +186,7 @@ unpack_row_old(rpl_group_info *rgi,
rgi->rli->report(ERROR_LEVEL, ER_NO_DEFAULT_FOR_FIELD, NULL, rgi->rli->report(ERROR_LEVEL, ER_NO_DEFAULT_FOR_FIELD, NULL,
"Field `%s` of table `%s`.`%s` " "Field `%s` of table `%s`.`%s` "
"has no default value and cannot be NULL", "has no default value and cannot be NULL",
(*field_ptr)->field_name, table->s->db.str, (*field_ptr)->field_name.str, table->s->db.str,
table->s->table_name.str); table->s->table_name.str);
error = ER_NO_DEFAULT_FOR_FIELD; error = ER_NO_DEFAULT_FOR_FIELD;
} }

View File

@ -825,7 +825,7 @@ table_def::compatible_with(THD *thd, rpl_group_info *rgi,
{ {
DBUG_PRINT("debug", ("Checking column %d -" DBUG_PRINT("debug", ("Checking column %d -"
" field '%s' can be converted - order: %d", " field '%s' can be converted - order: %d",
col, field->field_name, order)); col, field->field_name.str, order));
DBUG_ASSERT(order >= -1 && order <= 1); DBUG_ASSERT(order >= -1 && order <= 1);
/* /*
@ -855,7 +855,7 @@ table_def::compatible_with(THD *thd, rpl_group_info *rgi,
{ {
DBUG_PRINT("debug", ("Checking column %d -" DBUG_PRINT("debug", ("Checking column %d -"
" field '%s' can not be converted", " field '%s' can not be converted",
col, field->field_name)); col, field->field_name.str));
DBUG_ASSERT(col < size() && col < table->s->fields); DBUG_ASSERT(col < size() && col < table->s->fields);
DBUG_ASSERT(table->s->db.str && table->s->table_name.str); DBUG_ASSERT(table->s->db.str && table->s->table_name.str);
DBUG_ASSERT(table->in_use); DBUG_ASSERT(table->in_use);
@ -891,7 +891,7 @@ table_def::compatible_with(THD *thd, rpl_group_info *rgi,
table->field[col]->sql_type(target_type); table->field[col]->sql_type(target_type);
DBUG_PRINT("debug", ("Field %s - conversion required." DBUG_PRINT("debug", ("Field %s - conversion required."
" Source type: '%s', Target type: '%s'", " Source type: '%s', Target type: '%s'",
tmp_table->field[col]->field_name, tmp_table->field[col]->field_name.str,
source_type.c_ptr_safe(), target_type.c_ptr_safe())); source_type.c_ptr_safe(), target_type.c_ptr_safe()));
} }
} }
@ -928,7 +928,7 @@ public:
(int) sql_type, (int) sql_type,
target_field->table->s->db.str, target_field->table->s->db.str,
target_field->table->s->table_name.str, target_field->table->s->table_name.str,
target_field->field_name); target_field->field_name.str);
return true; return true;
} }
Field *tmp= handler->make_conversion_table_field(this, metadata, Field *tmp= handler->make_conversion_table_field(this, metadata,
@ -938,7 +938,7 @@ public:
Virtual_tmp_table::add(tmp); Virtual_tmp_table::add(tmp);
DBUG_PRINT("debug", ("sql_type: %d, target_field: '%s', max_length: %d, decimals: %d," DBUG_PRINT("debug", ("sql_type: %d, target_field: '%s', max_length: %d, decimals: %d,"
" maybe_null: %d, unsigned_flag: %d, pack_length: %u", " maybe_null: %d, unsigned_flag: %d, pack_length: %u",
sql_type, target_field->field_name, sql_type, target_field->field_name.str,
tmp->field_length, tmp->decimals(), TRUE, tmp->field_length, tmp->decimals(), TRUE,
tmp->flags, tmp->pack_length())); tmp->flags, tmp->pack_length()));
return false; return false;
@ -980,7 +980,7 @@ TABLE *table_def::create_conversion_table(THD *thd, rpl_group_info *rgi,
DBUG_PRINT("debug", ("binlog_type: %d, metadata: %04X, target_field: '%s'" DBUG_PRINT("debug", ("binlog_type: %d, metadata: %04X, target_field: '%s'"
" make_conversion_table_field() failed", " make_conversion_table_field() failed",
binlog_type(col), field_metadata(col), binlog_type(col), field_metadata(col),
target_table->field[col]->field_name)); target_table->field[col]->field_name.str));
goto err; goto err;
} }
} }

View File

@ -396,7 +396,7 @@ bool Session_sysvars_tracker::vars_list::parse_var_list(THD *thd,
return false; return false;
} }
if(!strcmp(var_list.str,(const char *)"*")) if(!strcmp(var_list.str, "*"))
{ {
track_all= true; track_all= true;
buffer_length= 2; buffer_length= 2;
@ -418,7 +418,7 @@ bool Session_sysvars_tracker::vars_list::parse_var_list(THD *thd,
for (;;) for (;;)
{ {
sys_var *svar; sys_var *svar;
LEX_STRING var; LEX_CSTRING var;
uint not_used; uint not_used;
lasts= (char *) memchr(token, separator, rest); lasts= (char *) memchr(token, separator, rest);
@ -435,7 +435,7 @@ bool Session_sysvars_tracker::vars_list::parse_var_list(THD *thd,
/* Remove leading/trailing whitespace. */ /* Remove leading/trailing whitespace. */
trim_whitespace(char_set, &var, &not_used); trim_whitespace(char_set, &var, &not_used);
if(!strcmp(var.str,(const char *)"*")) if(!strcmp(var.str, "*"))
{ {
track_all= true; track_all= true;
} }
@ -483,7 +483,7 @@ bool Session_sysvars_tracker::check_var_list(THD *thd,
size_t rest= var_list.length; size_t rest= var_list.length;
if (!var_list.str || var_list.length == 0 || if (!var_list.str || var_list.length == 0 ||
!strcmp(var_list.str,(const char *)"*")) !strcmp(var_list.str, "*"))
{ {
return false; return false;
} }
@ -500,7 +500,7 @@ bool Session_sysvars_tracker::check_var_list(THD *thd,
mysql_mutex_lock(&LOCK_plugin); mysql_mutex_lock(&LOCK_plugin);
for (;;) for (;;)
{ {
LEX_STRING var; LEX_CSTRING var;
uint not_used; uint not_used;
lasts= (char *) memchr(token, separator, rest); lasts= (char *) memchr(token, separator, rest);
@ -517,7 +517,7 @@ bool Session_sysvars_tracker::check_var_list(THD *thd,
/* Remove leading/trailing whitespace. */ /* Remove leading/trailing whitespace. */
trim_whitespace(char_set, &var, &not_used); trim_whitespace(char_set, &var, &not_used);
if(!strcmp(var.str,(const char *)"*") && if(!strcmp(var.str, "*") &&
!find_sys_var_ex(thd, var.str, var.length, throw_error, true)) !find_sys_var_ex(thd, var.str, var.length, throw_error, true))
{ {
if (throw_error && take_mutex && thd) if (throw_error && take_mutex && thd)

View File

@ -233,12 +233,12 @@ bool sys_var::update(THD *thd, set_var *var)
} }
} }
uchar *sys_var::session_value_ptr(THD *thd, const LEX_STRING *base) uchar *sys_var::session_value_ptr(THD *thd, const LEX_CSTRING *base)
{ {
return session_var_ptr(thd); return session_var_ptr(thd);
} }
uchar *sys_var::global_value_ptr(THD *thd, const LEX_STRING *base) uchar *sys_var::global_value_ptr(THD *thd, const LEX_CSTRING *base)
{ {
return global_var_ptr(); return global_var_ptr();
} }
@ -271,7 +271,8 @@ bool sys_var::check(THD *thd, set_var *var)
return false; return false;
} }
uchar *sys_var::value_ptr(THD *thd, enum_var_type type, const LEX_STRING *base) uchar *sys_var::value_ptr(THD *thd, enum_var_type type,
const LEX_CSTRING *base)
{ {
DBUG_ASSERT(base); DBUG_ASSERT(base);
if (type == OPT_GLOBAL || scope() == GLOBAL) if (type == OPT_GLOBAL || scope() == GLOBAL)
@ -327,7 +328,8 @@ do { \
break break
longlong sys_var::val_int(bool *is_null, longlong sys_var::val_int(bool *is_null,
THD *thd, enum_var_type type, const LEX_STRING *base) THD *thd, enum_var_type type,
const LEX_CSTRING *base)
{ {
LEX_STRING sval; LEX_STRING sval;
AutoWLock lock(&PLock_global_system_variables); AutoWLock lock(&PLock_global_system_variables);
@ -382,7 +384,7 @@ String *sys_var::val_str_nolock(String *str, THD *thd, const uchar *value)
String *sys_var::val_str(String *str, String *sys_var::val_str(String *str,
THD *thd, enum_var_type type, const LEX_STRING *base) THD *thd, enum_var_type type, const LEX_CSTRING *base)
{ {
AutoWLock lock(&PLock_global_system_variables); AutoWLock lock(&PLock_global_system_variables);
const uchar *value= value_ptr(thd, type, base); const uchar *value= value_ptr(thd, type, base);
@ -391,7 +393,7 @@ String *sys_var::val_str(String *str,
double sys_var::val_real(bool *is_null, double sys_var::val_real(bool *is_null,
THD *thd, enum_var_type type, const LEX_STRING *base) THD *thd, enum_var_type type, const LEX_CSTRING *base)
{ {
LEX_STRING sval; LEX_STRING sval;
AutoWLock lock(&PLock_global_system_variables); AutoWLock lock(&PLock_global_system_variables);
@ -691,7 +693,7 @@ bool find_sys_var_null_base(THD *thd, struct sys_var_with_base *tmp)
tmp->var= find_sys_var(thd, tmp->base_name.str, tmp->base_name.length); tmp->var= find_sys_var(thd, tmp->base_name.str, tmp->base_name.length);
if (tmp->var != NULL) if (tmp->var != NULL)
tmp->base_name= null_lex_str; tmp->base_name= null_clex_str;
return thd->is_error(); return thd->is_error();
} }
@ -838,7 +840,7 @@ int set_var::update(THD *thd)
set_var::set_var(THD *thd, enum_var_type type_arg, sys_var *var_arg, set_var::set_var(THD *thd, enum_var_type type_arg, sys_var *var_arg,
const LEX_STRING *base_name_arg, Item *value_arg) const LEX_CSTRING *base_name_arg, Item *value_arg)
:var(var_arg), type(type_arg), base(*base_name_arg) :var(var_arg), type(type_arg), base(*base_name_arg)
{ {
/* /*
@ -849,7 +851,9 @@ set_var::set_var(THD *thd, enum_var_type type_arg, sys_var *var_arg,
{ {
Item_field *item= (Item_field*) value_arg; Item_field *item= (Item_field*) value_arg;
// names are utf8 // names are utf8
if (!(value= new (thd->mem_root) Item_string_sys(thd, item->field_name))) if (!(value= new (thd->mem_root) Item_string_sys(thd,
item->field_name.str,
item->field_name.length)))
value=value_arg; /* Give error message later */ value=value_arg; /* Give error message later */
} }
else else
@ -1061,7 +1065,7 @@ static void store_var(Field *field, sys_var *var, enum_var_type scope,
return; return;
store_value_ptr(field, var, str, store_value_ptr(field, var, str,
var->value_ptr(field->table->in_use, scope, &null_lex_str)); var->value_ptr(field->table->in_use, scope, &null_clex_str));
} }
int fill_sysvars(THD *thd, TABLE_LIST *tables, COND *cond) int fill_sysvars(THD *thd, TABLE_LIST *tables, COND *cond)

View File

@ -112,7 +112,7 @@ public:
virtual sys_var_pluginvar *cast_pluginvar() { return 0; } virtual sys_var_pluginvar *cast_pluginvar() { return 0; }
bool check(THD *thd, set_var *var); bool check(THD *thd, set_var *var);
uchar *value_ptr(THD *thd, enum_var_type type, const LEX_STRING *base); uchar *value_ptr(THD *thd, enum_var_type type, const LEX_CSTRING *base);
/** /**
Update the system variable with the default value from either Update the system variable with the default value from either
@ -123,9 +123,9 @@ public:
bool update(THD *thd, set_var *var); bool update(THD *thd, set_var *var);
String *val_str_nolock(String *str, THD *thd, const uchar *value); String *val_str_nolock(String *str, THD *thd, const uchar *value);
longlong val_int(bool *is_null, THD *thd, enum_var_type type, const LEX_STRING *base); longlong val_int(bool *is_null, THD *thd, enum_var_type type, const LEX_CSTRING *base);
String *val_str(String *str, THD *thd, enum_var_type type, const LEX_STRING *base); String *val_str(String *str, THD *thd, enum_var_type type, const LEX_CSTRING *base);
double val_real(bool *is_null, THD *thd, enum_var_type type, const LEX_STRING *base); double val_real(bool *is_null, THD *thd, enum_var_type type, const LEX_CSTRING *base);
SHOW_TYPE show_type() { return show_val_type; } SHOW_TYPE show_type() { return show_val_type; }
int scope() const { return flags & SCOPE_MASK; } int scope() const { return flags & SCOPE_MASK; }
@ -229,8 +229,8 @@ protected:
It must be of show_val_type type (my_bool for SHOW_MY_BOOL, It must be of show_val_type type (my_bool for SHOW_MY_BOOL,
int for SHOW_INT, longlong for SHOW_LONGLONG, etc). int for SHOW_INT, longlong for SHOW_LONGLONG, etc).
*/ */
virtual uchar *session_value_ptr(THD *thd, const LEX_STRING *base); virtual uchar *session_value_ptr(THD *thd, const LEX_CSTRING *base);
virtual uchar *global_value_ptr(THD *thd, const LEX_STRING *base); virtual uchar *global_value_ptr(THD *thd, const LEX_CSTRING *base);
/** /**
A pointer to a storage area of the variable, to the raw data. A pointer to a storage area of the variable, to the raw data.
@ -290,10 +290,10 @@ public:
LEX_STRING string_value; ///< for Sys_var_charptr and others LEX_STRING string_value; ///< for Sys_var_charptr and others
const void *ptr; ///< for Sys_var_struct const void *ptr; ///< for Sys_var_struct
} save_result; } save_result;
LEX_STRING base; /**< for structured variables, like keycache_name.variable_name */ LEX_CSTRING base; /**< for structured variables, like keycache_name.variable_name */
set_var(THD *thd, enum_var_type type_arg, sys_var *var_arg, set_var(THD *thd, enum_var_type type_arg, sys_var *var_arg,
const LEX_STRING *base_name_arg, Item *value_arg); const LEX_CSTRING *base_name_arg, Item *value_arg);
virtual bool is_system() { return 1; } virtual bool is_system() { return 1; }
int check(THD *thd); int check(THD *thd);
int update(THD *thd); int update(THD *thd);
@ -330,10 +330,10 @@ public:
class set_var_role: public set_var_base class set_var_role: public set_var_base
{ {
LEX_STRING role; LEX_CSTRING role;
ulonglong access; ulonglong access;
public: public:
set_var_role(LEX_STRING role_arg) : role(role_arg) {} set_var_role(LEX_CSTRING role_arg) : role(role_arg) {}
int check(THD *thd); int check(THD *thd);
int update(THD *thd); int update(THD *thd);
}; };
@ -343,9 +343,9 @@ public:
class set_var_default_role: public set_var_base class set_var_default_role: public set_var_base
{ {
LEX_USER *user, *real_user; LEX_USER *user, *real_user;
LEX_STRING role; LEX_CSTRING role;
public: public:
set_var_default_role(LEX_USER *user_arg, LEX_STRING role_arg) : set_var_default_role(LEX_USER *user_arg, LEX_CSTRING role_arg) :
user(user_arg), role(role_arg) {} user(user_arg), role(role_arg) {}
int check(THD *thd); int check(THD *thd);
int update(THD *thd); int update(THD *thd);
@ -412,7 +412,8 @@ inline bool IS_SYSVAR_AUTOSIZE(void *ptr)
bool fix_delay_key_write(sys_var *self, THD *thd, enum_var_type type); bool fix_delay_key_write(sys_var *self, THD *thd, enum_var_type type);
sql_mode_t expand_sql_mode(sql_mode_t sql_mode); sql_mode_t expand_sql_mode(sql_mode_t sql_mode);
bool sql_mode_string_representation(THD *thd, sql_mode_t sql_mode, LEX_STRING *ls); bool sql_mode_string_representation(THD *thd, sql_mode_t sql_mode,
LEX_CSTRING *ls);
int default_regex_flags_pcre(const THD *thd); int default_regex_flags_pcre(const THD *thd);
extern sys_var *Sys_autocommit_ptr; extern sys_var *Sys_autocommit_ptr;

View File

@ -82,7 +82,7 @@ ulonglong opt_read_binlog_speed_limit = 0;
const char *relay_log_index= 0; const char *relay_log_index= 0;
const char *relay_log_basename= 0; const char *relay_log_basename= 0;
LEX_STRING default_master_connection_name= { (char*) "", 0 }; LEX_CSTRING default_master_connection_name= { (char*) "", 0 };
/* /*
When slave thread exits, we need to remember the temporary tables so we When slave thread exits, we need to remember the temporary tables so we

View File

@ -273,7 +273,7 @@ extern bool volatile abort_loop;
extern Master_info *active_mi; /* active_mi for multi-master */ extern Master_info *active_mi; /* active_mi for multi-master */
extern Master_info *default_master_info; /* To replace active_mi */ extern Master_info *default_master_info; /* To replace active_mi */
extern Master_info_index *master_info_index; extern Master_info_index *master_info_index;
extern LEX_STRING default_master_connection_name; extern LEX_CSTRING default_master_connection_name;
extern my_bool replicate_same_server_id; extern my_bool replicate_same_server_id;
extern int disconnect_slave_event_count, abort_slave_event_count ; extern int disconnect_slave_event_count, abort_slave_event_count ;

View File

@ -42,7 +42,8 @@ db_load_routine(THD *thd, stored_procedure_type type, const sp_name *name,
sp_head **sphp, sp_head **sphp,
sql_mode_t sql_mode, const char *params, const char *returns, sql_mode_t sql_mode, const char *params, const char *returns,
const char *body, st_sp_chistics &chistics, const char *body, st_sp_chistics &chistics,
LEX_STRING *definer_user_name, LEX_STRING *definer_host_name, LEX_CSTRING *definer_user_name,
LEX_CSTRING *definer_host_name,
longlong created, longlong modified, longlong created, longlong modified,
Stored_program_creation_ctx *creation_ctx); Stored_program_creation_ctx *creation_ctx);
@ -542,9 +543,9 @@ db_find_routine(THD *thd, stored_procedure_type type, const sp_name *name,
Open_tables_backup open_tables_state_backup; Open_tables_backup open_tables_state_backup;
Stored_program_creation_ctx *creation_ctx; Stored_program_creation_ctx *creation_ctx;
char definer_user_name_holder[USERNAME_LENGTH + 1]; char definer_user_name_holder[USERNAME_LENGTH + 1];
LEX_STRING definer_user_name= { definer_user_name_holder, USERNAME_LENGTH }; LEX_CSTRING definer_user_name= { definer_user_name_holder, USERNAME_LENGTH };
char definer_host_name_holder[HOSTNAME_LENGTH + 1]; char definer_host_name_holder[HOSTNAME_LENGTH + 1];
LEX_STRING definer_host_name= { definer_host_name_holder, HOSTNAME_LENGTH }; LEX_CSTRING definer_host_name= { definer_host_name_holder, HOSTNAME_LENGTH };
DBUG_ENTER("db_find_routine"); DBUG_ENTER("db_find_routine");
DBUG_PRINT("enter", ("type: %d name: %.*s", DBUG_PRINT("enter", ("type: %d name: %.*s",
@ -654,9 +655,10 @@ db_find_routine(THD *thd, stored_procedure_type type, const sp_name *name,
close_system_tables(thd, &open_tables_state_backup); close_system_tables(thd, &open_tables_state_backup);
table= 0; table= 0;
/* It's ok to cast to char* here as the pointers are to local buffers */
if (parse_user(definer, strlen(definer), if (parse_user(definer, strlen(definer),
definer_user_name.str, &definer_user_name.length, (char*) definer_user_name.str, &definer_user_name.length,
definer_host_name.str, &definer_host_name.length) && (char*) definer_host_name.str, &definer_host_name.length) &&
definer_user_name.length && !definer_host_name.length) definer_user_name.length && !definer_host_name.length)
{ {
// 'user@' -> 'user@%' // 'user@' -> 'user@%'
@ -812,7 +814,8 @@ db_load_routine(THD *thd, stored_procedure_type type,
const sp_name *name, sp_head **sphp, const sp_name *name, sp_head **sphp,
sql_mode_t sql_mode, const char *params, const char *returns, sql_mode_t sql_mode, const char *params, const char *returns,
const char *body, st_sp_chistics &chistics, const char *body, st_sp_chistics &chistics,
LEX_STRING *definer_user_name, LEX_STRING *definer_host_name, LEX_CSTRING *definer_user_name,
LEX_CSTRING *definer_host_name,
longlong created, longlong modified, longlong created, longlong modified,
Stored_program_creation_ctx *creation_ctx) Stored_program_creation_ctx *creation_ctx)
{ {
@ -884,7 +887,9 @@ db_load_routine(THD *thd, stored_procedure_type type,
generate an error. generate an error.
*/ */
if (cur_db_changed && mysql_change_db(thd, &saved_cur_db_name, TRUE)) if (cur_db_changed && mysql_change_db(thd,
(LEX_CSTRING*) &saved_cur_db_name,
TRUE))
{ {
ret= SP_INTERNAL_ERROR; ret= SP_INTERNAL_ERROR;
goto end; goto end;
@ -1023,7 +1028,7 @@ sp_create_routine(THD *thd, stored_procedure_type type, sp_head *sp)
bool ret= TRUE; bool ret= TRUE;
TABLE *table; TABLE *table;
char definer_buf[USER_HOST_BUFF_SIZE]; char definer_buf[USER_HOST_BUFF_SIZE];
LEX_STRING definer; LEX_CSTRING definer;
sql_mode_t saved_mode= thd->variables.sql_mode; sql_mode_t saved_mode= thd->variables.sql_mode;
MDL_key::enum_mdl_namespace mdl_type= type == TYPE_ENUM_FUNCTION ? MDL_key::enum_mdl_namespace mdl_type= type == TYPE_ENUM_FUNCTION ?
MDL_key::FUNCTION : MDL_key::PROCEDURE; MDL_key::FUNCTION : MDL_key::PROCEDURE;
@ -1501,7 +1506,7 @@ public:
cases. cases.
*/ */
bool lock_db_routines(THD *thd, char *db) bool lock_db_routines(THD *thd, const char *db)
{ {
TABLE *table; TABLE *table;
uint key_len; uint key_len;
@ -1587,7 +1592,7 @@ bool lock_db_routines(THD *thd, char *db)
*/ */
int int
sp_drop_db_routines(THD *thd, char *db) sp_drop_db_routines(THD *thd, const char *db)
{ {
TABLE *table; TABLE *table;
int ret; int ret;
@ -1840,13 +1845,12 @@ sp_exist_routines(THD *thd, TABLE_LIST *routines, bool is_proc)
for (routine= routines; routine; routine= routine->next_global) for (routine= routines; routine; routine= routine->next_global)
{ {
sp_name *name; sp_name *name;
LEX_STRING lex_db; LEX_CSTRING lex_db;
LEX_STRING lex_name; LEX_CSTRING lex_name;
lex_db.length= strlen(routine->db); thd->make_lex_string(&lex_db, routine->db, strlen(routine->db));
lex_name.length= strlen(routine->table_name); thd->make_lex_string(&lex_name, routine->table_name,
lex_db.str= thd->strmake(routine->db, lex_db.length); strlen(routine->table_name));
lex_name.str= thd->strmake(routine->table_name, lex_name.length); name= new sp_name(&lex_db, &lex_name, true);
name= new sp_name(lex_db, lex_name, true);
sp_object_found= is_proc ? sp_find_routine(thd, TYPE_ENUM_PROCEDURE, sp_object_found= is_proc ? sp_find_routine(thd, TYPE_ENUM_PROCEDURE,
name, &thd->sp_proc_cache, name, &thd->sp_proc_cache,
FALSE) != NULL : FALSE) != NULL :
@ -2198,8 +2202,8 @@ show_create_sp(THD *thd, String *buf,
const char *returns, ulong returnslen, const char *returns, ulong returnslen,
const char *body, ulong bodylen, const char *body, ulong bodylen,
st_sp_chistics *chistics, st_sp_chistics *chistics,
const LEX_STRING *definer_user, const LEX_CSTRING *definer_user,
const LEX_STRING *definer_host, const LEX_CSTRING *definer_host,
sql_mode_t sql_mode) sql_mode_t sql_mode)
{ {
sql_mode_t old_sql_mode= thd->variables.sql_mode; sql_mode_t old_sql_mode= thd->variables.sql_mode;
@ -2300,10 +2304,10 @@ sp_load_for_information_schema(THD *thd, TABLE *proc_table, String *db,
const char *sp_body; const char *sp_body;
String defstr; String defstr;
struct st_sp_chistics sp_chistics; struct st_sp_chistics sp_chistics;
const LEX_STRING definer_user= {(char*)STRING_WITH_LEN("")}; const LEX_CSTRING definer_user= {STRING_WITH_LEN("")};
const LEX_STRING definer_host= {(char*)STRING_WITH_LEN("")}; const LEX_CSTRING definer_host= {STRING_WITH_LEN("")};
LEX_STRING sp_db_str; LEX_CSTRING sp_db_str;
LEX_STRING sp_name_str; LEX_CSTRING sp_name_str;
sp_head *sp; sp_head *sp;
sp_cache **spc= ((type == TYPE_ENUM_PROCEDURE) ? sp_cache **spc= ((type == TYPE_ENUM_PROCEDURE) ?
&thd->sp_proc_cache : &thd->sp_func_cache); &thd->sp_proc_cache : &thd->sp_func_cache);
@ -2311,7 +2315,7 @@ sp_load_for_information_schema(THD *thd, TABLE *proc_table, String *db,
sp_db_str.length= db->length(); sp_db_str.length= db->length();
sp_name_str.str= name->c_ptr(); sp_name_str.str= name->c_ptr();
sp_name_str.length= name->length(); sp_name_str.length= name->length();
sp_name sp_name_obj(sp_db_str, sp_name_str, true); sp_name sp_name_obj(&sp_db_str, &sp_name_str, true);
*free_sp_head= 0; *free_sp_head= 0;
if ((sp= sp_cache_lookup(spc, &sp_name_obj))) if ((sp= sp_cache_lookup(spc, &sp_name_obj)))
{ {

View File

@ -107,7 +107,7 @@ enum
/* Drop all routines in database 'db' */ /* Drop all routines in database 'db' */
int int
sp_drop_db_routines(THD *thd, char *db); sp_drop_db_routines(THD *thd, const char *db);
/** /**
Acquires exclusive metadata lock on all stored routines in the Acquires exclusive metadata lock on all stored routines in the
@ -119,7 +119,7 @@ sp_drop_db_routines(THD *thd, char *db);
@retval false Success @retval false Success
@retval true Failure @retval true Failure
*/ */
bool lock_db_routines(THD *thd, char *db); bool lock_db_routines(THD *thd, const char *db);
sp_head * sp_head *
sp_find_routine(THD *thd, stored_procedure_type type, const sp_name *name, sp_find_routine(THD *thd, stored_procedure_type type, const sp_name *name,
@ -241,7 +241,7 @@ bool show_create_sp(THD *thd, String *buf,
const char *returns, ulong returnslen, const char *returns, ulong returnslen,
const char *body, ulong bodylen, const char *body, ulong bodylen,
st_sp_chistics *chistics, st_sp_chistics *chistics,
const LEX_STRING *definer_user, const LEX_CSTRING *definer_user,
const LEX_STRING *definer_host, const LEX_CSTRING *definer_host,
sql_mode_t sql_mode); sql_mode_t sql_mode);
#endif /* _SP_H_ */ #endif /* _SP_H_ */

View File

@ -454,8 +454,8 @@ error:
*/ */
sp_name::sp_name(const MDL_key *key, char *qname_buff) sp_name::sp_name(const MDL_key *key, char *qname_buff)
:Database_qualified_name((char*)key->db_name(), key->db_name_length(), :Database_qualified_name(key->db_name(), key->db_name_length(),
(char*)key->name(), key->name_length()), key->name(), key->name_length()),
m_explicit_name(false) m_explicit_name(false)
{ {
if (m_db.length) if (m_db.length)
@ -479,7 +479,7 @@ sp_name::sp_name(const MDL_key *key, char *qname_buff)
*/ */
bool bool
check_routine_name(LEX_STRING *ident) check_routine_name(LEX_CSTRING *ident)
{ {
DBUG_ASSERT(ident); DBUG_ASSERT(ident);
DBUG_ASSERT(ident->str); DBUG_ASSERT(ident->str);
@ -541,7 +541,7 @@ sp_head::operator delete(void *ptr, size_t size) throw()
sp_head::sp_head() sp_head::sp_head()
:Query_arena(&main_mem_root, STMT_INITIALIZED_FOR_SP), :Query_arena(&main_mem_root, STMT_INITIALIZED_FOR_SP),
Database_qualified_name(null_lex_str, null_lex_str), Database_qualified_name(&null_clex_str, &null_clex_str),
m_flags(0), m_flags(0),
m_sp_cache_version(0), m_sp_cache_version(0),
m_creation_ctx(0), m_creation_ctx(0),
@ -560,7 +560,7 @@ sp_head::sp_head()
be rewritten soon. Remove the else part and replace 'if' with be rewritten soon. Remove the else part and replace 'if' with
an assert when this is done. an assert when this is done.
*/ */
m_qname= null_lex_str; m_qname= null_clex_str;
DBUG_ENTER("sp_head::sp_head"); DBUG_ENTER("sp_head::sp_head");
@ -750,10 +750,11 @@ sp_head::~sp_head()
*/ */
Field * Field *
sp_head::create_result_field(uint field_max_length, const char *field_name, sp_head::create_result_field(uint field_max_length, const LEX_CSTRING *field_name,
TABLE *table) TABLE *table)
{ {
Field *field; Field *field;
LEX_CSTRING name;
DBUG_ENTER("sp_head::create_result_field"); DBUG_ENTER("sp_head::create_result_field");
@ -796,11 +797,13 @@ sp_head::create_result_field(uint field_max_length, const char *field_name,
(m_return_field_def.pack_flag & (m_return_field_def.pack_flag &
(FIELDFLAG_BLOB|FIELDFLAG_GEOM)))); (FIELDFLAG_BLOB|FIELDFLAG_GEOM))));
if (field_name)
name= *field_name;
else
name= m_name;
field= m_return_field_def.make_field(table->s, /* TABLE_SHARE ptr */ field= m_return_field_def.make_field(table->s, /* TABLE_SHARE ptr */
table->in_use->mem_root, table->in_use->mem_root,
field_name ? &name);
field_name :
(const char *) m_name.str);
field->vcol_info= m_return_field_def.vcol_info; field->vcol_info= m_return_field_def.vcol_info;
if (field) if (field)
@ -1359,7 +1362,7 @@ sp_head::execute(THD *thd, bool merge_da_on_success)
NULL. In this case, mysql_change_db() would generate an error. NULL. In this case, mysql_change_db() would generate an error.
*/ */
err_status|= mysql_change_db(thd, &saved_cur_db_name, TRUE); err_status|= mysql_change_db(thd, (LEX_CSTRING*) &saved_cur_db_name, TRUE);
} }
m_flags&= ~IS_INVOKED; m_flags&= ~IS_INVOKED;
DBUG_PRINT("info", DBUG_PRINT("info",
@ -1513,8 +1516,8 @@ sp_rcontext *sp_head::rcontext_create(THD *thd, bool is_proc, Field *ret_value)
bool bool
sp_head::execute_trigger(THD *thd, sp_head::execute_trigger(THD *thd,
const LEX_STRING *db_name, const LEX_CSTRING *db_name,
const LEX_STRING *table_name, const LEX_CSTRING *table_name,
GRANT_INFO *grant_info) GRANT_INFO *grant_info)
{ {
sp_rcontext *octx = thd->spcont; sp_rcontext *octx = thd->spcont;
@ -2108,8 +2111,8 @@ sp_head::execute_procedure(THD *thd, List<Item> *args)
out_param_info->db_name= m_db.str; out_param_info->db_name= m_db.str;
out_param_info->table_name= m_name.str; out_param_info->table_name= m_name.str;
out_param_info->org_table_name= m_name.str; out_param_info->org_table_name= m_name.str;
out_param_info->col_name= spvar->name.str; out_param_info->col_name= spvar->name;
out_param_info->org_col_name= spvar->name.str; out_param_info->org_col_name= spvar->name;
srp->set_out_param_info(out_param_info); srp->set_out_param_info(out_param_info);
} }
@ -2383,7 +2386,7 @@ sp_head::check_unresolved_goto()
{ {
if ((bp->instr_type == GOTO)) if ((bp->instr_type == GOTO))
{ {
my_error(ER_SP_LILABEL_MISMATCH, MYF(0), "GOTO", bp->lab->name); my_error(ER_SP_LILABEL_MISMATCH, MYF(0), "GOTO", bp->lab->name.str);
has_unresolved_label=true; has_unresolved_label=true;
} }
} }
@ -2465,13 +2468,13 @@ void
sp_head::set_definer(const char *definer, uint definerlen) sp_head::set_definer(const char *definer, uint definerlen)
{ {
char user_name_holder[USERNAME_LENGTH + 1]; char user_name_holder[USERNAME_LENGTH + 1];
LEX_STRING user_name= { user_name_holder, USERNAME_LENGTH }; LEX_CSTRING user_name= { user_name_holder, USERNAME_LENGTH };
char host_name_holder[HOSTNAME_LENGTH + 1]; char host_name_holder[HOSTNAME_LENGTH + 1];
LEX_STRING host_name= { host_name_holder, HOSTNAME_LENGTH }; LEX_CSTRING host_name= { host_name_holder, HOSTNAME_LENGTH };
if (parse_user(definer, definerlen, user_name.str, &user_name.length, if (parse_user(definer, definerlen, user_name_holder, &user_name.length,
host_name.str, &host_name.length) && host_name_holder, &host_name.length) &&
user_name.length && !host_name.length) user_name.length && !host_name.length)
{ {
// 'user@' -> 'user@%' // 'user@' -> 'user@%'
@ -2483,7 +2486,7 @@ sp_head::set_definer(const char *definer, uint definerlen)
void void
sp_head::set_definer(const LEX_STRING *user_name, const LEX_STRING *host_name) sp_head::set_definer(const LEX_CSTRING *user_name, const LEX_CSTRING *host_name)
{ {
m_definer_user.str= strmake_root(mem_root, user_name->str, user_name->length); m_definer_user.str= strmake_root(mem_root, user_name->str, user_name->length);
m_definer_user.length= user_name->length; m_definer_user.length= user_name->length;
@ -2661,7 +2664,7 @@ sp_head::show_create_routine(THD *thd, int type)
Protocol *protocol= thd->protocol; Protocol *protocol= thd->protocol;
List<Item> fields; List<Item> fields;
LEX_STRING sql_mode; LEX_CSTRING sql_mode;
bool full_access; bool full_access;
MEM_ROOT *mem_root= thd->mem_root; MEM_ROOT *mem_root= thd->mem_root;
@ -3439,13 +3442,13 @@ sp_instr_set_row_field::print(String *str)
var->field_def.row_field_definitions()->elem(m_field_offset); var->field_def.row_field_definitions()->elem(m_field_offset);
DBUG_ASSERT(def); DBUG_ASSERT(def);
rsrv+= var->name.length + strlen(def->field_name); rsrv+= var->name.length + def->field_name.length;
if (str->reserve(rsrv)) if (str->reserve(rsrv))
return; return;
str->qs_append(STRING_WITH_LEN("set ")); str->qs_append(STRING_WITH_LEN("set "));
str->qs_append(var->name.str, var->name.length); str->qs_append(var->name.str, var->name.length);
str->qs_append('.'); str->qs_append('.');
str->qs_append(def->field_name); str->qs_append(def->field_name.str, def->field_name.length);
str->qs_append('@'); str->qs_append('@');
str->qs_append(m_offset); str->qs_append(m_offset);
str->qs_append('['); str->qs_append('[');
@ -3966,7 +3969,7 @@ sp_instr_cpush::execute(THD *thd, uint *nextp)
void void
sp_instr_cpush::print(String *str) sp_instr_cpush::print(String *str)
{ {
const LEX_STRING *cursor_name= m_ctx->find_cursor(m_cursor); const LEX_CSTRING *cursor_name= m_ctx->find_cursor(m_cursor);
/* cpush name@offset */ /* cpush name@offset */
uint rsrv= SP_INSTR_UINT_MAXLEN+7; uint rsrv= SP_INSTR_UINT_MAXLEN+7;
@ -4054,7 +4057,7 @@ sp_instr_copen::exec_core(THD *thd, uint *nextp)
void void
sp_instr_copen::print(String *str) sp_instr_copen::print(String *str)
{ {
const LEX_STRING *cursor_name= m_ctx->find_cursor(m_cursor); const LEX_CSTRING *cursor_name= m_ctx->find_cursor(m_cursor);
/* copen name@offset */ /* copen name@offset */
uint rsrv= SP_INSTR_UINT_MAXLEN+7; uint rsrv= SP_INSTR_UINT_MAXLEN+7;
@ -4096,7 +4099,7 @@ sp_instr_cclose::execute(THD *thd, uint *nextp)
void void
sp_instr_cclose::print(String *str) sp_instr_cclose::print(String *str)
{ {
const LEX_STRING *cursor_name= m_ctx->find_cursor(m_cursor); const LEX_CSTRING *cursor_name= m_ctx->find_cursor(m_cursor);
/* cclose name@offset */ /* cclose name@offset */
uint rsrv= SP_INSTR_UINT_MAXLEN+8; uint rsrv= SP_INSTR_UINT_MAXLEN+8;
@ -4139,7 +4142,7 @@ sp_instr_cfetch::print(String *str)
{ {
List_iterator_fast<sp_variable> li(m_varlist); List_iterator_fast<sp_variable> li(m_varlist);
sp_variable *pv; sp_variable *pv;
const LEX_STRING *cursor_name= m_ctx->find_cursor(m_cursor); const LEX_CSTRING *cursor_name= m_ctx->find_cursor(m_cursor);
/* cfetch name@offset vars... */ /* cfetch name@offset vars... */
uint rsrv= SP_INSTR_UINT_MAXLEN+8; uint rsrv= SP_INSTR_UINT_MAXLEN+8;
@ -4235,11 +4238,11 @@ void
sp_instr_cursor_copy_struct::print(String *str) sp_instr_cursor_copy_struct::print(String *str)
{ {
sp_variable *var= m_ctx->find_variable(m_var); sp_variable *var= m_ctx->find_variable(m_var);
const LEX_STRING *name= m_lex_keeper.cursor_name(); const LEX_CSTRING *name= m_lex_keeper.cursor_name();
str->append(STRING_WITH_LEN("cursor_copy_struct ")); str->append(STRING_WITH_LEN("cursor_copy_struct "));
str->append(name->str, name->length); str->append(name);
str->append(' '); str->append(' ');
str->append(var->name.str, var->name.length); str->append(&var->name);
str->append('@'); str->append('@');
str->append_ulonglong(m_var); str->append_ulonglong(m_var);
} }
@ -4664,7 +4667,7 @@ sp_head::set_local_variable_row_field(THD *thd, sp_pcontext *spcont,
bool bool
sp_head::set_local_variable_row_field_by_name(THD *thd, sp_pcontext *spcont, sp_head::set_local_variable_row_field_by_name(THD *thd, sp_pcontext *spcont,
sp_variable *spv, sp_variable *spv,
const LEX_STRING &field_name, const LEX_CSTRING *field_name,
Item *val, LEX *lex) Item *val, LEX *lex)
{ {
if (!(val= adjust_assignment_source(thd, val, NULL))) if (!(val= adjust_assignment_source(thd, val, NULL)))
@ -4674,7 +4677,7 @@ sp_head::set_local_variable_row_field_by_name(THD *thd, sp_pcontext *spcont,
new (thd->mem_root) sp_instr_set_row_field_by_name(instructions(), new (thd->mem_root) sp_instr_set_row_field_by_name(instructions(),
spcont, spcont,
spv->offset, spv->offset,
field_name, *field_name,
val, val,
lex, true); lex, true);
return sp_set == NULL || add_instr(sp_set); return sp_set == NULL || add_instr(sp_set);

View File

@ -113,14 +113,15 @@ class sp_name : public Sql_alloc,
public: public:
bool m_explicit_name; /**< Prepend the db name? */ bool m_explicit_name; /**< Prepend the db name? */
sp_name(LEX_STRING db, LEX_STRING name, bool use_explicit_name) sp_name(const LEX_CSTRING *db, const LEX_CSTRING *name,
bool use_explicit_name)
: Database_qualified_name(db, name), m_explicit_name(use_explicit_name) : Database_qualified_name(db, name), m_explicit_name(use_explicit_name)
{ {
if (lower_case_table_names && m_db.str) if (lower_case_table_names && m_db.str)
m_db.length= my_casedn_str(files_charset_info, m_db.str); m_db.length= my_casedn_str(files_charset_info, (char*) m_db.str);
} }
/** Create temporary sp_name object from MDL key. */ /** Create temporary sp_name object from MDL key. Store in qname_buff */
sp_name(const MDL_key *key, char *qname_buff); sp_name(const MDL_key *key, char *qname_buff);
~sp_name() ~sp_name()
@ -129,7 +130,7 @@ public:
bool bool
check_routine_name(LEX_STRING *ident); check_routine_name(LEX_CSTRING *ident);
class sp_head :private Query_arena, class sp_head :private Query_arena,
public Database_qualified_name public Database_qualified_name
@ -180,14 +181,14 @@ public:
const char *m_tmp_query; ///< Temporary pointer to sub query string const char *m_tmp_query; ///< Temporary pointer to sub query string
st_sp_chistics *m_chistics; st_sp_chistics *m_chistics;
sql_mode_t m_sql_mode; ///< For SHOW CREATE and execution sql_mode_t m_sql_mode; ///< For SHOW CREATE and execution
LEX_STRING m_qname; ///< db.name bool m_explicit_name; /**< Prepend the db name? */
bool m_explicit_name; ///< Prepend the db name? */ LEX_CSTRING m_qname; ///< db.name
LEX_STRING m_params; LEX_CSTRING m_params;
LEX_STRING m_body; LEX_CSTRING m_body;
LEX_STRING m_body_utf8; LEX_CSTRING m_body_utf8;
LEX_STRING m_defstr; LEX_CSTRING m_defstr;
LEX_STRING m_definer_user; LEX_CSTRING m_definer_user;
LEX_STRING m_definer_host; LEX_CSTRING m_definer_host;
/** /**
Is this routine being executed? Is this routine being executed?
@ -325,8 +326,8 @@ public:
bool bool
execute_trigger(THD *thd, execute_trigger(THD *thd,
const LEX_STRING *db_name, const LEX_CSTRING *db_name,
const LEX_STRING *table_name, const LEX_CSTRING *table_name,
GRANT_INFO *grant_info); GRANT_INFO *grant_info);
bool bool
@ -382,7 +383,7 @@ public:
Item *val, LEX *lex); Item *val, LEX *lex);
bool set_local_variable_row_field_by_name(THD *thd, sp_pcontext *spcont, bool set_local_variable_row_field_by_name(THD *thd, sp_pcontext *spcont,
sp_variable *spv, sp_variable *spv,
const LEX_STRING &field_name, const LEX_CSTRING *field_name,
Item *val, LEX *lex); Item *val, LEX *lex);
private: private:
/** /**
@ -602,16 +603,12 @@ public:
/// Add cpush instructions for all cursors declared in the current frame /// Add cpush instructions for all cursors declared in the current frame
bool sp_add_instr_cpush_for_cursors(THD *thd, sp_pcontext *pcontext); bool sp_add_instr_cpush_for_cursors(THD *thd, sp_pcontext *pcontext);
char *name(uint *lenp = 0) const const LEX_CSTRING *name() const
{ { return &m_name; }
if (lenp)
*lenp= (uint) m_name.length;
return m_name.str;
}
char *create_string(THD *thd, ulong *lenp); char *create_string(THD *thd, ulong *lenp);
Field *create_result_field(uint field_max_length, const char *field_name, Field *create_result_field(uint field_max_length, const LEX_CSTRING *field_name,
TABLE *table); TABLE *table);
@ -657,9 +654,10 @@ public:
def->pack_flag|= FIELDFLAG_MAYBE_NULL; def->pack_flag|= FIELDFLAG_MAYBE_NULL;
return false; return false;
} }
bool fill_spvar_definition(THD *thd, Column_definition *def, const char *name) bool fill_spvar_definition(THD *thd, Column_definition *def,
LEX_CSTRING *name)
{ {
def->field_name= name; def->field_name= *name;
return fill_spvar_definition(thd, def); return fill_spvar_definition(thd, def);
} }
/** /**
@ -669,7 +667,7 @@ public:
Qualified_column_ident *ref) Qualified_column_ident *ref)
{ {
spvar->field_def.set_column_type_ref(ref); spvar->field_def.set_column_type_ref(ref);
spvar->field_def.field_name= spvar->name.str; spvar->field_def.field_name= spvar->name;
m_flags|= sp_head::HAS_COLUMN_TYPE_REFS; m_flags|= sp_head::HAS_COLUMN_TYPE_REFS;
} }
@ -677,7 +675,7 @@ public:
st_sp_chistics *chistics, sql_mode_t sql_mode); st_sp_chistics *chistics, sql_mode_t sql_mode);
void set_definer(const char *definer, uint definerlen); void set_definer(const char *definer, uint definerlen);
void set_definer(const LEX_STRING *user_name, const LEX_STRING *host_name); void set_definer(const LEX_CSTRING *user_name, const LEX_CSTRING *host_name);
void reset_thd_mem_root(THD *thd); void reset_thd_mem_root(THD *thd);
@ -763,7 +761,7 @@ public:
DBUG_PRINT("info", ("lex->get_stmt_unsafe_flags(): 0x%x", DBUG_PRINT("info", ("lex->get_stmt_unsafe_flags(): 0x%x",
prelocking_ctx->get_stmt_unsafe_flags())); prelocking_ctx->get_stmt_unsafe_flags()));
DBUG_PRINT("info", ("sp_head(0x%p=%s)->unsafe_flags: 0x%x", DBUG_PRINT("info", ("sp_head(0x%p=%s)->unsafe_flags: 0x%x",
this, name(), unsafe_flags)); this, name()->str, unsafe_flags));
prelocking_ctx->set_stmt_unsafe_flags(unsafe_flags); prelocking_ctx->set_stmt_unsafe_flags(unsafe_flags);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -837,12 +835,12 @@ private:
class sp_lex_cursor: public sp_lex_local, public Query_arena class sp_lex_cursor: public sp_lex_local, public Query_arena
{ {
LEX_STRING m_cursor_name; LEX_CSTRING m_cursor_name;
public: public:
sp_lex_cursor(THD *thd, const LEX *oldlex, MEM_ROOT *mem_root_arg) sp_lex_cursor(THD *thd, const LEX *oldlex, MEM_ROOT *mem_root_arg)
:sp_lex_local(thd, oldlex), :sp_lex_local(thd, oldlex),
Query_arena(mem_root_arg, STMT_INITIALIZED_FOR_SP), Query_arena(mem_root_arg, STMT_INITIALIZED_FOR_SP),
m_cursor_name(null_lex_str) m_cursor_name(null_clex_str)
{ } { }
sp_lex_cursor(THD *thd, const LEX *oldlex) sp_lex_cursor(THD *thd, const LEX *oldlex)
:sp_lex_local(thd, oldlex), :sp_lex_local(thd, oldlex),
@ -870,8 +868,8 @@ public:
thd->free_list= NULL; thd->free_list= NULL;
return false; return false;
} }
const LEX_STRING *cursor_name() const { return &m_cursor_name; } const LEX_CSTRING *cursor_name() const { return &m_cursor_name; }
void set_cursor_name(const LEX_STRING &name) { m_cursor_name= name; } void set_cursor_name(const LEX_CSTRING *name) { m_cursor_name= *name; }
}; };
@ -1045,7 +1043,7 @@ public:
m_lex->safe_to_cache_query= 0; m_lex->safe_to_cache_query= 0;
} }
const LEX_STRING *cursor_name() const const LEX_CSTRING *cursor_name() const
{ {
return m_lex->cursor_name(); return m_lex->cursor_name();
} }
@ -1197,12 +1195,12 @@ class sp_instr_set_row_field_by_name : public sp_instr_set
// Prevent use of this // Prevent use of this
sp_instr_set_row_field_by_name(const sp_instr_set_row_field &); sp_instr_set_row_field_by_name(const sp_instr_set_row_field &);
void operator=(sp_instr_set_row_field_by_name &); void operator=(sp_instr_set_row_field_by_name &);
const LEX_STRING m_field_name; const LEX_CSTRING m_field_name;
public: public:
sp_instr_set_row_field_by_name(uint ip, sp_pcontext *ctx, sp_instr_set_row_field_by_name(uint ip, sp_pcontext *ctx,
uint offset, const LEX_STRING &field_name, uint offset, const LEX_CSTRING &field_name,
Item *val, Item *val,
LEX *lex, bool lex_resp) LEX *lex, bool lex_resp)
: sp_instr_set(ip, ctx, offset, val, lex, lex_resp), : sp_instr_set(ip, ctx, offset, val, lex, lex_resp),

View File

@ -199,7 +199,7 @@ uint sp_pcontext::diff_cursors(const sp_pcontext *ctx, bool exclusive) const
} }
sp_variable *sp_pcontext::find_variable(LEX_STRING name, sp_variable *sp_pcontext::find_variable(const LEX_CSTRING *name,
bool current_scope_only) const bool current_scope_only) const
{ {
uint i= m_vars.elements() - m_pboundary; uint i= m_vars.elements() - m_pboundary;
@ -209,7 +209,7 @@ sp_variable *sp_pcontext::find_variable(LEX_STRING name,
sp_variable *p= m_vars.at(i); sp_variable *p= m_vars.at(i);
if (my_strnncoll(system_charset_info, if (my_strnncoll(system_charset_info,
(const uchar *)name.str, name.length, (const uchar *)name->str, name->length,
(const uchar *)p->name.str, p->name.length) == 0) (const uchar *)p->name.str, p->name.length) == 0)
{ {
return p; return p;
@ -269,7 +269,7 @@ sp_variable *sp_pcontext::find_variable(uint offset) const
} }
sp_variable *sp_pcontext::add_variable(THD *thd, LEX_STRING name) sp_variable *sp_pcontext::add_variable(THD *thd, const LEX_CSTRING *name)
{ {
sp_variable *p= sp_variable *p=
new (thd->mem_root) sp_variable(name, m_var_offset + m_max_var_index); new (thd->mem_root) sp_variable(name, m_var_offset + m_max_var_index);
@ -282,7 +282,7 @@ sp_variable *sp_pcontext::add_variable(THD *thd, LEX_STRING name)
return m_vars.append(p) ? NULL : p; return m_vars.append(p) ? NULL : p;
} }
sp_label *sp_pcontext::push_label(THD *thd, LEX_STRING name, uint ip, sp_label *sp_pcontext::push_label(THD *thd, const LEX_CSTRING *name, uint ip,
sp_label::enum_type type, sp_label::enum_type type,
List<sp_label> *list) List<sp_label> *list)
{ {
@ -297,14 +297,14 @@ sp_label *sp_pcontext::push_label(THD *thd, LEX_STRING name, uint ip,
return label; return label;
} }
sp_label *sp_pcontext::find_goto_label(const LEX_STRING name, bool recusive) sp_label *sp_pcontext::find_goto_label(const LEX_CSTRING *name, bool recusive)
{ {
List_iterator_fast<sp_label> li(m_goto_labels); List_iterator_fast<sp_label> li(m_goto_labels);
sp_label *lab; sp_label *lab;
while ((lab= li++)) while ((lab= li++))
{ {
if (my_strcasecmp(system_charset_info, name.str, lab->name.str) == 0) if (my_strcasecmp(system_charset_info, name->str, lab->name.str) == 0)
return lab; return lab;
} }
@ -334,14 +334,14 @@ sp_label *sp_pcontext::find_goto_label(const LEX_STRING name, bool recusive)
} }
sp_label *sp_pcontext::find_label(const LEX_STRING name) sp_label *sp_pcontext::find_label(const LEX_CSTRING *name)
{ {
List_iterator_fast<sp_label> li(m_labels); List_iterator_fast<sp_label> li(m_labels);
sp_label *lab; sp_label *lab;
while ((lab= li++)) while ((lab= li++))
{ {
if (my_strcasecmp(system_charset_info, name.str, lab->name.str) == 0) if (my_strcasecmp(system_charset_info, name->str, lab->name.str) == 0)
return lab; return lab;
} }
@ -377,7 +377,7 @@ sp_label *sp_pcontext::find_label_current_loop_start()
bool sp_pcontext::add_condition(THD *thd, bool sp_pcontext::add_condition(THD *thd,
LEX_STRING name, const LEX_CSTRING *name,
sp_condition_value *value) sp_condition_value *value)
{ {
sp_condition *p= new (thd->mem_root) sp_condition(name, value); sp_condition *p= new (thd->mem_root) sp_condition(name, value);
@ -389,7 +389,7 @@ bool sp_pcontext::add_condition(THD *thd,
} }
sp_condition_value *sp_pcontext::find_condition(const LEX_STRING name, sp_condition_value *sp_pcontext::find_condition(const LEX_CSTRING *name,
bool current_scope_only) const bool current_scope_only) const
{ {
uint i= m_conditions.elements(); uint i= m_conditions.elements();
@ -431,7 +431,7 @@ static sp_condition sp_predefined_conditions[]=
sp_condition_value * sp_condition_value *
sp_pcontext::find_predefined_condition(const LEX_STRING name) const sp_pcontext::find_predefined_condition(const LEX_CSTRING *name) const
{ {
for (uint i= 0; i < array_elements(sp_predefined_conditions) ; i++) for (uint i= 0; i < array_elements(sp_predefined_conditions) ; i++)
{ {
@ -589,7 +589,7 @@ sp_pcontext::find_handler(const Sql_condition_identity &value) const
} }
bool sp_pcontext::add_cursor(const LEX_STRING name, sp_pcontext *param_ctx, bool sp_pcontext::add_cursor(const LEX_CSTRING *name, sp_pcontext *param_ctx,
sp_lex_cursor *lex) sp_lex_cursor *lex)
{ {
if (m_cursors.elements() == m_max_cursor_index) if (m_cursors.elements() == m_max_cursor_index)
@ -599,7 +599,7 @@ bool sp_pcontext::add_cursor(const LEX_STRING name, sp_pcontext *param_ctx,
} }
const sp_pcursor *sp_pcontext::find_cursor(const LEX_STRING name, const sp_pcursor *sp_pcontext::find_cursor(const LEX_CSTRING *name,
uint *poff, uint *poff,
bool current_scope_only) const bool current_scope_only) const
{ {
@ -607,10 +607,10 @@ const sp_pcursor *sp_pcontext::find_cursor(const LEX_STRING name,
while (i--) while (i--)
{ {
LEX_STRING n= m_cursors.at(i); LEX_CSTRING n= m_cursors.at(i);
if (my_strnncoll(system_charset_info, if (my_strnncoll(system_charset_info,
(const uchar *) name.str, name.length, (const uchar *) name->str, name->length,
(const uchar *) n.str, n.length) == 0) (const uchar *) n.str, n.length) == 0)
{ {
*poff= m_cursor_offset + i; *poff= m_cursor_offset + i;
@ -695,7 +695,7 @@ bool sp_pcursor::check_param_count_with_error(uint param_count) const
if (param_count != (m_param_context ? if (param_count != (m_param_context ?
m_param_context->context_var_count() : 0)) m_param_context->context_var_count() : 0))
{ {
my_error(ER_WRONG_PARAMCOUNT_TO_CURSOR, MYF(0), LEX_STRING::str); my_error(ER_WRONG_PARAMCOUNT_TO_CURSOR, MYF(0), LEX_CSTRING::str);
return true; return true;
} }
return false; return false;
@ -703,20 +703,20 @@ bool sp_pcursor::check_param_count_with_error(uint param_count) const
const Spvar_definition * const Spvar_definition *
sp_variable::find_row_field(const LEX_STRING &var_name, sp_variable::find_row_field(const LEX_CSTRING *var_name,
const LEX_STRING &field_name, const LEX_CSTRING *field_name,
uint *row_field_offset) uint *row_field_offset)
{ {
if (!field_def.is_row()) if (!field_def.is_row())
{ {
my_printf_error(ER_UNKNOWN_ERROR, my_printf_error(ER_UNKNOWN_ERROR,
"'%s' is not a row variable", MYF(0), var_name.str); "'%s' is not a row variable", MYF(0), var_name->str);
return NULL; return NULL;
} }
const Spvar_definition *def; const Spvar_definition *def;
if ((def= field_def.find_row_field_by_name(field_name.str, row_field_offset))) if ((def= field_def.find_row_field_by_name(field_name, row_field_offset)))
return def; return def;
my_error(ER_ROW_VARIABLE_DOES_NOT_HAVE_FIELD, MYF(0), my_error(ER_ROW_VARIABLE_DOES_NOT_HAVE_FIELD, MYF(0),
var_name.str, field_name.str); var_name->str, field_name->str);
return NULL; return NULL;
} }

View File

@ -41,7 +41,7 @@ public:
}; };
/// Name of the SP-variable. /// Name of the SP-variable.
LEX_STRING name; LEX_CSTRING name;
/// Mode of the SP-variable. /// Mode of the SP-variable.
enum_mode mode; enum_mode mode;
@ -65,11 +65,11 @@ public:
const Type_handler *type_handler() const { return field_def.type_handler(); } const Type_handler *type_handler() const { return field_def.type_handler(); }
public: public:
sp_variable(LEX_STRING _name, uint _offset) sp_variable(const LEX_CSTRING *name_arg, uint offset_arg)
:Sql_alloc(), :Sql_alloc(),
name(_name), name(*name_arg),
mode(MODE_IN), mode(MODE_IN),
offset(_offset), offset(offset_arg),
default_value(NULL) default_value(NULL)
{ } { }
/* /*
@ -83,8 +83,8 @@ public:
with the given name, or a non-null pointer otherwise. with the given name, or a non-null pointer otherwise.
row_field_offset[0] is set only when the method returns !NULL. row_field_offset[0] is set only when the method returns !NULL.
*/ */
const Spvar_definition *find_row_field(const LEX_STRING &var_name, const Spvar_definition *find_row_field(const LEX_CSTRING *var_name,
const LEX_STRING &field_name, const LEX_CSTRING *field_name,
uint *row_field_offset); uint *row_field_offset);
}; };
@ -117,7 +117,7 @@ public:
}; };
/// Name of the label. /// Name of the label.
LEX_STRING name; LEX_CSTRING name;
/// Instruction pointer of the label. /// Instruction pointer of the label.
uint ip; uint ip;
@ -129,10 +129,10 @@ public:
class sp_pcontext *ctx; class sp_pcontext *ctx;
public: public:
sp_label(const LEX_STRING _name, sp_label(const LEX_CSTRING *_name,
uint _ip, enum_type _type, sp_pcontext *_ctx) uint _ip, enum_type _type, sp_pcontext *_ctx)
:Sql_alloc(), :Sql_alloc(),
name(_name), name(*_name),
ip(_ip), ip(_ip),
type(_type), type(_type),
ctx(_ctx) ctx(_ctx)
@ -243,29 +243,29 @@ class sp_condition : public Sql_alloc
{ {
public: public:
/// Name of the condition. /// Name of the condition.
LEX_STRING name; LEX_CSTRING name;
/// Value of the condition. /// Value of the condition.
sp_condition_value *value; sp_condition_value *value;
public: public:
sp_condition(const LEX_STRING _name, sp_condition_value *_value) sp_condition(const LEX_CSTRING *name_arg, sp_condition_value *value_arg)
:Sql_alloc(), :Sql_alloc(),
name(_name), name(*name_arg),
value(_value) value(value_arg)
{ } { }
sp_condition(const char *name_arg, size_t name_length_arg, sp_condition(const char *name_arg, size_t name_length_arg,
sp_condition_value *value_arg) sp_condition_value *value_arg)
:value(value_arg) :value(value_arg)
{ {
name.str= (char *) name_arg; name.str= name_arg;
name.length= name_length_arg; name.length= name_length_arg;
} }
bool eq_name(const LEX_STRING str) const bool eq_name(const LEX_CSTRING *str) const
{ {
return my_strnncoll(system_charset_info, return my_strnncoll(system_charset_info,
(const uchar *) name.str, name.length, (const uchar *) name.str, name.length,
(const uchar *) str.str, str.length) == 0; (const uchar *) str->str, str->length) == 0;
} }
}; };
@ -288,14 +288,14 @@ public:
Note, m_param_context can be not NULL, but have no variables. Note, m_param_context can be not NULL, but have no variables.
This is also means a cursor with no parameters (similar to NULL). This is also means a cursor with no parameters (similar to NULL).
*/ */
class sp_pcursor: public LEX_STRING class sp_pcursor: public LEX_CSTRING
{ {
class sp_pcontext *m_param_context; // Formal parameters class sp_pcontext *m_param_context; // Formal parameters
class sp_lex_cursor *m_lex; // The cursor statement LEX class sp_lex_cursor *m_lex; // The cursor statement LEX
public: public:
sp_pcursor(const LEX_STRING &name, class sp_pcontext *param_ctx, sp_pcursor(const LEX_CSTRING *name, class sp_pcontext *param_ctx,
class sp_lex_cursor *lex) class sp_lex_cursor *lex)
:LEX_STRING(name), m_param_context(param_ctx), m_lex(lex) :LEX_CSTRING(*name), m_param_context(param_ctx), m_lex(lex)
{ } { }
class sp_pcontext *param_context() const { return m_param_context; } class sp_pcontext *param_context() const { return m_param_context; }
class sp_lex_cursor *lex() const { return m_lex; } class sp_lex_cursor *lex() const { return m_lex; }
@ -462,7 +462,7 @@ public:
/// @param name Name of the SP-variable. /// @param name Name of the SP-variable.
/// ///
/// @return instance of newly added SP-variable. /// @return instance of newly added SP-variable.
sp_variable *add_variable(THD *thd, LEX_STRING name); sp_variable *add_variable(THD *thd, const LEX_CSTRING *name);
/// Retrieve full type information about SP-variables in this parsing /// Retrieve full type information about SP-variables in this parsing
/// context and its children. /// context and its children.
@ -481,7 +481,7 @@ public:
/// @param current_scope_only A flag if we search only in current scope. /// @param current_scope_only A flag if we search only in current scope.
/// ///
/// @return instance of found SP-variable, or NULL if not found. /// @return instance of found SP-variable, or NULL if not found.
sp_variable *find_variable(LEX_STRING name, bool current_scope_only) const; sp_variable *find_variable(const LEX_CSTRING *name, bool current_scope_only) const;
/// Find SP-variable by the offset in the root parsing context. /// Find SP-variable by the offset in the root parsing context.
/// ///
@ -524,28 +524,28 @@ public:
// Labels. // Labels.
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
sp_label *push_label(THD *thd, const LEX_STRING name, uint ip, sp_label *push_label(THD *thd, const LEX_CSTRING *name, uint ip,
sp_label::enum_type type, List<sp_label> * list); sp_label::enum_type type, List<sp_label> * list);
sp_label *push_label(THD *thd, LEX_STRING name, uint ip, sp_label *push_label(THD *thd, const LEX_CSTRING *name, uint ip,
sp_label::enum_type type) sp_label::enum_type type)
{ return push_label(thd, name, ip, type, &m_labels); } { return push_label(thd, name, ip, type, &m_labels); }
sp_label *push_goto_label(THD *thd, LEX_STRING name, uint ip, sp_label *push_goto_label(THD *thd, const LEX_CSTRING *name, uint ip,
sp_label::enum_type type) sp_label::enum_type type)
{ return push_label(thd, name, ip, type, &m_goto_labels); } { return push_label(thd, name, ip, type, &m_goto_labels); }
sp_label *push_label(THD *thd, const LEX_STRING name, uint ip) sp_label *push_label(THD *thd, const LEX_CSTRING *name, uint ip)
{ return push_label(thd, name, ip, sp_label::IMPLICIT); } { return push_label(thd, name, ip, sp_label::IMPLICIT); }
sp_label *push_goto_label(THD *thd, const LEX_STRING name, uint ip) sp_label *push_goto_label(THD *thd, const LEX_CSTRING *name, uint ip)
{ return push_goto_label(thd, name, ip, sp_label::GOTO); } { return push_goto_label(thd, name, ip, sp_label::GOTO); }
sp_label *find_label(const LEX_STRING name); sp_label *find_label(const LEX_CSTRING *name);
sp_label *find_goto_label(const LEX_STRING name, bool recusive); sp_label *find_goto_label(const LEX_CSTRING *name, bool recusive);
sp_label *find_goto_label(const LEX_STRING name) sp_label *find_goto_label(const LEX_CSTRING *name)
{ return find_goto_label(name, true); } { return find_goto_label(name, true); }
sp_label *find_label_current_loop_start(); sp_label *find_label_current_loop_start();
@ -568,12 +568,12 @@ public:
sp_label *pop_label() sp_label *pop_label()
{ return m_labels.pop(); } { return m_labels.pop(); }
bool block_label_declare(LEX_STRING label) bool block_label_declare(LEX_CSTRING *label)
{ {
sp_label *lab= find_label(label); sp_label *lab= find_label(label);
if (lab) if (lab)
{ {
my_error(ER_SP_LABEL_REDEFINE, MYF(0), label.str); my_error(ER_SP_LABEL_REDEFINE, MYF(0), label->str);
return true; return true;
} }
return false; return false;
@ -583,15 +583,15 @@ public:
// Conditions. // Conditions.
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
bool add_condition(THD *thd, const LEX_STRING name, bool add_condition(THD *thd, const LEX_CSTRING *name,
sp_condition_value *value); sp_condition_value *value);
/// See comment for find_variable() above. /// See comment for find_variable() above.
sp_condition_value *find_condition(const LEX_STRING name, sp_condition_value *find_condition(const LEX_CSTRING *name,
bool current_scope_only) const; bool current_scope_only) const;
sp_condition_value * sp_condition_value *
find_declared_or_predefined_condition(const LEX_STRING name) const find_declared_or_predefined_condition(const LEX_CSTRING *name) const
{ {
sp_condition_value *p= find_condition(name, false); sp_condition_value *p= find_condition(name, false);
if (p) if (p)
@ -599,12 +599,12 @@ public:
return find_predefined_condition(name); return find_predefined_condition(name);
} }
bool declare_condition(THD *thd, const LEX_STRING name, bool declare_condition(THD *thd, const LEX_CSTRING *name,
sp_condition_value *val) sp_condition_value *val)
{ {
if (find_condition(name, true)) if (find_condition(name, true))
{ {
my_error(ER_SP_DUP_COND, MYF(0), name.str); my_error(ER_SP_DUP_COND, MYF(0), name->str);
return true; return true;
} }
return add_condition(thd, name, val); return add_condition(thd, name, val);
@ -646,21 +646,21 @@ public:
// Cursors. // Cursors.
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
bool add_cursor(const LEX_STRING name, sp_pcontext *param_ctx, bool add_cursor(const LEX_CSTRING *name, sp_pcontext *param_ctx,
class sp_lex_cursor *lex); class sp_lex_cursor *lex);
/// See comment for find_variable() above. /// See comment for find_variable() above.
const sp_pcursor *find_cursor(const LEX_STRING name, const sp_pcursor *find_cursor(const LEX_CSTRING *name,
uint *poff, bool current_scope_only) const; uint *poff, bool current_scope_only) const;
const sp_pcursor *find_cursor_with_error(const LEX_STRING name, const sp_pcursor *find_cursor_with_error(const LEX_CSTRING *name,
uint *poff, uint *poff,
bool current_scope_only) const bool current_scope_only) const
{ {
const sp_pcursor *pcursor= find_cursor(name, poff, current_scope_only); const sp_pcursor *pcursor= find_cursor(name, poff, current_scope_only);
if (!pcursor) if (!pcursor)
{ {
my_error(ER_SP_CURSOR_MISMATCH, MYF(0), name.str); my_error(ER_SP_CURSOR_MISMATCH, MYF(0), name->str);
return NULL; return NULL;
} }
return pcursor; return pcursor;
@ -704,7 +704,7 @@ private:
sp_pcontext(const sp_pcontext &); sp_pcontext(const sp_pcontext &);
void operator=(sp_pcontext &); void operator=(sp_pcontext &);
sp_condition_value *find_predefined_condition(const LEX_STRING name) const; sp_condition_value *find_predefined_condition(const LEX_CSTRING *name) const;
private: private:
/// m_max_var_index -- number of variables (including all types of arguments) /// m_max_var_index -- number of variables (including all types of arguments)

View File

@ -171,7 +171,7 @@ bool sp_rcontext::resolve_type_ref(THD *thd, Column_definition *def,
!open_tables_only_view_structure(thd, table_list, !open_tables_only_view_structure(thd, table_list,
thd->mdl_context.has_locks())) thd->mdl_context.has_locks()))
{ {
if ((src= lex.query_tables->table->find_field_by_name(ref->m_column.str))) if ((src= lex.query_tables->table->find_field_by_name(&ref->m_column)))
{ {
if (!(rc= check_column_grant_for_type_ref(thd, table_list, if (!(rc= check_column_grant_for_type_ref(thd, table_list,
ref->m_column.str, ref->m_column.str,
@ -237,14 +237,14 @@ bool sp_rcontext::resolve_table_rowtype_ref(THD *thd,
as the table will be closed and freed soon, as the table will be closed and freed soon,
in the end of this method. in the end of this method.
*/ */
LEX_CSTRING tmp= {src[0]->field_name, strlen(src[0]->field_name)}; LEX_CSTRING tmp= src[0]->field_name;
Spvar_definition *def; Spvar_definition *def;
if ((rc= check_column_grant_for_type_ref(thd, table_list, if ((rc= check_column_grant_for_type_ref(thd, table_list,
tmp.str, tmp.length)) || tmp.str, tmp.length)) ||
(rc= !(src[0]->field_name= thd->strmake(tmp.str, tmp.length))) || (rc= !(src[0]->field_name.str= thd->strmake(tmp.str, tmp.length))) ||
(rc= !(def= new (thd->mem_root) Spvar_definition(thd, *src)))) (rc= !(def= new (thd->mem_root) Spvar_definition(thd, *src))))
break; break;
src[0]->field_name= tmp.str; // Restore field name, just in case. src[0]->field_name.str= tmp.str; // Restore field name, just in case.
def->flags&= (uint) ~NOT_NULL_FLAG; def->flags&= (uint) ~NOT_NULL_FLAG;
if ((rc= def->sp_prepare_create_field(thd, thd->mem_root))) if ((rc= def->sp_prepare_create_field(thd, thd->mem_root)))
break; break;

View File

@ -176,30 +176,30 @@ TABLE_FIELD_TYPE mysql_db_table_fields[MYSQL_DB_FIELD_COUNT] = {
const TABLE_FIELD_DEF const TABLE_FIELD_DEF
mysql_db_table_def= {MYSQL_DB_FIELD_COUNT, mysql_db_table_fields, 0, (uint*) 0 }; mysql_db_table_def= {MYSQL_DB_FIELD_COUNT, mysql_db_table_fields, 0, (uint*) 0 };
static LEX_STRING native_password_plugin_name= { static LEX_CSTRING native_password_plugin_name= {
C_STRING_WITH_LEN("mysql_native_password") STRING_WITH_LEN("mysql_native_password")
}; };
static LEX_STRING old_password_plugin_name= { static LEX_CSTRING old_password_plugin_name= {
C_STRING_WITH_LEN("mysql_old_password") STRING_WITH_LEN("mysql_old_password")
}; };
/// @todo make it configurable /// @todo make it configurable
LEX_STRING *default_auth_plugin_name= &native_password_plugin_name; LEX_CSTRING *default_auth_plugin_name= &native_password_plugin_name;
/* /*
Wildcard host, matches any hostname Wildcard host, matches any hostname
*/ */
LEX_STRING host_not_specified= { C_STRING_WITH_LEN("%") }; LEX_CSTRING host_not_specified= { STRING_WITH_LEN("%") };
/* /*
Constants, used in the SHOW GRANTS command. Constants, used in the SHOW GRANTS command.
Their actual string values are irrelevant, they're always compared Their actual string values are irrelevant, they're always compared
as pointers to these string constants. as pointers to these string constants.
*/ */
LEX_STRING current_user= { C_STRING_WITH_LEN("*current_user") }; LEX_CSTRING current_user= { STRING_WITH_LEN("*current_user") };
LEX_STRING current_role= { C_STRING_WITH_LEN("*current_role") }; LEX_CSTRING current_role= { STRING_WITH_LEN("*current_role") };
LEX_STRING current_user_and_current_role= { C_STRING_WITH_LEN("*current_user_and_current_role") }; LEX_CSTRING current_user_and_current_role= { STRING_WITH_LEN("*current_user_and_current_role") };
#ifndef NO_EMBEDDED_ACCESS_CHECKS #ifndef NO_EMBEDDED_ACCESS_CHECKS
@ -244,7 +244,7 @@ public:
{ return (void*) alloc_root(mem_root, size); } { return (void*) alloc_root(mem_root, size); }
uchar flags; // field used to store various state information uchar flags; // field used to store various state information
LEX_STRING user; LEX_CSTRING user;
/* list to hold references to granted roles (ACL_ROLE instances) */ /* list to hold references to granted roles (ACL_ROLE instances) */
DYNAMIC_ARRAY role_grants; DYNAMIC_ARRAY role_grants;
}; };
@ -259,9 +259,9 @@ public:
uint8 salt_len; // 0 - no password, 4 - 3.20, 8 - 4.0, 20 - 4.1.1 uint8 salt_len; // 0 - no password, 4 - 3.20, 8 - 4.0, 20 - 4.1.1
enum SSL_type ssl_type; enum SSL_type ssl_type;
const char *ssl_cipher, *x509_issuer, *x509_subject; const char *ssl_cipher, *x509_issuer, *x509_subject;
LEX_STRING plugin; LEX_CSTRING plugin;
LEX_STRING auth_string; LEX_CSTRING auth_string;
LEX_STRING default_rolename; LEX_CSTRING default_rolename;
ACL_USER *copy(MEM_ROOT *root) ACL_USER *copy(MEM_ROOT *root)
{ {
@ -338,7 +338,7 @@ class ACL_DB :public ACL_ACCESS
{ {
public: public:
acl_host_and_ip host; acl_host_and_ip host;
char *user,*db; const char *user,*db;
ulong initial_access; /* access bits present in the table */ ulong initial_access; /* access bits present in the table */
}; };
@ -530,10 +530,10 @@ public:
} }
static int store_pk(TABLE *table, static int store_pk(TABLE *table,
const LEX_STRING *host, const LEX_CSTRING *host,
const LEX_STRING *user, const LEX_CSTRING *user,
const LEX_STRING *proxied_host, const LEX_CSTRING *proxied_host,
const LEX_STRING *proxied_user) const LEX_CSTRING *proxied_user)
{ {
DBUG_ENTER("ACL_PROXY_USER::store_pk"); DBUG_ENTER("ACL_PROXY_USER::store_pk");
DBUG_PRINT("info", ("host=%s, user=%s, proxied_host=%s, proxied_user=%s", DBUG_PRINT("info", ("host=%s, user=%s, proxied_host=%s, proxied_user=%s",
@ -560,10 +560,10 @@ public:
} }
static int store_data_record(TABLE *table, static int store_data_record(TABLE *table,
const LEX_STRING *host, const LEX_CSTRING *host,
const LEX_STRING *user, const LEX_CSTRING *user,
const LEX_STRING *proxied_host, const LEX_CSTRING *proxied_host,
const LEX_STRING *proxied_user, const LEX_CSTRING *proxied_user,
bool with_grant, bool with_grant,
const char *grantor) const char *grantor)
{ {
@ -616,8 +616,8 @@ struct ROLE_GRANT_PAIR : public Sql_alloc
LEX_STRING hashkey; LEX_STRING hashkey;
bool with_admin; bool with_admin;
bool init(MEM_ROOT *mem, char *username, char *hostname, char *rolename, bool init(MEM_ROOT *mem, const char *username, const char *hostname,
bool with_admin_option); const char *rolename, bool with_admin_option);
}; };
static uchar* acl_role_map_get_key(ROLE_GRANT_PAIR *entry, size_t *length, static uchar* acl_role_map_get_key(ROLE_GRANT_PAIR *entry, size_t *length,
@ -627,8 +627,8 @@ static uchar* acl_role_map_get_key(ROLE_GRANT_PAIR *entry, size_t *length,
return (uchar*) entry->hashkey.str; return (uchar*) entry->hashkey.str;
} }
bool ROLE_GRANT_PAIR::init(MEM_ROOT *mem, char *username, bool ROLE_GRANT_PAIR::init(MEM_ROOT *mem, const char *username,
char *hostname, char *rolename, const char *hostname, const char *rolename,
bool with_admin_option) bool with_admin_option)
{ {
size_t uname_l = safe_strlen(username); size_t uname_l = safe_strlen(username);
@ -736,7 +736,7 @@ static void rebuild_role_grants(void);
static ACL_USER *find_user_exact(const char *host, const char *user); static ACL_USER *find_user_exact(const char *host, const char *user);
static ACL_USER *find_user_wild(const char *host, const char *user, const char *ip= 0); static ACL_USER *find_user_wild(const char *host, const char *user, const char *ip= 0);
static ACL_ROLE *find_acl_role(const char *user); static ACL_ROLE *find_acl_role(const char *user);
static ROLE_GRANT_PAIR *find_role_grant_pair(const LEX_STRING *u, const LEX_STRING *h, const LEX_STRING *r); static ROLE_GRANT_PAIR *find_role_grant_pair(const LEX_CSTRING *u, const LEX_CSTRING *h, const LEX_CSTRING *r);
static ACL_USER_BASE *find_acl_user_base(const char *user, const char *host); static ACL_USER_BASE *find_acl_user_base(const char *user, const char *host);
static bool update_user_table(THD *, const User_table &, const char *, const char *, const static bool update_user_table(THD *, const User_table &, const char *, const char *, const
char *, uint); char *, uint);
@ -1487,7 +1487,7 @@ static bool has_validation_plugins()
MariaDB_PASSWORD_VALIDATION_PLUGIN, NULL); MariaDB_PASSWORD_VALIDATION_PLUGIN, NULL);
} }
struct validation_data { LEX_STRING *user, *password; }; struct validation_data { LEX_CSTRING *user, *password; };
static my_bool do_validate(THD *, plugin_ref plugin, void *arg) static my_bool do_validate(THD *, plugin_ref plugin, void *arg)
{ {
@ -1504,7 +1504,7 @@ static bool validate_password(LEX_USER *user, THD *thd)
{ {
struct validation_data data= { &user->user, struct validation_data data= { &user->user,
user->pwtext.str ? &user->pwtext : user->pwtext.str ? &user->pwtext :
const_cast<LEX_STRING *>(&empty_lex_str) }; const_cast<LEX_CSTRING *>(&empty_clex_str) };
if (plugin_foreach(NULL, do_validate, if (plugin_foreach(NULL, do_validate,
MariaDB_PASSWORD_VALIDATION_PLUGIN, &data)) MariaDB_PASSWORD_VALIDATION_PLUGIN, &data))
{ {
@ -1553,7 +1553,7 @@ set_user_salt(ACL_USER *acl_user, const char *password, uint password_len)
acl_user->salt_len= 0; acl_user->salt_len= 0;
} }
static char *fix_plugin_ptr(char *name) static const char *fix_plugin_ptr(const char *name)
{ {
if (my_strcasecmp(system_charset_info, name, if (my_strcasecmp(system_charset_info, name,
native_password_plugin_name.str) == 0) native_password_plugin_name.str) == 0)
@ -1645,13 +1645,13 @@ static bool fix_lex_user(THD *thd, LEX_USER *user)
if (user->plugin.length) if (user->plugin.length)
{ {
user->pwhash= user->auth; user->pwhash= user->auth;
user->plugin= empty_lex_str; user->plugin= empty_clex_str;
user->auth= empty_lex_str; user->auth= empty_clex_str;
} }
if (user->pwhash.length && user->pwhash.length != check_length) if (user->pwhash.length && user->pwhash.length != check_length)
{ {
my_error(ER_PASSWD_LENGTH, MYF(0), check_length); my_error(ER_PASSWD_LENGTH, MYF(0), (int) check_length);
return true; return true;
} }
@ -2138,12 +2138,13 @@ static bool acl_load(THD *thd, const Grant_tables& tables)
while (!(read_record_info.read_record(&read_record_info))) while (!(read_record_info.read_record(&read_record_info)))
{ {
ACL_DB db; ACL_DB db;
char *db_name;
db.user=get_field(&acl_memroot, db_table.user()); db.user=get_field(&acl_memroot, db_table.user());
const char *hostname= get_field(&acl_memroot, db_table.host()); const char *hostname= get_field(&acl_memroot, db_table.host());
if (!hostname && find_acl_role(db.user)) if (!hostname && find_acl_role(db.user))
hostname= ""; hostname= "";
update_hostname(&db.host, hostname); update_hostname(&db.host, hostname);
db.db=get_field(&acl_memroot, db_table.db()); db.db= db_name= get_field(&acl_memroot, db_table.db());
if (!db.db) if (!db.db)
{ {
sql_print_warning("Found an entry in the 'db' table with empty database name; Skipped"); sql_print_warning("Found an entry in the 'db' table with empty database name; Skipped");
@ -2171,8 +2172,8 @@ static bool acl_load(THD *thd, const Grant_tables& tables)
sql_print_warning(ER_THD(thd, ER_WRONG_DB_NAME), db.db); sql_print_warning(ER_THD(thd, ER_WRONG_DB_NAME), db.db);
continue; continue;
} }
my_casedn_str(files_charset_info, db.db); my_casedn_str(files_charset_info, db_name);
if (strcmp(db.db, tmp_name) != 0) if (strcmp(db_name, tmp_name) != 0)
{ {
sql_print_warning("'db' entry '%s %s@%s' had database in mixed " sql_print_warning("'db' entry '%s %s@%s' had database in mixed "
"case that has been forced to lowercase because " "case that has been forced to lowercase because "
@ -2496,8 +2497,8 @@ static int acl_compare(ACL_ACCESS *a,ACL_ACCESS *b)
TRUE Error TRUE Error
*/ */
bool acl_getroot(Security_context *sctx, char *user, char *host, bool acl_getroot(Security_context *sctx, const char *user, const char *host,
char *ip, char *db) const char *ip, const char *db)
{ {
int res= 1; int res= 1;
uint i; uint i;
@ -2610,7 +2611,7 @@ static int check_user_can_set_role(const char *user, const char *host,
acl_user= find_user_wild(host, user, ip); acl_user= find_user_wild(host, user, ip);
if (acl_user == NULL) if (acl_user == NULL)
{ {
my_error(ER_INVALID_CURRENT_USER, MYF(0), rolename); my_error(ER_INVALID_CURRENT_USER, MYF(0));
result= -1; result= -1;
} }
else if (access) else if (access)
@ -2660,7 +2661,7 @@ end:
} }
int acl_check_setrole(THD *thd, char *rolename, ulonglong *access) int acl_check_setrole(THD *thd, const char *rolename, ulonglong *access)
{ {
/* Yes! priv_user@host. Don't ask why - that's what check_access() does. */ /* Yes! priv_user@host. Don't ask why - that's what check_access() does. */
return check_user_can_set_role(thd->security_ctx->priv_user, return check_user_can_set_role(thd->security_ctx->priv_user,
@ -2668,7 +2669,7 @@ int acl_check_setrole(THD *thd, char *rolename, ulonglong *access)
} }
int acl_setrole(THD *thd, char *rolename, ulonglong access) int acl_setrole(THD *thd, const char *rolename, ulonglong access)
{ {
/* merge the privileges */ /* merge the privileges */
Security_context *sctx= thd->security_ctx; Security_context *sctx= thd->security_ctx;
@ -2714,8 +2715,8 @@ static void acl_update_user(const char *user, const char *host,
const char *x509_subject, const char *x509_subject,
USER_RESOURCES *mqh, USER_RESOURCES *mqh,
ulong privileges, ulong privileges,
const LEX_STRING *plugin, const LEX_CSTRING *plugin,
const LEX_STRING *auth) const LEX_CSTRING *auth)
{ {
mysql_mutex_assert_owner(&acl_cache->lock); mysql_mutex_assert_owner(&acl_cache->lock);
@ -2792,8 +2793,8 @@ static void acl_insert_user(const char *user, const char *host,
const char *x509_subject, const char *x509_subject,
USER_RESOURCES *mqh, USER_RESOURCES *mqh,
ulong privileges, ulong privileges,
const LEX_STRING *plugin, const LEX_CSTRING *plugin,
const LEX_STRING *auth) const LEX_CSTRING *auth)
{ {
ACL_USER acl_user; ACL_USER acl_user;
@ -3998,7 +3999,7 @@ static int replace_user_table(THD *thd, const User_table &user_table,
} }
} }
else else
combo.pwhash= empty_lex_str; combo.pwhash= empty_clex_str;
/* if the user table is not up to date, we can't handle role updates */ /* if the user table is not up to date, we can't handle role updates */
if (!user_table.is_role() && handle_as_role) if (!user_table.is_role() && handle_as_role)
@ -4401,8 +4402,8 @@ abort:
@param revoke_grant true for REVOKE, false for GRANT @param revoke_grant true for REVOKE, false for GRANT
*/ */
static int static int
replace_roles_mapping_table(TABLE *table, LEX_STRING *user, LEX_STRING *host, replace_roles_mapping_table(TABLE *table, LEX_CSTRING *user, LEX_CSTRING *host,
LEX_STRING *role, bool with_admin, LEX_CSTRING *role, bool with_admin,
ROLE_GRANT_PAIR *existing, bool revoke_grant) ROLE_GRANT_PAIR *existing, bool revoke_grant)
{ {
DBUG_ENTER("replace_roles_mapping_table"); DBUG_ENTER("replace_roles_mapping_table");
@ -4483,7 +4484,7 @@ table_error:
@param revoke_grant true for REVOKE, false for GRANT @param revoke_grant true for REVOKE, false for GRANT
*/ */
static int static int
update_role_mapping(LEX_STRING *user, LEX_STRING *host, LEX_STRING *role, update_role_mapping(LEX_CSTRING *user, LEX_CSTRING *host, LEX_CSTRING *role,
bool with_admin, ROLE_GRANT_PAIR *existing, bool revoke_grant) bool with_admin, ROLE_GRANT_PAIR *existing, bool revoke_grant)
{ {
if (revoke_grant) if (revoke_grant)
@ -5823,7 +5824,8 @@ static int db_name_sort(ACL_DB * const *db1, ACL_DB * const *db2)
2 - ACL_DB was added 2 - ACL_DB was added
4 - ACL_DB was deleted 4 - ACL_DB was deleted
*/ */
static int update_role_db(ACL_DB *merged, ACL_DB **first, ulong access, char *role) static int update_role_db(ACL_DB *merged, ACL_DB **first, ulong access,
const char *role)
{ {
if (!first) if (!first)
return 0; return 0;
@ -6043,8 +6045,8 @@ static int update_role_columns(GRANT_TABLE *merged,
4 - GRANT_TABLE was deleted 4 - GRANT_TABLE was deleted
*/ */
static int update_role_table_columns(GRANT_TABLE *merged, static int update_role_table_columns(GRANT_TABLE *merged,
GRANT_TABLE **first, GRANT_TABLE **last, GRANT_TABLE **first, GRANT_TABLE **last,
ulong privs, ulong cols, char *role) ulong privs, ulong cols, const char *role)
{ {
if (!first) if (!first)
return 0; return 0;
@ -6173,7 +6175,7 @@ static int routine_name_sort(GRANT_NAME * const *r1, GRANT_NAME * const *r2)
4 - GRANT_NAME was deleted 4 - GRANT_NAME was deleted
*/ */
static int update_role_routines(GRANT_NAME *merged, GRANT_NAME **first, static int update_role_routines(GRANT_NAME *merged, GRANT_NAME **first,
ulong privs, char *role, HASH *hash) ulong privs, const char *role, HASH *hash)
{ {
if (!first) if (!first)
return 0; return 0;
@ -6392,7 +6394,7 @@ int mysql_table_grant(THD *thd, TABLE_LIST *table_list,
List_iterator <LEX_USER> str_list (user_list); List_iterator <LEX_USER> str_list (user_list);
LEX_USER *Str, *tmp_Str; LEX_USER *Str, *tmp_Str;
bool create_new_users=0; bool create_new_users=0;
char *db_name, *table_name; const char *db_name, *table_name;
DBUG_ENTER("mysql_table_grant"); DBUG_ENTER("mysql_table_grant");
if (rights & ~TABLE_ACLS) if (rights & ~TABLE_ACLS)
@ -6642,7 +6644,7 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc,
List_iterator <LEX_USER> str_list (user_list); List_iterator <LEX_USER> str_list (user_list);
LEX_USER *Str, *tmp_Str; LEX_USER *Str, *tmp_Str;
bool create_new_users= 0, result; bool create_new_users= 0, result;
char *db_name, *table_name; const char *db_name, *table_name;
DBUG_ENTER("mysql_routine_grant"); DBUG_ENTER("mysql_routine_grant");
if (rights & ~PROC_ACLS) if (rights & ~PROC_ACLS)
@ -6752,7 +6754,7 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc,
append a user or role name to a buffer that will be later used as an error message append a user or role name to a buffer that will be later used as an error message
*/ */
static void append_user(THD *thd, String *str, static void append_user(THD *thd, String *str,
const LEX_STRING *u, const LEX_STRING *h) const LEX_CSTRING *u, const LEX_CSTRING *h)
{ {
if (str->length()) if (str->length())
str->append(','); str->append(',');
@ -6795,11 +6797,11 @@ static int can_grant_role_callback(ACL_USER_BASE *grantee,
return 0; // keep searching return 0; // keep searching
if (grantee->flags & IS_ROLE) if (grantee->flags & IS_ROLE)
pair= find_role_grant_pair(&grantee->user, &empty_lex_str, &role->user); pair= find_role_grant_pair(&grantee->user, &empty_clex_str, &role->user);
else else
{ {
ACL_USER *user= (ACL_USER *)grantee; ACL_USER *user= (ACL_USER *)grantee;
LEX_STRING host= { user->host.hostname, user->hostname_length }; LEX_CSTRING host= { user->host.hostname, user->hostname_length };
pair= find_role_grant_pair(&user->user, &host, &role->user); pair= find_role_grant_pair(&user->user, &host, &role->user);
} }
if (!pair->with_admin) if (!pair->with_admin)
@ -6844,9 +6846,9 @@ bool mysql_grant_role(THD *thd, List <LEX_USER> &list, bool revoke)
bool create_new_user, no_auto_create_user; bool create_new_user, no_auto_create_user;
String wrong_users; String wrong_users;
LEX_USER *user, *granted_role; LEX_USER *user, *granted_role;
LEX_STRING rolename; LEX_CSTRING rolename;
LEX_STRING username; LEX_CSTRING username;
LEX_STRING hostname; LEX_CSTRING hostname;
ACL_ROLE *role, *role_as_user; ACL_ROLE *role, *role_as_user;
List_iterator <LEX_USER> user_list(list); List_iterator <LEX_USER> user_list(list);
@ -6900,9 +6902,9 @@ bool mysql_grant_role(THD *thd, List <LEX_USER> &list, bool revoke)
} }
if (!(role_as_user= find_acl_role(thd->security_ctx->priv_role))) if (!(role_as_user= find_acl_role(thd->security_ctx->priv_role)))
{ {
LEX_STRING ls= { thd->security_ctx->priv_role, LEX_CSTRING ls= { thd->security_ctx->priv_role,
strlen(thd->security_ctx->priv_role) }; strlen(thd->security_ctx->priv_role) };
append_user(thd, &wrong_users, &ls, &empty_lex_str); append_user(thd, &wrong_users, &ls, &empty_clex_str);
result= 1; result= 1;
continue; continue;
} }
@ -6910,13 +6912,13 @@ bool mysql_grant_role(THD *thd, List <LEX_USER> &list, bool revoke)
/* can not grant current_role to current_role */ /* can not grant current_role to current_role */
if (granted_role->user.str == current_role.str) if (granted_role->user.str == current_role.str)
{ {
append_user(thd, &wrong_users, &role_as_user->user, &empty_lex_str); append_user(thd, &wrong_users, &role_as_user->user, &empty_clex_str);
result= 1; result= 1;
continue; continue;
} }
username.str= thd->security_ctx->priv_role; username.str= thd->security_ctx->priv_role;
username.length= strlen(username.str); username.length= strlen(username.str);
hostname= empty_lex_str; hostname= empty_clex_str;
} }
else if (user->user.str == current_user.str) else if (user->user.str == current_user.str)
{ {
@ -6932,12 +6934,12 @@ bool mysql_grant_role(THD *thd, List <LEX_USER> &list, bool revoke)
hostname= user->host; hostname= user->host;
else else
if ((role_as_user= find_acl_role(user->user.str))) if ((role_as_user= find_acl_role(user->user.str)))
hostname= empty_lex_str; hostname= empty_clex_str;
else else
{ {
if (is_invalid_role_name(username.str)) if (is_invalid_role_name(username.str))
{ {
append_user(thd, &wrong_users, &username, &empty_lex_str); append_user(thd, &wrong_users, &username, &empty_clex_str);
result= 1; result= 1;
continue; continue;
} }
@ -6999,7 +7001,7 @@ bool mysql_grant_role(THD *thd, List <LEX_USER> &list, bool revoke)
if (role_as_user && if (role_as_user &&
traverse_role_graph_down(role, 0, 0, 0) == ROLE_CYCLE_FOUND) traverse_role_graph_down(role, 0, 0, 0) == ROLE_CYCLE_FOUND)
{ {
append_user(thd, &wrong_users, &username, &empty_lex_str); append_user(thd, &wrong_users, &username, &empty_clex_str);
result= 1; result= 1;
undo_add_role_user_mapping(grantee, role); undo_add_role_user_mapping(grantee, role);
continue; continue;
@ -7034,7 +7036,7 @@ bool mysql_grant_role(THD *thd, List <LEX_USER> &list, bool revoke)
thd->lex->with_admin_option, thd->lex->with_admin_option,
hash_entry, revoke)) hash_entry, revoke))
{ {
append_user(thd, &wrong_users, &username, &empty_lex_str); append_user(thd, &wrong_users, &username, &empty_clex_str);
result= 1; result= 1;
if (!revoke) if (!revoke)
{ {
@ -7887,7 +7889,7 @@ bool check_grant_all_columns(THD *thd, ulong want_access_arg,
for (; !fields->end_of_fields(); fields->next()) for (; !fields->end_of_fields(); fields->next())
{ {
const char *field_name= fields->name(); LEX_CSTRING *field_name= fields->name();
if (table_name != fields->get_table_name()) if (table_name != fields->get_table_name())
{ {
@ -7924,16 +7926,15 @@ bool check_grant_all_columns(THD *thd, ulong want_access_arg,
if (grant_table) if (grant_table)
{ {
GRANT_COLUMN *grant_column= GRANT_COLUMN *grant_column=
column_hash_search(grant_table, field_name, column_hash_search(grant_table, field_name->str, field_name->length);
(uint) strlen(field_name));
if (grant_column) if (grant_column)
have_access= grant_column->rights; have_access= grant_column->rights;
} }
if (grant_table_role) if (grant_table_role)
{ {
GRANT_COLUMN *grant_column= GRANT_COLUMN *grant_column=
column_hash_search(grant_table_role, field_name, column_hash_search(grant_table_role, field_name->str,
(uint) strlen(field_name)); field_name->length);
if (grant_column) if (grant_column)
have_access|= grant_column->rights; have_access|= grant_column->rights;
} }
@ -7965,7 +7966,7 @@ err:
command, command,
sctx->priv_user, sctx->priv_user,
sctx->host_or_ip, sctx->host_or_ip,
fields->name(), fields->name()->str,
table_name); table_name);
return 1; return 1;
} }
@ -8466,8 +8467,9 @@ static bool print_grants_for_role(THD *thd, ACL_ROLE * role)
that a role can never happen here, so *rolename will never that a role can never happen here, so *rolename will never
be assigned to be assigned to
*/ */
static bool check_show_access(THD *thd, LEX_USER *lex_user, char **username, static bool check_show_access(THD *thd, LEX_USER *lex_user,
char **hostname, char **rolename) const char **username,
const char **hostname, const char **rolename)
{ {
DBUG_ENTER("check_show_access"); DBUG_ENTER("check_show_access");
@ -8516,26 +8518,26 @@ static bool check_show_access(THD *thd, LEX_USER *lex_user, char **username,
bool mysql_show_create_user(THD *thd, LEX_USER *lex_user) bool mysql_show_create_user(THD *thd, LEX_USER *lex_user)
{ {
char *username= NULL, *hostname= NULL; const char *username= NULL, *hostname= NULL;
char buff[1024]; //Show create user should not take more than 1024 bytes. char buff[1024]; //Show create user should not take more than 1024 bytes.
Protocol *protocol= thd->protocol; Protocol *protocol= thd->protocol;
bool error= false; bool error= false;
ACL_USER *acl_user; ACL_USER *acl_user;
uint head_length;
DBUG_ENTER("mysql_show_create_user"); DBUG_ENTER("mysql_show_create_user");
if (check_show_access(thd, lex_user, &username, &hostname, NULL)) if (check_show_access(thd, lex_user, &username, &hostname, NULL))
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
List<Item> field_list; List<Item> field_list;
strxmov(buff, "CREATE USER for ", username, "@", hostname, NullS); head_length= (uint) (strxmov(buff, "CREATE USER for ", username, "@",
hostname, NullS) - buff);
Item_string *field = new (thd->mem_root) Item_string_ascii(thd, "", 0); Item_string *field = new (thd->mem_root) Item_string_ascii(thd, "", 0);
if (!field) if (!field)
{
my_error(ER_OUTOFMEMORY, MYF(0));
DBUG_RETURN(true); DBUG_RETURN(true);
}
field->name= buff; field->name.str= buff;
field->name.length= head_length;
field->max_length= sizeof(buff); field->max_length= sizeof(buff);
field_list.push_back(field, thd->mem_root); field_list.push_back(field, thd->mem_root);
if (protocol->send_result_set_metadata(&field_list, if (protocol->send_result_set_metadata(&field_list,
@ -8590,10 +8592,12 @@ static int show_grants_callback(ACL_USER_BASE *role, void *data)
} }
void mysql_show_grants_get_fields(THD *thd, List<Item> *fields, void mysql_show_grants_get_fields(THD *thd, List<Item> *fields,
const char *name) const char *name, size_t length)
{ {
Item_string *field=new (thd->mem_root) Item_string_ascii(thd, "", 0); Item_string *field=new (thd->mem_root) Item_string_ascii(thd, "", 0);
field->name= (char *) name; /* Set name explicit to avoid character set conversions */
field->name.str= name;
field->name.length= length;
field->max_length=1024; field->max_length=1024;
fields->push_back(field, thd->mem_root); fields->push_back(field, thd->mem_root);
} }
@ -8613,7 +8617,7 @@ bool mysql_show_grants(THD *thd, LEX_USER *lex_user)
ACL_ROLE *acl_role= NULL; ACL_ROLE *acl_role= NULL;
char buff[1024]; char buff[1024];
Protocol *protocol= thd->protocol; Protocol *protocol= thd->protocol;
char *username= NULL, *hostname= NULL, *rolename= NULL; const char *username= NULL, *hostname= NULL, *rolename= NULL, *end;
DBUG_ENTER("mysql_show_grants"); DBUG_ENTER("mysql_show_grants");
if (!initialized) if (!initialized)
@ -8628,11 +8632,11 @@ bool mysql_show_grants(THD *thd, LEX_USER *lex_user)
List<Item> field_list; List<Item> field_list;
if (!username) if (!username)
strxmov(buff,"Grants for ",rolename, NullS); end= strxmov(buff,"Grants for ",rolename, NullS);
else else
strxmov(buff,"Grants for ",username,"@",hostname, NullS); end= strxmov(buff,"Grants for ",username,"@",hostname, NullS);
mysql_show_grants_get_fields(thd, &field_list, buff); mysql_show_grants_get_fields(thd, &field_list, buff, (uint) (end-buff));
if (protocol->send_result_set_metadata(&field_list, if (protocol->send_result_set_metadata(&field_list,
Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF)) Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
@ -8713,9 +8717,9 @@ end:
DBUG_RETURN(error); DBUG_RETURN(error);
} }
static ROLE_GRANT_PAIR *find_role_grant_pair(const LEX_STRING *u, static ROLE_GRANT_PAIR *find_role_grant_pair(const LEX_CSTRING *u,
const LEX_STRING *h, const LEX_CSTRING *h,
const LEX_STRING *r) const LEX_CSTRING *r)
{ {
char buf[1024]; char buf[1024];
String pair_key(buf, sizeof(buf), &my_charset_bin); String pair_key(buf, sizeof(buf), &my_charset_bin);
@ -8736,7 +8740,7 @@ static bool show_role_grants(THD *thd, const char *username,
{ {
uint counter; uint counter;
Protocol *protocol= thd->protocol; Protocol *protocol= thd->protocol;
LEX_STRING host= {const_cast<char*>(hostname), strlen(hostname)}; LEX_CSTRING host= {const_cast<char*>(hostname), strlen(hostname)};
String grant(buff,sizeof(buff),system_charset_info); String grant(buff,sizeof(buff),system_charset_info);
for (counter= 0; counter < acl_entry->role_grants.elements; counter++) for (counter= 0; counter < acl_entry->role_grants.elements; counter++)
@ -9547,7 +9551,7 @@ static int handle_grant_struct(enum enum_acl_lists struct_no, bool drop,
DBUG_RETURN(1); DBUG_RETURN(1);
/* this calls for a role update */ /* this calls for a role update */
char *old_key= acl_role->user.str; const char *old_key= acl_role->user.str;
size_t old_key_length= acl_role->user.length; size_t old_key_length= acl_role->user.length;
if (drop) if (drop)
{ {
@ -11108,8 +11112,8 @@ static int enabled_roles_insert(ACL_USER_BASE *role, void *context_data)
struct APPLICABLE_ROLES_DATA struct APPLICABLE_ROLES_DATA
{ {
TABLE *table; TABLE *table;
const LEX_STRING host; const LEX_CSTRING host;
const LEX_STRING user_and_host; const LEX_CSTRING user_and_host;
ACL_USER *user; ACL_USER *user;
}; };
@ -11120,9 +11124,9 @@ applicable_roles_insert(ACL_USER_BASE *grantee, ACL_ROLE *role, void *ptr)
CHARSET_INFO *cs= system_charset_info; CHARSET_INFO *cs= system_charset_info;
TABLE *table= data->table; TABLE *table= data->table;
bool is_role= grantee != data->user; bool is_role= grantee != data->user;
const LEX_STRING *user_and_host= is_role ? &grantee->user const LEX_CSTRING *user_and_host= is_role ? &grantee->user
: &data->user_and_host; : &data->user_and_host;
const LEX_STRING *host= is_role ? &empty_lex_str : &data->host; const LEX_CSTRING *host= is_role ? &empty_clex_str : &data->host;
restore_record(table, s->default_values); restore_record(table, s->default_values);
table->field[0]->store(user_and_host->str, user_and_host->length, cs); table->field[0]->store(user_and_host->str, user_and_host->length, cs);
@ -11786,7 +11790,7 @@ LEX_USER *get_current_user(THD *thd, LEX_USER *user, bool lock)
if (lock) if (lock)
mysql_mutex_lock(&acl_cache->lock); mysql_mutex_lock(&acl_cache->lock);
if (find_acl_role(dup->user.str)) if (find_acl_role(dup->user.str))
dup->host= empty_lex_str; dup->host= empty_clex_str;
else else
dup->host= host_not_specified; dup->host= host_not_specified;
if (lock) if (lock)
@ -11801,7 +11805,7 @@ LEX_USER *get_current_user(THD *thd, LEX_USER *user, bool lock)
struct ACL_internal_schema_registry_entry struct ACL_internal_schema_registry_entry
{ {
const LEX_STRING *m_name; const LEX_CSTRING *m_name;
const ACL_internal_schema_access *m_access; const ACL_internal_schema_access *m_access;
}; };
@ -11822,7 +11826,7 @@ static uint m_registry_array_size= 0;
@param access the schema ACL specific rules @param access the schema ACL specific rules
*/ */
void ACL_internal_schema_registry::register_schema void ACL_internal_schema_registry::register_schema
(const LEX_STRING *name, const ACL_internal_schema_access *access) (const LEX_CSTRING *name, const ACL_internal_schema_access *access)
{ {
DBUG_ASSERT(m_registry_array_size < array_elements(registry_array)); DBUG_ASSERT(m_registry_array_size < array_elements(registry_array));
@ -11929,10 +11933,11 @@ struct MPVIO_EXT :public MYSQL_PLUGIN_VIO
MYSQL_SERVER_AUTH_INFO auth_info; MYSQL_SERVER_AUTH_INFO auth_info;
ACL_USER *acl_user; ///< a copy, independent from acl_users array ACL_USER *acl_user; ///< a copy, independent from acl_users array
plugin_ref plugin; ///< what plugin we're under plugin_ref plugin; ///< what plugin we're under
LEX_STRING db; ///< db name from the handshake packet LEX_CSTRING db; ///< db name from the handshake packet
/** when restarting a plugin this caches the last client reply */ /** when restarting a plugin this caches the last client reply */
struct { struct {
char *plugin, *pkt; ///< pointers into NET::buff const char *plugin;
char *pkt; ///< pointer into NET::buff
uint pkt_len; uint pkt_len;
} cached_client_reply; } cached_client_reply;
/** this caches the first plugin packet for restart request on the client */ /** this caches the first plugin packet for restart request on the client */
@ -12425,7 +12430,7 @@ static bool parse_com_change_user_packet(MPVIO_EXT *mpvio, uint packet_length)
if (find_mpvio_user(mpvio)) if (find_mpvio_user(mpvio))
DBUG_RETURN(1); DBUG_RETURN(1);
char *client_plugin; const char *client_plugin;
if (thd->client_capabilities & CLIENT_PLUGIN_AUTH) if (thd->client_capabilities & CLIENT_PLUGIN_AUTH)
{ {
if (next_field >= end) if (next_field >= end)
@ -12612,10 +12617,13 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
db_len= safe_strlen(db); db_len= safe_strlen(db);
char *next_field; char *next_field;
char *client_plugin= next_field= passwd + passwd_len + (db ? db_len + 1 : 0); const char *client_plugin= next_field= passwd + passwd_len + (db ? db_len + 1 : 0);
/* Since 4.1 all database names are stored in utf8 */ /*
if (thd->copy_with_error(system_charset_info, &mpvio->db, Since 4.1 all database names are stored in utf8
The cast is ok as copy_with_error will create a new area for db
*/
if (thd->copy_with_error(system_charset_info, (LEX_STRING*) &mpvio->db,
thd->charset(), db, db_len)) thd->charset(), db, db_len))
return packet_error; return packet_error;
@ -12642,7 +12650,7 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
Security_context *sctx= thd->security_ctx; Security_context *sctx= thd->security_ctx;
my_free(sctx->user); my_free((char*) sctx->user);
if (!(sctx->user= my_strndup(user, user_len, MYF(MY_WME)))) if (!(sctx->user= my_strndup(user, user_len, MYF(MY_WME))))
return packet_error; /* The error is set by my_strdup(). */ return packet_error; /* The error is set by my_strdup(). */
@ -13003,7 +13011,7 @@ static bool acl_check_ssl(THD *thd, const ACL_USER *acl_user)
} }
static int do_auth_once(THD *thd, const LEX_STRING *auth_plugin_name, static int do_auth_once(THD *thd, const LEX_CSTRING *auth_plugin_name,
MPVIO_EXT *mpvio) MPVIO_EXT *mpvio)
{ {
int res= CR_OK, old_status= MPVIO_EXT::FAILURE; int res= CR_OK, old_status= MPVIO_EXT::FAILURE;
@ -13085,7 +13093,7 @@ bool acl_authenticate(THD *thd, uint com_change_user_pkt_len)
{ {
int res= CR_OK; int res= CR_OK;
MPVIO_EXT mpvio; MPVIO_EXT mpvio;
const LEX_STRING *auth_plugin_name= default_auth_plugin_name; const LEX_CSTRING *auth_plugin_name= default_auth_plugin_name;
enum enum_server_command command= com_change_user_pkt_len ? COM_CHANGE_USER enum enum_server_command command= com_change_user_pkt_len ? COM_CHANGE_USER
: COM_CONNECT; : COM_CONNECT;
DBUG_ENTER("acl_authenticate"); DBUG_ENTER("acl_authenticate");

View File

@ -182,10 +182,10 @@ enum mysql_db_table_field
extern const TABLE_FIELD_DEF mysql_db_table_def; extern const TABLE_FIELD_DEF mysql_db_table_def;
extern bool mysql_user_table_is_in_short_password_format; extern bool mysql_user_table_is_in_short_password_format;
extern LEX_STRING host_not_specified; extern LEX_CSTRING host_not_specified;
extern LEX_STRING current_user; extern LEX_CSTRING current_user;
extern LEX_STRING current_role; extern LEX_CSTRING current_role;
extern LEX_STRING current_user_and_current_role; extern LEX_CSTRING current_user_and_current_role;
static inline int access_denied_error_code(int passwd_used) static inline int access_denied_error_code(int passwd_used)
@ -194,7 +194,6 @@ static inline int access_denied_error_code(int passwd_used)
: ER_ACCESS_DENIED_ERROR; : ER_ACCESS_DENIED_ERROR;
} }
/* prototypes */ /* prototypes */
bool hostname_requires_resolving(const char *hostname); bool hostname_requires_resolving(const char *hostname);
@ -204,8 +203,8 @@ void acl_free(bool end=0);
ulong acl_get(const char *host, const char *ip, ulong acl_get(const char *host, const char *ip,
const char *user, const char *db, my_bool db_is_pattern); const char *user, const char *db, my_bool db_is_pattern);
bool acl_authenticate(THD *thd, uint com_change_user_pkt_len); bool acl_authenticate(THD *thd, uint com_change_user_pkt_len);
bool acl_getroot(Security_context *sctx, char *user, char *host, bool acl_getroot(Security_context *sctx, const char *user, const char *host,
char *ip, char *db); const char *ip, const char *db);
bool acl_check_host(const char *host, const char *ip); bool acl_check_host(const char *host, const char *ip);
bool check_change_password(THD *thd, LEX_USER *user); bool check_change_password(THD *thd, LEX_USER *user);
bool change_password(THD *thd, LEX_USER *user); bool change_password(THD *thd, LEX_USER *user);
@ -243,7 +242,7 @@ ulong get_column_grant(THD *thd, GRANT_INFO *grant,
const char *db_name, const char *table_name, const char *db_name, const char *table_name,
const char *field_name); const char *field_name);
void mysql_show_grants_get_fields(THD *thd, List<Item> *fields, void mysql_show_grants_get_fields(THD *thd, List<Item> *fields,
const char *name); const char *name, size_t length);
bool mysql_show_grants(THD *thd, LEX_USER *user); bool mysql_show_grants(THD *thd, LEX_USER *user);
bool mysql_show_create_user(THD *thd, LEX_USER *user); bool mysql_show_create_user(THD *thd, LEX_USER *user);
int fill_schema_enabled_roles(THD *thd, TABLE_LIST *tables, COND *cond); int fill_schema_enabled_roles(THD *thd, TABLE_LIST *tables, COND *cond);
@ -385,7 +384,7 @@ public:
class ACL_internal_schema_registry class ACL_internal_schema_registry
{ {
public: public:
static void register_schema(const LEX_STRING *name, static void register_schema(const LEX_CSTRING *name,
const ACL_internal_schema_access *access); const ACL_internal_schema_access *access);
static const ACL_internal_schema_access *lookup(const char *name); static const ACL_internal_schema_access *lookup(const char *name);
}; };
@ -401,8 +400,8 @@ get_cached_table_access(GRANT_INTERNAL_INFO *grant_internal_info,
bool acl_check_proxy_grant_access (THD *thd, const char *host, const char *user, bool acl_check_proxy_grant_access (THD *thd, const char *host, const char *user,
bool with_grant); bool with_grant);
int acl_setrole(THD *thd, char *rolename, ulonglong access); int acl_setrole(THD *thd, const char *rolename, ulonglong access);
int acl_check_setrole(THD *thd, char *rolename, ulonglong *access); int acl_check_setrole(THD *thd, const char *rolename, ulonglong *access);
int acl_check_set_default_role(THD *thd, const char *host, const char *user); int acl_check_set_default_role(THD *thd, const char *host, const char *user);
int acl_set_default_role(THD *thd, const char *host, const char *user, int acl_set_default_role(THD *thd, const char *host, const char *user,
const char *rolename); const char *rolename);

View File

@ -189,7 +189,7 @@ static int prepare_for_repair(THD *thd, TABLE_LIST *table_list,
if (!mysql_file_stat(key_file_misc, from, &stat_info, MYF(0))) if (!mysql_file_stat(key_file_misc, from, &stat_info, MYF(0)))
goto end; // Can't use USE_FRM flag goto end; // Can't use USE_FRM flag
my_snprintf(tmp, sizeof(tmp), "%s-%lx_%lx", my_snprintf(tmp, sizeof(tmp), "%s-%lx_%llx",
from, current_pid, thd->thread_id); from, current_pid, thd->thread_id);
if (table_list->table) if (table_list->table)
@ -489,7 +489,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
for (table= tables; table; table= table->next_local) for (table= tables; table; table= table->next_local)
{ {
char table_name[SAFE_NAME_LEN*2+2]; char table_name[SAFE_NAME_LEN*2+2];
char* db = table->db; const char *db= table->db;
bool fatal_error=0; bool fatal_error=0;
bool open_error; bool open_error;
bool collect_eis= FALSE; bool collect_eis= FALSE;
@ -842,7 +842,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_NO_EIS_FOR_FIELD, ER_NO_EIS_FOR_FIELD,
ER_THD(thd, ER_NO_EIS_FOR_FIELD), ER_THD(thd, ER_NO_EIS_FOR_FIELD),
(*field_ptr)->field_name); (*field_ptr)->field_name.str);
} }
} }
else else
@ -1234,7 +1234,7 @@ err2:
*/ */
bool mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables, bool mysql_assign_to_keycache(THD* thd, TABLE_LIST* tables,
LEX_STRING *key_cache_name) const LEX_CSTRING *key_cache_name)
{ {
HA_CHECK_OPT check_opt; HA_CHECK_OPT check_opt;
KEY_CACHE *key_cache; KEY_CACHE *key_cache;

View File

@ -20,7 +20,7 @@
#define SQL_ADMIN_MSG_TEXT_SIZE (128 * 1024) #define SQL_ADMIN_MSG_TEXT_SIZE (128 * 1024)
bool mysql_assign_to_keycache(THD* thd, TABLE_LIST* table_list, bool mysql_assign_to_keycache(THD* thd, TABLE_LIST* table_list,
LEX_STRING *key_cache_name); const LEX_CSTRING *key_cache_name);
bool mysql_preload_keys(THD* thd, TABLE_LIST* table_list); bool mysql_preload_keys(THD* thd, TABLE_LIST* table_list);
int reassign_keycache_tables(THD* thd, KEY_CACHE *src_cache, int reassign_keycache_tables(THD* thd, KEY_CACHE *src_cache,
KEY_CACHE *dst_cache); KEY_CACHE *dst_cache);

Some files were not shown because too many files have changed in this diff Show More