summaryrefslogtreecommitdiff
path: root/sql/parse_file.cc
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2019-04-17 15:50:59 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2022-09-30 12:11:37 +0200
commitf65ba9aeb7eea75656c74da7c20cb4157cb8d943 (patch)
treebc116ccb44b9e2f073654c60515764ee6a99fc2a /sql/parse_file.cc
parent98e62e631706f982a6b0e3a63909fa96f98aac5a (diff)
downloadmariadb-git-f65ba9aeb7eea75656c74da7c20cb4157cb8d943.tar.gz
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.
Diffstat (limited to 'sql/parse_file.cc')
-rw-r--r--sql/parse_file.cc21
1 files changed, 11 insertions, 10 deletions
diff --git a/sql/parse_file.cc b/sql/parse_file.cc
index 59b4027a352..18fffb2445d 100644
--- a/sql/parse_file.cc
+++ b/sql/parse_file.cc
@@ -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: