/ Check-in [9b91502e]
Login

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

Overview
Comment:Remove the alternative UTF-16 implementation of SUBSTR(). It does not work anymore and the UTF-8 version can do everything that the UTF-16 version does. (CVS 4009)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9b91502ef0ea9c0bfb8362c4b70314dc8449eb9e
User & Date: drh 2007-05-15 14:40:11
Context
2007-05-15
16:51
Make sure pParse->rc gets set whenever sqlite3ErrorMsg() is called. This is added insurance that parsing will stop quickly after an error. This change did make the parser stop faster in some cases, which required some revisions to tests. (CVS 4010) check-in: f84d9dab user: drh tags: trunk
14:40
Remove the alternative UTF-16 implementation of SUBSTR(). It does not work anymore and the UTF-8 version can do everything that the UTF-16 version does. (CVS 4009) check-in: 9b91502e user: drh tags: trunk
14:34
Relax the restriction on using bytes 0x80 through 0xbf as the first character of an identifier. Enhancements to ALTER TABLE tests for tables with strange names or stange column names. (CVS 4008) check-in: 262a3e63 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/func.c.

    12     12   ** This file contains the C functions that implement various SQL
    13     13   ** functions of SQLite.  
    14     14   **
    15     15   ** There is only one exported symbol in this file - the function
    16     16   ** sqliteRegisterBuildinFunctions() found at the bottom of the file.
    17     17   ** All other code has file scope.
    18     18   **
    19         -** $Id: func.c,v 1.158 2007/05/15 13:27:07 drh Exp $
           19  +** $Id: func.c,v 1.159 2007/05/15 14:40:11 drh Exp $
    20     20   */
    21     21   #include "sqliteInt.h"
    22     22   #include <ctype.h>
    23     23   /* #include <math.h> */
    24     24   #include <stdlib.h>
    25     25   #include <assert.h>
    26     26   #include "vdbeInt.h"
................................................................................
  1306   1306       { "min",               -1, 0, SQLITE_UTF8,    1, minmaxFunc },
  1307   1307       { "min",                0, 0, SQLITE_UTF8,    1, 0          },
  1308   1308       { "max",               -1, 1, SQLITE_UTF8,    1, minmaxFunc },
  1309   1309       { "max",                0, 1, SQLITE_UTF8,    1, 0          },
  1310   1310       { "typeof",             1, 0, SQLITE_UTF8,    0, typeofFunc },
  1311   1311       { "length",             1, 0, SQLITE_UTF8,    0, lengthFunc },
  1312   1312       { "substr",             3, 0, SQLITE_UTF8,    0, substrFunc },
  1313         -#ifndef SQLITE_OMIT_UTF16
  1314         -    { "substr",             3, 0, SQLITE_UTF16LE, 0, sqlite3Utf16Substr },
  1315         -#endif
  1316   1313       { "abs",                1, 0, SQLITE_UTF8,    0, absFunc    },
  1317   1314       { "round",              1, 0, SQLITE_UTF8,    0, roundFunc  },
  1318   1315       { "round",              2, 0, SQLITE_UTF8,    0, roundFunc  },
  1319   1316       { "upper",              1, 0, SQLITE_UTF8,    0, upperFunc  },
  1320   1317       { "lower",              1, 0, SQLITE_UTF8,    0, lowerFunc  },
  1321   1318       { "coalesce",          -1, 0, SQLITE_UTF8,    0, ifnullFunc },
  1322   1319       { "coalesce",           0, 0, SQLITE_UTF8,    0, 0          },

Changes to src/utf.c.

     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains routines used to translate between UTF-8, 
    13     13   ** UTF-16, UTF-16BE, and UTF-16LE.
    14     14   **
    15         -** $Id: utf.c,v 1.47 2007/05/15 11:55:09 drh Exp $
           15  +** $Id: utf.c,v 1.48 2007/05/15 14:40:11 drh Exp $
    16     16   **
    17     17   ** Notes on UTF-8:
    18     18   **
    19     19   **   Byte-0    Byte-1    Byte-2    Byte-3    Value
    20     20   **  0xxxxxxx                                 00000000 00000000 0xxxxxxx
    21     21   **  110yyyyy  10xxxxxx                       00000000 00000yyy yyxxxxxx
    22     22   **  1110zzzz  10yyyyyy  10xxxxxx             00000000 zzzzyyyy yyxxxxxx
................................................................................
   430    430         READ_UTF16LE(z, c);
   431    431         n++;
   432    432       }
   433    433     }
   434    434     return (z-(char const *)zIn)-((c==0)?2:0);
   435    435   }
   436    436   
   437         -/*
   438         -** UTF-16 implementation of the substr()
   439         -*/
   440         -void sqlite3Utf16Substr(
   441         -  sqlite3_context *context,
   442         -  int argc,
   443         -  sqlite3_value **argv
   444         -){
   445         -  int y, z;
   446         -  unsigned char const *zStr;
   447         -  unsigned char const *zStrEnd;
   448         -  unsigned char const *zStart;
   449         -  unsigned char const *zEnd;
   450         -  int i;
   451         -
   452         -  zStr = (unsigned char const *)sqlite3_value_text16(argv[0]);
   453         -  zStrEnd = &zStr[sqlite3_value_bytes16(argv[0])];
   454         -  y = sqlite3_value_int(argv[1]);
   455         -  z = sqlite3_value_int(argv[2]);
   456         -
   457         -  if( y>0 ){
   458         -    y = y-1;
   459         -    zStart = zStr;
   460         -    if( SQLITE_UTF16BE==SQLITE_UTF16NATIVE ){
   461         -      for(i=0; i<y && zStart<zStrEnd; i++) SKIP_UTF16BE(zStart);
   462         -    }else{
   463         -      for(i=0; i<y && zStart<zStrEnd; i++) SKIP_UTF16LE(zStart);
   464         -    }
   465         -  }else{
   466         -    zStart = zStrEnd;
   467         -    if( SQLITE_UTF16BE==SQLITE_UTF16NATIVE ){
   468         -      for(i=y; i<0 && zStart>zStr; i++) RSKIP_UTF16BE(zStart);
   469         -    }else{
   470         -      for(i=y; i<0 && zStart>zStr; i++) RSKIP_UTF16LE(zStart);
   471         -    }
   472         -    for(; i<0; i++) z -= 1;
   473         -  }
   474         -
   475         -  zEnd = zStart;
   476         -  if( SQLITE_UTF16BE==SQLITE_UTF16NATIVE ){
   477         -    for(i=0; i<z && zEnd<zStrEnd; i++) SKIP_UTF16BE(zEnd);
   478         -  }else{
   479         -    for(i=0; i<z && zEnd<zStrEnd; i++) SKIP_UTF16LE(zEnd);
   480         -  }
   481         -
   482         -  sqlite3_result_text16(context, zStart, zEnd-zStart, SQLITE_TRANSIENT);
   483         -}
   484         -
   485    437   #if defined(SQLITE_TEST)
   486    438   /*
   487    439   ** Translate UTF-8 to UTF-8.
   488    440   **
   489    441   ** This has the effect of making sure that the string is well-formed
   490    442   ** UTF-8.  Miscoded characters are removed.
   491    443   **