Bug #26980 binlog_hton->create dangling after int binlog_init(void *p)?
Submitted: 9 Mar 2007 0:54 Modified: 4 Feb 2008 16:39
Reporter: Chongfeng Hu Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Replication Severity:S2 (Serious)
Version:5.2.0 falcon-alpha, 5.1 OS:Any (any)
Assigned to: Ingo Strüwing CPU Architecture:Any
Tags: create, dangling pointer

[9 Mar 2007 0:54] Chongfeng Hu
Description:
I found that in file sql/log.cc, in function int binlog_init(void *p), most of the fields in binlog_hton is initialized except create, which is a function pointer:

  binlog_hton= (handlerton *)p;
  binlog_hton->state=opt_bin_log ? SHOW_OPTION_YES : SHOW_OPTION_NO;
  binlog_hton->db_type=DB_TYPE_BINLOG;
  binlog_hton->savepoint_offset= sizeof(my_off_t);
  binlog_hton->close_connection= binlog_close_connection;
  binlog_hton->savepoint_set= binlog_savepoint_set;
  binlog_hton->savepoint_rollback= binlog_savepoint_rollback;
  binlog_hton->commit= binlog_commit;
  binlog_hton->rollback= binlog_rollback;
  binlog_hton->prepare= binlog_prepare;
  binlog_hton->flags= HTON_NOT_USER_SELECTABLE | HTON_HIDDEN;

I'm wondering if it is ok to leave create dangling there.

How to repeat:
I found this place with the help of a code-checking tool.

Suggested fix:
init create too.
[29 Mar 2007 10:33] Sveta Smirnova
Thank you for the report.

Verified as described.
[4 Feb 2008 16:39] Ingo Strüwing
This is not a bug. 'binlog_hton' is a pseudo handlerton. It cannot be used to create handlers. Its purpose is to store thread specific transaction information for the binlog functions.

Consequently there is no 'create' function. Hence the element is left at NULL. The structure is allocated in ha_initialize_handlerton() using MY_ZEROFILL, called from plugin_initialize() through plugin_type_initialize[MYSQL_STORAGE_ENGINE_PLUGIN], called from plugin_init(), called from init_server_components(), called from main(). So it is correctly initialized.

BTW, there are more elements, even function pointers, not assigned in binlog_init(). Why did you mention 'create' only?