Tarantool development patches archive
 help / color / mirror / Atom feed
From: "n.pettik" <korablev@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Imeev Mergen <imeevma@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH v2 6/6] sql: set column types for EXPLAIN and PRAGMA
Date: Mon, 24 Dec 2018 16:02:14 +0200	[thread overview]
Message-ID: <E54006FE-6C94-4D0B-8A62-5F1137EC0860@tarantool.org> (raw)
In-Reply-To: <f7265e12b4ad98ea4d92487bc258f6c62db2d9b3.1544871594.git.imeevma@gmail.com>


> -/*
> - * Set result column names for a pragma.
> - */
> +/** Set result column names and types for a pragma. */
> static void
> -setPragmaResultColumnNames(Vdbe * v, /* The query under construction */
> -        const PragmaName * pPragma /* The pragma */
> -    )
> +vdbe_set_pragma_result_columns(struct Vdbe *v, const struct PragmaName *pragma)
> {
> - u8 n = pPragma->nPragCName;
> - sqlite3VdbeSetNumCols(v, n == 0 ? 1 : n);
> - if (n == 0) {
> -   sqlite3VdbeSetColName(v, 0, COLNAME_NAME, pPragma->zName,
> + int n = pragma->nPragCName;
> + assert(n > 0);
> + sqlite3VdbeSetNumCols(v, n);
> + for (int i = 0, j = pragma->iPragCName; i < n; ++i) {
> +   /* Value of j is index of column name in array */
> +   sqlite3VdbeSetColName(v, i, COLNAME_NAME, pragCName[j++],
> +             SQLITE_STATIC);
> +   /* Value of j is index of column type in array */

These two comments are too obvious, lets remove them.

> 
> @@ -473,16 +468,14 @@ sqlite3Pragma(Parse * pParse, Token * pId,  /* First part of [schema.]id field */
>  }
>  /* Register the result column names for pragmas that return results */
>  if ((pPragma->mPragFlg & PragFlg_NoColumns) == 0
> -     && ((pPragma->mPragFlg & PragFlg_NoColumns1) == 0 || zRight == 0)
> -     ) {
> -   setPragmaResultColumnNames(v, pPragma);
> - }
> +     && ((pPragma->mPragFlg & PragFlg_NoColumns1) == 0 || zRight == 0))

Nit: put operator on previous line:

-       if ((pPragma->mPragFlg & PragFlg_NoColumns) == 0
-           && ((pPragma->mPragFlg & PragFlg_NoColumns1) == 0 || zRight == 0))
+       if ((pPragma->mPragFlg & PragFlg_NoColumns) == 0 &&
+           ((pPragma->mPragFlg & PragFlg_NoColumns1) == 0 || zRight == 0))

> ---
> ...
> diff --git a/test/sql/iproto.test.lua b/test/sql/iproto.test.lua
> index 6640903..9f9a382 100644
> --- a/test/sql/iproto.test.lua
> +++ b/test/sql/iproto.test.lua
> @@ -263,10 +263,26 @@ box.sql.execute('DROP TABLE t1')
> 
> cn:close()
> 
> +-- gh-3832: Some statements do not return column type
> +box.sql.execute('CREATE TABLE t1(id INTEGER PRIMARY KEY)')
> +cn = remote.connect(box.cfg.listen)
> +
> +-- PRAGMA:
> +res = cn:execute("PRAGMA table_info(t1)")
> +res.metadata
> +
> +-- EXPLAIN
> +res = cn:execute("EXPLAIN select 1")
> +res.metadata
> +res = cn:execute("EXPLAIN QUERY PLAN select count(*) from t1”)

Nit: uppercase all SQL keywords pls. Otherwise it looks pretty ugly.

Patch itself is OK.

      reply	other threads:[~2018-12-24 14:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-15 11:51 [tarantool-patches] [PATCH v2 0/6] " imeevma
2018-12-15 11:54 ` [tarantool-patches] [PATCH v2 1/6] sql: remove unnecessary macros from pragma.* imeevma
2018-12-20 20:41   ` [tarantool-patches] " Vladislav Shpilevoy
2018-12-24 14:01   ` n.pettik
2018-12-15 11:56 ` [tarantool-patches] [PATCH v2 2/6] sql: fix "PRAGMA parser_trace" result imeevma
2018-12-24 14:01   ` [tarantool-patches] " n.pettik
2018-12-15 12:01 ` [tarantool-patches] [PATCH v2 3/6] sql: Show currently set sql_default_engine imeevma
2018-12-24 14:01   ` [tarantool-patches] " n.pettik
2018-12-15 12:03 ` [tarantool-patches] [PATCH v2 4/6] sql: fix "PRAGMA case_sensitive_like" result imeevma
2018-12-24 14:01   ` [tarantool-patches] " n.pettik
2018-12-15 12:05 ` [tarantool-patches] [PATCH v2 5/6] sql: 'PRAGMA' result in Tarantool format imeevma
2018-12-24 14:02   ` [tarantool-patches] " n.pettik
2018-12-15 12:08 ` [tarantool-patches] [PATCH v2 6/6] sql: set column types for EXPLAIN and PRAGMA imeevma
2018-12-24 14:02   ` n.pettik [this message]

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=E54006FE-6C94-4D0B-8A62-5F1137EC0860@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=imeevma@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v2 6/6] sql: set column types for EXPLAIN and PRAGMA' \
    /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