Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch instr Excluding Merge-Ins
This is equivalent to a diff from aaa2d9b0db to 49ccae964f
2012-11-05
| ||
13:51 | Add the INSTR() SQL function. (check-in: a4c181cbcf user: drh tags: trunk) | |
2012-10-25
| ||
15:23 | Improvements to the command-line argument parsing in the command-line shell. Command-line options can now occur either before or after the database name and first command and are still accepted and processed. Command-line options are processed even if no database name is given (and :memory: is assumed). (check-in: 317c80cba3 user: drh tags: trunk) | |
03:07 | Implementation of the INSTR() SQL function, as found in SQL Server, MySQL, and Oracle. (Closed-Leaf check-in: 49ccae964f user: drh tags: instr) | |
01:50 | Initial check-in of a test VFS designed to simulate a NAND-flash SSD for the purpose of measuring and subsequently minimizing write amplification caused by SQLite. The code in this check-in compiles but does not run. (check-in: 9e6efcf054 user: drh tags: ssdsim) | |
2012-10-20
| ||
08:40 | Modify VSIX build tools in support of an additional package flavor. (check-in: 702ebc646b user: mistachkin tags: vsixFlavor) | |
2012-10-19
| ||
02:10 | Make sure substructure elements have proper alignment in the ICU tokenizers of FTS2 and FTS3. (check-in: aaa2d9b0db user: drh tags: trunk) | |
00:23 | Add detailed comments to the build tools used to generate the VSIX package. Also, allow the build configurations and native library directories to be overridden for the multi-platform build tool for MSVC. (check-in: 0482c73bfd user: mistachkin tags: trunk) | |
Changes to src/func.c.
︙ | |||
163 164 165 166 167 168 169 170 171 172 173 174 175 176 | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | double rVal = sqlite3_value_double(argv[0]); if( rVal<0 ) rVal = -rVal; sqlite3_result_double(context, rVal); break; } } } /* ** Implementation of the instr() function. ** ** instr(haystack,needle) finds the first occurrence of needle ** in haystack and returns the number of previous characters plus 1, ** or 0 if needle does not occur within haystack. ** ** If both haystack and needle are BLOBs, then the result is one more than ** the number of bytes in haystack prior to the first occurrence of needle, ** or 0 if needle never occurs in haystack. */ static void instrFunc( sqlite3_context *context, int argc, sqlite3_value **argv ){ const unsigned char *zHaystack; const unsigned char *zNeedle; int nHaystack; int nNeedle; int typeHaystack, typeNeedle; int N = 1; int isText; typeHaystack = sqlite3_value_type(argv[0]); typeNeedle = sqlite3_value_type(argv[1]); if( typeHaystack==SQLITE_NULL || typeNeedle==SQLITE_NULL ) return; nHaystack = sqlite3_value_bytes(argv[0]); nNeedle = sqlite3_value_bytes(argv[1]); if( typeHaystack==SQLITE_BLOB && typeNeedle==SQLITE_BLOB ){ zHaystack = sqlite3_value_blob(argv[0]); zNeedle = sqlite3_value_blob(argv[1]); isText = 0; }else{ zHaystack = sqlite3_value_text(argv[0]); zNeedle = sqlite3_value_text(argv[1]); isText = 1; } while( nNeedle<=nHaystack && memcmp(zHaystack, zNeedle, nNeedle)!=0 ){ N++; do{ nHaystack--; zHaystack++; }while( isText && (zHaystack[0]&0xc0)==0x80 ); } if( nNeedle>nHaystack ) N = 0; sqlite3_result_int(context, N); } /* ** Implementation of the substr() function. ** ** substr(x,p1,p2) returns p2 characters of x[] beginning with p1. ** p1 is 1-indexed. So substr(x,1,1) returns the first character ** of x. If x is text, then we actually count UTF-8 characters. |
︙ | |||
1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 | 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 | + | 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 ), FUNCTION2(typeof, 1, 0, 0, typeofFunc, SQLITE_FUNC_TYPEOF), FUNCTION2(length, 1, 0, 0, lengthFunc, SQLITE_FUNC_LENGTH), FUNCTION(instr, 2, 0, 0, instrFunc ), FUNCTION(substr, 2, 0, 0, substrFunc ), FUNCTION(substr, 3, 0, 0, substrFunc ), FUNCTION(abs, 1, 0, 0, absFunc ), #ifndef SQLITE_OMIT_FLOATING_POINT FUNCTION(round, 1, 0, 0, roundFunc ), FUNCTION(round, 2, 0, 0, roundFunc ), #endif |
︙ |
Added test/instr.test.