* ALTER RESOURCE QUEUE */
| 999 | * ALTER RESOURCE QUEUE |
| 1000 | */ |
| 1001 | void |
| 1002 | AlterQueue(AlterQueueStmt *stmt) |
| 1003 | { |
| 1004 | Relation pg_resqueue_rel; |
| 1005 | TupleDesc pg_resqueue_dsc; |
| 1006 | ScanKeyData scankey; |
| 1007 | SysScanDesc sscan; |
| 1008 | HeapTuple tuple, new_tuple; |
| 1009 | Oid queueid; |
| 1010 | Cost thresholds[NUM_RES_LIMIT_TYPES]; |
| 1011 | Datum new_record[Natts_pg_resqueue]; |
| 1012 | bool new_record_nulls[Natts_pg_resqueue]; |
| 1013 | bool new_record_repl[Natts_pg_resqueue]; |
| 1014 | ListCell *option; |
| 1015 | ListCell *pWithList = NULL; |
| 1016 | |
| 1017 | /* thresholds for active and cost limiters. */ |
| 1018 | Cost activelimit = INVALID_RES_LIMIT_THRESHOLD; |
| 1019 | Cost costlimit = INVALID_RES_LIMIT_THRESHOLD; |
| 1020 | |
| 1021 | /* overcommit indicator */ |
| 1022 | bool overcommit = false; |
| 1023 | |
| 1024 | /* cost ignore limit for queries */ |
| 1025 | float4 ignorelimit = 0; |
| 1026 | |
| 1027 | DefElem *dactivelimit = NULL; |
| 1028 | DefElem *dcostlimit = NULL; |
| 1029 | DefElem *dovercommit = NULL; |
| 1030 | DefElem *dignorelimit = NULL; |
| 1031 | ResAlterQueueResult queueok; |
| 1032 | bool bWith = false; |
| 1033 | bool bWithOut = false; |
| 1034 | int numopts = 0; |
| 1035 | char *alter_subtype = ""; /* metadata tracking: kind of |
| 1036 | redundant to say "role" */ |
| 1037 | |
| 1038 | /* Permission check - only superuser can alter queues. */ |
| 1039 | if (!superuser()) |
| 1040 | ereport(ERROR, |
| 1041 | (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), |
| 1042 | errmsg("must be superuser to alter resource queues"))); |
| 1043 | |
| 1044 | /* Extract options from the statement node tree */ |
| 1045 | foreach(option, stmt->options) |
| 1046 | { |
| 1047 | DefElem *defel = (DefElem *) lfirst(option); |
| 1048 | |
| 1049 | if (strcmp(defel->defname, "active_statements") == 0) |
| 1050 | { |
| 1051 | if (dactivelimit) |
| 1052 | ereport(ERROR, |
| 1053 | (errcode(ERRCODE_SYNTAX_ERROR), |
| 1054 | errmsg("conflicting or redundant options"))); |
| 1055 | if (!bWithOut) |
| 1056 | dactivelimit = defel; |
| 1057 | else |
| 1058 | dactivelimit = |
no test coverage detected