diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc index 8838aa99c1ac526a7b03b5ad4469c945826b4d2a..62e6d0c47ee5eeb6af457f6122696c12b43f718a 100644 --- a/sql/ha_heap.cc +++ b/sql/ha_heap.cc @@ -114,6 +114,26 @@ int ha_heap::close(void) } +/* + Create a copy of this table + + DESCRIPTION + Do same as default implementation but use file->s->name instead of + table->s->path. This is needed by Windows where the clone() call sees + '/'-delimited path in table->s->path, while ha_peap::open() was called + with '\'-delimited path. +*/ + +handler *ha_heap::clone(MEM_ROOT *mem_root) +{ + handler *new_handler= get_new_handler(table, mem_root, table->s->db_type); + if (new_handler && !new_handler->ha_open(file->s->name, table->db_stat, + HA_OPEN_IGNORE_IF_LOCKED)) + return new_handler; + return NULL; +} + + /* Compute which keys to use for scanning diff --git a/sql/ha_heap.h b/sql/ha_heap.h index 27846ca4a8e23d4ebfffb85cef788ca998306faf..23583d0a6a7aec9d00fcb0a3e63aedd2ce4021ca 100644 --- a/sql/ha_heap.h +++ b/sql/ha_heap.h @@ -32,6 +32,7 @@ class ha_heap: public handler public: ha_heap(TABLE *table); ~ha_heap() {} + handler *clone(MEM_ROOT *mem_root); const char *table_type() const { return (table->in_use->variables.sql_mode & MODE_MYSQL323) ? diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 952e5abfd1365b781cc2b54841e3076077ac95b3..76e78c7e9b8a5fb164c96e1d72a2cee868c7aaf6 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1131,6 +1131,14 @@ int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler) THD *thd= current_thd; if (!(file= head->file->clone(thd->mem_root))) { + /* + Manually set the error flag. Note: there seems to be quite a few + places where a failure could cause the server to "hang" the client by + sending no response to a query. ATM those are not real errors because + the storage engine calls in question happen to never fail with the + existing storage engines. + */ + thd->net.report_error= 1; /* Caller will free the memory */ goto failure; }