* CREATE RESOURCE QUEUE */
| 702 | * CREATE RESOURCE QUEUE |
| 703 | */ |
| 704 | void |
| 705 | CreateQueue(CreateQueueStmt *stmt) |
| 706 | { |
| 707 | Relation pg_resqueue_rel; |
| 708 | TupleDesc pg_resqueue_dsc; |
| 709 | ScanKeyData scankey; |
| 710 | SysScanDesc sscan; |
| 711 | HeapTuple tuple; |
| 712 | Oid queueid; |
| 713 | Cost thresholds[NUM_RES_LIMIT_TYPES]; |
| 714 | Datum new_record[Natts_pg_resqueue]; |
| 715 | bool new_record_nulls[Natts_pg_resqueue]; |
| 716 | ListCell *option; |
| 717 | ListCell *pWithList = NULL; |
| 718 | |
| 719 | /* thresholds for active and cost limiters. */ |
| 720 | Cost activelimit = INVALID_RES_LIMIT_THRESHOLD; |
| 721 | Cost costlimit = INVALID_RES_LIMIT_THRESHOLD; |
| 722 | |
| 723 | /* overcommit indicator */ |
| 724 | bool overcommit = false; |
| 725 | |
| 726 | /* cost ignore limit for queries */ |
| 727 | float4 ignorelimit = 0; |
| 728 | |
| 729 | DefElem *dactivelimit = NULL; |
| 730 | DefElem *dcostlimit = NULL; |
| 731 | DefElem *dovercommit = NULL; |
| 732 | DefElem *dignorelimit = NULL; |
| 733 | bool queueok = false; |
| 734 | bool bWith = false; |
| 735 | |
| 736 | /* Permission check - only superuser can create queues. */ |
| 737 | if (!superuser()) |
| 738 | ereport(ERROR, |
| 739 | (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), |
| 740 | errmsg("must be superuser to create resource queues"))); |
| 741 | |
| 742 | /* Extract options from the statement node tree */ |
| 743 | foreach(option, stmt->options) |
| 744 | { |
| 745 | DefElem *defel = (DefElem *) lfirst(option); |
| 746 | |
| 747 | if (strcmp(defel->defname, "active_statements") == 0) |
| 748 | { |
| 749 | if (dactivelimit) |
| 750 | ereport(ERROR, |
| 751 | (errcode(ERRCODE_SYNTAX_ERROR), |
| 752 | errmsg("conflicting or redundant options"))); |
| 753 | dactivelimit = defel; |
| 754 | } |
| 755 | else if (strcmp(defel->defname, "max_cost") == 0) |
| 756 | { |
| 757 | if (dcostlimit) |
| 758 | ereport(ERROR, |
| 759 | (errcode(ERRCODE_SYNTAX_ERROR), |
| 760 | errmsg("conflicting or redundant options"))); |
| 761 | dcostlimit = defel; |
no test coverage detected