summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2017-11-07 23:02:39 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2017-11-07 23:02:39 +0200
commit843e4508c0aa9fe50f750523b64ff04f517a2dea (patch)
tree06fa2a83f3e65f28832c46285236d3a5b8b568a1 /sql
parenta4feb04ace2e7759aee4dd74b71cbb1151b1886f (diff)
parent5691109689bc40fa303c1b7ddc84b9209ec5f869 (diff)
downloadmariadb-git-843e4508c0aa9fe50f750523b64ff04f517a2dea.tar.gz
Merge 10.1 into 10.2
Diffstat (limited to 'sql')
-rw-r--r--sql/datadict.cc15
-rw-r--r--sql/handler.cc9
-rw-r--r--sql/item.h11
3 files changed, 32 insertions, 3 deletions
diff --git a/sql/datadict.cc b/sql/datadict.cc
index 103a33214ae..ec3d65f0113 100644
--- a/sql/datadict.cc
+++ b/sql/datadict.cc
@@ -45,6 +45,8 @@ static int read_string(File file, uchar**to, size_t length)
engine_name is a LEX_STRING, where engine_name->str must point to
a buffer of at least NAME_CHAR_LEN+1 bytes.
+ If engine_name is 0, then the function will only test if the file is a
+ view or not
@retval FRMTYPE_ERROR error
@retval FRMTYPE_TABLE table
@@ -72,12 +74,23 @@ frm_type_enum dd_frm_type(THD *thd, char *path, LEX_STRING *engine_name)
goto err;
}
+ /*
+ We return FRMTYPE_TABLE if we can read the .frm file. This allows us
+ to drop a bad .frm file with DROP TABLE
+ */
type= FRMTYPE_TABLE;
- if (!is_binary_frm_header(header) || !engine_name)
+ /* engine_name is 0 if we only want to know if table is view or not */
+ if (!engine_name)
goto err;
+ /* Initialize engine name in case we are not able to find it out */
engine_name->length= 0;
+ engine_name->str[0]= 0;
+
+ if (!is_binary_frm_header(header))
+ goto err;
+
dbt= header[3];
/* cannot use ha_resolve_by_legacy_type without a THD */
diff --git a/sql/handler.cc b/sql/handler.cc
index 1f3df447f24..7eed722a971 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -5072,10 +5072,15 @@ bool ha_table_exists(THD *thd, const char *db, const char *table_name,
{
char engine_buf[NAME_CHAR_LEN + 1];
LEX_STRING engine= { engine_buf, 0 };
+ frm_type_enum type;
- if (dd_frm_type(thd, path, &engine) != FRMTYPE_VIEW)
+ if ((type= dd_frm_type(thd, path, &engine)) == FRMTYPE_ERROR)
+ DBUG_RETURN(0);
+
+ if (type != FRMTYPE_VIEW)
{
- plugin_ref p= plugin_lock_by_name(thd, &engine, MYSQL_STORAGE_ENGINE_PLUGIN);
+ plugin_ref p= plugin_lock_by_name(thd, &engine,
+ MYSQL_STORAGE_ENGINE_PLUGIN);
*hton= p ? plugin_hton(p) : NULL;
if (*hton)
// verify that the table really exists
diff --git a/sql/item.h b/sql/item.h
index 9b94a08c34e..d7daea4853d 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -2768,6 +2768,17 @@ public:
Field *result_field;
Item_null_result(THD *thd): Item_null(thd), result_field(0) {}
bool is_result_field() { return result_field != 0; }
+#if MARIADB_VERSION_ID < 100300
+ enum_field_types field_type() const
+ {
+ return result_field->type();
+ }
+#else
+ const Type_handler *type_handler() const
+ {
+ return result_field->type_handler();
+ }
+#endif
void save_in_result_field(bool no_conversions)
{
save_in_field(result_field, no_conversions);