mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-17124: mariadb 10.1.34, views and prepared statements: ERROR 1615 (HY000): Prepared statement needs to be re-prepared
The problem is that if table definition cache (TDC) is full of real tables which are in tables cache, view definition can not stay there so will be removed by its own underlying tables. In situation above old mechanism of detection matching definition in PS and current version always require reprepare and so prevent executing the PS. One work around is to increase TDC, other - improve version check for views/triggers (which is done here). Now in suspicious cases we check: - timestamp (microseconds) of the view to be sure that version really have changed; - time (microseconds) of creation of a trigger related to time (microseconds) of statement preparation.
This commit is contained in:
@ -173,11 +173,12 @@ write_parameter(IO_CACHE *file, const uchar* base, File_option *parameter)
|
||||
{
|
||||
/* string have to be allocated already */
|
||||
LEX_STRING *val_s= (LEX_STRING *)(base + parameter->offset);
|
||||
time_t tm= my_time(0);
|
||||
|
||||
get_date(val_s->str, GETDATE_DATE_TIME|GETDATE_GMT|GETDATE_FIXEDLENGTH,
|
||||
tm);
|
||||
val_s->length= PARSE_FILE_TIMESTAMPLENGTH;
|
||||
// number of microseconds since Epoch, timezone-independent
|
||||
my_hrtime_t tm= my_hrtime();
|
||||
// Paded to 19 characters for compatibility
|
||||
val_s->length= snprintf(val_s->str, MICROSECOND_TIMESTAMP_BUFFER_SIZE,
|
||||
"%019lld", tm.val);
|
||||
DBUG_ASSERT(val_s->length == MICROSECOND_TIMESTAMP_BUFFER_SIZE-1);
|
||||
if (my_b_write(file, (const uchar *)val_s->str,
|
||||
PARSE_FILE_TIMESTAMPLENGTH))
|
||||
DBUG_RETURN(TRUE);
|
||||
@ -833,16 +834,16 @@ File_parser::parse(uchar* base, MEM_ROOT *mem_root,
|
||||
{
|
||||
/* string have to be allocated already */
|
||||
LEX_STRING *val= (LEX_STRING *)(base + parameter->offset);
|
||||
/* yyyy-mm-dd HH:MM:SS = 19(PARSE_FILE_TIMESTAMPLENGTH) characters */
|
||||
if (ptr[PARSE_FILE_TIMESTAMPLENGTH] != '\n')
|
||||
/* 19 characters of timestamp */
|
||||
if (ptr[MICROSECOND_TIMESTAMP_BUFFER_SIZE-1] != '\n')
|
||||
{
|
||||
my_error(ER_FPARSER_ERROR_IN_PARAMETER, MYF(0),
|
||||
parameter->name.str, line);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
memcpy(val->str, ptr, PARSE_FILE_TIMESTAMPLENGTH);
|
||||
val->str[val->length= PARSE_FILE_TIMESTAMPLENGTH]= '\0';
|
||||
ptr+= (PARSE_FILE_TIMESTAMPLENGTH+1);
|
||||
memcpy(val->str, ptr, MICROSECOND_TIMESTAMP_BUFFER_SIZE-1);
|
||||
val->str[val->length= MICROSECOND_TIMESTAMP_BUFFER_SIZE-1]= '\0';
|
||||
ptr+= MICROSECOND_TIMESTAMP_BUFFER_SIZE;
|
||||
break;
|
||||
}
|
||||
case FILE_OPTIONS_STRLIST:
|
||||
|
Reference in New Issue
Block a user