Parse a query and open it as a cursor */
| 1558 | |
| 1559 | /* Parse a query and open it as a cursor */ |
| 1560 | Portal |
| 1561 | SPI_cursor_parse_open(const char *name, |
| 1562 | const char *src, |
| 1563 | const SPIParseOpenOptions *options) |
| 1564 | { |
| 1565 | Portal result; |
| 1566 | _SPI_plan plan; |
| 1567 | |
| 1568 | if (src == NULL || options == NULL) |
| 1569 | elog(ERROR, "SPI_cursor_parse_open called with invalid arguments"); |
| 1570 | |
| 1571 | SPI_result = _SPI_begin_call(true); |
| 1572 | if (SPI_result < 0) |
| 1573 | elog(ERROR, "SPI_cursor_parse_open called while not connected"); |
| 1574 | |
| 1575 | memset(&plan, 0, sizeof(_SPI_plan)); |
| 1576 | plan.magic = _SPI_PLAN_MAGIC; |
| 1577 | plan.parse_mode = RAW_PARSE_DEFAULT; |
| 1578 | plan.cursor_options = options->cursorOptions; |
| 1579 | if (options->params) |
| 1580 | { |
| 1581 | plan.parserSetup = options->params->parserSetup; |
| 1582 | plan.parserSetupArg = options->params->parserSetupArg; |
| 1583 | } |
| 1584 | |
| 1585 | _SPI_prepare_plan(src, &plan); |
| 1586 | |
| 1587 | /* We needn't copy the plan; SPI_cursor_open_internal will do so */ |
| 1588 | |
| 1589 | result = SPI_cursor_open_internal(name, &plan, |
| 1590 | options->params, options->read_only); |
| 1591 | |
| 1592 | /* And clean up */ |
| 1593 | _SPI_end_call(true); |
| 1594 | |
| 1595 | return result; |
| 1596 | } |
| 1597 | |
| 1598 | |
| 1599 | /* |
no test coverage detected