Parse, plan, and execute a query string */
| 621 | |
| 622 | /* Parse, plan, and execute a query string */ |
| 623 | int |
| 624 | SPI_execute(const char *src, bool read_only, long tcount) |
| 625 | { |
| 626 | _SPI_plan plan; |
| 627 | SPIExecuteOptions options; |
| 628 | int res; |
| 629 | |
| 630 | if (src == NULL || tcount < 0) |
| 631 | return SPI_ERROR_ARGUMENT; |
| 632 | |
| 633 | res = _SPI_begin_call(true); |
| 634 | if (res < 0) |
| 635 | return res; |
| 636 | |
| 637 | memset(&plan, 0, sizeof(_SPI_plan)); |
| 638 | plan.magic = _SPI_PLAN_MAGIC; |
| 639 | plan.parse_mode = RAW_PARSE_DEFAULT; |
| 640 | plan.cursor_options = CURSOR_OPT_PARALLEL_OK; |
| 641 | |
| 642 | _SPI_prepare_oneshot_plan(src, &plan); |
| 643 | |
| 644 | memset(&options, 0, sizeof(options)); |
| 645 | options.read_only = read_only; |
| 646 | options.tcount = tcount; |
| 647 | |
| 648 | res = _SPI_execute_plan(&plan, &options, |
| 649 | InvalidSnapshot, InvalidSnapshot, |
| 650 | true); |
| 651 | |
| 652 | _SPI_end_call(true); |
| 653 | return res; |
| 654 | } |
| 655 | |
| 656 | /* Obsolete version of SPI_execute */ |
| 657 | int |