Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Minor fixes for sample code in eqp.in. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
897bd4f88e4bfc4f3e22fffbcfc12e40 |
User & Date: | dan 2010-11-15 17:35:39.000 |
Context
2010-11-15
| ||
18:43 | Add additional requirements marks and reword a few sentences in eqp.html. (check-in: 09966391b1 user: drh tags: trunk) | |
17:35 | Minor fixes for sample code in eqp.in. (check-in: 897bd4f88e user: dan tags: trunk) | |
14:32 | Add the Airbus logo to the "famous.html" page. Update the changes for 3.7.4. (check-in: c0a45dd7fa user: drh tags: trunk) | |
Changes
Changes to pages/eqp.in.
︙ | ︙ | |||
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | 2|0|0|SCAN TABLE t2 (~1000000 rows) 2|0|0|USE TEMP B-TREE FOR ORDER BY 0|0|0|COMPOUND SUBQUERIES 1 AND 2 (EXCEPT) </codeblock>)^ <h1>Sample Code</h1> <codeblock> /* ** Argument pStmt is a prepared SQL statement. This function compiles ** an EXPLAIN QUERY PLAN command to report on the prepared statement, ** and prints the report to stdout using printf(). */ int printExplainQueryPlan(sqlite3_stmt *pStmt){ | > > > > > > > > > > > > > > | | | 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | 2|0|0|SCAN TABLE t2 (~1000000 rows) 2|0|0|USE TEMP B-TREE FOR ORDER BY 0|0|0|COMPOUND SUBQUERIES 1 AND 2 (EXCEPT) </codeblock>)^ <h1>Sample Code</h1> <p>Sometimes, within a large application, it may be inconvenient to modify code to generate EXPLAIN QUERY PLAN commands for the SELECT queries being investigated. From within an interactive debugging session, it may be almost impossible. In these situations, a function similar to the following may be useful. This particular function is passed an SQLite statement handle as an argument and outputs the corresponding EXPLAIN QUERY PLAN report to standard output. Application specific versions may output the report to an application log or similar. <!-- ** WARNING: The following function, printExplainQueryPlan() is duplicated ** in file test1.c of the source distribution for testing purposes. If ** the code below needs to be modified, the copy in test1.c should also ** be modified and the Tcl tests run. --> <codeblock> /* ** Argument pStmt is a prepared SQL statement. This function compiles ** an EXPLAIN QUERY PLAN command to report on the prepared statement, ** and prints the report to stdout using printf(). */ int printExplainQueryPlan(sqlite3_stmt *pStmt){ const char *zSql; /* Input SQL */ char *zExplain; /* SQL with EXPLAIN QUERY PLAN prepended */ sqlite3_stmt *pExplain; /* Compiled EXPLAIN QUERY PLAN command */ int rc; /* Return code from sqlite3_prepare_v2() */ zSql = sqlite3_sql(pStmt); if( zSql==0 ) return SQLITE_ERROR; zExplain = sqlite3_mprintf("EXPLAIN QUERY PLAN %s", zSql); if( zExplain==0 ) return SQLITE_NOMEM; rc = sqlite3_prepare_v2(sqlite3_db_handle(pStmt), zExplain, -1, &pExplain, 0); sqlite3_free(zExplain); if( rc!=SQLITE_OK ) return rc; while( SQLITE_ROW==sqlite3_step(pExplain) ){ int iSelectid = sqlite3_column_int(pExplain, 0); int iOrder = sqlite3_column_int(pExplain, 1); int iFrom = sqlite3_column_int(pExplain, 2); const char *zDetail = (const char *)sqlite3_column_text(pExplain, 3); printf("%d %d %d %s\n", iSelectid, iOrder, iFrom, zDetail); } return sqlite3_finalize(pExplain); } </codeblock> |