diff options
Diffstat (limited to 'storage')
-rw-r--r-- | storage/connect/tabrest.cpp | 6 | ||||
-rw-r--r-- | storage/innobase/handler/ha_innodb.cc | 64 | ||||
-rw-r--r-- | storage/innobase/handler/ha_innodb.h | 1 | ||||
-rw-r--r-- | storage/innobase/row/row0sel.cc | 146 |
4 files changed, 97 insertions, 120 deletions
diff --git a/storage/connect/tabrest.cpp b/storage/connect/tabrest.cpp index 4b6bb6a9e62..6679ccd55b0 100644 --- a/storage/connect/tabrest.cpp +++ b/storage/connect/tabrest.cpp @@ -60,12 +60,12 @@ int Xcurl(PGLOBAL g, PCSZ Http, PCSZ Uri, PCSZ filename) if (Uri) { if (*Uri == '/' || Http[strlen(Http) - 1] == '/') - sprintf(buf, "%s%s", Http, Uri); + my_snprintf(buf, sizeof(buf)-1, "%s%s", Http, Uri); else - sprintf(buf, "%s/%s", Http, Uri); + my_snprintf(buf, sizeof(buf)-1, "%s/%s", Http, Uri); } else - strcpy(buf, Http); + my_snprintf(buf, sizeof(buf)-1, "%s", Http); #if defined(__WIN__) char cmd[1024]; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index eb28a0ba59f..4e63edc65c2 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -14974,70 +14974,6 @@ ha_innobase::check( DBUG_RETURN(is_ok ? HA_ADMIN_OK : HA_ADMIN_CORRUPT); } -/*************************************************************//** -Adds information about free space in the InnoDB tablespace to a table comment -which is printed out when a user calls SHOW TABLE STATUS. Adds also info on -foreign keys. -@return table comment + InnoDB free space + info on foreign keys */ -UNIV_INTERN -char* -ha_innobase::update_table_comment( -/*==============================*/ - const char* comment)/*!< in: table comment defined by user */ -{ - uint length = (uint) strlen(comment); - char* str=0; - size_t flen; - std::string fk_str; - - /* We do not know if MySQL can call this function before calling - external_lock(). To be safe, update the thd of the current table - handle. */ - - if (length > 64000 - 3) { - return((char*) comment); /* string too long */ - } - - update_thd(ha_thd()); - - m_prebuilt->trx->op_info = "returning table comment"; - -#define SSTR( x ) reinterpret_cast< std::ostringstream & >( \ - ( std::ostringstream() << std::dec << x ) ).str() - - if (m_prebuilt->table->space) { - fk_str.append("InnoDB free: "); - fk_str.append(SSTR(fsp_get_available_space_in_free_extents( - *m_prebuilt->table->space))); - } - - fk_str.append(dict_print_info_on_foreign_keys( - FALSE, m_prebuilt->trx, - m_prebuilt->table)); - - flen = fk_str.length(); - - if (length + flen + 3 > 64000) { - flen = 64000 - 3 - length; - } - /* allocate buffer for the full string */ - str = (char*) my_malloc(length + flen + 3, MYF(0)); - if (str) { - char* pos = str + length; - if (length) { - memcpy(str, comment, length); - *pos++ = ';'; - *pos++ = ' '; - } - memcpy(pos, fk_str.c_str(), flen); - pos[flen] = 0; - } - - m_prebuilt->trx->op_info = (char*)""; - - return(str ? str : (char*) comment); -} - /*******************************************************************//** Gets the foreign key create info for a table stored in InnoDB. @return own: character string in the form which can be inserted to the diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h index 038528cc2e4..b11bb14714d 100644 --- a/storage/innobase/handler/ha_innodb.h +++ b/storage/innobase/handler/ha_innodb.h @@ -219,7 +219,6 @@ public: int rename_table(const char* from, const char* to); inline int defragment_table(const char* name); int check(THD* thd, HA_CHECK_OPT* check_opt); - char* update_table_comment(const char* comment); char* get_foreign_key_create_info(); diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc index 788cf644191..08401831d16 100644 --- a/storage/innobase/row/row0sel.cc +++ b/storage/innobase/row/row0sel.cc @@ -149,6 +149,76 @@ row_sel_sec_rec_is_for_blob( return(!cmp_data_data(mtype, prtype, buf, len, sec_field, sec_len)); } +/** Function to read the secondary spatial index, calculate +the minimum bounding rectangle for clustered index record +and secondary index record and compare it. +@param sec_rec secondary index record +@param sec_index spatial secondary index +@param clust_rec clustered index record +@param clust_index clustered index +@retval DB_SUCCESS_LOCKED_REC if the secondary record is equal to the + corresponding fields in the clustered record, when compared with + collation; +@retval DB_SUCCESS if not equal */ +static +dberr_t +row_sel_spatial_sec_rec_is_for_clust_rec( + const rec_t *sec_rec, const dict_index_t *sec_index, + const rec_t *clust_rec, dict_index_t *clust_index) +{ + mem_heap_t *heap= mem_heap_create(256); + rec_offs clust_offsets_[REC_OFFS_NORMAL_SIZE]; + rec_offs *clust_offs= clust_offsets_; + ulint clust_len; + + rec_offs_init(clust_offsets_); + ulint clust_pos= dict_col_get_clust_pos( + dict_index_get_nth_col(sec_index, 0), clust_index); + clust_offs= rec_get_offsets(clust_rec, clust_index, clust_offs, + clust_index->n_core_fields, clust_pos + 1, + &heap); + ut_ad(sec_index->n_user_defined_cols == 1); + const byte *clust_field= rec_get_nth_field(clust_rec, clust_offs, + clust_pos, &clust_len); + if (clust_len == UNIV_SQL_NULL || clust_len < GEO_DATA_HEADER_SIZE) + { + ut_ad("corrupted geometry column" == 0); +err_exit: + mem_heap_free(heap); + return DB_SUCCESS; + } + + /* For externally stored field, we need to get full + geo data to generate the MBR for comparing. */ + if (rec_offs_nth_extern(clust_offs, clust_pos)) + { + clust_field= btr_copy_externally_stored_field( + &clust_len, clust_field, dict_table_page_size(sec_index->table), + clust_len, heap); + if (clust_field == NULL) + { + ut_ad("corrupted geometry blob" == 0); + goto err_exit; + } + } + + ut_ad(clust_len >= GEO_DATA_HEADER_SIZE); + rtr_mbr_t tmp_mbr; + rtr_mbr_t sec_mbr; + + rtree_mbr_from_wkb( + clust_field + GEO_DATA_HEADER_SIZE, + static_cast<uint>(clust_len - GEO_DATA_HEADER_SIZE), + SPDIMS, reinterpret_cast<double*>(&tmp_mbr)); + + rtr_read_mbr(sec_rec, &sec_mbr); + + mem_heap_free(heap); + return MBR_EQUAL_CMP(&sec_mbr, &tmp_mbr) + ? DB_SUCCESS_LOCKED_REC + : DB_SUCCESS; +} + /** Returns TRUE if the user-defined column values in a secondary index record are alphabetically the same as the corresponding columns in the clustered index record. @@ -176,12 +246,31 @@ row_sel_sec_rec_is_for_clust_rec( dict_index_t* clust_index, que_thr_t* thr) { + if (rec_get_deleted_flag(clust_rec, + dict_table_is_comp(clust_index->table))) { + /* In delete-marked records, DB_TRX_ID must + always refer to an existing undo log record. */ + ut_ad(rec_get_trx_id(clust_rec, clust_index)); + + /* The clustered index record is delete-marked; + it is not visible in the read view. Besides, + if there are any externally stored columns, + some of them may have already been purged. */ + return DB_SUCCESS; + } + + if (dict_index_is_spatial(sec_index)) { + return row_sel_spatial_sec_rec_is_for_clust_rec( + sec_rec, sec_index, clust_rec, + clust_index); + } + const byte* sec_field; ulint sec_len; const byte* clust_field; ulint n; ulint i; - mem_heap_t* heap = NULL; + mem_heap_t* heap = mem_heap_create(256); rec_offs clust_offsets_[REC_OFFS_NORMAL_SIZE]; rec_offs sec_offsets_[REC_OFFS_SMALL_SIZE]; rec_offs* clust_offs = clust_offsets_; @@ -190,20 +279,7 @@ row_sel_sec_rec_is_for_clust_rec( rec_offs_init(clust_offsets_); rec_offs_init(sec_offsets_); - if (rec_get_deleted_flag(clust_rec, - dict_table_is_comp(clust_index->table))) { - /* In delete-marked records, DB_TRX_ID must - always refer to an existing undo log record. */ - ut_ad(rec_get_trx_id(clust_rec, clust_index)); - - /* The clustered index record is delete-marked; - it is not visible in the read view. Besides, - if there are any externally stored columns, - some of them may have already been purged. */ - return DB_SUCCESS; - } - heap = mem_heap_create(256); ib_vcol_row vc(heap); clust_offs = rec_get_offsets(clust_rec, clust_index, clust_offs, @@ -311,44 +387,10 @@ check_for_blob: } } - /* For spatial index, the first field is MBR, we check - if the MBR is equal or not. */ - if (dict_index_is_spatial(sec_index) && i == 0) { - rtr_mbr_t tmp_mbr; - rtr_mbr_t sec_mbr; - byte* dptr = - const_cast<byte*>(clust_field); - - ut_ad(clust_len != UNIV_SQL_NULL); - - /* For externally stored field, we need to get full - geo data to generate the MBR for comparing. */ - if (rec_offs_nth_extern(clust_offs, clust_pos)) { - dptr = btr_copy_externally_stored_field( - &clust_len, dptr, - page_size_t(clust_index->table->space - ->flags), - len, heap); - } - - rtree_mbr_from_wkb(dptr + GEO_DATA_HEADER_SIZE, - static_cast<uint>(clust_len - - GEO_DATA_HEADER_SIZE), - SPDIMS, - reinterpret_cast<double*>( - &tmp_mbr)); - rtr_read_mbr(sec_field, &sec_mbr); - - if (!MBR_EQUAL_CMP(&sec_mbr, &tmp_mbr)) { - return DB_SUCCESS; - } - } else { - - if (0 != cmp_data_data(col->mtype, col->prtype, - clust_field, len, - sec_field, sec_len)) { - return DB_SUCCESS; - } + if (0 != cmp_data_data(col->mtype, col->prtype, + clust_field, len, + sec_field, sec_len)) { + return DB_SUCCESS; } } |