[ https://issues.apache.org/jira/browse/HAWQ-405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15141769#comment-15141769 ]
ASF GitHub Bot commented on HAWQ-405: ------------------------------------- Github user hornn commented on a diff in the pull request: https://github.com/apache/incubator-hawq/pull/338#discussion_r52532011 --- Diff: src/backend/catalog/namespace.c --- @@ -1495,18 +1495,34 @@ LookupInternalNamespaceId(const char *nspname) Oid LookupNamespaceId(const char *nspname, Oid dboid) { - if(gp_upgrade_mode){ + + /* check for pg_temp alias */ + if (NSPDBOID_CURRENT == dboid && strcmp(nspname, "pg_temp") == 0) + { + if (TempNamespaceValid(true)) + return myTempNamespace; + /* + * Since this is used only for looking up existing objects, there + * is no point in trying to initialize the temp namespace here; + * and doing so might create problems for some callers. + * Just fall through and give the "does not exist" error. + */ + } + + if(gp_upgrade_mode) --- End diff -- indentation looks off > Issue with handling pg_temp schema > ---------------------------------- > > Key: HAWQ-405 > URL: https://issues.apache.org/jira/browse/HAWQ-405 > Project: Apache HAWQ > Issue Type: Bug > Components: Hcatalog, PXF > Affects Versions: 2.0.0-beta-incubating > Reporter: Shivram Mani > Assignee: Shivram Mani > Fix For: 2.0.0 > > > We aren't handling the temp namespace the right way when LookupNamespaceId is > invoked. > This change was done as part of handling hcatalog where we specifically > handle the pg_temp schema. > Steps to reproduce error > Reproduction 1: invalid reference to FROM-clause entry for table > {code} > create table pg_temp.test(row integer, count integer); > insert into pg_temp.test values (1, 10), (2, 20), (3, 30); > select avg(pg_temp.test.count) from pg_temp.test; > ERROR: invalid reference to FROM-clause entry for table "test" > LINE 1: select avg(pg_temp.test.count) from pg_temp.test; > ^ > {code} > Reproduction 2: missing FROM-clause entry for table > {code} > select case when pg_temp.test.count = 30 then 30 when pg_temp.test.count = 20 > then 20 else 10 end; > ERROR: missing FROM-clause entry for table "test" > LINE 1: select case when pg_temp.test.count = 30 then 30 when pg_tem... > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)