Skip to content

Commit 7c595b2

Browse files
danolivoarssher
authored andcommitted
Core patch for distributed parallel executor.
1 parent 863471e commit 7c595b2

File tree

17 files changed

+1493
-34
lines changed

17 files changed

+1493
-34
lines changed

contrib/postgres_fdw/connection.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,10 @@ configure_remote_session(PGconn *conn)
392392
int remoteversion = PQserverVersion(conn);
393393

394394
/* Force the search path to contain only pg_catalog (see deparse.c) */
395-
do_sql_command(conn, "SET search_path = pg_catalog");
395+
/*
396+
* Suppress for debug purposes
397+
* do_sql_command(conn, "SET search_path = pg_catalog");
398+
*/
396399

397400
/*
398401
* Set remote timezone; this is basically just cosmetic, since all

src/backend/commands/opclasscmds.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,6 +1599,58 @@ RemoveOpFamilyById(Oid opfamilyOid)
15991599
heap_close(rel, RowExclusiveLock);
16001600
}
16011601

1602+
Oid
1603+
get_family_oid(const char *opfname, const char *nspname, const char *ammth)
1604+
{
1605+
Oid nspoid,
1606+
amoid,
1607+
opfoid = InvalidOid;
1608+
HeapTuple htup = NULL;
1609+
1610+
nspoid = LookupNamespaceNoError(nspname);
1611+
amoid = get_am_oid(ammth, false);
1612+
1613+
if (OidIsValid(nspoid) && OidIsValid(amoid))
1614+
htup = SearchSysCache3(OPFAMILYAMNAMENSP,
1615+
ObjectIdGetDatum(amoid),
1616+
PointerGetDatum(opfname),
1617+
ObjectIdGetDatum(nspoid));
1618+
1619+
if (HeapTupleIsValid(htup))
1620+
{
1621+
opfoid = HeapTupleGetOid(htup);
1622+
ReleaseSysCache(htup);
1623+
}
1624+
1625+
return opfoid;
1626+
}
1627+
1628+
char *
1629+
get_opfamily_name(Oid opfamilyOid, char **nspname, char **opfmethod)
1630+
{
1631+
HeapTuple tup;
1632+
char *opfname;
1633+
Oid nspoid,
1634+
mthoid;
1635+
1636+
Assert(nspname != NULL);
1637+
1638+
1639+
tup = SearchSysCache1(OPFAMILYOID, ObjectIdGetDatum(opfamilyOid));
1640+
if (!HeapTupleIsValid(tup)) /* should not happen */
1641+
elog(ERROR, "cache lookup failed for opfamily %u", opfamilyOid);
1642+
1643+
opfname = pstrdup(NameStr(((Form_pg_opfamily) GETSTRUCT(tup))->opfname));
1644+
nspoid = ((Form_pg_opfamily) GETSTRUCT(tup))->opfnamespace;
1645+
*nspname = get_namespace_name(nspoid);
1646+
1647+
mthoid = ((Form_pg_opfamily) GETSTRUCT(tup))->opfmethod;
1648+
*opfmethod = get_am_name(mthoid);
1649+
1650+
ReleaseSysCache(tup);
1651+
return opfname;
1652+
}
1653+
16021654
void
16031655
RemoveOpClassById(Oid opclassOid)
16041656
{

src/backend/commands/user.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,42 @@ DropRole(DropRoleStmt *stmt)
11361136
heap_close(pg_authid_rel, NoLock);
11371137
}
11381138

1139+
char *
1140+
get_rolename(Oid roleid)
1141+
{
1142+
HeapTuple tuple;
1143+
char *rolename;
1144+
1145+
tuple = SearchSysCache1(AUTHOID, ObjectIdGetDatum(roleid));
1146+
1147+
if (!HeapTupleIsValid(tuple))
1148+
ereport(ERROR,
1149+
(errcode(ERRCODE_UNDEFINED_OBJECT),
1150+
errmsg("role with oid\"%d\" does not exist", roleid)));
1151+
1152+
rolename = strdup(NameStr(((Form_pg_authid) GETSTRUCT(tuple))->rolname));
1153+
ReleaseSysCache(tuple);
1154+
return rolename;
1155+
}
1156+
1157+
Oid
1158+
get_roleid(const char *rolename)
1159+
{
1160+
HeapTuple tuple;
1161+
Oid roleid;
1162+
1163+
tuple = SearchSysCache1(AUTHNAME, CStringGetDatum(rolename));
1164+
1165+
if (!HeapTupleIsValid(tuple))
1166+
ereport(ERROR,
1167+
(errcode(ERRCODE_UNDEFINED_OBJECT),
1168+
errmsg("role \"%s\" does not exist", rolename)));
1169+
1170+
roleid = HeapTupleGetOid(tuple);
1171+
ReleaseSysCache(tuple);
1172+
return roleid;
1173+
}
1174+
11391175
/*
11401176
* Rename role
11411177
*/

src/backend/executor/nodeHashjoin.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ static bool ExecParallelHashJoinNewBatch(HashJoinState *hjstate);
148148
static void ExecParallelHashJoinPartitionOuter(HashJoinState *node);
149149

150150

151+
static bool distributed = true;
151152
/* ----------------------------------------------------------------
152153
* ExecHashJoinImpl
153154
*
@@ -243,7 +244,7 @@ ExecHashJoinImpl(PlanState *pstate, bool parallel)
243244
/* no chance to not build the hash table */
244245
node->hj_FirstOuterTupleSlot = NULL;
245246
}
246-
else if (parallel)
247+
else if (parallel || distributed)
247248
{
248249
/*
249250
* The empty-outer optimization is not implemented for
@@ -294,7 +295,8 @@ ExecHashJoinImpl(PlanState *pstate, bool parallel)
294295
* doing a left outer join, we can quit without scanning the
295296
* outer relation.
296297
*/
297-
if (hashtable->totalTuples == 0 && !HJ_FILL_OUTER(node))
298+
if (!distributed && hashtable->totalTuples == 0 &&
299+
!HJ_FILL_OUTER(node))
298300
return NULL;
299301

300302
/*

0 commit comments

Comments
 (0)