[jira] [Commented] (HAWQ-405) Issue with handling pg_temp schema
[ https://issues.apache.org/jira/browse/HAWQ-405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15205883#comment-15205883 ] ASF GitHub Bot commented on HAWQ-405: - Github user asfgit closed the pull request at: https://github.com/apache/incubator-hawq/pull/338 > 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)
[jira] [Commented] (HAWQ-405) Issue with handling pg_temp schema
[ https://issues.apache.org/jira/browse/HAWQ-405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15143208#comment-15143208 ] ASF GitHub Bot commented on HAWQ-405: - Github user hornn commented on the pull request: https://github.com/apache/incubator-hawq/pull/338#issuecomment-182995496 +1 :) > 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)
[jira] [Commented] (HAWQ-405) Issue with handling pg_temp schema
[ https://issues.apache.org/jira/browse/HAWQ-405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15141989#comment-15141989 ] 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_r52548075 --- Diff: src/test/regress/expected/temp.out --- @@ -170,3 +170,19 @@ select * from whereami; -- you can invoke a temp function explicitly, though -- select pg_temp.whoami(); drop table public.whereami; +create temp table temptest (row integer, count integer); --- End diff -- I think it would be better to have the exact scenario that failed: ``` CREATE TABLE pg_temp.temptest ... SELECT avg(pg_temp.temptest.count) ... ``` Do you think we should cover all three cases (db.table.col, table.col, col)? > 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)
[jira] [Commented] (HAWQ-405) Issue with handling pg_temp schema
[ https://issues.apache.org/jira/browse/HAWQ-405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15141984#comment-15141984 ] ASF GitHub Bot commented on HAWQ-405: - Github user shivzone commented on the pull request: https://github.com/apache/incubator-hawq/pull/338#issuecomment-182641887 Added to installcheck-good > 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)
[jira] [Commented] (HAWQ-405) Issue with handling pg_temp schema
[ https://issues.apache.org/jira/browse/HAWQ-405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15141880#comment-15141880 ] ASF GitHub Bot commented on HAWQ-405: - Github user sansanichfb commented on the pull request: https://github.com/apache/incubator-hawq/pull/338#issuecomment-182618898 +1 > 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)
[jira] [Commented] (HAWQ-405) Issue with handling pg_temp schema
[ https://issues.apache.org/jira/browse/HAWQ-405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15141806#comment-15141806 ] ASF GitHub Bot commented on HAWQ-405: - Github user hornn commented on the pull request: https://github.com/apache/incubator-hawq/pull/338#issuecomment-182603281 I think it would be good to add the two cases that failed to installcheck-good. I checked, and there is already a temp test suite (src/test/regress/expected/temp.out, src/test/regress/sql/temp.sql) that can be a good place for them. > 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)
[jira] [Commented] (HAWQ-405) Issue with handling pg_temp schema
[ https://issues.apache.org/jira/browse/HAWQ-405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15141803#comment-15141803 ] 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_r52534496 --- 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 -- It should not be part of this commit though. > 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)
[jira] [Commented] (HAWQ-405) Issue with handling pg_temp schema
[ https://issues.apache.org/jira/browse/HAWQ-405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15141791#comment-15141791 ] ASF GitHub Bot commented on HAWQ-405: - Github user GodenYao commented on a diff in the pull request: https://github.com/apache/incubator-hawq/pull/338#discussion_r52534179 --- 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 -- I am thinking we may be able to remove the entire if(gp_upgrade_mode), as there's no upgrade path from previous Pivotal commercial 1.3.x HAWQ to 2.0 (only way is to do data reloading). So this logic probably is no longer needed. > 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)
[jira] [Commented] (HAWQ-405) Issue with handling pg_temp schema
[ 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)
[jira] [Commented] (HAWQ-405) Issue with handling pg_temp schema
[ https://issues.apache.org/jira/browse/HAWQ-405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15141765#comment-15141765 ] 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_r52531944 --- 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) +{ // This code is only need at hawq2.0 upgrade, in this case the old pg_namespace doesn't // have column nspdboid, so we report error in else clause -if(ObjectIdGetDatum(dboid)==NSPDBOID_CURRENT){ +if(ObjectIdGetDatum(dboid)==NSPDBOID_CURRENT) +{ return caql_getoid( NULL, cql("SELECT oid FROM pg_namespace " " WHERE nspname = :1", CStringGetDatum((char *) nspname))); -}else{ -elog(ERROR, "Upgrade cann't process the namespace: %s in dbid: %i", nspname, dboid); } +else + elog(ERROR, "Upgrade cann't process the namespace: %s in dbid: %i", nspname, dboid); --- End diff -- typo cannot > 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)
[jira] [Commented] (HAWQ-405) Issue with handling pg_temp schema
[ https://issues.apache.org/jira/browse/HAWQ-405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15141734#comment-15141734 ] ASF GitHub Bot commented on HAWQ-405: - GitHub user shivzone opened a pull request: https://github.com/apache/incubator-hawq/pull/338 HAWQ-405. Fix for handling of pg_temp schema You can merge this pull request into a Git repository by running: $ git pull https://github.com/apache/incubator-hawq HAWQ-405 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/incubator-hawq/pull/338.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #338 commit d431585ecd451549419081316eab7308249e4284 Author: Shivram Mani Date: 2016-02-10T21:43:04Z HAWQ-405. Fix for handling of pg_temp schema > 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)