[Tarantool-patches] [PATCH v2 4/9] sql: remove PRAGMA "vdbe_addoptrace"

imeevma at tarantool.org imeevma at tarantool.org
Mon Dec 30 19:43:11 MSK 2019


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



More information about the Tarantool-patches mailing list