ITPub博客

Mysql Prepared statement needs to be re-prepared

原创 MySQL 作者:gaopengtttt 时间:2018-01-04 11:55:38 0 删除 编辑

这个是我自己的笔记没有阅读性。也没仔细看。但是记录下断点以后好研究。

朋友遇到这个错修改了参数
| table_definition_cache | 1400 |
| table_open_cache | 2000 |
均设置为16384就好了。

但是他搞不明白有什么关系。我就看了一下这个报错的错误码
{ "ER_NEED_REPREPARE", 1615, "Prepared statement needs to be re-prepared" },
分析后他应该是在函数check_and_update_table_version中抛出来的。
其注释有

 Compare metadata versions of an element obtained from the table
  definition cache and its corresponding node in the parse tree. 

其逻辑有

static bool
check_and_update_table_version(THD *thd,
                               TABLE_LIST *tables, TABLE_SHARE *table_share)
{ if (! tables->is_table_ref_id_equal(table_share))
  {
    Reprepare_observer *reprepare_observer= thd->get_reprepare_observer(); if (reprepare_observer &&
        reprepare_observer->report_error(thd)) //这里如果前面的指针为NULL则触发这个报错逻辑 { /*
        Version of the table share is different from the
        previous execution of the prepared statement, and it is
        unacceptable for this SQLCOM. Error has been reported.
      */ DBUG_ASSERT(thd->is_error()); return TRUE;
    } /* Always maintain the latest version and type */ tables->set_table_ref_id(table_share);
  }

  DBUG_EXECUTE_IF("reprepare_each_statement", return inject_reprepare(thd);); return FALSE;
} 

看来他们确实有联系,但是怎么联系的说不上来,这个观察者搞毛线的我也不知道。以后再说。
断点设置

1 breakpoint     keep y 0x0000000000ebd5f3 in main(int, char**) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/main.cc:25 breakpoint already hit 1 time 4 breakpoint     keep y 0x00000000016a04bd in open_table_from_share(THD*, TABLE_SHARE*, char const*, uint, uint, uint, TABLE*, bool)
                                               at /root/mysql5.7.14/percona-server-5.7.14-7/sql/table.cc:3038 breakpoint already hit 4 times 5 breakpoint     keep y 0x0000000001519a10 in check_and_update_table_version(THD*, TABLE_LIST*, TABLE_SHARE*)
                                               at /root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_base.cc:4219 breakpoint already hit 4 times 6 breakpoint     keep y 0x00000000015285bb in Table_cache::add_used_table(THD*, TABLE*) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/table_cache.h:353 breakpoint already hit 2 times 7 breakpoint     keep y 0x0000000001527427 in TABLE_LIST::set_table_ref_id(enum_table_ref_type, ulonglong)
                                               at /root/mysql5.7.14/percona-server-5.7.14-7/sql/table.h:2100 8 breakpoint     keep y 0x00000000015273e3 in TABLE_LIST::set_table_ref_id(TABLE_SHARE*) at /root/mysql5.7.14/percona-server-5.7.14-7/sql/table.h:2095 breakpoint already hit 1 time


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7728585/viewspace-2149689/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
wxh gp_22389860

注册时间:2008-10-13

  • 博文量
    633
  • 访问量
    2776417