/ Check-in [846fff5f]
Login

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

Overview
Comment:Modify the aBuiltinFunc array in func.c to use the WSD macros. (CVS 5653)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:846fff5f0902418cfce2915d2ccfe567481a1289
User & Date: danielk1977 2008-09-01 19:14:02
Context
2008-09-01
20:38
Converted strcasecmp to sqlite3StrICmp. Test code only. (CVS 5654) check-in: bdeefe37 user: shane tags: trunk
19:14
Modify the aBuiltinFunc array in func.c to use the WSD macros. (CVS 5653) check-in: 846fff5f user: danielk1977 tags: trunk
18:34
Begin adding support for the SQLITE_OMIT_WSD macro. Some (many) WSD variables still need wrappers added to them. (CVS 5652) check-in: 573d92ab user: danielk1977 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/func.c.

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
....
1292
1293
1294
1295
1296
1297
1298

1299








1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378



1379
1380
1381
1382
** This file contains the C functions that implement various SQL
** functions of SQLite.  
**
** There is only one exported symbol in this file - the function
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
** All other code has file scope.
**
** $Id: func.c,v 1.200 2008/09/01 18:34:20 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
#include <stdlib.h>
#include <assert.h>
#include "vdbeInt.h"

................................................................................
  assert( (char*)&likeInfoAlt == (char*)&likeInfoAlt.matchAll );
  assert( &((char*)&likeInfoAlt)[1] == (char*)&likeInfoAlt.matchOne );
  assert( &((char*)&likeInfoAlt)[2] == (char*)&likeInfoAlt.matchSet );
  *pIsNocase = (pDef->flags & SQLITE_FUNC_CASE)==0;
  return 1;
}


/*








** The following array holds FuncDef structures for all of the functions
** defined in this file.
**
** The array cannot be constant since changes are made to the
** FuncDef.pHash elements at start-time.  The elements of this array
** are read-only after initialization is complete.
*/
static FuncDef aBuiltinFunc[] = {
  FUNCTION(ltrim,              1, 1, 0, trimFunc         ),
  FUNCTION(ltrim,              2, 1, 0, trimFunc         ),
  FUNCTION(rtrim,              1, 2, 0, trimFunc         ),
  FUNCTION(rtrim,              2, 2, 0, trimFunc         ),
  FUNCTION(trim,               1, 3, 0, trimFunc         ),
  FUNCTION(trim,               2, 3, 0, trimFunc         ),
  FUNCTION(min,               -1, 0, 1, minmaxFunc       ),
  FUNCTION(min,                0, 0, 1, 0                ),
  AGGREGATE(min,               1, 0, 1, minmaxStep,      minMaxFinalize ),
  FUNCTION(max,               -1, 1, 1, minmaxFunc       ),
  FUNCTION(max,                0, 1, 1, 0                ),
  AGGREGATE(max,               1, 1, 1, minmaxStep,      minMaxFinalize ),
  FUNCTION(typeof,             1, 0, 0, typeofFunc       ),
  FUNCTION(length,             1, 0, 0, lengthFunc       ),
  FUNCTION(substr,             2, 0, 0, substrFunc       ),
  FUNCTION(substr,             3, 0, 0, substrFunc       ),
  FUNCTION(abs,                1, 0, 0, absFunc          ),
  FUNCTION(round,              1, 0, 0, roundFunc        ),
  FUNCTION(round,              2, 0, 0, roundFunc        ),
  FUNCTION(upper,              1, 0, 0, upperFunc        ),
  FUNCTION(lower,              1, 0, 0, lowerFunc        ),
  FUNCTION(coalesce,           1, 0, 0, 0                ),
  FUNCTION(coalesce,          -1, 0, 0, ifnullFunc       ),
  FUNCTION(coalesce,           0, 0, 0, 0                ),
  FUNCTION(hex,                1, 0, 0, hexFunc          ),
  FUNCTION(ifnull,             2, 0, 1, ifnullFunc       ),
  FUNCTION(random,            -1, 0, 0, randomFunc       ),
  FUNCTION(randomblob,         1, 0, 0, randomBlob       ),
  FUNCTION(nullif,             2, 0, 1, nullifFunc       ),
  FUNCTION(sqlite_version,     0, 0, 0, versionFunc      ),
  FUNCTION(quote,              1, 0, 0, quoteFunc        ),
  FUNCTION(last_insert_rowid,  0, 0, 0, last_insert_rowid),
  FUNCTION(changes,            0, 0, 0, changes          ),
  FUNCTION(total_changes,      0, 0, 0, total_changes    ),
  FUNCTION(replace,            3, 0, 0, replaceFunc      ),
  FUNCTION(zeroblob,           1, 0, 0, zeroblobFunc     ),
#ifdef SQLITE_SOUNDEX
  FUNCTION(soundex,            1, 0, 0, soundexFunc      ),
#endif
#ifndef SQLITE_OMIT_LOAD_EXTENSION
  FUNCTION(load_extension,     1, 0, 0, loadExt          ),
  FUNCTION(load_extension,     2, 0, 0, loadExt          ),
#endif
  AGGREGATE(sum,               1, 0, 0, sumStep,         sumFinalize    ),
  AGGREGATE(total,             1, 0, 0, sumStep,         totalFinalize    ),
  AGGREGATE(avg,               1, 0, 0, sumStep,         avgFinalize    ),
  AGGREGATE(count,             0, 0, 0, countStep,       countFinalize  ),
  AGGREGATE(count,             1, 0, 0, countStep,       countFinalize  ),
  AGGREGATE(group_concat,     -1, 0, 0, groupConcatStep, groupConcatFinalize),

  LIKEFUNC(glob, 2, &globInfo, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
#ifdef SQLITE_CASE_SENSITIVE_LIKE
  LIKEFUNC(like, 2, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
  LIKEFUNC(like, 3, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
#else
  LIKEFUNC(like, 2, &likeInfoNorm, SQLITE_FUNC_LIKE),
  LIKEFUNC(like, 3, &likeInfoNorm, SQLITE_FUNC_LIKE),
#endif
};

/*
** All all of the FuncDef structures in the aBuiltinFunc[] array above
** to the global function hash table.  This occurs at start-time (as
** a consequence of calling sqlite3_initialize()).
**
** After this routine runs
*/
void sqlite3RegisterGlobalFunctions(void){
  int i;
  for(i=0; i<ArraySize(aBuiltinFunc); i++){
    FuncDefHash *pHash = &GLOBAL(FuncDefHash, sqlite3GlobalFunctions);



    sqlite3FuncDefInsert(pHash, &aBuiltinFunc[i]);
  }
  sqlite3RegisterDateTimeFunctions();
}







|







 







>

>
>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

<
<
<
<
<
<
<
<

<
|
>
>
>
|



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
....
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376








1377

1378
1379
1380
1381
1382
1383
1384
1385
** This file contains the C functions that implement various SQL
** functions of SQLite.  
**
** There is only one exported symbol in this file - the function
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
** All other code has file scope.
**
** $Id: func.c,v 1.201 2008/09/01 19:14:02 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
#include <stdlib.h>
#include <assert.h>
#include "vdbeInt.h"

................................................................................
  assert( (char*)&likeInfoAlt == (char*)&likeInfoAlt.matchAll );
  assert( &((char*)&likeInfoAlt)[1] == (char*)&likeInfoAlt.matchOne );
  assert( &((char*)&likeInfoAlt)[2] == (char*)&likeInfoAlt.matchSet );
  *pIsNocase = (pDef->flags & SQLITE_FUNC_CASE)==0;
  return 1;
}


/*
** All all of the FuncDef structures in the aBuiltinFunc[] array above
** to the global function hash table.  This occurs at start-time (as
** a consequence of calling sqlite3_initialize()).
**
** After this routine runs
*/
void sqlite3RegisterGlobalFunctions(void){
  /*
  ** The following array holds FuncDef structures for all of the functions
  ** defined in this file.
  **
  ** The array cannot be constant since changes are made to the
  ** FuncDef.pHash elements at start-time.  The elements of this array
  ** are read-only after initialization is complete.
  */
  static SQLITE_WSD FuncDef aBuiltinFunc[] = {
    FUNCTION(ltrim,              1, 1, 0, trimFunc         ),
    FUNCTION(ltrim,              2, 1, 0, trimFunc         ),
    FUNCTION(rtrim,              1, 2, 0, trimFunc         ),
    FUNCTION(rtrim,              2, 2, 0, trimFunc         ),
    FUNCTION(trim,               1, 3, 0, trimFunc         ),
    FUNCTION(trim,               2, 3, 0, trimFunc         ),
    FUNCTION(min,               -1, 0, 1, minmaxFunc       ),
    FUNCTION(min,                0, 0, 1, 0                ),
    AGGREGATE(min,               1, 0, 1, minmaxStep,      minMaxFinalize ),
    FUNCTION(max,               -1, 1, 1, minmaxFunc       ),
    FUNCTION(max,                0, 1, 1, 0                ),
    AGGREGATE(max,               1, 1, 1, minmaxStep,      minMaxFinalize ),
    FUNCTION(typeof,             1, 0, 0, typeofFunc       ),
    FUNCTION(length,             1, 0, 0, lengthFunc       ),
    FUNCTION(substr,             2, 0, 0, substrFunc       ),
    FUNCTION(substr,             3, 0, 0, substrFunc       ),
    FUNCTION(abs,                1, 0, 0, absFunc          ),
    FUNCTION(round,              1, 0, 0, roundFunc        ),
    FUNCTION(round,              2, 0, 0, roundFunc        ),
    FUNCTION(upper,              1, 0, 0, upperFunc        ),
    FUNCTION(lower,              1, 0, 0, lowerFunc        ),
    FUNCTION(coalesce,           1, 0, 0, 0                ),
    FUNCTION(coalesce,          -1, 0, 0, ifnullFunc       ),
    FUNCTION(coalesce,           0, 0, 0, 0                ),
    FUNCTION(hex,                1, 0, 0, hexFunc          ),
    FUNCTION(ifnull,             2, 0, 1, ifnullFunc       ),
    FUNCTION(random,            -1, 0, 0, randomFunc       ),
    FUNCTION(randomblob,         1, 0, 0, randomBlob       ),
    FUNCTION(nullif,             2, 0, 1, nullifFunc       ),
    FUNCTION(sqlite_version,     0, 0, 0, versionFunc      ),
    FUNCTION(quote,              1, 0, 0, quoteFunc        ),
    FUNCTION(last_insert_rowid,  0, 0, 0, last_insert_rowid),
    FUNCTION(changes,            0, 0, 0, changes          ),
    FUNCTION(total_changes,      0, 0, 0, total_changes    ),
    FUNCTION(replace,            3, 0, 0, replaceFunc      ),
    FUNCTION(zeroblob,           1, 0, 0, zeroblobFunc     ),
  #ifdef SQLITE_SOUNDEX
    FUNCTION(soundex,            1, 0, 0, soundexFunc      ),
  #endif
  #ifndef SQLITE_OMIT_LOAD_EXTENSION
    FUNCTION(load_extension,     1, 0, 0, loadExt          ),
    FUNCTION(load_extension,     2, 0, 0, loadExt          ),
  #endif
    AGGREGATE(sum,               1, 0, 0, sumStep,         sumFinalize    ),
    AGGREGATE(total,             1, 0, 0, sumStep,         totalFinalize    ),
    AGGREGATE(avg,               1, 0, 0, sumStep,         avgFinalize    ),
    AGGREGATE(count,             0, 0, 0, countStep,       countFinalize  ),
    AGGREGATE(count,             1, 0, 0, countStep,       countFinalize  ),
    AGGREGATE(group_concat,     -1, 0, 0, groupConcatStep, groupConcatFinalize),
  
    LIKEFUNC(glob, 2, &globInfo, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
  #ifdef SQLITE_CASE_SENSITIVE_LIKE
    LIKEFUNC(like, 2, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
    LIKEFUNC(like, 3, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
  #else
    LIKEFUNC(like, 2, &likeInfoNorm, SQLITE_FUNC_LIKE),
    LIKEFUNC(like, 3, &likeInfoNorm, SQLITE_FUNC_LIKE),
  #endif
  };









  int i;

  FuncDefHash *pHash = &GLOBAL(FuncDefHash, sqlite3GlobalFunctions);
  FuncDef *aFunc = &GLOBAL(FuncDef, aBuiltinFunc);

  for(i=0; i<ArraySize(aBuiltinFunc); i++){
    sqlite3FuncDefInsert(pHash, &aFunc[i]);
  }
  sqlite3RegisterDateTimeFunctions();
}