mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Provide the ability to use the SELECTTRACE() debugging macro outside of the
select.c source file. Use this to add a new SELECTTRACE() entry in window.c for improved tracing of window-function parse-tree rewriting. FossilOrigin-Name: 30c6d895b573d5f2a53487b3b7a0d20be7e382c7a0bc87336bd43fbd2fa89bf4
This commit is contained in:
@@ -1 +1 @@
|
|||||||
fd5abb1a7b5a55127d5c0d5ff448020d8bccab44e4f5afe1eb88fc19578af735
|
30c6d895b573d5f2a53487b3b7a0d20be7e382c7a0bc87336bd43fbd2fa89bf4
|
@@ -300,6 +300,11 @@ sqlite3_uint64 sqlite3NProfileCnt = 0;
|
|||||||
int sqlite3PendingByte = 0x40000000;
|
int sqlite3PendingByte = 0x40000000;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Flags for select tracing and the ".selecttrace" macro of the CLI
|
||||||
|
*/
|
||||||
|
/**/ u32 sqlite3SelectTrace = 0;
|
||||||
|
|
||||||
#include "opcodes.h"
|
#include "opcodes.h"
|
||||||
/*
|
/*
|
||||||
** Properties of opcodes. The OPFLG_INITIALIZER macro is
|
** Properties of opcodes. The OPFLG_INITIALIZER macro is
|
||||||
|
16
src/select.c
16
src/select.c
@@ -14,20 +14,6 @@
|
|||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
/*
|
|
||||||
** Trace output macros
|
|
||||||
*/
|
|
||||||
#if SELECTTRACE_ENABLED
|
|
||||||
/***/ int sqlite3SelectTrace = 0;
|
|
||||||
# define SELECTTRACE(K,P,S,X) \
|
|
||||||
if(sqlite3SelectTrace&(K)) \
|
|
||||||
sqlite3DebugPrintf("%u/%d/%p: ",(S)->selId,(P)->addrExplain,(S)),\
|
|
||||||
sqlite3DebugPrintf X
|
|
||||||
#else
|
|
||||||
# define SELECTTRACE(K,P,S,X)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** An instance of the following object is used to record information about
|
** An instance of the following object is used to record information about
|
||||||
** how to process the DISTINCT keyword, to simplify passing that information
|
** how to process the DISTINCT keyword, to simplify passing that information
|
||||||
@@ -5826,7 +5812,7 @@ int sqlite3Select(
|
|||||||
memset(&sSort, 0, sizeof(sSort));
|
memset(&sSort, 0, sizeof(sSort));
|
||||||
sSort.pOrderBy = p->pOrderBy;
|
sSort.pOrderBy = p->pOrderBy;
|
||||||
|
|
||||||
/* Try to various optimizations (flattening subqueries, and strength
|
/* Try to do various optimizations (flattening subqueries, and strength
|
||||||
** reduction of join operators) in the FROM clause up into the main query
|
** reduction of join operators) in the FROM clause up into the main query
|
||||||
*/
|
*/
|
||||||
#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)
|
#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)
|
||||||
|
@@ -979,6 +979,16 @@ typedef INT16_TYPE LogEst;
|
|||||||
#else
|
#else
|
||||||
# define SELECTTRACE_ENABLED 0
|
# define SELECTTRACE_ENABLED 0
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(SQLITE_ENABLE_SELECTTRACE)
|
||||||
|
# define SELECTTRACE_ENABLED 1
|
||||||
|
# define SELECTTRACE(K,P,S,X) \
|
||||||
|
if(sqlite3SelectTrace&(K)) \
|
||||||
|
sqlite3DebugPrintf("%u/%d/%p: ",(S)->selId,(P)->addrExplain,(S)),\
|
||||||
|
sqlite3DebugPrintf X
|
||||||
|
#else
|
||||||
|
# define SELECTTRACE(K,P,S,X)
|
||||||
|
# define SELECTTRACE_ENABLED 0
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** An instance of the following structure is used to store the busy-handler
|
** An instance of the following structure is used to store the busy-handler
|
||||||
@@ -4555,10 +4565,11 @@ extern const unsigned char sqlite3UpperToLower[];
|
|||||||
extern const unsigned char sqlite3CtypeMap[];
|
extern const unsigned char sqlite3CtypeMap[];
|
||||||
extern SQLITE_WSD struct Sqlite3Config sqlite3Config;
|
extern SQLITE_WSD struct Sqlite3Config sqlite3Config;
|
||||||
extern FuncDefHash sqlite3BuiltinFunctions;
|
extern FuncDefHash sqlite3BuiltinFunctions;
|
||||||
|
extern u32 sqlite3SelectTrace;
|
||||||
#ifndef SQLITE_OMIT_WSD
|
#ifndef SQLITE_OMIT_WSD
|
||||||
extern int sqlite3PendingByte;
|
extern int sqlite3PendingByte;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif /* SQLITE_AMALGAMATION */
|
||||||
#ifdef VDBE_PROFILE
|
#ifdef VDBE_PROFILE
|
||||||
extern sqlite3_uint64 sqlite3NProfileCnt;
|
extern sqlite3_uint64 sqlite3NProfileCnt;
|
||||||
#endif
|
#endif
|
||||||
|
@@ -8164,7 +8164,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if defined(SQLITE_ENABLE_SELECTTRACE)
|
#if defined(SQLITE_ENABLE_SELECTTRACE)
|
||||||
extern int sqlite3SelectTrace;
|
extern u32 sqlite3SelectTrace;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){
|
for(i=0; i<sizeof(aCmd)/sizeof(aCmd[0]); i++){
|
||||||
|
@@ -1043,6 +1043,9 @@ int sqlite3WindowRewrite(Parse *pParse, Select *p){
|
|||||||
pSub = sqlite3SelectNew(
|
pSub = sqlite3SelectNew(
|
||||||
pParse, pSublist, pSrc, pWhere, pGroupBy, pHaving, pSort, 0, 0
|
pParse, pSublist, pSrc, pWhere, pGroupBy, pHaving, pSort, 0, 0
|
||||||
);
|
);
|
||||||
|
SELECTTRACE(1,pParse,pSub,
|
||||||
|
("New window-function subquery in FROM clause of (%u/%p)\n",
|
||||||
|
p->selId, p));
|
||||||
p->pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0);
|
p->pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0);
|
||||||
if( p->pSrc ){
|
if( p->pSrc ){
|
||||||
Table *pTab2;
|
Table *pTab2;
|
||||||
|
Reference in New Issue
Block a user