mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +03:00
postgres_fdw: be more wary about shippability of reg* constants.
Don't consider a constant of regconfig or other reg* types to be shippable unless it refers to a built-in object, or an object in an extension that's been marked shippable. Without this restriction, we're too likely to send a constant that will fail to parse on the remote server. For the regconfig type only, consider OIDs up to 16383 to be "built in", rather than the normal cutoff of 9999. Otherwise the initdb-created text search configurations will be considered unshippable, which is unlikely to make anyone happy. It's possible that this new restriction will de-optimize queries that were working satisfactorily before. Users can restore any lost performance by making sure that objects that can be expected to exist on the remote side are in shippable extensions. However, that's not a change that people are likely to be happy about having to make after a minor-release update. Between that consideration and the lack of field complaints, let's just change this in HEAD. Noted while fixing bug #17483, although this is not precisely the problem that that report complained about. Discussion: https://postgr.es/m/1423433.1652722406@sss.pgh.pa.us
This commit is contained in:
@ -37,11 +37,14 @@
|
||||
#include "access/sysattr.h"
|
||||
#include "access/table.h"
|
||||
#include "catalog/pg_aggregate.h"
|
||||
#include "catalog/pg_authid.h"
|
||||
#include "catalog/pg_collation.h"
|
||||
#include "catalog/pg_namespace.h"
|
||||
#include "catalog/pg_operator.h"
|
||||
#include "catalog/pg_opfamily.h"
|
||||
#include "catalog/pg_proc.h"
|
||||
#include "catalog/pg_ts_config.h"
|
||||
#include "catalog/pg_ts_dict.h"
|
||||
#include "catalog/pg_type.h"
|
||||
#include "commands/defrem.h"
|
||||
#include "nodes/makefuncs.h"
|
||||
@ -384,6 +387,75 @@ foreign_expr_walker(Node *node,
|
||||
{
|
||||
Const *c = (Const *) node;
|
||||
|
||||
/*
|
||||
* Constants of regproc and related types can't be shipped
|
||||
* unless the referenced object is shippable. But NULL's ok.
|
||||
* (See also the related code in dependency.c.)
|
||||
*/
|
||||
if (!c->constisnull)
|
||||
{
|
||||
switch (c->consttype)
|
||||
{
|
||||
case REGPROCOID:
|
||||
case REGPROCEDUREOID:
|
||||
if (!is_shippable(DatumGetObjectId(c->constvalue),
|
||||
ProcedureRelationId, fpinfo))
|
||||
return false;
|
||||
break;
|
||||
case REGOPEROID:
|
||||
case REGOPERATOROID:
|
||||
if (!is_shippable(DatumGetObjectId(c->constvalue),
|
||||
OperatorRelationId, fpinfo))
|
||||
return false;
|
||||
break;
|
||||
case REGCLASSOID:
|
||||
if (!is_shippable(DatumGetObjectId(c->constvalue),
|
||||
RelationRelationId, fpinfo))
|
||||
return false;
|
||||
break;
|
||||
case REGTYPEOID:
|
||||
if (!is_shippable(DatumGetObjectId(c->constvalue),
|
||||
TypeRelationId, fpinfo))
|
||||
return false;
|
||||
break;
|
||||
case REGCOLLATIONOID:
|
||||
if (!is_shippable(DatumGetObjectId(c->constvalue),
|
||||
CollationRelationId, fpinfo))
|
||||
return false;
|
||||
break;
|
||||
case REGCONFIGOID:
|
||||
|
||||
/*
|
||||
* For text search objects only, we weaken the
|
||||
* normal shippability criterion to allow all OIDs
|
||||
* below FirstNormalObjectId. Without this, none
|
||||
* of the initdb-installed TS configurations would
|
||||
* be shippable, which would be quite annoying.
|
||||
*/
|
||||
if (DatumGetObjectId(c->constvalue) >= FirstNormalObjectId &&
|
||||
!is_shippable(DatumGetObjectId(c->constvalue),
|
||||
TSConfigRelationId, fpinfo))
|
||||
return false;
|
||||
break;
|
||||
case REGDICTIONARYOID:
|
||||
if (DatumGetObjectId(c->constvalue) >= FirstNormalObjectId &&
|
||||
!is_shippable(DatumGetObjectId(c->constvalue),
|
||||
TSDictionaryRelationId, fpinfo))
|
||||
return false;
|
||||
break;
|
||||
case REGNAMESPACEOID:
|
||||
if (!is_shippable(DatumGetObjectId(c->constvalue),
|
||||
NamespaceRelationId, fpinfo))
|
||||
return false;
|
||||
break;
|
||||
case REGROLEOID:
|
||||
if (!is_shippable(DatumGetObjectId(c->constvalue),
|
||||
AuthIdRelationId, fpinfo))
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If the constant has nondefault collation, either it's of a
|
||||
* non-builtin type, or it reflects folding of a CollateExpr.
|
||||
|
Reference in New Issue
Block a user