persistentstorage/sql/SQLite/main.c
branchRCL_3
changeset 6 5ffdb8f2067f
parent 0 08ec8eefde2f
equal deleted inserted replaced
2:6862383cf555 6:5ffdb8f2067f
  1129 /*
  1129 /*
  1130 ** Return UTF-16 encoded English language explanation of the most recent
  1130 ** Return UTF-16 encoded English language explanation of the most recent
  1131 ** error.
  1131 ** error.
  1132 */
  1132 */
  1133 const void *sqlite3_errmsg16(sqlite3 *db){
  1133 const void *sqlite3_errmsg16(sqlite3 *db){
  1134   /* Because all the characters in the string are in the unicode
  1134   static const u16 outOfMem[] = {
  1135   ** range 0x00-0xFF, if we pad the big-endian string with a 
  1135     'o', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y', 0
  1136   ** zero byte, we can obtain the little-endian string with
       
  1137   ** &big_endian[1].
       
  1138   */
       
  1139   static const char outOfMemBe[] = {
       
  1140     0, 'o', 0, 'u', 0, 't', 0, ' ', 
       
  1141     0, 'o', 0, 'f', 0, ' ', 
       
  1142     0, 'm', 0, 'e', 0, 'm', 0, 'o', 0, 'r', 0, 'y', 0, 0, 0
       
  1143   };
  1136   };
  1144   static const char misuseBe [] = {
  1137   static const u16 misuse[] = {
  1145     0, 'l', 0, 'i', 0, 'b', 0, 'r', 0, 'a', 0, 'r', 0, 'y', 0, ' ', 
  1138     'l', 'i', 'b', 'r', 'a', 'r', 'y', ' ',
  1146     0, 'r', 0, 'o', 0, 'u', 0, 't', 0, 'i', 0, 'n', 0, 'e', 0, ' ', 
  1139     'r', 'o', 'u', 't', 'i', 'n', 'e', ' ',
  1147     0, 'c', 0, 'a', 0, 'l', 0, 'l', 0, 'e', 0, 'd', 0, ' ', 
  1140     'c', 'a', 'l', 'l', 'e', 'd', ' ',
  1148     0, 'o', 0, 'u', 0, 't', 0, ' ', 
  1141     'o', 'u', 't', ' ',
  1149     0, 'o', 0, 'f', 0, ' ', 
  1142     'o', 'f', ' ',
  1150     0, 's', 0, 'e', 0, 'q', 0, 'u', 0, 'e', 0, 'n', 0, 'c', 0, 'e', 0, 0, 0
  1143     's', 'e', 'q', 'u', 'e', 'n', 'c', 'e', 0
  1151   };
  1144   };
  1152 
  1145 
  1153   const void *z;
  1146   const void *z;
  1154   if( !db ){
  1147   if( !db ){
  1155     return (void *)(&outOfMemBe[SQLITE_UTF16NATIVE==SQLITE_UTF16LE?1:0]);
  1148     return (void *)outOfMem;
  1156   }
  1149   }
  1157   if( !sqlite3SafetyCheckSickOrOk(db) ){
  1150   if( !sqlite3SafetyCheckSickOrOk(db) ){
  1158     return (void *)(&misuseBe[SQLITE_UTF16NATIVE==SQLITE_UTF16LE?1:0]);
  1151     return (void *)misuse;
  1159   }
  1152   }
  1160   sqlite3_mutex_enter(db->mutex);
  1153   sqlite3_mutex_enter(db->mutex);
  1161   assert( !db->mallocFailed );
  1154   assert( !db->mallocFailed );
  1162   z = sqlite3_value_text16(db->pErr);
  1155   z = sqlite3_value_text16(db->pErr);
  1163   if( z==0 ){
  1156   if( z==0 ){