mirror of
https://github.com/MariaDB/server.git
synced 2026-05-15 03:17:20 +02:00
EXISTS type of subselect
more correct parameters in result creation script mysql-test/create-test-result: more correct parameters in result creation script mysql-test/r/subselect.result: test of EXISTS mysql-test/t/subselect.test: test of EXISTS sql/item_subselect.cc: EXISTS type of subselect sql/item_subselect.h: EXISTS type of subselect sql/sql_class.cc: EXISTS type of subselect sql/sql_class.h: EXISTS type of subselect sql/sql_yacc.yy: EXISTS type of subselect
This commit is contained in:
parent
454712d20e
commit
c6a2ae17a0
8 changed files with 235 additions and 79 deletions
|
|
@ -24,42 +24,34 @@ struct st_select_lex;
|
|||
class JOIN;
|
||||
class select_subselect;
|
||||
|
||||
/* simple (not depended of covered select ) subselect */
|
||||
/* base class for subselects */
|
||||
|
||||
class Item_subselect :public Item
|
||||
{
|
||||
protected:
|
||||
longlong int_value;
|
||||
double real_value;
|
||||
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 */
|
||||
enum Item_result res_type;
|
||||
|
||||
int exec();
|
||||
void assign_null()
|
||||
virtual void assign_null()
|
||||
{
|
||||
null_value= 1;
|
||||
int_value= 0;
|
||||
real_value= 0;
|
||||
max_length= 4;
|
||||
res_type= STRING_RESULT;
|
||||
}
|
||||
public:
|
||||
st_select_lex *select_lex;
|
||||
JOIN *join;
|
||||
select_subselect *result;
|
||||
|
||||
Item_subselect(THD *thd, st_select_lex *select_lex);
|
||||
Item_subselect(THD *thd, st_select_lex *select_lex,
|
||||
select_subselect* result);
|
||||
Item_subselect(Item_subselect *item)
|
||||
{
|
||||
null_value= item->null_value;
|
||||
int_value= item->int_value;
|
||||
real_value= item->real_value;
|
||||
max_length= item->max_length;
|
||||
decimals= item->decimals;
|
||||
res_type= item->res_type;
|
||||
max_columns= item->max_columns;
|
||||
assigned= item->assigned;
|
||||
executed= item->executed;
|
||||
select_lex= item->select_lex;
|
||||
|
|
@ -69,16 +61,75 @@ public:
|
|||
error= item->error;
|
||||
}
|
||||
enum Type type() const;
|
||||
double val ();
|
||||
longlong val_int ();
|
||||
String *val_str (String *);
|
||||
bool is_null() { return null_value; }
|
||||
void make_field (Send_field *);
|
||||
bool fix_fields(THD *thd, TABLE_LIST *tables);
|
||||
Item *new_item() { return new Item_subselect(this); }
|
||||
enum Item_result result_type() const { return res_type; }
|
||||
table_map used_tables() const;
|
||||
|
||||
friend class select_subselect;
|
||||
};
|
||||
|
||||
|
||||
/* single value subselect */
|
||||
|
||||
class Item_singleval_subselect :public Item_subselect
|
||||
{
|
||||
protected:
|
||||
longlong int_value;
|
||||
double real_value;
|
||||
enum Item_result res_type;
|
||||
|
||||
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):
|
||||
Item_subselect(item)
|
||||
{
|
||||
int_value= item->int_value;
|
||||
real_value= item->real_value;
|
||||
max_length= item->max_length;
|
||||
decimals= item->decimals;
|
||||
res_type= item->res_type;
|
||||
}
|
||||
double val ();
|
||||
longlong val_int ();
|
||||
String *val_str (String *);
|
||||
Item *new_item() { return new Item_singleval_subselect(this); }
|
||||
enum Item_result result_type() const { return res_type; }
|
||||
|
||||
friend class select_singleval_subselect;
|
||||
};
|
||||
|
||||
/* exists subselect */
|
||||
|
||||
class Item_exists_subselect :public Item_subselect
|
||||
{
|
||||
protected:
|
||||
longlong value;
|
||||
|
||||
virtual void assign_null()
|
||||
{
|
||||
value= 0;
|
||||
}
|
||||
public:
|
||||
Item_exists_subselect(THD *thd, st_select_lex *select_lex);
|
||||
Item_exists_subselect(Item_exists_subselect *item):
|
||||
Item_subselect(item)
|
||||
{
|
||||
value= item->value;
|
||||
}
|
||||
Item *new_item() { return new Item_exists_subselect(this); }
|
||||
enum Item_result result_type() const { return INT_RESULT;}
|
||||
longlong val_int();
|
||||
double val();
|
||||
String *val_str(String*);
|
||||
|
||||
friend class select_exists_subselect;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue