• Alexander Barkov's avatar
    MDEV-11360 Dynamic SQL: DEFAULT as a bind parameter · 9bfde897
    Alexander Barkov authored
    This patch adds DEFAULT as a possible dynamic SQL parameter, e.g.:
      EXECUTE IMMEDIATE 'INSERT INTO t1 (column) VALUES(?)' USING DEFAULT;
      EXECUTE IMMEDIATE 'UPDATE t1 SET column=?' USING DEFAULT;
    and for similar PREPARE..EXECUTE queries.
    
    This is done for symmetry with the STMT_INDICATOR_DEFAULT indicator in
    the client-server PS protocol.
    
    The changes include:
    - Allowing DEFAULT as a possible option in execute USING clause (sql_yacc.yy)
    - Adding "virtual bool Item::save_in_param(THD *thd, Item_param *param)",
      because "normal" items (that have real values) and Item_default_value
      have now different actions when assigning itself as an Item_param value.
    - Fixing switch() statements in a few Item_param methods not to have "default",
      because it was easy to forget to add a new "case" when adding a new XXX_VALUE
      value into the enum Item_param::enum_item_param_state.
      This is important, as we'll be adding new values soon, e.g. for MDEV-11359.
      Removing "default" helped to find and report bugs MDEV-11361 and MDEV-11362,
      because DECIMAL_VALUE is obviously not properly handled in some cases.
    9bfde897
item.h 187 KB