Details
Description
To fix MDEV-27744 and to remove duplicate code, let's add a new class as follows:
/*
|
Save the current sql_mode. Switch off sql_mode flags which can prevent
|
normal parsing of VIEWs, expressions in generated columns.
|
Restore the old sql_mode on destructor.
|
*/
|
class Sql_mode_save_for_frm_handling: public Sql_mode_save |
{
|
public: |
Sql_mode_save_for_frm_handling(THD *thd)
|
:Sql_mode_save(thd)
|
{
|
/* |
- MODE_REAL_AS_FLOAT affect only CREATE TABLE parsing
|
+ MODE_PIPES_AS_CONCAT affect expression parsing
|
+ MODE_ANSI_QUOTES affect expression parsing
|
+ MODE_IGNORE_SPACE affect expression parsing
|
- MODE_IGNORE_BAD_TABLE_OPTIONS affect only CREATE/ALTER TABLE parsing
|
* MODE_ONLY_FULL_GROUP_BY affect execution
|
* MODE_NO_UNSIGNED_SUBTRACTION affect execution
|
- MODE_NO_DIR_IN_CREATE affect table creation only
|
- MODE_POSTGRESQL compounded from other modes
|
+ MODE_ORACLE affects Item creation (e.g for CONCAT)
|
- MODE_MSSQL compounded from other modes
|
- MODE_DB2 compounded from other modes
|
- MODE_MAXDB affect only CREATE TABLE parsing
|
- MODE_NO_KEY_OPTIONS affect only SHOW
|
- MODE_NO_TABLE_OPTIONS affect only SHOW
|
- MODE_NO_FIELD_OPTIONS affect only SHOW
|
- MODE_MYSQL323 affect only SHOW
|
- MODE_MYSQL40 affect only SHOW
|
- MODE_ANSI compounded from other modes
|
(+ transaction mode)
|
? MODE_NO_AUTO_VALUE_ON_ZERO affect UPDATEs
|
+ MODE_NO_BACKSLASH_ESCAPES affect expression parsing
|
+ MODE_EMPTY_STRING_IS_NULL affect expression parsing
|
*/
|
thd->variables.sql_mode&= ~(MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES |
|
MODE_IGNORE_SPACE | MODE_NO_BACKSLASH_ESCAPES |
|
MODE_ORACLE | MODE_EMPTY_STRING_IS_NULL);
|
};
|
};
|
and reuse it in all places where we reset sql_mode for unambiguous and equal re-parsing.
Currently there are multiple places resetting different sql_mode flags, e.g.:
generate_partition_syntax_for_frm:
|
sql_mode_t old_mode= thd->variables.sql_mode;
|
thd->variables.sql_mode &= ~MODE_ANSI_QUOTES;
|
|
mysql_register_view:
|
sql_mode_t sql_mode= thd->variables.sql_mode & MODE_ANSI_QUOTES;
|
thd->variables.sql_mode&= ~MODE_ANSI_QUOTES;
|
|
|
mysql_make_view:
|
thd->variables.sql_mode&= ~(MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES |
|
MODE_IGNORE_SPACE | MODE_NO_BACKSLASH_ESCAPES |
|
MODE_ORACLE);
|
parse_vcol_defs:
|
thd->variables.sql_mode &= ~(MODE_NO_BACKSLASH_ESCAPES | MODE_EMPTY_STRING_IS_NULL);
|
|
build_frm_image:
|
sql_mode_t save_sql_mode= thd->variables.sql_mode;
|
thd->variables.sql_mode &= ~MODE_ANSI_QUOTES;
|
/
Attachments
Issue Links
- blocks
-
MDEV-27744 LPAD in vcol created in ORACLE mode makes table corrupted in non-ORACLE
- Closed