@@ -99,6 +99,15 @@ void item_init(void)
99
99
}
100
100
101
101
102
+ void Item::raise_error_not_evaluable ()
103
+ {
104
+ Item::Print tmp (this , QT_ORDINARY);
105
+ // TODO-10.5: add an error message to errmsg-utf8.txt
106
+ my_printf_error (ER_UNKNOWN_ERROR,
107
+ " '%s' is not allowed in this context" , MYF (0 ), tmp.ptr ());
108
+ }
109
+
110
+
102
111
void Item::push_note_converted_to_negative_complement (THD *thd)
103
112
{
104
113
push_warning (thd, Sql_condition::WARN_LEVEL_NOTE, ER_UNKNOWN_ERROR,
@@ -4547,6 +4556,23 @@ int Item_param::save_in_field(Field *field, bool no_conversions)
4547
4556
}
4548
4557
4549
4558
4559
+ bool Item_param::is_evaluable_expression () const
4560
+ {
4561
+ switch (state) {
4562
+ case SHORT_DATA_VALUE:
4563
+ case LONG_DATA_VALUE:
4564
+ case NULL_VALUE:
4565
+ return true ;
4566
+ case NO_VALUE:
4567
+ return true ; // Not assigned yet, so we don't know
4568
+ case IGNORE_VALUE:
4569
+ case DEFAULT_VALUE:
4570
+ break ;
4571
+ }
4572
+ return false ;
4573
+ }
4574
+
4575
+
4550
4576
bool Item_param::can_return_value () const
4551
4577
{
4552
4578
// There's no "default". See comments in Item_param::save_in_field().
@@ -9308,12 +9334,7 @@ bool Item_default_value::fix_fields(THD *thd, Item **items)
9308
9334
Item_field *field_arg;
9309
9335
Field *def_field;
9310
9336
DBUG_ASSERT (fixed == 0 );
9311
-
9312
- if (!arg)
9313
- {
9314
- fixed= 1 ;
9315
- return FALSE ;
9316
- }
9337
+ DBUG_ASSERT (arg);
9317
9338
9318
9339
/*
9319
9340
DEFAULT() do not need table field so should not ask handler to bring
@@ -9389,11 +9410,7 @@ void Item_default_value::cleanup()
9389
9410
9390
9411
void Item_default_value::print (String *str, enum_query_type query_type)
9391
9412
{
9392
- if (!arg)
9393
- {
9394
- str->append (STRING_WITH_LEN (" default" ));
9395
- return ;
9396
- }
9413
+ DBUG_ASSERT (arg);
9397
9414
str->append (STRING_WITH_LEN (" default(" ));
9398
9415
/*
9399
9416
We take DEFAULT from a field so do not need it value in case of const
@@ -9407,6 +9424,7 @@ void Item_default_value::print(String *str, enum_query_type query_type)
9407
9424
9408
9425
void Item_default_value::calculate ()
9409
9426
{
9427
+ DBUG_ASSERT (arg);
9410
9428
if (field->default_value )
9411
9429
field->set_default ();
9412
9430
DEBUG_SYNC (field->table ->in_use , " after_Item_default_value_calculate" );
@@ -9450,14 +9468,8 @@ bool Item_default_value::send(Protocol *protocol, st_value *buffer)
9450
9468
9451
9469
int Item_default_value::save_in_field (Field *field_arg, bool no_conversions)
9452
9470
{
9453
- if (arg)
9454
- {
9455
- calculate ();
9456
- return Item_field::save_in_field (field_arg, no_conversions);
9457
- }
9458
-
9459
- return field_arg->save_in_field_default_value (context->error_processor ==
9460
- &view_error_processor);
9471
+ calculate ();
9472
+ return Item_field::save_in_field (field_arg, no_conversions);
9461
9473
}
9462
9474
9463
9475
table_map Item_default_value::used_tables () const
@@ -9478,13 +9490,7 @@ Item *Item_default_value::transform(THD *thd, Item_transformer transformer,
9478
9490
uchar *args)
9479
9491
{
9480
9492
DBUG_ASSERT (!thd->stmt_arena ->is_stmt_prepare ());
9481
-
9482
- /*
9483
- If the value of arg is NULL, then this object represents a constant,
9484
- so further transformation is unnecessary (and impossible).
9485
- */
9486
- if (!arg)
9487
- return 0 ;
9493
+ DBUG_ASSERT (arg);
9488
9494
9489
9495
Item *new_item= arg->transform (thd, transformer, args);
9490
9496
if (!new_item)
@@ -9501,57 +9507,6 @@ Item *Item_default_value::transform(THD *thd, Item_transformer transformer,
9501
9507
return (this ->*transformer)(thd, args);
9502
9508
}
9503
9509
9504
- void Item_ignore_value::print (String *str, enum_query_type query_type)
9505
- {
9506
- str->append (STRING_WITH_LEN (" ignore" ));
9507
- }
9508
-
9509
- int Item_ignore_value::save_in_field (Field *field_arg, bool no_conversions)
9510
- {
9511
- return field_arg->save_in_field_ignore_value (context->error_processor ==
9512
- &view_error_processor);
9513
- }
9514
-
9515
- String *Item_ignore_value::val_str (String *str)
9516
- {
9517
- DBUG_ASSERT (0 ); // never should be called
9518
- null_value= 1 ;
9519
- return 0 ;
9520
- }
9521
-
9522
- double Item_ignore_value::val_real ()
9523
- {
9524
- DBUG_ASSERT (0 ); // never should be called
9525
- null_value= 1 ;
9526
- return 0.0 ;
9527
- }
9528
-
9529
- longlong Item_ignore_value::val_int ()
9530
- {
9531
- DBUG_ASSERT (0 ); // never should be called
9532
- null_value= 1 ;
9533
- return 0 ;
9534
- }
9535
-
9536
- my_decimal *Item_ignore_value::val_decimal (my_decimal *decimal_value)
9537
- {
9538
- DBUG_ASSERT (0 ); // never should be called
9539
- null_value= 1 ;
9540
- return 0 ;
9541
- }
9542
-
9543
- bool Item_ignore_value::get_date (MYSQL_TIME *ltime, ulonglong fuzzydate)
9544
- {
9545
- DBUG_ASSERT (0 ); // never should be called
9546
- null_value= 1 ;
9547
- return TRUE ;
9548
- }
9549
-
9550
- bool Item_ignore_value::send (Protocol *protocol, st_value *buffer)
9551
- {
9552
- DBUG_ASSERT (0 ); // never should be called
9553
- return TRUE ;
9554
- }
9555
9510
9556
9511
bool Item_insert_value::eq (const Item *item, bool binary_cmp) const
9557
9512
{
0 commit comments