Tarantool development patches archive
 help / color / mirror / Atom feed
From: imeevma@tarantool.org
To: korablev@tarantool.org
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH v2 4/9] sql: remove PRAGMA "vdbe_addoptrace"
Date: Mon, 30 Dec 2019 19:43:11 +0300	[thread overview]
Message-ID: <81b9cdee0a6dfd07ffb74b80180c18c658f7b49e.1577724051.git.imeevma@gmail.com> (raw)
In-Reply-To: <cover.1577724051.git.imeevma@gmail.com>

The vdbe_addoptrace pragma provides a convenient way to track the
insertion of opcodes into VDBE during VDBE creation. This patch
makes it impossible to disable this feature in the debug build by
removing the pragma. So, now you do not need to enable pragma in
order to use this feature.

Part of #4511
---
 src/box/sql/expr.c        | 15 ---------------
 src/box/sql/pragma.h      | 44 ++++++++++++++++++--------------------------
 src/box/sql/sqlInt.h      |  1 -
 src/box/sql/vdbeaux.c     | 21 ++++-----------------
 test/sql/sql-debug.result |  1 -
 5 files changed, 22 insertions(+), 60 deletions(-)

diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c
index f76f822..6380894 100644
--- a/src/box/sql/expr.c
+++ b/src/box/sql/expr.c
@@ -3466,11 +3466,6 @@ sqlExprCachePush(Parse * pParse)
 {
 	struct session MAYBE_UNUSED *user_session;
 	pParse->iCacheLevel++;
-#ifdef SQL_DEBUG
-	if ((pParse->sql_flags & SQL_VdbeAddopTrace) != 0) {
-		printf("PUSH to %d\n", pParse->iCacheLevel);
-	}
-#endif
 }
 
 /*
@@ -3486,11 +3481,6 @@ sqlExprCachePop(Parse * pParse)
 	user_session = current_session();
 	assert(pParse->iCacheLevel >= 1);
 	pParse->iCacheLevel--;
-#ifdef SQL_DEBUG
-	if ((pParse->sql_flags & SQL_VdbeAddopTrace) != 0) {
-		printf("POP  to %d\n", pParse->iCacheLevel);
-	}
-#endif
 	while (i < pParse->nColCache) {
 		if (pParse->aColCache[i].iLevel > pParse->iCacheLevel) {
 			cacheEntryClear(pParse, i);
@@ -3562,11 +3552,6 @@ sqlExprCacheClear(Parse * pParse)
 	struct session MAYBE_UNUSED *user_session;
 	user_session = current_session();
 
-#if SQL_DEBUG
-	if ((pParse->sql_flags & SQL_VdbeAddopTrace) != 0) {
-		printf("CLEAR\n");
-	}
-#endif
 	for (i = 0; i < pParse->nColCache; i++) {
 		if (pParse->aColCache[i].tempReg
 		    && pParse->nTempReg < ArraySize(pParse->aTempReg)
diff --git a/src/box/sql/pragma.h b/src/box/sql/pragma.h
index 6c9aa8d..05c913d 100644
--- a/src/box/sql/pragma.h
+++ b/src/box/sql/pragma.h
@@ -116,27 +116,24 @@ static const char *const pragCName[] = {
 	/* Used by: sql_trace */
 	/*  72 */ "sql_trace",
 	/*  73 */ "integer",
-	/* Used by: vdbe_addoptrace */
-	/*  74 */ "vdbe_addoptrace",
-	/*  75 */ "integer",
 	/* Used by: vdbe_debug */
-	/*  76 */ "vdbe_debug",
-	/*  77 */ "integer",
+	/*  74 */ "vdbe_debug",
+	/*  75 */ "integer",
 	/* Used by: vdbe_eqp */
-	/*  78 */ "vdbe_eqp",
-	/*  79 */ "integer",
+	/*  76 */ "vdbe_eqp",
+	/*  77 */ "integer",
 	/* Used by: vdbe_listing */
-	/*  80 */ "vdbe_listing",
-	/*  81 */ "integer",
+	/*  78 */ "vdbe_listing",
+	/*  79 */ "integer",
 	/* Used by: vdbe_trace */
-	/*  82 */ "vdbe_trace",
-	/*  83 */ "integer",
+	/*  80 */ "vdbe_trace",
+	/*  81 */ "integer",
 	/* Used by: where_trace */
-	/*  84 */ "where_trace",
-	/*  85 */ "integer",
+	/*  82 */ "where_trace",
+	/*  83 */ "integer",
 	/* Used by: full_metadata */
-	/*  86 */ "full_metadata",
-	/*  87 */ "integer",
+	/*  84 */ "full_metadata",
+	/*  85 */ "integer",
 };
 
 /* Definitions of all built-in pragmas */
@@ -177,7 +174,7 @@ static const PragmaName aPragmaName[] = {
 	{ /* zName:     */ "full_metadata",
 	  /* ePragTyp:  */ PragTyp_FLAG,
 	  /* ePragFlg:  */ PragFlg_Result0 | PragFlg_NoColumns1,
-	  /* ColNames:  */ 86, 1,
+	  /* ColNames:  */ 84, 1,
 	  /* iArg:      */ SQL_FullMetadata},
 	{ /* zName:     */ "index_info",
 	 /* ePragTyp:  */ PragTyp_INDEX_INFO,
@@ -240,36 +237,31 @@ static const PragmaName aPragmaName[] = {
 	 /* ColNames:  */ 0, 6,
 	 /* iArg:      */ 0},
 #if defined(SQL_DEBUG)
-	{ /* zName:     */ "vdbe_addoptrace",
-	 /* ePragTyp:  */ PragTyp_FLAG,
-	 /* ePragFlg:  */ PragFlg_Result0 | PragFlg_NoColumns1,
-	 /* ColNames:  */ 74, 1,
-	 /* iArg:      */ SQL_VdbeAddopTrace},
 	{ /* zName:     */ "vdbe_debug",
 	 /* ePragTyp:  */ PragTyp_FLAG,
 	 /* ePragFlg:  */ PragFlg_Result0 | PragFlg_NoColumns1,
-	 /* ColNames:  */ 76, 1,
+	 /* ColNames:  */ 74, 1,
 	 /* iArg:      */
 	 SQL_SqlTrace | SQL_VdbeListing | SQL_VdbeTrace},
 	{ /* zName:     */ "vdbe_eqp",
 	 /* ePragTyp:  */ PragTyp_FLAG,
 	 /* ePragFlg:  */ PragFlg_Result0 | PragFlg_NoColumns1,
-	 /* ColNames:  */ 78, 1,
+	 /* ColNames:  */ 76, 1,
 	 /* iArg:      */ SQL_VdbeEQP},
 	{ /* zName:     */ "vdbe_listing",
 	 /* ePragTyp:  */ PragTyp_FLAG,
 	 /* ePragFlg:  */ PragFlg_Result0 | PragFlg_NoColumns1,
-	 /* ColNames:  */ 80, 1,
+	 /* ColNames:  */ 78, 1,
 	 /* iArg:      */ SQL_VdbeListing},
 	{ /* zName:     */ "vdbe_trace",
 	 /* ePragTyp:  */ PragTyp_FLAG,
 	 /* ePragFlg:  */ PragFlg_Result0 | PragFlg_NoColumns1,
-	 /* ColNames:  */ 82, 1,
+	 /* ColNames:  */ 80, 1,
 	 /* iArg:      */ SQL_VdbeTrace},
 	{ /* zName:     */ "where_trace",
 	/* ePragTyp:  */ PragTyp_FLAG,
 	/* ePragFlg:  */ PragFlg_Result0 | PragFlg_NoColumns1,
-	/* ColNames:  */ 84, 1,
+	/* ColNames:  */ 82, 1,
 	/* iArg:      */ SQL_WhereTrace},
 #endif
 };
diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h
index d1d1a11..09748a6 100644
--- a/src/box/sql/sqlInt.h
+++ b/src/box/sql/sqlInt.h
@@ -1194,7 +1194,6 @@ struct sql {
 #define SQL_SelectTrace    0x00000800       /* Debug info about select statement */
 #define SQL_WhereTrace     0x00008000       /* Debug info about optimizer's work */
 #define SQL_VdbeListing    0x00000400	/* Debug listings of VDBE programs */
-#define SQL_VdbeAddopTrace 0x00001000	/* Trace sqlVdbeAddOp() calls */
 #define SQL_ReverseOrder   0x00020000	/* Reverse unordered SELECTs */
 #define SQL_RecTriggers    0x00040000	/* Enable recursive triggers */
 #define SQL_AutoIndex      0x00100000	/* Enable automatic indexes */
diff --git a/src/box/sql/vdbeaux.c b/src/box/sql/vdbeaux.c
index 579f515..c63472c 100644
--- a/src/box/sql/vdbeaux.c
+++ b/src/box/sql/vdbeaux.c
@@ -165,9 +165,9 @@ growOpArray(Vdbe * v, int nOp)
 }
 
 #ifdef SQL_DEBUG
-/* This routine is just a convenient place to set a breakpoint that will
- * fire after each opcode is inserted and displayed using
- * "PRAGMA vdbe_addoptrace=on".
+/*
+ * This routine is just a convenient place to set a breakpoint
+ * that will fire after each opcode is inserted in debug build.
  */
 static void
 test_addop_breakpoint(void)
@@ -230,20 +230,7 @@ sqlVdbeAddOp3(Vdbe * p, int op, int p1, int p2, int p3)
 	pOp->zComment = 0;
 #endif
 #ifdef SQL_DEBUG
-	if (user_session->sql_flags & SQL_VdbeAddopTrace) {
-		int jj, kk;
-		Parse *pParse = p->pParse;
-		for (jj = kk = 0; jj < pParse->nColCache; jj++) {
-			struct yColCache *x = pParse->aColCache + jj;
-			printf(" r[%d]={%d:%d}", x->iReg, x->iTable,
-			       x->iColumn);
-			kk++;
-		}
-		if (kk)
-			printf("\n");
-		sqlVdbePrintOp(0, i, &p->aOp[i]);
-		test_addop_breakpoint();
-	}
+	test_addop_breakpoint();
 #endif
 #ifdef VDBE_PROFILE
 	pOp->cycles = 0;
diff --git a/test/sql/sql-debug.result b/test/sql/sql-debug.result
index ce87f11..150f1ec 100644
--- a/test/sql/sql-debug.result
+++ b/test/sql/sql-debug.result
@@ -46,7 +46,6 @@ box.execute('PRAGMA')
   - ['reverse_unordered_selects', 0]
   - ['select_trace', 0]
   - ['sql_trace', 0]
-  - ['vdbe_addoptrace', 0]
   - ['vdbe_debug', 0]
   - ['vdbe_eqp', 0]
   - ['vdbe_listing', 0]
-- 
2.7.4

  parent reply	other threads:[~2019-12-30 16:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-30 16:43 [Tarantool-patches] [PATCH v2 0/9] sql: Remove control pragmas imeevma
2019-12-30 16:43 ` [Tarantool-patches] [PATCH v2 1/9] sql: remove PRAGMA "count_changes" imeevma
2019-12-30 16:43 ` [Tarantool-patches] [PATCH v2 2/9] sql: remove PRAGMA "short_column_names" imeevma
2019-12-30 23:12   ` Nikita Pettik
2019-12-31  4:15     ` Mergen Imeev
2019-12-30 16:43 ` [Tarantool-patches] [PATCH v2 3/9] sql: remove PRAGMA "sql_compound_select_limit" imeevma
2019-12-30 23:11   ` Nikita Pettik
2019-12-31  4:14     ` Mergen Imeev
2019-12-30 16:43 ` imeevma [this message]
2019-12-30 16:43 ` [Tarantool-patches] [PATCH v2 5/9] box: introduce 'service' engine imeevma
2019-12-30 16:43 ` [Tarantool-patches] [PATCH v2 6/9] box: introduce _session_settings system space imeevma
2019-12-30 16:43 ` [Tarantool-patches] [PATCH v2 7/9] box: add SQL settings to _session_settings imeevma
2019-12-30 16:43 ` [Tarantool-patches] [PATCH v2 8/9] sql: remove control pragmas imeevma
2019-12-30 16:43 ` [Tarantool-patches] [PATCH v2 9/9] sql: refactor PRAGMA-related code imeevma
2019-12-30 23:31 ` [Tarantool-patches] [PATCH v2 0/9] sql: Remove control pragmas Nikita Pettik
2019-12-31  4:16   ` Mergen Imeev
2019-12-31  8:01 ` 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=81b9cdee0a6dfd07ffb74b80180c18c658f7b49e.1577724051.git.imeevma@gmail.com \
    --to=imeevma@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v2 4/9] sql: remove PRAGMA "vdbe_addoptrace"' \
    /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