/ Check-in [c48f6f39]
Login

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

Overview
Comment:Avoid the use of function pointers in columnName(), as function pointers appear to be a source of consternation to LLVM.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c48f6f39c5f89a338fed7153553a27a5d882d4d8db8221e911b96e0dd57c53d9
User & Date: drh 2019-02-20 18:13:57
Context
2019-02-20
19:06
Disable unix-specific features of dbfuzz2 when compiling on windows. check-in: af84774d user: drh tags: trunk
18:13
Avoid the use of function pointers in columnName(), as function pointers appear to be a source of consternation to LLVM. check-in: c48f6f39 user: drh tags: trunk
13:55
Progress handler improvements: (1) Invoke the callback after OP_Program opcodes (2) Invoke the callback multiple times in a row to catch up after a long run of no progress checks. check-in: 0c5db18d user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbeapi.c.

  1116   1116   **    3      The name of the table that the column derives from
  1117   1117   **    4      The name of the table column that the result column derives from
  1118   1118   **
  1119   1119   ** If the result is not a simple column reference (if it is an expression
  1120   1120   ** or a constant) then useTypes 2, 3, and 4 return NULL.
  1121   1121   */
  1122   1122   static const void *columnName(
  1123         -  sqlite3_stmt *pStmt,
  1124         -  int N,
  1125         -  const void *(*xFunc)(Mem*),
  1126         -  int useType
         1123  +  sqlite3_stmt *pStmt,     /* The statement */
         1124  +  int N,                   /* Which column to get the name for */
         1125  +  int useUtf16,            /* True to return the name as UTF16 */
         1126  +  int useType              /* What type of name */
  1127   1127   ){
  1128   1128     const void *ret;
  1129   1129     Vdbe *p;
  1130   1130     int n;
  1131   1131     sqlite3 *db;
  1132   1132   #ifdef SQLITE_ENABLE_API_ARMOR
  1133   1133     if( pStmt==0 ){
................................................................................
  1140   1140     db = p->db;
  1141   1141     assert( db!=0 );
  1142   1142     n = sqlite3_column_count(pStmt);
  1143   1143     if( N<n && N>=0 ){
  1144   1144       N += useType*n;
  1145   1145       sqlite3_mutex_enter(db->mutex);
  1146   1146       assert( db->mallocFailed==0 );
  1147         -    ret = xFunc(&p->aColName[N]);
  1148         -     /* A malloc may have failed inside of the xFunc() call. If this
         1147  +    if( useUtf16 ){
         1148  +      ret = sqlite3_value_text16((sqlite3_value*)&p->aColName[N]);
         1149  +    }else{
         1150  +      ret = sqlite3_value_text((sqlite3_value*)&p->aColName[N]);
         1151  +    }
         1152  +    /* A malloc may have failed inside of the _text() call. If this
  1149   1153       ** is the case, clear the mallocFailed flag and return NULL.
  1150   1154       */
  1151   1155       if( db->mallocFailed ){
  1152   1156         sqlite3OomClear(db);
  1153   1157         ret = 0;
  1154   1158       }
  1155   1159       sqlite3_mutex_leave(db->mutex);
................................................................................
  1158   1162   }
  1159   1163   
  1160   1164   /*
  1161   1165   ** Return the name of the Nth column of the result set returned by SQL
  1162   1166   ** statement pStmt.
  1163   1167   */
  1164   1168   const char *sqlite3_column_name(sqlite3_stmt *pStmt, int N){
  1165         -  return columnName(
  1166         -      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_NAME);
         1169  +  return columnName(pStmt, N, 0, COLNAME_NAME);
  1167   1170   }
  1168   1171   #ifndef SQLITE_OMIT_UTF16
  1169   1172   const void *sqlite3_column_name16(sqlite3_stmt *pStmt, int N){
  1170         -  return columnName(
  1171         -      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_NAME);
         1173  +  return columnName(pStmt, N, 1, COLNAME_NAME);
  1172   1174   }
  1173   1175   #endif
  1174   1176   
  1175   1177   /*
  1176   1178   ** Constraint:  If you have ENABLE_COLUMN_METADATA then you must
  1177   1179   ** not define OMIT_DECLTYPE.
  1178   1180   */
................................................................................
  1183   1185   
  1184   1186   #ifndef SQLITE_OMIT_DECLTYPE
  1185   1187   /*
  1186   1188   ** Return the column declaration type (if applicable) of the 'i'th column
  1187   1189   ** of the result set of SQL statement pStmt.
  1188   1190   */
  1189   1191   const char *sqlite3_column_decltype(sqlite3_stmt *pStmt, int N){
  1190         -  return columnName(
  1191         -      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_DECLTYPE);
         1192  +  return columnName(pStmt, N, 0, COLNAME_DECLTYPE);
  1192   1193   }
  1193   1194   #ifndef SQLITE_OMIT_UTF16
  1194   1195   const void *sqlite3_column_decltype16(sqlite3_stmt *pStmt, int N){
  1195         -  return columnName(
  1196         -      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_DECLTYPE);
         1196  +  return columnName(pStmt, N, 1, COLNAME_DECLTYPE);
  1197   1197   }
  1198   1198   #endif /* SQLITE_OMIT_UTF16 */
  1199   1199   #endif /* SQLITE_OMIT_DECLTYPE */
  1200   1200   
  1201   1201   #ifdef SQLITE_ENABLE_COLUMN_METADATA
  1202   1202   /*
  1203   1203   ** Return the name of the database from which a result column derives.
  1204   1204   ** NULL is returned if the result column is an expression or constant or
  1205   1205   ** anything else which is not an unambiguous reference to a database column.
  1206   1206   */
  1207   1207   const char *sqlite3_column_database_name(sqlite3_stmt *pStmt, int N){
  1208         -  return columnName(
  1209         -      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_DATABASE);
         1208  +  return columnName(pStmt, N, 0, COLNAME_DATABASE);
  1210   1209   }
  1211   1210   #ifndef SQLITE_OMIT_UTF16
  1212   1211   const void *sqlite3_column_database_name16(sqlite3_stmt *pStmt, int N){
  1213         -  return columnName(
  1214         -      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_DATABASE);
         1212  +  return columnName(pStmt, N, 1, COLNAME_DATABASE);
  1215   1213   }
  1216   1214   #endif /* SQLITE_OMIT_UTF16 */
  1217   1215   
  1218   1216   /*
  1219   1217   ** Return the name of the table from which a result column derives.
  1220   1218   ** NULL is returned if the result column is an expression or constant or
  1221   1219   ** anything else which is not an unambiguous reference to a database column.
  1222   1220   */
  1223   1221   const char *sqlite3_column_table_name(sqlite3_stmt *pStmt, int N){
  1224         -  return columnName(
  1225         -      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_TABLE);
         1222  +  return columnName(pStmt, N, 0, COLNAME_TABLE);
  1226   1223   }
  1227   1224   #ifndef SQLITE_OMIT_UTF16
  1228   1225   const void *sqlite3_column_table_name16(sqlite3_stmt *pStmt, int N){
  1229         -  return columnName(
  1230         -      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_TABLE);
         1226  +  return columnName(pStmt, N, 1, COLNAME_TABLE);
  1231   1227   }
  1232   1228   #endif /* SQLITE_OMIT_UTF16 */
  1233   1229   
  1234   1230   /*
  1235   1231   ** Return the name of the table column from which a result column derives.
  1236   1232   ** NULL is returned if the result column is an expression or constant or
  1237   1233   ** anything else which is not an unambiguous reference to a database column.
  1238   1234   */
  1239   1235   const char *sqlite3_column_origin_name(sqlite3_stmt *pStmt, int N){
  1240         -  return columnName(
  1241         -      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_COLUMN);
         1236  +  return columnName(pStmt, N, 0, COLNAME_COLUMN);
  1242   1237   }
  1243   1238   #ifndef SQLITE_OMIT_UTF16
  1244   1239   const void *sqlite3_column_origin_name16(sqlite3_stmt *pStmt, int N){
  1245         -  return columnName(
  1246         -      pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_COLUMN);
         1240  +  return columnName(pStmt, N, 1, COLNAME_COLUMN);
  1247   1241   }
  1248   1242   #endif /* SQLITE_OMIT_UTF16 */
  1249   1243   #endif /* SQLITE_ENABLE_COLUMN_METADATA */
  1250   1244   
  1251   1245   
  1252   1246   /******************************* sqlite3_bind_  ***************************
  1253   1247   **