Skip to content

Instantly share code, notes, and snippets.

@spetrunia
Created March 10, 2024 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spetrunia/abbe5daa0899c85b79f5f3d66c59cd50 to your computer and use it in GitHub Desktop.
Save spetrunia/abbe5daa0899c85b79f5f3d66c59cd50 to your computer and use it in GitHub Desktop.
diff --git a/sql/field.h b/sql/field.h
index 7f1c243a180..d5c1b049ff1 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -1526,7 +1526,7 @@ class Field: public Value_source
ptr=ptr_arg; null_ptr=null_ptr_arg; null_bit=null_bit_arg;
}
inline void move_field(uchar *ptr_arg) { ptr=ptr_arg; }
- inline uchar *record_ptr() // record[0] or wherever the field was moved to
+ inline uchar *record_ptr() const // record[0] or wherever the field was moved to
{
my_ptrdiff_t offset= table->s->field[field_index]->ptr - table->s->default_values;
return ptr - offset;
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index e41f1b08c5a..09b6067be4f 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -93,6 +93,7 @@ static const char *ha_par_ext= PAR_EXT;
table->record[0] during index condition evaluation (if present).
*/
using IndexOperationFunc= std::function<int(uchar* read_buf)>;
+#if 0
static int index_reader(TABLE* table,
Item* pushed_idx_cond,
uchar* record_buf,
@@ -106,6 +107,7 @@ static int index_reader(TABLE* table,
memcpy(record_buf, table->record[0], record_buf_len);
return error;
}
+#endif
/****************************************************************************
MODULE create/delete handler object
@@ -7966,6 +7968,7 @@ int ha_partition::handle_ordered_index_scan(uchar *buf, bool reverse_order)
switch (m_index_scan_type) {
case partition_index_read:
+#if 0
error=
index_reader(table, pushed_idx_cond, rec_buf_ptr, m_rec_length,
[this, file] (uchar* read_buf) {
@@ -7974,6 +7977,18 @@ int ha_partition::handle_ordered_index_scan(uchar *buf, bool reverse_order)
m_start_key.keypart_map,
m_start_key.flag);
});
+#endif
+ /*
+ We might be using ICP. Move table->fields from table->record[0] to
+ rec_buf_ptr.
+ */
+ table->move_fields(table->field, rec_buf_ptr, table->record[0]);
+ error= file->ha_index_read_map(rec_buf_ptr,
+ m_start_key.key,
+ m_start_key.keypart_map,
+ m_start_key.flag);
+
+ table->move_fields(table->field, table->record[0], rec_buf_ptr);
/* Caller has specified reverse_order */
break;
case partition_index_first:
diff --git a/sql/handler.cc b/sql/handler.cc
index 4bcd4a851f4..ab83bc6ff16 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -3688,7 +3688,7 @@ int handler::ha_index_read_map(uchar *buf, const uchar *key,
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
m_lock_type != F_UNLCK);
DBUG_ASSERT(inited==INDEX);
- DBUG_ASSERT(!pushed_idx_cond || !buf || buf == table->record[0]);
+ // DBUG_ASSERT(!pushed_idx_cond || !buf || buf == table->record[0]);
TABLE_IO_WAIT(tracker, PSI_TABLE_FETCH_ROW, active_index, result,
{ result= index_read_map(buf, key, keypart_map, find_flag); })
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 93127bb1c3a..986056dade1 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -817,7 +817,8 @@ get_field_offset(
const TABLE* table,
const Field* field)
{
- return field->offset(table->record[0]);
+// return field->offset(table->record[0]);
+ return field->offset(field->record_ptr());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment