From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 2286420A9C for ; Sat, 26 Jan 2019 19:28:17 -0500 (EST) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 16tRBVtK2r9Q for ; Sat, 26 Jan 2019 19:28:16 -0500 (EST) Received: from smtp46.i.mail.ru (smtp46.i.mail.ru [94.100.177.106]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id A52EE209D4 for ; Sat, 26 Jan 2019 19:28:15 -0500 (EST) From: Roman Khabibov Subject: [tarantool-patches] [PATCH 1/2] sql: add sqlite3 msgpack result function Date: Sun, 27 Jan 2019 03:28:10 +0300 Message-Id: <367affe7a5ed5f1acd195c900e25aa85249bcf0e.1548547565.git.roman.habibov@tarantool.org> In-Reply-To: References: In-Reply-To: References: Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org Cc: korablev@tarantool.org Add function like sqlite3_result_blob that sets subtype of out parameter as SQL_SUBTYPE_MSGPACK. It allows to encode msg pack fields. Needed for #3372 --- src/box/sql/sqliteInt.h | 3 +++ src/box/sql/vdbeapi.c | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/box/sql/sqliteInt.h b/src/box/sql/sqliteInt.h index 7e16edc9a..9b4db93d3 100644 --- a/src/box/sql/sqliteInt.h +++ b/src/box/sql/sqliteInt.h @@ -465,6 +465,9 @@ sqlite3_value_numeric_type(sqlite3_value *); sqlite3 * sqlite3_context_db_handle(sqlite3_context *); +void +sqlite3_result_msgpack(sqlite3_context *, const void *, + int, void (*)(void *)); void sqlite3_result_blob(sqlite3_context *, const void *, diff --git a/src/box/sql/vdbeapi.c b/src/box/sql/vdbeapi.c index 9e57af051..ed7b67e3b 100644 --- a/src/box/sql/vdbeapi.c +++ b/src/box/sql/vdbeapi.c @@ -360,6 +360,19 @@ invokeValueDestructor(const void *p, /* Value to destroy */ return SQLITE_TOOBIG; } +void +sqlite3_result_msgpack(sqlite3_context * pCtx, + const void *z, int n, void (*xDel) (void *) + ) +{ + assert(n >= 0); + if (sqlite3VdbeMemSetStr(pCtx->pOut, z, n,0, xDel) == SQLITE_TOOBIG) { + sqlite3_result_error_toobig(pCtx); + } + pCtx->pOut->flags|= MEM_Subtype; + pCtx->pOut->subtype = SQL_SUBTYPE_MSGPACK; +} + void sqlite3_result_blob(sqlite3_context * pCtx, const void *z, int n, void (*xDel) (void *) -- 2.17.1