[patches] [PATCH V2 7/9] sql: delete CursorPayload structure
Bulat Niatshin
niatshin at tarantool.org
Tue Feb 27 16:54:52 MSK 2018
Delete CursorPayload structure and delegate all responsibility to
BtCursor structure, because it already has all necessary fields for
that.
For #3119
---
src/box/sql.c | 8 ++++----
src/box/sql/cursor.h | 19 -------------------
src/box/sql/tarantoolInt.h | 6 +++---
src/box/sql/vdbe.c | 4 +---
4 files changed, 8 insertions(+), 29 deletions(-)
diff --git a/src/box/sql.c b/src/box/sql.c
index 9ce270da9..94cd7f9b9 100644
--- a/src/box/sql.c
+++ b/src/box/sql.c
@@ -488,7 +488,7 @@ int tarantoolSqlite3EphemeralCreate(BtCursor *pCur, uint32_t field_count,
*
* @retval SQLITE_OK on success, SQLITE_TARANTOOL_ERROR otherwise.
*/
-int tarantoolSqlite3EphemeralInsert(BtCursor *pCur, const CursorPayload *pX)
+int tarantoolSqlite3EphemeralInsert(BtCursor *pCur, const BtCursor *pX)
{
assert(pCur);
assert(pCur->curFlags & BTCF_TEphemCursor);
@@ -519,7 +519,7 @@ int tarantoolSqlite3EphemeralDrop(BtCursor *pCur)
return SQLITE_OK;
}
-static int insertOrReplace(BtCursor *pCur, const CursorPayload *pX,
+static int insertOrReplace(BtCursor *pCur, const BtCursor *pX,
int operationType)
{
assert(pCur->curFlags & BTCF_TaCursor);
@@ -541,12 +541,12 @@ static int insertOrReplace(BtCursor *pCur, const CursorPayload *pX,
return rc == 0 ? SQLITE_OK : SQL_TARANTOOL_INSERT_FAIL;;
}
-int tarantoolSqlite3Insert(BtCursor *pCur, const CursorPayload *pX)
+int tarantoolSqlite3Insert(BtCursor *pCur, const BtCursor *pX)
{
return insertOrReplace(pCur, pX, TARANTOOL_INDEX_INSERT);
}
-int tarantoolSqlite3Replace(BtCursor *pCur, const CursorPayload *pX)
+int tarantoolSqlite3Replace(BtCursor *pCur, const BtCursor *pX)
{
return insertOrReplace(pCur, pX, TARANTOOL_INDEX_REPLACE);
}
diff --git a/src/box/sql/cursor.h b/src/box/sql/cursor.h
index e89ee10d7..646d9913d 100644
--- a/src/box/sql/cursor.h
+++ b/src/box/sql/cursor.h
@@ -34,7 +34,6 @@
typedef u32 Pgno;
typedef struct BtCursor BtCursor;
-typedef struct CursorPayload CursorPayload;
/*
* Values that may be OR'd together to form the argument to the
@@ -80,24 +79,6 @@ void sqlite3CursorHintFlags(BtCursor *, unsigned);
int sqlite3CloseCursor(BtCursor *);
int sqlite3CursorMovetoUnpacked(BtCursor *, UnpackedRecord * pUnKey, int *pRes);
-/* An instance of the CursorPayload object describes the content of a single
- * entry in index.
- *
- * This object is used to pass information into tarantoolSqlite3Insert(). The
- * same information used to be passed as five separate parameters. But placing
- * the information into this object helps to keep the interface more
- * organized and understandable, and it also helps the resulting code to
- * run a little faster by using fewer registers for parameter passing.
- */
-struct CursorPayload {
- const void *pKey; /* Key content for indexes. NULL for tables */
- sqlite3_int64 nKey; /* Size of pKey for indexes. PRIMARY KEY for tabs */
- const void *pData; /* Data for tables. NULL for indexes */
- struct Mem *aMem; /* First of nMem value in the unpacked pKey */
- u16 nMem; /* Number of aMem[] value. Might be zero */
- int nData; /* Size of pData. 0 if none. */
-};
-
int sqlite3CursorNext(BtCursor *, int *pRes);
int sqlite3CursorPrevious(BtCursor *, int *pRes);
int sqlite3CursorPayload(BtCursor *, u32 offset, u32 amt, void *);
diff --git a/src/box/sql/tarantoolInt.h b/src/box/sql/tarantoolInt.h
index a7b6bd7f2..699fed2b5 100644
--- a/src/box/sql/tarantoolInt.h
+++ b/src/box/sql/tarantoolInt.h
@@ -74,8 +74,8 @@ int tarantoolSqlite3Previous(BtCursor * pCur, int *pRes);
int tarantoolSqlite3MovetoUnpacked(BtCursor * pCur, UnpackedRecord * pIdxKey,
int *pRes);
int tarantoolSqlite3Count(BtCursor * pCur, i64 * pnEntry);
-int tarantoolSqlite3Insert(BtCursor * pCur, const CursorPayload * pX);
-int tarantoolSqlite3Replace(BtCursor * pCur, const CursorPayload * pX);
+int tarantoolSqlite3Insert(BtCursor * pCur, const BtCursor * pX);
+int tarantoolSqlite3Replace(BtCursor * pCur, const BtCursor * pX);
int tarantoolSqlite3Delete(BtCursor * pCur, u8 flags);
int tarantoolSqlite3ClearTable(int iTable);
@@ -96,7 +96,7 @@ int tarantoolSqlite3RenameParentTable(int iTab, const char *zOldParentName,
/* Interface for ephemeral tables. */
int tarantoolSqlite3EphemeralCreate(BtCursor * pCur, uint32_t filed_count,
struct coll *aColl);
-int tarantoolSqlite3EphemeralInsert(BtCursor * pCur, const CursorPayload * pX);
+int tarantoolSqlite3EphemeralInsert(BtCursor * pCur, const BtCursor * pX);
int tarantoolSqlite3EphemeralDelete(BtCursor * pCur);
int tarantoolSqlite3EphemeralCount(BtCursor * pCur, i64 * pnEntry);
int tarantoolSqlite3EphemeralDrop(BtCursor * pCur);
diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index 46106d735..ec32c79fe 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -4457,7 +4457,7 @@ case OP_SorterInsert: /* in2 */
case OP_IdxReplace:
case OP_IdxInsert: { /* in2 */
VdbeCursor *pC;
- CursorPayload x;
+ BtCursor x;
assert(pOp->p1>=0 && pOp->p1<p->nCursor);
pC = p->apCsr[pOp->p1];
@@ -4474,8 +4474,6 @@ case OP_IdxInsert: { /* in2 */
} else {
x.nKey = pIn2->n;
x.pKey = pIn2->z;
- x.aMem = aMem + pOp->p3;
- x.nMem = (u16)pOp->p4.i;
BtCursor *pBtCur = pC->uc.pCursor;
assert((x.pKey == 0) == (pBtCur->pKeyInfo == 0));
--
2.14.1
More information about the Tarantool-patches
mailing list