/ Check-in [25c1c7aa]
Login

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

Overview
Comment:Get the build working with -DSQLITE_OMIT_UTF16=1. Ticket #2314. (CVS 3865)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:25c1c7aaa8ef203120c2c242cf72ce4750f78abd
User & Date: drh 2007-04-23 23:56:31
Context
2007-04-24
17:27
When the write_version flag in the database header is larger than what the library understands, make the database read-only. The old behavior was to make the database unreadable. (CVS 3866) check-in: 10648e99 user: drh tags: trunk
2007-04-23
23:56
Get the build working with -DSQLITE_OMIT_UTF16=1. Ticket #2314. (CVS 3865) check-in: 25c1c7aa user: drh tags: trunk
2007-04-21
16:37
Add the ability to turn the FTS2 module into an amalgamation. (CVS 3864) check-in: 94374654 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/loadext.c.

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
# define sqlite3_column_table_name16    0
# define sqlite3_column_origin_name     0
# define sqlite3_column_origin_name16   0
# define sqlite3_table_column_metadata  0
#endif

#ifdef SQLITE_OMIT_AUTHORIZATION
# define sqlite3_set_authorizer     0
#endif

#ifdef SQLITE_OMIT_UTF16
# define sqlite3_bind_text16        0
# define sqlite3_collation_needed16 0
# define sqlite3_column_decltype16  0
# define sqlite3_column_name16      0
# define sqlite3_column_text16      0
# define sqlite3_complete16         0
# define sqlite3_create_collation16 0
# define sqlite3_create_function16  0
# define sqlite3_errmsg16           0
# define sqlite3_open16             0
# define sqlite3_prepare16          0

# define sqlite3_result_error16     0
# define sqlite3_result_text16      0
# define sqlite3_result_text16be    0
# define sqlite3_result_text16le    0
# define sqlite3_value_text16       0
# define sqlite3_value_text16be     0
# define sqlite3_value_text16le     0



#endif

#ifdef SQLITE_OMIT_COMPLETE
# define sqlite3_complete 0
# define sqlite3_complete16 0
#endif








|



|
|
|
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
>
>
>







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
# define sqlite3_column_table_name16    0
# define sqlite3_column_origin_name     0
# define sqlite3_column_origin_name16   0
# define sqlite3_table_column_metadata  0
#endif

#ifdef SQLITE_OMIT_AUTHORIZATION
# define sqlite3_set_authorizer         0
#endif

#ifdef SQLITE_OMIT_UTF16
# define sqlite3_bind_text16            0
# define sqlite3_collation_needed16     0
# define sqlite3_column_decltype16      0
# define sqlite3_column_name16          0
# define sqlite3_column_text16          0
# define sqlite3_complete16             0
# define sqlite3_create_collation16     0
# define sqlite3_create_function16      0
# define sqlite3_errmsg16               0
# define sqlite3_open16                 0
# define sqlite3_prepare16              0
# define sqlite3_prepare16_v2           0
# define sqlite3_result_error16         0
# define sqlite3_result_text16          0
# define sqlite3_result_text16be        0
# define sqlite3_result_text16le        0
# define sqlite3_value_text16           0
# define sqlite3_value_text16be         0
# define sqlite3_value_text16le         0
# define sqlite3_column_database_name16 0
# define sqlite3_column_table_name16    0
# define sqlite3_column_origin_name16   0
#endif

#ifdef SQLITE_OMIT_COMPLETE
# define sqlite3_complete 0
# define sqlite3_complete16 0
#endif

Changes to src/test1.c.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
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
...
738
739
740
741
742
743
744

745
746
747
748

749
750
751
752
753
754
755
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Code for testing all sorts of SQLite interfaces.  This code
** is not included in the SQLite library.  It is used for automated
** testing of the SQLite library.
**
** $Id: test1.c,v 1.238 2007/04/19 11:09:02 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
#include "os.h"
#include <stdlib.h>
#include <string.h>

................................................................................
  z = sqlite3_value_text(argv[0]);
  for(i=0; i<sizeof(zBuf)/2 - 2 && z[i]; i++){
    sprintf(&zBuf[i*2], "%02x", z[i]&0xff);
  }
  zBuf[i*2] = 0;
  sqlite3_result_text(p, (char*)zBuf, -1, SQLITE_TRANSIENT);
}

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++){
    sprintf(&zBuf[i*4], "%04x", z[i]&0xff);
  }
  zBuf[i*4] = 0;
  sqlite3_result_text(p, (char*)zBuf, -1, SQLITE_TRANSIENT);
}


/*
** A structure into which to accumulate text.
*/
struct dstr {
  int nAlloc;  /* Space allocated */
  int nUsed;   /* Space used */
................................................................................
  if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
  rc = sqlite3_create_function(db, "x_coalesce", -1, SQLITE_ANY, 0, 
        t1_ifnullFunc, 0, 0);
  if( rc==SQLITE_OK ){
    rc = sqlite3_create_function(db, "hex8", 1, SQLITE_ANY, 0, 
          hex8Func, 0, 0);
  }

  if( rc==SQLITE_OK ){
    rc = sqlite3_create_function(db, "hex16", 1, SQLITE_ANY, 0, 
          hex16Func, 0, 0);
  }

  if( rc==SQLITE_OK ){
    rc = sqlite3_create_function(db, "tkt2213func", 1, SQLITE_ANY, 0, 
          tkt2213Function, 0, 0);
  }

#ifndef SQLITE_OMIT_UTF16
  /* Use the sqlite3_create_function16() API here. Mainly for fun, but also 







|







 







>











>







 







>




>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
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
...
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Code for testing all sorts of SQLite interfaces.  This code
** is not included in the SQLite library.  It is used for automated
** testing of the SQLite library.
**
** $Id: test1.c,v 1.239 2007/04/23 23:56:31 drh Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
#include "os.h"
#include <stdlib.h>
#include <string.h>

................................................................................
  z = sqlite3_value_text(argv[0]);
  for(i=0; i<sizeof(zBuf)/2 - 2 && z[i]; i++){
    sprintf(&zBuf[i*2], "%02x", z[i]&0xff);
  }
  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++){
    sprintf(&zBuf[i*4], "%04x", z[i]&0xff);
  }
  zBuf[i*4] = 0;
  sqlite3_result_text(p, (char*)zBuf, -1, SQLITE_TRANSIENT);
}
#endif

/*
** A structure into which to accumulate text.
*/
struct dstr {
  int nAlloc;  /* Space allocated */
  int nUsed;   /* Space used */
................................................................................
  if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
  rc = sqlite3_create_function(db, "x_coalesce", -1, SQLITE_ANY, 0, 
        t1_ifnullFunc, 0, 0);
  if( rc==SQLITE_OK ){
    rc = sqlite3_create_function(db, "hex8", 1, SQLITE_ANY, 0, 
          hex8Func, 0, 0);
  }
#ifndef SQLITE_OMIT_UTF16
  if( rc==SQLITE_OK ){
    rc = sqlite3_create_function(db, "hex16", 1, SQLITE_ANY, 0, 
          hex16Func, 0, 0);
  }
#endif
  if( rc==SQLITE_OK ){
    rc = sqlite3_create_function(db, "tkt2213func", 1, SQLITE_ANY, 0, 
          tkt2213Function, 0, 0);
  }

#ifndef SQLITE_OMIT_UTF16
  /* Use the sqlite3_create_function16() API here. Mainly for fun, but also 

Changes to src/test9.c.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
128
129
130
131
132
133
134

135
136
137
138
139

140
141
142
143
144
145
146
...
164
165
166
167
168
169
170

171
172
173
174
175

176
177
178
179
180
181
182
...
198
199
200
201
202
203
204
205
**
*************************************************************************
**
** This file contains obscure tests of the C-interface required
** for completeness. Test code is written in C for these cases
** as there is not much point in binding to Tcl.
**
** $Id: test9.c,v 1.2 2007/03/29 17:28:15 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
#include "os.h"
#include <stdlib.h>
#include <string.h>

................................................................................
  rc = sqlite3_open(":memory:", &db);
  if( rc!=SQLITE_OK ){
    zErrFunction = "sqlite3_open";
    goto error_out;
  }
  sqlite3_close(db);


  rc = sqlite3_collation_needed16(db, 0, 0);
  if( rc!=SQLITE_MISUSE ){
    zErrFunction = "sqlite3_collation_needed16";
    goto error_out;
  }


  rc = sqlite3_collation_needed(db, 0, 0);
  if( rc!=SQLITE_MISUSE ){
    zErrFunction = "sqlite3_collation_needed";
    goto error_out;
  }

................................................................................

  rc = sqlite3_errcode(db);
  if( rc!=SQLITE_MISUSE ){
    zErrFunction = "sqlite3_busy_handler";
    goto error_out;
  }


  rc = sqlite3_prepare16(db, 0, 0, 0, 0);
  if( rc!=SQLITE_MISUSE ){
    zErrFunction = "sqlite3_prepare16";
    goto error_out;
  }


  return TCL_OK;

error_out:
  Tcl_ResetResult(interp);
  Tcl_AppendResult(interp, "Error testing function: ", zErrFunction, 0);
  return TCL_ERROR;
................................................................................
  int i;
  for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){
    Tcl_CreateObjCommand(interp, aObjCmd[i].zName, 
        aObjCmd[i].xProc, aObjCmd[i].clientData, 0);
  }
  return TCL_OK;
}








|







 







>





>







 







>





>







 







<
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
...
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
...
202
203
204
205
206
207
208

**
*************************************************************************
**
** This file contains obscure tests of the C-interface required
** for completeness. Test code is written in C for these cases
** as there is not much point in binding to Tcl.
**
** $Id: test9.c,v 1.3 2007/04/23 23:56:32 drh Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
#include "os.h"
#include <stdlib.h>
#include <string.h>

................................................................................
  rc = sqlite3_open(":memory:", &db);
  if( rc!=SQLITE_OK ){
    zErrFunction = "sqlite3_open";
    goto error_out;
  }
  sqlite3_close(db);

#ifndef SQLITE_OMIT_UTF16
  rc = sqlite3_collation_needed16(db, 0, 0);
  if( rc!=SQLITE_MISUSE ){
    zErrFunction = "sqlite3_collation_needed16";
    goto error_out;
  }
#endif

  rc = sqlite3_collation_needed(db, 0, 0);
  if( rc!=SQLITE_MISUSE ){
    zErrFunction = "sqlite3_collation_needed";
    goto error_out;
  }

................................................................................

  rc = sqlite3_errcode(db);
  if( rc!=SQLITE_MISUSE ){
    zErrFunction = "sqlite3_busy_handler";
    goto error_out;
  }

#ifndef SQLITE_OMIT_UTF16
  rc = sqlite3_prepare16(db, 0, 0, 0, 0);
  if( rc!=SQLITE_MISUSE ){
    zErrFunction = "sqlite3_prepare16";
    goto error_out;
  }
#endif

  return TCL_OK;

error_out:
  Tcl_ResetResult(interp);
  Tcl_AppendResult(interp, "Error testing function: ", zErrFunction, 0);
  return TCL_ERROR;
................................................................................
  int i;
  for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){
    Tcl_CreateObjCommand(interp, aObjCmd[i].zName, 
        aObjCmd[i].xProc, aObjCmd[i].clientData, 0);
  }
  return TCL_OK;
}

Changes to test/misc6.test.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
26
27
28
29
30
31
32

33
34
35
36
37
38
39
40
41
42
43

44
45
46
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests to make sure sqlite3_value_text()
# always returns a null-terminated string.
#
# $Id: misc6.test,v 1.2 2006/09/04 18:54:14 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

do_test misc6-1.1 {
  set DB [sqlite3_connection_pointer db]
  sqlite3_create_function $DB
................................................................................
  set sqlite_static_bind_nbyte 5
  sqlite_bind $STMT 1 {} static-nbytes
  sqlite3_step $STMT
} SQLITE_ROW
do_test misc6-1.2 {
  sqlite3_column_text $STMT 0
} {3031323334}

do_test misc6-1.3 {
  sqlite3_finalize $STMT
  set STMT [sqlite3_prepare $DB {SELECT hex16(?)} -1 DUMMY]
  set sqlite_static_bind_value {0123456789}
  set sqlite_static_bind_nbyte 5
  sqlite_bind $STMT 1 {} static-nbytes
  sqlite3_step $STMT
} SQLITE_ROW
do_test misc6-1.4 {
  sqlite3_column_text $STMT 0
} {00300031003200330034}

sqlite3_finalize $STMT

finish_test







|







 







>
|
|
|
|
|
|
|
|
|
|
|
>



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests to make sure sqlite3_value_text()
# always returns a null-terminated string.
#
# $Id: misc6.test,v 1.3 2007/04/23 23:56:32 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

do_test misc6-1.1 {
  set DB [sqlite3_connection_pointer db]
  sqlite3_create_function $DB
................................................................................
  set sqlite_static_bind_nbyte 5
  sqlite_bind $STMT 1 {} static-nbytes
  sqlite3_step $STMT
} SQLITE_ROW
do_test misc6-1.2 {
  sqlite3_column_text $STMT 0
} {3031323334}
ifcapable utf16 {
  do_test misc6-1.3 {
    sqlite3_finalize $STMT
    set STMT [sqlite3_prepare $DB {SELECT hex16(?)} -1 DUMMY]
    set sqlite_static_bind_value {0123456789}
    set sqlite_static_bind_nbyte 5
    sqlite_bind $STMT 1 {} static-nbytes
    sqlite3_step $STMT
  } SQLITE_ROW
  do_test misc6-1.4 {
    sqlite3_column_text $STMT 0
  } {00300031003200330034}
}
sqlite3_finalize $STMT

finish_test