← Back to team overview

maria-developers team mailing list archive

Doubt in bin logging for CREATE VIEW

 

Hi All,

I was checking the behavior of bin logging in various methods. I found out
CREATE VIEW differs a little bit than others in bin logging.

The query is written into bin log if query is executed successfully. If
there is any error the query is not logged. This behavior is observed
across all the commands.

In case of CREATE VIEW (method: mysql_create_view file: sql/sql_view.cc),
while the bin logging is skipped for most of the errors by jumping to "err"
label, it is not skipped in following code snippet (line number: 616)

res= mysql_register_view(thd, view, mode);

/*
    View TABLE_SHARE must be removed from the table definition cache in
order to
    make ALTER VIEW work properly. Otherwise, we would not be able to detect
    meta-data changes after ALTER VIEW.
*/

if (!res)
  tdc_remove_table(thd, TDC_RT_REMOVE_ALL, view->db, view->table_name,
false);

if (mysql_bin_log.is_open())
{
  // this is where the log is written
}


If an error occurs in mysql_register_view, e.g. ER_OUT_OF_RESOURCES,
ER_TABLE_EXISTS_ERROR, etc. the query is still logged.

Is there a specific reason why it is logged even though an error occurs? Or
is it a bug?

Thanks & Regards,
Sriram

Follow ups