@@ -99,6 +99,13 @@ void item_init(void)
9999}
100100
101101
102+ void Item::raise_error_not_evaluable ()
103+ {
104+ Item::Print tmp (this , QT_ORDINARY);
105+ my_error (ER_NOT_ALLOWED_IN_THIS_CONTEXT, MYF (0 ), tmp.ptr ());
106+ }
107+
108+
102109void Item::push_note_converted_to_negative_complement (THD *thd)
103110{
104111 push_warning (thd, Sql_condition::WARN_LEVEL_NOTE, ER_UNKNOWN_ERROR,
@@ -4298,6 +4305,23 @@ int Item_param::save_in_field(Field *field, bool no_conversions)
42984305}
42994306
43004307
4308+ bool Item_param::is_evaluable_expression () const
4309+ {
4310+ switch (state) {
4311+ case SHORT_DATA_VALUE:
4312+ case LONG_DATA_VALUE:
4313+ case NULL_VALUE:
4314+ return true ;
4315+ case NO_VALUE:
4316+ return true ; // Not assigned yet, so we don't know
4317+ case IGNORE_VALUE:
4318+ case DEFAULT_VALUE:
4319+ break ;
4320+ }
4321+ return false ;
4322+ }
4323+
4324+
43014325bool Item_param::can_return_value () const
43024326{
43034327 // There's no "default". See comments in Item_param::save_in_field().
@@ -9229,12 +9253,7 @@ bool Item_default_value::fix_fields(THD *thd, Item **items)
92299253 Item_field *field_arg;
92309254 Field *def_field;
92319255 DBUG_ASSERT (fixed == 0 );
9232-
9233- if (!arg)
9234- {
9235- fixed= 1 ;
9236- return FALSE ;
9237- }
9256+ DBUG_ASSERT (arg);
92389257
92399258 /*
92409259 DEFAULT() do not need table field so should not ask handler to bring
@@ -9309,11 +9328,7 @@ void Item_default_value::cleanup()
93099328
93109329void Item_default_value::print (String *str, enum_query_type query_type)
93119330{
9312- if (!arg)
9313- {
9314- str->append (STRING_WITH_LEN (" default" ));
9315- return ;
9316- }
9331+ DBUG_ASSERT (arg);
93179332 str->append (STRING_WITH_LEN (" default(" ));
93189333 /*
93199334 We take DEFAULT from a field so do not need it value in case of const
@@ -9327,6 +9342,7 @@ void Item_default_value::print(String *str, enum_query_type query_type)
93279342
93289343void Item_default_value::calculate ()
93299344{
9345+ DBUG_ASSERT (arg);
93309346 if (field->default_value )
93319347 field->set_default ();
93329348 DEBUG_SYNC (field->table ->in_use , " after_Item_default_value_calculate" );
@@ -9370,14 +9386,8 @@ bool Item_default_value::send(Protocol *protocol, st_value *buffer)
93709386
93719387int Item_default_value::save_in_field (Field *field_arg, bool no_conversions)
93729388{
9373- if (arg)
9374- {
9375- calculate ();
9376- return Item_field::save_in_field (field_arg, no_conversions);
9377- }
9378-
9379- return field_arg->save_in_field_default_value (context->error_processor ==
9380- &view_error_processor);
9389+ calculate ();
9390+ return Item_field::save_in_field (field_arg, no_conversions);
93819391}
93829392
93839393table_map Item_default_value::used_tables () const
@@ -9398,13 +9408,7 @@ Item *Item_default_value::transform(THD *thd, Item_transformer transformer,
93989408 uchar *args)
93999409{
94009410 DBUG_ASSERT (!thd->stmt_arena ->is_stmt_prepare ());
9401-
9402- /*
9403- If the value of arg is NULL, then this object represents a constant,
9404- so further transformation is unnecessary (and impossible).
9405- */
9406- if (!arg)
9407- return 0 ;
9411+ DBUG_ASSERT (arg);
94089412
94099413 Item *new_item= arg->transform (thd, transformer, args);
94109414 if (!new_item)
@@ -9421,57 +9425,6 @@ Item *Item_default_value::transform(THD *thd, Item_transformer transformer,
94219425 return (this ->*transformer)(thd, args);
94229426}
94239427
9424- void Item_ignore_value::print (String *str, enum_query_type query_type)
9425- {
9426- str->append (STRING_WITH_LEN (" ignore" ));
9427- }
9428-
9429- int Item_ignore_value::save_in_field (Field *field_arg, bool no_conversions)
9430- {
9431- return field_arg->save_in_field_ignore_value (context->error_processor ==
9432- &view_error_processor);
9433- }
9434-
9435- String *Item_ignore_value::val_str (String *str)
9436- {
9437- DBUG_ASSERT (0 ); // never should be called
9438- null_value= 1 ;
9439- return 0 ;
9440- }
9441-
9442- double Item_ignore_value::val_real ()
9443- {
9444- DBUG_ASSERT (0 ); // never should be called
9445- null_value= 1 ;
9446- return 0.0 ;
9447- }
9448-
9449- longlong Item_ignore_value::val_int ()
9450- {
9451- DBUG_ASSERT (0 ); // never should be called
9452- null_value= 1 ;
9453- return 0 ;
9454- }
9455-
9456- my_decimal *Item_ignore_value::val_decimal (my_decimal *decimal_value)
9457- {
9458- DBUG_ASSERT (0 ); // never should be called
9459- null_value= 1 ;
9460- return 0 ;
9461- }
9462-
9463- bool Item_ignore_value::get_date (THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
9464- {
9465- DBUG_ASSERT (0 ); // never should be called
9466- null_value= 1 ;
9467- return TRUE ;
9468- }
9469-
9470- bool Item_ignore_value::send (Protocol *protocol, st_value *buffer)
9471- {
9472- DBUG_ASSERT (0 ); // never should be called
9473- return TRUE ;
9474- }
94759428
94769429bool Item_insert_value::eq (const Item *item, bool binary_cmp) const
94779430{
0 commit comments