From: Kirill Shcherbatov <kshcherbatov@tarantool.org> To: tarantool-patches@freelists.org, v.shpilevoy@tarantool.org Cc: Kirill Shcherbatov <kshcherbatov@tarantool.org> Subject: [tarantool-patches] [PATCH v5 2/6] sql: refactor OP_Column vdbe instruction Date: Thu, 23 May 2019 13:19:35 +0300 [thread overview] Message-ID: <f0b290edae4ff909a8f17a1afa42a783dc4a51ac.1558605591.git.kshcherbatov@tarantool.org> (raw) In-Reply-To: <cover.1558605591.git.kshcherbatov@tarantool.org> This preparatory refactoring is necessary to simplify the process of introducing a new OP_Fetch statement in the next patch. - got rid of useless sMem local variable - got rid of useless payloadSize in VdbeCursor structure Needed for #3691 --- src/box/sql/vdbe.c | 35 +++++++---------------------------- src/box/sql/vdbeInt.h | 1 - 2 files changed, 7 insertions(+), 29 deletions(-) diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index 11f5685f3..5d37f63fb 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -2600,7 +2600,6 @@ case OP_Column: { u32 *aOffset; /* aOffset[i] is offset to start of data for i-th column */ int i; /* Loop counter */ Mem *pDest; /* Where to write the extracted value */ - Mem sMem; /* For storing the record being decoded */ const u8 *zData; /* Part of the record being decoded */ const u8 MAYBE_UNUSED *zEnd; /* Data end */ const u8 *zParse; /* Next unparsed byte of the row */ @@ -2626,7 +2625,7 @@ case OP_Column: { pReg = &aMem[pC->uc.pseudoTableReg]; assert(pReg->flags & MEM_Blob); assert(memIsValid(pReg)); - pC->payloadSize = pC->szRow = pReg->n; + pC->szRow = pReg->n; pC->aRow = (u8*)pReg->z; } else { sqlVdbeMemSetNull(pDest); @@ -2639,9 +2638,7 @@ case OP_Column: { assert(sqlCursorIsValid(pCrsr)); assert(pCrsr->curFlags & BTCF_TaCursor || pCrsr->curFlags & BTCF_TEphemCursor); - pC->aRow = tarantoolsqlPayloadFetch(pCrsr, - &pC->payloadSize); - pC->szRow = pC->payloadSize; + pC->aRow = tarantoolsqlPayloadFetch(pCrsr, &pC->szRow); } pC->cacheStatus = p->cacheCtr; @@ -2659,22 +2656,8 @@ case OP_Column: { } goto op_column_out; } - - /* Sometimes the data is too large and overflow pages come into play. - * In the later case allocate a buffer and reassamble the row. - * Stock sql utilized several clever techniques to optimize here. - * The techniques we ripped out to simplify the code. - */ - if (pC->szRow==pC->payloadSize) { - zData = pC->aRow; - zEnd = zData + pC->payloadSize; - } else { - memset(&sMem, 0, sizeof(sMem)); - rc = sqlVdbeMemFromBtree(pC->uc.pCursor, 0, pC->payloadSize, &sMem); - if (rc!=SQL_OK) goto abort_due_to_error; - zData = (u8*)sMem.z; - zEnd = zData + pC->payloadSize; - } + zData = pC->aRow; + zEnd = zData + pC->szRow; /* * Make sure at least the first p2+1 entries of the header @@ -2767,7 +2750,8 @@ case OP_Column: { if ((pDest->flags & (MEM_Ephem | MEM_Str)) == (MEM_Ephem | MEM_Str)) { int len = pDest->n; if (pDest->szMalloc<len+1) { - if (sqlVdbeMemGrow(pDest, len+1, 1)) goto op_column_error; + if (sqlVdbeMemGrow(pDest, len+1, 1)) + goto abort_due_to_error; } else { pDest->z = memcpy(pDest->zMalloc, pDest->z, len); pDest->flags &= ~MEM_Ephem; @@ -2776,15 +2760,10 @@ case OP_Column: { pDest->flags |= MEM_Term; } - if (zData!=pC->aRow) sqlVdbeMemRelease(&sMem); - op_column_out: +op_column_out: UPDATE_MAX_BLOBSIZE(pDest); REGISTER_TRACE(p, pOp->p3, pDest); break; - - op_column_error: - if (zData!=pC->aRow) sqlVdbeMemRelease(&sMem); - goto abort_due_to_error; } /* Opcode: ApplyType P1 P2 * P4 * diff --git a/src/box/sql/vdbeInt.h b/src/box/sql/vdbeInt.h index 240283927..d58e3df7b 100644 --- a/src/box/sql/vdbeInt.h +++ b/src/box/sql/vdbeInt.h @@ -114,7 +114,6 @@ struct VdbeCursor { i16 nField; /* Number of fields in the header */ u16 nHdrParsed; /* Number of header fields parsed so far */ const u8 *aRow; /* Data for the current row, if all on one page */ - u32 payloadSize; /* Total number of bytes in the record */ u32 szRow; /* Byte available in aRow */ #ifdef SQL_ENABLE_COLUMN_USED_MASK u64 maskUsed; /* Mask of columns used by this cursor */ -- 2.21.0
next prev parent reply other threads:[~2019-05-23 10:19 UTC|newest] Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-05-23 10:19 [tarantool-patches] [PATCH v5 0/6] box: run checks on insertions in LUA spaces Kirill Shcherbatov 2019-05-23 10:19 ` [tarantool-patches] [PATCH v5 1/6] sql: introduce a new method to bind a pointer Kirill Shcherbatov 2019-05-23 10:19 ` Kirill Shcherbatov [this message] 2019-05-23 10:19 ` [tarantool-patches] [PATCH v5 3/6] sql: introduce tuple_fetcher class Kirill Shcherbatov 2019-05-26 12:05 ` [tarantool-patches] " Vladislav Shpilevoy 2019-05-31 13:45 ` Kirill Shcherbatov 2019-05-31 19:45 ` Konstantin Osipov 2019-05-31 19:50 ` Kirill Shcherbatov 2019-05-31 22:36 ` Vladislav Shpilevoy 2019-06-01 5:45 ` Konstantin Osipov 2019-06-02 18:50 ` Kirill Shcherbatov 2019-06-03 21:15 ` Vladislav Shpilevoy 2019-06-05 6:47 ` Konstantin Osipov 2019-06-05 6:48 ` Konstantin Osipov 2019-05-23 10:19 ` [tarantool-patches] [PATCH v5 4/6] schema: add new system space for CHECK constraints Kirill Shcherbatov 2019-05-26 12:06 ` [tarantool-patches] " Vladislav Shpilevoy 2019-05-26 13:31 ` n.pettik 2019-05-26 13:32 ` Vladislav Shpilevoy 2019-05-31 13:45 ` Kirill Shcherbatov 2019-06-03 21:15 ` Vladislav Shpilevoy 2019-05-23 10:19 ` [tarantool-patches] [PATCH v5 5/6] box: run check constraint tests on space alter Kirill Shcherbatov 2019-05-26 12:07 ` [tarantool-patches] " Vladislav Shpilevoy 2019-05-31 13:45 ` Kirill Shcherbatov 2019-06-03 21:15 ` Vladislav Shpilevoy 2019-05-23 10:19 ` [tarantool-patches] [PATCH v5 6/6] box: user-friendly interface to manage ck constraints Kirill Shcherbatov 2019-05-26 12:07 ` [tarantool-patches] " Vladislav Shpilevoy 2019-05-31 13:45 ` Kirill Shcherbatov 2019-06-03 21:15 ` [tarantool-patches] Re: [PATCH v5 0/6] box: run checks on insertions in LUA spaces Vladislav Shpilevoy 2019-06-04 7:21 ` Kirill Shcherbatov 2019-06-04 18:59 ` Vladislav Shpilevoy 2019-06-06 11:58 ` Kirill Yukhin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=f0b290edae4ff909a8f17a1afa42a783dc4a51ac.1558605591.git.kshcherbatov@tarantool.org \ --to=kshcherbatov@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [tarantool-patches] [PATCH v5 2/6] sql: refactor OP_Column vdbe instruction' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox