Commit 43bd32ae authored by Will DeVries's avatar Will DeVries Committed by Sergei Petrunia

Rework key_read to end with status.

parent 5d80d3dc
......@@ -369,8 +369,18 @@ int clustrix_connection::key_read(ulonglong clustrix_table_oid, uint index,
if (packet_length == packet_error)
return mysql_errno(&clustrix_net);
*rowdata = clustrix_net.net.read_pos;
*rowdata_length = safe_net_field_length_ll(rowdata, packet_length);
uchar *data = clustrix_net.net.read_pos;
*rowdata_length = safe_net_field_length_ll(&data, packet_length);
*rowdata = (uchar *)my_malloc(*rowdata_length, MYF(MY_WME));
memcpy(*rowdata, data, *rowdata_length);
packet_length = cli_safe_read(&clustrix_net);
if (packet_length == packet_error) {
my_free(*rowdata);
*rowdata = NULL;
*rowdata_length = 0;
return mysql_errno(&clustrix_net);
}
return 0;
}
......
......@@ -97,8 +97,8 @@ class clustrix_connection
int key_delete(ulonglong clustrix_table_oid,
uchar *packed_key, size_t packed_key_length);
int key_read(ulonglong clustrix_table_oid, uint index, MY_BITMAP *read_set,
uchar *packed_key, ulong packed_key_length,
uchar **rowdata, ulong *rowdata_length);
uchar *packed_key, ulong packed_key_length, uchar **rowdata,
ulong *rowdata_length);
enum sort_order {SORT_NONE = 0, SORT_ASC = 1, SORT_DESC = 2};
enum scan_type {
......
......@@ -856,7 +856,7 @@ int ha_clustrixdb::rnd_pos(uchar * buf, uchar *pos)
build_key_packed_row(table->s->primary_key, table->record[0],
packed_key, &packed_key_len);
uchar *rowdata;
uchar *rowdata = NULL;
ulong rowdata_length;
if ((error_code = trx->key_read(clustrix_table_oid, 0, table->read_set,
packed_key, packed_key_len,
......@@ -871,6 +871,8 @@ int ha_clustrixdb::rnd_pos(uchar * buf, uchar *pos)
goto err;
err:
if (rowdata);
my_free(rowdata);
if (packed_key)
my_afree(packed_key);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment