summaryrefslogtreecommitdiff
path: root/sql/table.h
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2022-10-01 23:07:26 +0200
committerSergei Golubchik <serg@mariadb.org>2022-10-01 23:07:26 +0200
commitd4f6d2f08f228778fd7744554d8b12be05b6a114 (patch)
tree2ccc39d16d3a5be27c54e03a81d2d3f75cfb9266 /sql/table.h
parent3744b8ae3171fd423f89c64a83d3afc7e3722856 (diff)
parentdd8833bff0af1b75e007e3db1d18debfb7c4a096 (diff)
downloadmariadb-git-d4f6d2f08f228778fd7744554d8b12be05b6a114.tar.gz
Merge branch '10.3' into 10.4
Diffstat (limited to 'sql/table.h')
-rw-r--r--sql/table.h67
1 files changed, 51 insertions, 16 deletions
diff --git a/sql/table.h b/sql/table.h
index 3f750e7b221..b888dfe04db 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -33,6 +33,19 @@
#include "filesort_utils.h"
#include "parse_file.h"
+/*
+ Buffer for unix timestamp in microseconds:
+ 9,223,372,036,854,775,807 (signed int64 maximal value)
+ 1 234 567 890 123 456 789
+
+ Note: we can use unsigned for calculation, but practically they
+ are the same by probability to overflow them (signed int64 in
+ microseconds is enough for almost 3e5 years) and signed allow to
+ avoid increasing the buffer (the old buffer for human readable
+ date was 19+1).
+*/
+#define MICROSECOND_TIMESTAMP_BUFFER_SIZE (19 + 1)
+
/* Structs that defines the TABLE */
class Item; /* Needed by ORDER */
@@ -68,6 +81,8 @@ struct Name_resolution_context;
*/
typedef ulonglong nested_join_map;
+#define VIEW_MD5_LEN 32
+
#define tmp_file_prefix "#sql" /**< Prefix for tmp tables */
#define tmp_file_prefix_length 4
@@ -1062,7 +1077,7 @@ struct TABLE_SHARE
with a base table, a base table is replaced with a temporary
table and so on.
- @sa TABLE_LIST::is_table_ref_id_equal()
+ @sa TABLE_LIST::is_the_same_definition()
*/
ulong get_table_ref_version() const
{
@@ -2454,6 +2469,12 @@ struct TABLE_LIST
to view with SQL SECURITY DEFINER)
*/
Security_context *security_ctx;
+ uchar tabledef_version_buf[MY_UUID_SIZE >
+ MICROSECOND_TIMESTAMP_BUFFER_SIZE-1 ?
+ MY_UUID_SIZE + 1 :
+ MICROSECOND_TIMESTAMP_BUFFER_SIZE];
+ LEX_CUSTRING tabledef_version;
+
/*
This view security context (non-zero only for views with
SQL SECURITY DEFINER)
@@ -2467,7 +2488,7 @@ struct TABLE_LIST
LEX_CSTRING source; /* source of CREATE VIEW */
LEX_CSTRING view_db; /* saved view database */
LEX_CSTRING view_name; /* saved view name */
- LEX_STRING timestamp; /* GMT time stamp of last operation */
+ LEX_STRING hr_timestamp; /* time stamp of last operation */
LEX_USER definer; /* definer of view */
ulonglong file_version; /* version of file's field set */
ulonglong mariadb_version; /* version of server on creation */
@@ -2550,7 +2571,7 @@ struct TABLE_LIST
/* TABLE_TYPE_UNKNOWN if any type is acceptable */
Table_type required_type;
handlerton *db_type; /* table_type for handler */
- char timestamp_buffer[MAX_DATETIME_WIDTH + 1];
+ char timestamp_buffer[MICROSECOND_TIMESTAMP_BUFFER_SIZE];
/*
This TABLE_LIST object is just placeholder for prelocking, it will be
used for implicit LOCK TABLES only and won't be used in real statement.
@@ -2748,19 +2769,7 @@ struct TABLE_LIST
*/
bool process_index_hints(TABLE *table);
- /**
- Compare the version of metadata from the previous execution
- (if any) with values obtained from the current table
- definition cache element.
-
- @sa check_and_update_table_version()
- */
- inline bool is_table_ref_id_equal(TABLE_SHARE *s) const
- {
- return (m_table_ref_type == s->get_table_ref_type() &&
- m_table_ref_version == s->get_table_ref_version());
- }
-
+ bool is_the_same_definition(THD *thd, TABLE_SHARE *s);
/**
Record the value of metadata version of the corresponding
table definition cache element in this parse tree node.
@@ -2777,6 +2786,26 @@ struct TABLE_LIST
m_table_ref_version= table_ref_version_arg;
}
+ void set_table_id(TABLE_SHARE *s)
+ {
+ set_table_ref_id(s);
+ set_tabledef_version(s);
+ }
+
+ void set_tabledef_version(TABLE_SHARE *s)
+ {
+ if (!tabledef_version.length && s->tabledef_version.length)
+ {
+ DBUG_ASSERT(s->tabledef_version.length <
+ sizeof(tabledef_version_buf));
+ tabledef_version.str= tabledef_version_buf;
+ memcpy(tabledef_version_buf, s->tabledef_version.str,
+ (tabledef_version.length= s->tabledef_version.length));
+ // safety
+ tabledef_version_buf[tabledef_version.length]= 0;
+ }
+ }
+
/* Set of functions returning/setting state of a derived table/view. */
inline bool is_non_derived()
{
@@ -2906,6 +2935,12 @@ struct TABLE_LIST
}
}
+ inline void set_view_def_version(LEX_STRING *version)
+ {
+ m_table_ref_type= TABLE_REF_VIEW;
+ tabledef_version.str= (const uchar *) version->str;
+ tabledef_version.length= version->length;
+ }
private:
bool prep_check_option(THD *thd, uint8 check_opt_type);
bool prep_where(THD *thd, Item **conds, bool no_where_clause);