/ Check-in [efb4aab0]
Login

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

Overview
Comment:More compact implementation of the typeof() SQL function.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: efb4aab0caa4145732a5438cc2a193bc12c455b4007220564d240e75900ea8ad
User & Date: drh 2017-07-06 13:51:50
Context
2017-07-06
16:33
Change the (machine-generated) keywordhash.h file to increase the scope of the tables used for keyword matching, so that the tables are accessible to functions other then keywordCode(). check-in: c5ed5ebd user: drh tags: trunk
13:51
More compact implementation of the typeof() SQL function. check-in: efb4aab0 user: drh tags: trunk
13:23
Avoid unnecessary upper-to-lower case conversion for function names when registering the built-in functions. check-in: 06269257 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/func.c.

    72     72   ** Return the type of the argument.
    73     73   */
    74     74   static void typeofFunc(
    75     75     sqlite3_context *context,
    76     76     int NotUsed,
    77     77     sqlite3_value **argv
    78     78   ){
    79         -  const char *z = 0;
           79  +  static const char *azType[] = { "integer", "real", "text", "blob", "null" };
           80  +  int i = sqlite3_value_type(argv[0]) - 1;
    80     81     UNUSED_PARAMETER(NotUsed);
    81         -  switch( sqlite3_value_type(argv[0]) ){
    82         -    case SQLITE_INTEGER: z = "integer"; break;
    83         -    case SQLITE_TEXT:    z = "text";    break;
    84         -    case SQLITE_FLOAT:   z = "real";    break;
    85         -    case SQLITE_BLOB:    z = "blob";    break;
    86         -    default:             z = "null";    break;
    87         -  }
    88         -  sqlite3_result_text(context, z, -1, SQLITE_STATIC);
           82  +  assert( i>=0 && i<ArraySize(azType) );
           83  +  assert( SQLITE_INTEGER==1 );
           84  +  assert( SQLITE_FLOAT==2 );
           85  +  assert( SQLITE_TEXT==3 );
           86  +  assert( SQLITE_BLOB==4 );
           87  +  assert( SQLITE_NULL==5 );
           88  +  sqlite3_result_text(context, azType[i], -1, SQLITE_STATIC);
    89     89   }
    90     90   
    91     91   
    92     92   /*
    93     93   ** Implementation of the length() function
    94     94   */
    95     95   static void lengthFunc(