From 28dcb30a154e2ac18da679c12ae9a17b7ef6fa2f Mon Sep 17 00:00:00 2001 From: Pavan Deolasee Date: Thu, 19 Jul 2018 15:01:07 +0530 Subject: 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. --- src/backend/utils/adt/dbsize.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src') 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); -- cgit v1.2.3