SQLite4
Check-in [c7c533dddc]
Not logged in

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

Overview
Comment:Remove legacy API functions: complete16(), errmsg16(), column_name16(), column_database_name16(), column_table_name16(), column_origin_name16(), column_decltype16(), create_function16() and collation_needed16().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c7c533dddcf39d9a47276892573032cb5ff7c257
User & Date: dan 2013-06-11 16:48:56
Context
2013-06-11
17:27
Add a note to www/porting.wiki describing the changes to utf-16 support. check-in: 5cd50e225c user: dan tags: trunk
16:48
Remove legacy API functions: complete16(), errmsg16(), column_name16(), column_database_name16(), column_table_name16(), column_origin_name16(), column_decltype16(), create_function16() and collation_needed16(). check-in: c7c533dddc user: dan tags: trunk
15:18
Add tests and minor fixes for the sqlite4_translate() API. check-in: 211c1baef7 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/main.c.

   709    709       FuncDef *p = sqlite4FindFunction(db, zFunc, -1, n, enc, 0);
   710    710       p->bMatchinfo = 1;
   711    711     }
   712    712     rc = sqlite4ApiExit(db, rc);
   713    713     sqlite4_mutex_leave(db->mutex);
   714    714     return rc;
   715    715   }
   716         -
   717         -#ifndef SQLITE4_OMIT_UTF16
   718         -int sqlite4_create_function16(
   719         -  sqlite4 *db,
   720         -  const void *zFunctionName,
   721         -  int nArg,
   722         -  int enc,
   723         -  void *p,
   724         -  void (*xFunc)(sqlite4_context*,int,sqlite4_value**),
   725         -  void (*xStep)(sqlite4_context*,int,sqlite4_value**),
   726         -  void (*xFinal)(sqlite4_context*),
   727         -  void (*xDestroy)(void *)
   728         -){
   729         -  int rc;
   730         -  char *zFunc8;
   731         -  sqlite4_mutex_enter(db->mutex);
   732         -  assert( !db->mallocFailed );
   733         -  zFunc8 = sqlite4Utf16to8(db, zFunctionName, -1, SQLITE4_UTF16NATIVE);
   734         -  rc = createFunctionDestructor(
   735         -      db, zFunc8, nArg, enc, p, xFunc, xStep, xFinal, xDestroy
   736         -  );
   737         -  sqlite4DbFree(db, zFunc8);
   738         -  rc = sqlite4ApiExit(db, rc);
   739         -  sqlite4_mutex_leave(db->mutex);
   740         -  return rc;
   741         -}
   742         -#endif
   743         -
   744    716   
   745    717   /*
   746    718   ** Declare that a function has been overloaded by a virtual table.
   747    719   **
   748    720   ** If the function already exists as a regular global function, then
   749    721   ** this routine is a no-op.  If the function does not exist, then create
   750    722   ** a new one that always throws a run-time error.  
................................................................................
   868    840         z = sqlite4ErrStr(db->errCode);
   869    841       }
   870    842     }
   871    843     sqlite4_mutex_leave(db->mutex);
   872    844     return z;
   873    845   }
   874    846   
   875         -#ifndef SQLITE4_OMIT_UTF16
   876         -/*
   877         -** Return UTF-16 encoded English language explanation of the most recent
   878         -** error.
   879         -*/
   880         -const void *sqlite4_errmsg16(sqlite4 *db){
   881         -  static const u16 outOfMem[] = {
   882         -    'o', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y', 0
   883         -  };
   884         -  static const u16 misuse[] = {
   885         -    'l', 'i', 'b', 'r', 'a', 'r', 'y', ' ', 
   886         -    'r', 'o', 'u', 't', 'i', 'n', 'e', ' ', 
   887         -    'c', 'a', 'l', 'l', 'e', 'd', ' ', 
   888         -    'o', 'u', 't', ' ', 
   889         -    'o', 'f', ' ', 
   890         -    's', 'e', 'q', 'u', 'e', 'n', 'c', 'e', 0
   891         -  };
   892         -
   893         -  const void *z;
   894         -  if( !db ){
   895         -    return (void *)outOfMem;
   896         -  }
   897         -  if( !sqlite4SafetyCheckSickOrOk(db) ){
   898         -    return (void *)misuse;
   899         -  }
   900         -  sqlite4_mutex_enter(db->mutex);
   901         -  if( db->mallocFailed ){
   902         -    z = (void *)outOfMem;
   903         -  }else{
   904         -    z = sqlite4_value_text16(db->pErr, 0);
   905         -    if( z==0 ){
   906         -      sqlite4ValueSetStr(db->pErr, -1, sqlite4ErrStr(db->errCode),
   907         -           SQLITE4_UTF8, SQLITE4_STATIC, 0);
   908         -      z = sqlite4_value_text16(db->pErr, 0);
   909         -    }
   910         -    /* A malloc() may have failed within the call to sqlite4_value_text16()
   911         -    ** above. If this is the case, then the db->mallocFailed flag needs to
   912         -    ** be cleared before returning. Do this directly, instead of via
   913         -    ** sqlite4ApiExit(), to avoid setting the database handle error message.
   914         -    */
   915         -    db->mallocFailed = 0;
   916         -  }
   917         -  sqlite4_mutex_leave(db->mutex);
   918         -  return z;
   919         -}
   920         -#endif /* SQLITE4_OMIT_UTF16 */
   921         -
   922    847   /*
   923    848   ** Return the most recent error code generated by an SQLite routine. If NULL is
   924    849   ** passed to this function, we assume a malloc() failed during sqlite4_open().
   925    850   */
   926    851   int sqlite4_errcode(sqlite4 *db){
   927    852     if( db && !sqlite4SafetyCheckSickOrOk(db) ){
   928    853       return SQLITE4_MISUSE_BKPT;
................................................................................
  1547   1472     db->xCollNeeded = xCollNeeded;
  1548   1473     db->xCollNeeded16 = 0;
  1549   1474     db->pCollNeededArg = pCollNeededArg;
  1550   1475     sqlite4_mutex_leave(db->mutex);
  1551   1476     return SQLITE4_OK;
  1552   1477   }
  1553   1478   
  1554         -#ifndef SQLITE4_OMIT_UTF16
  1555         -/*
  1556         -** Register a collation sequence factory callback with the database handle
  1557         -** db. Replace any previously installed collation sequence factory.
  1558         -*/
  1559         -int sqlite4_collation_needed16(
  1560         -  sqlite4 *db, 
  1561         -  void(*xCollNeeded16)(void*,sqlite4*,int eTextRep,const void*),
  1562         -  void *pCollNeededArg
  1563         -){
  1564         -  sqlite4_mutex_enter(db->mutex);
  1565         -  db->xCollNeeded = 0;
  1566         -  db->xCollNeeded16 = xCollNeeded16;
  1567         -  db->pCollNeededArg = pCollNeededArg;
  1568         -  sqlite4_mutex_leave(db->mutex);
  1569         -  return SQLITE4_OK;
  1570         -}
  1571         -#endif /* SQLITE4_OMIT_UTF16 */
  1572         -
  1573   1479   /*
  1574   1480   ** Test to see whether or not the database connection is currently within
  1575   1481   ** an explicitly started transaction (BEGIN/COMMIT block). Return non-zero 
  1576   1482   ** if it is and FALSE otherwise. Explicit transactions are opened by a 
  1577   1483   ** BEGIN statement and concluded by the next COMMIT or ROLLBACK.
  1578   1484   */
  1579   1485   int sqlite4_db_transaction_status(sqlite4 *db){

Changes to src/sqlite.h.in.

   966    966   ** is running then bad things will likely happen.
   967    967   */
   968    968   void sqlite4_interrupt(sqlite4*);
   969    969   
   970    970   /*
   971    971   ** CAPIREF: Determine If An SQL Statement Is Complete
   972    972   **
   973         -** These routines are useful during command-line input to determine if the
   974         -** currently entered text seems to form a complete SQL statement or
   975         -** if additional input is needed before sending the text into
   976         -** SQLite for parsing.  ^These routines return 1 if the input string
   977         -** appears to be a complete SQL statement.  ^A statement is judged to be
   978         -** complete if it ends with a semicolon token and is not a prefix of a
   979         -** well-formed CREATE TRIGGER statement.  ^Semicolons that are embedded within
   980         -** string literals or quoted identifier names or comments are not
   981         -** independent tokens (they are part of the token in which they are
   982         -** embedded) and thus do not count as a statement terminator.  ^Whitespace
   983         -** and comments that follow the final semicolon are ignored.
   984         -**
   985         -** ^These routines return 0 if the statement is incomplete.  ^If a
   986         -** memory allocation fails, then SQLITE4_NOMEM is returned.
   987         -**
   988         -** ^These routines do not parse the SQL statements thus
   989         -** will not detect syntactically incorrect SQL.
   990         -**
   991         -** ^(If SQLite has not been initialized using [sqlite4_initialize()] prior 
   992         -** to invoking sqlite4_complete16() then sqlite4_initialize() is invoked
   993         -** automatically by sqlite4_complete16().  If that initialization fails,
   994         -** then the return value from sqlite4_complete16() will be non-zero
   995         -** regardless of whether or not the input SQL is complete.)^
   996         -**
   997         -** The input to [sqlite4_complete()] must be a zero-terminated
   998         -** UTF-8 string.
   999         -**
  1000         -** The input to [sqlite4_complete16()] must be a zero-terminated
  1001         -** UTF-16 string in native byte order.
  1002         -*/
  1003         -int sqlite4_complete(const char *sql);
  1004         -int sqlite4_complete16(const void *sql);
          973  +** This routine is useful when processing command-line input to determine 
          974  +** if the currently entered text appears to form a complete SQL statement 
          975  +** or if additional input is needed before sending the text into
          976  +** SQLite for parsing.  ^This routine returns 1 if the input string
          977  +** appears to be a complete SQL statement, or 0 otherwise. ^A statement 
          978  +** is judged to be complete if it ends with a semicolon token and is not 
          979  +** a prefix of a well-formed CREATE TRIGGER statement. ^Semicolons that 
          980  +** are embedded within string literals or quoted identifier names or 
          981  +** comments are not independent tokens (they are part of the token in which 
          982  +** they are embedded) and thus do not count as a statement terminator. 
          983  +** ^Whitespace and comments that follow the final semicolon are ignored.
          984  +**
          985  +** ^This routine does not parse the SQL statements thus will not detect 
          986  +** syntactically incorrect SQL.
          987  +**
          988  +** The argument passed to [sqlite4_complete()] must be a pointer to a 
          989  +** zero-terminated UTF-8 string.
          990  +*/
          991  +int sqlite4_complete(const char *sql);
  1005    992   
  1006    993   
  1007    994   /*
  1008    995   ** CAPIREF: Formatted String Printing Functions
  1009    996   **
  1010    997   ** These routines are work-alikes of the "printf()" family of functions
  1011    998   ** from the standard C library.
................................................................................
  1447   1434   **
  1448   1435   ** ^The sqlite4_errcode() interface returns the numeric 
  1449   1436   ** [extended result code] for the most recent failed sqlite4_* API call
  1450   1437   ** associated with a [database connection]. If a prior API call failed
  1451   1438   ** but the most recent API call succeeded, the return value from
  1452   1439   ** sqlite4_errcode() is undefined.
  1453   1440   **
  1454         -** ^The sqlite4_errmsg() and sqlite4_errmsg16() return English-language
  1455         -** text that describes the error, as either UTF-8 or UTF-16 respectively.
  1456         -** ^(Memory to hold the error message string is managed internally.
  1457         -** The application does not need to worry about freeing the result.
  1458         -** However, the error string might be overwritten or deallocated by
  1459         -** subsequent calls to other SQLite interface functions.)^
         1441  +** ^The sqlite4_errmsg() routine returns English-language text that 
         1442  +** describes the error, as a UTF-8 encoded string. ^(Memory to hold the 
         1443  +** error message string is managed internally. The application does not 
         1444  +** need to worry about freeing the result. However, the error string 
         1445  +** might be overwritten or deallocated by subsequent calls to other 
         1446  +** SQLite interface functions.)^
  1460   1447   **
  1461   1448   ** When the serialized [threading mode] is in use, it might be the
  1462   1449   ** case that a second error occurs on a separate thread in between
  1463   1450   ** the time of the first error and the call to these interfaces.
  1464   1451   ** When that happens, the second error will be reported since these
  1465   1452   ** interfaces always report the most recent result.  To avoid
  1466   1453   ** this, each thread can obtain exclusive use of the [database connection] D
  1467   1454   ** by invoking [sqlite4_mutex_enter]([sqlite4_db_mutex](D)) before beginning
  1468   1455   ** to use D and invoking [sqlite4_mutex_leave]([sqlite4_db_mutex](D)) after
  1469   1456   ** all calls to the interfaces listed here are completed.
  1470   1457   **
  1471         -** If an interface fails with SQLITE4_MISUSE, that means the interface
  1472         -** was invoked incorrectly by the application.  In that case, the
         1458  +** If an SQLite API call fails with SQLITE4_MISUSE, that means the 
         1459  +** interface was invoked incorrectly by the application. In that case, the
  1473   1460   ** error code and message may or may not be set.
  1474   1461   */
  1475   1462   int sqlite4_errcode(sqlite4 *db);
  1476   1463   const char *sqlite4_errmsg(sqlite4*);
  1477         -const void *sqlite4_errmsg16(sqlite4*);
  1478   1464   
  1479   1465   /*
  1480   1466   ** CAPIREF: SQL Statement Object
  1481   1467   ** KEYWORDS: {prepared statement} {prepared statements}
  1482   1468   **
  1483   1469   ** An instance of this object represents a single SQL statement.
  1484   1470   ** This object is variously known as a "prepared statement" or a
................................................................................
  1903   1889   ** See also: [sqlite4_data_count()]
  1904   1890   */
  1905   1891   int sqlite4_column_count(sqlite4_stmt *pStmt);
  1906   1892   
  1907   1893   /*
  1908   1894   ** CAPIREF: Column Names In A Result Set
  1909   1895   **
  1910         -** ^These routines return the name assigned to a particular column
  1911         -** in the result set of a [SELECT] statement.  ^The sqlite4_column_name()
  1912         -** interface returns a pointer to a zero-terminated UTF-8 string
  1913         -** and sqlite4_column_name16() returns a pointer to a zero-terminated
  1914         -** UTF-16 string.  ^The first parameter is the [prepared statement]
  1915         -** that implements the [SELECT] statement. ^The second parameter is the
  1916         -** column number.  ^The leftmost column is number 0.
  1917         -**
  1918         -** ^The returned string pointer is valid until either the [prepared statement]
  1919         -** is destroyed by [sqlite4_finalize()] or until the statement is automatically
  1920         -** reprepared by the first call to [sqlite4_step()] for a particular run
  1921         -** or until the next call to
  1922         -** sqlite4_column_name() or sqlite4_column_name16() on the same column.
  1923         -**
  1924         -** ^If sqlite4_malloc() fails during the processing of either routine
  1925         -** (for example during a conversion from UTF-8 to UTF-16) then a
  1926         -** NULL pointer is returned.
         1896  +** ^This routine returns the name assigned to a particular column
         1897  +** in the result set of a [SELECT] statement. ^The first parameter is the
         1898  +** [prepared statement] that implements the [SELECT] statement. ^The second
         1899  +** parameter is the column number. ^The leftmost column is number 0.
  1927   1900   **
  1928   1901   ** ^The name of a result column is the value of the "AS" clause for
  1929   1902   ** that column, if there is an AS clause.  If there is no AS clause
  1930   1903   ** then the name of the column is unspecified and may change from
  1931   1904   ** one release of SQLite to the next.
         1905  +**
         1906  +** ^The returned string pointer is valid until either the [prepared statement]
         1907  +** is destroyed by [sqlite4_finalize()] or until the statement is automatically
         1908  +** reprepared by the first call to [sqlite4_step()] for a particular run.
         1909  +**
         1910  +** ^If a memory allocation fails during the processing of this routine
         1911  +** then a NULL pointer is returned.
  1932   1912   */
  1933   1913   const char *sqlite4_column_name(sqlite4_stmt*, int N);
  1934         -const void *sqlite4_column_name16(sqlite4_stmt*, int N);
  1935   1914   
  1936   1915   /*
  1937   1916   ** CAPIREF: Source Of Data In A Query Result
  1938   1917   **
  1939   1918   ** ^These routines provide a means to determine the database, table, and
  1940   1919   ** table column that is the origin of a particular result column in
  1941         -** [SELECT] statement.
  1942         -** ^The name of the database or table or column can be returned as
  1943         -** either a UTF-8 or UTF-16 string.  ^The _database_ routines return
  1944         -** the database name, the _table_ routines return the table name, and
  1945         -** the origin_ routines return the column name.
         1920  +** [SELECT] statement. Specifically, the sqlite4_column_database_name()
         1921  +** routine returns the database name, the _table_name() routine returns
         1922  +** the table name and _origin_name() returns the column name.
  1946   1923   ** ^The returned string is valid until the [prepared statement] is destroyed
  1947   1924   ** using [sqlite4_finalize()] or until the statement is automatically
  1948         -** reprepared by the first call to [sqlite4_step()] for a particular run
  1949         -** or until the same information is requested
  1950         -** again in a different encoding.
         1925  +** reprepared by the first call to [sqlite4_step()] for a particular run.
  1951   1926   **
  1952   1927   ** ^The names returned are the original un-aliased names of the
  1953   1928   ** database, table, and column.
  1954   1929   **
  1955   1930   ** ^The first argument to these interfaces is a [prepared statement].
  1956   1931   ** ^These functions return information about the Nth result column returned by
  1957   1932   ** the statement, where N is the second function argument.
................................................................................
  1959   1934   **
  1960   1935   ** ^If the Nth column returned by the statement is an expression or
  1961   1936   ** subquery and is not a column value, then all of these functions return
  1962   1937   ** NULL.  ^These routine might also return NULL if a memory allocation error
  1963   1938   ** occurs.  ^Otherwise, they return the name of the attached database, table,
  1964   1939   ** or column that query result column was extracted from.
  1965   1940   **
  1966         -** ^As with all other SQLite APIs, those whose names end with "16" return
  1967         -** UTF-16 encoded strings and the other functions return UTF-8.
  1968         -**
  1969   1941   ** ^These APIs are only available if the library was compiled with the
  1970   1942   ** [SQLITE4_ENABLE_COLUMN_METADATA] C-preprocessor symbol.
  1971   1943   **
  1972   1944   ** If two or more threads call one or more of these routines against the same
  1973   1945   ** prepared statement and column at the same time then the results are
  1974   1946   ** undefined.
  1975   1947   **
  1976   1948   ** If two or more threads call one or more
  1977   1949   ** [sqlite4_column_database_name | column metadata interfaces]
  1978   1950   ** for the same [prepared statement] and result column
  1979   1951   ** at the same time then the results are undefined.
  1980   1952   */
  1981   1953   const char *sqlite4_column_database_name(sqlite4_stmt*,int);
  1982         -const void *sqlite4_column_database_name16(sqlite4_stmt*,int);
  1983   1954   const char *sqlite4_column_table_name(sqlite4_stmt*,int);
  1984         -const void *sqlite4_column_table_name16(sqlite4_stmt*,int);
  1985   1955   const char *sqlite4_column_origin_name(sqlite4_stmt*,int);
  1986         -const void *sqlite4_column_origin_name16(sqlite4_stmt*,int);
  1987   1956   
  1988   1957   /*
  1989   1958   ** CAPIREF: Declared Datatype Of A Query Result
  1990   1959   **
  1991   1960   ** ^(The first parameter is a [prepared statement].
  1992   1961   ** If this statement is a [SELECT] statement and the Nth column of the
  1993   1962   ** returned result set of that [SELECT] is a table column (not an
................................................................................
  2011   1980   ** is declared to contain a particular type does not mean that the
  2012   1981   ** data stored in that column is of the declared type.  SQLite is
  2013   1982   ** strongly typed, but the typing is dynamic not static.  ^Type
  2014   1983   ** is associated with individual values, not with the containers
  2015   1984   ** used to hold those values.
  2016   1985   */
  2017   1986   const char *sqlite4_column_decltype(sqlite4_stmt*,int);
  2018         -const void *sqlite4_column_decltype16(sqlite4_stmt*,int);
  2019   1987   
  2020   1988   /*
  2021   1989   ** CAPIREF: Evaluate An SQL Statement
  2022   1990   **
  2023   1991   ** After a [prepared statement] has been prepared using [sqlite4_prepare()],
  2024   1992   ** this function must be called one or more times to evaluate the statement.
  2025   1993   **
................................................................................
  2291   2259   ** ^The [sqlite4_reset(S)] interface does not change the values
  2292   2260   ** of any [sqlite4_bind_blob|bindings] on the [prepared statement] S.
  2293   2261   */
  2294   2262   int sqlite4_reset(sqlite4_stmt *pStmt);
  2295   2263   
  2296   2264   /*
  2297   2265   ** CAPIREF: Create Or Redefine SQL Functions
  2298         -** KEYWORDS: {function creation routines}
         2266  +** KEYWORDS: {function creation routine}
  2299   2267   ** KEYWORDS: {application-defined SQL function}
  2300   2268   ** KEYWORDS: {application-defined SQL functions}
  2301   2269   **
  2302         -** ^These functions (collectively known as "function creation routines")
  2303         -** are used to add new SQL scalar or aggregate functions. The only 
  2304         -** difference between the two routines is the text encoding expected for 
  2305         -** the second parameter (the name of the function being created).
         2270  +** ^This function is used to add new SQL scalar or aggregate functions. 
  2306   2271   **
  2307   2272   ** ^The first parameter is the [database connection] to which the SQL
  2308   2273   ** function is to be added.  ^If an application uses more than one database
  2309   2274   ** connection then application-defined SQL functions must be added
  2310   2275   ** to each database connection separately.
  2311   2276   **
  2312   2277   ** ^The second parameter is the name of the SQL function to be created or
  2313   2278   ** redefined.  ^The length of the name is limited to 255 bytes in a UTF-8
  2314   2279   ** representation, exclusive of the zero-terminator.  ^Note that the name
  2315         -** length limit is in UTF-8 bytes, not characters nor UTF-16 bytes.  
  2316         -** ^Any attempt to create a function with a longer name
  2317         -** will result in [SQLITE4_MISUSE] being returned.
         2280  +** length limit is in bytes, not characters. ^Any attempt to create a 
         2281  +** function with a longer name will result in [SQLITE4_MISUSE] being returned.
  2318   2282   **
  2319   2283   ** ^The third parameter (nArg) is the number of arguments that the SQL 
  2320   2284   ** function or aggregate takes. ^If this parameter is -1, then the SQL 
  2321   2285   ** function or aggregate may take any number of arguments between 0 and 
  2322   2286   ** the limit set by [sqlite4_limit]([SQLITE4_LIMIT_FUNCTION_ARG]).  If 
  2323   2287   ** the third parameter is less than -1 or greater than 127 then the 
  2324   2288   ** behavior is undefined.
................................................................................
  2376   2340   ** close the database connection nor finalize or reset the prepared
  2377   2341   ** statement in which the function is running.
  2378   2342   */
  2379   2343   int sqlite4_create_function(
  2380   2344     sqlite4 *db,
  2381   2345     const char *zFunctionName,
  2382   2346     int nArg,
  2383         -  int eTextRep,
  2384         -  void *pApp,
  2385         -  void (*xFunc)(sqlite4_context*,int,sqlite4_value**),
  2386         -  void (*xStep)(sqlite4_context*,int,sqlite4_value**),
  2387         -  void (*xFinal)(sqlite4_context*),
  2388         -  void(*xDestroy)(void*)
  2389         -);
  2390         -int sqlite4_create_function16(
  2391         -  sqlite4 *db,
  2392         -  const void *zFunctionName,
  2393         -  int nArg,
  2394   2347     int eTextRep,
  2395   2348     void *pApp,
  2396   2349     void (*xFunc)(sqlite4_context*,int,sqlite4_value**),
  2397   2350     void (*xStep)(sqlite4_context*,int,sqlite4_value**),
  2398   2351     void (*xFinal)(sqlite4_context*),
  2399   2352     void(*xDestroy)(void*)
  2400   2353   );
................................................................................
  2821   2774   ** CAPIREF: Collation Needed Callbacks
  2822   2775   **
  2823   2776   ** ^To avoid having to register all collation sequences before a database
  2824   2777   ** can be used, a single callback function may be registered with the
  2825   2778   ** [database connection] to be invoked whenever an undefined collation
  2826   2779   ** sequence is required.
  2827   2780   **
  2828         -** ^If the function is registered using the sqlite4_collation_needed() API,
  2829         -** then it is passed the names of undefined collation sequences as strings
  2830         -** encoded in UTF-8. ^If sqlite4_collation_needed16() is used,
  2831         -** the names are passed as UTF-16 in machine native byte order.
  2832         -** ^A call to either function replaces the existing collation-needed callback.
  2833         -**
  2834   2781   ** ^(When the callback is invoked, the first argument passed is a copy
  2835   2782   ** of the second argument to sqlite4_collation_needed() or
  2836   2783   ** sqlite4_collation_needed16().  The second argument is the database
  2837   2784   ** connection.  The third argument is one of [SQLITE4_UTF8], [SQLITE4_UTF16BE],
  2838   2785   ** or [SQLITE4_UTF16LE], indicating the most desirable form of the collation
  2839   2786   ** sequence function required.  The fourth parameter is the name of the
  2840   2787   ** required collation sequence.)^
................................................................................
  2843   2790   ** [sqlite4_create_collation()].
  2844   2791   */
  2845   2792   int sqlite4_collation_needed(
  2846   2793     sqlite4*, 
  2847   2794     void(*)(void*,sqlite4*,int eTextRep,const char*),
  2848   2795     void* 
  2849   2796   );
  2850         -int sqlite4_collation_needed16(
  2851         -  sqlite4*, 
  2852         -  void(*)(void*,sqlite4*,int eTextRep,const void*),
  2853         -  void*
  2854         -);
  2855   2797   
  2856   2798   /*
  2857   2799   ** CAPIREF: Suspend Execution For A Short Time
  2858   2800   **
  2859   2801   ** The sqlite4_sleep() function causes the current thread to suspend execution
  2860   2802   ** for at least a number of milliseconds specified in its parameter.
  2861   2803   **

Changes to src/vdbeapi.c.

   846    846   ** Return the name of the Nth column of the result set returned by SQL
   847    847   ** statement pStmt.
   848    848   */
   849    849   const char *sqlite4_column_name(sqlite4_stmt *pStmt, int N){
   850    850     return columnName(
   851    851         pStmt, N, (const void*(*)(Mem*, int*))sqlite4_value_text, COLNAME_NAME);
   852    852   }
   853         -#ifndef SQLITE4_OMIT_UTF16
   854         -const void *sqlite4_column_name16(sqlite4_stmt *pStmt, int N){
   855         -  return columnName(
   856         -      pStmt, N, (const void*(*)(Mem*, int*))sqlite4_value_text16, COLNAME_NAME);
   857         -}
   858         -#endif
   859    853   
   860    854   /*
   861    855   ** Constraint:  If you have ENABLE_COLUMN_METADATA then you must
   862    856   ** not define OMIT_DECLTYPE.
   863    857   */
   864    858   #if defined(SQLITE4_OMIT_DECLTYPE) && defined(SQLITE4_ENABLE_COLUMN_METADATA)
   865    859   # error "Must not define both SQLITE4_OMIT_DECLTYPE \
................................................................................
   871    865   ** Return the column declaration type (if applicable) of the 'i'th column
   872    866   ** of the result set of SQL statement pStmt.
   873    867   */
   874    868   const char *sqlite4_column_decltype(sqlite4_stmt *pStmt, int N){
   875    869     return columnName(pStmt, 
   876    870         N, (const void*(*)(Mem*, int*))sqlite4_value_text, COLNAME_DECLTYPE);
   877    871   }
   878         -#ifndef SQLITE4_OMIT_UTF16
   879         -const void *sqlite4_column_decltype16(sqlite4_stmt *pStmt, int N){
   880         -  return columnName(pStmt, 
   881         -      N, (const void*(*)(Mem*, int*))sqlite4_value_text16, COLNAME_DECLTYPE);
   882         -}
   883         -#endif /* SQLITE4_OMIT_UTF16 */
   884    872   #endif /* SQLITE4_OMIT_DECLTYPE */
   885    873   
   886    874   #ifdef SQLITE4_ENABLE_COLUMN_METADATA
   887    875   /*
   888    876   ** Return the name of the database from which a result column derives.
   889    877   ** NULL is returned if the result column is an expression or constant or
   890    878   ** anything else which is not an unabiguous reference to a database column.
   891    879   */
   892    880   const char *sqlite4_column_database_name(sqlite4_stmt *pStmt, int N){
   893    881     return columnName(pStmt, 
   894    882         N, (const void*(*)(Mem*, int*))sqlite4_value_text, COLNAME_DATABASE);
   895    883   }
   896         -#ifndef SQLITE4_OMIT_UTF16
   897         -const void *sqlite4_column_database_name16(sqlite4_stmt *pStmt, int N){
   898         -  return columnName(pStmt, 
   899         -      N, (const void*(*)(Mem*, int*))sqlite4_value_text16, COLNAME_DATABASE);
   900         -}
   901         -#endif /* SQLITE4_OMIT_UTF16 */
   902    884   
   903    885   /*
   904    886   ** Return the name of the table from which a result column derives.
   905    887   ** NULL is returned if the result column is an expression or constant or
   906    888   ** anything else which is not an unabiguous reference to a database column.
   907    889   */
   908    890   const char *sqlite4_column_table_name(sqlite4_stmt *pStmt, int N){
   909    891     return columnName(pStmt, 
   910    892         N, (const void*(*)(Mem*, int*))sqlite4_value_text, COLNAME_TABLE);
   911    893   }
   912         -#ifndef SQLITE4_OMIT_UTF16
   913         -const void *sqlite4_column_table_name16(sqlite4_stmt *pStmt, int N){
   914         -  return columnName(pStmt, 
   915         -      N, (const void*(*)(Mem*, int*))sqlite4_value_text16, COLNAME_TABLE);
   916         -}
   917         -#endif /* SQLITE4_OMIT_UTF16 */
   918    894   
   919    895   /*
   920    896   ** Return the name of the table column from which a result column derives.
   921    897   ** NULL is returned if the result column is an expression or constant or
   922    898   ** anything else which is not an unabiguous reference to a database column.
   923    899   */
   924    900   const char *sqlite4_column_origin_name(sqlite4_stmt *pStmt, int N){
   925    901     return columnName(pStmt, 
   926    902         N, (const void*(*)(Mem*, int*))sqlite4_value_text, COLNAME_COLUMN);
   927    903   }
   928         -#ifndef SQLITE4_OMIT_UTF16
   929         -const void *sqlite4_column_origin_name16(sqlite4_stmt *pStmt, int N){
   930         -  return columnName(pStmt, 
   931         -      N, (const void*(*)(Mem*, int*))sqlite4_value_text16, COLNAME_COLUMN);
   932         -}
   933         -#endif /* SQLITE4_OMIT_UTF16 */
   934    904   #endif /* SQLITE4_ENABLE_COLUMN_METADATA */
   935    905   
   936    906   
   937    907   /******************************* sqlite4_bind_  ***************************
   938    908   ** 
   939    909   ** Routines used to attach values to wildcards in a compiled SQL statement.
   940    910   */

Changes to test/bind.test.

   373    373   # Test that the 'out of range' error works.
   374    374   do_test bind-8.1 {
   375    375     catch { sqlite4_bind_null $VM 0 }
   376    376   } {1}
   377    377   do_test bind-8.2 {
   378    378     sqlite4_errmsg $DB
   379    379   } {bind or column index out of range}
   380         -ifcapable {utf16} {
   381         -  do_test bind-8.3 {
   382         -    encoding convertfrom unicode [sqlite4_errmsg16 $DB]
   383         -  } {bind or column index out of range}
   384         -}
          380  +do_test bind-8.3 {
          381  +  sqlite4_errmsg $DB
          382  +} {bind or column index out of range}
   385    383   do_test bind-8.4 {
   386    384     sqlite4_bind_null $VM 1 
   387    385     sqlite4_errmsg $DB
   388    386   } {not an error}
   389    387   do_test bind-8.5 {
   390    388     catch { sqlite4_bind_null $VM 4 }
   391    389   } {1}
   392    390   do_test bind-8.6 {
   393    391     sqlite4_errmsg $DB
   394    392   } {bind or column index out of range}
   395         -ifcapable {utf16} {
   396         -  do_test bind-8.7 {
   397         -    encoding convertfrom unicode [sqlite4_errmsg16 $DB]
   398         -  } {bind or column index out of range}
   399         -}
          393  +do_test bind-8.7 {
          394  +  sqlite4_errmsg $DB
          395  +} {bind or column index out of range}
   400    396   
   401    397   do_test bind-8.8 {
   402    398     catch { sqlite4_bind_blob $VM 0 "abc" 3 }
   403    399   } {1}
   404    400   do_test bind-8.9 {
   405    401     catch { sqlite4_bind_blob $VM 4 "abc" 3 }
   406    402   } {1}

Changes to test/test_func.c.

   155    155   #ifndef SQLITE4_OMIT_BUILTIN_TEST
   156    156   void sqlite4BeginBenignMalloc(void);
   157    157   void sqlite4EndBenignMalloc(void);
   158    158   #else
   159    159     #define sqlite4BeginBenignMalloc()
   160    160     #define sqlite4EndBenignMalloc()
   161    161   #endif
   162         -static void test_agg_errmsg16_step(sqlite4_context *a, int b,sqlite4_value **c){
   163         -}
   164         -static void test_agg_errmsg16_final(sqlite4_context *ctx){
   165         -#ifndef SQLITE4_OMIT_UTF16
   166         -  const void *z;
   167         -  sqlite4 * db = sqlite4_context_db_handle(ctx);
   168         -  sqlite4_aggregate_context(ctx, 2048);
   169         -  sqlite4BeginBenignMalloc();
   170         -  z = sqlite4_errmsg16(db);
   171         -  sqlite4EndBenignMalloc();
   172         -  sqlite4_result_text16(ctx, z, -1, SQLITE4_TRANSIENT, 0);
   173         -#endif
   174         -}
   175    162   
   176    163   /*
   177    164   ** Routines for testing the sqlite4_auxdata_fetch() and sqlite4_auxdata_store()
   178    165   ** interface.
   179    166   **
   180    167   ** The test_auxdata() SQL function attempts to register each of its arguments
   181    168   ** as auxiliary data.  If there are no prior registrations of aux data for
................................................................................
   464    451     int i;
   465    452   
   466    453     for(i=0; i<sizeof(aFuncs)/sizeof(aFuncs[0]); i++){
   467    454       sqlite4_create_function(db, aFuncs[i].zName, aFuncs[i].nArg,
   468    455           aFuncs[i].eTextRep, 0, aFuncs[i].xFunc, 0, 0, 0);
   469    456     }
   470    457   
   471         -  sqlite4_create_function(db, "test_agg_errmsg16", 0, SQLITE4_ANY, 0, 0, 
   472         -      test_agg_errmsg16_step, test_agg_errmsg16_final, 0);
   473         -      
   474    458     return SQLITE4_OK;
   475    459   }
   476    460   
   477    461   /*
   478    462   ** A bogus step function and finalizer function.
   479    463   */
   480    464   static void tStep(sqlite4_context *a, int b, sqlite4_value **c){}

Changes to test/test_main.c.

   866    866     }
   867    867   #endif
   868    868     if( rc==SQLITE4_OK ){
   869    869       rc = sqlite4_create_function(db, "tkt2213func", 1, SQLITE4_ANY, 0, 
   870    870             tkt2213Function, 0, 0, 0);
   871    871     }
   872    872   
   873         -#ifndef SQLITE4_OMIT_UTF16
   874         -  /* Use the sqlite4_create_function16() API here. Mainly for fun, but also 
   875         -  ** because it is not tested anywhere else. */
   876    873     if( rc==SQLITE4_OK ){
   877         -    const void *zUtf16;
   878         -    sqlite4_value *pVal;
   879         -    sqlite4_mutex_enter(db->mutex);
   880         -    pVal = sqlite4ValueNew(db);
   881         -    sqlite4ValueSetStr(pVal, -1, "x_sqlite_exec", SQLITE4_UTF8,
   882         -                       SQLITE4_STATIC, 0);
   883         -    zUtf16 = sqlite4ValueText(pVal, SQLITE4_UTF16NATIVE);
   884         -    if( db->mallocFailed ){
   885         -      rc = SQLITE4_NOMEM;
   886         -    }else{
   887         -      rc = sqlite4_create_function16(db, zUtf16, 
   888         -                1, SQLITE4_UTF16, db, sqlite4ExecFunc, 0, 0, 0);
   889         -    }
   890         -    sqlite4ValueFree(pVal);
   891         -    sqlite4_mutex_leave(db->mutex);
          874  +    rc = sqlite4_create_function(
          875  +        db, "x_sqlite_exec", 1, SQLITE4_UTF16, db, sqlite4ExecFunc, 0, 0, 0
          876  +    );
   892    877     }
   893         -#endif
   894    878   
   895    879     if( sqlite4TestErrCode(interp, db, rc) ) return TCL_ERROR;
   896    880     Tcl_SetResult(interp, (char *)t1ErrorName(rc), 0);
   897    881     return TCL_OK;
   898    882   }
   899    883   
   900    884   /*
................................................................................
  2102   2086   ** Called when a collating sequence is needed.  Registered using
  2103   2087   ** sqlite4_collation_needed16().
  2104   2088   */
  2105   2089   static void test_collate_needed_cb(
  2106   2090     void *pCtx, 
  2107   2091     sqlite4 *db,
  2108   2092     int eTextRep,
  2109         -  const void *pName
         2093  +  const char *zName
  2110   2094   ){
  2111   2095     int enc = ENC(db);
  2112         -  int i;
  2113         -  char *z;
  2114         -  for(z = (char*)pName, i=0; *z || z[1]; z++){
  2115         -    if( *z ) zNeededCollation[i++] = *z;
  2116         -  }
  2117         -  zNeededCollation[i] = 0;
         2096  +  strcpy(zNeededCollation, zName);
  2118   2097     sqlite4_create_collation(
  2119         -      db, "test_collate", ENC(db), SQLITE4_INT_TO_PTR(enc), test_collate_func,
  2120         -      0, 0);
         2098  +      db, "test_collate", enc, SQLITE4_INT_TO_PTR(enc), test_collate_func, 0, 0
         2099  +  );
  2121   2100   }
  2122   2101   
  2123   2102   /*
  2124   2103   ** Usage: add_test_collate_needed DB
  2125   2104   */
  2126   2105   static int test_collate_needed(
  2127   2106     void * clientData,
................................................................................
  2130   2109     Tcl_Obj *CONST objv[]
  2131   2110   ){
  2132   2111     sqlite4 *db;
  2133   2112     int rc;
  2134   2113   
  2135   2114     if( objc!=2 ) goto bad_args;
  2136   2115     if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
  2137         -  rc = sqlite4_collation_needed16(db, test_collate_needed_cb, 0);
  2138         -  zNeededCollation[0] = 0;
         2116  +  rc = sqlite4_collation_needed(db, test_collate_needed_cb, 0);
  2139   2117     if( sqlite4TestErrCode(interp, db, rc) ) return TCL_ERROR;
  2140   2118     return TCL_OK;
  2141   2119   
  2142   2120   bad_args:
  2143   2121     Tcl_WrongNumArgs(interp, 1, objv, "DB");
  2144   2122     return TCL_ERROR;
  2145   2123   }
................................................................................
  2880   2858     if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
  2881   2859   
  2882   2860     zErr = sqlite4_errmsg(db);
  2883   2861     Tcl_SetObjResult(interp, Tcl_NewStringObj(zErr, -1));
  2884   2862     return TCL_OK;
  2885   2863   }
  2886   2864   
  2887         -/*
  2888         -** Usage:   test_errmsg16 DB
  2889         -**
  2890         -** Returns the UTF-16 representation of the error message string for the
  2891         -** most recent sqlite4_* API call. This is a byte array object at the TCL 
  2892         -** level, and it includes the 0x00 0x00 terminator bytes at the end of the
  2893         -** UTF-16 string.
  2894         -*/
  2895         -static int test_errmsg16(
  2896         -  void * clientData,
  2897         -  Tcl_Interp *interp,
  2898         -  int objc,
  2899         -  Tcl_Obj *CONST objv[]
  2900         -){
  2901         -#ifndef SQLITE4_OMIT_UTF16
  2902         -  sqlite4 *db;
  2903         -  const void *zErr;
  2904         -  const char *z;
  2905         -  int bytes = 0;
  2906         -
  2907         -  if( objc!=2 ){
  2908         -    Tcl_AppendResult(interp, "wrong # args: should be \"", 
  2909         -       Tcl_GetString(objv[0]), " DB", 0);
  2910         -    return TCL_ERROR;
  2911         -  }
  2912         -  if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
  2913         -
  2914         -  zErr = sqlite4_errmsg16(db);
  2915         -  if( zErr ){
  2916         -    z = zErr;
  2917         -    for(bytes=0; z[bytes] || z[bytes+1]; bytes+=2){}
  2918         -  }
  2919         -  Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(zErr, bytes));
  2920         -#endif /* SQLITE4_OMIT_UTF16 */
  2921         -  return TCL_OK;
  2922         -}
  2923         -
  2924   2865   /*
  2925   2866   ** Usage: sqlite4_prepare DB sql bytes ?tailvar?
  2926   2867   **
  2927   2868   ** Compile up to <bytes> bytes of the supplied SQL string <sql> using
  2928   2869   ** database handle <DB>. The parameter <tailval> is the name of a global
  2929   2870   ** variable that is set to the unused portion of <sql> (if any). A
  2930   2871   ** STMT handle is returned.
................................................................................
  3363   3304   
  3364   3305     if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;
  3365   3306     if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR;
  3366   3307     zRet = xFunc(pStmt, col, 0);
  3367   3308     if( zRet ){
  3368   3309       Tcl_SetResult(interp, (char *)zRet, 0);
  3369   3310     }
  3370         -  return TCL_OK;
  3371         -}
  3372         -
  3373         -/*
  3374         -** Usage: sqlite4_column_text STMT column
  3375         -**
  3376         -** Usage: sqlite4_column_decltype STMT column
  3377         -**
  3378         -** Usage: sqlite4_column_name STMT column
  3379         -*/
  3380         -static int test_stmt_utf16(
  3381         -  void * clientData,     /* Pointer to SQLite API function to be invoked */
  3382         -  Tcl_Interp *interp,
  3383         -  int objc,
  3384         -  Tcl_Obj *CONST objv[]
  3385         -){
  3386         -#ifndef SQLITE4_OMIT_UTF16
  3387         -  sqlite4_stmt *pStmt;
  3388         -  int col;
  3389         -  Tcl_Obj *pRet;
  3390         -  const void *zName16;
  3391         -  const void *(*xFunc)(sqlite4_stmt*, int);
  3392         -
  3393         -  xFunc = (const void *(*)(sqlite4_stmt*, int))clientData;
  3394         -  if( objc!=3 ){
  3395         -    Tcl_AppendResult(interp, "wrong # args: should be \"", 
  3396         -       Tcl_GetString(objv[0]), " STMT column", 0);
  3397         -    return TCL_ERROR;
  3398         -  }
  3399         -
  3400         -  if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;
  3401         -  if( Tcl_GetIntFromObj(interp, objv[2], &col) ) return TCL_ERROR;
  3402         -
  3403         -  zName16 = xFunc(pStmt, col);
  3404         -  if( zName16 ){
  3405         -    int n;
  3406         -    const char *z = zName16;
  3407         -    for(n=0; z[n] || z[n+1]; n+=2){}
  3408         -    pRet = Tcl_NewByteArrayObj(zName16, n+2);
  3409         -    Tcl_SetObjResult(interp, pRet);
  3410         -  }
  3411         -#endif /* SQLITE4_OMIT_UTF16 */
  3412         -
  3413   3311     return TCL_OK;
  3414   3312   }
  3415   3313   
  3416   3314   /*
  3417   3315   ** Usage: sqlite4_column_int STMT column
  3418   3316   */
  3419   3317   static int test_stmt_int(
................................................................................
  4222   4120        { "sqlite4_bind_parameter_count",  test_bind_parameter_count, 0},
  4223   4121        { "sqlite4_bind_parameter_name",   test_bind_parameter_name,  0},
  4224   4122        { "sqlite4_bind_parameter_index",  test_bind_parameter_index, 0},
  4225   4123        { "sqlite4_clear_bindings",        test_clear_bindings, 0},
  4226   4124        { "sqlite4_sleep",                 test_sleep,          0},
  4227   4125        { "sqlite4_errcode",               test_errcode       ,0 },
  4228   4126        { "sqlite4_errmsg",                test_errmsg        ,0 },
  4229         -     { "sqlite4_errmsg16",              test_errmsg16      ,0 },
  4230   4127        { "sqlite4_open",                  test_open          ,0 },
  4231   4128        { "sqlite4_open_v2",               test_open_v2       ,0 },
  4232   4129   
  4233   4130        { "sqlite4_prepare",               test_prepare       ,0 },
  4234   4131        { "sqlite4_prepare_tkt3134",       test_prepare_tkt3134, 0},
  4235   4132        { "sqlite4_finalize",              test_finalize      ,0 },
  4236   4133        { "sqlite4_stmt_status",           test_stmt_status   ,0 },
................................................................................
  4269   4166   #ifdef SQLITE4_ENABLE_COLUMN_METADATA
  4270   4167   { "sqlite4_column_database_name",test_stmt_utf8,(void*)sqlite4_column_database_name},
  4271   4168   { "sqlite4_column_table_name",test_stmt_utf8,(void*)sqlite4_column_table_name},
  4272   4169   { "sqlite4_column_origin_name",test_stmt_utf8,(void*)sqlite4_column_origin_name},
  4273   4170   #endif
  4274   4171   
  4275   4172   #ifndef SQLITE4_OMIT_UTF16
  4276         -     { "sqlite4_column_text16",  test_stmt_utf16, (void*)sqlite4_column_text16},
  4277         -     { "sqlite4_column_name16",  test_stmt_utf16, (void*)sqlite4_column_name16},
  4278   4173        { "add_alignment_test_collations", add_alignment_test_collations, 0      },
  4279         -#ifndef SQLITE4_OMIT_DECLTYPE
  4280         -     { "sqlite4_column_decltype16",test_stmt_utf16,(void*)sqlite4_column_decltype16},
  4281         -#endif
  4282         -#ifdef SQLITE4_ENABLE_COLUMN_METADATA
  4283         -{"sqlite4_column_database_name16",
  4284         -  test_stmt_utf16, sqlite4_column_database_name16},
  4285         -{"sqlite4_column_table_name16", test_stmt_utf16, (void*)sqlite4_column_table_name16},
  4286         -{"sqlite4_column_origin_name16", test_stmt_utf16, (void*)sqlite4_column_origin_name16},
  4287         -#endif
  4288   4174   #endif
  4289   4175        { "sqlite4_create_collation",   test_create_collation, 0 },
  4290   4176        { "working_64bit_int",          working_64bit_int,   0   },
  4291   4177        { "sqlite4_create_function_v2", test_create_function_v2, 0 },
  4292   4178   
  4293   4179        /* Functions from os.h */
  4294   4180   #ifndef SQLITE4_OMIT_UTF16

Changes to test/test_utf.c.

    87     87     val.z = "hello world";
    88     88     val.type = SQLITE4_TEXT;
    89     89     val.enc = SQLITE4_UTF8;
    90     90   
    91     91     for(i=0; i<repeat_count; i++){
    92     92       if( do_calls ){
    93     93         zVal = sqlite4_value_text(&val, 0);
           94  +      UNUSED_PARAMETER(zVal);
    94     95       }
    95     96     }
    96     97   
    97     98     return TCL_OK;
    98     99   }
    99    100   
   100    101   static u8 name_to_enc(Tcl_Interp *interp, Tcl_Obj *pObj){