mirror of
https://github.com/MariaDB/server.git
synced 2026-05-06 15:15:34 +02:00
subselect with union
new error handling Item_ref bug fixed include/mysql_com.h: new error handling query cache pointer description mysql-test/r/distinct.result: new result's after Monty's bug fixing mysql-test/r/subselect.result: subselect with union test mysql-test/t/subselect.test: subselect with union test sql/item.cc: subselect with union Item_ref bug fixed sql/item_cmpfunc.cc: Monty's bug fixing sql/item_subselect.cc: TODO changing subselect with union sql/item_subselect.h: subselect with union sql/mysql_priv.h: Item_ref bug fixed sql/mysqld.cc: new error handling sql/net_pkg.cc: new error handling sql/net_serv.cc: new error handling sql/sql_base.cc: Item_ref bug fixed sql/sql_class.cc: new error handling sql/sql_class.h: new error handling sql/sql_derived.cc: subselect with union sql/sql_insert.cc: new error handling (only with mysql_select now) sql/sql_lex.cc: subselect with union sql/sql_lex.h: subselect with union sql/sql_parse.cc: new error handling sql/sql_select.cc: new error handling subselect with union removed thd->where=0 hack sql/sql_select.h: subselect with union sql/sql_union.cc: subselect with union sql/sql_update.cc: new error handling (only with mysql_select now) sql/sql_yacc.yy: subselect with union
This commit is contained in:
parent
1648e47889
commit
3fbcafea9c
25 changed files with 658 additions and 354 deletions
|
|
@ -20,31 +20,25 @@
|
|||
#pragma interface /* gcc class implementation */
|
||||
#endif
|
||||
|
||||
struct st_select_lex;
|
||||
class st_select_lex;
|
||||
class st_select_lex_unit;
|
||||
class JOIN;
|
||||
class select_subselect;
|
||||
class subselect_engine;
|
||||
|
||||
/* base class for subselects */
|
||||
|
||||
class Item_subselect :public Item
|
||||
{
|
||||
my_bool engine_owner; /* Is this item owner of engine */
|
||||
my_bool value_assigned; /* value already assigned to subselect */
|
||||
protected:
|
||||
/* engine that perform execution of subselect (single select or union) */
|
||||
subselect_engine *engine;
|
||||
/* allowed number of columns (1 for single value subqueries) */
|
||||
uint max_columns;
|
||||
my_bool assigned; /* value already assigned to subselect */
|
||||
my_bool executed; /* simple subselect is executed */
|
||||
my_bool optimized; /* simple subselect is optimized */
|
||||
my_bool error; /* error in query */
|
||||
|
||||
int exec();
|
||||
virtual void assign_null()
|
||||
{
|
||||
null_value= 1;
|
||||
}
|
||||
public:
|
||||
st_select_lex *select_lex;
|
||||
JOIN *join;
|
||||
select_subselect *result;
|
||||
|
||||
Item_subselect(THD *thd, st_select_lex *select_lex,
|
||||
select_subselect* result);
|
||||
Item_subselect(Item_subselect *item)
|
||||
|
|
@ -52,14 +46,17 @@ public:
|
|||
null_value= item->null_value;
|
||||
decimals= item->decimals;
|
||||
max_columns= item->max_columns;
|
||||
assigned= item->assigned;
|
||||
executed= item->executed;
|
||||
select_lex= item->select_lex;
|
||||
join= item->join;
|
||||
result= item->result;
|
||||
engine= item->engine;
|
||||
engine_owner= 0;
|
||||
name= item->name;
|
||||
error= item->error;
|
||||
}
|
||||
~Item_subselect();
|
||||
virtual void assign_null()
|
||||
{
|
||||
null_value= 1;
|
||||
}
|
||||
bool assigned() { return value_assigned; }
|
||||
void assigned(bool a) { value_assigned= a; }
|
||||
enum Type type() const;
|
||||
bool is_null() { return null_value; }
|
||||
void make_field (Send_field *);
|
||||
|
|
@ -75,18 +72,10 @@ public:
|
|||
class Item_singleval_subselect :public Item_subselect
|
||||
{
|
||||
protected:
|
||||
longlong int_value;
|
||||
double real_value;
|
||||
enum Item_result res_type;
|
||||
longlong int_value; /* here stored integer value of this item */
|
||||
double real_value; /* here stored real value of this item */
|
||||
enum Item_result res_type; /* type of results */
|
||||
|
||||
virtual void assign_null()
|
||||
{
|
||||
null_value= 1;
|
||||
int_value= 0;
|
||||
real_value= 0;
|
||||
max_length= 4;
|
||||
res_type= STRING_RESULT;
|
||||
}
|
||||
public:
|
||||
Item_singleval_subselect(THD *thd, st_select_lex *select_lex);
|
||||
Item_singleval_subselect(Item_singleval_subselect *item):
|
||||
|
|
@ -98,6 +87,14 @@ public:
|
|||
decimals= item->decimals;
|
||||
res_type= item->res_type;
|
||||
}
|
||||
virtual void assign_null()
|
||||
{
|
||||
null_value= 1;
|
||||
int_value= 0;
|
||||
real_value= 0;
|
||||
max_length= 4;
|
||||
res_type= STRING_RESULT;
|
||||
}
|
||||
double val ();
|
||||
longlong val_int ();
|
||||
String *val_str (String *);
|
||||
|
|
@ -112,12 +109,8 @@ public:
|
|||
class Item_exists_subselect :public Item_subselect
|
||||
{
|
||||
protected:
|
||||
longlong value;
|
||||
longlong value; /* value of this item (boolean: exists/not-exists) */
|
||||
|
||||
virtual void assign_null()
|
||||
{
|
||||
value= 0;
|
||||
}
|
||||
public:
|
||||
Item_exists_subselect(THD *thd, st_select_lex *select_lex);
|
||||
Item_exists_subselect(Item_exists_subselect *item):
|
||||
|
|
@ -125,6 +118,11 @@ public:
|
|||
{
|
||||
value= item->value;
|
||||
}
|
||||
virtual void assign_null()
|
||||
{
|
||||
value= 0;
|
||||
}
|
||||
|
||||
Item *new_item() { return new Item_exists_subselect(this); }
|
||||
enum Item_result result_type() const { return INT_RESULT;}
|
||||
longlong val_int();
|
||||
|
|
@ -133,3 +131,58 @@ public:
|
|||
|
||||
friend class select_exists_subselect;
|
||||
};
|
||||
|
||||
class subselect_engine
|
||||
{
|
||||
protected:
|
||||
select_subselect *result; /* results storage class */
|
||||
THD *thd; /* pointer to current THD */
|
||||
Item_subselect *item; /* item, that use this engine */
|
||||
public:
|
||||
static void *operator new(size_t size)
|
||||
{
|
||||
return (void*) sql_alloc((uint) size);
|
||||
}
|
||||
static void operator delete(void *ptr, size_t size) {}
|
||||
|
||||
subselect_engine(THD *thd, Item_subselect *si, select_subselect *res)
|
||||
{
|
||||
result= res;
|
||||
item= si;
|
||||
this->thd= thd;
|
||||
}
|
||||
virtual int prepare()= 0;
|
||||
virtual int exec()= 0;
|
||||
virtual uint cols()= 0; /* return number of columnss in select */
|
||||
virtual bool depended()= 0; /* depended from outer select */
|
||||
};
|
||||
|
||||
class subselect_single_select_engine: public subselect_engine
|
||||
{
|
||||
my_bool executed; /* simple subselect is executed */
|
||||
my_bool optimized; /* simple subselect is optimized */
|
||||
st_select_lex *select_lex; /* corresponding select_lex */
|
||||
JOIN * join; /* corresponding JOIN structure */
|
||||
public:
|
||||
subselect_single_select_engine(THD *thd, st_select_lex *select,
|
||||
select_subselect *result,
|
||||
Item_subselect *item);
|
||||
virtual int prepare();
|
||||
virtual int exec();
|
||||
virtual uint cols();
|
||||
virtual bool depended();
|
||||
};
|
||||
|
||||
class subselect_union_engine: public subselect_engine
|
||||
{
|
||||
st_select_lex_unit *unit; /* corresponding unit structure */
|
||||
public:
|
||||
subselect_union_engine(THD *thd,
|
||||
st_select_lex_unit *u,
|
||||
select_subselect *result,
|
||||
Item_subselect *item);
|
||||
virtual int prepare();
|
||||
virtual int exec();
|
||||
virtual uint cols();
|
||||
virtual bool depended();
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue