Tarantool development patches archive
 help / color / mirror / Atom feed
From: Nikita Tatunov <hollow653@gmail.com>
To: korablev@tarantool.org
Cc: tarantool-patches@freelists.org
Subject: [tarantool-patches] Re: [PATCH] sql: Remove 'BEGIN TRANSACTION'
Date: Thu, 19 Jul 2018 14:48:48 +0300	[thread overview]
Message-ID: <CAEi+_arorVXcHRuD9TzumEG_scx2gVKXv9e2EEn3H-J15qKROA@mail.gmail.com> (raw)
In-Reply-To: <D0B70AE8-D0C6-4B45-9E7A-E14E8FE5D27D@tarantool.org>

[-- Attachment #1: Type: text/plain, Size: 3906 bytes --]

чт, 19 июл. 2018 г. в 3:24, n.pettik <korablev@tarantool.org>:

>
> diff --git a/extra/lempar.c b/extra/lempar.c
> index 00fd79c..d043e39 100644
> --- a/extra/lempar.c
> +++ b/extra/lempar.c
> @@ -336,8 +336,8 @@ void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){
>    if( pParser ){
>  #ifdef YYTRACKMAXSTACKDEPTH
>      pParser->yyhwm = 0;
> -    pParser->is_fallback_failed = false;
>  #endif
> +    pParser->is_fallback_failed = false;
>
>
> Could you please explain this code movement?
>

"Also found
initialization in ifdef that caused some problems with error
messages in occasions when the wrong syntax was used."

To be more accurate it's just variable initialization that was in wrong
place.
Moreover in most cases (almost always) after allocating memory for this
variable there was non-zero value ('true', basically), that was causing
"keyword 'BEGIN' is reserved" error message if we use "BEGIN" instead
of "START TRANSACTION", after the patch changes are applied.


>
> +++ b/test/sql-tap/start-transaction.test.lua
> @@ -0,0 +1,266 @@
> +#!/usr/bin/env tarantool
> +test = require("sqltester")
> +test:plan(21)
> +
> +test:do_catchsql_test(
> + "start-transaction-1.0",
> + [[
> + CREATE TABLE IF NOT EXISTS t(id int PRIMARY KEY);
> + DELETE FROM t;
> + BEGIN;
> + INSERT INTO t VALUES (1);
> + INSERT INTO t VALUES (2);
> + COMMIT;
> + ]], {
> + -- <start-transaction-1.0>
> + 1, "near \"BEGIN\": syntax error"
> + -- <start-transaction-1.0>
> + })
> +
> +test:do_execsql_test(
> + "start-transaction-1.1",
> + [[
> + SELECT * FROM t;
> + ]], {
> + -- <start-transaction-1.1>
> +
> + -- <start-transaction-1.1>
> + })
> +
> +test:do_catchsql_test(
> + "start-transaction-1.2",
> + [[
> + CREATE TABLE IF NOT EXISTS t(id int primary key);
> + delete from t;
>
>
> We write SQL queries in upper-case. Fix it in other places too.
>
> Fixed it.

Diff with the previous pushed patch:

diff --git a/test/sql-tap/start-transaction.test.lua
b/test/sql-tap/start-transaction.test.lua
index eece4cd..98ca531 100755
--- a/test/sql-tap/start-transaction.test.lua
+++ b/test/sql-tap/start-transaction.test.lua
@@ -30,8 +30,8 @@ test:do_execsql_test(
 test:do_catchsql_test(
  "start-transaction-1.2",
  [[
- CREATE TABLE IF NOT EXISTS t(id int primary key);
- delete from t;
+ CREATE TABLE IF NOT EXISTS t(id INT PRIMARY KEY);
+ DELETE FROM t;
  BEGIN TRANSACTION;
  INSERT INTO t VALUES (1);
  INSERT INTO t VALUES (2);
@@ -256,7 +256,7 @@ test:do_execsql_test(
 test:do_execsql_test(
  "start-transaction-1.20",
  [[
- drop table t;
+ DROP TABLE t;
  ]], {
  -- <start0transaction-1.20>

diff --git a/test/sql/tokenizer.result b/test/sql/tokenizer.result
index 7c0ca8f..95063b5 100644
--- a/test/sql/tokenizer.result
+++ b/test/sql/tokenizer.result
@@ -102,9 +102,9 @@ sql_tokenizer.split_sql('select 1; -- test comment\n;
select 2;')
 - - select 1;
   - ' select 2;'
 ...
-sql_tokenizer.split_sql("start transaction; insert into table values
('example kek--'); commit;")
+sql_tokenizer.split_sql("START TRANSACTION; insert into table values
('example kek--'); commit;")
 ---
-- - start transaction;
+- - START TRANSACTION;
   - ' insert into table values (''example kek--'');'
   - ' commit;'
 ...
diff --git a/test/sql/tokenizer.test.lua b/test/sql/tokenizer.test.lua
index 5c1cadc..4a4e289 100644
--- a/test/sql/tokenizer.test.lua
+++ b/test/sql/tokenizer.test.lua
@@ -32,7 +32,7 @@ test_run:cmd("setopt delimiter ''");

 sql_tokenizer.split_sql('select 1; -- test comment\n; select 2;')

-sql_tokenizer.split_sql("start transaction; insert into table values
('example kek--'); commit;")
+sql_tokenizer.split_sql("START TRANSACTION; insert into table values
('example kek--'); commit;")

 sql_tokenizer.split_sql("insert into quoted(a) value 'lalala'")

[-- Attachment #2: Type: text/html, Size: 8335 bytes --]

  reply	other threads:[~2018-07-19 11:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-05 10:42 [tarantool-patches] " N.Tatunov
2018-07-05 11:48 ` [tarantool-patches] " Nikita Tatunov
2018-07-09 15:35 ` Alexander Turenko
2018-07-13  2:15 ` n.pettik
2018-07-16 12:22   ` Nikita Tatunov
2018-07-19  0:24     ` n.pettik
2018-07-19 11:48       ` Nikita Tatunov [this message]
2018-07-19 14:03         ` n.pettik
2018-07-19 15:44           ` Vladislav Shpilevoy
2018-07-19 18:08             ` Nikita Tatunov
2018-07-19 18:13               ` Vladislav Shpilevoy
2018-07-20 13:24 ` 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=CAEi+_arorVXcHRuD9TzumEG_scx2gVKXv9e2EEn3H-J15qKROA@mail.gmail.com \
    --to=hollow653@gmail.com \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH] sql: Remove '\''BEGIN TRANSACTION'\''' \
    /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