Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Replace the randomHex() function with separate functions randomBlob() and hex(). (CVS 3620) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
f5ad74a9bc57e83c11beb3cf46bb6cd8 |
User & Date: | drh 2007-01-29 17:58:28.000 |
Context
2007-01-31
| ||
23:37 | Fixed incorrect typecast for flock structure ptr in fcntl() call in sqlite3TestLockingStyle() Restored previous fullfsync behavior, try fsync() if fcntl(fd, F_FULLFSYNC, 0) returns an error. (CVS 3621) (check-in: f044c5f49f user: aswift tags: trunk) | |
2007-01-29
| ||
17:58 | Replace the randomHex() function with separate functions randomBlob() and hex(). (CVS 3620) (check-in: f5ad74a9bc user: drh tags: trunk) | |
15:50 | Add the randomhex() function as a built-in. (CVS 3619) (check-in: a6001589ab user: drh tags: trunk) | |
Changes
Changes to src/func.c.
︙ | |||
12 13 14 15 16 17 18 | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | - + | ** 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. ** |
︙ | |||
269 270 271 272 273 274 275 | 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | - - + + - + - - + + - - - - + + + - - - - - - - - + | sqlite3Randomness(sizeof(r), &r); if( (r<<1)==0 ) r = 0; /* Prevent 0x8000.... as the result so that we */ /* can always do abs() of the result */ sqlite3_result_int64(context, r); } /* |
︙ | |||
571 572 573 574 575 576 577 578 579 580 581 582 583 584 | 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 | + + + + + + | sqlite3_context *context, int argc, sqlite3_value **argv ){ sqlite3_result_text(context, sqlite3_version, -1, SQLITE_STATIC); } /* Array for converting from half-bytes (nybbles) into ASCII hex ** digits. */ static const char hexdigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; /* ** EXPERIMENTAL - This is not an official function. The interface may ** change. This function may disappear. Do not write code that depends ** on this function. ** ** Implementation of the QUOTE() function. This function takes a single |
︙ | |||
596 597 598 599 600 601 602 | 594 595 596 597 598 599 600 601 602 603 604 605 606 607 | - - - - | } case SQLITE_INTEGER: case SQLITE_FLOAT: { sqlite3_result_value(context, argv[0]); break; } case SQLITE_BLOB: { |
︙ | |||
644 645 646 647 648 649 650 651 652 653 654 655 | 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 | + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + | z[j++] = '\''; z[j] = 0; sqlite3_result_text(context, z, j, SQLITE_TRANSIENT); sqliteFree(z); } } } /* ** The hex() function. Interpret the argument as a blob. Return ** a hexadecimal rendering as text. */ static void hexFunc( sqlite3_context *context, int argc, sqlite3_value **argv ){ int i, n; const unsigned char *pBlob; char *zHex, *z; assert( argc==1 ); pBlob = sqlite3_value_blob(argv[0]); n = sqlite3_value_bytes(argv[0]); z = zHex = sqlite3_malloc(n*2 + 1); if( zHex==0 ) return; for(i=0; i<n; i++, pBlob++){ unsigned char c = *pBlob; *(z++) = hexdigits[(c>>4)&0xf]; *(z++) = hexdigits[c&0xf]; } *z = 0; sqlite3_result_text(context, zHex, n*2, sqlite3_free); } #ifdef SQLITE_SOUNDEX /* ** Compute the soundex encoding of a word. */ |
︙ | |||
1045 1046 1047 1048 1049 1050 1051 1052 1053 | 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 | + - + | { "round", 1, 0, SQLITE_UTF8, 0, roundFunc }, { "round", 2, 0, SQLITE_UTF8, 0, roundFunc }, { "upper", 1, 0, SQLITE_UTF8, 0, upperFunc }, { "lower", 1, 0, SQLITE_UTF8, 0, lowerFunc }, { "coalesce", -1, 0, SQLITE_UTF8, 0, ifnullFunc }, { "coalesce", 0, 0, SQLITE_UTF8, 0, 0 }, { "coalesce", 1, 0, SQLITE_UTF8, 0, 0 }, { "hex", 1, 0, SQLITE_UTF8, 0, hexFunc }, { "ifnull", 2, 0, SQLITE_UTF8, 1, ifnullFunc }, { "random", -1, 0, SQLITE_UTF8, 0, randomFunc }, |
︙ |
Changes to test/func.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | - + | # 2001 September 15 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing built-in functions. # |
︙ | |||
299 300 301 302 303 304 305 | 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 | - + - + - + - - + + - + + + + + + + + | do_test func-9.2 { execsql { SELECT typeof(random()); } } {integer} do_test func-9.3 { execsql { |
︙ |
Changes to www/lang.tcl.
1 2 3 | 1 2 3 4 5 6 7 8 9 10 11 | - + | # # Run this Tcl script to generate the lang-*.html files. # |
︙ | |||
1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 | 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 | + + + + + + | <tr> <td valign="top" align="right">ifnull(<i>X</i>,<i>Y</i>)</td> <td valign="top">Return a copy of the first non-NULL argument. If both arguments are NULL then NULL is returned. This behaves the same as <b>coalesce()</b> above.</td> </tr> <tr> <td valign="top" align="right">hex(<i>X</i>)</td> <td valign="top">The argument is interpreted as a BLOB. The result is a hexadecimal rendering of the content of that blob.</td> </tr> <tr> <td valign="top" align="right">last_insert_rowid()</td> <td valign="top">Return the ROWID of the last row insert from this connection to the database. This is the same value that would be returned from the <b>sqlite_last_insert_rowid()</b> API function.</td> </tr> |
︙ | |||
1370 1371 1372 1373 1374 1375 1376 | 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 | - - - + + + - - - | <tr> <td valign="top" align="right">random(*)</td> <td valign="top">Return a pseudo-random integer between -9223372036854775808 and +9223372036854775807.</td> </tr> <tr> |
︙ |