| 361 | } |
| 362 | |
| 363 | static bool |
| 364 | contains_required_value(ITEM *curitem) |
| 365 | { |
| 366 | /* since this function recurses, it could be driven to stack overflow */ |
| 367 | check_stack_depth(); |
| 368 | |
| 369 | if (curitem->type == VAL) |
| 370 | return true; |
| 371 | else if (curitem->val == (int32) '!') |
| 372 | { |
| 373 | /* |
| 374 | * Assume anything under a NOT is non-required. For some cases with |
| 375 | * nested NOTs, we could prove there's a required value, but it seems |
| 376 | * unlikely to be worth the trouble. |
| 377 | */ |
| 378 | return false; |
| 379 | } |
| 380 | else if (curitem->val == (int32) '&') |
| 381 | { |
| 382 | /* If either side has a required value, we're good */ |
| 383 | if (contains_required_value(curitem + curitem->left)) |
| 384 | return true; |
| 385 | else |
| 386 | return contains_required_value(curitem - 1); |
| 387 | } |
| 388 | else |
| 389 | { /* |-operator */ |
| 390 | /* Both sides must have required values */ |
| 391 | if (contains_required_value(curitem + curitem->left)) |
| 392 | return contains_required_value(curitem - 1); |
| 393 | else |
| 394 | return false; |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | bool |
| 399 | query_has_required_values(QUERYTYPE *query) |
no test coverage detected