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 1/6] sql: introduce a new method to bind a pointer Date: Thu, 23 May 2019 13:19:34 +0300 [thread overview] Message-ID: <d5b027080e52d7d2f381fb08d4b796b3e48f0efd.1558605591.git.kshcherbatov@tarantool.org> (raw) In-Reply-To: <cover.1558605591.git.kshcherbatov@tarantool.org> A new sql_bind_ptr routine allows to bing a generic pointer to VDBE variable. This change is required to pass a tuple_fetcher representing a new tuple to the check constraint VDBE. Needed for #3961 --- src/box/sql/sqlInt.h | 12 ++++++++++++ src/box/sql/vdbeInt.h | 8 ++++++++ src/box/sql/vdbeapi.c | 12 ++++++++++++ src/box/sql/vdbemem.c | 8 ++++++++ 4 files changed, 40 insertions(+) diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h index e33d7d95b..7212553f6 100644 --- a/src/box/sql/sqlInt.h +++ b/src/box/sql/sqlInt.h @@ -923,6 +923,18 @@ int sql_bind_zeroblob64(sql_stmt *, int, sql_uint64); +/** + * Perform pointer parameter binding for the prepared sql + * statement. + * @param stmt Prepared statement. + * @param i Index of the variable to be binded. + * @param ptr Pointer value to use. + * @retval 0 On Success. + * @retval Not 0 otherwise. + */ +int +sql_bind_ptr(struct sql_stmt *stmt, int i, void *ptr); + int sql_stmt_busy(sql_stmt *); diff --git a/src/box/sql/vdbeInt.h b/src/box/sql/vdbeInt.h index 86fd92da1..240283927 100644 --- a/src/box/sql/vdbeInt.h +++ b/src/box/sql/vdbeInt.h @@ -501,6 +501,14 @@ void sqlVdbeMemSetInt64(Mem *, i64); void mem_set_bool(struct Mem *mem, bool value); +/** + * Set VDBE memory register with given pointer as a data. + * @param mem VDBE memory register to update. + * @param ptr Pointer to use. + */ +void +mem_set_ptr(struct Mem *mem, void *ptr); + void sqlVdbeMemSetDouble(Mem *, double); void sqlVdbeMemInit(Mem *, sql *, u32); void sqlVdbeMemSetNull(Mem *); diff --git a/src/box/sql/vdbeapi.c b/src/box/sql/vdbeapi.c index e480ae720..198c2a9d7 100644 --- a/src/box/sql/vdbeapi.c +++ b/src/box/sql/vdbeapi.c @@ -1392,6 +1392,18 @@ sql_bind_null(sql_stmt * pStmt, int i) return rc; } +int +sql_bind_ptr(struct sql_stmt *stmt, int i, void *ptr) +{ + struct Vdbe *p = (struct Vdbe *) stmt; + int rc = vdbeUnbind(p, i); + if (rc == SQL_OK) { + rc = sql_bind_type(p, i, "BLOB"); + mem_set_ptr(&p->aVar[i - 1], ptr); + } + return rc; +} + int sql_bind_text(sql_stmt * pStmt, int i, const char *zData, int nData, void (*xDel) (void *) diff --git a/src/box/sql/vdbemem.c b/src/box/sql/vdbemem.c index f73ea0a71..382d8ae56 100644 --- a/src/box/sql/vdbemem.c +++ b/src/box/sql/vdbemem.c @@ -749,6 +749,14 @@ sqlValueSetNull(sql_value * p) sqlVdbeMemSetNull((Mem *) p); } +void +mem_set_ptr(struct Mem *mem, void *ptr) +{ + sqlVdbeMemRelease(mem); + mem->flags = MEM_Ptr; + mem->u.p = ptr; +} + /* * Delete any previous value and set the value to be a BLOB of length * n containing all zeros. -- 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 ` Kirill Shcherbatov [this message] 2019-05-23 10:19 ` [tarantool-patches] [PATCH v5 2/6] sql: refactor OP_Column vdbe instruction Kirill Shcherbatov 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=d5b027080e52d7d2f381fb08d4b796b3e48f0efd.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 1/6] sql: introduce a new method to bind a pointer' \ /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