mirror of
https://github.com/MariaDB/server.git
synced 2025-09-11 05:52:26 +03:00
Under strict mode MySQL will generate an error message if there was any conversion when assigning data to a field. Added checking of date/datetime fields. If strict mode, give error if we have not given value to field without a default value (for INSERT) client/mysqltest.c: Added --exit as an option to abort a test in a middle (good for debugging) include/my_time.h: Added flags to allow checking of dates in strict mode include/mysql_com.h: Added flag to check if field has a default value or not include/mysqld_error.h: New error messages for strict mode include/sql_state.h: Fixed SQL states (for strict mode tests) mysql-test/r/auto_increment.result: Updated error messages mysql-test/r/func_sapdb.result: Added test for ALLOW_INVALID_DATES mysql-test/r/func_str.result: Updated error messages mysql-test/r/func_time.result: Updated error messages mysql-test/r/insert.result: Updated error messages mysql-test/r/loaddata.result: Updated error messages mysql-test/r/select.result: Updated error messages mysql-test/r/sp.result: Updated error messages mysql-test/r/timezone2.result: Updated error messages mysql-test/r/type_datetime.result: Updated error messages mysql-test/r/type_decimal.result: Updated error messages mysql-test/r/type_float.result: Updated error messages mysql-test/r/type_ranges.result: Updated error messages mysql-test/r/type_time.result: Updated error messages mysql-test/r/type_uint.result: Updated error messages mysql-test/r/warnings.result: Updated error messages mysql-test/t/func_sapdb.test: Aded test sql-common/my_time.c: Added checking of dates sql/field.cc: Better error messages Optimization of warning handling (by introducing of check_int()) Changed to use my_strtoll10() sql/field.h: Added check_int() sql/item_func.cc: Warnings when dividing by NULL sql/item_func.h: Warnings when dividing by NULL sql/item_timefunc.cc: Testing of date/datetime Use macros instead of constants sql/mysql_priv.h: New modes (part of strict mode) sql/mysqld.cc: New modes (part of strict mode) sql/opt_range.cc: Simple optimizations sql/protocol.cc: Add note/warning level to find_handler() sql/set_var.cc: Added mode 'traditional' sql/share/czech/errmsg.txt: New error messages for strict mode sql/share/danish/errmsg.txt: New error messages for strict mode sql/share/dutch/errmsg.txt: New error messages for strict mode sql/share/english/errmsg.txt: New error messages for strict mode sql/share/estonian/errmsg.txt: New error messages for strict mode sql/share/french/errmsg.txt: New error messages for strict mode sql/share/german/errmsg.txt: New error messages for strict mode sql/share/greek/errmsg.txt: New error messages for strict mode sql/share/hungarian/errmsg.txt: New error messages for strict mode sql/share/italian/errmsg.txt: New error messages for strict mode sql/share/japanese/errmsg.txt: New error messages for strict mode sql/share/korean/errmsg.txt: New error messages for strict mode sql/share/norwegian-ny/errmsg.txt: New error messages for strict mode sql/share/norwegian/errmsg.txt: New error messages for strict mode sql/share/polish/errmsg.txt: New error messages for strict mode sql/share/portuguese/errmsg.txt: New error messages for strict mode sql/share/romanian/errmsg.txt: New error messages for strict mode sql/share/russian/errmsg.txt: New error messages for strict mode sql/share/serbian/errmsg.txt: New error messages for strict mode sql/share/slovak/errmsg.txt: New error messages for strict mode sql/share/spanish/errmsg.txt: New error messages for strict mode sql/share/swedish/errmsg.txt: New error messages for strict mode sql/share/ukrainian/errmsg.txt: New error messages for strict mode sql/sp_rcontext.cc: Add note/warning level to find_handler() sql/sp_rcontext.h: Add note/warning level to find_handler() sql/sql_base.cc: Fix bug for detecting crashed table sql/sql_class.cc: Variables for strct mode sql/sql_class.h: Variables for strct mode sql/sql_error.cc: In strict mode, convert warnings to errors sql/sql_insert.cc: Strict mode If strict mode, give error if we have not given value to field without a default value sql/sql_load.cc: Strict mode sql/sql_parse.cc: Strict mode. Add flag to field if it doesn't have a default value sql/sql_select.cc: Added comment Prepare for upper level handling of table->status sql/sql_union.cc: Added THD to write_record() sql/sql_update.cc: Strict mode sql/table.cc: Handling of default values sql/time.cc: Checking of dates
256 lines
4.7 KiB
C++
256 lines
4.7 KiB
C++
/* -*- C++ -*- */
|
|
/* Copyright (C) 2002 MySQL AB
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
#ifndef _SP_RCONTEXT_H_
|
|
#define _SP_RCONTEXT_H_
|
|
|
|
#ifdef __GNUC__
|
|
#pragma interface /* gcc class implementation */
|
|
#endif
|
|
|
|
struct sp_cond_type;
|
|
class sp_cursor;
|
|
struct sp_pvar;
|
|
|
|
#define SP_HANDLER_NONE 0
|
|
#define SP_HANDLER_EXIT 1
|
|
#define SP_HANDLER_CONTINUE 2
|
|
#define SP_HANDLER_UNDO 3
|
|
|
|
typedef struct
|
|
{
|
|
struct sp_cond_type *cond;
|
|
uint handler; // Location of handler
|
|
int type;
|
|
uint foffset; // Frame offset for the handlers declare level
|
|
} sp_handler_t;
|
|
|
|
class sp_rcontext : public Sql_alloc
|
|
{
|
|
sp_rcontext(const sp_rcontext &); /* Prevent use of these */
|
|
void operator=(sp_rcontext &);
|
|
|
|
public:
|
|
|
|
bool in_handler;
|
|
|
|
sp_rcontext(uint fsize, uint hmax, uint cmax);
|
|
|
|
~sp_rcontext()
|
|
{
|
|
// Not needed?
|
|
//sql_element_free(m_frame);
|
|
//m_saved.empty();
|
|
}
|
|
|
|
inline void
|
|
push_item(Item *i)
|
|
{
|
|
if (m_count < m_fsize)
|
|
m_frame[m_count++] = i;
|
|
}
|
|
|
|
inline void
|
|
set_item(uint idx, Item *i)
|
|
{
|
|
if (idx < m_count)
|
|
m_frame[idx] = i;
|
|
}
|
|
|
|
/* Returns 0 on success, -1 on (eval) failure */
|
|
int
|
|
set_item_eval(uint idx, Item *i, enum_field_types type);
|
|
|
|
inline Item *
|
|
get_item(uint idx)
|
|
{
|
|
return m_frame[idx];
|
|
}
|
|
|
|
inline void
|
|
set_oindex(uint idx, int oidx)
|
|
{
|
|
m_outs[idx] = oidx;
|
|
}
|
|
|
|
inline int
|
|
get_oindex(uint idx)
|
|
{
|
|
return m_outs[idx];
|
|
}
|
|
|
|
inline void
|
|
set_result(Item *it)
|
|
{
|
|
m_result= it;
|
|
}
|
|
|
|
inline Item *
|
|
get_result()
|
|
{
|
|
return m_result;
|
|
}
|
|
|
|
inline void
|
|
push_handler(struct sp_cond_type *cond, uint h, int type, uint f)
|
|
{
|
|
m_handler[m_hcount].cond= cond;
|
|
m_handler[m_hcount].handler= h;
|
|
m_handler[m_hcount].type= type;
|
|
m_handler[m_hcount].foffset= f;
|
|
m_hcount+= 1;
|
|
}
|
|
|
|
inline void
|
|
pop_handlers(uint count)
|
|
{
|
|
m_hcount-= count;
|
|
}
|
|
|
|
// Returns 1 if a handler was found, 0 otherwise.
|
|
int
|
|
find_handler(uint sql_errno,MYSQL_ERROR::enum_warning_level level);
|
|
|
|
// Returns handler type and sets *ip to location if one was found
|
|
inline int
|
|
found_handler(uint *ip, uint *fp)
|
|
{
|
|
if (m_hfound < 0)
|
|
return SP_HANDLER_NONE;
|
|
*ip= m_handler[m_hfound].handler;
|
|
*fp= m_handler[m_hfound].foffset;
|
|
return m_handler[m_hfound].type;
|
|
}
|
|
|
|
// Clears the handler find state
|
|
inline void
|
|
clear_handler()
|
|
{
|
|
m_hfound= -1;
|
|
}
|
|
|
|
inline void
|
|
push_hstack(uint h)
|
|
{
|
|
m_hstack[m_hsp++]= h;
|
|
}
|
|
|
|
inline uint
|
|
pop_hstack()
|
|
{
|
|
return m_hstack[--m_hsp];
|
|
}
|
|
|
|
// Save variables starting at fp and up
|
|
void
|
|
save_variables(uint fp);
|
|
|
|
// Restore variables down to fp
|
|
void
|
|
restore_variables(uint fp);
|
|
|
|
void
|
|
push_cursor(LEX *lex);
|
|
|
|
void
|
|
pop_cursors(uint count);
|
|
|
|
void
|
|
pop_all_cursors()
|
|
{
|
|
pop_cursors(m_ccount);
|
|
}
|
|
|
|
inline sp_cursor *
|
|
get_cursor(uint i)
|
|
{
|
|
return m_cstack[i];
|
|
}
|
|
|
|
private:
|
|
|
|
uint m_count;
|
|
uint m_fsize;
|
|
Item **m_frame;
|
|
int *m_outs;
|
|
|
|
Item *m_result; // For FUNCTIONs
|
|
|
|
sp_handler_t *m_handler;
|
|
uint m_hcount;
|
|
uint *m_hstack;
|
|
uint m_hsp;
|
|
int m_hfound; // Set by find_handler; -1 if not found
|
|
List<Item> m_saved; // Saved variables
|
|
|
|
sp_cursor **m_cstack;
|
|
uint m_ccount;
|
|
|
|
}; // class sp_rcontext : public Sql_alloc
|
|
|
|
|
|
class sp_cursor : public Sql_alloc
|
|
{
|
|
public:
|
|
|
|
sp_cursor(LEX *lex)
|
|
: m_lex(lex), m_prot(NULL), m_isopen(0), m_current_row(NULL)
|
|
{
|
|
/* Empty */
|
|
}
|
|
|
|
virtual ~sp_cursor()
|
|
{
|
|
destroy();
|
|
}
|
|
|
|
// We have split this in two to make it easy for sp_instr_copen
|
|
// to reuse the sp_instr::exec_stmt() code.
|
|
LEX *
|
|
pre_open(THD *thd);
|
|
void
|
|
post_open(THD *thd, my_bool was_opened);
|
|
|
|
int
|
|
close(THD *thd);
|
|
|
|
inline my_bool
|
|
is_open()
|
|
{
|
|
return m_isopen;
|
|
}
|
|
|
|
int
|
|
fetch(THD *, List<struct sp_pvar> *vars);
|
|
|
|
private:
|
|
|
|
MEM_ROOT m_mem_root; // My own mem_root
|
|
LEX *m_lex;
|
|
Protocol_cursor *m_prot;
|
|
my_bool m_isopen;
|
|
my_bool m_nseof; // Original no_send_eof
|
|
Protocol *m_oprot; // Original protcol
|
|
MYSQL_ROWS *m_current_row;
|
|
|
|
void
|
|
destroy();
|
|
|
|
}; // class sp_cursor : public Sql_alloc
|
|
|
|
#endif /* _SP_RCONTEXT_H_ */
|