|
37 | 37 | #include "access/sysattr.h"
|
38 | 38 | #include "access/table.h"
|
39 | 39 | #include "catalog/pg_aggregate.h"
|
| 40 | +#include "catalog/pg_authid.h" |
40 | 41 | #include "catalog/pg_collation.h"
|
41 | 42 | #include "catalog/pg_namespace.h"
|
42 | 43 | #include "catalog/pg_operator.h"
|
43 | 44 | #include "catalog/pg_opfamily.h"
|
44 | 45 | #include "catalog/pg_proc.h"
|
| 46 | +#include "catalog/pg_ts_config.h" |
| 47 | +#include "catalog/pg_ts_dict.h" |
45 | 48 | #include "catalog/pg_type.h"
|
46 | 49 | #include "commands/defrem.h"
|
47 | 50 | #include "nodes/makefuncs.h"
|
@@ -384,6 +387,75 @@ foreign_expr_walker(Node *node,
|
384 | 387 | {
|
385 | 388 | Const *c = (Const *) node;
|
386 | 389 |
|
| 390 | + /* |
| 391 | + * Constants of regproc and related types can't be shipped |
| 392 | + * unless the referenced object is shippable. But NULL's ok. |
| 393 | + * (See also the related code in dependency.c.) |
| 394 | + */ |
| 395 | + if (!c->constisnull) |
| 396 | + { |
| 397 | + switch (c->consttype) |
| 398 | + { |
| 399 | + case REGPROCOID: |
| 400 | + case REGPROCEDUREOID: |
| 401 | + if (!is_shippable(DatumGetObjectId(c->constvalue), |
| 402 | + ProcedureRelationId, fpinfo)) |
| 403 | + return false; |
| 404 | + break; |
| 405 | + case REGOPEROID: |
| 406 | + case REGOPERATOROID: |
| 407 | + if (!is_shippable(DatumGetObjectId(c->constvalue), |
| 408 | + OperatorRelationId, fpinfo)) |
| 409 | + return false; |
| 410 | + break; |
| 411 | + case REGCLASSOID: |
| 412 | + if (!is_shippable(DatumGetObjectId(c->constvalue), |
| 413 | + RelationRelationId, fpinfo)) |
| 414 | + return false; |
| 415 | + break; |
| 416 | + case REGTYPEOID: |
| 417 | + if (!is_shippable(DatumGetObjectId(c->constvalue), |
| 418 | + TypeRelationId, fpinfo)) |
| 419 | + return false; |
| 420 | + break; |
| 421 | + case REGCOLLATIONOID: |
| 422 | + if (!is_shippable(DatumGetObjectId(c->constvalue), |
| 423 | + CollationRelationId, fpinfo)) |
| 424 | + return false; |
| 425 | + break; |
| 426 | + case REGCONFIGOID: |
| 427 | + |
| 428 | + /* |
| 429 | + * For text search objects only, we weaken the |
| 430 | + * normal shippability criterion to allow all OIDs |
| 431 | + * below FirstNormalObjectId. Without this, none |
| 432 | + * of the initdb-installed TS configurations would |
| 433 | + * be shippable, which would be quite annoying. |
| 434 | + */ |
| 435 | + if (DatumGetObjectId(c->constvalue) >= FirstNormalObjectId && |
| 436 | + !is_shippable(DatumGetObjectId(c->constvalue), |
| 437 | + TSConfigRelationId, fpinfo)) |
| 438 | + return false; |
| 439 | + break; |
| 440 | + case REGDICTIONARYOID: |
| 441 | + if (DatumGetObjectId(c->constvalue) >= FirstNormalObjectId && |
| 442 | + !is_shippable(DatumGetObjectId(c->constvalue), |
| 443 | + TSDictionaryRelationId, fpinfo)) |
| 444 | + return false; |
| 445 | + break; |
| 446 | + case REGNAMESPACEOID: |
| 447 | + if (!is_shippable(DatumGetObjectId(c->constvalue), |
| 448 | + NamespaceRelationId, fpinfo)) |
| 449 | + return false; |
| 450 | + break; |
| 451 | + case REGROLEOID: |
| 452 | + if (!is_shippable(DatumGetObjectId(c->constvalue), |
| 453 | + AuthIdRelationId, fpinfo)) |
| 454 | + return false; |
| 455 | + break; |
| 456 | + } |
| 457 | + } |
| 458 | + |
387 | 459 | /*
|
388 | 460 | * If the constant has nondefault collation, either it's of a
|
389 | 461 | * non-builtin type, or it reflects folding of a CollateExpr.
|
|
0 commit comments