Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | More MEM changes in the vdbe.c. Still will not compile. (CVS 1469) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
dbdd1a7f316e576d0611748ec63c9ef0 |
User & Date: | drh 2004-05-27 01:53:56.000 |
Context
2004-05-27
| ||
03:12 | Fixes to the MEM changes. The library now links. (CVS 1470) (check-in: f33d15d95f user: drh tags: trunk) | |
01:53 | More MEM changes in the vdbe.c. Still will not compile. (CVS 1469) (check-in: dbdd1a7f31 user: drh tags: trunk) | |
01:49 | More test cases for the new query API. (CVS 1468) (check-in: 74097ecdb0 user: danielk1977 tags: trunk) | |
Changes
Changes to main.mk.
︙ | ︙ | |||
54 55 56 57 58 59 60 | # Object files for the SQLite library. # LIBOBJ = attach.o auth.o btree.o build.o copy.o date.o delete.o \ expr.o func.o hash.o insert.o \ main.o opcodes.o os_mac.o os_unix.o os_win.o \ pager.o parse.o pragma.o printf.o random.o \ | | > | | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | # Object files for the SQLite library. # LIBOBJ = attach.o auth.o btree.o build.o copy.o date.o delete.o \ expr.o func.o hash.o insert.o \ main.o opcodes.o os_mac.o os_unix.o os_win.o \ pager.o parse.o pragma.o printf.o random.o \ select.o table.o tokenize.o trigger.o update.o util.o vacuum.o \ vdbe.o vdbeapi.o vdbeaux.o vdbemem.o \ where.o tclsqlite.o utf.o legacy.o # All of the source code files. # SRC = \ $(TOP)/src/attach.c \ $(TOP)/src/auth.c \ $(TOP)/src/btree.c \ |
︙ | ︙ | |||
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | $(TOP)/src/trigger.c \ $(TOP)/src/utf.c \ $(TOP)/src/update.c \ $(TOP)/src/util.c \ $(TOP)/src/vacuum.c \ $(TOP)/src/vdbe.c \ $(TOP)/src/vdbe.h \ $(TOP)/src/vdbeaux.c \ $(TOP)/src/vdbeInt.h \ $(TOP)/src/where.c # Source code to the test files. # TESTSRC = \ $(TOP)/src/btree.c \ | > > | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | $(TOP)/src/trigger.c \ $(TOP)/src/utf.c \ $(TOP)/src/update.c \ $(TOP)/src/util.c \ $(TOP)/src/vacuum.c \ $(TOP)/src/vdbe.c \ $(TOP)/src/vdbe.h \ $(TOP)/src/vdbeapi.c \ $(TOP)/src/vdbeaux.c \ $(TOP)/src/vdbemem.c \ $(TOP)/src/vdbeInt.h \ $(TOP)/src/where.c # Source code to the test files. # TESTSRC = \ $(TOP)/src/btree.c \ |
︙ | ︙ | |||
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | $(TCCX) -c $(TOP)/src/util.c vacuum.o: $(TOP)/src/vacuum.c $(HDR) $(TCCX) -c $(TOP)/src/vacuum.c vdbe.o: $(TOP)/src/vdbe.c $(VDBEHDR) $(TCCX) -c $(TOP)/src/vdbe.c vdbeaux.o: $(TOP)/src/vdbeaux.c $(VDBEHDR) $(TCCX) -c $(TOP)/src/vdbeaux.c where.o: $(TOP)/src/where.c $(HDR) $(TCCX) -c $(TOP)/src/where.c # Rules for building test programs and for running tests # tclsqlite: $(TOP)/src/tclsqlite.c libsqlite.a | > > > > > > | 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 | $(TCCX) -c $(TOP)/src/util.c vacuum.o: $(TOP)/src/vacuum.c $(HDR) $(TCCX) -c $(TOP)/src/vacuum.c vdbe.o: $(TOP)/src/vdbe.c $(VDBEHDR) $(TCCX) -c $(TOP)/src/vdbe.c vdbeapi.o: $(TOP)/src/vdbeapi.c $(VDBEHDR) $(TCCX) -c $(TOP)/src/vdbeapi.c vdbeaux.o: $(TOP)/src/vdbeaux.c $(VDBEHDR) $(TCCX) -c $(TOP)/src/vdbeaux.c vdbemem.o: $(TOP)/src/vdbemem.c $(VDBEHDR) $(TCCX) -c $(TOP)/src/vdbemem.c where.o: $(TOP)/src/where.c $(HDR) $(TCCX) -c $(TOP)/src/where.c # Rules for building test programs and for running tests # tclsqlite: $(TOP)/src/tclsqlite.c libsqlite.a |
︙ | ︙ |
Changes to src/sqliteInt.h.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Internal interface definitions for SQLite. ** | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Internal interface definitions for SQLite. ** ** @(#) $Id: sqliteInt.h,v 1.254 2004/05/27 01:53:56 drh Exp $ */ #include "config.h" #include "sqlite.h" #include "hash.h" #include "parse.h" #include <stdio.h> #include <stdlib.h> |
︙ | ︙ | |||
1343 1344 1345 1346 1347 1348 1349 | char sqlite3AffinityType(const char *, int); void sqlite3IndexAffinityStr(Vdbe *, Index *); void sqlite3TableAffinityStr(Vdbe *, Table *); char sqlite3CompareAffinity(Expr *pExpr, char aff2); char const *sqlite3AffinityString(char affinity); int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity); char sqlite3ExprAffinity(Expr *pExpr); | | | 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 | char sqlite3AffinityType(const char *, int); void sqlite3IndexAffinityStr(Vdbe *, Index *); void sqlite3TableAffinityStr(Vdbe *, Table *); char sqlite3CompareAffinity(Expr *pExpr, char aff2); char const *sqlite3AffinityString(char affinity); int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity); char sqlite3ExprAffinity(Expr *pExpr); int sqlite3atoi64(const char*, i64*); void sqlite3Error(sqlite *, int, const char*,...); int sqlite3utfTranslate(const void *, int , u8 , void **, int *, u8); u8 sqlite3UtfReadBom(const void *zData, int nData); |
Changes to src/utf.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains routines used to translate between UTF-8, ** UTF-16, UTF-16BE, and UTF-16LE. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains routines used to translate between UTF-8, ** UTF-16, UTF-16BE, and UTF-16LE. ** ** $Id: utf.c,v 1.11 2004/05/27 01:53:56 drh Exp $ ** ** Notes on UTF-8: ** ** Byte-0 Byte-1 Byte-2 Byte-3 Value ** 0xxxxxxx 00000000 00000000 0xxxxxxx ** 110yyyyy 10xxxxxx 00000000 00000yyy yyxxxxxx ** 1110zzzz 10yyyyyy 10xxxxxx 00000000 zzzzyyyy yyxxxxxx |
︙ | ︙ | |||
575 576 577 578 579 580 581 | } /* ** This function is used to translate between UTF-8 and UTF-16. The ** result is returned in dynamically allocated memory. */ int sqlite3utfTranslate( | | < | | < | | 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 | } /* ** This function is used to translate between UTF-8 and UTF-16. The ** result is returned in dynamically allocated memory. */ int sqlite3utfTranslate( const void *zData, int nData, /* Input string */ u8 enc1, /* Encoding of zData */ void **zOut, int *nOut, /* Output string */ u8 enc2 /* Desired encoding of output */ ){ assert( enc1==TEXT_Utf8 || enc1==TEXT_Utf16le || enc1==TEXT_Utf16be ); assert( enc2==TEXT_Utf8 || enc2==TEXT_Utf16le || enc2==TEXT_Utf16be ); assert( (enc1==TEXT_Utf8 && (enc2==TEXT_Utf16le || enc2==TEXT_Utf16be)) || (enc2==TEXT_Utf8 && (enc1==TEXT_Utf16le || enc1==TEXT_Utf16be)) ); |
︙ | ︙ | |||
604 605 606 607 608 609 610 | }else{ *zOut = sqlite3utf16to8(zData, nData, enc1==TEXT_Utf16be); if( !(*zOut) ) return SQLITE_NOMEM; *nOut = strlen(*zOut)+1; } return SQLITE_OK; } | < < | 602 603 604 605 606 607 608 | }else{ *zOut = sqlite3utf16to8(zData, nData, enc1==TEXT_Utf16be); if( !(*zOut) ) return SQLITE_NOMEM; *nOut = strlen(*zOut)+1; } return SQLITE_OK; } |
Changes to src/util.c.
︙ | ︙ | |||
10 11 12 13 14 15 16 | ** ************************************************************************* ** Utility functions used throughout sqlite. ** ** This file contains functions for allocating memory, comparing ** strings, and stuff like that. ** | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ** ************************************************************************* ** Utility functions used throughout sqlite. ** ** This file contains functions for allocating memory, comparing ** strings, and stuff like that. ** ** $Id: util.c,v 1.89 2004/05/27 01:53:56 drh Exp $ */ #include "sqliteInt.h" #include <stdarg.h> #include <ctype.h> /* ** If malloc() ever fails, this global variable gets set to 1. |
︙ | ︙ | |||
661 662 663 664 665 666 667 | ** then return false. If n>0 and the integer is string is not ** exactly n bytes long, return false. ** ** When this routine was originally written it dealt with only ** 32-bit numbers. At that time, it was much faster than the ** atoi() library routine in RedHat 7.2. */ | | < < | | | < < | 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 | ** then return false. If n>0 and the integer is string is not ** exactly n bytes long, return false. ** ** When this routine was originally written it dealt with only ** 32-bit numbers. At that time, it was much faster than the ** atoi() library routine in RedHat 7.2. */ int sqlite3atoi64(const char *zNum, i64 *pNum){ i64 v = 0; int neg; int i, c; if( *zNum=='-' ){ neg = 1; zNum++; }else if( *zNum=='+' ){ neg = 0; zNum++; }else{ neg = 0; } for(i=0; (c=zNum[i])>='0' && c<='9'; i++){ v = v*10 + c - '0'; } *pNum = neg ? -v : v; return c==0 && i>0 && (i<19 || (i==19 && memcmp(zNum,"9223372036854775807",19)<=0)); } /* ** The string zNum represents an integer. There might be some other ** information following the integer too, but that part is ignored. |
︙ | ︙ |
Changes to src/vdbe.c.
︙ | ︙ | |||
39 40 41 42 43 44 45 | ** ** Various scripts scan this source file in order to generate HTML ** documentation, headers files, or other derived files. The formatting ** of the code in this file is, therefore, important. See other comments ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** | | | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | ** ** Various scripts scan this source file in order to generate HTML ** documentation, headers files, or other derived files. The formatting ** of the code in this file is, therefore, important. See other comments ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** ** $Id: vdbe.c,v 1.337 2004/05/27 01:53:56 drh Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> #include "vdbeInt.h" /* |
︙ | ︙ | |||
65 66 67 68 69 70 71 72 | ** of the db.flags field is set in order to simulate and interrupt. ** ** This facility is used for testing purposes only. It does not function ** in an ordinary build. */ int sqlite3_interrupt_count = 0; /* | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < | < < < < < < < < | < < < | < < < < < < < < | < < < < < < < < < < < | < < < < < < < < < < < < < | | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | ** of the db.flags field is set in order to simulate and interrupt. ** ** This facility is used for testing purposes only. It does not function ** in an ordinary build. */ int sqlite3_interrupt_count = 0; /* ** Release the memory associated with the given stack level. This ** leaves the Mem.flags field in an inconsistent state. */ #define Release(P) if((P)->flags&MEM_Dyn){ sqliteFree((P)->z); } /* ** Convert the given stack entity into a string if it isn't one ** already. Return non-zero if a malloc() fails. */ #define Stringify(P, enc) \ (!((P)->flags&(MEM_Str|MEM_Blob)) && sqlite3VdbeMemStringify(P,enc)) /* ** Convert the given stack entity into a string that has been obtained ** from sqliteMalloc(). This is different from Stringify() above in that ** Stringify() will use the NBFS bytes of static string space if the string ** will fit but this routine always mallocs for space. ** Return non-zero if we run out of memory. */ #define Dynamicify(P,enc) sqlite3VdbeMemDynamicify(P) /* ** An ephemeral string value (signified by the MEM_Ephem flag) contains ** a pointer to a dynamically allocated string where some other entity ** is responsible for deallocating that string. Because the stack entry ** does not control the string, it might be deleted without the stack ** entry knowing it. ** ** This routine converts an ephemeral string into a dynamically allocated ** string that the stack entry itself controls. In other words, it ** converts an MEM_Ephem string into an MEM_Dyn string. */ #define Deephemeralize(P) \ if( ((P)->flags&MEM_Ephem)!=0 \ && sqlite3VdbeMemMakeWriteable(P) ){ goto no_mem;} /* ** Convert the given stack entity into a integer if it isn't one ** already. ** ** Any prior string or real representation is invalidated. ** NULLs are converted into 0. */ #define Integerify(P, enc) \ if((P)->flags!=MEM_Int){ sqlite3VdbeMemIntegerify(P); } /* ** Get a valid Real representation for the given stack element. ** ** Any prior string or integer representation is retained. ** NULLs are converted into 0.0. */ #define Realify(P,enc) \ if(((P)->flags&MEM_Real)==0){ sqlite3VdbeMemRealify(P); } /* ** Insert a new aggregate element and make it the element that ** has focus. ** ** Return 0 on success and 1 if memory is exhausted. |
︙ | ︙ | |||
1154 1155 1156 1157 1158 1159 1160 | */ case OP_Concat: { char *zNew; int nByte; int nField; int i, j; Mem *pTerm; | | < < < | | | > | | < | | | | | < | | | < | < | | | > > | 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 | */ case OP_Concat: { char *zNew; int nByte; int nField; int i, j; Mem *pTerm; Mem mSep; /* Memory cell containing the seperator string, if any */ /* FIX ME: Eventually, P3 will be in database native encoding. But for ** now it is always UTF-8. So set up zSep to hold the native encoding of ** P3. */ if( pOp->p3 ){ mSep.z = pOp->p3; mSep.n = strlen(mSep.z); mSep.flags = MEM_Str|MEM_Static|MEM_Term; mSep.enc = TEXT_Utf8; sqlite3VdbeChangeEncoding(&mSep, db->enc); }else{ mSep.flags = MEM_Null; } /* Loop through the stack elements to see how long the result will be. */ nField = pOp->p1; pTerm = &pTos[1-nField]; nByte = (nField-1)*mSep.n; for(i=0; i<nField; i++, pTerm++){ assert( pOp->p2==0 || (pTerm->flags&MEM_Str) ); if( pTerm->flags&MEM_Null ){ nByte = -1; break; } Stringify(pTerm, db->enc); nByte += pTerm->n; } if( nByte<0 ){ /* If nByte is less than zero, then there is a NULL value on the stack. ** In this case just pop the values off the stack (if required) and ** push on a NULL. */ if( pOp->p2==0 ){ popStack(&pTos, nField); } pTos++; pTos->flags = MEM_Null; }else{ /* Otherwise malloc() space for the result and concatenate all the ** stack values. */ zNew = sqliteMallocRaw( nByte+2 ); if( zNew==0 ) goto no_mem; j = 0; pTerm = &pTos[1-nField]; for(i=j=0; i<nField; i++, pTerm++){ int n = pTerm->n; assert( pTerm->flags & MEM_Str ); memcpy(&zNew[j], pTerm->z, n); j += n; if( i<nField-1 && !(mSep.flags|MEM_Null) ){ memcpy(&zNew[j], mSep.z, mSep.n); j += mSep.n; } } zNew[j] = 0; zNew[j+1] = 0; assert( j==nByte-1 ); if( pOp->p2==0 ){ popStack(&pTos, nField); } pTos++; pTos->n = j; pTos->flags = MEM_Str|MEM_Dyn|MEM_Term pTos->enc = db->enc; pTos->type = SQLITE3_TEXT; pTos->z = zNew; } break; } /* Opcode: Add * * * ** |
︙ | ︙ | |||
1549 1550 1551 1552 1553 1554 1555 | double r = (double)i; if( r!=pTos->r ){ goto mismatch; } pTos->i = i; }else if( pTos->flags & MEM_Str ){ i64 v; | > > > > | | | > | 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 | double r = (double)i; if( r!=pTos->r ){ goto mismatch; } pTos->i = i; }else if( pTos->flags & MEM_Str ){ i64 v; if( sqlite3VdbeChangeEncoding(pTos, TEXT_Utf8) || sqlite3VdbeNulTerminate(pTos) ){ goto no_mem; } if( !sqlite3atoi64(pTos->z, &v) ){ double r; if( !sqlite3IsNumber(pTos->z, 0, TEXT_Utf8) ){ goto mismatch; } Realify(pTos, TEXT_Utf8); v = (int)pTos->r; r = (double)v; if( r!=pTos->r ){ goto mismatch; } } pTos->i = v; }else{ goto mismatch; } Release(pTos); pTos->flags = MEM_Int; pTos->type = SQLITE3_INTEGER; break; mismatch: if( pOp->p2==0 ){ rc = SQLITE_MISMATCH; goto abort_due_to_error; }else{ |
︙ | ︙ | |||
4381 4382 4383 4384 4385 4386 4387 | Sorter *pSorter = p->pSort; CHECK_FOR_INTERRUPT; if( pSorter!=0 ){ p->pSort = pSorter->pNext; pTos++; pTos->z = pSorter->pData; pTos->n = pSorter->nData; | < < < | | > | 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 | Sorter *pSorter = p->pSort; CHECK_FOR_INTERRUPT; if( pSorter!=0 ){ p->pSort = pSorter->pNext; pTos++; pTos->z = pSorter->pData; pTos->n = pSorter->nData; pTos->flags = MEM_Blob|MEM_Dyn|MEM_Term; pTos->enc = 0; pTos->type = SQLITE3_BLOB; sqliteFree(pSorter->zKey); sqliteFree(pSorter); }else{ pc = pOp->p2 - 1; } break; } |
︙ | ︙ |
Changes to src/vdbeInt.h.
︙ | ︙ | |||
352 353 354 355 356 357 358 | int sqlite3VdbeRowCompare(void*,int,const void*,int, const void*); int sqlite3VdbeExec(Vdbe*); int sqlite3VdbeList(Vdbe*); int sqlite3VdbeSetEncoding(Mem *, u8); int sqlite3VdbeMemCopy(Mem*, const Mem*); int sqlite3VdbeMemNulTerminate(Mem *); int sqlite3VdbeMemSetStr(Mem*, const char*, int, u8, int); | > > > > > > > | 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | int sqlite3VdbeRowCompare(void*,int,const void*,int, const void*); int sqlite3VdbeExec(Vdbe*); int sqlite3VdbeList(Vdbe*); int sqlite3VdbeSetEncoding(Mem *, u8); int sqlite3VdbeMemCopy(Mem*, const Mem*); int sqlite3VdbeMemNulTerminate(Mem *); int sqlite3VdbeMemSetStr(Mem*, const char*, int, u8, int); int sqlite3VdbeMemSetInt64(Mem*, long long int); int sqlite3VdbeMemSetDouble(Mem*, double); int sqlite3VdbeMemMakeWriteable(Mem*); int sqlite3VdbeMemDynamicify(Mem*); int sqlite3VdbeMemStringify(Mem*); int sqlite3VdbeMemIntegerify(Mem*); int sqlite3VdbeMemRealify(Mem*); |
Changes to src/vdbeapi.c.
︙ | ︙ | |||
193 194 195 196 197 198 199 200 201 202 203 204 205 206 | if( sqlite3SafetyOff(db) ){ rc = SQLITE_MISUSE; } sqlite3Error(p->db, rc, p->zErrMsg); return rc; } /* ** Return the number of columns in the result set for the statement pStmt. */ int sqlite3_column_count(sqlite3_stmt *pStmt){ Vdbe *pVm = (Vdbe *)pStmt; return pVm->nResColumn; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | if( sqlite3SafetyOff(db) ){ rc = SQLITE_MISUSE; } sqlite3Error(p->db, rc, p->zErrMsg); return rc; } /* ** Extract the user data from a sqlite3_context structure and return a ** pointer to it. */ void *sqlite3_user_data(sqlite3_context *p){ assert( p && p->pFunc ); return p->pFunc->pUserData; } /* ** Allocate or return the aggregate context for a user function. A new ** context is allocated on the first call. Subsequent calls return the ** same context that was returned on prior calls. ** ** This routine is defined here in vdbe.c because it depends on knowing ** the internals of the sqlite3_context structure which is only defined in ** this source file. */ void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){ assert( p && p->pFunc && p->pFunc->xStep ); if( p->pAgg==0 ){ if( nByte<=NBFS ){ p->pAgg = (void*)p->s.z; memset(p->pAgg, 0, nByte); }else{ p->pAgg = sqliteMalloc( nByte ); } } return p->pAgg; } /* ** Return the number of times the Step function of a aggregate has been ** called. ** ** This routine is defined here in vdbe.c because it depends on knowing ** the internals of the sqlite3_context structure which is only defined in ** this source file. */ int sqlite3_aggregate_count(sqlite3_context *p){ assert( p && p->pFunc && p->pFunc->xStep ); return p->cnt; } /* ** Return the number of columns in the result set for the statement pStmt. */ int sqlite3_column_count(sqlite3_stmt *pStmt){ Vdbe *pVm = (Vdbe *)pStmt; return pVm->nResColumn; |
︙ | ︙ |
Changes to src/vdbeaux.c.
︙ | ︙ | |||
105 106 107 108 109 110 111 | #endif return i; } /* ** Add an opcode that includes the p3 value. */ | | | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | #endif return i; } /* ** Add an opcode that includes the p3 value. */ int sqlite3VdbeOp3(Vdbe *p, int op, int p1, int p2, const char *zP3,int p3type){ int addr = sqlite3VdbeAddOp(p, op, p1, p2); sqlite3VdbeChangeP3(p, addr, zP3, p3type); return addr; } /* ** Add multiple opcodes. The list is terminated by an opcode of 0. |
︙ | ︙ | |||
420 421 422 423 424 425 426 | */ VdbeOp *sqlite3VdbeGetOp(Vdbe *p, int addr){ assert( p->magic==VDBE_MAGIC_INIT ); assert( addr>=0 && addr<p->nOp ); return &p->aOp[addr]; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 420 421 422 423 424 425 426 427 428 429 430 431 432 433 | */ VdbeOp *sqlite3VdbeGetOp(Vdbe *p, int addr){ assert( p->magic==VDBE_MAGIC_INIT ); assert( addr>=0 && addr<p->nOp ); return &p->aOp[addr]; } /* ** Compute a string that describes the P3 parameter for an opcode. ** Use zTemp for any required temporary buffer space. */ static char *displayP3(Op *pOp, char *zTemp, int nTemp){ char *zP3; assert( nTemp>=20 ); |
︙ | ︙ | |||
609 610 611 612 613 614 615 | }else{ p->rc = SQLITE_INTERRUPT; } rc = SQLITE_ERROR; sqlite3SetString(&p->zErrMsg, sqlite3_error_string(p->rc), (char*)0); }else{ Op *pOp = &p->aOp[i]; | > | > | > > | | > > > > > | | > > > | | > > | > | < < < < > > | | | 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 | }else{ p->rc = SQLITE_INTERRUPT; } rc = SQLITE_ERROR; sqlite3SetString(&p->zErrMsg, sqlite3_error_string(p->rc), (char*)0); }else{ Op *pOp = &p->aOp[i]; Mem *pMem = p->aStack; pMem->flags = MEM_Int; pMem->type = SQLITE3_INT; pMem->i = i; /* Program counter */ pMem++; pMem->flags = MEM_Static|MEM_Str|MEM_Term; pMem->z = sqlite3OpcodeNames[pOp->opcode]; /* Opcode */ pMem->n = strlen(pMem->z); pMem->type = SQLITE3_TEXT; pMem->enc = TEXT_Utf8; pMem++; pMem->flags = MEM_Int; pMem->i = pOp->p1; /* P1 */ pMem->type = SQLITE3_INT; pMem++; pMem->flags = MEM_Int; pMem->i = pOp->p2; /* P2 */ pMem->type = SQLITE_INT; pMem++; pMem->flags = MEM_Short|MEM_Str|MEM_Term; /* P3 */ pMem->z = displayP3(pOp, pMem->zShort, sizeof(pMem->zShort)); pMem->type = SQLITE_TEXT; pMem->enc = TEXT_Utf8; p->nResColumn = 5; p->pTos = pMem; p->rc = SQLITE_OK; p->resOnStack = 1; rc = SQLITE_ROW; } return rc; } |
︙ | ︙ | |||
1180 1181 1182 1183 1184 1185 1186 | } if( flags&MEM_Real ){ return 5; } if( flags&MEM_Str ){ int n = pMem->n; assert( n>=0 ); | < < < < < < < < < | 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 | } if( flags&MEM_Real ){ return 5; } if( flags&MEM_Str ){ int n = pMem->n; assert( n>=0 ); return ((n*2) + 13); } if( flags&MEM_Blob ){ return (pMem->n*2 + 12); } return 0; } |
︙ | ︙ | |||
1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 | /* memset(pMem, 0, sizeof(pMem)); */ pMem->flags = 0; pMem->z = 0; /* NULL */ if( serial_type==6 ){ pMem->flags = MEM_Null; return 0; } /* Integer and Real */ if( serial_type<=5 ){ u64 v = 0; int n; len = sqlite3VdbeSerialTypeLen(serial_type); if( buf[0]&0x80 ){ v = -1; } for(n=0; n<len; n++){ v = (v<<8) | buf[n]; } if( serial_type==5 ){ pMem->flags = MEM_Real; pMem->r = *(double*)&v; }else{ pMem->flags = MEM_Int; pMem->i = *(i64*)&v; } return len; } /* String or blob */ assert( serial_type>=12 ); len = sqlite3VdbeSerialTypeLen(serial_type); if( serial_type&0x01 ){ | > > > < < | < < < < < < < < < | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 | /* memset(pMem, 0, sizeof(pMem)); */ pMem->flags = 0; pMem->z = 0; /* NULL */ if( serial_type==6 ){ pMem->flags = MEM_Null; pMem->type = SQLITE3_NULL; return 0; } /* Integer and Real */ if( serial_type<=5 ){ u64 v = 0; int n; len = sqlite3VdbeSerialTypeLen(serial_type); if( buf[0]&0x80 ){ v = -1; } for(n=0; n<len; n++){ v = (v<<8) | buf[n]; } if( serial_type==5 ){ pMem->flags = MEM_Real; pMem->r = *(double*)&v; pMem->type = SQLITE3_FLOAT; }else{ pMem->flags = MEM_Int; pMem->i = *(i64*)&v; pMem->type = SQLITE3_INTEGER; } return len; } /* String or blob */ assert( serial_type>=12 ); len = sqlite3VdbeSerialTypeLen(serial_type); if( serial_type&0x01 ){ pMem->flags = MEM_Str | MEM_Ephem; pMem->n = len; }else{ pMem->flags = MEM_Blob | MEM_Ephem; pMem->n = len; } sqlite3VdbeMemMakeWriteable(pMem); return len; } /* ** The following is the comparison function for (non-integer) ** keys in the btrees. This function returns negative, zero, or ** positive if the first key is less than, equal to, or greater than ** the second. ** ** This function assumes that each key consists of one or more type/blob |
︙ | ︙ | |||
1699 1700 1701 1702 1703 1704 1705 | *res = sqlite3VdbeKeyCompare(pC->pKeyInfo, len, pCellKey, nKey, pKey); if( freeCellKey ){ sqliteFree(pCellKey); } return SQLITE_OK; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1542 1543 1544 1545 1546 1547 1548 | *res = sqlite3VdbeKeyCompare(pC->pKeyInfo, len, pCellKey, nKey, pKey); if( freeCellKey ){ sqliteFree(pCellKey); } return SQLITE_OK; } |
Changes to src/vdbemem.c.
︙ | ︙ | |||
16 17 18 19 20 21 22 | ** name sqlite_value */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> #include "vdbeInt.h" | < < < < < < < < | | < | | | < | > | < < | < < | | | | | | > | | | | | | | | | > | | | | > | > > > | | > | > > | > > > > > > > > > > > | | > > > | > > > > | > | | > > > > > > > > > > > | | < < < > > > > > > > | > > > > > > > > > | > > | > | < < < > | > > > | | < < > > > > > > > > | | > | | < > > | > > > > > > | | | < | < | | > | > | < < | | < > | > | > | | | | > | > | > > > > > > > > > > > > > > | | > > > > > > > > | > > > > | > | | | > > > > | > > > > | > > > > | | > > > > > | > | > | | < < < < < < | < < | < | > > > | | > | > < | < < < | < < < < | | < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 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 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 | ** name sqlite_value */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> #include "vdbeInt.h" /* ** If pMem is a string object, this routine sets the encoding of the string ** (to one of UTF-8 or UTF16) and whether or not the string is ** nul-terminated. If pMem is not a string object, then this routine is ** a no-op. ** ** The second argument, "desiredEnc" is one of TEXT_Utf8, TEXT_Utf16le ** or TEXT_Utf16be. This routine changes the encoding of pMem to match ** desiredEnc. ** ** SQLITE_OK is returned if the conversion is successful (or not required). ** SQLITE_NOMEM may be returned if a malloc() fails during conversion ** between formats. */ int sqlite3VdbeChangeEncoding(Mem *pMem, int desiredEnc){ u8 oldEnd; /* /* If this is not a string, or if it is a string but the encoding is ** already correct, do nothing. */ if( !(pMem->flags&MEM_Str) || pMem->enc==desiredEnc ){ return SQLITE_OK; } if( pMem->enc==TEXT_Utf8 || desiredEnd==TEXT_Utf8 ){ /* If the current encoding does not match the desired encoding, then ** we will need to do some translation between encodings. */ char *z; int n; int rc = sqlite3utfTranslate(pMem->z, pMem->n, pMem->enc, (void **)&z, &n, desiredEnd); if( rc!=SQLITE_OK ){ return rc; } /* Result of sqlite3utfTranslate is currently always dynamically ** allocated and nul terminated. This might be altered as a performance ** enhancement later. */ pMem->z = z; pMem->n = n; pMem->flags &= ~(MEM_Ephem | MEM_Short | MEM_Static); pMem->flags |= MEM_Str | MEM_Dyn | MEM_Term; }else{ /* Must be translating between UTF-16le and UTF-16be. */ int i; u8 *pFrom, *pTo; sqlite3VdbeMemMakeWritable(pMem); for(i=0, pFrom=pMem->z, pTo=&pMem->z[1]; i<pMem->n; i+=2, pFrom++, pTo++){ u8 temp = *pFrom; *pFrom = *pTo; *pTo = temp; } } pMem->enc = desiredEnc; return SQLITE_OK; } /* ** Make the given Mem object MEM_Dyn. ** ** Return SQLITE_OK on success or SQLITE_NOMEM if malloc fails. */ int sqlite3VdbeMemMakeDynamicify(Mem *pMem){ int n; u8 *z; if( (pMem->flags & (MEM_Ephem|MEM_Static|MEM_Short))==0 ){ return SQLITE_OK; } assert( (pMem->flags & MEM_Dyn)==0 ); assert( pMem->flags & (MEM_Str|MEM_Blob) ); z = sqliteMallocRaw( n+2 ) if( z==0 ){ return SQLITE_NOMEM; } pMem->flags |= MEM_Dyn|MEM_Term; memcpy(z, pMem->z, n ); z[n] = 0; z[n+1] = 0; pMem->z = z; pMem->flags &= ~(MEM_Ephem|MEM_Static|MEM_Short); } /* ** Make the given Mem object either MEM_Short or MEM_Dyn so that bytes ** of the Mem.z[] array can be modified. ** ** Return SQLITE_OK on success or SQLITE_NOMEM if malloc fails. */ int sqlite3VdbeMemMakeWritable(Mem *pMem){ int n; u8 *z; if( (pMem->flags & (MEM_Ephem|MEM_Static))==0 ){ return SQLITE_OK; } assert( (pMem->flags & MEM_Dyn)==0 ); assert( pMem->flags & (MEM_Str|MEM_Blob) ); if( (n = pMem->n)+2<sizeof(pMem->zShort) ){ z = pMem->zShort; pMem->flags |= MEM_Short|MEM_Term; }else{ z = sqliteMallocRaw( n+2 ) if( z==0 ){ return SQLITE_NOMEM; } pMem->flags |= MEM_Dyn|MEM_Term; } memcpy(z, pMem->z, n ); z[n] = 0; z[n+1] = 0; pMem->z = z; pMem->flags &= ~(MEM_Ephem|MEM_Static); } /* ** Make sure the given Mem is \u0000 terminated. */ int sqlite3VdbeMemNulTerminate(Mem *pMem){ if( (pMem->flags & MEM_Term)!=0 || pMem->flags & (MEM_Str|MEM_Blob))==0 ){ return SQLITE_OK; /* Nothing to do */ } /* Only static or ephemeral strings can be unterminated */ assert( (pMem->flags & (MEM_Static|MEM_Ephem))!=0 ); sqlite3VdbeMemMakeWriteable(pMem); } /* ** Add MEM_Str to the set of representations for the given Mem. ** A NULL is converted into an empty string. Numbers are converted ** using sqlite3_snprintf(). Converting a BLOB to a string is a ** no-op. ** ** Existing representations MEM_Int and MEM_Real are *not* invalidated. ** But MEM_Null is. */ int sqlite3VdbeMemStringify(Mem *pMem, int enc){ int rc = SQLITE_OK; int fg = pMem->flags; assert( !(fg&(MEM_Str|MEM_Blob)) ); assert( fg&(MEM_Int|MEM_Real|MEM_Null) ); if( fg & MEM_Null ){ /* A NULL value is converted to a zero length string */ u8 *z = pMem->zShort; z[0] = 0; z[1] = 0; pMem->flags = MEM_Str | MEM_Short | MEM_Term; pMem->z = z; pMem->n = 0; pMem->enc = enc; }else{ /* For a Real or Integer, use sqlite3_snprintf() to produce the UTF-8 ** string representation of the value. Then, if the required encoding ** is UTF-16le or UTF-16be do a translation. ** ** FIX ME: It would be better if sqlite3_snprintf() could do UTF-16. */ u8 *z = pMem->zShort; if( fg & MEM_Real ){ sqlite3_snprintf(NBFS, z, "%.15g", pMem->r); }else{ assert( fg & MEM_Int ); sqlite3_snprintf(NBFS, z, "%lld", pMem->i); } pMem->n = strlen(z); pMem->z = n; pMem->enc = TEXT_Utf8; pMem->flags |= MEM_Str | MEM_Short | MEM_Term; sqlite3VdbeMemChangeEncoding(pMem, enc); } return rc; } /* ** Convert the Mem to have representation MEM_Int only. All ** prior representations are invalidated. NULL is converted into 0. */ int sqlite3VdbeMemIntegerify(Mem *pMem){ if( pMem->flags & MEM_Int ){ /* Do nothing */ }else if( pMem->flags & MEM_Real ){ pMem->i = (i64)pMem->r; }else if( pMem->flags & (MEM_Str|MEM_Blob) ){ if( sqlite3VdbeChangeEncoding(pMem, TEXT_Utf8) || sqlite3VdbeNulTerminate(pMem) ){ return SQLITE_NOMEM; } assert( pMem->z ); sqlite3atoi64(pMem->z, &pMem->i); }else{ pMem->i = 0; } Release(pMem); pMem->flags = MEM_Int; pMem->type = SQLITE3_INTEGER; } /* ** Add MEM_Real to the set of representations for pMem. Prior ** prior representations other than MEM_Null retained. NULL is ** converted into 0.0. */ int sqlite3VdbeMemRealify(Mem *pMem){ if( pMem->flags & MEM_Int ){ pMem->r = pMem->r; pMem->flags |= MEM_Real; }else if( pMem->flags & (MEM_Str|MEM_Blob) ){ if( sqlite3VdbeChangeEncoding(pMem, TEXT_Utf8) || sqlite3VdbeNulTerminate(pMem) ){ return SQLITE_NOMEM; } assert( pMem->z ); pMem->r = sqlite3AtoF(pMem->z, 0); Release(pMem); pMem->flags = MEM_Real; pMem->type = SQLITE3_INTEGER; }else{ pMem->r = 0.0; pMem->flags = MEM_Real; pMem->type = SQLITE3_INTEGER; } } /* ** Release any memory held by the Mem */ static void releaseMem(Mem *p){ if( p->flags & MEM_Dyn ){ sqliteFree(p); } } /* ** Delete any previous value and set the value stored in *pMem to NULL. */ void sqlite3VdbeMemSetNull(Mem *pMem){ releaseMem(pMem); pMem->flags = MEM_Null; pMem->type = SQLITE3_NULL; } /* ** Delete any previous value and set the value stored in *pMem to val, ** manifest type INTEGER. */ void sqlite3VdbeMemSetInt64(Mem *pMem, i64 val){ releaseMem(pMem); pMem->i = val; pMem->flags = MEM_Int; pMem->type = SQLITE3_INTEGER; } /* ** Delete any previous value and set the value stored in *pMem to val, ** manifest type REAL. */ void sqlite3VdbeMemSetDouble(Mem *pMem, double val){ releaseMem(pMem); pMem->r = val; pMem->flags = MEM_Real; pMem->type = SQLITE3_FLOAT; } /* ** Copy the contents of memory cell pFrom into pTo. */ int sqlite3VdbeMemCopy(Mem *pTo, const Mem *pFrom){ releaseMem(pTo); memcpy(pTo, pFrom, sizeof(*pFrom)-sizeof(pFrom->zShort)); if( pTo->flags & (MEM_Str|MEM_Blob) ){ pTo->flags &= ~(MEM_Dyn|MEM_Static|MEM_Short); pTo->flags |= MEM_Ephem; sqlite3VdbeMemMakeWriteable(pTo); } return SQLITE_OK; } /* ** Change the value of a Mem to be a string or a BLOB. */ int sqlite3VdbeMemSetStr( Mem *pMem, /* Memory cell to set to string value */ const char *z, /* String pointer */ int n, /* Bytes in string, or negative */ u8 enc, /* Encoding of z. 0 for BLOBs */ int eCopy /* True if this function should make a copy of z */ ){ Mem tmp; releaseMem(pMem); if( !z ){ pMem->flags = MEM_Null; pMem->type = SQLITE3_NULL; return SQLITE_OK; } pMem->z = (char *)z; if( eCopy ){ pMem->flags = MEM_Ephem|MEM_Str; }else{ pMem->flags = MEM_Static|MEM_Str; } pMem->enc = enc; pMem->type = enc==0 ? SQLITE3_BLOB : SQLITE3_TEXT; pMem->n = n; switch( enc ){ case 0: pMem->flags |= MEM_Blob; break; case TEXT_Utf8: if( n<0 ){ pMem->n = strlen(z); pMem->flags |= MEM_Term; } break; case TEXT_Utf16le: case TEXT_Utf16be: if( n<0 ){ pMem->n = sqlite3utf16ByteLen(z,-1); pMem->flags |= MEM_Term; } break; default: assert(0); } if( eCopy ){ sqlite3VdbeMemMakeWriteable(pMem); } } /* ** Compare the values contained by the two memory cells, returning ** negative, zero or positive if pMem1 is less than, equal to, or greater ** than pMem2. Sorting order is NULL's first, followed by numbers (integers ** and reals) sorted numerically, followed by text ordered by the collating |
︙ | ︙ |
Changes to test/bind.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2003 September 6 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script testing the sqlite_bind API. # | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | # 2003 September 6 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this script testing the sqlite_bind API. # # $Id: bind.test,v 1.10 2004/05/27 01:53:56 drh Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl proc sqlite_step {stmt N VALS COLS} { upvar VALS vals upvar COLS cols set vals [list] set cols [list] set rc [sqlite3_step $stmt] for {set i 0} {$i < [sqlite3_column_count $stmt]} {incr i} { lappend cols [sqlite3_column_name $stmt $i] } for {set i 0} {$i < [sqlite3_data_count $stmt]} {incr i} { lappend vals [sqlite3_column_text $stmt $i] } return $rc } do_test bind-1.1 { db close |
︙ | ︙ |
Changes to test/enc2.test.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # #*********************************************************************** # This file implements regression tests for SQLite library. The focus of # this file is testing the SQLite routines used for converting between the # various suported unicode encodings (UTF-8, UTF-16, UTF-16le and # UTF-16be). # | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # #*********************************************************************** # This file implements regression tests for SQLite library. The focus of # this file is testing the SQLite routines used for converting between the # various suported unicode encodings (UTF-8, UTF-16, UTF-16le and # UTF-16be). # # $Id: enc2.test,v 1.3 2004/05/27 01:53:56 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl db close # Return the UTF-8 representation of the supplied UTF-16 string $str. |
︙ | ︙ | |||
87 88 89 90 91 92 93 | } } {one I 1 two II 2} # Now check that we can retrieve data in both UTF-16 and UTF-8 do_test $t.7 { set STMT [sqlite3_prepare $DB "SELECT a FROM t1 WHERE c>3;" -1 TAIL] sqlite3_step $STMT | | | | 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | } } {one I 1 two II 2} # Now check that we can retrieve data in both UTF-16 and UTF-8 do_test $t.7 { set STMT [sqlite3_prepare $DB "SELECT a FROM t1 WHERE c>3;" -1 TAIL] sqlite3_step $STMT sqlite3_column_text $STMT 0 } {four} do_test $t.8 { sqlite3_step $STMT utf8 [sqlite3_column_text16 $STMT 0] } {five} do_test $t.9 { sqlite3_finalize $STMT } SQLITE_OK do_test $t.99 { |
︙ | ︙ | |||
119 120 121 122 123 124 125 | execsql $dbcontents db close run_test_script enc2-$i incr i } finish_test | < < < < | 119 120 121 122 123 124 125 | execsql $dbcontents db close run_test_script enc2-$i incr i } finish_test |