Commit f86d3289 authored by monty@mashka.mysql.fi's avatar monty@mashka.mysql.fi

Added some compatibility modes (for the future)

parent 5601da7a
...@@ -927,7 +927,7 @@ static const char *default_options[]= ...@@ -927,7 +927,7 @@ static const char *default_options[]=
"character-sets-dir", "default-character-set", "interactive-timeout", "character-sets-dir", "default-character-set", "interactive-timeout",
"connect-timeout", "local-infile", "disable-local-infile", "connect-timeout", "local-infile", "disable-local-infile",
"replication-probe", "enable-reads-from-master", "repl-parse-query", "replication-probe", "enable-reads-from-master", "repl-parse-query",
"ssl-cipher","protocol","shared_memory_base_name", "ssl-cipher","protocol", "shared_memory_base_name",
NullS NullS
}; };
......
...@@ -49,6 +49,10 @@ ...@@ -49,6 +49,10 @@
static my_bool mysql_client_init=0; static my_bool mysql_client_init=0;
uint mysql_port=0; uint mysql_port=0;
my_string mysql_unix_port=0; my_string mysql_unix_port=0;
const char *sql_protocol_names_lib[] =
{ "TCP", "SOCKET", "PIPE", "MEMORY",NullS };
TYPELIB sql_protocol_typelib = {array_elements(sql_protocol_names_lib)-1,"",
sql_protocol_names_lib};
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_TRANSACTIONS | CLIENT_PROTOCOL_41) #define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_TRANSACTIONS | CLIENT_PROTOCOL_41)
...@@ -433,11 +437,15 @@ mysql_free_result(MYSQL_RES *result) ...@@ -433,11 +437,15 @@ mysql_free_result(MYSQL_RES *result)
****************************************************************************/ ****************************************************************************/
static const char *default_options[]= static const char *default_options[]=
{"port","socket","compress","password","pipe", "timeout", "user", {
"init-command", "host", "database", "debug", "return-found-rows", "port","socket","compress","password","pipe", "timeout", "user",
"ssl_key" ,"ssl_cert" ,"ssl_ca" ,"ssl_capath", "init-command", "host", "database", "debug", "return-found-rows",
"character-set-dir", "default-character-set", "ssl-key" ,"ssl-cert" ,"ssl-ca" ,"ssl-capath",
NullS "character-sets-dir", "default-character-set", "interactive-timeout",
"connect-timeout", "local-infile", "disable-local-infile",
"replication-probe", "enable-reads-from-master", "repl-parse-query",
"ssl-cipher","protocol", "shared_memory_base_name",
NullS
}; };
static TYPELIB option_types={array_elements(default_options)-1, static TYPELIB option_types={array_elements(default_options)-1,
...@@ -471,6 +479,9 @@ static void mysql_read_default_options(struct st_mysql_options *options, ...@@ -471,6 +479,9 @@ static void mysql_read_default_options(struct st_mysql_options *options,
opt_arg=end+1; opt_arg=end+1;
*end=0; /* Remove '=' */ *end=0; /* Remove '=' */
} }
/* Change all '_' in variable name to '-' */
for (end= *option ; *(end= strcend(end,'_')) ; )
*end= '-';
switch (find_type(*option+2,&option_types,2)) { switch (find_type(*option+2,&option_types,2)) {
case 1: /* port */ case 1: /* port */
if (opt_arg) if (opt_arg)
...@@ -494,8 +505,9 @@ static void mysql_read_default_options(struct st_mysql_options *options, ...@@ -494,8 +505,9 @@ static void mysql_read_default_options(struct st_mysql_options *options,
} }
break; break;
case 5: /* pipe */ case 5: /* pipe */
options->named_pipe=1; /* Force named pipe */ options->protocol = MYSQL_PROTOCOL_PIPE;
break; break;
case 20: /* connect_timeout */
case 6: /* timeout */ case 6: /* timeout */
if (opt_arg) if (opt_arg)
options->connect_timeout=atoi(opt_arg); options->connect_timeout=atoi(opt_arg);
...@@ -538,6 +550,7 @@ static void mysql_read_default_options(struct st_mysql_options *options, ...@@ -538,6 +550,7 @@ static void mysql_read_default_options(struct st_mysql_options *options,
case 14: case 14:
case 15: case 15:
case 16: case 16:
case 26:
break; break;
case 17: /* charset-lib */ case 17: /* charset-lib */
my_free(options->charset_dir,MYF(MY_ALLOW_ZERO_PTR)); my_free(options->charset_dir,MYF(MY_ALLOW_ZERO_PTR));
...@@ -547,6 +560,15 @@ static void mysql_read_default_options(struct st_mysql_options *options, ...@@ -547,6 +560,15 @@ static void mysql_read_default_options(struct st_mysql_options *options,
my_free(options->charset_name,MYF(MY_ALLOW_ZERO_PTR)); my_free(options->charset_name,MYF(MY_ALLOW_ZERO_PTR));
options->charset_name = my_strdup(opt_arg, MYF(MY_WME)); options->charset_name = my_strdup(opt_arg, MYF(MY_WME));
break; break;
case 19: /* Interactive-timeout */
case 21: /* client_local_files */
case 22:
case 23: /* Replication options */
case 24:
case 25:
case 27: /* Protocol */
case 28: /* Shared memory */
break;
default: default:
DBUG_PRINT("warning",("unknown option: %s",option[0])); DBUG_PRINT("warning",("unknown option: %s",option[0]));
} }
...@@ -1789,7 +1811,13 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg) ...@@ -1789,7 +1811,13 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg)
mysql->options.compress=1; /* Remember for connect */ mysql->options.compress=1; /* Remember for connect */
break; break;
case MYSQL_OPT_NAMED_PIPE: case MYSQL_OPT_NAMED_PIPE:
mysql->options.named_pipe=1; /* Force named pipe */ mysql->options.protocol=MYSQL_PROTOCOL_PIPE; /* Force named pipe */
break;
case MYSQL_OPT_LOCAL_INFILE: /* Allow LOAD DATA LOCAL ?*/
if (!arg || test(*(uint*) arg))
mysql->options.client_flag|= CLIENT_LOCAL_FILES;
else
mysql->options.client_flag&= ~CLIENT_LOCAL_FILES;
break; break;
case MYSQL_INIT_COMMAND: case MYSQL_INIT_COMMAND:
my_free(mysql->options.init_command,MYF(MY_ALLOW_ZERO_PTR)); my_free(mysql->options.init_command,MYF(MY_ALLOW_ZERO_PTR));
...@@ -1811,6 +1839,11 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg) ...@@ -1811,6 +1839,11 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const char *arg)
my_free(mysql->options.charset_name,MYF(MY_ALLOW_ZERO_PTR)); my_free(mysql->options.charset_name,MYF(MY_ALLOW_ZERO_PTR));
mysql->options.charset_name=my_strdup(arg,MYF(MY_WME)); mysql->options.charset_name=my_strdup(arg,MYF(MY_WME));
break; break;
case MYSQL_OPT_PROTOCOL:
mysql->options.protocol= *(uint*) arg;
break;
case MYSQL_SHARED_MEMORY_BASE_NAME:
break;
default: default:
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
......
...@@ -76,6 +76,7 @@ static SYMBOL symbols[] = { ...@@ -76,6 +76,7 @@ static SYMBOL symbols[] = {
{ "BOTH", SYM(BOTH),0,0}, { "BOTH", SYM(BOTH),0,0},
{ "BTREE", SYM(BTREE_SYM),0,0}, { "BTREE", SYM(BTREE_SYM),0,0},
{ "BY", SYM(BY),0,0}, { "BY", SYM(BY),0,0},
{ "BYTE", SYM(BYTE_SYM), 0, 0},
{ "CACHE", SYM(CACHE_SYM),0,0}, { "CACHE", SYM(CACHE_SYM),0,0},
{ "CASCADE", SYM(CASCADE),0,0}, { "CASCADE", SYM(CASCADE),0,0},
{ "CASE", SYM(CASE_SYM),0,0}, { "CASE", SYM(CASE_SYM),0,0},
...@@ -313,6 +314,7 @@ static SYMBOL symbols[] = { ...@@ -313,6 +314,7 @@ static SYMBOL symbols[] = {
{ "RTREE", SYM(RTREE_SYM),0,0}, { "RTREE", SYM(RTREE_SYM),0,0},
{ "SECOND", SYM(SECOND_SYM),0,0}, { "SECOND", SYM(SECOND_SYM),0,0},
{ "SELECT", SYM(SELECT_SYM),0,0}, { "SELECT", SYM(SELECT_SYM),0,0},
{ "SERIAL", SYM(SERIAL_SYM),0,0},
{ "SERIALIZABLE", SYM(SERIALIZABLE_SYM),0,0}, { "SERIALIZABLE", SYM(SERIALIZABLE_SYM),0,0},
{ "SESSION", SYM(SESSION_SYM),0,0}, { "SESSION", SYM(SESSION_SYM),0,0},
{ "SET", SYM(SET),0,0}, { "SET", SYM(SET),0,0},
...@@ -369,6 +371,7 @@ static SYMBOL symbols[] = { ...@@ -369,6 +371,7 @@ static SYMBOL symbols[] = {
{ "USING", SYM(USING),0,0}, { "USING", SYM(USING),0,0},
{ "UPDATE", SYM(UPDATE_SYM),0,0}, { "UPDATE", SYM(UPDATE_SYM),0,0},
{ "USAGE", SYM(USAGE),0,0}, { "USAGE", SYM(USAGE),0,0},
{ "VALUE", SYM(VALUE_SYM),0,0},
{ "VALUES", SYM(VALUES),0,0}, { "VALUES", SYM(VALUES),0,0},
{ "VARCHAR", SYM(VARCHAR),0,0}, { "VARCHAR", SYM(VARCHAR),0,0},
{ "VARIABLES", SYM(VARIABLES),0,0}, { "VARIABLES", SYM(VARIABLES),0,0},
......
...@@ -201,6 +201,11 @@ char* query_table_status(THD *thd,const char *db,const char *table_name); ...@@ -201,6 +201,11 @@ char* query_table_status(THD *thd,const char *db,const char *table_name);
#define MODE_SERIALIZABLE 16 #define MODE_SERIALIZABLE 16
#define MODE_ONLY_FULL_GROUP_BY 32 #define MODE_ONLY_FULL_GROUP_BY 32
#define MODE_NO_UNSIGNED_SUBTRACTION 64 #define MODE_NO_UNSIGNED_SUBTRACTION 64
#define MODE_POSTGRESQL 128
#define MODE_ORACLE 256
#define MODE_MSSQL 512
#define MODE_DB2 1024
#define MODE_SAPDB 2048
#define RAID_BLOCK_SIZE 1024 #define RAID_BLOCK_SIZE 1024
......
...@@ -414,8 +414,12 @@ time_t start_time; ...@@ -414,8 +414,12 @@ time_t start_time;
ulong opt_sql_mode = 0L; ulong opt_sql_mode = 0L;
const char *sql_mode_names[] = const char *sql_mode_names[] =
{ "REAL_AS_FLOAT", "PIPES_AS_CONCAT", "ANSI_QUOTES", "IGNORE_SPACE", {
"SERIALIZE","ONLY_FULL_GROUP_BY", "NO_UNSIGNED_SUBTRACTION",NullS }; "REAL_AS_FLOAT", "PIPES_AS_CONCAT", "ANSI_QUOTES", "IGNORE_SPACE",
"SERIALIZE", "ONLY_FULL_GROUP_BY", "NO_UNSIGNED_SUBTRACTION",
"POSTGRESQL", "ORACLE", "MSSQL", "SAPDB",
NullS
};
TYPELIB sql_mode_typelib= {array_elements(sql_mode_names)-1,"", TYPELIB sql_mode_typelib= {array_elements(sql_mode_names)-1,"",
sql_mode_names}; sql_mode_names};
...@@ -4185,8 +4189,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -4185,8 +4189,8 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
break; break;
case 'a': case 'a':
opt_sql_mode = (MODE_REAL_AS_FLOAT | MODE_PIPES_AS_CONCAT | opt_sql_mode = (MODE_REAL_AS_FLOAT | MODE_PIPES_AS_CONCAT |
MODE_ANSI_QUOTES | MODE_IGNORE_SPACE | MODE_SERIALIZABLE MODE_ANSI_QUOTES | MODE_IGNORE_SPACE | MODE_SERIALIZABLE |
| MODE_ONLY_FULL_GROUP_BY); MODE_ONLY_FULL_GROUP_BY);
global_system_variables.tx_isolation= ISO_SERIALIZABLE; global_system_variables.tx_isolation= ISO_SERIALIZABLE;
break; break;
case 'b': case 'b':
......
...@@ -35,18 +35,12 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order, ...@@ -35,18 +35,12 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
SQL_SELECT *select=0; SQL_SELECT *select=0;
READ_RECORD info; READ_RECORD info;
bool using_limit=limit != HA_POS_ERROR; bool using_limit=limit != HA_POS_ERROR;
bool using_transactions, safe_update; bool using_transactions, safe_update, const_cond;
ha_rows deleted; ha_rows deleted;
DBUG_ENTER("mysql_delete"); DBUG_ENTER("mysql_delete");
if (!table_list->db) if (!table_list->db)
table_list->db=thd->db; table_list->db=thd->db;
if (((safe_update=thd->options & OPTION_SAFE_UPDATES)) && !conds)
{
send_error(thd,ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE);
DBUG_RETURN(1);
}
if (!(table = open_ltable(thd,table_list, lock_type))) if (!(table = open_ltable(thd,table_list, lock_type)))
DBUG_RETURN(-1); DBUG_RETURN(-1);
table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK); table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
...@@ -56,9 +50,17 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order, ...@@ -56,9 +50,17 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
setup_ftfuncs(&thd->lex.select_lex)) setup_ftfuncs(&thd->lex.select_lex))
DBUG_RETURN(-1); DBUG_RETURN(-1);
const_cond= (!conds || conds->const_item());
safe_update=test(thd->options & OPTION_SAFE_UPDATES);
if (safe_update && const_cond)
{
send_error(thd,ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE);
DBUG_RETURN(1);
}
/* Test if the user wants to delete all rows */ /* Test if the user wants to delete all rows */
if (!using_limit && (!conds || conds->const_item()) && if (!using_limit && const_cond &&
!(specialflag & (SPECIAL_NO_NEW_FUNC | SPECIAL_SAFE_MODE)) && !safe_update) !(specialflag & (SPECIAL_NO_NEW_FUNC | SPECIAL_SAFE_MODE)))
{ {
deleted= table->file->records; deleted= table->file->records;
if (!(error=table->file->delete_all_rows())) if (!(error=table->file->delete_all_rows()))
......
...@@ -167,6 +167,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); ...@@ -167,6 +167,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token BOTH %token BOTH
%token BTREE_SYM %token BTREE_SYM
%token BY %token BY
%token BYTE_SYM
%token CACHE_SYM %token CACHE_SYM
%token CASCADE %token CASCADE
%token CAST_SYM %token CAST_SYM
...@@ -314,6 +315,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); ...@@ -314,6 +315,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token ROW_SYM %token ROW_SYM
%token RTREE_SYM %token RTREE_SYM
%token SET %token SET
%token SERIAL_SYM
%token SERIALIZABLE_SYM %token SERIALIZABLE_SYM
%token SESSION_SYM %token SESSION_SYM
%token SIMPLE_SYM %token SIMPLE_SYM
...@@ -349,6 +351,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); ...@@ -349,6 +351,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%token USE_FRM %token USE_FRM
%token USE_SYM %token USE_SYM
%token USING %token USING
%token VALUE_SYM
%token VALUES %token VALUES
%token VARIABLES %token VARIABLES
%token WHERE %token WHERE
...@@ -1058,7 +1061,13 @@ type: ...@@ -1058,7 +1061,13 @@ type:
| YEAR_SYM opt_len field_options { $$=FIELD_TYPE_YEAR; Lex->length=$2; } | YEAR_SYM opt_len field_options { $$=FIELD_TYPE_YEAR; Lex->length=$2; }
| DATE_SYM { $$=FIELD_TYPE_DATE; } | DATE_SYM { $$=FIELD_TYPE_DATE; }
| TIME_SYM { $$=FIELD_TYPE_TIME; } | TIME_SYM { $$=FIELD_TYPE_TIME; }
| TIMESTAMP { $$=FIELD_TYPE_TIMESTAMP; } | TIMESTAMP
{
if (current_thd->sql_mode & MODE_SAPDB)
$$=FIELD_TYPE_DATETIME;
else
$$=FIELD_TYPE_TIMESTAMP;
}
| TIMESTAMP '(' NUM ')' { Lex->length=$3.str; | TIMESTAMP '(' NUM ')' { Lex->length=$3.str;
$$=FIELD_TYPE_TIMESTAMP; } $$=FIELD_TYPE_TIMESTAMP; }
| DATETIME { $$=FIELD_TYPE_DATETIME; } | DATETIME { $$=FIELD_TYPE_DATETIME; }
...@@ -1094,7 +1103,11 @@ type: ...@@ -1094,7 +1103,11 @@ type:
LEX *lex=Lex; LEX *lex=Lex;
lex->interval=typelib(lex->interval_list); lex->interval=typelib(lex->interval_list);
$$=FIELD_TYPE_SET; $$=FIELD_TYPE_SET;
}; }
| LONG_SYM { $$=FIELD_TYPE_MEDIUM_BLOB; }
| LONG_SYM BINARY { Lex->charset=my_charset_bin;
$$=FIELD_TYPE_MEDIUM_BLOB; }
;
char: char:
CHAR_SYM {} CHAR_SYM {}
...@@ -1167,6 +1180,8 @@ attribute: ...@@ -1167,6 +1180,8 @@ attribute:
| NOT NULL_SYM { Lex->type|= NOT_NULL_FLAG; } | NOT NULL_SYM { Lex->type|= NOT_NULL_FLAG; }
| DEFAULT literal { Lex->default_value=$2; } | DEFAULT literal { Lex->default_value=$2; }
| AUTO_INC { Lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG; } | AUTO_INC { Lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG; }
| SERIAL_SYM DEFAULT VALUE_SYM
{ Lex->type|= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG; }
| PRIMARY_SYM KEY_SYM { Lex->type|= PRI_KEY_FLAG | NOT_NULL_FLAG; } | PRIMARY_SYM KEY_SYM { Lex->type|= PRI_KEY_FLAG | NOT_NULL_FLAG; }
| UNIQUE_SYM { Lex->type|= UNIQUE_FLAG; } | UNIQUE_SYM { Lex->type|= UNIQUE_FLAG; }
| UNIQUE_SYM KEY_SYM { Lex->type|= UNIQUE_KEY_FLAG; } | UNIQUE_SYM KEY_SYM { Lex->type|= UNIQUE_KEY_FLAG; }
...@@ -1205,6 +1220,7 @@ opt_db_default_character_set: ...@@ -1205,6 +1220,7 @@ opt_db_default_character_set:
opt_binary: opt_binary:
/* empty */ { Lex->charset=NULL; } /* empty */ { Lex->charset=NULL; }
| BYTE_SYM { Lex->charset=my_charset_bin; }
| BINARY { Lex->charset=my_charset_bin; } | BINARY { Lex->charset=my_charset_bin; }
| CHAR_SYM SET charset_name { Lex->charset=$3; } ; | CHAR_SYM SET charset_name { Lex->charset=$3; } ;
...@@ -3493,6 +3509,7 @@ keyword: ...@@ -3493,6 +3509,7 @@ keyword:
| BIT_SYM {} | BIT_SYM {}
| BOOL_SYM {} | BOOL_SYM {}
| BOOLEAN_SYM {} | BOOLEAN_SYM {}
| BYTE_SYM {}
| CACHE_SYM {} | CACHE_SYM {}
| CHANGED {} | CHANGED {}
| CHARSET {} | CHARSET {}
...@@ -3605,6 +3622,7 @@ keyword: ...@@ -3605,6 +3622,7 @@ keyword:
| ROW_FORMAT_SYM {} | ROW_FORMAT_SYM {}
| ROW_SYM {} | ROW_SYM {}
| SECOND_SYM {} | SECOND_SYM {}
| SERIAL_SYM {}
| SERIALIZABLE_SYM {} | SERIALIZABLE_SYM {}
| SESSION_SYM {} | SESSION_SYM {}
| SIGNED_SYM {} | SIGNED_SYM {}
...@@ -3633,6 +3651,7 @@ keyword: ...@@ -3633,6 +3651,7 @@ keyword:
| UNCOMMITTED_SYM {} | UNCOMMITTED_SYM {}
| USE_FRM {} | USE_FRM {}
| VARIABLES {} | VARIABLES {}
| VALUE_SYM {}
| WORK_SYM {} | WORK_SYM {}
| YEAR_SYM {} | YEAR_SYM {}
; ;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment