| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/sqlite/src/src/func.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||||||||
| 6 | static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){ | - | ||||||||||||||||||||||||||||||
| 7 | VdbeOp *pOp; | - | ||||||||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||||||||
| 9 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 10 | ; | - | ||||||||||||||||||||||||||||||
| 11 | pOp = &context->pVdbe->aOp[context->iOp-1]; | - | ||||||||||||||||||||||||||||||
| 12 | - | |||||||||||||||||||||||||||||||
| 13 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 14 | ; | - | ||||||||||||||||||||||||||||||
| 15 | - | |||||||||||||||||||||||||||||||
| 16 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 17 | ; | - | ||||||||||||||||||||||||||||||
| 18 | return executed 458361 times by 1 test: pOp->p4.pColl;return pOp->p4.pColl;Executed by:
executed 458361 times by 1 test: return pOp->p4.pColl;Executed by:
| 458361 | ||||||||||||||||||||||||||||||
| 19 | } | - | ||||||||||||||||||||||||||||||
| 20 | - | |||||||||||||||||||||||||||||||
| 21 | - | |||||||||||||||||||||||||||||||
| 22 | - | |||||||||||||||||||||||||||||||
| 23 | - | |||||||||||||||||||||||||||||||
| 24 | - | |||||||||||||||||||||||||||||||
| 25 | static void sqlite3SkipAccumulatorLoad(sqlite3_context *context){ | - | ||||||||||||||||||||||||||||||
| 26 | - | |||||||||||||||||||||||||||||||
| 27 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 28 | ; | - | ||||||||||||||||||||||||||||||
| 29 | context->isError = -1; | - | ||||||||||||||||||||||||||||||
| 30 | context->skipFlag = 1; | - | ||||||||||||||||||||||||||||||
| 31 | } executed 69306 times by 1 test: end of blockExecuted by:
| 69306 | ||||||||||||||||||||||||||||||
| 32 | - | |||||||||||||||||||||||||||||||
| 33 | - | |||||||||||||||||||||||||||||||
| 34 | - | |||||||||||||||||||||||||||||||
| 35 | - | |||||||||||||||||||||||||||||||
| 36 | static void minmaxFunc( | - | ||||||||||||||||||||||||||||||
| 37 | sqlite3_context *context, | - | ||||||||||||||||||||||||||||||
| 38 | int argc, | - | ||||||||||||||||||||||||||||||
| 39 | sqlite3_value **argv | - | ||||||||||||||||||||||||||||||
| 40 | ){ | - | ||||||||||||||||||||||||||||||
| 41 | int i; | - | ||||||||||||||||||||||||||||||
| 42 | int mask; | - | ||||||||||||||||||||||||||||||
| 43 | int iBest; | - | ||||||||||||||||||||||||||||||
| 44 | CollSeq *pColl; | - | ||||||||||||||||||||||||||||||
| 45 | - | |||||||||||||||||||||||||||||||
| 46 | - | |||||||||||||||||||||||||||||||
| 47 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 48 | ; | - | ||||||||||||||||||||||||||||||
| 49 | mask = sqlite3_user_data(context)==0
| 43060-44495 | ||||||||||||||||||||||||||||||
| 50 | pColl = sqlite3GetFuncCollSeq(context); | - | ||||||||||||||||||||||||||||||
| 51 | - | |||||||||||||||||||||||||||||||
| 52 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 53 | ; | - | ||||||||||||||||||||||||||||||
| 54 | - | |||||||||||||||||||||||||||||||
| 55 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 56 | ; | - | ||||||||||||||||||||||||||||||
| 57 | iBest = 0; | - | ||||||||||||||||||||||||||||||
| 58 | if( sqlite3_value_type(argv[0])==5
executed 8 times by 1 test: return;Executed by:
| 8-87547 | ||||||||||||||||||||||||||||||
| 59 | for(i=1; i<argc
| 87545-87572 | ||||||||||||||||||||||||||||||
| 60 | if( sqlite3_value_type(argv[i])==5
executed 2 times by 1 test: return;Executed by:
| 2-87570 | ||||||||||||||||||||||||||||||
| 61 | if( (
| 43409-44161 | ||||||||||||||||||||||||||||||
| 62 | ; | - | ||||||||||||||||||||||||||||||
| 63 | iBest = i; | - | ||||||||||||||||||||||||||||||
| 64 | } executed 43409 times by 1 test: end of blockExecuted by:
| 43409 | ||||||||||||||||||||||||||||||
| 65 | } executed 87570 times by 1 test: end of blockExecuted by:
| 87570 | ||||||||||||||||||||||||||||||
| 66 | sqlite3_result_value(context, argv[iBest]); | - | ||||||||||||||||||||||||||||||
| 67 | } executed 87545 times by 1 test: end of blockExecuted by:
| 87545 | ||||||||||||||||||||||||||||||
| 68 | - | |||||||||||||||||||||||||||||||
| 69 | - | |||||||||||||||||||||||||||||||
| 70 | - | |||||||||||||||||||||||||||||||
| 71 | - | |||||||||||||||||||||||||||||||
| 72 | static void typeofFunc( | - | ||||||||||||||||||||||||||||||
| 73 | sqlite3_context *context, | - | ||||||||||||||||||||||||||||||
| 74 | int NotUsed, | - | ||||||||||||||||||||||||||||||
| 75 | sqlite3_value **argv | - | ||||||||||||||||||||||||||||||
| 76 | ){ | - | ||||||||||||||||||||||||||||||
| 77 | static const char *azType[] = { "integer", "real", "text", "blob", "null" }; | - | ||||||||||||||||||||||||||||||
| 78 | int i = sqlite3_value_type(argv[0]) - 1; | - | ||||||||||||||||||||||||||||||
| 79 | (void)(NotUsed); | - | ||||||||||||||||||||||||||||||
| 80 | - | |||||||||||||||||||||||||||||||
| 81 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 82 | ; | - | ||||||||||||||||||||||||||||||
| 83 | - | |||||||||||||||||||||||||||||||
| 84 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 85 | ; | - | ||||||||||||||||||||||||||||||
| 86 | - | |||||||||||||||||||||||||||||||
| 87 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 88 | ; | - | ||||||||||||||||||||||||||||||
| 89 | - | |||||||||||||||||||||||||||||||
| 90 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 91 | ; | - | ||||||||||||||||||||||||||||||
| 92 | - | |||||||||||||||||||||||||||||||
| 93 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 94 | ; | - | ||||||||||||||||||||||||||||||
| 95 | - | |||||||||||||||||||||||||||||||
| 96 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 97 | ; | - | ||||||||||||||||||||||||||||||
| 98 | - | |||||||||||||||||||||||||||||||
| 99 | - | |||||||||||||||||||||||||||||||
| 100 | - | |||||||||||||||||||||||||||||||
| 101 | - | |||||||||||||||||||||||||||||||
| 102 | sqlite3_result_text(context, azType[i], -1, ((sqlite3_destructor_type)0)); | - | ||||||||||||||||||||||||||||||
| 103 | } executed 6310 times by 1 test: end of blockExecuted by:
| 6310 | ||||||||||||||||||||||||||||||
| 104 | - | |||||||||||||||||||||||||||||||
| 105 | - | |||||||||||||||||||||||||||||||
| 106 | - | |||||||||||||||||||||||||||||||
| 107 | - | |||||||||||||||||||||||||||||||
| 108 | - | |||||||||||||||||||||||||||||||
| 109 | static void lengthFunc( | - | ||||||||||||||||||||||||||||||
| 110 | sqlite3_context *context, | - | ||||||||||||||||||||||||||||||
| 111 | int argc, | - | ||||||||||||||||||||||||||||||
| 112 | sqlite3_value **argv | - | ||||||||||||||||||||||||||||||
| 113 | ){ | - | ||||||||||||||||||||||||||||||
| 114 | - | |||||||||||||||||||||||||||||||
| 115 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 116 | ; | - | ||||||||||||||||||||||||||||||
| 117 | (void)(argc); | - | ||||||||||||||||||||||||||||||
| 118 | switch( sqlite3_value_type(argv[0]) ){ | - | ||||||||||||||||||||||||||||||
| 119 | case executed 11509 times by 1 test: 4:case 4:Executed by:
executed 11509 times by 1 test: case 4:Executed by:
| 11509 | ||||||||||||||||||||||||||||||
| 120 | case executed 12 times by 1 test: 1:case 1:Executed by:
executed 12 times by 1 test: case 1:Executed by:
| 12 | ||||||||||||||||||||||||||||||
| 121 | case executed 2 times by 1 test: 2:case 2:Executed by:
executed 2 times by 1 test: {case 2:Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 122 | sqlite3_result_int(context, sqlite3_value_bytes(argv[0])); | - | ||||||||||||||||||||||||||||||
| 123 | break; executed 11523 times by 1 test: break;Executed by:
| 11523 | ||||||||||||||||||||||||||||||
| 124 | } | - | ||||||||||||||||||||||||||||||
| 125 | case executed 19351 times by 1 test: 3:case 3:Executed by:
executed 19351 times by 1 test: {case 3:Executed by:
| 19351 | ||||||||||||||||||||||||||||||
| 126 | const unsigned char *z = sqlite3_value_text(argv[0]); | - | ||||||||||||||||||||||||||||||
| 127 | const unsigned char *z0; | - | ||||||||||||||||||||||||||||||
| 128 | unsigned char c; | - | ||||||||||||||||||||||||||||||
| 129 | if( z==0
never executed: return; | 0-19351 | ||||||||||||||||||||||||||||||
| 130 | z0 = z; | - | ||||||||||||||||||||||||||||||
| 131 | while( (
| 19351-21462987 | ||||||||||||||||||||||||||||||
| 132 | z++; | - | ||||||||||||||||||||||||||||||
| 133 | if( c>=0xc0
| 7-21462980 | ||||||||||||||||||||||||||||||
| 134 | while( (*
executed 29 times by 1 test: end of blockExecuted by:
| 7-29 | ||||||||||||||||||||||||||||||
| 135 | } executed 7 times by 1 test: end of blockExecuted by:
| 7 | ||||||||||||||||||||||||||||||
| 136 | } executed 21462987 times by 1 test: end of blockExecuted by:
| 21462987 | ||||||||||||||||||||||||||||||
| 137 | sqlite3_result_int(context, (int)(z-z0)); | - | ||||||||||||||||||||||||||||||
| 138 | break; executed 19351 times by 1 test: break;Executed by:
| 19351 | ||||||||||||||||||||||||||||||
| 139 | } | - | ||||||||||||||||||||||||||||||
| 140 | default executed 10 times by 1 test: :default:Executed by:
executed 10 times by 1 test: {default:Executed by:
| 10 | ||||||||||||||||||||||||||||||
| 141 | sqlite3_result_null(context); | - | ||||||||||||||||||||||||||||||
| 142 | break; executed 10 times by 1 test: break;Executed by:
| 10 | ||||||||||||||||||||||||||||||
| 143 | } | - | ||||||||||||||||||||||||||||||
| 144 | } | - | ||||||||||||||||||||||||||||||
| 145 | } | - | ||||||||||||||||||||||||||||||
| 146 | - | |||||||||||||||||||||||||||||||
| 147 | - | |||||||||||||||||||||||||||||||
| 148 | - | |||||||||||||||||||||||||||||||
| 149 | - | |||||||||||||||||||||||||||||||
| 150 | - | |||||||||||||||||||||||||||||||
| 151 | - | |||||||||||||||||||||||||||||||
| 152 | - | |||||||||||||||||||||||||||||||
| 153 | static void absFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ | - | ||||||||||||||||||||||||||||||
| 154 | - | |||||||||||||||||||||||||||||||
| 155 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 156 | ; | - | ||||||||||||||||||||||||||||||
| 157 | (void)(argc); | - | ||||||||||||||||||||||||||||||
| 158 | switch( sqlite3_value_type(argv[0]) ){ | - | ||||||||||||||||||||||||||||||
| 159 | case executed 5280 times by 1 test: 1:case 1:Executed by:
executed 5280 times by 1 test: {case 1:Executed by:
| 5280 | ||||||||||||||||||||||||||||||
| 160 | i64 iVal = sqlite3_value_int64(argv[0]); | - | ||||||||||||||||||||||||||||||
| 161 | if( iVal<0
| 641-4639 | ||||||||||||||||||||||||||||||
| 162 | if( iVal==(((i64)-1) - (0xffffffff|(((i64)0x7fffffff)<<32)))
| 1-640 | ||||||||||||||||||||||||||||||
| 163 | - | |||||||||||||||||||||||||||||||
| 164 | - | |||||||||||||||||||||||||||||||
| 165 | - | |||||||||||||||||||||||||||||||
| 166 | sqlite3_result_error(context, "integer overflow", -1); | - | ||||||||||||||||||||||||||||||
| 167 | return; executed 1 time by 1 test: return;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 168 | } | - | ||||||||||||||||||||||||||||||
| 169 | iVal = -iVal; | - | ||||||||||||||||||||||||||||||
| 170 | } executed 640 times by 1 test: end of blockExecuted by:
| 640 | ||||||||||||||||||||||||||||||
| 171 | sqlite3_result_int64(context, iVal); | - | ||||||||||||||||||||||||||||||
| 172 | break; executed 5279 times by 1 test: break;Executed by:
| 5279 | ||||||||||||||||||||||||||||||
| 173 | } | - | ||||||||||||||||||||||||||||||
| 174 | case executed 19 times by 1 test: 5:case 5:Executed by:
executed 19 times by 1 test: {case 5:Executed by:
| 19 | ||||||||||||||||||||||||||||||
| 175 | - | |||||||||||||||||||||||||||||||
| 176 | sqlite3_result_null(context); | - | ||||||||||||||||||||||||||||||
| 177 | break; executed 19 times by 1 test: break;Executed by:
| 19 | ||||||||||||||||||||||||||||||
| 178 | } | - | ||||||||||||||||||||||||||||||
| 179 | default executed 17 times by 1 test: :default:Executed by:
executed 17 times by 1 test: {default:Executed by:
| 17 | ||||||||||||||||||||||||||||||
| 180 | - | |||||||||||||||||||||||||||||||
| 181 | - | |||||||||||||||||||||||||||||||
| 182 | - | |||||||||||||||||||||||||||||||
| 183 | - | |||||||||||||||||||||||||||||||
| 184 | - | |||||||||||||||||||||||||||||||
| 185 | double rVal = sqlite3_value_double(argv[0]); | - | ||||||||||||||||||||||||||||||
| 186 | if( rVal<0
executed 2 times by 1 test: rVal = -rVal;Executed by:
| 2-15 | ||||||||||||||||||||||||||||||
| 187 | sqlite3_result_double(context, rVal); | - | ||||||||||||||||||||||||||||||
| 188 | break; executed 17 times by 1 test: break;Executed by:
| 17 | ||||||||||||||||||||||||||||||
| 189 | } | - | ||||||||||||||||||||||||||||||
| 190 | } | - | ||||||||||||||||||||||||||||||
| 191 | } | - | ||||||||||||||||||||||||||||||
| 192 | static void instrFunc( | - | ||||||||||||||||||||||||||||||
| 193 | sqlite3_context *context, | - | ||||||||||||||||||||||||||||||
| 194 | int argc, | - | ||||||||||||||||||||||||||||||
| 195 | sqlite3_value **argv | - | ||||||||||||||||||||||||||||||
| 196 | ){ | - | ||||||||||||||||||||||||||||||
| 197 | const unsigned char *zHaystack; | - | ||||||||||||||||||||||||||||||
| 198 | const unsigned char *zNeedle; | - | ||||||||||||||||||||||||||||||
| 199 | int nHaystack; | - | ||||||||||||||||||||||||||||||
| 200 | int nNeedle; | - | ||||||||||||||||||||||||||||||
| 201 | int typeHaystack, typeNeedle; | - | ||||||||||||||||||||||||||||||
| 202 | int N = 1; | - | ||||||||||||||||||||||||||||||
| 203 | int isText; | - | ||||||||||||||||||||||||||||||
| 204 | - | |||||||||||||||||||||||||||||||
| 205 | (void)(argc); | - | ||||||||||||||||||||||||||||||
| 206 | typeHaystack = sqlite3_value_type(argv[0]); | - | ||||||||||||||||||||||||||||||
| 207 | typeNeedle = sqlite3_value_type(argv[1]); | - | ||||||||||||||||||||||||||||||
| 208 | if( typeHaystack==5
executed 5 times by 1 test: return;Executed by:
| 2-4705 | ||||||||||||||||||||||||||||||
| 209 | nHaystack = sqlite3_value_bytes(argv[0]); | - | ||||||||||||||||||||||||||||||
| 210 | nNeedle = sqlite3_value_bytes(argv[1]); | - | ||||||||||||||||||||||||||||||
| 211 | if( nNeedle>0
| 4-4699 | ||||||||||||||||||||||||||||||
| 212 | if( typeHaystack==4
| 5-4679 | ||||||||||||||||||||||||||||||
| 213 | zHaystack = sqlite3_value_blob(argv[0]); | - | ||||||||||||||||||||||||||||||
| 214 | zNeedle = sqlite3_value_blob(argv[1]); | - | ||||||||||||||||||||||||||||||
| 215 | isText = 0; | - | ||||||||||||||||||||||||||||||
| 216 | } executed 15 times by 1 test: else{end of blockExecuted by:
| 15 | ||||||||||||||||||||||||||||||
| 217 | zHaystack = sqlite3_value_text(argv[0]); | - | ||||||||||||||||||||||||||||||
| 218 | zNeedle = sqlite3_value_text(argv[1]); | - | ||||||||||||||||||||||||||||||
| 219 | isText = 1; | - | ||||||||||||||||||||||||||||||
| 220 | } executed 4684 times by 1 test: end of blockExecuted by:
| 4684 | ||||||||||||||||||||||||||||||
| 221 | if( zNeedle==0
never executed: return; | 0-4699 | ||||||||||||||||||||||||||||||
| 222 | while( nNeedle<=nHaystack
| 21-1006645 | ||||||||||||||||||||||||||||||
| 223 | N++; | - | ||||||||||||||||||||||||||||||
| 224 | do{ | - | ||||||||||||||||||||||||||||||
| 225 | nHaystack--; | - | ||||||||||||||||||||||||||||||
| 226 | zHaystack++; | - | ||||||||||||||||||||||||||||||
| 227 | } executed 1018369 times by 1 test: while( isTextend of blockExecuted by:
| 40-1018369 | ||||||||||||||||||||||||||||||
| 228 | } executed 1001967 times by 1 test: end of blockExecuted by:
| 1001967 | ||||||||||||||||||||||||||||||
| 229 | if( nNeedle>nHaystack
executed 21 times by 1 test: N = 0;Executed by:
| 21-4678 | ||||||||||||||||||||||||||||||
| 230 | } executed 4699 times by 1 test: end of blockExecuted by:
| 4699 | ||||||||||||||||||||||||||||||
| 231 | sqlite3_result_int(context, N); | - | ||||||||||||||||||||||||||||||
| 232 | } executed 4703 times by 1 test: end of blockExecuted by:
| 4703 | ||||||||||||||||||||||||||||||
| 233 | - | |||||||||||||||||||||||||||||||
| 234 | - | |||||||||||||||||||||||||||||||
| 235 | - | |||||||||||||||||||||||||||||||
| 236 | - | |||||||||||||||||||||||||||||||
| 237 | static void printfFunc( | - | ||||||||||||||||||||||||||||||
| 238 | sqlite3_context *context, | - | ||||||||||||||||||||||||||||||
| 239 | int argc, | - | ||||||||||||||||||||||||||||||
| 240 | sqlite3_value **argv | - | ||||||||||||||||||||||||||||||
| 241 | ){ | - | ||||||||||||||||||||||||||||||
| 242 | PrintfArguments x; | - | ||||||||||||||||||||||||||||||
| 243 | StrAccum str; | - | ||||||||||||||||||||||||||||||
| 244 | const char *zFormat; | - | ||||||||||||||||||||||||||||||
| 245 | int n; | - | ||||||||||||||||||||||||||||||
| 246 | sqlite3 *db = sqlite3_context_db_handle(context); | - | ||||||||||||||||||||||||||||||
| 247 | - | |||||||||||||||||||||||||||||||
| 248 | if( argc>=1
| 1-12013 | ||||||||||||||||||||||||||||||
| 249 | x.nArg = argc-1; | - | ||||||||||||||||||||||||||||||
| 250 | x.nUsed = 0; | - | ||||||||||||||||||||||||||||||
| 251 | x.apArg = argv+1; | - | ||||||||||||||||||||||||||||||
| 252 | sqlite3StrAccumInit(&str, db, 0, 0, db->aLimit[0]); | - | ||||||||||||||||||||||||||||||
| 253 | str.printfFlags = 0x02; | - | ||||||||||||||||||||||||||||||
| 254 | sqlite3_str_appendf(&str, zFormat, &x); | - | ||||||||||||||||||||||||||||||
| 255 | n = str.nChar; | - | ||||||||||||||||||||||||||||||
| 256 | sqlite3_result_text(context, sqlite3StrAccumFinish(&str), n, | - | ||||||||||||||||||||||||||||||
| 257 | ((sqlite3_destructor_type)sqlite3MallocSize)); | - | ||||||||||||||||||||||||||||||
| 258 | } executed 12012 times by 1 test: end of blockExecuted by:
| 12012 | ||||||||||||||||||||||||||||||
| 259 | } executed 12014 times by 1 test: end of blockExecuted by:
| 12014 | ||||||||||||||||||||||||||||||
| 260 | static void substrFunc( | - | ||||||||||||||||||||||||||||||
| 261 | sqlite3_context *context, | - | ||||||||||||||||||||||||||||||
| 262 | int argc, | - | ||||||||||||||||||||||||||||||
| 263 | sqlite3_value **argv | - | ||||||||||||||||||||||||||||||
| 264 | ){ | - | ||||||||||||||||||||||||||||||
| 265 | const unsigned char *z; | - | ||||||||||||||||||||||||||||||
| 266 | const unsigned char *z2; | - | ||||||||||||||||||||||||||||||
| 267 | int len; | - | ||||||||||||||||||||||||||||||
| 268 | int p0type; | - | ||||||||||||||||||||||||||||||
| 269 | i64 p1, p2; | - | ||||||||||||||||||||||||||||||
| 270 | int negP2 = 0; | - | ||||||||||||||||||||||||||||||
| 271 | - | |||||||||||||||||||||||||||||||
| 272 | - | |||||||||||||||||||||||||||||||
| 273 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 274 | ; | - | ||||||||||||||||||||||||||||||
| 275 | if( sqlite3_value_type(argv[1])==5
| 2-433356 | ||||||||||||||||||||||||||||||
| 276 | || (argc==3
| 1-423686 | ||||||||||||||||||||||||||||||
| 277 | ){ | - | ||||||||||||||||||||||||||||||
| 278 | return; executed 3 times by 1 test: return;Executed by:
| 3 | ||||||||||||||||||||||||||||||
| 279 | } | - | ||||||||||||||||||||||||||||||
| 280 | p0type = sqlite3_value_type(argv[0]); | - | ||||||||||||||||||||||||||||||
| 281 | p1 = sqlite3_value_int(argv[1]); | - | ||||||||||||||||||||||||||||||
| 282 | if( p0type==4
| 79-433276 | ||||||||||||||||||||||||||||||
| 283 | len = sqlite3_value_bytes(argv[0]); | - | ||||||||||||||||||||||||||||||
| 284 | z = sqlite3_value_blob(argv[0]); | - | ||||||||||||||||||||||||||||||
| 285 | if( z==0
never executed: return; | 0-79 | ||||||||||||||||||||||||||||||
| 286 | - | |||||||||||||||||||||||||||||||
| 287 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 288 | ; | - | ||||||||||||||||||||||||||||||
| 289 | } executed 79 times by 1 test: else{end of blockExecuted by:
| 79 | ||||||||||||||||||||||||||||||
| 290 | z = sqlite3_value_text(argv[0]); | - | ||||||||||||||||||||||||||||||
| 291 | if( z==0
executed 6 times by 1 test: return;Executed by:
| 6-433270 | ||||||||||||||||||||||||||||||
| 292 | len = 0; | - | ||||||||||||||||||||||||||||||
| 293 | if( p1<0
| 165-433105 | ||||||||||||||||||||||||||||||
| 294 | for(z2=z; *
| 165-23024 | ||||||||||||||||||||||||||||||
| 295 | { if( (*(
executed 50 times by 1 test: }end of blockExecuted by:
executed 25 times by 1 test: };end of blockExecuted by:
| 25-22999 | ||||||||||||||||||||||||||||||
| 296 | } executed 23024 times by 1 test: end of blockExecuted by:
| 23024 | ||||||||||||||||||||||||||||||
| 297 | } executed 165 times by 1 test: end of blockExecuted by:
| 165 | ||||||||||||||||||||||||||||||
| 298 | } executed 433270 times by 1 test: end of blockExecuted by:
| 433270 | ||||||||||||||||||||||||||||||
| 299 | if( argc==3
| 9669-423680 | ||||||||||||||||||||||||||||||
| 300 | p2 = sqlite3_value_int(argv[2]); | - | ||||||||||||||||||||||||||||||
| 301 | if( p2<0
| 36-423644 | ||||||||||||||||||||||||||||||
| 302 | p2 = -p2; | - | ||||||||||||||||||||||||||||||
| 303 | negP2 = 1; | - | ||||||||||||||||||||||||||||||
| 304 | } executed 36 times by 1 test: end of blockExecuted by:
| 36 | ||||||||||||||||||||||||||||||
| 305 | } executed 423680 times by 1 test: else{end of blockExecuted by:
| 423680 | ||||||||||||||||||||||||||||||
| 306 | p2 = sqlite3_context_db_handle(context)->aLimit[0]; | - | ||||||||||||||||||||||||||||||
| 307 | } executed 9669 times by 1 test: end of blockExecuted by:
| 9669 | ||||||||||||||||||||||||||||||
| 308 | if( p1<0
| 196-433153 | ||||||||||||||||||||||||||||||
| 309 | p1 += len; | - | ||||||||||||||||||||||||||||||
| 310 | if( p1<0
| 15-181 | ||||||||||||||||||||||||||||||
| 311 | p2 += p1; | - | ||||||||||||||||||||||||||||||
| 312 | if( p2<0
executed 2 times by 1 test: p2 = 0;Executed by:
| 2-13 | ||||||||||||||||||||||||||||||
| 313 | p1 = 0; | - | ||||||||||||||||||||||||||||||
| 314 | } executed 15 times by 1 test: end of blockExecuted by:
| 15 | ||||||||||||||||||||||||||||||
| 315 | } executed 196 times by 1 test: else if( p1>0end of blockExecuted by:
| 30-433123 | ||||||||||||||||||||||||||||||
| 316 | p1--; | - | ||||||||||||||||||||||||||||||
| 317 | } executed 433123 times by 1 test: else if( p2>0end of blockExecuted by:
| 4-433123 | ||||||||||||||||||||||||||||||
| 318 | p2--; | - | ||||||||||||||||||||||||||||||
| 319 | } executed 26 times by 1 test: end of blockExecuted by:
| 26 | ||||||||||||||||||||||||||||||
| 320 | if( negP2
| 36-433313 | ||||||||||||||||||||||||||||||
| 321 | p1 -= p2; | - | ||||||||||||||||||||||||||||||
| 322 | if( p1<0
| 14-22 | ||||||||||||||||||||||||||||||
| 323 | p2 += p1; | - | ||||||||||||||||||||||||||||||
| 324 | p1 = 0; | - | ||||||||||||||||||||||||||||||
| 325 | } executed 14 times by 1 test: end of blockExecuted by:
| 14 | ||||||||||||||||||||||||||||||
| 326 | } executed 36 times by 1 test: end of blockExecuted by:
| 36 | ||||||||||||||||||||||||||||||
| 327 | - | |||||||||||||||||||||||||||||||
| 328 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 329 | ; | - | ||||||||||||||||||||||||||||||
| 330 | if( p0type!=4
| 79-433270 | ||||||||||||||||||||||||||||||
| 331 | while( *
| 16-12799701 | ||||||||||||||||||||||||||||||
| 332 | { if( (*(
executed 36 times by 1 test: }end of blockExecuted by:
executed 22 times by 1 test: };end of blockExecuted by:
| 22-12366425 | ||||||||||||||||||||||||||||||
| 333 | p1--; | - | ||||||||||||||||||||||||||||||
| 334 | } executed 12366447 times by 1 test: end of blockExecuted by:
| 12366447 | ||||||||||||||||||||||||||||||
| 335 | for(z2=z; *
| 10320-1702127 | ||||||||||||||||||||||||||||||
| 336 | { if( (*(
executed 78 times by 1 test: }end of blockExecuted by:
executed 41 times by 1 test: };end of blockExecuted by:
| 41-1279136 | ||||||||||||||||||||||||||||||
| 337 | } executed 1279177 times by 1 test: end of blockExecuted by:
| 1279177 | ||||||||||||||||||||||||||||||
| 338 | sqlite3_result_text64(context, (char*)z, z2-z, ((sqlite3_destructor_type)-1), | - | ||||||||||||||||||||||||||||||
| 339 | 1); | - | ||||||||||||||||||||||||||||||
| 340 | } executed 433270 times by 1 test: else{end of blockExecuted by:
| 433270 | ||||||||||||||||||||||||||||||
| 341 | if( p1+p2>len
| 12-67 | ||||||||||||||||||||||||||||||
| 342 | p2 = len-p1; | - | ||||||||||||||||||||||||||||||
| 343 | if( p2<0
executed 4 times by 1 test: p2 = 0;Executed by:
| 4-8 | ||||||||||||||||||||||||||||||
| 344 | } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||||||||||||||||||||||||||
| 345 | sqlite3_result_blob64(context, (char*)&z[p1], (u64)p2, ((sqlite3_destructor_type)-1)); | - | ||||||||||||||||||||||||||||||
| 346 | } executed 79 times by 1 test: end of blockExecuted by:
| 79 | ||||||||||||||||||||||||||||||
| 347 | } | - | ||||||||||||||||||||||||||||||
| 348 | - | |||||||||||||||||||||||||||||||
| 349 | - | |||||||||||||||||||||||||||||||
| 350 | - | |||||||||||||||||||||||||||||||
| 351 | - | |||||||||||||||||||||||||||||||
| 352 | - | |||||||||||||||||||||||||||||||
| 353 | static void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ | - | ||||||||||||||||||||||||||||||
| 354 | int n = 0; | - | ||||||||||||||||||||||||||||||
| 355 | double r; | - | ||||||||||||||||||||||||||||||
| 356 | char *zBuf; | - | ||||||||||||||||||||||||||||||
| 357 | - | |||||||||||||||||||||||||||||||
| 358 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 359 | ; | - | ||||||||||||||||||||||||||||||
| 360 | if( argc==2
| 1129-5297 | ||||||||||||||||||||||||||||||
| 361 | if( 5==sqlite3_value_type(argv[1])
never executed: return; | 0-1129 | ||||||||||||||||||||||||||||||
| 362 | n = sqlite3_value_int(argv[1]); | - | ||||||||||||||||||||||||||||||
| 363 | if( n>30
executed 3 times by 1 test: n = 30;Executed by:
| 3-1126 | ||||||||||||||||||||||||||||||
| 364 | if( n<0
never executed: n = 0; | 0-1129 | ||||||||||||||||||||||||||||||
| 365 | } executed 1129 times by 1 test: end of blockExecuted by:
| 1129 | ||||||||||||||||||||||||||||||
| 366 | if( sqlite3_value_type(argv[0])==5
executed 4 times by 1 test: return;Executed by:
| 4-6422 | ||||||||||||||||||||||||||||||
| 367 | r = sqlite3_value_double(argv[0]); | - | ||||||||||||||||||||||||||||||
| 368 | - | |||||||||||||||||||||||||||||||
| 369 | - | |||||||||||||||||||||||||||||||
| 370 | - | |||||||||||||||||||||||||||||||
| 371 | - | |||||||||||||||||||||||||||||||
| 372 | if( n==0
| 0-5298 | ||||||||||||||||||||||||||||||
| 373 | r = (double)((sqlite_int64)(r+0.5)); | - | ||||||||||||||||||||||||||||||
| 374 | } executed 5295 times by 1 test: else if( n==0end of blockExecuted by:
| 0-5295 | ||||||||||||||||||||||||||||||
| 375 | r = -(double)((sqlite_int64)((-r)+0.5)); | - | ||||||||||||||||||||||||||||||
| 376 | } executed 3 times by 1 test: else{end of blockExecuted by:
| 3 | ||||||||||||||||||||||||||||||
| 377 | zBuf = sqlite3_mprintf("%.*f",n,r); | - | ||||||||||||||||||||||||||||||
| 378 | if( zBuf==0
| 0-1124 | ||||||||||||||||||||||||||||||
| 379 | sqlite3_result_error_nomem(context); | - | ||||||||||||||||||||||||||||||
| 380 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 381 | } | - | ||||||||||||||||||||||||||||||
| 382 | sqlite3AtoF(zBuf, &r, sqlite3Strlen30(zBuf), 1); | - | ||||||||||||||||||||||||||||||
| 383 | sqlite3_free(zBuf); | - | ||||||||||||||||||||||||||||||
| 384 | } executed 1124 times by 1 test: end of blockExecuted by:
| 1124 | ||||||||||||||||||||||||||||||
| 385 | sqlite3_result_double(context, r); | - | ||||||||||||||||||||||||||||||
| 386 | } executed 6422 times by 1 test: end of blockExecuted by:
| 6422 | ||||||||||||||||||||||||||||||
| 387 | static void *contextMalloc(sqlite3_context *context, i64 nByte){ | - | ||||||||||||||||||||||||||||||
| 388 | char *z; | - | ||||||||||||||||||||||||||||||
| 389 | sqlite3 *db = sqlite3_context_db_handle(context); | - | ||||||||||||||||||||||||||||||
| 390 | - | |||||||||||||||||||||||||||||||
| 391 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 392 | ; | - | ||||||||||||||||||||||||||||||
| 393 | ; | - | ||||||||||||||||||||||||||||||
| 394 | ; | - | ||||||||||||||||||||||||||||||
| 395 | if( nByte>db->aLimit[0]
| 0-1321545 | ||||||||||||||||||||||||||||||
| 396 | sqlite3_result_error_toobig(context); | - | ||||||||||||||||||||||||||||||
| 397 | z = 0; | - | ||||||||||||||||||||||||||||||
| 398 | } never executed: else{end of block | 0 | ||||||||||||||||||||||||||||||
| 399 | z = sqlite3Malloc(nByte); | - | ||||||||||||||||||||||||||||||
| 400 | if( !z
| 0-1321545 | ||||||||||||||||||||||||||||||
| 401 | sqlite3_result_error_nomem(context); | - | ||||||||||||||||||||||||||||||
| 402 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 403 | } executed 1321545 times by 364 tests: end of blockExecuted by:
| 1321545 | ||||||||||||||||||||||||||||||
| 404 | return executed 1321545 times by 364 tests: z;return z;Executed by:
executed 1321545 times by 364 tests: return z;Executed by:
| 1321545 | ||||||||||||||||||||||||||||||
| 405 | } | - | ||||||||||||||||||||||||||||||
| 406 | - | |||||||||||||||||||||||||||||||
| 407 | - | |||||||||||||||||||||||||||||||
| 408 | - | |||||||||||||||||||||||||||||||
| 409 | - | |||||||||||||||||||||||||||||||
| 410 | static void upperFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ | - | ||||||||||||||||||||||||||||||
| 411 | char *z1; | - | ||||||||||||||||||||||||||||||
| 412 | const char *z2; | - | ||||||||||||||||||||||||||||||
| 413 | int i, n; | - | ||||||||||||||||||||||||||||||
| 414 | (void)(argc); | - | ||||||||||||||||||||||||||||||
| 415 | z2 = (char*)sqlite3_value_text(argv[0]); | - | ||||||||||||||||||||||||||||||
| 416 | n = sqlite3_value_bytes(argv[0]); | - | ||||||||||||||||||||||||||||||
| 417 | - | |||||||||||||||||||||||||||||||
| 418 | - | |||||||||||||||||||||||||||||||
| 419 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 420 | ; | - | ||||||||||||||||||||||||||||||
| 421 | if( z2
| 4-45 | ||||||||||||||||||||||||||||||
| 422 | z1 = contextMalloc(context, ((i64)n)+1); | - | ||||||||||||||||||||||||||||||
| 423 | if( z1
| 0-45 | ||||||||||||||||||||||||||||||
| 424 | for(i=0; i<n
| 45-136 | ||||||||||||||||||||||||||||||
| 425 | z1[i] = (char)((z2[i])&~(sqlite3CtypeMap[(unsigned char)(z2[i])]&0x20)); | - | ||||||||||||||||||||||||||||||
| 426 | } executed 136 times by 1 test: end of blockExecuted by:
| 136 | ||||||||||||||||||||||||||||||
| 427 | sqlite3_result_text(context, z1, n, sqlite3_free); | - | ||||||||||||||||||||||||||||||
| 428 | } executed 45 times by 1 test: end of blockExecuted by:
| 45 | ||||||||||||||||||||||||||||||
| 429 | } executed 45 times by 1 test: end of blockExecuted by:
| 45 | ||||||||||||||||||||||||||||||
| 430 | } executed 49 times by 1 test: end of blockExecuted by:
| 49 | ||||||||||||||||||||||||||||||
| 431 | static void lowerFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ | - | ||||||||||||||||||||||||||||||
| 432 | char *z1; | - | ||||||||||||||||||||||||||||||
| 433 | const char *z2; | - | ||||||||||||||||||||||||||||||
| 434 | int i, n; | - | ||||||||||||||||||||||||||||||
| 435 | (void)(argc); | - | ||||||||||||||||||||||||||||||
| 436 | z2 = (char*)sqlite3_value_text(argv[0]); | - | ||||||||||||||||||||||||||||||
| 437 | n = sqlite3_value_bytes(argv[0]); | - | ||||||||||||||||||||||||||||||
| 438 | - | |||||||||||||||||||||||||||||||
| 439 | - | |||||||||||||||||||||||||||||||
| 440 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 441 | ; | - | ||||||||||||||||||||||||||||||
| 442 | if( z2
| 11-69 | ||||||||||||||||||||||||||||||
| 443 | z1 = contextMalloc(context, ((i64)n)+1); | - | ||||||||||||||||||||||||||||||
| 444 | if( z1
| 0-69 | ||||||||||||||||||||||||||||||
| 445 | for(i=0; i<n
| 69-227 | ||||||||||||||||||||||||||||||
| 446 | z1[i] = (sqlite3UpperToLower[(unsigned char)(z2[i])]); | - | ||||||||||||||||||||||||||||||
| 447 | } executed 227 times by 1 test: end of blockExecuted by:
| 227 | ||||||||||||||||||||||||||||||
| 448 | sqlite3_result_text(context, z1, n, sqlite3_free); | - | ||||||||||||||||||||||||||||||
| 449 | } executed 69 times by 1 test: end of blockExecuted by:
| 69 | ||||||||||||||||||||||||||||||
| 450 | } executed 69 times by 1 test: end of blockExecuted by:
| 69 | ||||||||||||||||||||||||||||||
| 451 | } executed 80 times by 1 test: end of blockExecuted by:
| 80 | ||||||||||||||||||||||||||||||
| 452 | static void randomFunc( | - | ||||||||||||||||||||||||||||||
| 453 | sqlite3_context *context, | - | ||||||||||||||||||||||||||||||
| 454 | int NotUsed, | - | ||||||||||||||||||||||||||||||
| 455 | sqlite3_value **NotUsed2 | - | ||||||||||||||||||||||||||||||
| 456 | ){ | - | ||||||||||||||||||||||||||||||
| 457 | sqlite_int64 r; | - | ||||||||||||||||||||||||||||||
| 458 | (void)(NotUsed),(void)(NotUsed2); | - | ||||||||||||||||||||||||||||||
| 459 | sqlite3_randomness(sizeof(r), &r); | - | ||||||||||||||||||||||||||||||
| 460 | if( r<0
| 361308-361765 | ||||||||||||||||||||||||||||||
| 461 | r = -(r & (0xffffffff|(((i64)0x7fffffff)<<32))); | - | ||||||||||||||||||||||||||||||
| 462 | } executed 361308 times by 1 test: end of blockExecuted by:
| 361308 | ||||||||||||||||||||||||||||||
| 463 | sqlite3_result_int64(context, r); | - | ||||||||||||||||||||||||||||||
| 464 | } executed 723073 times by 1 test: end of blockExecuted by:
| 723073 | ||||||||||||||||||||||||||||||
| 465 | - | |||||||||||||||||||||||||||||||
| 466 | - | |||||||||||||||||||||||||||||||
| 467 | - | |||||||||||||||||||||||||||||||
| 468 | - | |||||||||||||||||||||||||||||||
| 469 | - | |||||||||||||||||||||||||||||||
| 470 | static void randomBlob( | - | ||||||||||||||||||||||||||||||
| 471 | sqlite3_context *context, | - | ||||||||||||||||||||||||||||||
| 472 | int argc, | - | ||||||||||||||||||||||||||||||
| 473 | sqlite3_value **argv | - | ||||||||||||||||||||||||||||||
| 474 | ){ | - | ||||||||||||||||||||||||||||||
| 475 | int n; | - | ||||||||||||||||||||||||||||||
| 476 | unsigned char *p; | - | ||||||||||||||||||||||||||||||
| 477 | - | |||||||||||||||||||||||||||||||
| 478 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 479 | ; | - | ||||||||||||||||||||||||||||||
| 480 | (void)(argc); | - | ||||||||||||||||||||||||||||||
| 481 | n = sqlite3_value_int(argv[0]); | - | ||||||||||||||||||||||||||||||
| 482 | if( n<1
| 1-1282287 | ||||||||||||||||||||||||||||||
| 483 | n = 1; | - | ||||||||||||||||||||||||||||||
| 484 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||||||||
| 485 | p = contextMalloc(context, n); | - | ||||||||||||||||||||||||||||||
| 486 | if( p
| 0-1282288 | ||||||||||||||||||||||||||||||
| 487 | sqlite3_randomness(n, p); | - | ||||||||||||||||||||||||||||||
| 488 | sqlite3_result_blob(context, (char*)p, n, sqlite3_free); | - | ||||||||||||||||||||||||||||||
| 489 | } executed 1282288 times by 363 tests: end of blockExecuted by:
| 1282288 | ||||||||||||||||||||||||||||||
| 490 | } executed 1282288 times by 363 tests: end of blockExecuted by:
| 1282288 | ||||||||||||||||||||||||||||||
| 491 | - | |||||||||||||||||||||||||||||||
| 492 | - | |||||||||||||||||||||||||||||||
| 493 | - | |||||||||||||||||||||||||||||||
| 494 | - | |||||||||||||||||||||||||||||||
| 495 | - | |||||||||||||||||||||||||||||||
| 496 | static void last_insert_rowid( | - | ||||||||||||||||||||||||||||||
| 497 | sqlite3_context *context, | - | ||||||||||||||||||||||||||||||
| 498 | int NotUsed, | - | ||||||||||||||||||||||||||||||
| 499 | sqlite3_value **NotUsed2 | - | ||||||||||||||||||||||||||||||
| 500 | ){ | - | ||||||||||||||||||||||||||||||
| 501 | sqlite3 *db = sqlite3_context_db_handle(context); | - | ||||||||||||||||||||||||||||||
| 502 | (void)(NotUsed),(void)(NotUsed2); | - | ||||||||||||||||||||||||||||||
| 503 | - | |||||||||||||||||||||||||||||||
| 504 | - | |||||||||||||||||||||||||||||||
| 505 | - | |||||||||||||||||||||||||||||||
| 506 | sqlite3_result_int64(context, sqlite3_last_insert_rowid(db)); | - | ||||||||||||||||||||||||||||||
| 507 | } executed 49 times by 1 test: end of blockExecuted by:
| 49 | ||||||||||||||||||||||||||||||
| 508 | static void changes( | - | ||||||||||||||||||||||||||||||
| 509 | sqlite3_context *context, | - | ||||||||||||||||||||||||||||||
| 510 | int NotUsed, | - | ||||||||||||||||||||||||||||||
| 511 | sqlite3_value **NotUsed2 | - | ||||||||||||||||||||||||||||||
| 512 | ){ | - | ||||||||||||||||||||||||||||||
| 513 | sqlite3 *db = sqlite3_context_db_handle(context); | - | ||||||||||||||||||||||||||||||
| 514 | (void)(NotUsed),(void)(NotUsed2); | - | ||||||||||||||||||||||||||||||
| 515 | sqlite3_result_int(context, sqlite3_changes(db)); | - | ||||||||||||||||||||||||||||||
| 516 | } executed 66 times by 1 test: end of blockExecuted by:
| 66 | ||||||||||||||||||||||||||||||
| 517 | - | |||||||||||||||||||||||||||||||
| 518 | - | |||||||||||||||||||||||||||||||
| 519 | - | |||||||||||||||||||||||||||||||
| 520 | - | |||||||||||||||||||||||||||||||
| 521 | - | |||||||||||||||||||||||||||||||
| 522 | static void total_changes( | - | ||||||||||||||||||||||||||||||
| 523 | sqlite3_context *context, | - | ||||||||||||||||||||||||||||||
| 524 | int NotUsed, | - | ||||||||||||||||||||||||||||||
| 525 | sqlite3_value **NotUsed2 | - | ||||||||||||||||||||||||||||||
| 526 | ){ | - | ||||||||||||||||||||||||||||||
| 527 | sqlite3 *db = sqlite3_context_db_handle(context); | - | ||||||||||||||||||||||||||||||
| 528 | (void)(NotUsed),(void)(NotUsed2); | - | ||||||||||||||||||||||||||||||
| 529 | - | |||||||||||||||||||||||||||||||
| 530 | - | |||||||||||||||||||||||||||||||
| 531 | sqlite3_result_int(context, sqlite3_total_changes(db)); | - | ||||||||||||||||||||||||||||||
| 532 | } executed 5 times by 1 test: end of blockExecuted by:
| 5 | ||||||||||||||||||||||||||||||
| 533 | - | |||||||||||||||||||||||||||||||
| 534 | - | |||||||||||||||||||||||||||||||
| 535 | - | |||||||||||||||||||||||||||||||
| 536 | - | |||||||||||||||||||||||||||||||
| 537 | struct compareInfo { | - | ||||||||||||||||||||||||||||||
| 538 | u8 matchAll; | - | ||||||||||||||||||||||||||||||
| 539 | u8 matchOne; | - | ||||||||||||||||||||||||||||||
| 540 | u8 matchSet; | - | ||||||||||||||||||||||||||||||
| 541 | u8 noCase; | - | ||||||||||||||||||||||||||||||
| 542 | }; | - | ||||||||||||||||||||||||||||||
| 543 | static const struct compareInfo globInfo = { '*', '?', '[', 0 }; | - | ||||||||||||||||||||||||||||||
| 544 | - | |||||||||||||||||||||||||||||||
| 545 | - | |||||||||||||||||||||||||||||||
| 546 | static const struct compareInfo likeInfoNorm = { '%', '_', 0, 1 }; | - | ||||||||||||||||||||||||||||||
| 547 | - | |||||||||||||||||||||||||||||||
| 548 | - | |||||||||||||||||||||||||||||||
| 549 | static const struct compareInfo likeInfoAlt = { '%', '_', 0, 0 }; | - | ||||||||||||||||||||||||||||||
| 550 | static int patternCompare( | - | ||||||||||||||||||||||||||||||
| 551 | const u8 *zPattern, | - | ||||||||||||||||||||||||||||||
| 552 | const u8 *zString, | - | ||||||||||||||||||||||||||||||
| 553 | const struct compareInfo *pInfo, | - | ||||||||||||||||||||||||||||||
| 554 | u32 matchOther | - | ||||||||||||||||||||||||||||||
| 555 | ){ | - | ||||||||||||||||||||||||||||||
| 556 | u32 c, c2; | - | ||||||||||||||||||||||||||||||
| 557 | u32 matchOne = pInfo->matchOne; | - | ||||||||||||||||||||||||||||||
| 558 | u32 matchAll = pInfo->matchAll; | - | ||||||||||||||||||||||||||||||
| 559 | u8 noCase = pInfo->noCase; | - | ||||||||||||||||||||||||||||||
| 560 | const u8 *zEscaped = 0; | - | ||||||||||||||||||||||||||||||
| 561 | - | |||||||||||||||||||||||||||||||
| 562 | while( (
| 88-66166 | ||||||||||||||||||||||||||||||
| 563 | if( c==matchAll
| 4344-59966 | ||||||||||||||||||||||||||||||
| 564 | - | |||||||||||||||||||||||||||||||
| 565 | - | |||||||||||||||||||||||||||||||
| 566 | - | |||||||||||||||||||||||||||||||
| 567 | while( (
| 0-4354 | ||||||||||||||||||||||||||||||
| 568 | if( c==matchOne
| 0-11 | ||||||||||||||||||||||||||||||
| 569 | return executed 1 time by 1 test: 2;return 2;Executed by:
executed 1 time by 1 test: return 2;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 570 | } | - | ||||||||||||||||||||||||||||||
| 571 | } executed 10 times by 1 test: end of blockExecuted by:
| 10 | ||||||||||||||||||||||||||||||
| 572 | if( c==0
| 520-3823 | ||||||||||||||||||||||||||||||
| 573 | return executed 3823 times by 1 test: 0;return 0;Executed by:
executed 3823 times by 1 test: return 0;Executed by:
| 3823 | ||||||||||||||||||||||||||||||
| 574 | }else if( c==matchOther
| 21-499 | ||||||||||||||||||||||||||||||
| 575 | if( pInfo->matchSet==0
| 8-13 | ||||||||||||||||||||||||||||||
| 576 | c = sqlite3Utf8Read(&zPattern); | - | ||||||||||||||||||||||||||||||
| 577 | if( c==0
executed 1 time by 1 test: 2;return 2;Executed by:
executed 1 time by 1 test: return 2;Executed by:
| 1-12 | ||||||||||||||||||||||||||||||
| 578 | } executed 12 times by 1 test: else{end of blockExecuted by:
| 12 | ||||||||||||||||||||||||||||||
| 579 | - | |||||||||||||||||||||||||||||||
| 580 | - | |||||||||||||||||||||||||||||||
| 581 | - | |||||||||||||||||||||||||||||||
| 582 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 583 | ; | - | ||||||||||||||||||||||||||||||
| 584 | while( *
| 4-44 | ||||||||||||||||||||||||||||||
| 585 | int bMatch = patternCompare(&zPattern[-1],zString,pInfo,matchOther); | - | ||||||||||||||||||||||||||||||
| 586 | if( bMatch!=1
executed 4 times by 1 test: bMatch;return bMatch;Executed by:
executed 4 times by 1 test: return bMatch;Executed by:
| 4-40 | ||||||||||||||||||||||||||||||
| 587 | { if( (*(
never executed: }end of blocknever executed: };end of block | 0-40 | ||||||||||||||||||||||||||||||
| 588 | } executed 40 times by 1 test: end of blockExecuted by:
| 40 | ||||||||||||||||||||||||||||||
| 589 | return executed 4 times by 1 test: 2;return 2;Executed by:
executed 4 times by 1 test: return 2;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 590 | } | - | ||||||||||||||||||||||||||||||
| 591 | } | - | ||||||||||||||||||||||||||||||
| 592 | if( c<=0x80
| 8-503 | ||||||||||||||||||||||||||||||
| 593 | char zStop[3]; | - | ||||||||||||||||||||||||||||||
| 594 | int bMatch; | - | ||||||||||||||||||||||||||||||
| 595 | if( noCase
| 124-379 | ||||||||||||||||||||||||||||||
| 596 | zStop[0] = ((c)&~(sqlite3CtypeMap[(unsigned char)(c)]&0x20)); | - | ||||||||||||||||||||||||||||||
| 597 | zStop[1] = (sqlite3UpperToLower[(unsigned char)(c)]); | - | ||||||||||||||||||||||||||||||
| 598 | zStop[2] = 0; | - | ||||||||||||||||||||||||||||||
| 599 | } executed 124 times by 1 test: else{end of blockExecuted by:
| 124 | ||||||||||||||||||||||||||||||
| 600 | zStop[0] = c; | - | ||||||||||||||||||||||||||||||
| 601 | zStop[1] = 0; | - | ||||||||||||||||||||||||||||||
| 602 | } executed 379 times by 1 test: end of blockExecuted by:
| 379 | ||||||||||||||||||||||||||||||
| 603 | while(1){ | - | ||||||||||||||||||||||||||||||
| 604 | zString += | - | ||||||||||||||||||||||||||||||
| 605 | __builtin_strcspn ( | - | ||||||||||||||||||||||||||||||
| 606 | (const char*)zString | - | ||||||||||||||||||||||||||||||
| 607 | , | - | ||||||||||||||||||||||||||||||
| 608 | zStop | - | ||||||||||||||||||||||||||||||
| 609 | ) | - | ||||||||||||||||||||||||||||||
| 610 | ; | - | ||||||||||||||||||||||||||||||
| 611 | if( zString[0]==0
executed 406 times by 1 test: break;Executed by:
| 209-406 | ||||||||||||||||||||||||||||||
| 612 | zString++; | - | ||||||||||||||||||||||||||||||
| 613 | bMatch = patternCompare(zPattern,zString,pInfo,matchOther); | - | ||||||||||||||||||||||||||||||
| 614 | if( bMatch!=1
executed 97 times by 1 test: bMatch;return bMatch;Executed by:
executed 97 times by 1 test: return bMatch;Executed by:
| 97-112 | ||||||||||||||||||||||||||||||
| 615 | } executed 112 times by 1 test: end of blockExecuted by:
| 112 | ||||||||||||||||||||||||||||||
| 616 | } executed 406 times by 1 test: else{end of blockExecuted by:
| 406 | ||||||||||||||||||||||||||||||
| 617 | int bMatch; | - | ||||||||||||||||||||||||||||||
| 618 | while( (
| 0-24 | ||||||||||||||||||||||||||||||
| 619 | if( c2!=c
executed 13 times by 1 test: continue;Executed by:
| 11-13 | ||||||||||||||||||||||||||||||
| 620 | bMatch = patternCompare(zPattern,zString,pInfo,matchOther); | - | ||||||||||||||||||||||||||||||
| 621 | if( bMatch!=1
executed 8 times by 1 test: bMatch;return bMatch;Executed by:
executed 8 times by 1 test: return bMatch;Executed by:
| 3-8 | ||||||||||||||||||||||||||||||
| 622 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||||||||||||||
| 623 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 624 | return executed 406 times by 1 test: 2;return 2;Executed by:
executed 406 times by 1 test: return 2;Executed by:
| 406 | ||||||||||||||||||||||||||||||
| 625 | } | - | ||||||||||||||||||||||||||||||
| 626 | if( c==matchOther
| 382-59584 | ||||||||||||||||||||||||||||||
| 627 | if( pInfo->matchSet==0
| 110-272 | ||||||||||||||||||||||||||||||
| 628 | c = sqlite3Utf8Read(&zPattern); | - | ||||||||||||||||||||||||||||||
| 629 | if( c==0
executed 3 times by 1 test: 1;return 1;Executed by:
executed 3 times by 1 test: return 1;Executed by:
| 3-269 | ||||||||||||||||||||||||||||||
| 630 | zEscaped = zPattern; | - | ||||||||||||||||||||||||||||||
| 631 | } executed 269 times by 1 test: else{end of blockExecuted by:
| 269 | ||||||||||||||||||||||||||||||
| 632 | u32 prior_c = 0; | - | ||||||||||||||||||||||||||||||
| 633 | int seen = 0; | - | ||||||||||||||||||||||||||||||
| 634 | int invert = 0; | - | ||||||||||||||||||||||||||||||
| 635 | c = sqlite3Utf8Read(&zString); | - | ||||||||||||||||||||||||||||||
| 636 | if( c==0
executed 1 time by 1 test: 1;return 1;Executed by:
executed 1 time by 1 test: return 1;Executed by:
| 1-109 | ||||||||||||||||||||||||||||||
| 637 | c2 = sqlite3Utf8Read(&zPattern); | - | ||||||||||||||||||||||||||||||
| 638 | if( c2=='^'
| 24-85 | ||||||||||||||||||||||||||||||
| 639 | invert = 1; | - | ||||||||||||||||||||||||||||||
| 640 | c2 = sqlite3Utf8Read(&zPattern); | - | ||||||||||||||||||||||||||||||
| 641 | } executed 24 times by 1 test: end of blockExecuted by:
| 24 | ||||||||||||||||||||||||||||||
| 642 | if( c2==']'
| 7-102 | ||||||||||||||||||||||||||||||
| 643 | if( c==']'
executed 2 times by 1 test: seen = 1;Executed by:
| 2-5 | ||||||||||||||||||||||||||||||
| 644 | c2 = sqlite3Utf8Read(&zPattern); | - | ||||||||||||||||||||||||||||||
| 645 | } executed 7 times by 1 test: end of blockExecuted by:
| 7 | ||||||||||||||||||||||||||||||
| 646 | while( c2
| 0-348 | ||||||||||||||||||||||||||||||
| 647 | if( c2=='-'
| 0-203 | ||||||||||||||||||||||||||||||
| 648 | c2 = sqlite3Utf8Read(&zPattern); | - | ||||||||||||||||||||||||||||||
| 649 | if( c>=prior_c
executed 26 times by 1 test: seen = 1;Executed by:
| 5-31 | ||||||||||||||||||||||||||||||
| 650 | prior_c = 0; | - | ||||||||||||||||||||||||||||||
| 651 | } executed 36 times by 1 test: else{end of blockExecuted by:
| 36 | ||||||||||||||||||||||||||||||
| 652 | if( c==c2
| 37-166 | ||||||||||||||||||||||||||||||
| 653 | seen = 1; | - | ||||||||||||||||||||||||||||||
| 654 | } executed 37 times by 1 test: end of blockExecuted by:
| 37 | ||||||||||||||||||||||||||||||
| 655 | prior_c = c2; | - | ||||||||||||||||||||||||||||||
| 656 | } executed 203 times by 1 test: end of blockExecuted by:
| 203 | ||||||||||||||||||||||||||||||
| 657 | c2 = sqlite3Utf8Read(&zPattern); | - | ||||||||||||||||||||||||||||||
| 658 | } executed 239 times by 1 test: end of blockExecuted by:
| 239 | ||||||||||||||||||||||||||||||
| 659 | if( c2==0
| 0-109 | ||||||||||||||||||||||||||||||
| 660 | return executed 47 times by 1 test: 1;return 1;Executed by:
executed 47 times by 1 test: return 1;Executed by:
| 47 | ||||||||||||||||||||||||||||||
| 661 | } | - | ||||||||||||||||||||||||||||||
| 662 | continue; executed 62 times by 1 test: continue;Executed by:
| 62 | ||||||||||||||||||||||||||||||
| 663 | } | - | ||||||||||||||||||||||||||||||
| 664 | } | - | ||||||||||||||||||||||||||||||
| 665 | c2 = (zString[0]<0x80
| 54-59799 | ||||||||||||||||||||||||||||||
| 666 | if( c==c2
executed 25102 times by 1 test: continue;Executed by:
| 25102-34751 | ||||||||||||||||||||||||||||||
| 667 | if( noCase
| 1-26651 | ||||||||||||||||||||||||||||||
| 668 | continue; executed 5507 times by 1 test: continue;Executed by:
| 5507 | ||||||||||||||||||||||||||||||
| 669 | } | - | ||||||||||||||||||||||||||||||
| 670 | if( c==matchOne
executed 2057 times by 1 test: continue;Executed by:
| 13-27157 | ||||||||||||||||||||||||||||||
| 671 | return executed 27187 times by 1 test: 1;return 1;Executed by:
executed 27187 times by 1 test: return 1;Executed by:
| 27187 | ||||||||||||||||||||||||||||||
| 672 | } | - | ||||||||||||||||||||||||||||||
| 673 | return executed 1944 times by 1 test: *return *zString==0 ? 0 : 1;Executed by:
executed 1944 times by 1 test: return *zString==0 ? 0 : 1;Executed by:
| 148-1944 | ||||||||||||||||||||||||||||||
| 674 | } | - | ||||||||||||||||||||||||||||||
| 675 | - | |||||||||||||||||||||||||||||||
| 676 | - | |||||||||||||||||||||||||||||||
| 677 | - | |||||||||||||||||||||||||||||||
| 678 | - | |||||||||||||||||||||||||||||||
| 679 | - | |||||||||||||||||||||||||||||||
| 680 | int sqlite3_strglob(const char *zGlobPattern, const char *zString){ | - | ||||||||||||||||||||||||||||||
| 681 | return executed 133 times by 1 test: patternCompare((u8*)zGlobPattern, (u8*)zString, &globInfo, '[');return patternCompare((u8*)zGlobPattern, (u8*)zString, &globInfo, '[');Executed by:
executed 133 times by 1 test: return patternCompare((u8*)zGlobPattern, (u8*)zString, &globInfo, '[');Executed by:
| 133 | ||||||||||||||||||||||||||||||
| 682 | } | - | ||||||||||||||||||||||||||||||
| 683 | - | |||||||||||||||||||||||||||||||
| 684 | - | |||||||||||||||||||||||||||||||
| 685 | - | |||||||||||||||||||||||||||||||
| 686 | - | |||||||||||||||||||||||||||||||
| 687 | - | |||||||||||||||||||||||||||||||
| 688 | int sqlite3_strlike(const char *zPattern, const char *zStr, unsigned int esc){ | - | ||||||||||||||||||||||||||||||
| 689 | return executed 472 times by 1 test: patternCompare((u8*)zPattern, (u8*)zStr, &likeInfoNorm, esc);return patternCompare((u8*)zPattern, (u8*)zStr, &likeInfoNorm, esc);Executed by:
executed 472 times by 1 test: return patternCompare((u8*)zPattern, (u8*)zStr, &likeInfoNorm, esc);Executed by:
| 472 | ||||||||||||||||||||||||||||||
| 690 | } | - | ||||||||||||||||||||||||||||||
| 691 | - | |||||||||||||||||||||||||||||||
| 692 | - | |||||||||||||||||||||||||||||||
| 693 | - | |||||||||||||||||||||||||||||||
| 694 | - | |||||||||||||||||||||||||||||||
| 695 | - | |||||||||||||||||||||||||||||||
| 696 | - | |||||||||||||||||||||||||||||||
| 697 | - | |||||||||||||||||||||||||||||||
| 698 | int sqlite3_like_count = 0; | - | ||||||||||||||||||||||||||||||
| 699 | static void likeFunc( | - | ||||||||||||||||||||||||||||||
| 700 | sqlite3_context *context, | - | ||||||||||||||||||||||||||||||
| 701 | int argc, | - | ||||||||||||||||||||||||||||||
| 702 | sqlite3_value **argv | - | ||||||||||||||||||||||||||||||
| 703 | ){ | - | ||||||||||||||||||||||||||||||
| 704 | const unsigned char *zA, *zB; | - | ||||||||||||||||||||||||||||||
| 705 | u32 escape; | - | ||||||||||||||||||||||||||||||
| 706 | int nPat; | - | ||||||||||||||||||||||||||||||
| 707 | sqlite3 *db = sqlite3_context_db_handle(context); | - | ||||||||||||||||||||||||||||||
| 708 | struct compareInfo *pInfo = sqlite3_user_data(context); | - | ||||||||||||||||||||||||||||||
| 709 | zB = sqlite3_value_text(argv[0]); | - | ||||||||||||||||||||||||||||||
| 710 | zA = sqlite3_value_text(argv[1]); | - | ||||||||||||||||||||||||||||||
| 711 | - | |||||||||||||||||||||||||||||||
| 712 | - | |||||||||||||||||||||||||||||||
| 713 | - | |||||||||||||||||||||||||||||||
| 714 | - | |||||||||||||||||||||||||||||||
| 715 | nPat = sqlite3_value_bytes(argv[0]); | - | ||||||||||||||||||||||||||||||
| 716 | ; | - | ||||||||||||||||||||||||||||||
| 717 | ; | - | ||||||||||||||||||||||||||||||
| 718 | if( nPat > db->aLimit[8]
| 0-32960 | ||||||||||||||||||||||||||||||
| 719 | sqlite3_result_error(context, "LIKE or GLOB pattern too complex", -1); | - | ||||||||||||||||||||||||||||||
| 720 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 721 | } | - | ||||||||||||||||||||||||||||||
| 722 | - | |||||||||||||||||||||||||||||||
| 723 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 724 | ; | - | ||||||||||||||||||||||||||||||
| 725 | - | |||||||||||||||||||||||||||||||
| 726 | if( argc==3
| 787-32173 | ||||||||||||||||||||||||||||||
| 727 | - | |||||||||||||||||||||||||||||||
| 728 | - | |||||||||||||||||||||||||||||||
| 729 | - | |||||||||||||||||||||||||||||||
| 730 | const unsigned char *zEsc = sqlite3_value_text(argv[2]); | - | ||||||||||||||||||||||||||||||
| 731 | if( zEsc==0
never executed: return; | 0-787 | ||||||||||||||||||||||||||||||
| 732 | if( sqlite3Utf8CharLen((char*)zEsc, -1)!=1
| 4-783 | ||||||||||||||||||||||||||||||
| 733 | sqlite3_result_error(context, | - | ||||||||||||||||||||||||||||||
| 734 | "ESCAPE expression must be a single character", -1); | - | ||||||||||||||||||||||||||||||
| 735 | return; executed 4 times by 1 test: return;Executed by:
| 4 | ||||||||||||||||||||||||||||||
| 736 | } | - | ||||||||||||||||||||||||||||||
| 737 | escape = sqlite3Utf8Read(&zEsc); | - | ||||||||||||||||||||||||||||||
| 738 | } executed 783 times by 1 test: else{end of blockExecuted by:
| 783 | ||||||||||||||||||||||||||||||
| 739 | escape = pInfo->matchSet; | - | ||||||||||||||||||||||||||||||
| 740 | } executed 32173 times by 1 test: end of blockExecuted by:
| 32173 | ||||||||||||||||||||||||||||||
| 741 | if( zA
| 87-32744 | ||||||||||||||||||||||||||||||
| 742 | - | |||||||||||||||||||||||||||||||
| 743 | sqlite3_like_count++; | - | ||||||||||||||||||||||||||||||
| 744 | - | |||||||||||||||||||||||||||||||
| 745 | sqlite3_result_int(context, | - | ||||||||||||||||||||||||||||||
| 746 | patternCompare(zB, zA, pInfo, escape)==0); | - | ||||||||||||||||||||||||||||||
| 747 | } executed 32657 times by 1 test: end of blockExecuted by:
| 32657 | ||||||||||||||||||||||||||||||
| 748 | } executed 32956 times by 1 test: end of blockExecuted by:
| 32956 | ||||||||||||||||||||||||||||||
| 749 | - | |||||||||||||||||||||||||||||||
| 750 | - | |||||||||||||||||||||||||||||||
| 751 | - | |||||||||||||||||||||||||||||||
| 752 | - | |||||||||||||||||||||||||||||||
| 753 | - | |||||||||||||||||||||||||||||||
| 754 | - | |||||||||||||||||||||||||||||||
| 755 | static void nullifFunc( | - | ||||||||||||||||||||||||||||||
| 756 | sqlite3_context *context, | - | ||||||||||||||||||||||||||||||
| 757 | int NotUsed, | - | ||||||||||||||||||||||||||||||
| 758 | sqlite3_value **argv | - | ||||||||||||||||||||||||||||||
| 759 | ){ | - | ||||||||||||||||||||||||||||||
| 760 | CollSeq *pColl = sqlite3GetFuncCollSeq(context); | - | ||||||||||||||||||||||||||||||
| 761 | (void)(NotUsed); | - | ||||||||||||||||||||||||||||||
| 762 | if( sqlite3MemCompare(argv[0], argv[1], pColl)!=0
| 609-131129 | ||||||||||||||||||||||||||||||
| 763 | sqlite3_result_value(context, argv[0]); | - | ||||||||||||||||||||||||||||||
| 764 | } executed 131129 times by 1 test: end of blockExecuted by:
| 131129 | ||||||||||||||||||||||||||||||
| 765 | } executed 131738 times by 1 test: end of blockExecuted by:
| 131738 | ||||||||||||||||||||||||||||||
| 766 | - | |||||||||||||||||||||||||||||||
| 767 | - | |||||||||||||||||||||||||||||||
| 768 | - | |||||||||||||||||||||||||||||||
| 769 | - | |||||||||||||||||||||||||||||||
| 770 | - | |||||||||||||||||||||||||||||||
| 771 | static void versionFunc( | - | ||||||||||||||||||||||||||||||
| 772 | sqlite3_context *context, | - | ||||||||||||||||||||||||||||||
| 773 | int NotUsed, | - | ||||||||||||||||||||||||||||||
| 774 | sqlite3_value **NotUsed2 | - | ||||||||||||||||||||||||||||||
| 775 | ){ | - | ||||||||||||||||||||||||||||||
| 776 | (void)(NotUsed),(void)(NotUsed2); | - | ||||||||||||||||||||||||||||||
| 777 | - | |||||||||||||||||||||||||||||||
| 778 | - | |||||||||||||||||||||||||||||||
| 779 | sqlite3_result_text(context, sqlite3_libversion(), -1, ((sqlite3_destructor_type)0)); | - | ||||||||||||||||||||||||||||||
| 780 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||
| 781 | - | |||||||||||||||||||||||||||||||
| 782 | - | |||||||||||||||||||||||||||||||
| 783 | - | |||||||||||||||||||||||||||||||
| 784 | - | |||||||||||||||||||||||||||||||
| 785 | - | |||||||||||||||||||||||||||||||
| 786 | - | |||||||||||||||||||||||||||||||
| 787 | static void sourceidFunc( | - | ||||||||||||||||||||||||||||||
| 788 | sqlite3_context *context, | - | ||||||||||||||||||||||||||||||
| 789 | int NotUsed, | - | ||||||||||||||||||||||||||||||
| 790 | sqlite3_value **NotUsed2 | - | ||||||||||||||||||||||||||||||
| 791 | ){ | - | ||||||||||||||||||||||||||||||
| 792 | (void)(NotUsed),(void)(NotUsed2); | - | ||||||||||||||||||||||||||||||
| 793 | - | |||||||||||||||||||||||||||||||
| 794 | - | |||||||||||||||||||||||||||||||
| 795 | sqlite3_result_text(context, sqlite3_sourceid(), -1, ((sqlite3_destructor_type)0)); | - | ||||||||||||||||||||||||||||||
| 796 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||||||||
| 797 | - | |||||||||||||||||||||||||||||||
| 798 | - | |||||||||||||||||||||||||||||||
| 799 | - | |||||||||||||||||||||||||||||||
| 800 | - | |||||||||||||||||||||||||||||||
| 801 | - | |||||||||||||||||||||||||||||||
| 802 | - | |||||||||||||||||||||||||||||||
| 803 | static void errlogFunc( | - | ||||||||||||||||||||||||||||||
| 804 | sqlite3_context *context, | - | ||||||||||||||||||||||||||||||
| 805 | int argc, | - | ||||||||||||||||||||||||||||||
| 806 | sqlite3_value **argv | - | ||||||||||||||||||||||||||||||
| 807 | ){ | - | ||||||||||||||||||||||||||||||
| 808 | (void)(argc); | - | ||||||||||||||||||||||||||||||
| 809 | (void)(context); | - | ||||||||||||||||||||||||||||||
| 810 | sqlite3_log(sqlite3_value_int(argv[0]), "%s", sqlite3_value_text(argv[1])); | - | ||||||||||||||||||||||||||||||
| 811 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 812 | - | |||||||||||||||||||||||||||||||
| 813 | - | |||||||||||||||||||||||||||||||
| 814 | - | |||||||||||||||||||||||||||||||
| 815 | - | |||||||||||||||||||||||||||||||
| 816 | - | |||||||||||||||||||||||||||||||
| 817 | - | |||||||||||||||||||||||||||||||
| 818 | - | |||||||||||||||||||||||||||||||
| 819 | static void compileoptionusedFunc( | - | ||||||||||||||||||||||||||||||
| 820 | sqlite3_context *context, | - | ||||||||||||||||||||||||||||||
| 821 | int argc, | - | ||||||||||||||||||||||||||||||
| 822 | sqlite3_value **argv | - | ||||||||||||||||||||||||||||||
| 823 | ){ | - | ||||||||||||||||||||||||||||||
| 824 | const char *zOptName; | - | ||||||||||||||||||||||||||||||
| 825 | - | |||||||||||||||||||||||||||||||
| 826 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 827 | ; | - | ||||||||||||||||||||||||||||||
| 828 | (void)(argc); | - | ||||||||||||||||||||||||||||||
| 829 | - | |||||||||||||||||||||||||||||||
| 830 | - | |||||||||||||||||||||||||||||||
| 831 | - | |||||||||||||||||||||||||||||||
| 832 | - | |||||||||||||||||||||||||||||||
| 833 | if( (
| 1-25 | ||||||||||||||||||||||||||||||
| 834 | sqlite3_result_int(context, sqlite3_compileoption_used(zOptName)); | - | ||||||||||||||||||||||||||||||
| 835 | } executed 25 times by 1 test: end of blockExecuted by:
| 25 | ||||||||||||||||||||||||||||||
| 836 | } executed 26 times by 1 test: end of blockExecuted by:
| 26 | ||||||||||||||||||||||||||||||
| 837 | static void compileoptiongetFunc( | - | ||||||||||||||||||||||||||||||
| 838 | sqlite3_context *context, | - | ||||||||||||||||||||||||||||||
| 839 | int argc, | - | ||||||||||||||||||||||||||||||
| 840 | sqlite3_value **argv | - | ||||||||||||||||||||||||||||||
| 841 | ){ | - | ||||||||||||||||||||||||||||||
| 842 | int n; | - | ||||||||||||||||||||||||||||||
| 843 | - | |||||||||||||||||||||||||||||||
| 844 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 845 | ; | - | ||||||||||||||||||||||||||||||
| 846 | (void)(argc); | - | ||||||||||||||||||||||||||||||
| 847 | - | |||||||||||||||||||||||||||||||
| 848 | - | |||||||||||||||||||||||||||||||
| 849 | - | |||||||||||||||||||||||||||||||
| 850 | n = sqlite3_value_int(argv[0]); | - | ||||||||||||||||||||||||||||||
| 851 | sqlite3_result_text(context, sqlite3_compileoption_get(n), -1, ((sqlite3_destructor_type)0)); | - | ||||||||||||||||||||||||||||||
| 852 | } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||||||||||||||||||||||||||
| 853 | - | |||||||||||||||||||||||||||||||
| 854 | - | |||||||||||||||||||||||||||||||
| 855 | - | |||||||||||||||||||||||||||||||
| 856 | - | |||||||||||||||||||||||||||||||
| 857 | static const char hexdigits[] = { | - | ||||||||||||||||||||||||||||||
| 858 | '0', '1', '2', '3', '4', '5', '6', '7', | - | ||||||||||||||||||||||||||||||
| 859 | '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' | - | ||||||||||||||||||||||||||||||
| 860 | }; | - | ||||||||||||||||||||||||||||||
| 861 | static void quoteFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ | - | ||||||||||||||||||||||||||||||
| 862 | - | |||||||||||||||||||||||||||||||
| 863 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 864 | ; | - | ||||||||||||||||||||||||||||||
| 865 | (void)(argc); | - | ||||||||||||||||||||||||||||||
| 866 | switch( sqlite3_value_type(argv[0]) ){ | - | ||||||||||||||||||||||||||||||
| 867 | case executed 20016 times by 1 test: 2:case 2:Executed by:
executed 20016 times by 1 test: {case 2:Executed by:
| 20016 | ||||||||||||||||||||||||||||||
| 868 | double r1, r2; | - | ||||||||||||||||||||||||||||||
| 869 | char zBuf[50]; | - | ||||||||||||||||||||||||||||||
| 870 | r1 = sqlite3_value_double(argv[0]); | - | ||||||||||||||||||||||||||||||
| 871 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%!.15g", r1); | - | ||||||||||||||||||||||||||||||
| 872 | sqlite3AtoF(zBuf, &r2, 20, 1); | - | ||||||||||||||||||||||||||||||
| 873 | if( r1!=r2
| 1371-18645 | ||||||||||||||||||||||||||||||
| 874 | sqlite3_snprintf(sizeof(zBuf), zBuf, "%!.20e", r1); | - | ||||||||||||||||||||||||||||||
| 875 | } executed 18645 times by 1 test: end of blockExecuted by:
| 18645 | ||||||||||||||||||||||||||||||
| 876 | sqlite3_result_text(context, zBuf, -1, ((sqlite3_destructor_type)-1)); | - | ||||||||||||||||||||||||||||||
| 877 | break; executed 20016 times by 1 test: break;Executed by:
| 20016 | ||||||||||||||||||||||||||||||
| 878 | } | - | ||||||||||||||||||||||||||||||
| 879 | case executed 53 times by 1 test: 1:case 1:Executed by:
executed 53 times by 1 test: {case 1:Executed by:
| 53 | ||||||||||||||||||||||||||||||
| 880 | sqlite3_result_value(context, argv[0]); | - | ||||||||||||||||||||||||||||||
| 881 | break; executed 53 times by 1 test: break;Executed by:
| 53 | ||||||||||||||||||||||||||||||
| 882 | } | - | ||||||||||||||||||||||||||||||
| 883 | case executed 123 times by 1 test: 4:case 4:Executed by:
executed 123 times by 1 test: {case 4:Executed by:
| 123 | ||||||||||||||||||||||||||||||
| 884 | char *zText = 0; | - | ||||||||||||||||||||||||||||||
| 885 | char const *zBlob = sqlite3_value_blob(argv[0]); | - | ||||||||||||||||||||||||||||||
| 886 | int nBlob = sqlite3_value_bytes(argv[0]); | - | ||||||||||||||||||||||||||||||
| 887 | - | |||||||||||||||||||||||||||||||
| 888 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 889 | ; | - | ||||||||||||||||||||||||||||||
| 890 | zText = (char *)contextMalloc(context, (2*(i64)nBlob)+4); | - | ||||||||||||||||||||||||||||||
| 891 | if( zText
| 0-123 | ||||||||||||||||||||||||||||||
| 892 | int i; | - | ||||||||||||||||||||||||||||||
| 893 | for(i=0; i<nBlob
| 123-757 | ||||||||||||||||||||||||||||||
| 894 | zText[(i*2)+2] = hexdigits[(zBlob[i]>>4)&0x0F]; | - | ||||||||||||||||||||||||||||||
| 895 | zText[(i*2)+3] = hexdigits[(zBlob[i])&0x0F]; | - | ||||||||||||||||||||||||||||||
| 896 | } executed 757 times by 1 test: end of blockExecuted by:
| 757 | ||||||||||||||||||||||||||||||
| 897 | zText[(nBlob*2)+2] = '\''; | - | ||||||||||||||||||||||||||||||
| 898 | zText[(nBlob*2)+3] = '\0'; | - | ||||||||||||||||||||||||||||||
| 899 | zText[0] = 'X'; | - | ||||||||||||||||||||||||||||||
| 900 | zText[1] = '\''; | - | ||||||||||||||||||||||||||||||
| 901 | sqlite3_result_text(context, zText, -1, ((sqlite3_destructor_type)-1)); | - | ||||||||||||||||||||||||||||||
| 902 | sqlite3_free(zText); | - | ||||||||||||||||||||||||||||||
| 903 | } executed 123 times by 1 test: end of blockExecuted by:
| 123 | ||||||||||||||||||||||||||||||
| 904 | break; executed 123 times by 1 test: break;Executed by:
| 123 | ||||||||||||||||||||||||||||||
| 905 | } | - | ||||||||||||||||||||||||||||||
| 906 | case executed 36958 times by 2 tests: 3:case 3:Executed by:
executed 36958 times by 2 tests: {case 3:Executed by:
| 36958 | ||||||||||||||||||||||||||||||
| 907 | int i,j; | - | ||||||||||||||||||||||||||||||
| 908 | u64 n; | - | ||||||||||||||||||||||||||||||
| 909 | const unsigned char *zArg = sqlite3_value_text(argv[0]); | - | ||||||||||||||||||||||||||||||
| 910 | char *z; | - | ||||||||||||||||||||||||||||||
| 911 | - | |||||||||||||||||||||||||||||||
| 912 | if( zArg==0
never executed: return; | 0-36958 | ||||||||||||||||||||||||||||||
| 913 | for(i=0, n=0; zArg[i]
executed 1 time by 1 test: }n++;Executed by:
executed 115356 times by 2 tests: end of blockExecuted by:
| 1-115356 | ||||||||||||||||||||||||||||||
| 914 | z = contextMalloc(context, ((i64)i)+((i64)n)+3); | - | ||||||||||||||||||||||||||||||
| 915 | if( z
| 0-36958 | ||||||||||||||||||||||||||||||
| 916 | z[0] = '\''; | - | ||||||||||||||||||||||||||||||
| 917 | for(i=0, j=1; zArg[i]
| 36958-115356 | ||||||||||||||||||||||||||||||
| 918 | z[j++] = zArg[i]; | - | ||||||||||||||||||||||||||||||
| 919 | if( zArg[i]=='\''
| 1-115355 | ||||||||||||||||||||||||||||||
| 920 | z[j++] = '\''; | - | ||||||||||||||||||||||||||||||
| 921 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||||||||
| 922 | } executed 115356 times by 2 tests: end of blockExecuted by:
| 115356 | ||||||||||||||||||||||||||||||
| 923 | z[j++] = '\''; | - | ||||||||||||||||||||||||||||||
| 924 | z[j] = 0; | - | ||||||||||||||||||||||||||||||
| 925 | sqlite3_result_text(context, z, j, sqlite3_free); | - | ||||||||||||||||||||||||||||||
| 926 | } executed 36958 times by 2 tests: end of blockExecuted by:
| 36958 | ||||||||||||||||||||||||||||||
| 927 | break; executed 36958 times by 2 tests: break;Executed by:
| 36958 | ||||||||||||||||||||||||||||||
| 928 | } | - | ||||||||||||||||||||||||||||||
| 929 | default executed 25 times by 1 test: :default:Executed by:
executed 25 times by 1 test: {default:Executed by:
| 25 | ||||||||||||||||||||||||||||||
| 930 | - | |||||||||||||||||||||||||||||||
| 931 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 932 | ; | - | ||||||||||||||||||||||||||||||
| 933 | sqlite3_result_text(context, "NULL", 4, ((sqlite3_destructor_type)0)); | - | ||||||||||||||||||||||||||||||
| 934 | break; executed 25 times by 1 test: break;Executed by:
| 25 | ||||||||||||||||||||||||||||||
| 935 | } | - | ||||||||||||||||||||||||||||||
| 936 | } | - | ||||||||||||||||||||||||||||||
| 937 | } | - | ||||||||||||||||||||||||||||||
| 938 | - | |||||||||||||||||||||||||||||||
| 939 | - | |||||||||||||||||||||||||||||||
| 940 | - | |||||||||||||||||||||||||||||||
| 941 | - | |||||||||||||||||||||||||||||||
| 942 | - | |||||||||||||||||||||||||||||||
| 943 | static void unicodeFunc( | - | ||||||||||||||||||||||||||||||
| 944 | sqlite3_context *context, | - | ||||||||||||||||||||||||||||||
| 945 | int argc, | - | ||||||||||||||||||||||||||||||
| 946 | sqlite3_value **argv | - | ||||||||||||||||||||||||||||||
| 947 | ){ | - | ||||||||||||||||||||||||||||||
| 948 | const unsigned char *z = sqlite3_value_text(argv[0]); | - | ||||||||||||||||||||||||||||||
| 949 | (void)argc; | - | ||||||||||||||||||||||||||||||
| 950 | if( z
executed 12283 times by 1 test: sqlite3_result_int(context, sqlite3Utf8Read(&z));Executed by:
| 0-12283 | ||||||||||||||||||||||||||||||
| 951 | } executed 12283 times by 1 test: end of blockExecuted by:
| 12283 | ||||||||||||||||||||||||||||||
| 952 | - | |||||||||||||||||||||||||||||||
| 953 | - | |||||||||||||||||||||||||||||||
| 954 | - | |||||||||||||||||||||||||||||||
| 955 | - | |||||||||||||||||||||||||||||||
| 956 | - | |||||||||||||||||||||||||||||||
| 957 | - | |||||||||||||||||||||||||||||||
| 958 | static void charFunc( | - | ||||||||||||||||||||||||||||||
| 959 | sqlite3_context *context, | - | ||||||||||||||||||||||||||||||
| 960 | int argc, | - | ||||||||||||||||||||||||||||||
| 961 | sqlite3_value **argv | - | ||||||||||||||||||||||||||||||
| 962 | ){ | - | ||||||||||||||||||||||||||||||
| 963 | unsigned char *z, *zOut; | - | ||||||||||||||||||||||||||||||
| 964 | int i; | - | ||||||||||||||||||||||||||||||
| 965 | zOut = z = sqlite3_malloc64( argc*4+1 ); | - | ||||||||||||||||||||||||||||||
| 966 | if( z==0
| 0-12345 | ||||||||||||||||||||||||||||||
| 967 | sqlite3_result_error_nomem(context); | - | ||||||||||||||||||||||||||||||
| 968 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 969 | } | - | ||||||||||||||||||||||||||||||
| 970 | for(i=0; i<argc
| 12344-12345 | ||||||||||||||||||||||||||||||
| 971 | sqlite3_int64 x; | - | ||||||||||||||||||||||||||||||
| 972 | unsigned c; | - | ||||||||||||||||||||||||||||||
| 973 | x = sqlite3_value_int64(argv[i]); | - | ||||||||||||||||||||||||||||||
| 974 | if( x<0
never executed: x = 0xfffd; | 0-12344 | ||||||||||||||||||||||||||||||
| 975 | c = (unsigned)(x & 0x1fffff); | - | ||||||||||||||||||||||||||||||
| 976 | if( c<0x00080
| 37-12307 | ||||||||||||||||||||||||||||||
| 977 | *zOut++ = (u8)(c&0xFF); | - | ||||||||||||||||||||||||||||||
| 978 | } executed 37 times by 1 test: else if( c<0x00800end of blockExecuted by:
| 37-12152 | ||||||||||||||||||||||||||||||
| 979 | *zOut++ = 0xC0 + (u8)((c>>6)&0x1F); | - | ||||||||||||||||||||||||||||||
| 980 | *zOut++ = 0x80 + (u8)(c & 0x3F); | - | ||||||||||||||||||||||||||||||
| 981 | } executed 155 times by 1 test: else if( c<0x10000end of blockExecuted by:
| 155-7567 | ||||||||||||||||||||||||||||||
| 982 | *zOut++ = 0xE0 + (u8)((c>>12)&0x0F); | - | ||||||||||||||||||||||||||||||
| 983 | *zOut++ = 0x80 + (u8)((c>>6) & 0x3F); | - | ||||||||||||||||||||||||||||||
| 984 | *zOut++ = 0x80 + (u8)(c & 0x3F); | - | ||||||||||||||||||||||||||||||
| 985 | } executed 4585 times by 1 test: else{end of blockExecuted by:
| 4585 | ||||||||||||||||||||||||||||||
| 986 | *zOut++ = 0xF0 + (u8)((c>>18) & 0x07); | - | ||||||||||||||||||||||||||||||
| 987 | *zOut++ = 0x80 + (u8)((c>>12) & 0x3F); | - | ||||||||||||||||||||||||||||||
| 988 | *zOut++ = 0x80 + (u8)((c>>6) & 0x3F); | - | ||||||||||||||||||||||||||||||
| 989 | *zOut++ = 0x80 + (u8)(c & 0x3F); | - | ||||||||||||||||||||||||||||||
| 990 | } executed 7567 times by 1 test: end of blockExecuted by:
| 7567 | ||||||||||||||||||||||||||||||
| 991 | } | - | ||||||||||||||||||||||||||||||
| 992 | sqlite3_result_text64(context, (char*)z, zOut-z, sqlite3_free, 1); | - | ||||||||||||||||||||||||||||||
| 993 | } executed 12345 times by 1 test: end of blockExecuted by:
| 12345 | ||||||||||||||||||||||||||||||
| 994 | - | |||||||||||||||||||||||||||||||
| 995 | - | |||||||||||||||||||||||||||||||
| 996 | - | |||||||||||||||||||||||||||||||
| 997 | - | |||||||||||||||||||||||||||||||
| 998 | - | |||||||||||||||||||||||||||||||
| 999 | static void hexFunc( | - | ||||||||||||||||||||||||||||||
| 1000 | sqlite3_context *context, | - | ||||||||||||||||||||||||||||||
| 1001 | int argc, | - | ||||||||||||||||||||||||||||||
| 1002 | sqlite3_value **argv | - | ||||||||||||||||||||||||||||||
| 1003 | ){ | - | ||||||||||||||||||||||||||||||
| 1004 | int i, n; | - | ||||||||||||||||||||||||||||||
| 1005 | const unsigned char *pBlob; | - | ||||||||||||||||||||||||||||||
| 1006 | char *zHex, *z; | - | ||||||||||||||||||||||||||||||
| 1007 | - | |||||||||||||||||||||||||||||||
| 1008 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 1009 | ; | - | ||||||||||||||||||||||||||||||
| 1010 | (void)(argc); | - | ||||||||||||||||||||||||||||||
| 1011 | pBlob = sqlite3_value_blob(argv[0]); | - | ||||||||||||||||||||||||||||||
| 1012 | n = sqlite3_value_bytes(argv[0]); | - | ||||||||||||||||||||||||||||||
| 1013 | - | |||||||||||||||||||||||||||||||
| 1014 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 1015 | ; | - | ||||||||||||||||||||||||||||||
| 1016 | z = zHex = contextMalloc(context, ((i64)n)*2 + 1); | - | ||||||||||||||||||||||||||||||
| 1017 | if( zHex
| 0-959 | ||||||||||||||||||||||||||||||
| 1018 | for(i=0; i<n
| 959-99236 | ||||||||||||||||||||||||||||||
| 1019 | unsigned char c = *pBlob; | - | ||||||||||||||||||||||||||||||
| 1020 | *(z++) = hexdigits[(c>>4)&0xf]; | - | ||||||||||||||||||||||||||||||
| 1021 | *(z++) = hexdigits[c&0xf]; | - | ||||||||||||||||||||||||||||||
| 1022 | } executed 99236 times by 1 test: end of blockExecuted by:
| 99236 | ||||||||||||||||||||||||||||||
| 1023 | *z = 0; | - | ||||||||||||||||||||||||||||||
| 1024 | sqlite3_result_text(context, zHex, n*2, sqlite3_free); | - | ||||||||||||||||||||||||||||||
| 1025 | } executed 959 times by 1 test: end of blockExecuted by:
| 959 | ||||||||||||||||||||||||||||||
| 1026 | } executed 959 times by 1 test: end of blockExecuted by:
| 959 | ||||||||||||||||||||||||||||||
| 1027 | - | |||||||||||||||||||||||||||||||
| 1028 | - | |||||||||||||||||||||||||||||||
| 1029 | - | |||||||||||||||||||||||||||||||
| 1030 | - | |||||||||||||||||||||||||||||||
| 1031 | static void zeroblobFunc( | - | ||||||||||||||||||||||||||||||
| 1032 | sqlite3_context *context, | - | ||||||||||||||||||||||||||||||
| 1033 | int argc, | - | ||||||||||||||||||||||||||||||
| 1034 | sqlite3_value **argv | - | ||||||||||||||||||||||||||||||
| 1035 | ){ | - | ||||||||||||||||||||||||||||||
| 1036 | i64 n; | - | ||||||||||||||||||||||||||||||
| 1037 | int rc; | - | ||||||||||||||||||||||||||||||
| 1038 | - | |||||||||||||||||||||||||||||||
| 1039 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 1040 | ; | - | ||||||||||||||||||||||||||||||
| 1041 | (void)(argc); | - | ||||||||||||||||||||||||||||||
| 1042 | n = sqlite3_value_int64(argv[0]); | - | ||||||||||||||||||||||||||||||
| 1043 | if( n<0
executed 9 times by 1 test: n = 0;Executed by:
| 9-867 | ||||||||||||||||||||||||||||||
| 1044 | rc = sqlite3_result_zeroblob64(context, n); | - | ||||||||||||||||||||||||||||||
| 1045 | if( rc
| 5-871 | ||||||||||||||||||||||||||||||
| 1046 | sqlite3_result_error_code(context, rc); | - | ||||||||||||||||||||||||||||||
| 1047 | } executed 5 times by 1 test: end of blockExecuted by:
| 5 | ||||||||||||||||||||||||||||||
| 1048 | } executed 876 times by 1 test: end of blockExecuted by:
| 876 | ||||||||||||||||||||||||||||||
| 1049 | - | |||||||||||||||||||||||||||||||
| 1050 | - | |||||||||||||||||||||||||||||||
| 1051 | - | |||||||||||||||||||||||||||||||
| 1052 | - | |||||||||||||||||||||||||||||||
| 1053 | - | |||||||||||||||||||||||||||||||
| 1054 | - | |||||||||||||||||||||||||||||||
| 1055 | - | |||||||||||||||||||||||||||||||
| 1056 | static void replaceFunc( | - | ||||||||||||||||||||||||||||||
| 1057 | sqlite3_context *context, | - | ||||||||||||||||||||||||||||||
| 1058 | int argc, | - | ||||||||||||||||||||||||||||||
| 1059 | sqlite3_value **argv | - | ||||||||||||||||||||||||||||||
| 1060 | ){ | - | ||||||||||||||||||||||||||||||
| 1061 | const unsigned char *zStr; | - | ||||||||||||||||||||||||||||||
| 1062 | const unsigned char *zPattern; | - | ||||||||||||||||||||||||||||||
| 1063 | const unsigned char *zRep; | - | ||||||||||||||||||||||||||||||
| 1064 | unsigned char *zOut; | - | ||||||||||||||||||||||||||||||
| 1065 | int nStr; | - | ||||||||||||||||||||||||||||||
| 1066 | int nPattern; | - | ||||||||||||||||||||||||||||||
| 1067 | int nRep; | - | ||||||||||||||||||||||||||||||
| 1068 | i64 nOut; | - | ||||||||||||||||||||||||||||||
| 1069 | int loopLimit; | - | ||||||||||||||||||||||||||||||
| 1070 | int i, j; | - | ||||||||||||||||||||||||||||||
| 1071 | unsigned cntExpand; | - | ||||||||||||||||||||||||||||||
| 1072 | sqlite3 *db = sqlite3_context_db_handle(context); | - | ||||||||||||||||||||||||||||||
| 1073 | - | |||||||||||||||||||||||||||||||
| 1074 | - | |||||||||||||||||||||||||||||||
| 1075 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 1076 | ; | - | ||||||||||||||||||||||||||||||
| 1077 | (void)(argc); | - | ||||||||||||||||||||||||||||||
| 1078 | zStr = sqlite3_value_text(argv[0]); | - | ||||||||||||||||||||||||||||||
| 1079 | if( zStr==0
executed 1 time by 1 test: return;Executed by:
| 1-1085 | ||||||||||||||||||||||||||||||
| 1080 | nStr = sqlite3_value_bytes(argv[0]); | - | ||||||||||||||||||||||||||||||
| 1081 | - | |||||||||||||||||||||||||||||||
| 1082 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 1083 | ; | - | ||||||||||||||||||||||||||||||
| 1084 | zPattern = sqlite3_value_text(argv[1]); | - | ||||||||||||||||||||||||||||||
| 1085 | if( zPattern==0
| 1-1084 | ||||||||||||||||||||||||||||||
| 1086 | - | |||||||||||||||||||||||||||||||
| 1087 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 1088 | - | |||||||||||||||||||||||||||||||
| 1089 | ; | - | ||||||||||||||||||||||||||||||
| 1090 | return; executed 1 time by 1 test: return;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 1091 | } | - | ||||||||||||||||||||||||||||||
| 1092 | if( zPattern[0]==0
| 1-1083 | ||||||||||||||||||||||||||||||
| 1093 | - | |||||||||||||||||||||||||||||||
| 1094 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 1095 | ; | - | ||||||||||||||||||||||||||||||
| 1096 | sqlite3_result_value(context, argv[0]); | - | ||||||||||||||||||||||||||||||
| 1097 | return; executed 1 time by 1 test: return;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 1098 | } | - | ||||||||||||||||||||||||||||||
| 1099 | nPattern = sqlite3_value_bytes(argv[1]); | - | ||||||||||||||||||||||||||||||
| 1100 | - | |||||||||||||||||||||||||||||||
| 1101 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 1102 | ; | - | ||||||||||||||||||||||||||||||
| 1103 | zRep = sqlite3_value_text(argv[2]); | - | ||||||||||||||||||||||||||||||
| 1104 | if( zRep==0
executed 1 time by 1 test: return;Executed by:
| 1-1082 | ||||||||||||||||||||||||||||||
| 1105 | nRep = sqlite3_value_bytes(argv[2]); | - | ||||||||||||||||||||||||||||||
| 1106 | - | |||||||||||||||||||||||||||||||
| 1107 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 1108 | ; | - | ||||||||||||||||||||||||||||||
| 1109 | nOut = nStr + 1; | - | ||||||||||||||||||||||||||||||
| 1110 | - | |||||||||||||||||||||||||||||||
| 1111 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 1112 | ; | - | ||||||||||||||||||||||||||||||
| 1113 | zOut = contextMalloc(context, (i64)nOut); | - | ||||||||||||||||||||||||||||||
| 1114 | if( zOut==0
| 0-1082 | ||||||||||||||||||||||||||||||
| 1115 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1116 | } | - | ||||||||||||||||||||||||||||||
| 1117 | loopLimit = nStr - nPattern; | - | ||||||||||||||||||||||||||||||
| 1118 | cntExpand = 0; | - | ||||||||||||||||||||||||||||||
| 1119 | for(i=j=0; i<=loopLimit
| 1082-613296 | ||||||||||||||||||||||||||||||
| 1120 | if( zStr[i]!=zPattern[0]
| 1-541371 | ||||||||||||||||||||||||||||||
| 1121 | zOut[j++] = zStr[i]; | - | ||||||||||||||||||||||||||||||
| 1122 | } executed 71926 times by 1 test: else{end of blockExecuted by:
| 71926 | ||||||||||||||||||||||||||||||
| 1123 | if( nRep>nPattern
| 37-541333 | ||||||||||||||||||||||||||||||
| 1124 | nOut += nRep - nPattern; | - | ||||||||||||||||||||||||||||||
| 1125 | ; | - | ||||||||||||||||||||||||||||||
| 1126 | ; | - | ||||||||||||||||||||||||||||||
| 1127 | if( nOut-1>db->aLimit[0]
| 0-541333 | ||||||||||||||||||||||||||||||
| 1128 | sqlite3_result_error_toobig(context); | - | ||||||||||||||||||||||||||||||
| 1129 | sqlite3_free(zOut); | - | ||||||||||||||||||||||||||||||
| 1130 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1131 | } | - | ||||||||||||||||||||||||||||||
| 1132 | cntExpand++; | - | ||||||||||||||||||||||||||||||
| 1133 | if( (
| 9413-531920 | ||||||||||||||||||||||||||||||
| 1134 | - | |||||||||||||||||||||||||||||||
| 1135 | - | |||||||||||||||||||||||||||||||
| 1136 | u8 *zOld; | - | ||||||||||||||||||||||||||||||
| 1137 | zOld = zOut; | - | ||||||||||||||||||||||||||||||
| 1138 | zOut = sqlite3_realloc64(zOut, (int)nOut + (nOut - nStr - 1)); | - | ||||||||||||||||||||||||||||||
| 1139 | if( zOut==0
| 0-9413 | ||||||||||||||||||||||||||||||
| 1140 | sqlite3_result_error_nomem(context); | - | ||||||||||||||||||||||||||||||
| 1141 | sqlite3_free(zOld); | - | ||||||||||||||||||||||||||||||
| 1142 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1143 | } | - | ||||||||||||||||||||||||||||||
| 1144 | } executed 9413 times by 1 test: end of blockExecuted by:
| 9413 | ||||||||||||||||||||||||||||||
| 1145 | } executed 541333 times by 1 test: end of blockExecuted by:
| 541333 | ||||||||||||||||||||||||||||||
| 1146 | memcpy(&zOut[j], zRep, nRep); | - | ||||||||||||||||||||||||||||||
| 1147 | j += nRep; | - | ||||||||||||||||||||||||||||||
| 1148 | i += nPattern-1; | - | ||||||||||||||||||||||||||||||
| 1149 | } executed 541370 times by 1 test: end of blockExecuted by:
| 541370 | ||||||||||||||||||||||||||||||
| 1150 | } | - | ||||||||||||||||||||||||||||||
| 1151 | - | |||||||||||||||||||||||||||||||
| 1152 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 1153 | ; | - | ||||||||||||||||||||||||||||||
| 1154 | memcpy(&zOut[j], &zStr[i], nStr-i); | - | ||||||||||||||||||||||||||||||
| 1155 | j += nStr - i; | - | ||||||||||||||||||||||||||||||
| 1156 | - | |||||||||||||||||||||||||||||||
| 1157 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 1158 | ; | - | ||||||||||||||||||||||||||||||
| 1159 | zOut[j] = 0; | - | ||||||||||||||||||||||||||||||
| 1160 | sqlite3_result_text(context, (char*)zOut, j, sqlite3_free); | - | ||||||||||||||||||||||||||||||
| 1161 | } executed 1082 times by 1 test: end of blockExecuted by:
| 1082 | ||||||||||||||||||||||||||||||
| 1162 | - | |||||||||||||||||||||||||||||||
| 1163 | - | |||||||||||||||||||||||||||||||
| 1164 | - | |||||||||||||||||||||||||||||||
| 1165 | - | |||||||||||||||||||||||||||||||
| 1166 | - | |||||||||||||||||||||||||||||||
| 1167 | static void trimFunc( | - | ||||||||||||||||||||||||||||||
| 1168 | sqlite3_context *context, | - | ||||||||||||||||||||||||||||||
| 1169 | int argc, | - | ||||||||||||||||||||||||||||||
| 1170 | sqlite3_value **argv | - | ||||||||||||||||||||||||||||||
| 1171 | ){ | - | ||||||||||||||||||||||||||||||
| 1172 | const unsigned char *zIn; | - | ||||||||||||||||||||||||||||||
| 1173 | const unsigned char *zCharSet; | - | ||||||||||||||||||||||||||||||
| 1174 | int nIn; | - | ||||||||||||||||||||||||||||||
| 1175 | int flags; | - | ||||||||||||||||||||||||||||||
| 1176 | int i; | - | ||||||||||||||||||||||||||||||
| 1177 | unsigned char *aLen = 0; | - | ||||||||||||||||||||||||||||||
| 1178 | unsigned char **azChar = 0; | - | ||||||||||||||||||||||||||||||
| 1179 | int nChar; | - | ||||||||||||||||||||||||||||||
| 1180 | - | |||||||||||||||||||||||||||||||
| 1181 | if( sqlite3_value_type(argv[0])==5
| 2-49 | ||||||||||||||||||||||||||||||
| 1182 | return; executed 2 times by 1 test: return;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 1183 | } | - | ||||||||||||||||||||||||||||||
| 1184 | zIn = sqlite3_value_text(argv[0]); | - | ||||||||||||||||||||||||||||||
| 1185 | if( zIn==0
never executed: return; | 0-49 | ||||||||||||||||||||||||||||||
| 1186 | nIn = sqlite3_value_bytes(argv[0]); | - | ||||||||||||||||||||||||||||||
| 1187 | - | |||||||||||||||||||||||||||||||
| 1188 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 1189 | ; | - | ||||||||||||||||||||||||||||||
| 1190 | if( argc==1
| 23-26 | ||||||||||||||||||||||||||||||
| 1191 | static const unsigned char lenOne[] = { 1 }; | - | ||||||||||||||||||||||||||||||
| 1192 | static unsigned char * const azOne[] = { (u8*)" " }; | - | ||||||||||||||||||||||||||||||
| 1193 | nChar = 1; | - | ||||||||||||||||||||||||||||||
| 1194 | aLen = (u8*)lenOne; | - | ||||||||||||||||||||||||||||||
| 1195 | azChar = (unsigned char **)azOne; | - | ||||||||||||||||||||||||||||||
| 1196 | zCharSet = 0; | - | ||||||||||||||||||||||||||||||
| 1197 | } executed 26 times by 1 test: else if( (end of blockExecuted by:
| 1-26 | ||||||||||||||||||||||||||||||
| 1198 | return; executed 1 time by 1 test: return;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 1199 | }else{ | - | ||||||||||||||||||||||||||||||
| 1200 | const unsigned char *z; | - | ||||||||||||||||||||||||||||||
| 1201 | for(z=zCharSet, nChar=0; *
| 22-43 | ||||||||||||||||||||||||||||||
| 1202 | { if( (*(
executed 15 times by 1 test: }end of blockExecuted by:
executed 13 times by 1 test: };end of blockExecuted by:
| 13-30 | ||||||||||||||||||||||||||||||
| 1203 | } executed 43 times by 1 test: end of blockExecuted by:
| 43 | ||||||||||||||||||||||||||||||
| 1204 | if( nChar>0
| 1-21 | ||||||||||||||||||||||||||||||
| 1205 | azChar = contextMalloc(context, ((i64)nChar)*(sizeof(char*)+1)); | - | ||||||||||||||||||||||||||||||
| 1206 | if( azChar==0
| 0-21 | ||||||||||||||||||||||||||||||
| 1207 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1208 | } | - | ||||||||||||||||||||||||||||||
| 1209 | aLen = (unsigned char*)&azChar[nChar]; | - | ||||||||||||||||||||||||||||||
| 1210 | for(z=zCharSet, nChar=0; *
| 21-43 | ||||||||||||||||||||||||||||||
| 1211 | azChar[nChar] = (unsigned char *)z; | - | ||||||||||||||||||||||||||||||
| 1212 | { if( (*(
executed 15 times by 1 test: }end of blockExecuted by:
executed 13 times by 1 test: };end of blockExecuted by:
| 13-30 | ||||||||||||||||||||||||||||||
| 1213 | aLen[nChar] = (u8)(z - azChar[nChar]); | - | ||||||||||||||||||||||||||||||
| 1214 | } executed 43 times by 1 test: end of blockExecuted by:
| 43 | ||||||||||||||||||||||||||||||
| 1215 | } executed 21 times by 1 test: end of blockExecuted by:
| 21 | ||||||||||||||||||||||||||||||
| 1216 | } executed 22 times by 1 test: end of blockExecuted by:
| 22 | ||||||||||||||||||||||||||||||
| 1217 | if( nChar>0
| 1-47 | ||||||||||||||||||||||||||||||
| 1218 | flags = ((int)(long int)(sqlite3_user_data(context))); | - | ||||||||||||||||||||||||||||||
| 1219 | if( flags & 1
| 21-26 | ||||||||||||||||||||||||||||||
| 1220 | while( nIn>0
| 0-51 | ||||||||||||||||||||||||||||||
| 1221 | int len = 0; | - | ||||||||||||||||||||||||||||||
| 1222 | for(i=0; i<nChar
| 21-81 | ||||||||||||||||||||||||||||||
| 1223 | len = aLen[i]; | - | ||||||||||||||||||||||||||||||
| 1224 | if( len<=nIn
executed 30 times by 1 test: break;Executed by:
| 0-81 | ||||||||||||||||||||||||||||||
| 1225 | } executed 51 times by 1 test: end of blockExecuted by:
| 51 | ||||||||||||||||||||||||||||||
| 1226 | if( i>=nChar
executed 21 times by 1 test: break;Executed by:
| 21-30 | ||||||||||||||||||||||||||||||
| 1227 | zIn += len; | - | ||||||||||||||||||||||||||||||
| 1228 | nIn -= len; | - | ||||||||||||||||||||||||||||||
| 1229 | } executed 30 times by 1 test: end of blockExecuted by:
| 30 | ||||||||||||||||||||||||||||||
| 1230 | } executed 21 times by 1 test: end of blockExecuted by:
| 21 | ||||||||||||||||||||||||||||||
| 1231 | if( flags & 2
| 5-42 | ||||||||||||||||||||||||||||||
| 1232 | while( nIn>0
| 0-471 | ||||||||||||||||||||||||||||||
| 1233 | int len = 0; | - | ||||||||||||||||||||||||||||||
| 1234 | for(i=0; i<nChar
| 42-513 | ||||||||||||||||||||||||||||||
| 1235 | len = aLen[i]; | - | ||||||||||||||||||||||||||||||
| 1236 | if( len<=nIn
executed 429 times by 1 test: break;Executed by:
| 2-511 | ||||||||||||||||||||||||||||||
| 1237 | } executed 84 times by 1 test: end of blockExecuted by:
| 84 | ||||||||||||||||||||||||||||||
| 1238 | if( i>=nChar
executed 42 times by 1 test: break;Executed by:
| 42-429 | ||||||||||||||||||||||||||||||
| 1239 | nIn -= len; | - | ||||||||||||||||||||||||||||||
| 1240 | } executed 429 times by 1 test: end of blockExecuted by:
| 429 | ||||||||||||||||||||||||||||||
| 1241 | } executed 42 times by 1 test: end of blockExecuted by:
| 42 | ||||||||||||||||||||||||||||||
| 1242 | if( zCharSet
| 21-26 | ||||||||||||||||||||||||||||||
| 1243 | sqlite3_free(azChar); | - | ||||||||||||||||||||||||||||||
| 1244 | } executed 21 times by 1 test: end of blockExecuted by:
| 21 | ||||||||||||||||||||||||||||||
| 1245 | } executed 47 times by 1 test: end of blockExecuted by:
| 47 | ||||||||||||||||||||||||||||||
| 1246 | sqlite3_result_text(context, (char*)zIn, nIn, ((sqlite3_destructor_type)-1)); | - | ||||||||||||||||||||||||||||||
| 1247 | } executed 48 times by 1 test: end of blockExecuted by:
| 48 | ||||||||||||||||||||||||||||||
| 1248 | static void loadExt(sqlite3_context *context, int argc, sqlite3_value **argv){ | - | ||||||||||||||||||||||||||||||
| 1249 | const char *zFile = (const char *)sqlite3_value_text(argv[0]); | - | ||||||||||||||||||||||||||||||
| 1250 | const char *zProc; | - | ||||||||||||||||||||||||||||||
| 1251 | sqlite3 *db = sqlite3_context_db_handle(context); | - | ||||||||||||||||||||||||||||||
| 1252 | char *zErrMsg = 0; | - | ||||||||||||||||||||||||||||||
| 1253 | - | |||||||||||||||||||||||||||||||
| 1254 | - | |||||||||||||||||||||||||||||||
| 1255 | - | |||||||||||||||||||||||||||||||
| 1256 | - | |||||||||||||||||||||||||||||||
| 1257 | if( (
| 0 | ||||||||||||||||||||||||||||||
| 1258 | sqlite3_result_error(context, "not authorized", -1); | - | ||||||||||||||||||||||||||||||
| 1259 | return; never executed: return; | 0 | ||||||||||||||||||||||||||||||
| 1260 | } | - | ||||||||||||||||||||||||||||||
| 1261 | - | |||||||||||||||||||||||||||||||
| 1262 | if( argc==2
| 0 | ||||||||||||||||||||||||||||||
| 1263 | zProc = (const char *)sqlite3_value_text(argv[1]); | - | ||||||||||||||||||||||||||||||
| 1264 | } never executed: else{end of block | 0 | ||||||||||||||||||||||||||||||
| 1265 | zProc = 0; | - | ||||||||||||||||||||||||||||||
| 1266 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1267 | if( zFile
| 0 | ||||||||||||||||||||||||||||||
| 1268 | sqlite3_result_error(context, zErrMsg, -1); | - | ||||||||||||||||||||||||||||||
| 1269 | sqlite3_free(zErrMsg); | - | ||||||||||||||||||||||||||||||
| 1270 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1271 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 1272 | - | |||||||||||||||||||||||||||||||
| 1273 | - | |||||||||||||||||||||||||||||||
| 1274 | - | |||||||||||||||||||||||||||||||
| 1275 | - | |||||||||||||||||||||||||||||||
| 1276 | - | |||||||||||||||||||||||||||||||
| 1277 | - | |||||||||||||||||||||||||||||||
| 1278 | - | |||||||||||||||||||||||||||||||
| 1279 | typedef struct SumCtx SumCtx; | - | ||||||||||||||||||||||||||||||
| 1280 | struct SumCtx { | - | ||||||||||||||||||||||||||||||
| 1281 | double rSum; | - | ||||||||||||||||||||||||||||||
| 1282 | i64 iSum; | - | ||||||||||||||||||||||||||||||
| 1283 | i64 cnt; | - | ||||||||||||||||||||||||||||||
| 1284 | u8 overflow; | - | ||||||||||||||||||||||||||||||
| 1285 | u8 approx; | - | ||||||||||||||||||||||||||||||
| 1286 | }; | - | ||||||||||||||||||||||||||||||
| 1287 | static void sumStep(sqlite3_context *context, int argc, sqlite3_value **argv){ | - | ||||||||||||||||||||||||||||||
| 1288 | SumCtx *p; | - | ||||||||||||||||||||||||||||||
| 1289 | int type; | - | ||||||||||||||||||||||||||||||
| 1290 | - | |||||||||||||||||||||||||||||||
| 1291 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 1292 | ; | - | ||||||||||||||||||||||||||||||
| 1293 | (void)(argc); | - | ||||||||||||||||||||||||||||||
| 1294 | p = sqlite3_aggregate_context(context, sizeof(*p)); | - | ||||||||||||||||||||||||||||||
| 1295 | type = sqlite3_value_numeric_type(argv[0]); | - | ||||||||||||||||||||||||||||||
| 1296 | if( p
| 0-250700 | ||||||||||||||||||||||||||||||
| 1297 | p->cnt++; | - | ||||||||||||||||||||||||||||||
| 1298 | if( type==1
| 55-250444 | ||||||||||||||||||||||||||||||
| 1299 | i64 v = sqlite3_value_int64(argv[0]); | - | ||||||||||||||||||||||||||||||
| 1300 | p->rSum += v; | - | ||||||||||||||||||||||||||||||
| 1301 | if( (
| 4-250436 | ||||||||||||||||||||||||||||||
| 1302 | p->approx = p->overflow = 1; | - | ||||||||||||||||||||||||||||||
| 1303 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||||||||
| 1304 | } executed 250444 times by 1 test: else{end of blockExecuted by:
| 250444 | ||||||||||||||||||||||||||||||
| 1305 | p->rSum += sqlite3_value_double(argv[0]); | - | ||||||||||||||||||||||||||||||
| 1306 | p->approx = 1; | - | ||||||||||||||||||||||||||||||
| 1307 | } executed 55 times by 1 test: end of blockExecuted by:
| 55 | ||||||||||||||||||||||||||||||
| 1308 | } | - | ||||||||||||||||||||||||||||||
| 1309 | } executed 250700 times by 1 test: end of blockExecuted by:
| 250700 | ||||||||||||||||||||||||||||||
| 1310 | - | |||||||||||||||||||||||||||||||
| 1311 | static void sumInverse(sqlite3_context *context, int argc, sqlite3_value**argv){ | - | ||||||||||||||||||||||||||||||
| 1312 | SumCtx *p; | - | ||||||||||||||||||||||||||||||
| 1313 | int type; | - | ||||||||||||||||||||||||||||||
| 1314 | - | |||||||||||||||||||||||||||||||
| 1315 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 1316 | ; | - | ||||||||||||||||||||||||||||||
| 1317 | (void)(argc); | - | ||||||||||||||||||||||||||||||
| 1318 | p = sqlite3_aggregate_context(context, sizeof(*p)); | - | ||||||||||||||||||||||||||||||
| 1319 | type = sqlite3_value_numeric_type(argv[0]); | - | ||||||||||||||||||||||||||||||
| 1320 | - | |||||||||||||||||||||||||||||||
| 1321 | - | |||||||||||||||||||||||||||||||
| 1322 | if( (
| 0-1878 | ||||||||||||||||||||||||||||||
| 1323 | - | |||||||||||||||||||||||||||||||
| 1324 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 1325 | ; | - | ||||||||||||||||||||||||||||||
| 1326 | p->cnt--; | - | ||||||||||||||||||||||||||||||
| 1327 | - | |||||||||||||||||||||||||||||||
| 1328 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 1329 | ; | - | ||||||||||||||||||||||||||||||
| 1330 | if( type==1
| 0-1874 | ||||||||||||||||||||||||||||||
| 1331 | i64 v = sqlite3_value_int64(argv[0]); | - | ||||||||||||||||||||||||||||||
| 1332 | p->rSum -= v; | - | ||||||||||||||||||||||||||||||
| 1333 | p->iSum -= v; | - | ||||||||||||||||||||||||||||||
| 1334 | } executed 1874 times by 1 test: else{end of blockExecuted by:
| 1874 | ||||||||||||||||||||||||||||||
| 1335 | p->rSum -= sqlite3_value_double(argv[0]); | - | ||||||||||||||||||||||||||||||
| 1336 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||||||||||||||
| 1337 | } | - | ||||||||||||||||||||||||||||||
| 1338 | } executed 1878 times by 1 test: end of blockExecuted by:
| 1878 | ||||||||||||||||||||||||||||||
| 1339 | - | |||||||||||||||||||||||||||||||
| 1340 | - | |||||||||||||||||||||||||||||||
| 1341 | - | |||||||||||||||||||||||||||||||
| 1342 | static void sumFinalize(sqlite3_context *context){ | - | ||||||||||||||||||||||||||||||
| 1343 | SumCtx *p; | - | ||||||||||||||||||||||||||||||
| 1344 | p = sqlite3_aggregate_context(context, 0); | - | ||||||||||||||||||||||||||||||
| 1345 | if( p
| 77-6330 | ||||||||||||||||||||||||||||||
| 1346 | if( p->overflow
| 3-6250 | ||||||||||||||||||||||||||||||
| 1347 | sqlite3_result_error(context,"integer overflow",-1); | - | ||||||||||||||||||||||||||||||
| 1348 | } executed 3 times by 1 test: else if( p->approxend of blockExecuted by:
| 3-6222 | ||||||||||||||||||||||||||||||
| 1349 | sqlite3_result_double(context, p->rSum); | - | ||||||||||||||||||||||||||||||
| 1350 | } executed 28 times by 1 test: else{end of blockExecuted by:
| 28 | ||||||||||||||||||||||||||||||
| 1351 | sqlite3_result_int64(context, p->iSum); | - | ||||||||||||||||||||||||||||||
| 1352 | } executed 6222 times by 1 test: end of blockExecuted by:
| 6222 | ||||||||||||||||||||||||||||||
| 1353 | } | - | ||||||||||||||||||||||||||||||
| 1354 | } executed 6658 times by 1 test: end of blockExecuted by:
| 6658 | ||||||||||||||||||||||||||||||
| 1355 | static void avgFinalize(sqlite3_context *context){ | - | ||||||||||||||||||||||||||||||
| 1356 | SumCtx *p; | - | ||||||||||||||||||||||||||||||
| 1357 | p = sqlite3_aggregate_context(context, 0); | - | ||||||||||||||||||||||||||||||
| 1358 | if( p
| 0-2145 | ||||||||||||||||||||||||||||||
| 1359 | sqlite3_result_double(context, p->rSum/(double)p->cnt); | - | ||||||||||||||||||||||||||||||
| 1360 | } executed 2145 times by 1 test: end of blockExecuted by:
| 2145 | ||||||||||||||||||||||||||||||
| 1361 | } executed 2147 times by 1 test: end of blockExecuted by:
| 2147 | ||||||||||||||||||||||||||||||
| 1362 | static void totalFinalize(sqlite3_context *context){ | - | ||||||||||||||||||||||||||||||
| 1363 | SumCtx *p; | - | ||||||||||||||||||||||||||||||
| 1364 | p = sqlite3_aggregate_context(context, 0); | - | ||||||||||||||||||||||||||||||
| 1365 | - | |||||||||||||||||||||||||||||||
| 1366 | sqlite3_result_double(context, p ? p->rSum : (double)0); | - | ||||||||||||||||||||||||||||||
| 1367 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||||||||||||||
| 1368 | - | |||||||||||||||||||||||||||||||
| 1369 | - | |||||||||||||||||||||||||||||||
| 1370 | - | |||||||||||||||||||||||||||||||
| 1371 | - | |||||||||||||||||||||||||||||||
| 1372 | - | |||||||||||||||||||||||||||||||
| 1373 | typedef struct CountCtx CountCtx; | - | ||||||||||||||||||||||||||||||
| 1374 | struct CountCtx { | - | ||||||||||||||||||||||||||||||
| 1375 | i64 n; | - | ||||||||||||||||||||||||||||||
| 1376 | - | |||||||||||||||||||||||||||||||
| 1377 | - | |||||||||||||||||||||||||||||||
| 1378 | - | |||||||||||||||||||||||||||||||
| 1379 | }; | - | ||||||||||||||||||||||||||||||
| 1380 | - | |||||||||||||||||||||||||||||||
| 1381 | - | |||||||||||||||||||||||||||||||
| 1382 | - | |||||||||||||||||||||||||||||||
| 1383 | - | |||||||||||||||||||||||||||||||
| 1384 | static void countStep(sqlite3_context *context, int argc, sqlite3_value **argv){ | - | ||||||||||||||||||||||||||||||
| 1385 | CountCtx *p; | - | ||||||||||||||||||||||||||||||
| 1386 | p = sqlite3_aggregate_context(context, sizeof(*p)); | - | ||||||||||||||||||||||||||||||
| 1387 | if( (argc==0
| 0-1505681 | ||||||||||||||||||||||||||||||
| 1388 | p->n++; | - | ||||||||||||||||||||||||||||||
| 1389 | } executed 1505681 times by 1 test: end of blockExecuted by:
| 1505681 | ||||||||||||||||||||||||||||||
| 1390 | - | |||||||||||||||||||||||||||||||
| 1391 | - | |||||||||||||||||||||||||||||||
| 1392 | - | |||||||||||||||||||||||||||||||
| 1393 | - | |||||||||||||||||||||||||||||||
| 1394 | - | |||||||||||||||||||||||||||||||
| 1395 | - | |||||||||||||||||||||||||||||||
| 1396 | - | |||||||||||||||||||||||||||||||
| 1397 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 1398 | - | |||||||||||||||||||||||||||||||
| 1399 | ; | - | ||||||||||||||||||||||||||||||
| 1400 | - | |||||||||||||||||||||||||||||||
| 1401 | } executed 1508989 times by 1 test: end of blockExecuted by:
| 1508989 | ||||||||||||||||||||||||||||||
| 1402 | static void countFinalize(sqlite3_context *context){ | - | ||||||||||||||||||||||||||||||
| 1403 | CountCtx *p; | - | ||||||||||||||||||||||||||||||
| 1404 | p = sqlite3_aggregate_context(context, 0); | - | ||||||||||||||||||||||||||||||
| 1405 | sqlite3_result_int64(context, p ? p->n : 0); | - | ||||||||||||||||||||||||||||||
| 1406 | } executed 19736 times by 1 test: end of blockExecuted by:
| 19736 | ||||||||||||||||||||||||||||||
| 1407 | - | |||||||||||||||||||||||||||||||
| 1408 | static void countInverse(sqlite3_context *ctx, int argc, sqlite3_value **argv){ | - | ||||||||||||||||||||||||||||||
| 1409 | CountCtx *p; | - | ||||||||||||||||||||||||||||||
| 1410 | p = sqlite3_aggregate_context(ctx, sizeof(*p)); | - | ||||||||||||||||||||||||||||||
| 1411 | - | |||||||||||||||||||||||||||||||
| 1412 | if( (argc==0
| 0-7515 | ||||||||||||||||||||||||||||||
| 1413 | p->n--; | - | ||||||||||||||||||||||||||||||
| 1414 | - | |||||||||||||||||||||||||||||||
| 1415 | - | |||||||||||||||||||||||||||||||
| 1416 | - | |||||||||||||||||||||||||||||||
| 1417 | } executed 7515 times by 1 test: end of blockExecuted by:
| 7515 | ||||||||||||||||||||||||||||||
| 1418 | } executed 7515 times by 1 test: end of blockExecuted by:
| 7515 | ||||||||||||||||||||||||||||||
| 1419 | - | |||||||||||||||||||||||||||||||
| 1420 | - | |||||||||||||||||||||||||||||||
| 1421 | - | |||||||||||||||||||||||||||||||
| 1422 | - | |||||||||||||||||||||||||||||||
| 1423 | - | |||||||||||||||||||||||||||||||
| 1424 | - | |||||||||||||||||||||||||||||||
| 1425 | - | |||||||||||||||||||||||||||||||
| 1426 | static void minmaxStep( | - | ||||||||||||||||||||||||||||||
| 1427 | sqlite3_context *context, | - | ||||||||||||||||||||||||||||||
| 1428 | int NotUsed, | - | ||||||||||||||||||||||||||||||
| 1429 | sqlite3_value **argv | - | ||||||||||||||||||||||||||||||
| 1430 | ){ | - | ||||||||||||||||||||||||||||||
| 1431 | Mem *pArg = (Mem *)argv[0]; | - | ||||||||||||||||||||||||||||||
| 1432 | Mem *pBest; | - | ||||||||||||||||||||||||||||||
| 1433 | (void)(NotUsed); | - | ||||||||||||||||||||||||||||||
| 1434 | - | |||||||||||||||||||||||||||||||
| 1435 | pBest = (Mem *)sqlite3_aggregate_context(context, sizeof(*pBest)); | - | ||||||||||||||||||||||||||||||
| 1436 | if( !pBest
never executed: return; | 0-263340 | ||||||||||||||||||||||||||||||
| 1437 | - | |||||||||||||||||||||||||||||||
| 1438 | if( sqlite3_value_type(pArg)==5
| 4163-259177 | ||||||||||||||||||||||||||||||
| 1439 | if( pBest->flags
executed 35 times by 1 test: sqlite3SkipAccumulatorLoad(context);Executed by:
| 35-4128 | ||||||||||||||||||||||||||||||
| 1440 | } executed 4163 times by 1 test: else if( pBest->flagsend of blockExecuted by:
| 4163-239068 | ||||||||||||||||||||||||||||||
| 1441 | int max; | - | ||||||||||||||||||||||||||||||
| 1442 | int cmp; | - | ||||||||||||||||||||||||||||||
| 1443 | CollSeq *pColl = sqlite3GetFuncCollSeq(context); | - | ||||||||||||||||||||||||||||||
| 1444 | max = sqlite3_user_data(context)!=0; | - | ||||||||||||||||||||||||||||||
| 1445 | cmp = sqlite3MemCompare(pBest, pArg, pColl); | - | ||||||||||||||||||||||||||||||
| 1446 | if( (max
| 7551-195255 | ||||||||||||||||||||||||||||||
| 1447 | sqlite3VdbeMemCopy(pBest, pArg); | - | ||||||||||||||||||||||||||||||
| 1448 | } executed 169797 times by 1 test: else{end of blockExecuted by:
| 169797 | ||||||||||||||||||||||||||||||
| 1449 | sqlite3SkipAccumulatorLoad(context); | - | ||||||||||||||||||||||||||||||
| 1450 | } executed 69271 times by 1 test: end of blockExecuted by:
| 69271 | ||||||||||||||||||||||||||||||
| 1451 | }else{ | - | ||||||||||||||||||||||||||||||
| 1452 | pBest->db = sqlite3_context_db_handle(context); | - | ||||||||||||||||||||||||||||||
| 1453 | sqlite3VdbeMemCopy(pBest, pArg); | - | ||||||||||||||||||||||||||||||
| 1454 | } executed 20109 times by 1 test: end of blockExecuted by:
| 20109 | ||||||||||||||||||||||||||||||
| 1455 | } | - | ||||||||||||||||||||||||||||||
| 1456 | static void minMaxValueFinalize(sqlite3_context *context, int bValue){ | - | ||||||||||||||||||||||||||||||
| 1457 | sqlite3_value *pRes; | - | ||||||||||||||||||||||||||||||
| 1458 | pRes = (sqlite3_value *)sqlite3_aggregate_context(context, 0); | - | ||||||||||||||||||||||||||||||
| 1459 | if( pRes
| 1137-22713 | ||||||||||||||||||||||||||||||
| 1460 | if( pRes->flags
| 19-22694 | ||||||||||||||||||||||||||||||
| 1461 | sqlite3_result_value(context, pRes); | - | ||||||||||||||||||||||||||||||
| 1462 | } executed 22694 times by 1 test: end of blockExecuted by:
| 22694 | ||||||||||||||||||||||||||||||
| 1463 | if( bValue==0
executed 20127 times by 1 test: sqlite3VdbeMemRelease(pRes);Executed by:
| 2586-20127 | ||||||||||||||||||||||||||||||
| 1464 | } executed 22713 times by 1 test: end of blockExecuted by:
| 22713 | ||||||||||||||||||||||||||||||
| 1465 | } executed 23850 times by 1 test: end of blockExecuted by:
| 23850 | ||||||||||||||||||||||||||||||
| 1466 | - | |||||||||||||||||||||||||||||||
| 1467 | static void minMaxValue(sqlite3_context *context){ | - | ||||||||||||||||||||||||||||||
| 1468 | minMaxValueFinalize(context, 1); | - | ||||||||||||||||||||||||||||||
| 1469 | } executed 2624 times by 1 test: end of blockExecuted by:
| 2624 | ||||||||||||||||||||||||||||||
| 1470 | - | |||||||||||||||||||||||||||||||
| 1471 | - | |||||||||||||||||||||||||||||||
| 1472 | - | |||||||||||||||||||||||||||||||
| 1473 | static void minMaxFinalize(sqlite3_context *context){ | - | ||||||||||||||||||||||||||||||
| 1474 | minMaxValueFinalize(context, 0); | - | ||||||||||||||||||||||||||||||
| 1475 | } executed 21226 times by 1 test: end of blockExecuted by:
| 21226 | ||||||||||||||||||||||||||||||
| 1476 | - | |||||||||||||||||||||||||||||||
| 1477 | - | |||||||||||||||||||||||||||||||
| 1478 | - | |||||||||||||||||||||||||||||||
| 1479 | - | |||||||||||||||||||||||||||||||
| 1480 | static void groupConcatStep( | - | ||||||||||||||||||||||||||||||
| 1481 | sqlite3_context *context, | - | ||||||||||||||||||||||||||||||
| 1482 | int argc, | - | ||||||||||||||||||||||||||||||
| 1483 | sqlite3_value **argv | - | ||||||||||||||||||||||||||||||
| 1484 | ){ | - | ||||||||||||||||||||||||||||||
| 1485 | const char *zVal; | - | ||||||||||||||||||||||||||||||
| 1486 | StrAccum *pAccum; | - | ||||||||||||||||||||||||||||||
| 1487 | const char *zSep; | - | ||||||||||||||||||||||||||||||
| 1488 | int nVal, nSep; | - | ||||||||||||||||||||||||||||||
| 1489 | - | |||||||||||||||||||||||||||||||
| 1490 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 1491 | ; | - | ||||||||||||||||||||||||||||||
| 1492 | if( sqlite3_value_type(argv[0])==5
executed 11 times by 1 test: return;Executed by:
| 11-45192 | ||||||||||||||||||||||||||||||
| 1493 | pAccum = (StrAccum*)sqlite3_aggregate_context(context, sizeof(*pAccum)); | - | ||||||||||||||||||||||||||||||
| 1494 | - | |||||||||||||||||||||||||||||||
| 1495 | if( pAccum
| 0-45192 | ||||||||||||||||||||||||||||||
| 1496 | sqlite3 *db = sqlite3_context_db_handle(context); | - | ||||||||||||||||||||||||||||||
| 1497 | int firstTerm = pAccum->mxAlloc==0; | - | ||||||||||||||||||||||||||||||
| 1498 | pAccum->mxAlloc = db->aLimit[0]; | - | ||||||||||||||||||||||||||||||
| 1499 | if( !firstTerm
| 14538-30654 | ||||||||||||||||||||||||||||||
| 1500 | if( argc==2
| 8674-21980 | ||||||||||||||||||||||||||||||
| 1501 | zSep = (char*)sqlite3_value_text(argv[1]); | - | ||||||||||||||||||||||||||||||
| 1502 | nSep = sqlite3_value_bytes(argv[1]); | - | ||||||||||||||||||||||||||||||
| 1503 | } executed 21980 times by 1 test: else{end of blockExecuted by:
| 21980 | ||||||||||||||||||||||||||||||
| 1504 | zSep = ","; | - | ||||||||||||||||||||||||||||||
| 1505 | nSep = 1; | - | ||||||||||||||||||||||||||||||
| 1506 | } executed 8674 times by 1 test: end of blockExecuted by:
| 8674 | ||||||||||||||||||||||||||||||
| 1507 | if( zSep
executed 30650 times by 1 test: sqlite3_str_append(pAccum, zSep, nSep);Executed by:
| 4-30650 | ||||||||||||||||||||||||||||||
| 1508 | } executed 30654 times by 1 test: end of blockExecuted by:
| 30654 | ||||||||||||||||||||||||||||||
| 1509 | zVal = (char*)sqlite3_value_text(argv[0]); | - | ||||||||||||||||||||||||||||||
| 1510 | nVal = sqlite3_value_bytes(argv[0]); | - | ||||||||||||||||||||||||||||||
| 1511 | if( zVal
executed 45192 times by 1 test: sqlite3_str_append(pAccum, zVal, nVal);Executed by:
| 0-45192 | ||||||||||||||||||||||||||||||
| 1512 | } executed 45192 times by 1 test: end of blockExecuted by:
| 45192 | ||||||||||||||||||||||||||||||
| 1513 | } executed 45192 times by 1 test: end of blockExecuted by:
| 45192 | ||||||||||||||||||||||||||||||
| 1514 | - | |||||||||||||||||||||||||||||||
| 1515 | static void groupConcatInverse( | - | ||||||||||||||||||||||||||||||
| 1516 | sqlite3_context *context, | - | ||||||||||||||||||||||||||||||
| 1517 | int argc, | - | ||||||||||||||||||||||||||||||
| 1518 | sqlite3_value **argv | - | ||||||||||||||||||||||||||||||
| 1519 | ){ | - | ||||||||||||||||||||||||||||||
| 1520 | int n; | - | ||||||||||||||||||||||||||||||
| 1521 | StrAccum *pAccum; | - | ||||||||||||||||||||||||||||||
| 1522 | - | |||||||||||||||||||||||||||||||
| 1523 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 1524 | ; | - | ||||||||||||||||||||||||||||||
| 1525 | if( sqlite3_value_type(argv[0])==5
never executed: return; | 0-11783 | ||||||||||||||||||||||||||||||
| 1526 | pAccum = (StrAccum*)sqlite3_aggregate_context(context, sizeof(*pAccum)); | - | ||||||||||||||||||||||||||||||
| 1527 | - | |||||||||||||||||||||||||||||||
| 1528 | - | |||||||||||||||||||||||||||||||
| 1529 | if( (
| 0-11783 | ||||||||||||||||||||||||||||||
| 1530 | n = sqlite3_value_bytes(argv[0]); | - | ||||||||||||||||||||||||||||||
| 1531 | if( argc==2
| 2-11781 | ||||||||||||||||||||||||||||||
| 1532 | n += sqlite3_value_bytes(argv[1]); | - | ||||||||||||||||||||||||||||||
| 1533 | } executed 11781 times by 1 test: else{end of blockExecuted by:
| 11781 | ||||||||||||||||||||||||||||||
| 1534 | n++; | - | ||||||||||||||||||||||||||||||
| 1535 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||||||||||||||
| 1536 | if( n>=(int)pAccum->nChar
| 1640-10143 | ||||||||||||||||||||||||||||||
| 1537 | pAccum->nChar = 0; | - | ||||||||||||||||||||||||||||||
| 1538 | } executed 1640 times by 1 test: else{end of blockExecuted by:
| 1640 | ||||||||||||||||||||||||||||||
| 1539 | pAccum->nChar -= n; | - | ||||||||||||||||||||||||||||||
| 1540 | memmove(pAccum->zText, &pAccum->zText[n], pAccum->nChar); | - | ||||||||||||||||||||||||||||||
| 1541 | } executed 10143 times by 1 test: end of blockExecuted by:
| 10143 | ||||||||||||||||||||||||||||||
| 1542 | if( pAccum->nChar==0
executed 1640 times by 1 test: pAccum->mxAlloc = 0;Executed by:
| 1640-10143 | ||||||||||||||||||||||||||||||
| 1543 | } executed 11783 times by 1 test: end of blockExecuted by:
| 11783 | ||||||||||||||||||||||||||||||
| 1544 | } executed 11783 times by 1 test: end of blockExecuted by:
| 11783 | ||||||||||||||||||||||||||||||
| 1545 | - | |||||||||||||||||||||||||||||||
| 1546 | - | |||||||||||||||||||||||||||||||
| 1547 | - | |||||||||||||||||||||||||||||||
| 1548 | static void groupConcatFinalize(sqlite3_context *context){ | - | ||||||||||||||||||||||||||||||
| 1549 | StrAccum *pAccum; | - | ||||||||||||||||||||||||||||||
| 1550 | pAccum = sqlite3_aggregate_context(context, 0); | - | ||||||||||||||||||||||||||||||
| 1551 | if( pAccum
| 694-13362 | ||||||||||||||||||||||||||||||
| 1552 | if( pAccum->accError==18
| 0-13362 | ||||||||||||||||||||||||||||||
| 1553 | sqlite3_result_error_toobig(context); | - | ||||||||||||||||||||||||||||||
| 1554 | } never executed: else if( pAccum->accError==7end of block
| 0-13362 | ||||||||||||||||||||||||||||||
| 1555 | sqlite3_result_error_nomem(context); | - | ||||||||||||||||||||||||||||||
| 1556 | } never executed: else{end of block | 0 | ||||||||||||||||||||||||||||||
| 1557 | sqlite3_result_text(context, sqlite3StrAccumFinish(pAccum), -1, | - | ||||||||||||||||||||||||||||||
| 1558 | sqlite3_free); | - | ||||||||||||||||||||||||||||||
| 1559 | } executed 13362 times by 1 test: end of blockExecuted by:
| 13362 | ||||||||||||||||||||||||||||||
| 1560 | } | - | ||||||||||||||||||||||||||||||
| 1561 | } executed 14056 times by 1 test: end of blockExecuted by:
| 14056 | ||||||||||||||||||||||||||||||
| 1562 | - | |||||||||||||||||||||||||||||||
| 1563 | static void groupConcatValue(sqlite3_context *context){ | - | ||||||||||||||||||||||||||||||
| 1564 | sqlite3_str *pAccum; | - | ||||||||||||||||||||||||||||||
| 1565 | pAccum = (sqlite3_str*)sqlite3_aggregate_context(context, 0); | - | ||||||||||||||||||||||||||||||
| 1566 | if( pAccum
| 8129-21797 | ||||||||||||||||||||||||||||||
| 1567 | if( pAccum->accError==18
| 0-21797 | ||||||||||||||||||||||||||||||
| 1568 | sqlite3_result_error_toobig(context); | - | ||||||||||||||||||||||||||||||
| 1569 | } never executed: else if( pAccum->accError==7end of block
| 0-21797 | ||||||||||||||||||||||||||||||
| 1570 | sqlite3_result_error_nomem(context); | - | ||||||||||||||||||||||||||||||
| 1571 | } never executed: else{end of block | 0 | ||||||||||||||||||||||||||||||
| 1572 | const char *zText = sqlite3_str_value(pAccum); | - | ||||||||||||||||||||||||||||||
| 1573 | sqlite3_result_text(context, zText, -1, ((sqlite3_destructor_type)-1)); | - | ||||||||||||||||||||||||||||||
| 1574 | } executed 21797 times by 1 test: end of blockExecuted by:
| 21797 | ||||||||||||||||||||||||||||||
| 1575 | } | - | ||||||||||||||||||||||||||||||
| 1576 | } executed 29926 times by 1 test: end of blockExecuted by:
| 29926 | ||||||||||||||||||||||||||||||
| 1577 | void sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3 *db){ | - | ||||||||||||||||||||||||||||||
| 1578 | int rc = sqlite3_overload_function(db, "MATCH", 2); | - | ||||||||||||||||||||||||||||||
| 1579 | - | |||||||||||||||||||||||||||||||
| 1580 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 1581 | ; | - | ||||||||||||||||||||||||||||||
| 1582 | if( rc==7
| 32-31743 | ||||||||||||||||||||||||||||||
| 1583 | sqlite3OomFault(db); | - | ||||||||||||||||||||||||||||||
| 1584 | } executed 32 times by 1 test: end of blockExecuted by:
| 32 | ||||||||||||||||||||||||||||||
| 1585 | } executed 31775 times by 438 tests: end of blockExecuted by:
| 31775 | ||||||||||||||||||||||||||||||
| 1586 | - | |||||||||||||||||||||||||||||||
| 1587 | - | |||||||||||||||||||||||||||||||
| 1588 | - | |||||||||||||||||||||||||||||||
| 1589 | - | |||||||||||||||||||||||||||||||
| 1590 | static void setLikeOptFlag(sqlite3 *db, const char *zName, u8 flagVal){ | - | ||||||||||||||||||||||||||||||
| 1591 | FuncDef *pDef; | - | ||||||||||||||||||||||||||||||
| 1592 | pDef = sqlite3FindFunction(db, zName, 2, 1, 0); | - | ||||||||||||||||||||||||||||||
| 1593 | if( (
| 0-58 | ||||||||||||||||||||||||||||||
| 1594 | pDef->funcFlags |= flagVal; | - | ||||||||||||||||||||||||||||||
| 1595 | } executed 58 times by 1 test: end of blockExecuted by:
| 58 | ||||||||||||||||||||||||||||||
| 1596 | } executed 58 times by 1 test: end of blockExecuted by:
| 58 | ||||||||||||||||||||||||||||||
| 1597 | - | |||||||||||||||||||||||||||||||
| 1598 | - | |||||||||||||||||||||||||||||||
| 1599 | - | |||||||||||||||||||||||||||||||
| 1600 | - | |||||||||||||||||||||||||||||||
| 1601 | - | |||||||||||||||||||||||||||||||
| 1602 | - | |||||||||||||||||||||||||||||||
| 1603 | void sqlite3RegisterLikeFunctions(sqlite3 *db, int caseSensitive){ | - | ||||||||||||||||||||||||||||||
| 1604 | struct compareInfo *pInfo; | - | ||||||||||||||||||||||||||||||
| 1605 | if( caseSensitive
| 14-15 | ||||||||||||||||||||||||||||||
| 1606 | pInfo = (struct compareInfo*)&likeInfoAlt; | - | ||||||||||||||||||||||||||||||
| 1607 | } executed 14 times by 1 test: else{end of blockExecuted by:
| 14 | ||||||||||||||||||||||||||||||
| 1608 | pInfo = (struct compareInfo*)&likeInfoNorm; | - | ||||||||||||||||||||||||||||||
| 1609 | } executed 15 times by 1 test: end of blockExecuted by:
| 15 | ||||||||||||||||||||||||||||||
| 1610 | sqlite3CreateFunc(db, "like", 2, 1, pInfo, likeFunc, 0, 0, 0, 0, 0); | - | ||||||||||||||||||||||||||||||
| 1611 | sqlite3CreateFunc(db, "like", 3, 1, pInfo, likeFunc, 0, 0, 0, 0, 0); | - | ||||||||||||||||||||||||||||||
| 1612 | sqlite3CreateFunc(db, "glob", 2, 1, | - | ||||||||||||||||||||||||||||||
| 1613 | (struct compareInfo*)&globInfo, likeFunc, 0, 0, 0, 0, 0); | - | ||||||||||||||||||||||||||||||
| 1614 | setLikeOptFlag(db, "glob", 0x0004 | 0x0008); | - | ||||||||||||||||||||||||||||||
| 1615 | setLikeOptFlag(db, "like", | - | ||||||||||||||||||||||||||||||
| 1616 | caseSensitive ? (0x0004 | 0x0008) : 0x0004); | - | ||||||||||||||||||||||||||||||
| 1617 | } executed 29 times by 1 test: end of blockExecuted by:
| 29 | ||||||||||||||||||||||||||||||
| 1618 | int sqlite3IsLikeFunction(sqlite3 *db, Expr *pExpr, int *pIsNocase, char *aWc){ | - | ||||||||||||||||||||||||||||||
| 1619 | FuncDef *pDef; | - | ||||||||||||||||||||||||||||||
| 1620 | int nExpr; | - | ||||||||||||||||||||||||||||||
| 1621 | if( pExpr->op!=157
| 0-236797 | ||||||||||||||||||||||||||||||
| 1622 | return executed 236797 times by 368 tests: 0;return 0;Executed by:
executed 236797 times by 368 tests: return 0;Executed by:
| 236797 | ||||||||||||||||||||||||||||||
| 1623 | } | - | ||||||||||||||||||||||||||||||
| 1624 | - | |||||||||||||||||||||||||||||||
| 1625 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 1626 | ; | - | ||||||||||||||||||||||||||||||
| 1627 | nExpr = pExpr->x.pList->nExpr; | - | ||||||||||||||||||||||||||||||
| 1628 | pDef = sqlite3FindFunction(db, pExpr->u.zToken, nExpr, 1, 0); | - | ||||||||||||||||||||||||||||||
| 1629 | if( (
| 0-11590 | ||||||||||||||||||||||||||||||
| 1630 | return executed 130 times by 1 test: 0;return 0;Executed by:
executed 130 times by 1 test: return 0;Executed by:
| 130 | ||||||||||||||||||||||||||||||
| 1631 | } | - | ||||||||||||||||||||||||||||||
| 1632 | if( nExpr<3
| 15-11445 | ||||||||||||||||||||||||||||||
| 1633 | aWc[3] = 0; | - | ||||||||||||||||||||||||||||||
| 1634 | } executed 11445 times by 1 test: else{end of blockExecuted by:
| 11445 | ||||||||||||||||||||||||||||||
| 1635 | Expr *pEscape = pExpr->x.pList->a[2].pExpr; | - | ||||||||||||||||||||||||||||||
| 1636 | char *zEscape; | - | ||||||||||||||||||||||||||||||
| 1637 | if( pEscape->op!=106
never executed: 0;return 0;never executed: return 0; | 0-15 | ||||||||||||||||||||||||||||||
| 1638 | zEscape = pEscape->u.zToken; | - | ||||||||||||||||||||||||||||||
| 1639 | if( zEscape[0]==0
executed 2 times by 1 test: 0;return 0;Executed by:
executed 2 times by 1 test: return 0;Executed by:
| 1-14 | ||||||||||||||||||||||||||||||
| 1640 | aWc[3] = zEscape[0]; | - | ||||||||||||||||||||||||||||||
| 1641 | } executed 13 times by 1 test: end of blockExecuted by:
| 13 | ||||||||||||||||||||||||||||||
| 1642 | - | |||||||||||||||||||||||||||||||
| 1643 | - | |||||||||||||||||||||||||||||||
| 1644 | - | |||||||||||||||||||||||||||||||
| 1645 | - | |||||||||||||||||||||||||||||||
| 1646 | - | |||||||||||||||||||||||||||||||
| 1647 | memcpy(aWc, pDef->pUserData, 3); | - | ||||||||||||||||||||||||||||||
| 1648 | - | |||||||||||||||||||||||||||||||
| 1649 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 1650 | ; | - | ||||||||||||||||||||||||||||||
| 1651 | - | |||||||||||||||||||||||||||||||
| 1652 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 1653 | ; | - | ||||||||||||||||||||||||||||||
| 1654 | - | |||||||||||||||||||||||||||||||
| 1655 | ((void) (0)) | - | ||||||||||||||||||||||||||||||
| 1656 | ; | - | ||||||||||||||||||||||||||||||
| 1657 | *pIsNocase = (pDef->funcFlags & 0x0008)==0; | - | ||||||||||||||||||||||||||||||
| 1658 | return executed 11458 times by 1 test: 1;return 1;Executed by:
executed 11458 times by 1 test: return 1;Executed by:
| 11458 | ||||||||||||||||||||||||||||||
| 1659 | } | - | ||||||||||||||||||||||||||||||
| 1660 | void sqlite3RegisterBuiltinFunctions(void){ | - | ||||||||||||||||||||||||||||||
| 1661 | static FuncDef aBuiltinFunc[] = { | - | ||||||||||||||||||||||||||||||
| 1662 | - | |||||||||||||||||||||||||||||||
| 1663 | - | |||||||||||||||||||||||||||||||
| 1664 | - | |||||||||||||||||||||||||||||||
| 1665 | - | |||||||||||||||||||||||||||||||
| 1666 | {1, 1|(0*0x0020), ((void*)(long int)(0)), 0, loadExt, 0, 0, 0, "load_extension", {0} }, | - | ||||||||||||||||||||||||||||||
| 1667 | {2, 1|(0*0x0020), ((void*)(long int)(0)), 0, loadExt, 0, 0, 0, "load_extension", {0} }, | - | ||||||||||||||||||||||||||||||
| 1668 | - | |||||||||||||||||||||||||||||||
| 1669 | - | |||||||||||||||||||||||||||||||
| 1670 | - | |||||||||||||||||||||||||||||||
| 1671 | - | |||||||||||||||||||||||||||||||
| 1672 | - | |||||||||||||||||||||||||||||||
| 1673 | {1, 0x2000|1, 0, 0, compileoptionusedFunc, 0, 0, 0, "sqlite_compileoption_used", {0} }, | - | ||||||||||||||||||||||||||||||
| 1674 | {1, 0x2000|1, 0, 0, compileoptiongetFunc, 0, 0, 0, "sqlite_compileoption_get", {0} }, | - | ||||||||||||||||||||||||||||||
| 1675 | - | |||||||||||||||||||||||||||||||
| 1676 | {1,0x0800|1|(0*0x0020)|0x0400, ((void*)(long int)(0)), 0, versionFunc, 0, 0, 0, "unlikely", {0} }, | - | ||||||||||||||||||||||||||||||
| 1677 | {2,0x0800|1|(0*0x0020)|0x0400, ((void*)(long int)(0)), 0, versionFunc, 0, 0, 0, "likelihood", {0} }, | - | ||||||||||||||||||||||||||||||
| 1678 | {1,0x0800|1|(0*0x0020)|0x0400, ((void*)(long int)(0)), 0, versionFunc, 0, 0, 0, "likely", {0} }, | - | ||||||||||||||||||||||||||||||
| 1679 | - | |||||||||||||||||||||||||||||||
| 1680 | - | |||||||||||||||||||||||||||||||
| 1681 | - | |||||||||||||||||||||||||||||||
| 1682 | - | |||||||||||||||||||||||||||||||
| 1683 | - | |||||||||||||||||||||||||||||||
| 1684 | - | |||||||||||||||||||||||||||||||
| 1685 | - | |||||||||||||||||||||||||||||||
| 1686 | {1, 0x0800|1|(0*0x0020), ((void*)(long int)(1)), 0, trimFunc, 0, 0, 0, "ltrim", {0} }, | - | ||||||||||||||||||||||||||||||
| 1687 | {2, 0x0800|1|(0*0x0020), ((void*)(long int)(1)), 0, trimFunc, 0, 0, 0, "ltrim", {0} }, | - | ||||||||||||||||||||||||||||||
| 1688 | {1, 0x0800|1|(0*0x0020), ((void*)(long int)(2)), 0, trimFunc, 0, 0, 0, "rtrim", {0} }, | - | ||||||||||||||||||||||||||||||
| 1689 | {2, 0x0800|1|(0*0x0020), ((void*)(long int)(2)), 0, trimFunc, 0, 0, 0, "rtrim", {0} }, | - | ||||||||||||||||||||||||||||||
| 1690 | {1, 0x0800|1|(0*0x0020), ((void*)(long int)(3)), 0, trimFunc, 0, 0, 0, "trim", {0} }, | - | ||||||||||||||||||||||||||||||
| 1691 | {2, 0x0800|1|(0*0x0020), ((void*)(long int)(3)), 0, trimFunc, 0, 0, 0, "trim", {0} }, | - | ||||||||||||||||||||||||||||||
| 1692 | {-1, 0x0800|1|(1*0x0020), ((void*)(long int)(0)), 0, minmaxFunc, 0, 0, 0, "min", {0} }, | - | ||||||||||||||||||||||||||||||
| 1693 | {0, 0x0800|1|(1*0x0020), ((void*)(long int)(0)), 0, 0, 0, 0, 0, "min", {0} }, | - | ||||||||||||||||||||||||||||||
| 1694 | {1, 1|(1*0x0020)|0x1000, ((void*)(long int)(0)), 0, minmaxStep,minMaxFinalize,minMaxValue,0,"min", {0}} | - | ||||||||||||||||||||||||||||||
| 1695 | , | - | ||||||||||||||||||||||||||||||
| 1696 | {-1, 0x0800|1|(1*0x0020), ((void*)(long int)(1)), 0, minmaxFunc, 0, 0, 0, "max", {0} }, | - | ||||||||||||||||||||||||||||||
| 1697 | {0, 0x0800|1|(1*0x0020), ((void*)(long int)(1)), 0, 0, 0, 0, 0, "max", {0} }, | - | ||||||||||||||||||||||||||||||
| 1698 | {1, 1|(1*0x0020)|0x1000, ((void*)(long int)(1)), 0, minmaxStep,minMaxFinalize,minMaxValue,0,"max", {0}} | - | ||||||||||||||||||||||||||||||
| 1699 | , | - | ||||||||||||||||||||||||||||||
| 1700 | {1,0x0800|1|(0*0x0020)|0x0080, ((void*)(long int)(0)), 0, typeofFunc, 0, 0, 0, "typeof", {0} }, | - | ||||||||||||||||||||||||||||||
| 1701 | {1,0x0800|1|(0*0x0020)|0x0040, ((void*)(long int)(0)), 0, lengthFunc, 0, 0, 0, "length", {0} }, | - | ||||||||||||||||||||||||||||||
| 1702 | {2, 0x0800|1|(0*0x0020), ((void*)(long int)(0)), 0, instrFunc, 0, 0, 0, "instr", {0} }, | - | ||||||||||||||||||||||||||||||
| 1703 | {-1, 0x0800|1|(0*0x0020), ((void*)(long int)(0)), 0, printfFunc, 0, 0, 0, "printf", {0} }, | - | ||||||||||||||||||||||||||||||
| 1704 | {1, 0x0800|1|(0*0x0020), ((void*)(long int)(0)), 0, unicodeFunc, 0, 0, 0, "unicode", {0} }, | - | ||||||||||||||||||||||||||||||
| 1705 | {-1, 0x0800|1|(0*0x0020), ((void*)(long int)(0)), 0, charFunc, 0, 0, 0, "char", {0} }, | - | ||||||||||||||||||||||||||||||
| 1706 | {1, 0x0800|1|(0*0x0020), ((void*)(long int)(0)), 0, absFunc, 0, 0, 0, "abs", {0} }, | - | ||||||||||||||||||||||||||||||
| 1707 | - | |||||||||||||||||||||||||||||||
| 1708 | {1, 0x0800|1|(0*0x0020), ((void*)(long int)(0)), 0, roundFunc, 0, 0, 0, "round", {0} }, | - | ||||||||||||||||||||||||||||||
| 1709 | {2, 0x0800|1|(0*0x0020), ((void*)(long int)(0)), 0, roundFunc, 0, 0, 0, "round", {0} }, | - | ||||||||||||||||||||||||||||||
| 1710 | - | |||||||||||||||||||||||||||||||
| 1711 | {1, 0x0800|1|(0*0x0020), ((void*)(long int)(0)), 0, upperFunc, 0, 0, 0, "upper", {0} }, | - | ||||||||||||||||||||||||||||||
| 1712 | {1, 0x0800|1|(0*0x0020), ((void*)(long int)(0)), 0, lowerFunc, 0, 0, 0, "lower", {0} }, | - | ||||||||||||||||||||||||||||||
| 1713 | {1, 0x0800|1|(0*0x0020), ((void*)(long int)(0)), 0, hexFunc, 0, 0, 0, "hex", {0} }, | - | ||||||||||||||||||||||||||||||
| 1714 | {2,0x0800|1|(0*0x0020)|0x0200, ((void*)(long int)(0)), 0, versionFunc, 0, 0, 0, "ifnull", {0} }, | - | ||||||||||||||||||||||||||||||
| 1715 | {0, 1|(0*0x0020), ((void*)(long int)(0)), 0, randomFunc, 0, 0, 0, "random", {0} }, | - | ||||||||||||||||||||||||||||||
| 1716 | {1, 1|(0*0x0020), ((void*)(long int)(0)), 0, randomBlob, 0, 0, 0, "randomblob", {0} }, | - | ||||||||||||||||||||||||||||||
| 1717 | {2, 0x0800|1|(1*0x0020), ((void*)(long int)(0)), 0, nullifFunc, 0, 0, 0, "nullif", {0} }, | - | ||||||||||||||||||||||||||||||
| 1718 | {0, 0x2000|1, 0, 0, versionFunc, 0, 0, 0, "sqlite_version", {0} }, | - | ||||||||||||||||||||||||||||||
| 1719 | {0, 0x2000|1, 0, 0, sourceidFunc, 0, 0, 0, "sqlite_source_id", {0} }, | - | ||||||||||||||||||||||||||||||
| 1720 | {2, 0x0800|1|(0*0x0020), ((void*)(long int)(0)), 0, errlogFunc, 0, 0, 0, "sqlite_log", {0} }, | - | ||||||||||||||||||||||||||||||
| 1721 | {1, 0x0800|1|(0*0x0020), ((void*)(long int)(0)), 0, quoteFunc, 0, 0, 0, "quote", {0} }, | - | ||||||||||||||||||||||||||||||
| 1722 | {0, 1|(0*0x0020), ((void*)(long int)(0)), 0, last_insert_rowid, 0, 0, 0, "last_insert_rowid", {0} }, | - | ||||||||||||||||||||||||||||||
| 1723 | {0, 1|(0*0x0020), ((void*)(long int)(0)), 0, changes, 0, 0, 0, "changes", {0} }, | - | ||||||||||||||||||||||||||||||
| 1724 | {0, 1|(0*0x0020), ((void*)(long int)(0)), 0, total_changes, 0, 0, 0, "total_changes", {0} }, | - | ||||||||||||||||||||||||||||||
| 1725 | {3, 0x0800|1|(0*0x0020), ((void*)(long int)(0)), 0, replaceFunc, 0, 0, 0, "replace", {0} }, | - | ||||||||||||||||||||||||||||||
| 1726 | {1, 0x0800|1|(0*0x0020), ((void*)(long int)(0)), 0, zeroblobFunc, 0, 0, 0, "zeroblob", {0} }, | - | ||||||||||||||||||||||||||||||
| 1727 | {2, 0x0800|1|(0*0x0020), ((void*)(long int)(0)), 0, substrFunc, 0, 0, 0, "substr", {0} }, | - | ||||||||||||||||||||||||||||||
| 1728 | {3, 0x0800|1|(0*0x0020), ((void*)(long int)(0)), 0, substrFunc, 0, 0, 0, "substr", {0} }, | - | ||||||||||||||||||||||||||||||
| 1729 | {1, 1|(0*0x0020)|0, ((void*)(long int)(0)), 0, sumStep,sumFinalize,sumFinalize,sumInverse,"sum", {0}}, | - | ||||||||||||||||||||||||||||||
| 1730 | {1, 1|(0*0x0020)|0, ((void*)(long int)(0)), 0, sumStep,totalFinalize,totalFinalize,sumInverse,"total", {0}}, | - | ||||||||||||||||||||||||||||||
| 1731 | {1, 1|(0*0x0020)|0, ((void*)(long int)(0)), 0, sumStep,avgFinalize,avgFinalize,sumInverse,"avg", {0}}, | - | ||||||||||||||||||||||||||||||
| 1732 | {0, 1|(0*0x0020)|0x0100, ((void*)(long int)(0)), 0, countStep,countFinalize,countFinalize,countInverse,"count", {0}} | - | ||||||||||||||||||||||||||||||
| 1733 | , | - | ||||||||||||||||||||||||||||||
| 1734 | {1, 1|(0*0x0020)|0, ((void*)(long int)(0)), 0, countStep,countFinalize,countFinalize,countInverse,"count", {0}} | - | ||||||||||||||||||||||||||||||
| 1735 | , | - | ||||||||||||||||||||||||||||||
| 1736 | {1, 1|(0*0x0020)|0, ((void*)(long int)(0)), 0, groupConcatStep,groupConcatFinalize,groupConcatValue,groupConcatInverse,"group_concat", {0}} | - | ||||||||||||||||||||||||||||||
| 1737 | , | - | ||||||||||||||||||||||||||||||
| 1738 | {2, 1|(0*0x0020)|0, ((void*)(long int)(0)), 0, groupConcatStep,groupConcatFinalize,groupConcatValue,groupConcatInverse,"group_concat", {0}} | - | ||||||||||||||||||||||||||||||
| 1739 | , | - | ||||||||||||||||||||||||||||||
| 1740 | - | |||||||||||||||||||||||||||||||
| 1741 | {2, 0x0800|1|0x0004|0x0008, (void *)&globInfo, 0, likeFunc, 0, 0, 0, "glob", {0} }, | - | ||||||||||||||||||||||||||||||
| 1742 | - | |||||||||||||||||||||||||||||||
| 1743 | - | |||||||||||||||||||||||||||||||
| 1744 | - | |||||||||||||||||||||||||||||||
| 1745 | - | |||||||||||||||||||||||||||||||
| 1746 | {2, 0x0800|1|0x0004, (void *)&likeInfoNorm, 0, likeFunc, 0, 0, 0, "like", {0} }, | - | ||||||||||||||||||||||||||||||
| 1747 | {3, 0x0800|1|0x0004, (void *)&likeInfoNorm, 0, likeFunc, 0, 0, 0, "like", {0} }, | - | ||||||||||||||||||||||||||||||
| 1748 | - | |||||||||||||||||||||||||||||||
| 1749 | - | |||||||||||||||||||||||||||||||
| 1750 | - | |||||||||||||||||||||||||||||||
| 1751 | - | |||||||||||||||||||||||||||||||
| 1752 | {1, 0x0800|1|(0*0x0020), ((void*)(long int)(0)), 0, 0, 0, 0, 0, "coalesce", {0} }, | - | ||||||||||||||||||||||||||||||
| 1753 | {0, 0x0800|1|(0*0x0020), ((void*)(long int)(0)), 0, 0, 0, 0, 0, "coalesce", {0} }, | - | ||||||||||||||||||||||||||||||
| 1754 | {-1,0x0800|1|(0*0x0020)|0x0200, ((void*)(long int)(0)), 0, versionFunc, 0, 0, 0, "coalesce", {0} }, | - | ||||||||||||||||||||||||||||||
| 1755 | }; | - | ||||||||||||||||||||||||||||||
| 1756 | - | |||||||||||||||||||||||||||||||
| 1757 | sqlite3AlterFunctions(); | - | ||||||||||||||||||||||||||||||
| 1758 | - | |||||||||||||||||||||||||||||||
| 1759 | sqlite3WindowFunctions(); | - | ||||||||||||||||||||||||||||||
| 1760 | - | |||||||||||||||||||||||||||||||
| 1761 | - | |||||||||||||||||||||||||||||||
| 1762 | - | |||||||||||||||||||||||||||||||
| 1763 | sqlite3RegisterDateTimeFunctions(); | - | ||||||||||||||||||||||||||||||
| 1764 | sqlite3InsertBuiltinFuncs(aBuiltinFunc, ((int)(sizeof(aBuiltinFunc)/sizeof(aBuiltinFunc[0])))); | - | ||||||||||||||||||||||||||||||
| 1765 | } executed 534 times by 438 tests: end of blockExecuted by:
| 534 | ||||||||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |