SQLite

Check-in [efb4aab0ca]
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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: efb4aab0caa4145732a5438cc2a193bc12c455b4007220564d240e75900ea8ad
User & Date: drh 2017-07-06 13:51:50.091
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: c5ed5ebdf6 user: drh tags: trunk)
13:51
More compact implementation of the typeof() SQL function. (check-in: efb4aab0ca user: drh tags: trunk)
13:23
Avoid unnecessary upper-to-lower case conversion for function names when registering the built-in functions. (check-in: 0626925764 user: drh tags: trunk)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to src/func.c.
72
73
74
75
76
77
78
79


80
81
82
83
84
85






86
87
88

89
90
91
92
93
94
95
72
73
74
75
76
77
78

79
80
81





82
83
84
85
86
87



88
89
90
91
92
93
94
95







-
+
+

-
-
-
-
-
+
+
+
+
+
+
-
-
-
+







** Return the type of the argument.
*/
static void typeofFunc(
  sqlite3_context *context,
  int NotUsed,
  sqlite3_value **argv
){
  const char *z = 0;
  static const char *azType[] = { "integer", "real", "text", "blob", "null" };
  int i = sqlite3_value_type(argv[0]) - 1;
  UNUSED_PARAMETER(NotUsed);
  switch( sqlite3_value_type(argv[0]) ){
    case SQLITE_INTEGER: z = "integer"; break;
    case SQLITE_TEXT:    z = "text";    break;
    case SQLITE_FLOAT:   z = "real";    break;
    case SQLITE_BLOB:    z = "blob";    break;
  assert( i>=0 && i<ArraySize(azType) );
  assert( SQLITE_INTEGER==1 );
  assert( SQLITE_FLOAT==2 );
  assert( SQLITE_TEXT==3 );
  assert( SQLITE_BLOB==4 );
  assert( SQLITE_NULL==5 );
    default:             z = "null";    break;
  }
  sqlite3_result_text(context, z, -1, SQLITE_STATIC);
  sqlite3_result_text(context, azType[i], -1, SQLITE_STATIC);
}


/*
** Implementation of the length() function
*/
static void lengthFunc(