mirror of
https://github.com/MariaDB/server.git
synced 2025-01-23 23:34:34 +01:00
f73bdb685d
When updating a table with virtual BLOB columns, the following might happen: - an old record is read from the table, it has no virtual blob values - update_virtual_fields() is run, vcol blob gets its value into the record. But only a pointer to the value is in the table->record[0], the value is in Field_blob::value String (but it doesn't have to be! it can be in the record, if the column is just a copy of another columns: ... b VARCHAR, c BLOB AS (b) ...) - store_record(table,record[1]), old record now is in record[1] - fill_record() prepares new values in record[0], vcol blob is updated, new value replaces the old one in the Field_blob::value - now both record[1] and record[0] have a pointer that points to the *new* vcol blob value. Or record[1] has a pointer to nowhere if Field_blob::value had to realloc. To resolve this we unlink vcol blobs from the pointer to the data (in the record[1]). Because the value is not *always* in the Field_blob::value String, we need to remember what blobs were unlinked. The orphan memory must be freed manually. To complicate the matter, ha_update_row() is also used in multi-update, in REPLACE, in INSERT ... ON DUPLICATE KEY UPDATE, also on REPLACE ... SELECT, REPLACE DELAYED, and LOAD DATA REPLACE, etc
47 lines
2.1 KiB
C
47 lines
2.1 KiB
C
/* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
|
|
|
#ifndef SQL_INSERT_INCLUDED
|
|
#define SQL_INSERT_INCLUDED
|
|
|
|
#include "sql_class.h" /* enum_duplicates */
|
|
#include "sql_list.h"
|
|
|
|
/* Instead of including sql_lex.h we add this typedef here */
|
|
typedef List<Item> List_item;
|
|
|
|
bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE *table,
|
|
List<Item> &fields, List_item *values,
|
|
List<Item> &update_fields,
|
|
List<Item> &update_values, enum_duplicates duplic,
|
|
COND **where, bool select_insert,
|
|
bool check_fields, bool abort_on_warning);
|
|
bool mysql_insert(THD *thd,TABLE_LIST *table,List<Item> &fields,
|
|
List<List_item> &values, List<Item> &update_fields,
|
|
List<Item> &update_values, enum_duplicates flag,
|
|
bool ignore);
|
|
void upgrade_lock_type_for_insert(THD *thd, thr_lock_type *lock_type,
|
|
enum_duplicates duplic,
|
|
bool is_multi_insert);
|
|
int check_that_all_fields_are_given_values(THD *thd, TABLE *entry,
|
|
TABLE_LIST *table_list);
|
|
int write_record(THD *thd, TABLE *table, COPY_INFO *info);
|
|
void kill_delayed_threads(void);
|
|
|
|
#ifdef EMBEDDED_LIBRARY
|
|
inline void kill_delayed_threads(void) {}
|
|
#endif
|
|
|
|
#endif /* SQL_INSERT_INCLUDED */
|