diff options
Diffstat (limited to 'sql/item.cc')
-rw-r--r-- | sql/item.cc | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/sql/item.cc b/sql/item.cc index b4a7820eabf..050171b8fbe 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -3724,7 +3724,18 @@ bool Item_field::fix_fields(THD *thd, Item **reference) use the field from the Item_field in the select list and leave the Item_field instance in place. */ - set_field((*((Item_field**)res))->field); + + Field *field= (*((Item_field**)res))->field; + + if (field == NULL) + { + /* The column to which we link isn't valid. */ + my_error(ER_BAD_FIELD_ERROR, MYF(0), (*res)->name, + current_thd->where); + return(1); + } + + set_field(field); return 0; } else |