From: drh Date: Sun, 22 Feb 2004 18:40:56 +0000 (+0000) Subject: Use sqliteErrorMsg instead of sqliteSetString whereever practical. (CVS 1264) X-Git-Tag: version-3.6.10~4804 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f7a9e1ac87ab64286d256279042347c64c53ea6d;p=thirdparty%2Fsqlite.git Use sqliteErrorMsg instead of sqliteSetString whereever practical. (CVS 1264) FossilOrigin-Name: 69aac043af7f93e7b3f036622c0ac9261cae1839 --- diff --git a/manifest b/manifest index 67df4a77ee..b616e024aa 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Code\scleanup\sin\sthe\sdate\sand\stime\sfunctions.\s(CVS\s1263) -D 2004-02-22T17:49:33 +C Use\ssqliteErrorMsg\sinstead\sof\ssqliteSetString\swhereever\spractical.\s(CVS\s1264) +D 2004-02-22T18:40:57 F Makefile.in cfd75c46b335881999333a9e4b982fa8491f200b F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd @@ -23,16 +23,16 @@ F sqlite.1 83f4a9d37bdf2b7ef079a82d54eaf2e3509ee6ea F sqlite.def a4d2ada1c3667fd1bc18a37bf2ff9dcf138e0d51 F sqlite.pc.in 30552343140c53304c2a658c080fbe810cd09ca2 F src/attach.c b01db0d3211f673d8e670abf7eaad04591d40d14 -F src/auth.c c59ad0dab501888f8b1fccc25e2f5965d2265116 +F src/auth.c 4fa3b05bd19445d1c474d6751c4a508d6ea0abe1 F src/btree.c 0a40efb01fa3a431a16d8604f603431d8c9cebfa F src/btree.h 41cb3ff6ebc3f6da2d0a074e39ff8c7a2287469f F src/btree_rb.c 32b2cb4285c0fbd53b89de021637b63d52257e54 -F src/build.c f6ef61a2b9524f5d1fd66a500747b6a5c114dd0f +F src/build.c 160e623334897d2cc362db34ed0f9bcb10e6fa6a F src/copy.c 391ce142f6b1faa093867ecee134f61a5028a9af F src/date.c 3025642cee50d5c41aef4a22cbc41aa7e543c922 F src/delete.c 8e2ff752bf485906effcc64f267cdd7227463567 F src/encode.c 9e70ea1e4e746f23f18180949e94f1bb1c2220d3 -F src/expr.c 7bb3a1ffbf3233b663f017d5296a718156f1f5fb +F src/expr.c 86eaf80e4d893ba184afc965a53a8dffda209ad4 F src/func.c a2265f29e6a286203c9dfeb835d9a50439617805 F src/hash.c 9b56ef3b291e25168f630d5643a4264ec011c70e F src/hash.h 3247573ab95b9dd90bcca0307a75d9a16da1ccc7 @@ -43,7 +43,7 @@ F src/os.c f5fc4954725b2fcd852979f2746085fe8ca27710 F src/os.h 250a3789be609adfee5c5aa20137ce8683276f24 F src/pager.c 29ddad4dd454f0aaa98e2bcd327710ab9f02f833 F src/pager.h 82332878799280145639a48d88cdb4058925e3f6 -F src/parse.y b990b5841eb7f32c051bce6c0330e575a5dc3e84 +F src/parse.y 023720cb8c3bef74e51738bca78335d0dc6d2cfd F src/pragma.c a8d43661193ba3114da787f43969d0a34f0ed07c F src/printf.c f201a5a316afc474d29d51e07501536e8998194d F src/random.c 775913e0b7fbd6295d21f12a7bd35b46387c44b2 @@ -66,7 +66,7 @@ F src/vdbe.c af187d86cb1bcc1ead227245350d1693c28c77a2 F src/vdbe.h b1b22ffca48f593d375fd846c583679d49c2e5c9 F src/vdbeInt.h b40ff02ce39fd076e6ff3369e19c1bbfe1986682 F src/vdbeaux.c 88ebe3aa963478f3cee9fb6e3d8ca9db1bafacb2 -F src/where.c 1302d728bd338c237e6a8282e4e3eadbbdf11e45 +F src/where.c 6ac293e94aa3e662ec74f6b48d2ef5e341a30cdd F test/all.test 569a92a8ee88f5300c057cc4a8f50fbbc69a3242 F test/attach.test ba8261d38da6b6a7d4f78ec543c548c4418582ef F test/attach2.test ce61e6185b3cd891cc0e9a4c868fcc65eb92fc55 @@ -189,7 +189,7 @@ F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604 F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4 -P d372c16ec6621dbab371bff7f1803ca096862984 -R 26dc1ce48ade981ea71375567947b9f1 +P 9b3bcde1530091602e551435ffd7820eb79727d5 +R d797e4457343833d61bf9ff409e94242 U drh -Z 69ec7e76ed86d8c90a49976c004def1a +Z 97d7595e018edb09b04d76c0b0766e57 diff --git a/manifest.uuid b/manifest.uuid index f74d9b4cf0..d3b35c6a06 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9b3bcde1530091602e551435ffd7820eb79727d5 \ No newline at end of file +69aac043af7f93e7b3f036622c0ac9261cae1839 \ No newline at end of file diff --git a/src/auth.c b/src/auth.c index 403f884b50..8f8077dd94 100644 --- a/src/auth.c +++ b/src/auth.c @@ -14,7 +14,7 @@ ** systems that do not need this facility may omit it by recompiling ** the library with -DSQLITE_OMIT_AUTHORIZATION=1 ** -** $Id: auth.c,v 1.11 2003/12/06 21:43:56 drh Exp $ +** $Id: auth.c,v 1.12 2004/02/22 18:40:57 drh Exp $ */ #include "sqliteInt.h" @@ -85,12 +85,9 @@ int sqlite_set_authorizer( ** user-supplied authorization function returned an illegal value. */ static void sqliteAuthBadReturnCode(Parse *pParse, int rc){ - char zBuf[20]; - sprintf(zBuf, "(%d)", rc); - sqliteSetString(&pParse->zErrMsg, "illegal return value ", zBuf, - " from the authorization function - should be SQLITE_OK, " - "SQLITE_IGNORE, or SQLITE_DENY", (char*)0); - pParse->nErr++; + sqliteErrorMsg(pParse, "illegal return value (%d) from the " + "authorization function - should be SQLITE_OK, SQLITE_IGNORE, " + "or SQLITE_DENY", rc); pParse->rc = SQLITE_MISUSE; } @@ -150,13 +147,11 @@ void sqliteAuthRead( pExpr->op = TK_NULL; }else if( rc==SQLITE_DENY ){ if( db->nDb>2 || pExpr->iDb!=0 ){ - sqliteSetString(&pParse->zErrMsg,"access to ", zDBase, ".", - pTab->zName, ".", zCol, " is prohibited", (char*)0); + sqliteErrorMsg(pParse, "access to %s.%s.%s is prohibited", + zDBase, pTab->zName, zCol); }else{ - sqliteSetString(&pParse->zErrMsg,"access to ", pTab->zName, ".", - zCol, " is prohibited", (char*)0); + sqliteErrorMsg(pParse, "access to %s.%s is prohibited", pTab->zName,zCol); } - pParse->nErr++; pParse->rc = SQLITE_AUTH; }else if( rc!=SQLITE_OK ){ sqliteAuthBadReturnCode(pParse, rc); @@ -184,9 +179,8 @@ int sqliteAuthCheck( } rc = db->xAuth(db->pAuthArg, code, zArg1, zArg2, zArg3, pParse->zAuthContext); if( rc==SQLITE_DENY ){ - sqliteSetString(&pParse->zErrMsg, "not authorized", (char*)0); + sqliteErrorMsg(pParse, "not authorized"); pParse->rc = SQLITE_AUTH; - pParse->nErr++; }else if( rc!=SQLITE_OK && rc!=SQLITE_IGNORE ){ rc = SQLITE_DENY; sqliteAuthBadReturnCode(pParse, rc); diff --git a/src/build.c b/src/build.c index bc49327ae5..21f7fa56de 100644 --- a/src/build.c +++ b/src/build.c @@ -23,7 +23,7 @@ ** ROLLBACK ** PRAGMA ** -** $Id: build.c,v 1.171 2004/02/21 13:31:10 drh Exp $ +** $Id: build.c,v 1.172 2004/02/22 18:40:57 drh Exp $ */ #include "sqliteInt.h" #include @@ -474,16 +474,16 @@ void sqliteStartTable( if( isTemp && db->aDb[1].pBt==0 && !pParse->explain ){ int rc = sqliteBtreeFactory(db, 0, 0, MAX_PAGES, &db->aDb[1].pBt); if( rc!=SQLITE_OK ){ - sqliteSetString(&pParse->zErrMsg, "unable to open a temporary database " - "file for storing temporary tables", (char*)0); + sqliteErrorMsg(pParse, "unable to open a temporary database " + "file for storing temporary tables"); pParse->nErr++; return; } if( db->flags & SQLITE_InTrans ){ rc = sqliteBtreeBeginTrans(db->aDb[1].pBt); if( rc!=SQLITE_OK ){ - sqliteSetNString(&pParse->zErrMsg, "unable to get a write lock on " - "the temporary database file", 0); + sqliteErrorMsg(pParse, "unable to get a write lock on " + "the temporary database file"); pParse->nErr++; return; } @@ -500,18 +500,14 @@ void sqliteStartTable( pTable = sqliteFindTable(db, zName, 0); iDb = isTemp ? 1 : db->init.iDb; if( pTable!=0 && (pTable->iDb==iDb || !db->init.busy) ){ - sqliteSetNString(&pParse->zErrMsg, "table ", 0, pName->z, pName->n, - " already exists", 0, 0); + sqliteErrorMsg(pParse, "table %T already exists", pName); sqliteFree(zName); - pParse->nErr++; return; } if( (pIdx = sqliteFindIndex(db, zName, 0))!=0 && (pIdx->iDb==0 || !db->init.busy) ){ - sqliteSetString(&pParse->zErrMsg, "there is already an index named ", - zName, (char*)0); + sqliteErrorMsg(pParse, "there is already an index named %s", zName); sqliteFree(zName); - pParse->nErr++; return; } pTable = sqliteMalloc( sizeof(Table) ); @@ -569,8 +565,7 @@ void sqliteAddColumn(Parse *pParse, Token *pName){ sqliteDequote(z); for(i=0; inCol; i++){ if( sqliteStrICmp(z, p->aCol[i].zName)==0 ){ - sqliteSetString(&pParse->zErrMsg, "duplicate column name: ", z, (char*)0); - pParse->nErr++; + sqliteErrorMsg(pParse, "duplicate column name: %s", z); sqliteFree(z); return; } @@ -689,9 +684,8 @@ void sqliteAddPrimaryKey(Parse *pParse, IdList *pList, int onError){ int iCol = -1, i; if( pTab==0 ) goto primary_key_exit; if( pTab->hasPrimKey ){ - sqliteSetString(&pParse->zErrMsg, "table \"", pTab->zName, - "\" has more than one primary key", (char*)0); - pParse->nErr++; + sqliteErrorMsg(pParse, + "table \"%s\" has more than one primary key", pTab->zName); goto primary_key_exit; } pTab->hasPrimKey = 1; @@ -1107,9 +1101,7 @@ int sqliteViewGetColumnNames(Parse *pParse, Table *pTable){ ** should always fail. But we will leave it in place just to be safe. */ if( pTable->nCol<0 ){ - sqliteSetString(&pParse->zErrMsg, "view ", pTable->zName, - " is circularly defined", (char*)0); - pParse->nErr++; + sqliteErrorMsg(pParse, "view %s is circularly defined", pTable->zName); return 1; } @@ -1198,9 +1190,7 @@ Table *sqliteTableFromToken(Parse *pParse, Token *pTok){ pTab = sqliteFindTable(pParse->db, zName, 0); sqliteFree(zName); if( pTab==0 ){ - sqliteSetNString(&pParse->zErrMsg, "no such table: ", 0, - pTok->z, pTok->n, 0); - pParse->nErr++; + sqliteErrorMsg(pParse, "no such table: %T", pTok); } return pTab; } @@ -1251,21 +1241,16 @@ void sqliteDropTable(Parse *pParse, Token *pName, int isView){ } #endif if( pTable->readOnly ){ - sqliteSetString(&pParse->zErrMsg, "table ", pTable->zName, - " may not be dropped", (char*)0); + sqliteErrorMsg(pParse, "table %s may not be dropped", pTable->zName); pParse->nErr++; return; } if( isView && pTable->pSelect==0 ){ - sqliteSetString(&pParse->zErrMsg, "use DROP TABLE to delete table ", - pTable->zName, (char*)0); - pParse->nErr++; + sqliteErrorMsg(pParse, "use DROP TABLE to delete table %s", pTable->zName); return; } if( !isView && pTable->pSelect ){ - sqliteSetString(&pParse->zErrMsg, "use DROP VIEW to delete view ", - pTable->zName, (char*)0); - pParse->nErr++; + sqliteErrorMsg(pParse, "use DROP VIEW to delete view %s", pTable->zName); return; } @@ -1408,19 +1393,16 @@ void sqliteCreateForeignKey( int iCol = p->nCol-1; if( iCol<0 ) goto fk_end; if( pToCol && pToCol->nId!=1 ){ - sqliteSetNString(&pParse->zErrMsg, "foreign key on ", -1, - p->aCol[iCol].zName, -1, - " should reference only one column of table ", -1, - pTo->z, pTo->n, 0); - pParse->nErr++; + sqliteErrorMsg(pParse, "foreign key on %s" + " should reference only one column of table %T", + p->aCol[iCol].zName, pTo); goto fk_end; } nCol = 1; }else if( pToCol && pToCol->nId!=pFromCol->nId ){ - sqliteSetString(&pParse->zErrMsg, + sqliteErrorMsg(pParse, "number of columns in foreign key does not match the number of " - "columns in the referenced table", (char*)0); - pParse->nErr++; + "columns in the referenced table"); goto fk_end; }else{ nCol = pFromCol->nId; @@ -1456,9 +1438,9 @@ void sqliteCreateForeignKey( } } if( j>=p->nCol ){ - sqliteSetString(&pParse->zErrMsg, "unknown column \"", - pFromCol->a[i].zName, "\" in foreign key definition", (char*)0); - pParse->nErr++; + sqliteErrorMsg(pParse, + "unknown column \"%s\" in foreign key definition", + pFromCol->a[i].zName); goto fk_end; } } @@ -1553,20 +1535,15 @@ void sqliteCreateIndex( } if( pTab==0 || pParse->nErr ) goto exit_create_index; if( pTab->readOnly ){ - sqliteSetString(&pParse->zErrMsg, "table ", pTab->zName, - " may not be indexed", (char*)0); - pParse->nErr++; + sqliteErrorMsg(pParse, "table %s may not be indexed", pTab->zName); goto exit_create_index; } if( pTab->iDb>=2 && db->init.busy==0 ){ - sqliteSetString(&pParse->zErrMsg, "table ", pTab->zName, - " may not have indices added", (char*)0); - pParse->nErr++; + sqliteErrorMsg(pParse, "table %s may not have indices added", pTab->zName); goto exit_create_index; } if( pTab->pSelect ){ - sqliteSetString(&pParse->zErrMsg, "views may not be indexed", (char*)0); - pParse->nErr++; + sqliteErrorMsg(pParse, "views may not be indexed"); goto exit_create_index; } isTemp = pTab->iDb==1; @@ -1590,15 +1567,11 @@ void sqliteCreateIndex( zName = sqliteStrNDup(pName->z, pName->n); if( zName==0 ) goto exit_create_index; if( (pISameName = sqliteFindIndex(db, zName, 0))!=0 ){ - sqliteSetString(&pParse->zErrMsg, "index ", zName, - " already exists", (char*)0); - pParse->nErr++; + sqliteErrorMsg(pParse, "index %s already exists", zName); goto exit_create_index; } if( (pTSameName = sqliteFindTable(db, zName, 0))!=0 ){ - sqliteSetString(&pParse->zErrMsg, "there is already a table named ", - zName, (char*)0); - pParse->nErr++; + sqliteErrorMsg(pParse, "there is already a table named %s", zName); goto exit_create_index; } }else if( pName==0 ){ @@ -1667,9 +1640,8 @@ void sqliteCreateIndex( if( sqliteStrICmp(pList->a[i].zName, pTab->aCol[j].zName)==0 ) break; } if( j>=pTab->nCol ){ - sqliteSetString(&pParse->zErrMsg, "table ", pTab->zName, - " has no column named ", pList->a[i].zName, (char*)0); - pParse->nErr++; + sqliteErrorMsg(pParse, "table %s has no column named %s", + pTab->zName, pList->a[i].zName); sqliteFree(pIndex); goto exit_create_index; } diff --git a/src/expr.c b/src/expr.c index 8071a0e75c..3daa2b20c3 100644 --- a/src/expr.c +++ b/src/expr.c @@ -12,7 +12,7 @@ ** This file contains routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** -** $Id: expr.c,v 1.109 2004/02/21 19:17:18 drh Exp $ +** $Id: expr.c,v 1.110 2004/02/22 18:40:57 drh Exp $ */ #include "sqliteInt.h" #include @@ -847,23 +847,21 @@ int sqliteExprCheck(Parse *pParse, Expr *pExpr, int allowAgg, int *pIsAgg){ is_agg = pDef->xFunc==0; } if( is_agg && !allowAgg ){ - sqliteSetNString(&pParse->zErrMsg, "misuse of aggregate function ", -1, - zId, nId, "()", 2, 0); - pParse->nErr++; + sqliteErrorMsg(pParse, "misuse of aggregate function %.*s()", nId, zId); nErr++; is_agg = 0; }else if( no_such_func ){ - sqliteSetNString(&pParse->zErrMsg, "no such function: ", -1, zId,nId,0); - pParse->nErr++; + sqliteErrorMsg(pParse, "no such function: %.*s", nId, zId); nErr++; }else if( wrong_num_args ){ - sqliteSetNString(&pParse->zErrMsg, - "wrong number of arguments to function ", -1, zId, nId, "()", 2, 0); - pParse->nErr++; + sqliteErrorMsg(pParse,"wrong number of arguments to function %.*s()", + nId, zId); nErr++; } - if( is_agg ) pExpr->op = TK_AGG_FUNCTION; - if( is_agg && pIsAgg ) *pIsAgg = 1; + if( is_agg ){ + pExpr->op = TK_AGG_FUNCTION; + if( pIsAgg ) *pIsAgg = 1; + } for(i=0; nErr==0 && ipList->a[i].pExpr, allowAgg && !is_agg, pIsAgg); diff --git a/src/parse.y b/src/parse.y index 1b73a7e616..256f9661dc 100644 --- a/src/parse.y +++ b/src/parse.y @@ -14,7 +14,7 @@ ** the parser. Lemon will also generate a header file containing ** numeric codes for all of the tokens. ** -** @(#) $Id: parse.y,v 1.111 2004/02/22 16:27:00 drh Exp $ +** @(#) $Id: parse.y,v 1.112 2004/02/22 18:40:57 drh Exp $ */ %token_prefix TK_ %token_type {Token} @@ -23,13 +23,11 @@ %syntax_error { if( pParse->zErrMsg==0 ){ if( TOKEN.z[0] ){ - sqliteSetNString(&pParse->zErrMsg, - "near \"", -1, TOKEN.z, TOKEN.n, "\": syntax error", -1, 0); + sqliteErrorMsg(pParse, "near \"%T\": syntax error", &TOKEN); }else{ - sqliteSetString(&pParse->zErrMsg, "incomplete SQL statement", (char*)0); + sqliteErrorMsg(pParse, "incomplete SQL statement"); } } - pParse->nErr++; } %name sqliteParser %include { diff --git a/src/where.c b/src/where.c index 1cfaf63d2b..5df3c07042 100644 --- a/src/where.c +++ b/src/where.c @@ -12,7 +12,7 @@ ** This module contains C code that generates VDBE code used to process ** the WHERE clause of SQL statements. ** -** $Id: where.c,v 1.87 2004/01/14 21:59:24 drh Exp $ +** $Id: where.c,v 1.88 2004/02/22 18:40:57 drh Exp $ */ #include "sqliteInt.h" @@ -380,11 +380,8 @@ WhereInfo *sqliteWhereBegin( memset(aExpr, 0, sizeof(aExpr)); nExpr = exprSplit(ARRAYSIZE(aExpr), aExpr, pWhere); if( nExpr==ARRAYSIZE(aExpr) ){ - char zBuf[50]; - sprintf(zBuf, "%d", (int)ARRAYSIZE(aExpr)-1); - sqliteSetString(&pParse->zErrMsg, "WHERE clause too complex - no more " - "than ", zBuf, " terms allowed", (char*)0); - pParse->nErr++; + sqliteErrorMsg(pParse, "WHERE clause too complex - no more " + "than %d terms allowed", (int)ARRAYSIZE(aExpr)-1); return 0; }