mirror of https://github.com/citusdata/citus.git
Address review
parent
04758ff272
commit
cbdf059c52
|
@ -459,19 +459,20 @@ FilterShardsFromPgclass(Node *node, void *context)
|
||||||
/* make sure the expression is in the right memory context */
|
/* make sure the expression is in the right memory context */
|
||||||
MemoryContext originalContext = MemoryContextSwitchTo(queryContext);
|
MemoryContext originalContext = MemoryContextSwitchTo(queryContext);
|
||||||
|
|
||||||
/* add NOT relation_is_a_known_shard(oid) to the security quals of the RTE */
|
|
||||||
|
/* add relation_is_a_known_shard(oid) IS NOT TRUE to the quals of the query */
|
||||||
|
Node *newQual = CreateRelationIsAKnownShardFilter(varno);
|
||||||
Node *oldQuals = query->jointree->quals;
|
Node *oldQuals = query->jointree->quals;
|
||||||
if (oldQuals)
|
if (oldQuals)
|
||||||
{
|
{
|
||||||
query->jointree->quals = (Node *) makeBoolExpr(
|
query->jointree->quals = (Node *) makeBoolExpr(
|
||||||
AND_EXPR,
|
AND_EXPR,
|
||||||
list_make2(oldQuals, CreateRelationIsAKnownShardFilter(varno)),
|
list_make2(oldQuals, newQual),
|
||||||
-1);
|
-1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
query->jointree->quals = (Node *) CreateRelationIsAKnownShardFilter(
|
query->jointree->quals = newQual;
|
||||||
varno);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryContextSwitchTo(originalContext);
|
MemoryContextSwitchTo(originalContext);
|
||||||
|
@ -486,7 +487,13 @@ FilterShardsFromPgclass(Node *node, void *context)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CreateRelationIsAKnownShardFilter constructs an expression of the form:
|
* CreateRelationIsAKnownShardFilter constructs an expression of the form:
|
||||||
* NOT pg_catalog.relation_is_a_known_shard(oid)
|
* pg_catalog.relation_is_a_known_shard(oid) IS NOT TRUE
|
||||||
|
*
|
||||||
|
* The difference between "NOT pg_catalog.relation_is_a_known_shard(oid)" and
|
||||||
|
* "pg_catalog.relation_is_a_known_shard(oid) IS NOT TRUE" is that the former
|
||||||
|
* will return FALSE if the function returns NULL, while the second will return
|
||||||
|
* TRUE. This difference is important in the case of outer joins, because this
|
||||||
|
* filter might be applied on an oid that is then NULL.
|
||||||
*/
|
*/
|
||||||
static Node *
|
static Node *
|
||||||
CreateRelationIsAKnownShardFilter(int pgClassVarno)
|
CreateRelationIsAKnownShardFilter(int pgClassVarno)
|
||||||
|
|
|
@ -83,6 +83,13 @@ SELECT relname FROM pg_catalog.pg_class WHERE relnamespace = 'mx_hide_shard_name
|
||||||
test_table
|
test_table
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
-- EVen when using subquery and having no existing quals on pg_clcass
|
||||||
|
SELECT relname FROM (SELECT relname, relnamespace FROM pg_catalog.pg_class) AS q WHERE relnamespace = 'mx_hide_shard_names'::regnamespace ORDER BY relname;
|
||||||
|
relname
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
test_table
|
||||||
|
(1 row)
|
||||||
|
|
||||||
commit prepared 'take-aggressive-lock';
|
commit prepared 'take-aggressive-lock';
|
||||||
-- now create an index
|
-- now create an index
|
||||||
\c - - - :master_port
|
\c - - - :master_port
|
||||||
|
|
|
@ -50,6 +50,8 @@ prepare transaction 'take-aggressive-lock';
|
||||||
|
|
||||||
-- shards are hidden when using psql as application_name
|
-- shards are hidden when using psql as application_name
|
||||||
SELECT relname FROM pg_catalog.pg_class WHERE relnamespace = 'mx_hide_shard_names'::regnamespace ORDER BY relname;
|
SELECT relname FROM pg_catalog.pg_class WHERE relnamespace = 'mx_hide_shard_names'::regnamespace ORDER BY relname;
|
||||||
|
-- EVen when using subquery and having no existing quals on pg_clcass
|
||||||
|
SELECT relname FROM (SELECT relname, relnamespace FROM pg_catalog.pg_class) AS q WHERE relnamespace = 'mx_hide_shard_names'::regnamespace ORDER BY relname;
|
||||||
|
|
||||||
commit prepared 'take-aggressive-lock';
|
commit prepared 'take-aggressive-lock';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue