Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Merge updates from trunk. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | expShell |
Files: | files | file ages | folders |
SHA1: |
c7167f88ec261eb0dbcea29817c7677e |
User & Date: | mistachkin 2015-01-19 07:42:14.456 |
Context
2015-01-19
| ||
20:19 | Merge updates from trunk. (check-in: d9f4035b38 user: mistachkin tags: expShell) | |
07:42 | Merge updates from trunk. (check-in: c7167f88ec user: mistachkin tags: expShell) | |
00:35 | Eliminate all use of sprintf(), strcpy() and strcat() from test logic because OpenBSD hates those functions. (check-in: 1032191099 user: drh tags: trunk) | |
2015-01-18
| ||
09:02 | Modify the new shell test case to work on non-Windows platforms as well. (check-in: f362c5d9d1 user: mistachkin tags: expShell) | |
Changes
Changes to ext/misc/amatch.c.
︙ | ︙ | |||
993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 | ** Write the zCost[] field for a amatch_word object */ static void amatchWriteCost(amatch_word *pWord){ amatchEncodeInt(pWord->rCost, pWord->zCost); amatchEncodeInt(pWord->iSeq, pWord->zCost+4); pWord->zCost[8] = 0; } /* ** Add a new amatch_word object to the queue. ** ** If a prior amatch_word object with the same zWord, and nMatch ** already exists, update its rCost (if the new rCost is less) but ** otherwise leave it unchanged. Do not add a duplicate. | > > > > > > > > > > > > > > > > > | 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 | ** Write the zCost[] field for a amatch_word object */ static void amatchWriteCost(amatch_word *pWord){ amatchEncodeInt(pWord->rCost, pWord->zCost); amatchEncodeInt(pWord->iSeq, pWord->zCost+4); pWord->zCost[8] = 0; } /* Circumvent compiler warnings about the use of strcpy() by supplying ** our own implementation. */ #if defined(__OpenBSD__) static void amatchStrcpy(char *dest, const char *src){ while( (*(dest++) = *(src++))!=0 ){} } static void amatchStrcat(char *dest, const char *src){ while( *dest ) dest++; amatchStrcpy(dest, src); } #else # define amatchStrcpy strcpy # define amatchStrcat strcat #endif /* ** Add a new amatch_word object to the queue. ** ** If a prior amatch_word object with the same zWord, and nMatch ** already exists, update its rCost (if the new rCost is less) but ** otherwise leave it unchanged. Do not add a duplicate. |
︙ | ︙ | |||
1069 1070 1071 1072 1073 1074 1075 | pCur->pAllWords = pWord; pWord->sCost.zKey = pWord->zCost; pWord->sCost.pWord = pWord; pOther = amatchAvlInsert(&pCur->pCost, &pWord->sCost); assert( pOther==0 ); (void)pOther; pWord->sWord.zKey = pWord->zWord; pWord->sWord.pWord = pWord; | | > | 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 | pCur->pAllWords = pWord; pWord->sCost.zKey = pWord->zCost; pWord->sCost.pWord = pWord; pOther = amatchAvlInsert(&pCur->pCost, &pWord->sCost); assert( pOther==0 ); (void)pOther; pWord->sWord.zKey = pWord->zWord; pWord->sWord.pWord = pWord; amatchStrcpy(pWord->zWord, pCur->zBuf); pOther = amatchAvlInsert(&pCur->pWord, &pWord->sWord); assert( pOther==0 ); (void)pOther; #ifdef AMATCH_TRACE_1 printf("INSERT [%s][%.*s^%s] %d (\"%s\" \"%s\")\n", pWord->zWord+2, pWord->nMatch, pCur->zInput, pCur->zInput+pWord->nMatch, rCost, pWord->zWord, pWord->zCost); #endif } /* ** Advance a cursor to its next row of output */ static int amatchNext(sqlite3_vtab_cursor *cur){ amatch_cursor *pCur = (amatch_cursor*)cur; amatch_word *pWord = 0; |
︙ | ︙ | |||
1144 1145 1146 1147 1148 1149 1150 | #endif nWord = (int)strlen(pWord->zWord+2); if( nWord+20>nBuf ){ nBuf = nWord+100; zBuf = sqlite3_realloc(zBuf, nBuf); if( zBuf==0 ) return SQLITE_NOMEM; } | | | | | | 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 | #endif nWord = (int)strlen(pWord->zWord+2); if( nWord+20>nBuf ){ nBuf = nWord+100; zBuf = sqlite3_realloc(zBuf, nBuf); if( zBuf==0 ) return SQLITE_NOMEM; } amatchStrcpy(zBuf, pWord->zWord+2); zNext[0] = 0; zNextIn[0] = pCur->zInput[pWord->nMatch]; if( zNextIn[0] ){ for(i=1; i<=4 && (pCur->zInput[pWord->nMatch+i]&0xc0)==0x80; i++){ zNextIn[i] = pCur->zInput[pWord->nMatch+i]; } zNextIn[i] = 0; nNextIn = i; }else{ nNextIn = 0; } if( zNextIn[0] && zNextIn[0]!='*' ){ sqlite3_reset(p->pVCheck); amatchStrcat(zBuf, zNextIn); sqlite3_bind_text(p->pVCheck, 1, zBuf, nWord+nNextIn, SQLITE_STATIC); rc = sqlite3_step(p->pVCheck); if( rc==SQLITE_ROW ){ zW = (const char*)sqlite3_column_text(p->pVCheck, 0); if( strncmp(zBuf, zW, nWord+nNextIn)==0 ){ amatchAddWord(pCur, pWord->rCost, pWord->nMatch+nNextIn, zBuf, ""); } } zBuf[nWord] = 0; } while( 1 ){ amatchStrcpy(zBuf+nWord, zNext); sqlite3_reset(p->pVCheck); sqlite3_bind_text(p->pVCheck, 1, zBuf, -1, SQLITE_TRANSIENT); rc = sqlite3_step(p->pVCheck); if( rc!=SQLITE_ROW ) break; zW = (const char*)sqlite3_column_text(p->pVCheck, 0); amatchStrcpy(zBuf+nWord, zNext); if( strncmp(zW, zBuf, nWord)!=0 ) break; if( (zNextIn[0]=='*' && zNextIn[1]==0) || (zNextIn[0]==0 && zW[nWord]==0) ){ isMatch = 1; zNextIn[0] = 0; nNextIn = 0; |
︙ | ︙ |
Changes to src/shell.c.
︙ | ︙ | |||
102 103 104 105 106 107 108 109 110 111 112 113 114 115 | #endif /* ctype macros that work with signed characters */ #define IsSpace(X) isspace((unsigned char)X) #define IsDigit(X) isdigit((unsigned char)X) #define ToLower(X) (char)tolower((unsigned char)X) /* True if the timer is enabled */ static int enableTimer = 0; /* Return the current wall-clock time */ static sqlite3_int64 timeOfDay(void){ static sqlite3_vfs *clockVfs = 0; | > > > > > > > > > > > > > > > > > > > > | 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | #endif /* ctype macros that work with signed characters */ #define IsSpace(X) isspace((unsigned char)X) #define IsDigit(X) isdigit((unsigned char)X) #define ToLower(X) (char)tolower((unsigned char)X) /* On Windows, we normally run with output mode of TEXT so that \n characters ** are automatically translated into \r\n. However, this behavior needs ** to be disabled in some cases (ex: when generating CSV output and when ** rendering quoted strings that contain \n characters). The following ** routines take care of that. */ #if defined(_WIN32) || defined(WIN32) static setBinaryMode(FILE *out){ fflush(out); _setmode(_fileno(out), _O_BINARY); } static setTextMode(FILE *out){ fflush(out); _setmode(_fileno(out), _O_TEXT); } #else # define setBinaryMode(X) # define setTextMode(X) #endif /* True if the timer is enabled */ static int enableTimer = 0; /* Return the current wall-clock time */ static sqlite3_int64 timeOfDay(void){ static sqlite3_vfs *clockVfs = 0; |
︙ | ︙ | |||
580 581 582 583 584 585 586 587 588 589 590 591 592 593 | /* ** Output the given string as a quoted string using SQL quoting conventions. */ static void output_quoted_string(FILE *out, const char *z){ int i; int nSingle = 0; for(i=0; z[i]; i++){ if( z[i]=='\'' ) nSingle++; } if( nSingle==0 ){ fprintf(out,"'%s'",z); }else{ fprintf(out,"'"); | > | 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 | /* ** Output the given string as a quoted string using SQL quoting conventions. */ static void output_quoted_string(FILE *out, const char *z){ int i; int nSingle = 0; setBinaryMode(out); for(i=0; z[i]; i++){ if( z[i]=='\'' ) nSingle++; } if( nSingle==0 ){ fprintf(out,"'%s'",z); }else{ fprintf(out,"'"); |
︙ | ︙ | |||
602 603 604 605 606 607 608 609 610 611 612 613 614 615 | }else{ fprintf(out,"%s",z); break; } } fprintf(out,"'"); } } /* ** Output the given string as a quoted according to C or TCL quoting rules. */ static void output_c_string(FILE *out, const char *z){ unsigned int c; | > | 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 | }else{ fprintf(out,"%s",z); break; } } fprintf(out,"'"); } setTextMode(out); } /* ** Output the given string as a quoted according to C or TCL quoting rules. */ static void output_c_string(FILE *out, const char *z){ unsigned int c; |
︙ | ︙ | |||
920 921 922 923 924 925 926 | output_c_string(p->out, azArg[i] ? azArg[i] : p->nullValue); if(i<nArg-1) fprintf(p->out, "%s", p->colSeparator); } fprintf(p->out, "%s", p->rowSeparator); break; } case MODE_Csv: { | | | | 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 | output_c_string(p->out, azArg[i] ? azArg[i] : p->nullValue); if(i<nArg-1) fprintf(p->out, "%s", p->colSeparator); } fprintf(p->out, "%s", p->rowSeparator); break; } case MODE_Csv: { setBinaryMode(p->out); if( p->cnt++==0 && p->showHeader ){ for(i=0; i<nArg; i++){ output_csv(p, azCol[i] ? azCol[i] : "", i<nArg-1); } fprintf(p->out, "%s", p->rowSeparator); } if( nArg>0 ){ for(i=0; i<nArg; i++){ output_csv(p, azArg[i], i<nArg-1); } fprintf(p->out, "%s", p->rowSeparator); } setTextMode(p->out); break; } case MODE_Insert: { p->cnt++; if( azArg==0 ) break; fprintf(p->out,"INSERT INTO %s VALUES(",p->zDestTable); for(i=0; i<nArg; i++){ |
︙ | ︙ | |||
4210 4211 4212 4213 4214 4215 4216 | #if USE_SYSTEM_SQLITE+0!=1 if( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)!=0 ){ fprintf(stderr, "SQLite header and source version mismatch\n%s\n%s\n", sqlite3_sourceid(), SQLITE_SOURCE_ID); exit(1); } #endif | < | < | 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 | #if USE_SYSTEM_SQLITE+0!=1 if( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)!=0 ){ fprintf(stderr, "SQLite header and source version mismatch\n%s\n%s\n", sqlite3_sourceid(), SQLITE_SOURCE_ID); exit(1); } #endif setBinaryMode(stdin); Argv0 = argv[0]; main_init(&data); stdin_is_interactive = isatty(0); /* Make sure we have a valid signal handler early, before anything ** else is done. */ |
︙ | ︙ |
Changes to src/tclsqlite.c.
︙ | ︙ | |||
657 658 659 660 661 662 663 | return ret; } #if defined(SQLITE_TEST) && defined(SQLITE_ENABLE_UNLOCK_NOTIFY) static void setTestUnlockNotifyVars(Tcl_Interp *interp, int iArg, int nArg){ char zBuf[64]; | | | | 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 | return ret; } #if defined(SQLITE_TEST) && defined(SQLITE_ENABLE_UNLOCK_NOTIFY) static void setTestUnlockNotifyVars(Tcl_Interp *interp, int iArg, int nArg){ char zBuf[64]; sqlite3_snprintf(sizeof(zBuf), zBuf, "%d", iArg); Tcl_SetVar(interp, "sqlite_unlock_notify_arg", zBuf, TCL_GLOBAL_ONLY); sqlite3_snprintf(sizeof(zBuf), zBuf, "%d", nArg); Tcl_SetVar(interp, "sqlite_unlock_notify_argcount", zBuf, TCL_GLOBAL_ONLY); } #else # define setTestUnlockNotifyVars(x,y,z) #endif #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY |
︙ | ︙ | |||
3425 3426 3427 3428 3429 3430 3431 | */ static void MD5DigestToBase10x8(unsigned char digest[16], char zDigest[50]){ int i, j; unsigned int x; for(i=j=0; i<16; i+=2){ x = digest[i]*256 + digest[i+1]; if( i>0 ) zDigest[j++] = '-'; | | | 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 | */ static void MD5DigestToBase10x8(unsigned char digest[16], char zDigest[50]){ int i, j; unsigned int x; for(i=j=0; i<16; i+=2){ x = digest[i]*256 + digest[i+1]; if( i>0 ) zDigest[j++] = '-'; sqlite3_snprintf(16-j, &zDigest[j], "%05u", x); j += 5; } zDigest[j] = 0; } /* ** A TCL command for md5. The argument is the text to be hashed. The |
︙ | ︙ |
Changes to src/test1.c.
︙ | ︙ | |||
90 91 92 93 94 95 96 | } if( !Tcl_GetCommandInfo(interp, Tcl_GetString(objv[1]), &cmdInfo) ){ Tcl_AppendResult(interp, "command not found: ", Tcl_GetString(objv[1]), (char*)0); return TCL_ERROR; } p = (struct SqliteDb*)cmdInfo.objClientData; | | < < < | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | } if( !Tcl_GetCommandInfo(interp, Tcl_GetString(objv[1]), &cmdInfo) ){ Tcl_AppendResult(interp, "command not found: ", Tcl_GetString(objv[1]), (char*)0); return TCL_ERROR; } p = (struct SqliteDb*)cmdInfo.objClientData; sqlite3_snprintf(sizeof(zBuf), zBuf, "%p", p->db); Tcl_AppendResult(interp, zBuf, 0); return TCL_OK; } /* ** Decode a pointer to an sqlite3 object. */ |
︙ | ︙ | |||
141 142 143 144 145 146 147 | ** from sqlite3_errcode. */ int sqlite3TestErrCode(Tcl_Interp *interp, sqlite3 *db, int rc){ if( sqlite3_threadsafe()==0 && rc!=SQLITE_MISUSE && rc!=SQLITE_OK && sqlite3_errcode(db)!=rc ){ char zBuf[200]; int r2 = sqlite3_errcode(db); | > | | 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | ** from sqlite3_errcode. */ int sqlite3TestErrCode(Tcl_Interp *interp, sqlite3 *db, int rc){ if( sqlite3_threadsafe()==0 && rc!=SQLITE_MISUSE && rc!=SQLITE_OK && sqlite3_errcode(db)!=rc ){ char zBuf[200]; int r2 = sqlite3_errcode(db); sqlite3_snprintf(sizeof(zBuf), zBuf, "error code %s (%d) does not match sqlite3_errcode %s (%d)", t1ErrorName(rc), rc, t1ErrorName(r2), r2); Tcl_ResetResult(interp); Tcl_AppendResult(interp, zBuf, 0); return 1; } return 0; } |
︙ | ︙ | |||
306 307 308 309 310 311 312 | return TCL_ERROR; } if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; Tcl_DStringInit(&str); zSql = sqlite3_mprintf(argv[2], argv[3]); rc = sqlite3_exec(db, zSql, exec_printf_cb, &str, &zErr); sqlite3_free(zSql); | | | 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | return TCL_ERROR; } if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; Tcl_DStringInit(&str); zSql = sqlite3_mprintf(argv[2], argv[3]); rc = sqlite3_exec(db, zSql, exec_printf_cb, &str, &zErr); sqlite3_free(zSql); sqlite3_snprintf(sizeof(zBuf), zBuf, "%d", rc); Tcl_AppendElement(interp, zBuf); Tcl_AppendElement(interp, rc==SQLITE_OK ? Tcl_DStringValue(&str) : zErr); Tcl_DStringFree(&str); if( zErr ) sqlite3_free(zErr); if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; return TCL_OK; } |
︙ | ︙ | |||
353 354 355 356 357 358 359 | }else{ zSql[i] = zHex[j]; } } zSql[i] = 0; Tcl_DStringInit(&str); rc = sqlite3_exec(db, zSql, exec_printf_cb, &str, &zErr); | | | 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | }else{ zSql[i] = zHex[j]; } } zSql[i] = 0; Tcl_DStringInit(&str); rc = sqlite3_exec(db, zSql, exec_printf_cb, &str, &zErr); sqlite3_snprintf(sizeof(zBuf), zBuf, "%d", rc); Tcl_AppendElement(interp, zBuf); Tcl_AppendElement(interp, rc==SQLITE_OK ? Tcl_DStringValue(&str) : zErr); Tcl_DStringFree(&str); if( zErr ) sqlite3_free(zErr); if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; return TCL_OK; } |
︙ | ︙ | |||
438 439 440 441 442 443 444 | }else{ zSql[j++] = zSql[i++]; } } zSql[j] = 0; rc = sqlite3_exec(db, zSql, exec_printf_cb, &str, &zErr); sqlite3_free(zSql); | | | 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 | }else{ zSql[j++] = zSql[i++]; } } zSql[j] = 0; rc = sqlite3_exec(db, zSql, exec_printf_cb, &str, &zErr); sqlite3_free(zSql); sqlite3_snprintf(sizeof(zBuf), zBuf, "%d", rc); Tcl_AppendElement(interp, zBuf); Tcl_AppendElement(interp, rc==SQLITE_OK ? Tcl_DStringValue(&str) : zErr); Tcl_DStringFree(&str); if( zErr ) sqlite3_free(zErr); if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; return TCL_OK; } |
︙ | ︙ | |||
587 588 589 590 591 592 593 | if( argc==5 ){ rc = sqlite3_get_table(db, zSql, &aResult, 0, 0, &zErr); }else{ rc = sqlite3_get_table(db, zSql, &aResult, &nRow, &nCol, &zErr); resCount = (nRow+1)*nCol; } sqlite3_free(zSql); | | | | | 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 | if( argc==5 ){ rc = sqlite3_get_table(db, zSql, &aResult, 0, 0, &zErr); }else{ rc = sqlite3_get_table(db, zSql, &aResult, &nRow, &nCol, &zErr); resCount = (nRow+1)*nCol; } sqlite3_free(zSql); sqlite3_snprintf(sizeof(zBuf), zBuf, "%d", rc); Tcl_AppendElement(interp, zBuf); if( rc==SQLITE_OK ){ if( argc==4 ){ sqlite3_snprintf(sizeof(zBuf), zBuf, "%d", nRow); Tcl_AppendElement(interp, zBuf); sqlite3_snprintf(sizeof(zBuf), zBuf, "%d", nCol); Tcl_AppendElement(interp, zBuf); } for(i=0; i<resCount; i++){ Tcl_AppendElement(interp, aResult[i] ? aResult[i] : "NULL"); } }else{ Tcl_AppendElement(interp, zErr); |
︙ | ︙ | |||
630 631 632 633 634 635 636 | char zBuf[30]; if( argc!=2 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " DB\"", 0); return TCL_ERROR; } if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; | | | 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 | char zBuf[30]; if( argc!=2 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " DB\"", 0); return TCL_ERROR; } if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", sqlite3_last_insert_rowid(db)); Tcl_AppendResult(interp, zBuf, 0); return SQLITE_OK; } /* ** Usage: sqlite3_key DB KEY ** |
︙ | ︙ | |||
770 771 772 773 774 775 776 | */ static void hex8Func(sqlite3_context *p, int argc, sqlite3_value **argv){ const unsigned char *z; int i; char zBuf[200]; z = sqlite3_value_text(argv[0]); for(i=0; i<sizeof(zBuf)/2 - 2 && z[i]; i++){ | | | | 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 | */ static void hex8Func(sqlite3_context *p, int argc, sqlite3_value **argv){ const unsigned char *z; int i; char zBuf[200]; z = sqlite3_value_text(argv[0]); for(i=0; i<sizeof(zBuf)/2 - 2 && z[i]; i++){ sqlite3_snprintf(sizeof(zBuf)-i*2, &zBuf[i*2], "%02x", z[i]); } zBuf[i*2] = 0; sqlite3_result_text(p, (char*)zBuf, -1, SQLITE_TRANSIENT); } #ifndef SQLITE_OMIT_UTF16 static void hex16Func(sqlite3_context *p, int argc, sqlite3_value **argv){ const unsigned short int *z; int i; char zBuf[400]; z = sqlite3_value_text16(argv[0]); for(i=0; i<sizeof(zBuf)/4 - 4 && z[i]; i++){ sqlite3_snprintf(sizeof(zBuf)-i*4, &zBuf[i*4],"%04x", z[i]&0xff); } zBuf[i*4] = 0; sqlite3_result_text(p, (char*)zBuf, -1, SQLITE_TRANSIENT); } #endif /* |
︙ | ︙ | |||
2493 2494 2495 2496 2497 2498 2499 | Tcl_AppendResult(interp, "4th argument should be " "\"null\" or \"static\" or \"normal\"", 0); return TCL_ERROR; } if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR; if( rc ){ char zBuf[50]; | | | 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 | Tcl_AppendResult(interp, "4th argument should be " "\"null\" or \"static\" or \"normal\"", 0); return TCL_ERROR; } if( sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ) return TCL_ERROR; if( rc ){ char zBuf[50]; sqlite3_snprintf(sizeof(zBuf), zBuf, "(%d) ", rc); Tcl_AppendResult(interp, zBuf, sqlite3ErrStr(rc), 0); return TCL_ERROR; } return TCL_OK; } #ifndef SQLITE_OMIT_UTF16 |
︙ | ︙ | |||
3607 3608 3609 3610 3611 3612 3613 | if( (int)strlen(zTail)<bytes ){ bytes = (int)strlen(zTail); } Tcl_ObjSetVar2(interp, objv[4], 0, Tcl_NewStringObj(zTail, bytes), 0); } if( rc!=SQLITE_OK ){ assert( pStmt==0 ); | | | 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 | if( (int)strlen(zTail)<bytes ){ bytes = (int)strlen(zTail); } Tcl_ObjSetVar2(interp, objv[4], 0, Tcl_NewStringObj(zTail, bytes), 0); } if( rc!=SQLITE_OK ){ assert( pStmt==0 ); sqlite3_snprintf(sizeof(zBuf), zBuf, "(%d) ", rc); Tcl_AppendResult(interp, zBuf, sqlite3_errmsg(db), 0); return TCL_ERROR; } if( pStmt ){ if( sqlite3TestMakePointerStr(interp, zBuf, pStmt) ) return TCL_ERROR; Tcl_AppendResult(interp, zBuf, 0); |
︙ | ︙ | |||
3677 3678 3679 3680 3681 3682 3683 | if( bytes>=0 ){ bytes = bytes - (int)(zTail-zSql); } Tcl_ObjSetVar2(interp, objv[4], 0, Tcl_NewStringObj(zTail, bytes), 0); } if( rc!=SQLITE_OK ){ assert( pStmt==0 ); | | | 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 | if( bytes>=0 ){ bytes = bytes - (int)(zTail-zSql); } Tcl_ObjSetVar2(interp, objv[4], 0, Tcl_NewStringObj(zTail, bytes), 0); } if( rc!=SQLITE_OK ){ assert( pStmt==0 ); sqlite3_snprintf(sizeof(zBuf), zBuf, "(%d) ", rc); Tcl_AppendResult(interp, zBuf, sqlite3_errmsg(db), 0); return TCL_ERROR; } if( pStmt ){ if( sqlite3TestMakePointerStr(interp, zBuf, pStmt) ) return TCL_ERROR; Tcl_AppendResult(interp, zBuf, 0); |
︙ | ︙ | |||
3718 3719 3720 3721 3722 3723 3724 | } if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; rc = sqlite3_prepare_v2(db, &zSql[1], 0, &pStmt, 0); assert(rc==SQLITE_OK || pStmt==0); if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; if( rc!=SQLITE_OK ){ assert( pStmt==0 ); | | | 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 | } if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; rc = sqlite3_prepare_v2(db, &zSql[1], 0, &pStmt, 0); assert(rc==SQLITE_OK || pStmt==0); if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; if( rc!=SQLITE_OK ){ assert( pStmt==0 ); sqlite3_snprintf(sizeof(zBuf), zBuf, "(%d) ", rc); Tcl_AppendResult(interp, zBuf, sqlite3_errmsg(db), 0); return TCL_ERROR; } if( pStmt ){ if( sqlite3TestMakePointerStr(interp, zBuf, pStmt) ) return TCL_ERROR; Tcl_AppendResult(interp, zBuf, 0); |
︙ | ︙ | |||
4533 4534 4535 4536 4537 4538 4539 | sqlite3 *db; if( argc!=2 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " DB", 0); return TCL_ERROR; } if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; | | | 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 | sqlite3 *db; if( argc!=2 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], " DB", 0); return TCL_ERROR; } if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR; sqlite3_snprintf(sizeof(zBuf), zBuf, "%d", sqlite3_get_autocommit(db)); Tcl_AppendResult(interp, zBuf, 0); return TCL_OK; } /* ** Usage: sqlite3_busy_timeout DB MS ** |
︙ | ︙ | |||
5169 5170 5171 5172 5173 5174 5175 | char proxyPath[400]; zPwd = Tcl_GetStringFromObj(objv[2], &nPwd); if( sizeof(proxyPath)<nPwd+20 ){ Tcl_AppendResult(interp, "PWD too big", (void*)0); return TCL_ERROR; } | | | 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 | char proxyPath[400]; zPwd = Tcl_GetStringFromObj(objv[2], &nPwd); if( sizeof(proxyPath)<nPwd+20 ){ Tcl_AppendResult(interp, "PWD too big", (void*)0); return TCL_ERROR; } sqlite3_snprintf(sizeof(proxyPath), proxyPath, "%s/test.proxy", zPwd); rc = sqlite3_file_control(db, NULL, SQLITE_SET_LOCKPROXYFILE, proxyPath); if( rc ){ Tcl_SetObjResult(interp, Tcl_NewIntObj(rc)); return TCL_ERROR; } rc = sqlite3_file_control(db, NULL, SQLITE_GET_LOCKPROXYFILE, &testPath); if( strncmp(proxyPath,testPath,11) ){ |
︙ | ︙ | |||
5974 5975 5976 5977 5978 5979 5980 | Tcl_Obj *CONST objv[] ){ char buf[1024]; struct rusage r; memset(&r, 0, sizeof(r)); getrusage(RUSAGE_SELF, &r); | > | | 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 | Tcl_Obj *CONST objv[] ){ char buf[1024]; struct rusage r; memset(&r, 0, sizeof(r)); getrusage(RUSAGE_SELF, &r); sqlite3_snprintf(sizeof(buf), buf, "ru_utime=%d.%06d ru_stime=%d.%06d ru_minflt=%d ru_majflt=%d", (int)r.ru_utime.tv_sec, (int)r.ru_utime.tv_usec, (int)r.ru_stime.tv_sec, (int)r.ru_stime.tv_usec, (int)r.ru_minflt, (int)r.ru_majflt ); Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, -1)); return TCL_OK; } |
︙ | ︙ |
Changes to src/test3.c.
︙ | ︙ | |||
441 442 443 444 445 446 447 | if( Tcl_GetInt(interp, argv[4], (int*)&incr) ) return TCL_ERROR; in = start; in *= mult; for(i=0; i<(int)count; i++){ char zErr[200]; n1 = putVarint(zBuf, in); if( n1>9 || n1<1 ){ | > | > | > | > | > | | 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 | if( Tcl_GetInt(interp, argv[4], (int*)&incr) ) return TCL_ERROR; in = start; in *= mult; for(i=0; i<(int)count; i++){ char zErr[200]; n1 = putVarint(zBuf, in); if( n1>9 || n1<1 ){ sqlite3_snprintf(sizeof(zErr), zErr, "putVarint returned %d - should be between 1 and 9", n1); Tcl_AppendResult(interp, zErr, 0); return TCL_ERROR; } n2 = getVarint(zBuf, &out); if( n1!=n2 ){ sqlite3_snprintf(sizeof(zErr), zErr, "putVarint returned %d and getVarint returned %d", n1, n2); Tcl_AppendResult(interp, zErr, 0); return TCL_ERROR; } if( in!=out ){ sqlite3_snprintf(sizeof(zErr), zErr, "Wrote 0x%016llx and got back 0x%016llx", in, out); Tcl_AppendResult(interp, zErr, 0); return TCL_ERROR; } if( (in & 0xffffffff)==in ){ u32 out32; n2 = getVarint32(zBuf, out32); out = out32; if( n1!=n2 ){ sqlite3_snprintf(sizeof(zErr), zErr, "putVarint returned %d and GetVarint32 returned %d", n1, n2); Tcl_AppendResult(interp, zErr, 0); return TCL_ERROR; } if( in!=out ){ sqlite3_snprintf(sizeof(zErr), zErr, "Wrote 0x%016llx and got back 0x%016llx from GetVarint32", in, out); Tcl_AppendResult(interp, zErr, 0); return TCL_ERROR; } } /* In order to get realistic timings, run getVarint 19 more times. |
︙ | ︙ |
Changes to src/test4.c.
︙ | ︙ | |||
266 267 268 269 270 271 272 | i = parse_thread_id(interp, argv[1]); if( i<0 ) return TCL_ERROR; if( !threadset[i].busy ){ Tcl_AppendResult(interp, "no such thread", 0); return TCL_ERROR; } thread_wait(&threadset[i]); | | | 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | i = parse_thread_id(interp, argv[1]); if( i<0 ) return TCL_ERROR; if( !threadset[i].busy ){ Tcl_AppendResult(interp, "no such thread", 0); return TCL_ERROR; } thread_wait(&threadset[i]); sqlite3_snprintf(sizeof(zBuf), zBuf, "%d", threadset[i].argc); Tcl_AppendResult(interp, zBuf, 0); return TCL_OK; } /* ** Usage: thread_argv ID N ** |
︙ | ︙ |
Changes to src/test7.c.
︙ | ︙ | |||
311 312 313 314 315 316 317 | i = parse_client_id(interp, argv[1]); if( i<0 ) return TCL_ERROR; if( !threadset[i].busy ){ Tcl_AppendResult(interp, "no such thread", 0); return TCL_ERROR; } client_wait(&threadset[i]); | | | 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | i = parse_client_id(interp, argv[1]); if( i<0 ) return TCL_ERROR; if( !threadset[i].busy ){ Tcl_AppendResult(interp, "no such thread", 0); return TCL_ERROR; } client_wait(&threadset[i]); sqlite3_snprintf(sizeof(zBuf), zBuf, "%d", threadset[i].argc); Tcl_AppendResult(interp, zBuf, 0); return TCL_OK; } /* ** Usage: client_argv ID N ** |
︙ | ︙ |
Changes to src/test8.c.
︙ | ︙ | |||
202 203 204 205 206 207 208 | /* Copy the column names into the allocated space and set up the ** pointers in the aCol[] array. */ zSpace = (char *)(&aCol[nCol]); for(ii=0; ii<nCol; ii++){ aCol[ii] = zSpace; | | | | 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | /* Copy the column names into the allocated space and set up the ** pointers in the aCol[] array. */ zSpace = (char *)(&aCol[nCol]); for(ii=0; ii<nCol; ii++){ aCol[ii] = zSpace; sqlite3_snprintf(nBytes, zSpace, "%s", sqlite3_column_name(pStmt,ii)); zSpace += (int)strlen(zSpace) + 1; } assert( (zSpace-nBytes)==(char *)aCol ); } *paCol = aCol; *pnCol = nCol; |
︙ | ︙ |
Changes to src/test_sqllog.c.
︙ | ︙ | |||
361 362 363 364 365 366 367 | /* If it is still NULL, have global.zPrefix point to a copy of ** environment variable $ENVIRONMENT_VARIABLE1_NAME. */ if( sqllogglobal.zPrefix[0]==0 ){ FILE *fd; char *zVar = getenv(ENVIRONMENT_VARIABLE1_NAME); if( zVar==0 || strlen(zVar)+10>=(sizeof(sqllogglobal.zPrefix)) ) return; | > | > | | 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | /* If it is still NULL, have global.zPrefix point to a copy of ** environment variable $ENVIRONMENT_VARIABLE1_NAME. */ if( sqllogglobal.zPrefix[0]==0 ){ FILE *fd; char *zVar = getenv(ENVIRONMENT_VARIABLE1_NAME); if( zVar==0 || strlen(zVar)+10>=(sizeof(sqllogglobal.zPrefix)) ) return; sqlite3_snprintf(sizeof(sqllogglobal.zPrefix), sqllogglobal.zPrefix, "%s/sqllog_%d", zVar, getProcessId()); sqlite3_snprintf(sizeof(sqllogglobal.zIdx), sqllogglobal.zIdx, "%s.idx", sqllogglobal.zPrefix); if( getenv(ENVIRONMENT_VARIABLE2_NAME) ){ sqllogglobal.bReuse = atoi(getenv(ENVIRONMENT_VARIABLE2_NAME)); } fd = fopen(sqllogglobal.zIdx, "w"); if( fd ) fclose(fd); } |
︙ | ︙ |
Changes to src/test_thread.c.
︙ | ︙ | |||
604 605 606 607 608 609 610 | if( bytes>=0 ){ bytes = bytes - (zTail-zSql); } Tcl_ObjSetVar2(interp, objv[4], 0, Tcl_NewStringObj(zTail, bytes), 0); } if( rc!=SQLITE_OK ){ assert( pStmt==0 ); | | | 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 | if( bytes>=0 ){ bytes = bytes - (zTail-zSql); } Tcl_ObjSetVar2(interp, objv[4], 0, Tcl_NewStringObj(zTail, bytes), 0); } if( rc!=SQLITE_OK ){ assert( pStmt==0 ); sqlite3_snprintf(sizeof(zBuf), zBuf, "%s ", (char *)sqlite3ErrName(rc)); Tcl_AppendResult(interp, zBuf, sqlite3_errmsg(db), 0); return TCL_ERROR; } if( pStmt ){ if( sqlite3TestMakePointerStr(interp, zBuf, pStmt) ) return TCL_ERROR; Tcl_AppendResult(interp, zBuf, 0); |
︙ | ︙ |
Changes to src/test_vfs.c.
︙ | ︙ | |||
819 820 821 822 823 824 825 | } /* Search for a TestvfsBuffer. Create a new one if required. */ for(pBuffer=p->pBuffer; pBuffer; pBuffer=pBuffer->pNext){ if( 0==strcmp(pFd->zFilename, pBuffer->zFile) ) break; } if( !pBuffer ){ | > | | | 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 | } /* Search for a TestvfsBuffer. Create a new one if required. */ for(pBuffer=p->pBuffer; pBuffer; pBuffer=pBuffer->pNext){ if( 0==strcmp(pFd->zFilename, pBuffer->zFile) ) break; } if( !pBuffer ){ int szName = (int)strlen(pFd->zFilename); int nByte = sizeof(TestvfsBuffer) + szName + 1; pBuffer = (TestvfsBuffer *)ckalloc(nByte); memset(pBuffer, 0, nByte); pBuffer->zFile = (char *)&pBuffer[1]; memcpy(pBuffer->zFile, pFd->zFilename, szName+1); pBuffer->pNext = p->pBuffer; p->pBuffer = pBuffer; } /* Connect the TestvfsBuffer to the new TestvfsShm handle and return. */ pFd->pNext = pBuffer->pFile; pBuffer->pFile = pFd; |
︙ | ︙ |