[patches] [PATCH] sql: fix misusing of index_max() in SQL bindings

Nikita Pettik korablev at tarantool.org
Wed Mar 7 20:59:18 MSK 2018


After #3167 has been implemented, to get max tuple from index it is
required to pass NULL as a key and 0 as parts count. Previously, it was
also possbile (and actually used) by passing surrogate key created on
stack and real number of parts.
---
 src/box/sql.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/box/sql.c b/src/box/sql.c
index 256985793..771b18e60 100644
--- a/src/box/sql.c
+++ b/src/box/sql.c
@@ -1735,12 +1735,8 @@ int tarantoolSqlite3EphemeralGetMaxId(BtCursor *pCur, uint32_t fieldno,
 	assert(ephem_space);
 	struct index *primary_index = *ephem_space->index;
 
-	char key[16];
-	mp_encode_array(key, 0);
 	struct tuple *tuple;
-
-	uint32_t part_count = primary_index->def->key_def->part_count;
-	if (index_max(primary_index, key, part_count, &tuple) != 0) {
+	if (index_max(primary_index, NULL, 0, &tuple) != 0) {
 		return SQL_TARANTOOL_ERROR;
 	}
 	if (tuple != NULL && tuple_bless(tuple) == NULL)
-- 
2.15.1




More information about the Tarantool-patches mailing list