|
89 | 89 | #include "utils/snapmgr.h" |
90 | 90 | #include "utils/timeout.h" |
91 | 91 | #include "utils/timestamp.h" |
| 92 | +#include "utils/varlena.h" |
92 | 93 |
|
93 | 94 | #include "cdb/cdbutil.h" |
94 | 95 | #include "cdb/cdbvars.h" |
@@ -151,6 +152,8 @@ cancel_pending_hook_type cancel_pending_hook = NULL; |
151 | 152 | * Hook for query execution. |
152 | 153 | */ |
153 | 154 | exec_simple_query_hook_type exec_simple_query_hook = NULL; |
| 155 | +/* flags for non-system relation kinds to restrict use */ |
| 156 | +int restrict_nonsystem_relation_kind; |
154 | 157 |
|
155 | 158 | /* ---------------- |
156 | 159 | * private typedefs etc |
@@ -4546,6 +4549,66 @@ assign_max_stack_depth(int newval, void *extra) |
4546 | 4549 | max_stack_depth_bytes = newval_bytes; |
4547 | 4550 | } |
4548 | 4551 |
|
| 4552 | +/* |
| 4553 | + * GUC check_hook for restrict_nonsystem_relation_kind |
| 4554 | + */ |
| 4555 | +bool |
| 4556 | +check_restrict_nonsystem_relation_kind(char **newval, void **extra, GucSource source) |
| 4557 | +{ |
| 4558 | + char *rawstring; |
| 4559 | + List *elemlist; |
| 4560 | + ListCell *l; |
| 4561 | + int flags = 0; |
| 4562 | + |
| 4563 | + /* Need a modifiable copy of string */ |
| 4564 | + rawstring = pstrdup(*newval); |
| 4565 | + |
| 4566 | + if (!SplitIdentifierString(rawstring, ',', &elemlist)) |
| 4567 | + { |
| 4568 | + /* syntax error in list */ |
| 4569 | + GUC_check_errdetail("List syntax is invalid."); |
| 4570 | + pfree(rawstring); |
| 4571 | + list_free(elemlist); |
| 4572 | + return false; |
| 4573 | + } |
| 4574 | + |
| 4575 | + foreach(l, elemlist) |
| 4576 | + { |
| 4577 | + char *tok = (char *) lfirst(l); |
| 4578 | + |
| 4579 | + if (pg_strcasecmp(tok, "view") == 0) |
| 4580 | + flags |= RESTRICT_RELKIND_VIEW; |
| 4581 | + else if (pg_strcasecmp(tok, "foreign-table") == 0) |
| 4582 | + flags |= RESTRICT_RELKIND_FOREIGN_TABLE; |
| 4583 | + else |
| 4584 | + { |
| 4585 | + GUC_check_errdetail("Unrecognized key word: \"%s\".", tok); |
| 4586 | + pfree(rawstring); |
| 4587 | + list_free(elemlist); |
| 4588 | + return false; |
| 4589 | + } |
| 4590 | + } |
| 4591 | + |
| 4592 | + pfree(rawstring); |
| 4593 | + list_free(elemlist); |
| 4594 | + |
| 4595 | + /* Save the flags in *extra, for use by the assign function */ |
| 4596 | + *extra = malloc(sizeof(int)); |
| 4597 | + *((int *) *extra) = flags; |
| 4598 | + |
| 4599 | + return true; |
| 4600 | +} |
| 4601 | + |
| 4602 | +/* |
| 4603 | + * GUC assign_hook for restrict_nonsystem_relation_kind |
| 4604 | + */ |
| 4605 | +void |
| 4606 | +assign_restrict_nonsystem_relation_kind(const char *newval, void *extra) |
| 4607 | +{ |
| 4608 | + int *flags = (int *) extra; |
| 4609 | + |
| 4610 | + restrict_nonsystem_relation_kind = *flags; |
| 4611 | +} |
4549 | 4612 |
|
4550 | 4613 | /* |
4551 | 4614 | * set_debug_options --- apply "-d N" command line option |
|
0 commit comments