Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Attempt to improve error messages resulting from SQL errors. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
b94e15cff72b105e9fa6ecbf404baeb4 |
User & Date: | drh 2019-09-13 13:54:36.692 |
Context
2019-09-13
| ||
22:53 | Update to openssl 1.1.1d ... (check-in: 74aac0ed3d user: jan.nijtmans tags: trunk) | |
15:11 | Merge in latest developments from trunk. ... (Closed-Leaf check-in: b713393b9a user: andybradford tags: db-begin-txn-updates) | |
13:54 | Attempt to improve error messages resulting from SQL errors. ... (check-in: b94e15cff7 user: drh tags: trunk) | |
12:48 | Rewrote the "One vs. Many Check-outs per Repository" section in fossil-v-git.wiki to focus more on default modes of operation and their consequences in response to nit-picking on the Lobste.rs thread about this article pointing out that you can make Git work in the Fossil style. Defaults matter. ... (check-in: 10a57cece1 user: wyoung tags: trunk) | |
Changes
Changes to src/db.c.
︙ | ︙ | |||
86 87 88 89 90 91 92 93 94 95 96 97 98 99 | if( g.xferPanic && g.cgiOutput==1 ){ cgi_reset_content(); @ error Database\serror:\s%F(z) cgi_reply(); } fossil_fatal("Database error: %s", z); } /* ** All static variable that a used by only this file are gathered into ** the following structure. */ static struct DbLocalData { int nBegin; /* Nesting depth of BEGIN */ | > > > > > > > > > > > > | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | if( g.xferPanic && g.cgiOutput==1 ){ cgi_reset_content(); @ error Database\serror:\s%F(z) cgi_reply(); } fossil_fatal("Database error: %s", z); } /* ** Check a result code. If it is not SQLITE_OK, print the ** corresponding error message and exit. */ static void db_check_result(int rc, Stmt *pStmt){ if( rc!=SQLITE_OK ){ db_err("SQL error (%d,%d: %s) while running [%s]", rc, sqlite3_extended_errcode(g.db), sqlite3_errmsg(g.db), blob_str(&pStmt->sql)); } } /* ** All static variable that a used by only this file are gathered into ** the following structure. */ static struct DbLocalData { int nBegin; /* Nesting depth of BEGIN */ |
︙ | ︙ | |||
476 477 478 479 480 481 482 | /* ** Reset or finalize a statement. */ int db_reset(Stmt *pStmt){ int rc; db_stats(pStmt); rc = sqlite3_reset(pStmt->pStmt); | | | | 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | /* ** Reset or finalize a statement. */ int db_reset(Stmt *pStmt){ int rc; db_stats(pStmt); rc = sqlite3_reset(pStmt->pStmt); db_check_result(rc, pStmt); return rc; } int db_finalize(Stmt *pStmt){ int rc; if( pStmt->pNext ){ pStmt->pNext->pPrev = pStmt->pPrev; } if( pStmt->pPrev ){ pStmt->pPrev->pNext = pStmt->pNext; }else if( db.pAllStmt==pStmt ){ db.pAllStmt = pStmt->pNext; } pStmt->pNext = 0; pStmt->pPrev = 0; db_stats(pStmt); blob_reset(&pStmt->sql); rc = sqlite3_finalize(pStmt->pStmt); db_check_result(rc, pStmt); pStmt->pStmt = 0; return rc; } /* ** Return the rowid of the most recent insert */ |
︙ | ︙ | |||
574 575 576 577 578 579 580 | ** invalid when the statement is stepped or reset. */ void db_ephemeral_blob(Stmt *pStmt, int N, Blob *pBlob){ blob_init(pBlob, sqlite3_column_blob(pStmt->pStmt, N), sqlite3_column_bytes(pStmt->pStmt, N)); } | < < < < < < < < < < | > > > > > > > > > > > > > | 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 | ** invalid when the statement is stepped or reset. */ void db_ephemeral_blob(Stmt *pStmt, int N, Blob *pBlob){ blob_init(pBlob, sqlite3_column_blob(pStmt->pStmt, N), sqlite3_column_bytes(pStmt->pStmt, N)); } /* ** Execute a single prepared statement until it finishes. */ int db_exec(Stmt *pStmt){ int rc; while( (rc = db_step(pStmt))==SQLITE_ROW ){} rc = db_reset(pStmt); db_check_result(rc, pStmt); return rc; } /* ** COMMAND: test-db-exec-error ** ** Invoke the db_exec() interface with an erroneous SQL statement ** in order to verify the error handling logic. */ void db_test_db_exec_cmd(void){ Stmt err; db_find_and_open_repository(0,0); db_prepare(&err, "INSERT INTO repository.config(name) VALUES(NULL);"); db_exec(&err); } /* ** Print the output of one or more SQL queries on standard output. ** This routine is used for debugging purposes only. */ int db_debug(const char *zSql, ...){ Blob sql; |
︙ | ︙ |