/ Check-in [9e8e1c4a]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Merge the pointer-type enhancement from the 3.20 branch.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 9e8e1c4aa14bcda165b392d1d8af2ce394a56a8e7b67e4c73c742d8da75e73e2
User & Date: drh 2017-07-17 13:37:07
Context
2017-07-17
18:45
Merge all changes from branch-3.20. Improvements to the fts5() extension interface. Work around a gcc/valgrind bug in the sqlite3_value_pointer() interface. check-in: e0aca7d2 user: drh tags: trunk
13:37
Merge the pointer-type enhancement from the 3.20 branch. check-in: 9e8e1c4a user: drh tags: trunk
12:41
Comment changes clarifying details of the pointer-type parameter. No changes to code. check-in: e4579e50 user: drh tags: branch-3.20
2017-07-15
20:33
Fix a register allocation problem in PRAGMA integrity_check that caused the same register to be used for two different purposes on the first ATTACHed database if the schema for the ATTACHed database was noticable more complex than the schema for the first database. Fix for ticket [a4e06e75a9ab61a1]. check-in: 253945d4 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/fts3/fts3.c.

  3349   3349   
  3350   3350     /* The column value supplied by SQLite must be in range. */
  3351   3351     assert( iCol>=0 && iCol<=p->nColumn+2 );
  3352   3352   
  3353   3353     switch( iCol-p->nColumn ){
  3354   3354       case 0:
  3355   3355         /* The special 'table-name' column */
  3356         -      sqlite3_result_pointer(pCtx, pCsr);
         3356  +      sqlite3_result_pointer(pCtx, pCsr, "fts3cursor");
  3357   3357         break;
  3358   3358   
  3359   3359       case 1:
  3360   3360         /* The docid column */
  3361   3361         sqlite3_result_int64(pCtx, pCsr->iPrevId);
  3362   3362         break;
  3363   3363   
................................................................................
  3568   3568   static int fts3FunctionArg(
  3569   3569     sqlite3_context *pContext,      /* SQL function call context */
  3570   3570     const char *zFunc,              /* Function name */
  3571   3571     sqlite3_value *pVal,            /* argv[0] passed to function */
  3572   3572     Fts3Cursor **ppCsr              /* OUT: Store cursor handle here */
  3573   3573   ){
  3574   3574     int rc;
  3575         -  *ppCsr = (Fts3Cursor*)sqlite3_value_pointer(pVal);
         3575  +  *ppCsr = (Fts3Cursor*)sqlite3_value_pointer(pVal, "fts3cursor");
  3576   3576     if( (*ppCsr)!=0 ){
  3577   3577       rc = SQLITE_OK;
  3578   3578     }else{
  3579   3579       char *zErr = sqlite3_mprintf("illegal first argument to %s", zFunc);
  3580   3580       sqlite3_result_error(pContext, zErr, -1);
  3581   3581       sqlite3_free(zErr);
  3582   3582       rc = SQLITE_ERROR;

Changes to ext/misc/carray.c.

    15     15   ** Examples:
    16     16   **
    17     17   **      SELECT * FROM carray($ptr,5)
    18     18   **
    19     19   ** The query above returns 5 integers contained in a C-language array
    20     20   ** at the address $ptr.  $ptr is a pointer to the array of integers.
    21     21   ** The pointer value must be assigned to $ptr using the
    22         -** sqlite3_bind_pointer() interface.
           22  +** sqlite3_bind_pointer() interface with a pointer type of "carray".
           23  +** For example:
           24  +**
           25  +**    static int aX[] = { 53, 9, 17, 2231, 4, 99 };
           26  +**    int i = sqlite3_bind_parameter_index(pStmt, "$ptr");
           27  +**    sqlite3_bind_value(pStmt, i, aX, "carray");
    23     28   **
    24     29   ** There is an optional third parameter to determine the datatype of
    25     30   ** the C-language array.  Allowed values of the third parameter are
    26     31   ** 'int32', 'int64', 'double', 'char*'.  Example:
    27     32   **
    28     33   **      SELECT * FROM carray($ptr,10,'char*');
           34  +**
           35  +** The default value of the third parameter is 'int32'.
    29     36   **
    30     37   ** HOW IT WORKS
    31     38   **
    32     39   ** The carray "function" is really a virtual table with the
    33     40   ** following schema:
    34     41   **
    35     42   **     CREATE TABLE carray(
................................................................................
   229    236   static int carrayFilter(
   230    237     sqlite3_vtab_cursor *pVtabCursor, 
   231    238     int idxNum, const char *idxStr,
   232    239     int argc, sqlite3_value **argv
   233    240   ){
   234    241     carray_cursor *pCur = (carray_cursor *)pVtabCursor;
   235    242     if( idxNum ){
   236         -    pCur->pPtr = sqlite3_value_pointer(argv[0]);
          243  +    pCur->pPtr = sqlite3_value_pointer(argv[0], "carray");
   237    244       pCur->iCnt = pCur->pPtr ? sqlite3_value_int64(argv[1]) : 0;
   238    245       if( idxNum<3 ){
   239    246         pCur->eType = CARRAY_INT32;
   240    247       }else{
   241    248         unsigned char i;
   242    249         const char *zType = (const char*)sqlite3_value_text(argv[2]);
   243    250         for(i=0; i<sizeof(azType)/sizeof(azType[0]); i++){
................................................................................
   366    373     i64 = sqlite3_value_int64(argv[0]);
   367    374     if( sizeof(i64)==sizeof(p) ){
   368    375       memcpy(&p, &i64, sizeof(p));
   369    376     }else{
   370    377       int i32 = i64 & 0xffffffff;
   371    378       memcpy(&p, &i32, sizeof(p));
   372    379     }
   373         -  sqlite3_result_pointer(context, p);
          380  +  sqlite3_result_pointer(context, p, "carray");
   374    381   }
   375    382   #endif /* SQLITE_TEST */
   376    383   
   377    384   #endif /* SQLITE_OMIT_VIRTUALTABLE */
   378    385   
   379    386   #ifdef _WIN32
   380    387   __declspec(dllexport)

Changes to ext/misc/remember.c.

    17     17   **
    18     18   ** This allows, for example, a counter to incremented and the original
    19     19   ** value retrieved, atomically, using a single statement:
    20     20   **
    21     21   **    UPDATE counterTab SET cnt=remember(cnt,$PTR)+1 WHERE id=$ID
    22     22   **
    23     23   ** Prepare the above statement once.  Then to use it, bind the address
    24         -** of the output variable to $PTR (using sqlite3_bind_pointer()) and
    25         -** bind the id of the counter to $ID and run the prepared statement.
           24  +** of the output variable to $PTR using sqlite3_bind_pointer() with a
           25  +** pointer type of "carray" and bind the id of the counter to $ID and
           26  +** run the prepared statement.
           27  +**
           28  +** This implementation of the remember() function uses a "carray"
           29  +** pointer so that it can share pointers with the carray() extension.
    26     30   **
    27     31   ** One can imagine doing similar things with floating-point values and
    28     32   ** strings, but this demonstration extension will stick to using just
    29     33   ** integers.
    30     34   */
    31     35   #include "sqlite3ext.h"
    32     36   SQLITE_EXTENSION_INIT1
................................................................................
    43     47     int argc,
    44     48     sqlite3_value **argv
    45     49   ){
    46     50     sqlite3_int64 v;
    47     51     sqlite3_int64 *ptr;
    48     52     assert( argc==2 );
    49     53     v = sqlite3_value_int64(argv[0]);
    50         -  ptr = sqlite3_value_pointer(argv[1]);
           54  +  ptr = sqlite3_value_pointer(argv[1], "carray");
    51     55     if( ptr ) *ptr = v;
    52     56     sqlite3_result_int64(pCtx, v);
    53     57   }
    54     58   
    55     59   #ifdef _WIN32
    56     60   __declspec(dllexport)
    57     61   #endif

Changes to src/sqlite.h.in.

  3879   3879   ** is filled with zeroes.  ^A zeroblob uses a fixed amount of memory
  3880   3880   ** (just an integer to hold its size) while it is being processed.
  3881   3881   ** Zeroblobs are intended to serve as placeholders for BLOBs whose
  3882   3882   ** content is later written using
  3883   3883   ** [sqlite3_blob_open | incremental BLOB I/O] routines.
  3884   3884   ** ^A negative value for the zeroblob results in a zero-length BLOB.
  3885   3885   **
  3886         -** ^The sqlite3_bind_pointer(S,I,P) routine causes the I-th parameter in
         3886  +** ^The sqlite3_bind_pointer(S,I,P,T) routine causes the I-th parameter in
  3887   3887   ** [prepared statement] S to have an SQL value of NULL, but to also be
  3888         -** associated with the pointer P.
         3888  +** associated with the pointer P of type T.
  3889   3889   ** ^The sqlite3_bind_pointer() routine can be used to pass
  3890   3890   ** host-language pointers into [application-defined SQL functions].
  3891   3891   ** ^A parameter that is initialized using [sqlite3_bind_pointer()] appears
  3892   3892   ** to be an ordinary SQL NULL value to everything other than
  3893         -** [sqlite3_value_pointer()].
         3893  +** [sqlite3_value_pointer()].  The T parameter should be a static string.
  3894   3894   **
  3895   3895   ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer
  3896   3896   ** for the [prepared statement] or with a prepared statement for which
  3897   3897   ** [sqlite3_step()] has been called more recently than [sqlite3_reset()],
  3898   3898   ** then the call will return [SQLITE_MISUSE].  If any sqlite3_bind_()
  3899   3899   ** routine is passed a [prepared statement] that has been finalized, the
  3900   3900   ** result is undefined and probably harmful.
................................................................................
  3921   3921   int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
  3922   3922   int sqlite3_bind_null(sqlite3_stmt*, int);
  3923   3923   int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
  3924   3924   int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
  3925   3925   int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
  3926   3926                            void(*)(void*), unsigned char encoding);
  3927   3927   int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
  3928         -int sqlite3_bind_pointer(sqlite3_stmt*, int, void*);
         3928  +int sqlite3_bind_pointer(sqlite3_stmt*, int, void*, const char*);
  3929   3929   int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
  3930   3930   int sqlite3_bind_zeroblob64(sqlite3_stmt*, int, sqlite3_uint64);
  3931   3931   
  3932   3932   /*
  3933   3933   ** CAPI3REF: Number Of SQL Parameters
  3934   3934   ** METHOD: sqlite3_stmt
  3935   3935   **
................................................................................
  4754   4754   **
  4755   4755   ** ^The sqlite3_value_text16() interface extracts a UTF-16 string
  4756   4756   ** in the native byte-order of the host machine.  ^The
  4757   4757   ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
  4758   4758   ** extract UTF-16 strings as big-endian and little-endian respectively.
  4759   4759   **
  4760   4760   ** ^If [sqlite3_value] object V was initialized 
  4761         -** using [sqlite3_bind_pointer(S,I,P)] or [sqlite3_result_pointer(C,P)], then
  4762         -** sqlite3_value_pointer(V) will return the pointer P.  Otherwise,
  4763         -** sqlite3_value_pointer(V) returns a NULL.
         4761  +** using [sqlite3_bind_pointer(S,I,P,X)] or [sqlite3_result_pointer(C,P,X)]
         4762  +** and if X and Y are strings that compare equal according to strcmp(X,Y),
         4763  +** then sqlite3_value_pointer(V,Y) will return the pointer P.  ^Otherwise,
         4764  +** sqlite3_value_pointer(V,Y) returns a NULL.
  4764   4765   **
  4765   4766   ** ^(The sqlite3_value_type(V) interface returns the
  4766   4767   ** [SQLITE_INTEGER | datatype code] for the initial datatype of the
  4767   4768   ** [sqlite3_value] object V. The returned value is one of [SQLITE_INTEGER],
  4768   4769   ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL].)^
  4769   4770   ** Other interfaces might change the datatype for an sqlite3_value object.
  4770   4771   ** For example, if the datatype is initially SQLITE_INTEGER and
................................................................................
  4790   4791   ** These routines must be called from the same thread as
  4791   4792   ** the SQL function that supplied the [sqlite3_value*] parameters.
  4792   4793   */
  4793   4794   const void *sqlite3_value_blob(sqlite3_value*);
  4794   4795   double sqlite3_value_double(sqlite3_value*);
  4795   4796   int sqlite3_value_int(sqlite3_value*);
  4796   4797   sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
  4797         -void *sqlite3_value_pointer(sqlite3_value*);
         4798  +void *sqlite3_value_pointer(sqlite3_value*, const char*);
  4798   4799   const unsigned char *sqlite3_value_text(sqlite3_value*);
  4799   4800   const void *sqlite3_value_text16(sqlite3_value*);
  4800   4801   const void *sqlite3_value_text16le(sqlite3_value*);
  4801   4802   const void *sqlite3_value_text16be(sqlite3_value*);
  4802   4803   int sqlite3_value_bytes(sqlite3_value*);
  4803   4804   int sqlite3_value_bytes16(sqlite3_value*);
  4804   4805   int sqlite3_value_type(sqlite3_value*);
................................................................................
  5091   5092   ** sqlite3_result_value() interface makes a copy of the [sqlite3_value]
  5092   5093   ** so that the [sqlite3_value] specified in the parameter may change or
  5093   5094   ** be deallocated after sqlite3_result_value() returns without harm.
  5094   5095   ** ^A [protected sqlite3_value] object may always be used where an
  5095   5096   ** [unprotected sqlite3_value] object is required, so either
  5096   5097   ** kind of [sqlite3_value] object can be used with this interface.
  5097   5098   **
  5098         -** ^The sqlite3_result_pointer(C,P) interface sets the result to an
         5099  +** ^The sqlite3_result_pointer(C,P,T) interface sets the result to an
  5099   5100   ** SQL NULL value, just like [sqlite3_result_null(C)], except that it
  5100         -** also associates the host-language pointer P with that NULL value such
  5101         -** that the pointer can be retrieved within an
         5101  +** also associates the host-language pointer P or type T with that 
         5102  +** NULL value such that the pointer can be retrieved within an
  5102   5103   ** [application-defined SQL function] using [sqlite3_value_pointer()].
         5104  +** The T parameter should be a static string.
  5103   5105   ** This mechanism can be used to pass non-SQL values between
  5104   5106   ** application-defined functions.
  5105   5107   **
  5106   5108   ** If these routines are called from within the different thread
  5107   5109   ** than the one containing the application-defined function that received
  5108   5110   ** the [sqlite3_context] pointer, the results are undefined.
  5109   5111   */
................................................................................
  5122   5124   void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
  5123   5125   void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
  5124   5126                              void(*)(void*), unsigned char encoding);
  5125   5127   void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
  5126   5128   void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
  5127   5129   void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
  5128   5130   void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
  5129         -void sqlite3_result_pointer(sqlite3_context*, void*);
         5131  +void sqlite3_result_pointer(sqlite3_context*, void*, const char*);
  5130   5132   void sqlite3_result_zeroblob(sqlite3_context*, int n);
  5131   5133   int sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n);
  5132   5134   
  5133   5135   
  5134   5136   /*
  5135   5137   ** CAPI3REF: Setting The Subtype Of An SQL Function
  5136   5138   ** METHOD: sqlite3_context

Changes to src/sqlite3ext.h.

   285    285     /* Version 3.18.0 and later */
   286    286     void (*set_last_insert_rowid)(sqlite3*,sqlite3_int64);
   287    287     /* Version 3.20.0 and later */
   288    288     int (*prepare_v3)(sqlite3*,const char*,int,unsigned int,
   289    289                       sqlite3_stmt**,const char**);
   290    290     int (*prepare16_v3)(sqlite3*,const void*,int,unsigned int,
   291    291                         sqlite3_stmt**,const void**);
   292         -  int (*bind_pointer)(sqlite3_stmt*,int,void*);
   293         -  void (*result_pointer)(sqlite3_context*,void*);
   294         -  void *(*value_pointer)(sqlite3_value*);
          292  +  int (*bind_pointer)(sqlite3_stmt*,int,void*,const char*);
          293  +  void (*result_pointer)(sqlite3_context*,void*,const char*);
          294  +  void *(*value_pointer)(sqlite3_value*,const char*);
   295    295   };
   296    296   
   297    297   /*
   298    298   ** This is the function signature used for all extension entry points.  It
   299    299   ** is also defined in the file "loadext.c".
   300    300   */
   301    301   typedef int (*sqlite3_loadext_entry)(

Changes to src/vdbeInt.h.

   472    472   int sqlite3VdbeMemSetStr(Mem*, const char*, int, u8, void(*)(void*));
   473    473   void sqlite3VdbeMemSetInt64(Mem*, i64);
   474    474   #ifdef SQLITE_OMIT_FLOATING_POINT
   475    475   # define sqlite3VdbeMemSetDouble sqlite3VdbeMemSetInt64
   476    476   #else
   477    477     void sqlite3VdbeMemSetDouble(Mem*, double);
   478    478   #endif
   479         -void sqlite3VdbeMemSetPointer(Mem*, void*);
          479  +void sqlite3VdbeMemSetPointer(Mem*, void*, const char*);
   480    480   void sqlite3VdbeMemInit(Mem*,sqlite3*,u16);
   481    481   void sqlite3VdbeMemSetNull(Mem*);
   482    482   void sqlite3VdbeMemSetZeroBlob(Mem*,int);
   483    483   void sqlite3VdbeMemSetRowSet(Mem*);
   484    484   int sqlite3VdbeMemMakeWriteable(Mem*);
   485    485   int sqlite3VdbeMemStringify(Mem*, u8, u8);
   486    486   i64 sqlite3VdbeIntValue(Mem*);

Changes to src/vdbeapi.c.

   195    195   sqlite_int64 sqlite3_value_int64(sqlite3_value *pVal){
   196    196     return sqlite3VdbeIntValue((Mem*)pVal);
   197    197   }
   198    198   unsigned int sqlite3_value_subtype(sqlite3_value *pVal){
   199    199     Mem *pMem = (Mem*)pVal;
   200    200     return ((pMem->flags & MEM_Subtype) ? pMem->eSubtype : 0);
   201    201   }
   202         -void *sqlite3_value_pointer(sqlite3_value *pVal){
          202  +void *sqlite3_value_pointer(sqlite3_value *pVal, const char *zPType){
   203    203     Mem *p = (Mem*)pVal;
   204         -  if( (p->flags & MEM_TypeMask)==(MEM_Null|MEM_Subtype) && p->eSubtype=='p' ){
          204  +  if( p->flags==(MEM_Null|MEM_Subtype|MEM_Term|MEM_Static)
          205  +   && p->eSubtype=='p'
          206  +   && zPType!=0
          207  +   && strcmp(p->z, zPType)==0
          208  +  ){
   205    209       return p->u.pPtr;
   206    210     }else{
   207    211       return 0;
   208    212     }
   209    213   }
   210    214   const unsigned char *sqlite3_value_text(sqlite3_value *pVal){
   211    215     return (const unsigned char *)sqlite3ValueText(pVal, SQLITE_UTF8);
................................................................................
   381    385     assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
   382    386     sqlite3VdbeMemSetInt64(pCtx->pOut, iVal);
   383    387   }
   384    388   void sqlite3_result_null(sqlite3_context *pCtx){
   385    389     assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
   386    390     sqlite3VdbeMemSetNull(pCtx->pOut);
   387    391   }
   388         -void sqlite3_result_pointer(sqlite3_context *pCtx, void *pPtr){
          392  +void sqlite3_result_pointer(sqlite3_context *pCtx, void *pPtr, const char *zPT){
   389    393     Mem *pOut = pCtx->pOut;
   390    394     assert( sqlite3_mutex_held(pOut->db->mutex) );
   391    395     sqlite3VdbeMemSetNull(pOut);
   392         -  sqlite3VdbeMemSetPointer(pOut, pPtr);
          396  +  sqlite3VdbeMemSetPointer(pOut, pPtr, zPT);
   393    397   }
   394    398   void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){
   395    399     Mem *pOut = pCtx->pOut;
   396    400     assert( sqlite3_mutex_held(pOut->db->mutex) );
   397    401     pOut->eSubtype = eSubtype & 0xff;
   398    402     pOut->flags |= MEM_Subtype;
   399    403   }
................................................................................
  1390   1394     Vdbe *p = (Vdbe*)pStmt;
  1391   1395     rc = vdbeUnbind(p, i);
  1392   1396     if( rc==SQLITE_OK ){
  1393   1397       sqlite3_mutex_leave(p->db->mutex);
  1394   1398     }
  1395   1399     return rc;
  1396   1400   }
  1397         -int sqlite3_bind_pointer(sqlite3_stmt *pStmt, int i, void *pPtr){
         1401  +int sqlite3_bind_pointer(sqlite3_stmt *pStmt, int i, void *pPtr,const char *zT){
  1398   1402     int rc;
  1399   1403     Vdbe *p = (Vdbe*)pStmt;
  1400   1404     rc = vdbeUnbind(p, i);
  1401   1405     if( rc==SQLITE_OK ){
  1402         -    sqlite3VdbeMemSetPointer(&p->aVar[i-1], pPtr);
         1406  +    sqlite3VdbeMemSetPointer(&p->aVar[i-1], pPtr, zT);
  1403   1407       sqlite3_mutex_leave(p->db->mutex);
  1404   1408     }
  1405   1409     return rc;
  1406   1410   }
  1407   1411   int sqlite3_bind_text( 
  1408   1412     sqlite3_stmt *pStmt, 
  1409   1413     int i, 

Changes to src/vdbemem.c.

   705    705     }
   706    706   }
   707    707   
   708    708   /*
   709    709   ** Set the value stored in *pMem should already be a NULL.
   710    710   ** Also store a pointer to go with it.
   711    711   */
   712         -void sqlite3VdbeMemSetPointer(Mem *pMem, void *pPtr){
          712  +void sqlite3VdbeMemSetPointer(Mem *pMem, void *pPtr, const char *zPType){
   713    713     assert( pMem->flags==MEM_Null );
   714         -  pMem->flags = MEM_Null|MEM_Subtype;
   715         -  pMem->u.pPtr = pPtr;
   716         -  pMem->eSubtype = 'p';
          714  +  if( zPType ){
          715  +    pMem->flags = MEM_Null|MEM_Subtype|MEM_Term|MEM_Static;
          716  +    pMem->u.pPtr = pPtr;
          717  +    pMem->eSubtype = 'p';
          718  +    pMem->z = (char*)zPType;
          719  +  }
   717    720   }
   718    721   
   719    722   #ifndef SQLITE_OMIT_FLOATING_POINT
   720    723   /*
   721    724   ** Delete any previous value and set the value stored in *pMem to val,
   722    725   ** manifest type REAL.
   723    726   */

Changes to test/shell5.test.

   184    184     catchcmd "test.db" {SELECT b FROM t1 WHERE a='7';}
   185    185   } {0 {Now is the time for all good men to come to the aid of their country.}}
   186    186   
   187    187   # import file with 2 rows, 2 columns and an initial BOM
   188    188   #
   189    189   do_test shell5-1.4.11 {
   190    190     set in [open shell5.csv wb]
   191         -  puts $in "\xef\xbb\xbf2|3"
          191  +  puts -nonewline $in "\xef\xbb\xbf"
          192  +  puts $in "2|3"
   192    193     puts $in "4|5"
   193    194     close $in
   194    195     set res [catchcmd "test.db" {CREATE TABLE t2(x INT, y INT);
   195    196   .import shell5.csv t2
   196    197   .mode quote
   197    198   .header on
   198    199   SELECT * FROM t2;}]