Parse post-WHERE clauses: additional MATCH, WITH, RETURN. A UNION keyword * is left for cbm_parse, which reads the branches in a loop. */
| 2012 | /* Parse post-WHERE clauses: additional MATCH, WITH, RETURN. A UNION keyword |
| 2013 | * is left for cbm_parse, which reads the branches in a loop. */ |
| 2014 | static int parse_post_where(parser_t *p, cbm_query_t *q, int *pat_cap) { |
| 2015 | /* More MATCH / OPTIONAL MATCH after WHERE */ |
| 2016 | if (parse_match_chain(p, q, pat_cap) < 0) { |
| 2017 | return CBM_NOT_FOUND; |
| 2018 | } |
| 2019 | /* Check for unsupported keywords */ |
| 2020 | const char *unsup = unsupported_clause_error(peek(p)->type); |
| 2021 | if (unsup) { |
| 2022 | snprintf(p->error, sizeof(p->error), "%s", unsup); |
| 2023 | return CBM_NOT_FOUND; |
| 2024 | } |
| 2025 | /* Optional WITH clause (standalone, not STARTS WITH) */ |
| 2026 | if (check(p, TOK_WITH) && |
| 2027 | (p->pos < PAIR_LEN || p->tokens[p->pos - SKIP_ONE].type != TOK_STARTS)) { |
| 2028 | if (parse_return_or_with(p, &q->with_clause, true) < 0) { |
| 2029 | return CBM_NOT_FOUND; |
| 2030 | } |
| 2031 | if (parse_where(p, &q->post_with_where) < 0) { |
| 2032 | return CBM_NOT_FOUND; |
| 2033 | } |
| 2034 | } |
| 2035 | /* Optional RETURN */ |
| 2036 | if (parse_return(p, &q->ret) < 0) { |
| 2037 | return CBM_NOT_FOUND; |
| 2038 | } |
| 2039 | return 0; |
| 2040 | } |
| 2041 | |
| 2042 | /* A stage that failed without writing a message gets the stage's own. */ |
| 2043 | static void parse_error_default(parser_t *p, const char *msg) { |
no test coverage detected