diff options
author | Pavan Deolasee | 2018-07-19 09:31:07 +0000 |
---|---|---|
committer | Pavan Deolasee | 2018-07-27 08:01:29 +0000 |
commit | 28dcb30a154e2ac18da679c12ae9a17b7ef6fa2f (patch) | |
tree | 6907e2571fa2f7f48927eb8681cc5d0f247d692f | |
parent | e7b4a1e0e35cdc7547e40bc9860eb6e32be569d8 (diff) |
Teach pgxc_exec_sizefunc() to use pg_my_temp_schema() to get temp schema
Similar to what we did in e688c0c23c962d425b82fdfad014bace4207af1d, we must not
rely on the temporary namespace on the coordinator since it may change on the
remote nodes. Instead we use the pg_my_temp_schema() function to find the
currently active temporary schema on the remote node.
-rw-r--r-- | src/backend/utils/adt/dbsize.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/backend/utils/adt/dbsize.c b/src/backend/utils/adt/dbsize.c index 5bf80a26a9..6d5fe23c5f 100644 --- a/src/backend/utils/adt/dbsize.c +++ b/src/backend/utils/adt/dbsize.c @@ -1356,18 +1356,28 @@ pgxc_exec_sizefunc(Oid relOid, char *funcname, char *extra_arg) char *relname = NULL; StringInfoData buf; Relation rel; + bool istemp; rel = relation_open(relOid, AccessShareLock); + istemp = (rel->rd_rel->relpersistence == RELPERSISTENCE_TEMP); - if (rel->rd_locator_info) - /* get relation name including any needed schema prefix and quoting */ - relname = quote_qualified_identifier(get_namespace_name(rel->rd_rel->relnamespace), - RelationGetRelationName(rel)); initStringInfo(&buf); + /* get relation name including any needed schema prefix and quoting */ if (!extra_arg) - appendStringInfo(&buf, "SELECT pg_catalog.%s('%s')", funcname, relname); + appendStringInfo(&buf, "SELECT pg_catalog.%s(c.oid) " + "FROM pg_class c JOIN pg_namespace nc " + " ON c.oid = nc.oid ", funcname); + else + appendStringInfo(&buf, "SELECT pg_catalog.%s(c.oid, '%s') " + "FROM pg_class c JOIN pg_namespace nc " + " ON c.oid = nc.oid ", funcname, extra_arg); + + if (!istemp) + appendStringInfo(&buf, "WHERE relname = '%s' AND nc.nspname = '%s'", + relname, get_namespace_name(rel->rd_rel->relnamespace)); else - appendStringInfo(&buf, "SELECT pg_catalog.%s('%s', '%s')", funcname, relname, extra_arg); + appendStringInfo(&buf, "WHERE relname = '%s' AND " + " nc.oid = pg_my_temp_schema()", relname); numnodes = get_pgxc_classnodes(RelationGetRelid(rel), &nodelist); |