hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject [1/3] incubator-hawq git commit: HAWQ-1131. Fix error message difference between Orca and Planner
Date Wed, 02 Nov 2016 09:43:12 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/master 7363ea75c -> fed12f1a5


HAWQ-1131. Fix error message difference between Orca and Planner

- In ORCA, due to the way exception handled previously we do warning first
and then later print error referring that message. In this commit, we
enhanced the exception handling so we just print a single error message.
- Removed 'PQO unable to generate a plan' or 'Aborting PQO plan
generation' message and make the error message as close as the planner.
- Updated error message with filename and line number from where the exception
is raised.
- Updated regression test expected output files

Patches are ported the following commits from GPDB:
https://github.com/greenplum-db/gpdb/commit/4eb5db7a6bc8ac3faeca761193dc37e2c70e1ea3
https://github.com/greenplum-db/gpdb/commit/d41ebde141104dd3db6fa29ac46b4096ee7d4825

Author: Karthikeyan Jambu Rajaraman <karthi.jrk@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/56b44f85
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/56b44f85
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/56b44f85

Branch: refs/heads/master
Commit: 56b44f8595b4ba1ac9c49b775d5110e9be1275b2
Parents: 7363ea7
Author: Haisheng Yuan and Karthikeyan Jambu Rajaraman <karthi.jrk@gmail.com>
Authored: Wed Nov 2 13:49:41 2016 +0800
Committer: Wen Lin <wlin@pivotal.io>
Committed: Wed Nov 2 17:41:19 2016 +0800

----------------------------------------------------------------------
 depends/thirdparty/gporca.commit                |   2 +-
 depends/thirdparty/gpos.commit                  |   2 +-
 src/backend/gpopt/CGPOptimizer.cpp              |  38 +-
 src/backend/gpopt/gpdbwrappers.cpp              |   2 -
 src/backend/gpopt/utils/COptTasks.cpp           |  79 +-
 src/backend/gpopt/utils/funcs.cpp               |  18 -
 src/include/gpopt/utils/COptTasks.h             |  88 +--
 src/test/regress/expected/abstime_optimizer.out |   1 -
 .../regress/expected/horology_optimizer.out     |   1 -
 .../regress/expected/namespace_optimizer.out    | 142 ----
 .../regress/expected/privileges_optimizer.out   | 733 -------------------
 src/test/regress/expected/role_optimizer.out    | 107 ---
 .../regress/output/constraints_optimizer.source |   4 +-
 13 files changed, 127 insertions(+), 1090 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/56b44f85/depends/thirdparty/gporca.commit
----------------------------------------------------------------------
diff --git a/depends/thirdparty/gporca.commit b/depends/thirdparty/gporca.commit
index d362229..fb98394 100644
--- a/depends/thirdparty/gporca.commit
+++ b/depends/thirdparty/gporca.commit
@@ -1 +1 @@
-https://github.com/greenplum-db/gporca.git master f55733c00a01b99b3a12cd029d50ea56a5d17c35
+https://github.com/greenplum-db/gporca.git master 10a4e6bc0682937120f4fbce9251b6ad7a6b0ba7

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/56b44f85/depends/thirdparty/gpos.commit
----------------------------------------------------------------------
diff --git a/depends/thirdparty/gpos.commit b/depends/thirdparty/gpos.commit
index 04c74ca..c4358f9 100644
--- a/depends/thirdparty/gpos.commit
+++ b/depends/thirdparty/gpos.commit
@@ -1 +1 @@
-https://github.com/greenplum-db/gpos.git master 7f1bd6eec40fcaaa032edeac88dd54660f2f0943
+https://github.com/greenplum-db/gpos.git master 9a6372d4bdfc548d05cd41e44f8948de157c5076

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/56b44f85/src/backend/gpopt/CGPOptimizer.cpp
----------------------------------------------------------------------
diff --git a/src/backend/gpopt/CGPOptimizer.cpp b/src/backend/gpopt/CGPOptimizer.cpp
index bcace95..84d7002 100644
--- a/src/backend/gpopt/CGPOptimizer.cpp
+++ b/src/backend/gpopt/CGPOptimizer.cpp
@@ -39,6 +39,8 @@
 
 #include "naucrates/exception.h"
 
+extern MemoryContext MessageContext;
+
 //---------------------------------------------------------------------------
 //	@function:
 //		CGPOptimizer::TouchLibraryInitializers
@@ -71,23 +73,47 @@ CGPOptimizer::PplstmtOptimize
 	bool *pfUnexpectedFailure // output : set to true if optimizer unexpectedly failed to produce plan
 	)
 {
+	SOptContext octx;
+	PlannedStmt* plStmt = NULL;
 	GPOS_TRY
 	{
-		return COptTasks::PplstmtOptimize(pquery, pfUnexpectedFailure);
+		plStmt = COptTasks::PplstmtOptimize(pquery, &octx, pfUnexpectedFailure);
+		// clean up context
+		octx.Free(octx.epinQuery, octx.epinPlStmt);
 	}
 	GPOS_CATCH_EX(ex)
 	{
-		if (GPOS_MATCH_EX(ex, gpdxl::ExmaDXL, gpdxl::ExmiWarningAsError))
+		// clone the error message before context free.
+		CHAR* szErrorMsg = octx.CloneErrorMsg(MessageContext);
+		// clean up context
+		octx.Free(octx.epinQuery, octx.epinPlStmt);
+		if (GPOS_MATCH_EX(ex, gpdxl::ExmaDXL, gpdxl::ExmiOptimizerError) ||
+			NULL != szErrorMsg)
+		{
+			Assert(NULL != szErrorMsg);
+			errstart(ERROR, ex.SzFilename(), ex.UlLine(), NULL, TEXTDOMAIN);
+			errfinish(errcode(ERRCODE_INTERNAL_ERROR),
+					errmsg("%s", szErrorMsg));
+		}
+		else if (GPOS_MATCH_EX(ex, gpdxl::ExmaGPDB, gpdxl::ExmiGPDBError))
+		{
+			PG_RE_THROW();
+		}
+		else if (GPOS_MATCH_EX(ex, gpdxl::ExmaDXL, gpdxl::ExmiNoAvailableMemory))
 		{
-		  elog(ERROR, "PQO unable to generate plan, please see the above message for details.");
+			errstart(ERROR, ex.SzFilename(), ex.UlLine(), NULL, TEXTDOMAIN);
+			errfinish(errcode(ERRCODE_INTERNAL_ERROR),
+					errmsg("No available memory to allocate string buffer."));
 		}
-		if (GPOS_MATCH_EX(ex, gpdxl::ExmaGPDB, gpdxl::ExmiGPDBError))
+		else if (GPOS_MATCH_EX(ex, gpdxl::ExmaDXL, gpdxl::ExmiInvalidComparisonTypeCode))
 		{
-		  elog(ERROR, "GPDB exception. Aborting PQO plan generation.");
+			errstart(ERROR, ex.SzFilename(), ex.UlLine(), NULL, TEXTDOMAIN);
+			errfinish(errcode(ERRCODE_INTERNAL_ERROR),
+					errmsg("Invalid comparison type code. Valid values are Eq, NEq, LT, LEq, GT, GEq."));
 		}
 	}
 	GPOS_CATCH_END;
-	return NULL;
+	return plStmt;
 }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/56b44f85/src/backend/gpopt/gpdbwrappers.cpp
----------------------------------------------------------------------
diff --git a/src/backend/gpopt/gpdbwrappers.cpp b/src/backend/gpopt/gpdbwrappers.cpp
index 1d6a071..489d6b6 100644
--- a/src/backend/gpopt/gpdbwrappers.cpp
+++ b/src/backend/gpopt/gpdbwrappers.cpp
@@ -239,8 +239,6 @@
 		}	\
 		else \
 		{ \
-			EmitErrorReport(); \
-			FlushErrorState(); \
 			GPOS_RAISE(gpdxl::ExmaGPDB, gpdxl::ExmiGPDBError); \
 		} \
 	}	\

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/56b44f85/src/backend/gpopt/utils/COptTasks.cpp
----------------------------------------------------------------------
diff --git a/src/backend/gpopt/utils/COptTasks.cpp b/src/backend/gpopt/utils/COptTasks.cpp
index dcccfec..1adba9c 100644
--- a/src/backend/gpopt/utils/COptTasks.cpp
+++ b/src/backend/gpopt/utils/COptTasks.cpp
@@ -161,13 +161,13 @@ const ULONG rgulExpectedDXLErrors[] =
 
 //---------------------------------------------------------------------------
 //	@function:
-//		COptTasks::SOptContext::SOptContext
+//		SOptContext::SOptContext
 //
 //	@doc:
 //		Ctor
 //
 //---------------------------------------------------------------------------
-COptTasks::SOptContext::SOptContext()
+SOptContext::SOptContext()
 	:
 	m_szQueryDXL(NULL),
 	m_pquery(NULL),
@@ -181,7 +181,7 @@ COptTasks::SOptContext::SOptContext()
 
 //---------------------------------------------------------------------------
 //	@function:
-//		COptTasks::SOptContext::HandleError
+//		SOptContext::HandleError
 //
 //	@doc:
 //		If there is an error print as warning and throw GPOS_EXCEPTION to abort
@@ -189,31 +189,22 @@ COptTasks::SOptContext::SOptContext()
 //		a memory leak.
 //---------------------------------------------------------------------------
 void
-COptTasks::SOptContext::HandleError
+SOptContext::HandleError
 	(
 	BOOL *pfUnexpectedFailure
 	)
 {
-	BOOL bhasError = false;
-	if (NULL != m_szErrorMsg)
-	{
-		bhasError = true;
-		elog(WARNING, "%s", m_szErrorMsg);
-	}
 	*pfUnexpectedFailure = m_fUnexpectedFailure;
-
-	// clean up context
-	Free(epinQuery, epinPlStmt);
-	if (bhasError)
+	if (NULL != m_szErrorMsg)
 	{
-		GPOS_RAISE(gpdxl::ExmaDXL, gpdxl::ExmiWarningAsError);
+		GPOS_RAISE(gpdxl::ExmaDXL, gpdxl::ExmiOptimizerError);
 	}
 }
 
 
 //---------------------------------------------------------------------------
 //	@function:
-//		COptTasks::SOptContext::Free
+//		SOptContext::Free
 //
 //	@doc:
 //		Free all members except those pointed to by either epinInput or
@@ -221,10 +212,10 @@ COptTasks::SOptContext::HandleError
 //
 //---------------------------------------------------------------------------
 void
-COptTasks::SOptContext::Free
+SOptContext::Free
 	(
-	COptTasks::SOptContext::EPin epinInput,
-	COptTasks::SOptContext::EPin epinOutput
+	SOptContext::EPin epinInput,
+	SOptContext::EPin epinOutput
 	)
 {
 	if (NULL != m_szQueryDXL && epinQueryDXL != epinInput && epinQueryDXL != epinOutput)
@@ -253,17 +244,40 @@ COptTasks::SOptContext::Free
 	}
 }
 
+//---------------------------------------------------------------------------
+//	@function:
+//		SOptContext::CloneErrorMsg
+//
+//	@doc:
+//		Clone m_szErrorMsg to given memory context. Return NULL if there is no
+//		error message.
+//
+//---------------------------------------------------------------------------
+CHAR*
+SOptContext::CloneErrorMsg
+	(
+	MemoryContext context
+	)
+{
+	if (NULL == context ||
+		NULL == m_szErrorMsg)
+	{
+		return NULL;
+	}
+	return gpdb::SzMemoryContextStrdup(context, m_szErrorMsg);
+}
+
 
 //---------------------------------------------------------------------------
 //	@function:
-//		COptTasks::SOptContext::PoptctxtConvert
+//		SOptContext::PoptctxtConvert
 //
 //	@doc:
 //		Casting function
 //
 //---------------------------------------------------------------------------
-COptTasks::SOptContext *
-COptTasks::SOptContext::PoptctxtConvert
+SOptContext *
+SOptContext::PoptctxtConvert
 	(
 	void *pv
 	)
@@ -390,8 +404,7 @@ COptTasks::SzAllocate
 	}
 	GPOS_CATCH_EX(ex)
 	{
-		elog(WARNING, "no available memory to allocate string buffer");
-		GPOS_RAISE(gpdxl::ExmaDXL, gpdxl::ExmiWarningAsError);
+		GPOS_RAISE(gpdxl::ExmaDXL, gpdxl::ExmiNoAvailableMemory);
 	}
 	GPOS_CATCH_END;
 
@@ -1655,26 +1668,27 @@ PlannedStmt *
 COptTasks::PplstmtOptimize
 	(
 	Query *pquery,
+	SOptContext *octx,
 	BOOL *pfUnexpectedFailure // output : set to true if optimizer unexpectedly failed to produce plan
 	)
 {
 	Assert(pquery);
+	Assert(octx);
 
-	SOptContext octx;
-	octx.m_pquery = pquery;
-	octx.m_fGeneratePlStmt= true;
+	octx->m_pquery = pquery;
+	octx->m_fGeneratePlStmt= true;
 	GPOS_TRY
 	{
-		Execute(&PvOptimizeTask, &octx);
+		Execute(&PvOptimizeTask, octx);
 	}
 	GPOS_CATCH_EX(ex)
 	{
-		octx.HandleError(pfUnexpectedFailure);
+		*pfUnexpectedFailure = octx->m_fUnexpectedFailure;
 		GPOS_RETHROW(ex);
 	}
 	GPOS_CATCH_END;
-	octx.HandleError(pfUnexpectedFailure);
-	return octx.m_pplstmt;
+	octx->HandleError(pfUnexpectedFailure);
+	return octx->m_pplstmt;
 }
 
 
@@ -1886,8 +1900,7 @@ COptTasks::UlCmpt
 		}
 	}
 
-	elog(WARNING, "Invalid comparison type code. Valid values are Eq, NEq, LT, LEq, GT, GEq");
-	GPOS_RAISE(gpdxl::ExmaDXL, gpdxl::ExmiWarningAsError);
+	GPOS_RAISE(gpdxl::ExmaDXL, gpdxl::ExmiInvalidComparisonTypeCode);
 	return CmptOther;
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/56b44f85/src/backend/gpopt/utils/funcs.cpp
----------------------------------------------------------------------
diff --git a/src/backend/gpopt/utils/funcs.cpp b/src/backend/gpopt/utils/funcs.cpp
index 9a901d0..d39d65c 100644
--- a/src/backend/gpopt/utils/funcs.cpp
+++ b/src/backend/gpopt/utils/funcs.cpp
@@ -1165,24 +1165,6 @@ Optimize(PG_FUNCTION_ARGS)
 }
 }
 
-//---------------------------------------------------------------------------
-//	@function:
-//		orca
-//
-//	@doc:
-//		API for planner replacement
-//
-//---------------------------------------------------------------------------
-
-extern "C" {
-PlannedStmt *orca(Query *pquery)
-{
-	BOOL fUnexpectedFailure = false;
-
-	return COptTasks::PplstmtOptimize(pquery, &fUnexpectedFailure);
-}
-}
-
 
 extern "C" {
 char *read_file(const char *szFilename)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/56b44f85/src/include/gpopt/utils/COptTasks.h
----------------------------------------------------------------------
diff --git a/src/include/gpopt/utils/COptTasks.h b/src/include/gpopt/utils/COptTasks.h
index 2f1b510..a2b0fda 100644
--- a/src/include/gpopt/utils/COptTasks.h
+++ b/src/include/gpopt/utils/COptTasks.h
@@ -67,66 +67,67 @@ using namespace gpos;
 using namespace gpdxl;
 using namespace gpopt;
 
-class COptTasks
+// context of optimizer input and output objects
+struct SOptContext
 {
 
-	private:
+	// mark which pointer member should NOT be released
+	// when calling Free() function
+	enum EPin
+	{
+		epinQueryDXL, // keep m_szQueryDXL
+		epinQuery, 	 // keep m_pquery
+		epinPlanDXL, // keep m_szPlanDXL
+		epinPlStmt, // keep m_pplstmt
+		epinErrorMsg // keep m_szErrorMsg
+	};
 
-		// context of optimizer input and output objects
-		struct SOptContext
-		{
+	// query object serialized to DXL
+	CHAR *m_szQueryDXL;
 
-			// mark which pointer member should NOT be released
-			// when calling Free() function
-			enum EPin
-			{
-				epinQueryDXL, // keep m_szQueryDXL
-				epinQuery, 	 // keep m_pquery
-				epinPlanDXL, // keep m_szPlanDXL
-				epinPlStmt, // keep m_pplstmt
-				epinErrorMsg // keep m_szErrorMsg
-			};
+	// query object
+	Query *m_pquery;
 
-			// query object serialized to DXL
-			CHAR *m_szQueryDXL;
+	// plan object serialized to DXL
+	CHAR *m_szPlanDXL;
 
-			// query object
-			Query *m_pquery;
+	// plan object
+	PlannedStmt *m_pplstmt;
 
-			// plan object serialized to DXL
-			CHAR *m_szPlanDXL;
+	// is generating a plan object required ?
+	BOOL m_fGeneratePlStmt;
 
-			// plan object
-			PlannedStmt *m_pplstmt;
+	// is serializing a plan to DXL required ?
+	BOOL m_fSerializePlanDXL;
 
-			// is generating a plan object required ?
-			BOOL m_fGeneratePlStmt;
+	// did the optimizer fail unexpectedly?
+	BOOL m_fUnexpectedFailure;
 
-			// is serializing a plan to DXL required ?
-			BOOL m_fSerializePlanDXL;
+	// buffer for optimizer error messages
+	CHAR *m_szErrorMsg;
 
-			// did the optimizer fail unexpectedly?
-			BOOL m_fUnexpectedFailure;
+	// ctor
+	SOptContext();
 
-			// buffer for optimizer error messages
-			CHAR *m_szErrorMsg;
-
-			// ctor
-			SOptContext();
+	// If there is an error print as warning and throw exception to abort
+	// plan generation
+	void HandleError(BOOL *pfUnexpectedFailure);
 
-			// If there is an error print as warning and throw exception to abort
-			// plan generation
-			void HandleError(BOOL *pfUnexpectedFailure);
+	// free all members except input and output pointers
+	void Free(EPin epinInput, EPin epinOutput);
 
-			// free all members except input and output pointers
-			void Free(EPin epinInput, EPin epinOutput);
+	// Clone the error message in given context.
+	CHAR* CloneErrorMsg(MemoryContext context);
 
-			// casting function
-			static
-			SOptContext *PoptctxtConvert(void *pv);
+	// casting function
+	static
+	SOptContext *PoptctxtConvert(void *pv);
 
-		}; // struct SOptContext
+}; // struct SOptContext
 
+class COptTasks
+{
+	private:
 
 		// context of relcache input and output objects
 		struct SContextRelcacheToDXL
@@ -278,6 +279,7 @@ class COptTasks
 		PlannedStmt *PplstmtOptimize
 			(
 			Query *pquery,
+			SOptContext* octx,
 			BOOL *pfUnexpectedFailure // output : set to true if optimizer unexpectedly failed to produce plan
 			);
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/56b44f85/src/test/regress/expected/abstime_optimizer.out
----------------------------------------------------------------------
diff --git a/src/test/regress/expected/abstime_optimizer.out b/src/test/regress/expected/abstime_optimizer.out
index 81b6fbd..8f49274 100644
--- a/src/test/regress/expected/abstime_optimizer.out
+++ b/src/test/regress/expected/abstime_optimizer.out
@@ -45,7 +45,6 @@ LINE 1: INSERT INTO ABSTIME_TBL (f1) VALUES ('bad date format');
                                              ^
 INSERT INTO ABSTIME_TBL (f1) VALUES ('Jun 10, 1843');
 ERROR:  cannot convert abstime "invalid" to timestamp
-ERROR:  GPDB exception. Aborting GPORCA plan generation. (CGPOptimizer.cpp:66)
 -- test abstime operators
 SELECT '' AS eight, * FROM ABSTIME_TBL ORDER BY 2;
  eight |              f1              

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/56b44f85/src/test/regress/expected/horology_optimizer.out
----------------------------------------------------------------------
diff --git a/src/test/regress/expected/horology_optimizer.out b/src/test/regress/expected/horology_optimizer.out
index 8b434cd..23cae8e 100755
--- a/src/test/regress/expected/horology_optimizer.out
+++ b/src/test/regress/expected/horology_optimizer.out
@@ -14,7 +14,6 @@ INSERT INTO ABSTIME_HOROLOGY_TBL (f1) VALUES ('Jan 14, 1973 03:14:21'),
 -- orca will fail for this
 INSERT INTO ABSTIME_HOROLOGY_TBL (f1) VALUES('Jun 10, 1843');
 ERROR:  cannot convert abstime "invalid" to timestamp
-ERROR:  GPDB exception. Aborting GPORCA plan generation. (CGPOptimizer.cpp:66)
 CREATE TABLE INTERVAL_HOROLOGY_TBL (f1 interval);
 NOTICE:  Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'f1' as the Greenplum Database data distribution key for this table.
 HINT:  The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/56b44f85/src/test/regress/expected/namespace_optimizer.out
----------------------------------------------------------------------
diff --git a/src/test/regress/expected/namespace_optimizer.out b/src/test/regress/expected/namespace_optimizer.out
deleted file mode 100644
index 88a4411..0000000
--- a/src/test/regress/expected/namespace_optimizer.out
+++ /dev/null
@@ -1,142 +0,0 @@
---
--- Regression tests for schemas (namespaces)
---
-CREATE SCHEMA test_schema_1
-       CREATE INDEX abc_a_idx ON abc (a)
-       CREATE VIEW abc_view AS
-              SELECT a+1 AS a, b+1 AS b FROM abc
-       CREATE TABLE abc (
-              a serial,
-              b int UNIQUE
-       ) DISTRIBUTED BY (b);
-NOTICE:  CREATE TABLE will create implicit sequence "abc_a_seq" for serial column "abc.a"
-NOTICE:  CREATE TABLE / UNIQUE will create implicit index "abc_b_key" for table "abc"
--- verify that the objects were created
-SELECT COUNT(*) FROM pg_class WHERE relnamespace =
-    (SELECT oid FROM pg_namespace WHERE nspname = 'test_schema_1');
- count 
--------
-     5
-(1 row)
-
-INSERT INTO test_schema_1.abc DEFAULT VALUES;
-INSERT INTO test_schema_1.abc DEFAULT VALUES;
-INSERT INTO test_schema_1.abc DEFAULT VALUES;
-SELECT * FROM test_schema_1.abc;
- a | b 
----+---
- 1 |  
- 2 |  
- 3 |  
-(3 rows)
-
-SELECT * FROM test_schema_1.abc_view;
- a | b 
----+---
- 2 |  
- 3 |  
- 4 |  
-(3 rows)
-
--- Test GRANT/REVOKE 
-CREATE SCHEMA test_schema_2;
-CREATE TABLE test_schema_2.abc as select * from test_schema_1.abc DISTRIBUTED BY (a);
-create role tmp_test_schema_role RESOURCE QUEUE pg_default;
-GRANT ALL ON SCHEMA test_schema_1 to tmp_test_schema_role;
-SET SESSION AUTHORIZATION tmp_test_schema_role;
-CREATE TABLE test_schema_1.grant_test(a int) DISTRIBUTED BY (a);
-DROP TABLE test_schema_1.grant_test;
-CREATE TABLE test_schema_2.grant_test(a int) DISTRIBUTED BY (a); -- no permissions on schema
-ERROR:  permission denied for schema test_schema_2
-SELECT * FROM test_schema_1.abc; -- no permissions on table
-ERROR:  permission denied for relation abc
-ERROR:  GPDB exception. Aborting GPORCA plan generation. (CGPOptimizer.cpp:66)
-SELECT * FROM test_schema_2.abc; -- no permissions on schema
-ERROR:  permission denied for schema test_schema_2
-LINE 1: SELECT * FROM test_schema_2.abc;
-                      ^
-ALTER SCHEMA test_schema_1 RENAME to myschema;  -- not the schema owner
-ERROR:  must be owner of schema test_schema_1
-RESET SESSION AUTHORIZATION;
-DROP TABLE test_schema_2.abc;
-DROP SCHEMA test_schema_2;
--- ALTER SCHEMA .. OWNER TO
-ALTER SCHEMA pg_toast OWNER to tmp_test_schema_role; -- system schema
-ERROR:  permission denied to ALTER SCHEMA "pg_toast"
-DETAIL:  Schema pg_toast is reserved for system use.
-alter schema test_schema_1 owner to tmp_test_schema_role;
-select rolname from pg_authid a, pg_namespace n where a.oid = n.nspowner
-  and nspname = 'test_schema_1';
-       rolname        
-----------------------
- tmp_test_schema_role
-(1 row)
-
--- test CREATE SCHEMA/ALTER SCHEMA for reserved names
-CREATE SCHEMA pg_schema; -- reserved name
-ERROR:  unacceptable schema name "pg_schema"
-DETAIL:  The prefix "pg_" is reserved for system schemas.
-CREATE SCHEMA gp_schema; -- reserved name
-ERROR:  unacceptable schema name "gp_schema"
-DETAIL:  The prefix "gp_" is reserved for system schemas.
-ALTER SCHEMA test_schema_1 RENAME to pg_schema; -- reseved name
-ERROR:  unacceptable schema name "pg_schema"
-DETAIL:  The prefix "pg_" is reserved for system schemas.
-ALTER SCHEMA test_schema_1 RENAME to gp_schema; -- reserved name
-ERROR:  unacceptable schema name "gp_schema"
-DETAIL:  The prefix "gp_" is reserved for system schemas.
-ALTER SCHEMA pg_toast RENAME to bread;  -- system schema
-ERROR:  permission denied to ALTER SCHEMA "pg_toast"
-DETAIL:  Schema pg_toast is reserved for system use.
--- RENAME to a valid new name
-ALTER SCHEMA test_schema_1 RENAME to test_schema_2;
--- Check that ALTER statements dispatched correctly
-select * 
-FROM gp_dist_random('pg_namespace') n1 
-  full outer join pg_namespace n2 on (n1.oid = n2.oid)
-WHERE n1.nspname != n2.nspname or n1.nspowner != n2.nspowner or
-      n1.nspname is null or n2.nspname is null;
- nspname | nspowner | nspacl | nspname | nspowner | nspacl 
----------+----------+--------+---------+----------+--------
-(0 rows)
-
--- DROP SCHEMA
-DROP SCHEMA pg_toast;       -- system schema
-ERROR:  cannot drop schema pg_toast because it is required by the database system
-DROP SCHEMA test_schema_1;  -- does not exist
-ERROR:  schema "test_schema_1" does not exist
-DROP SCHEMA test_schema_2;  -- contains objects
-NOTICE:  view test_schema_2.abc_view depends on schema test_schema_2
-NOTICE:  rule _RETURN on view test_schema_2.abc_view depends on view test_schema_2.abc_view
-NOTICE:  table test_schema_2.abc depends on schema test_schema_2
-NOTICE:  default for table test_schema_2.abc column a depends on sequence test_schema_2.abc_a_seq
-ERROR:  cannot drop schema test_schema_2 because other objects depend on it
-HINT:  Use DROP ... CASCADE to drop the dependent objects too.
-DROP SCHEMA test_schema_2 CASCADE;
-NOTICE:  drop cascades to view test_schema_2.abc_view
-NOTICE:  drop cascades to rule _RETURN on view test_schema_2.abc_view
-NOTICE:  drop cascades to table test_schema_2.abc
-NOTICE:  drop cascades to default for table test_schema_2.abc column a
-DROP ROLE tmp_test_schema_role;
--- verify that the objects were dropped
-SELECT nspname, relname
-FROM pg_class c JOIN pg_namespace n ON (c.relnamespace = n.oid)
-WHERE nspname ~ 'test_schema_[12]';
- nspname | relname 
----------+---------
-(0 rows)
-
-SELECT nspname 
-FROM pg_namespace n
-WHERE nspname ~ 'test_schema_[12]';
- nspname 
----------
-(0 rows)
-
-SELECT rolname
-FROM pg_authid a
-WHERE rolname ~ 'tmp_test_schema_role'
- rolname 
----------
-(0 rows)
-

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/56b44f85/src/test/regress/expected/privileges_optimizer.out
----------------------------------------------------------------------
diff --git a/src/test/regress/expected/privileges_optimizer.out b/src/test/regress/expected/privileges_optimizer.out
deleted file mode 100755
index a743ac4..0000000
--- a/src/test/regress/expected/privileges_optimizer.out
+++ /dev/null
@@ -1,733 +0,0 @@
---
--- Test access privileges
---
-set optimizer=off;
--- Clean up in case a prior regression run failed
--- Suppress NOTICE messages when users/groups don't exist
-SET client_min_messages TO 'error';
-DROP ROLE IF EXISTS regressgroup1;
-DROP ROLE IF EXISTS regressgroup2;
-DROP ROLE IF EXISTS regressuser1;
-DROP ROLE IF EXISTS regressuser2;
-DROP ROLE IF EXISTS regressuser3;
-DROP ROLE IF EXISTS regressuser4;
-DROP ROLE IF EXISTS regressuser5;
-RESET client_min_messages;
--- test proper begins here
-CREATE USER regressuser1;
-CREATE USER regressuser2;
-CREATE USER regressuser3;
-CREATE USER regressuser4;
-CREATE USER regressuser5;
-CREATE USER regressuser5;	-- duplicate
-ERROR:  role "regressuser5" already exists
-CREATE GROUP regressgroup1;
-CREATE GROUP regressgroup2 WITH USER regressuser1, regressuser2;
-ALTER GROUP regressgroup1 ADD USER regressuser4;
-ALTER GROUP regressgroup2 ADD USER regressuser2;	-- duplicate
-NOTICE:  role "regressuser2" is already a member of role "regressgroup2"
-ALTER GROUP regressgroup2 DROP USER regressuser2;
-GRANT regressgroup2 TO regressuser4 WITH ADMIN OPTION;
--- test owner privileges
-SET SESSION AUTHORIZATION regressuser1;
-SELECT session_user, current_user;
- session_user | current_user 
---------------+--------------
- regressuser1 | regressuser1
-(1 row)
-
-CREATE TABLE atest1 ( a int, b text );
-NOTICE:  Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table.
-HINT:  The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
-SELECT * FROM atest1;
- a | b 
----+---
-(0 rows)
-
-INSERT INTO atest1 VALUES (1, 'one');
-DELETE FROM atest1;
-UPDATE atest1 SET b = 'blech' WHERE a = 213;
-TRUNCATE atest1;
-LOCK atest1 IN ACCESS EXCLUSIVE MODE;
-REVOKE ALL ON atest1 FROM PUBLIC;
-NOTICE:  no privileges could be revoked from role PUBLIC on object atest1
-SELECT * FROM atest1;
- a | b 
----+---
-(0 rows)
-
-GRANT ALL ON atest1 TO regressuser2;
-GRANT SELECT ON atest1 TO regressuser3, regressuser4;
-SELECT * FROM atest1;
- a | b 
----+---
-(0 rows)
-
-CREATE TABLE atest2 (col1 varchar(10), col2 boolean);
-NOTICE:  Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'col1' as the Greenplum Database data distribution key for this table.
-HINT:  The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
-GRANT SELECT ON atest2 TO regressuser2;
-GRANT UPDATE ON atest2 TO regressuser3;
-GRANT INSERT ON atest2 TO regressuser4;
-GRANT TRUNCATE ON atest2 TO regressuser5;
-SET SESSION AUTHORIZATION regressuser2;
-SELECT session_user, current_user;
- session_user | current_user 
---------------+--------------
- regressuser2 | regressuser2
-(1 row)
-
--- try various combinations of queries on atest1 and atest2
-SELECT * FROM atest1; -- ok
- a | b 
----+---
-(0 rows)
-
-SELECT * FROM atest2; -- ok
- col1 | col2 
-------+------
-(0 rows)
-
-INSERT INTO atest1 VALUES (2, 'two'); -- ok
-INSERT INTO atest2 VALUES ('foo', true); -- fail
-ERROR:  permission denied for relation atest2
-INSERT INTO atest1 SELECT 1, b FROM atest1; -- ok
-UPDATE atest1 SET b = 'twotwo' WHERE a = 2; -- ok
-UPDATE atest2 SET col2 = NOT col2; -- fail
-ERROR:  permission denied for relation atest2
-SELECT * FROM atest1 FOR UPDATE; -- ok
- a |   b    
----+--------
- 1 | two
- 2 | twotwo
-(2 rows)
-
-SELECT * FROM atest2 FOR UPDATE; -- fail
-ERROR:  permission denied for relation atest2
-DELETE FROM atest2; -- fail
-ERROR:  permission denied for relation atest2
-TRUNCATE atest2; -- fail
-ERROR:  permission denied for relation atest2
-LOCK atest2 IN ACCESS EXCLUSIVE MODE; -- fail
-ERROR:  permission denied for relation atest2
-COPY atest2 FROM stdin; -- fail
-ERROR:  permission denied for relation atest2
-GRANT ALL ON atest1 TO PUBLIC; -- fail
-WARNING:  no privileges were granted for "atest1"
--- checks in subquery, both ok
-SELECT * FROM atest1 WHERE ( b IN ( SELECT col1 FROM atest2 ) );
- a | b 
----+---
-(0 rows)
-
-SELECT * FROM atest2 WHERE ( col1 IN ( SELECT b FROM atest1 ) );
- col1 | col2 
-------+------
-(0 rows)
-
-SET SESSION AUTHORIZATION regressuser3;
-SELECT session_user, current_user;
- session_user | current_user 
---------------+--------------
- regressuser3 | regressuser3
-(1 row)
-
-SELECT * FROM atest1; -- ok
- a |   b    
----+--------
- 1 | two
- 2 | twotwo
-(2 rows)
-
-SELECT * FROM atest2; -- fail
-ERROR:  permission denied for relation atest2
-INSERT INTO atest1 VALUES (2, 'two'); -- fail
-ERROR:  permission denied for relation atest1
-INSERT INTO atest2 VALUES ('foo', true); -- fail
-ERROR:  permission denied for relation atest2
-INSERT INTO atest1 SELECT 1, b FROM atest1; -- fail
-ERROR:  permission denied for relation atest1
-UPDATE atest1 SET b = 'twotwo' WHERE a = 2; -- fail
-ERROR:  permission denied for relation atest1
-UPDATE atest2 SET col2 = NULL; -- ok
-UPDATE atest2 SET col2 = NOT col2; -- fails; requires SELECT on atest2
-ERROR:  permission denied for relation atest2
-UPDATE atest2 SET col2 = true FROM atest1 WHERE atest1.a = 5; -- ok
-SELECT * FROM atest1 FOR UPDATE; -- fail
-ERROR:  permission denied for relation atest1
-SELECT * FROM atest2 FOR UPDATE; -- fail
-ERROR:  permission denied for relation atest2
-DELETE FROM atest2; -- fail
-ERROR:  permission denied for relation atest2
-TRUNCATE atest2; -- fail
-ERROR:  permission denied for relation atest2
-LOCK atest2 IN ACCESS EXCLUSIVE MODE; -- ok
-COPY atest2 FROM stdin; -- fail
-ERROR:  permission denied for relation atest2
--- checks in subquery, both fail
-SELECT * FROM atest1 WHERE ( b IN ( SELECT col1 FROM atest2 ) );
-ERROR:  permission denied for relation atest2
-SELECT * FROM atest2 WHERE ( col1 IN ( SELECT b FROM atest1 ) );
-ERROR:  permission denied for relation atest2
-SET SESSION AUTHORIZATION regressuser4;
-COPY atest2 FROM stdin; -- ok
-SELECT * FROM atest1; -- ok
- a |   b    
----+--------
- 1 | two
- 2 | twotwo
-(2 rows)
-
--- groups
-SET SESSION AUTHORIZATION regressuser3;
-CREATE TABLE atest3 (one int, two int, three int);
-NOTICE:  Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'one' as the Greenplum Database data distribution key for this table.
-HINT:  The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
-GRANT DELETE ON atest3 TO GROUP regressgroup2;
-SET SESSION AUTHORIZATION regressuser1;
-SELECT * FROM atest3; -- fail
-ERROR:  permission denied for relation atest3
-DELETE FROM atest3; -- ok
--- views
-SET SESSION AUTHORIZATION regressuser3;
-CREATE VIEW atestv1 AS SELECT * FROM atest1; -- ok
-/* The next *should* fail, but it's not implemented that way yet. */
-CREATE VIEW atestv2 AS SELECT * FROM atest2;
-CREATE VIEW atestv3 AS SELECT * FROM atest3; -- ok
-SELECT * FROM atestv1; -- ok
- a |   b    
----+--------
- 1 | two
- 2 | twotwo
-(2 rows)
-
-SELECT * FROM atestv2; -- fail
-ERROR:  permission denied for relation atest2
-GRANT SELECT ON atestv1, atestv3 TO regressuser4;
-GRANT SELECT ON atestv2 TO regressuser2;
-SET SESSION AUTHORIZATION regressuser4;
-SELECT * FROM atestv1; -- ok
- a |   b    
----+--------
- 1 | two
- 2 | twotwo
-(2 rows)
-
-SELECT * FROM atestv2; -- fail
-ERROR:  permission denied for relation atestv2
-SELECT * FROM atestv3; -- ok
- one | two | three 
------+-----+-------
-(0 rows)
-
-CREATE VIEW atestv4 AS SELECT * FROM atestv3; -- nested view
-SELECT * FROM atestv4; -- ok
- one | two | three 
------+-----+-------
-(0 rows)
-
-GRANT SELECT ON atestv4 TO regressuser2;
-SET SESSION AUTHORIZATION regressuser2;
--- Two complex cases:
-SELECT * FROM atestv3; -- fail
-ERROR:  permission denied for relation atestv3
-SELECT * FROM atestv4; -- ok (even though regressuser2 cannot access underlying atestv3)
- one | two | three 
------+-----+-------
-(0 rows)
-
-SELECT * FROM atest2; -- ok
- col1 | col2 
-------+------
- bar  | t
-(1 row)
-
-SELECT * FROM atestv2; -- fail (even though regressuser2 can access underlying atest2)
-ERROR:  permission denied for relation atest2
--- privileges on functions, languages
--- switch to superuser
-\c -
-REVOKE ALL PRIVILEGES ON LANGUAGE sql FROM PUBLIC;
-GRANT USAGE ON LANGUAGE sql TO regressuser1; -- ok
-GRANT USAGE ON LANGUAGE c TO PUBLIC; -- fail
-ERROR:  language "c" is not trusted
-HINT:  Only superusers can use untrusted languages.
-SET SESSION AUTHORIZATION regressuser1;
-GRANT USAGE ON LANGUAGE sql TO regressuser2; -- fail
-WARNING:  no privileges were granted for "sql"
-CREATE FUNCTION testfunc1(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sql CONTAINS SQL;
-CREATE FUNCTION testfunc2(int) RETURNS int AS 'select 3 * $1;' LANGUAGE sql CONTAINS SQL;
-REVOKE ALL ON FUNCTION testfunc1(int), testfunc2(int) FROM PUBLIC;
-GRANT EXECUTE ON FUNCTION testfunc1(int), testfunc2(int) TO regressuser2;
-GRANT USAGE ON FUNCTION testfunc1(int) TO regressuser3; -- semantic error
-ERROR:  invalid privilege type USAGE for function
-GRANT ALL PRIVILEGES ON FUNCTION testfunc1(int) TO regressuser4;
-GRANT ALL PRIVILEGES ON FUNCTION testfunc_nosuch(int) TO regressuser4;
-ERROR:  function testfunc_nosuch(integer) does not exist
-CREATE FUNCTION testfunc4(boolean) RETURNS text
-  AS 'select col1 from atest2 where col2 = $1;'
-  LANGUAGE sql SECURITY DEFINER READS SQL DATA;
-GRANT EXECUTE ON FUNCTION testfunc4(boolean) TO regressuser3;
-SET SESSION AUTHORIZATION regressuser2;
-SELECT testfunc1(5), testfunc2(5); -- ok
- testfunc1 | testfunc2 
------------+-----------
-        10 |        15
-(1 row)
-
-CREATE FUNCTION testfunc3(int) RETURNS int AS 'select 2 * $1;' LANGUAGE sql CONTAINS SQL; -- fail
-ERROR:  permission denied for language sql
-SET SESSION AUTHORIZATION regressuser3;
-SELECT testfunc1(5); -- fail
-ERROR:  permission denied for function testfunc1
-SELECT col1 FROM atest2 WHERE col2 = true; -- fail
-ERROR:  permission denied for relation atest2
-ERROR:  GPDB exception. Aborting GPORCA plan generation. (CGPOptimizer.cpp:66)
-SELECT testfunc4(true); -- ok
- testfunc4 
------------
- bar
-(1 row)
-
-SET SESSION AUTHORIZATION regressuser4;
-SELECT testfunc1(5); -- ok
- testfunc1 
------------
-        10
-(1 row)
-
-DROP FUNCTION testfunc1(int); -- fail
-ERROR:  must be owner of function testfunc1
-\c -
-DROP FUNCTION testfunc1(int); -- ok
--- restore to sanity
-GRANT ALL PRIVILEGES ON LANGUAGE sql TO PUBLIC;
--- truncate
-SET SESSION AUTHORIZATION regressuser5;
-TRUNCATE atest2; -- ok
-TRUNCATE atest3; -- fail
-ERROR:  permission denied for relation atest3
--- has_table_privilege function
--- bad-input checks
-select has_table_privilege(NULL,'pg_authid','select');
- has_table_privilege 
----------------------
- 
-(1 row)
-
-select has_table_privilege('pg_shad','select');
- has_table_privilege 
----------------------
- 
-(1 row)
-
-select has_table_privilege('nosuchuser','pg_authid','select');
-ERROR:  role "nosuchuser" does not exist
-select has_table_privilege('pg_authid','sel');
-ERROR:  unrecognized privilege type: "sel"
-select has_table_privilege(-999999,'pg_authid','update');
-ERROR:  role with OID 4293967297 does not exist
-select has_table_privilege(1,'select');
- has_table_privilege 
----------------------
- 
-(1 row)
-
--- superuser
-\c -
-select has_table_privilege(current_user,'pg_authid','select');
- has_table_privilege 
----------------------
- t
-(1 row)
-
-select has_table_privilege(current_user,'pg_authid','insert');
- has_table_privilege 
----------------------
- t
-(1 row)
-
-select has_table_privilege(t2.oid,'pg_authid','update')
-from (select oid from pg_roles where rolname = current_user) as t2;
- has_table_privilege 
----------------------
- t
-(1 row)
-
-select has_table_privilege(t2.oid,'pg_authid','delete')
-from (select oid from pg_roles where rolname = current_user) as t2;
- has_table_privilege 
----------------------
- t
-(1 row)
-
--- 'rule' privilege no longer exists, but for backwards compatibility
--- has_table_privilege still recognizes the keyword and says FALSE
-select has_table_privilege(current_user,t1.oid,'rule')
-from (select oid from pg_class where relname = 'pg_authid') as t1;
- has_table_privilege 
----------------------
- f
-(1 row)
-
-select has_table_privilege(current_user,t1.oid,'references')
-from (select oid from pg_class where relname = 'pg_authid') as t1;
- has_table_privilege 
----------------------
- t
-(1 row)
-
-select has_table_privilege(t2.oid,t1.oid,'select')
-from (select oid from pg_class where relname = 'pg_authid') as t1,
-  (select oid from pg_roles where rolname = current_user) as t2;
- has_table_privilege 
----------------------
- t
-(1 row)
-
-select has_table_privilege(t2.oid,t1.oid,'insert')
-from (select oid from pg_class where relname = 'pg_authid') as t1,
-  (select oid from pg_roles where rolname = current_user) as t2;
- has_table_privilege 
----------------------
- t
-(1 row)
-
-select has_table_privilege('pg_authid','update');
- has_table_privilege 
----------------------
- t
-(1 row)
-
-select has_table_privilege('pg_authid','delete');
- has_table_privilege 
----------------------
- t
-(1 row)
-
-select has_table_privilege('pg_authid','truncate');
- has_table_privilege 
----------------------
- t
-(1 row)
-
-select has_table_privilege(t1.oid,'select')
-from (select oid from pg_class where relname = 'pg_authid') as t1;
- has_table_privilege 
----------------------
- t
-(1 row)
-
-select has_table_privilege(t1.oid,'trigger')
-from (select oid from pg_class where relname = 'pg_authid') as t1;
- has_table_privilege 
----------------------
- t
-(1 row)
-
--- non-superuser
-SET SESSION AUTHORIZATION regressuser3;
-select has_table_privilege(current_user,'pg_class','select');
- has_table_privilege 
----------------------
- t
-(1 row)
-
-select has_table_privilege(current_user,'pg_class','insert');
- has_table_privilege 
----------------------
- f
-(1 row)
-
-select has_table_privilege(t2.oid,'pg_class','update')
-from (select oid from pg_roles where rolname = current_user) as t2;
- has_table_privilege 
----------------------
- f
-(1 row)
-
-select has_table_privilege(t2.oid,'pg_class','delete')
-from (select oid from pg_roles where rolname = current_user) as t2;
- has_table_privilege 
----------------------
- f
-(1 row)
-
-select has_table_privilege(current_user,t1.oid,'references')
-from (select oid from pg_class where relname = 'pg_class') as t1;
- has_table_privilege 
----------------------
- f
-(1 row)
-
-select has_table_privilege(t2.oid,t1.oid,'select')
-from (select oid from pg_class where relname = 'pg_class') as t1,
-  (select oid from pg_roles where rolname = current_user) as t2;
- has_table_privilege 
----------------------
- t
-(1 row)
-
-select has_table_privilege(t2.oid,t1.oid,'insert')
-from (select oid from pg_class where relname = 'pg_class') as t1,
-  (select oid from pg_roles where rolname = current_user) as t2;
- has_table_privilege 
----------------------
- f
-(1 row)
-
-select has_table_privilege('pg_class','update');
- has_table_privilege 
----------------------
- f
-(1 row)
-
-select has_table_privilege('pg_class','delete');
- has_table_privilege 
----------------------
- f
-(1 row)
-
-select has_table_privilege('pg_class','truncate');
- has_table_privilege 
----------------------
- f
-(1 row)
-
-select has_table_privilege(t1.oid,'select')
-from (select oid from pg_class where relname = 'pg_class') as t1;
- has_table_privilege 
----------------------
- t
-(1 row)
-
-select has_table_privilege(t1.oid,'trigger')
-from (select oid from pg_class where relname = 'pg_class') as t1;
- has_table_privilege 
----------------------
- f
-(1 row)
-
-select has_table_privilege(current_user,'atest1','select');
- has_table_privilege 
----------------------
- t
-(1 row)
-
-select has_table_privilege(current_user,'atest1','insert');
- has_table_privilege 
----------------------
- f
-(1 row)
-
-select has_table_privilege(t2.oid,'atest1','update')
-from (select oid from pg_roles where rolname = current_user) as t2;
- has_table_privilege 
----------------------
- f
-(1 row)
-
-select has_table_privilege(t2.oid,'atest1','delete')
-from (select oid from pg_roles where rolname = current_user) as t2;
- has_table_privilege 
----------------------
- f
-(1 row)
-
-select has_table_privilege(current_user,t1.oid,'references')
-from (select oid from pg_class where relname = 'atest1') as t1;
- has_table_privilege 
----------------------
- f
-(1 row)
-
-select has_table_privilege(t2.oid,t1.oid,'select')
-from (select oid from pg_class where relname = 'atest1') as t1,
-  (select oid from pg_roles where rolname = current_user) as t2;
- has_table_privilege 
----------------------
- t
-(1 row)
-
-select has_table_privilege(t2.oid,t1.oid,'insert')
-from (select oid from pg_class where relname = 'atest1') as t1,
-  (select oid from pg_roles where rolname = current_user) as t2;
- has_table_privilege 
----------------------
- f
-(1 row)
-
-select has_table_privilege('atest1','update');
- has_table_privilege 
----------------------
- f
-(1 row)
-
-select has_table_privilege('atest1','delete');
- has_table_privilege 
----------------------
- f
-(1 row)
-
-select has_table_privilege('atest1','truncate');
- has_table_privilege 
----------------------
- f
-(1 row)
-
-select has_table_privilege(t1.oid,'select')
-from (select oid from pg_class where relname = 'atest1') as t1;
- has_table_privilege 
----------------------
- t
-(1 row)
-
-select has_table_privilege(t1.oid,'trigger')
-from (select oid from pg_class where relname = 'atest1') as t1;
- has_table_privilege 
----------------------
- f
-(1 row)
-
--- Grant options
-SET SESSION AUTHORIZATION regressuser1;
-CREATE TABLE atest4 (a int);
-NOTICE:  Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table.
-HINT:  The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
-GRANT SELECT ON atest4 TO regressuser2 WITH GRANT OPTION;
-GRANT UPDATE ON atest4 TO regressuser2;
-GRANT SELECT ON atest4 TO GROUP regressgroup1 WITH GRANT OPTION;
-SET SESSION AUTHORIZATION regressuser2;
-GRANT SELECT ON atest4 TO regressuser3;
-GRANT UPDATE ON atest4 TO regressuser3; -- fail
-WARNING:  no privileges were granted for "atest4"
-SET SESSION AUTHORIZATION regressuser1;
-REVOKE SELECT ON atest4 FROM regressuser3; -- does nothing
-NOTICE:  no privileges could be revoked from role regressuser3 on object atest4
-SELECT has_table_privilege('regressuser3', 'atest4', 'SELECT'); -- true
- has_table_privilege 
----------------------
- t
-(1 row)
-
-REVOKE SELECT ON atest4 FROM regressuser2; -- fail
-ERROR:  dependent privileges exist
-HINT:  Use CASCADE to revoke them too.
-REVOKE GRANT OPTION FOR SELECT ON atest4 FROM regressuser2 CASCADE; -- ok
-SELECT has_table_privilege('regressuser2', 'atest4', 'SELECT'); -- true
- has_table_privilege 
----------------------
- t
-(1 row)
-
-SELECT has_table_privilege('regressuser3', 'atest4', 'SELECT'); -- false
- has_table_privilege 
----------------------
- f
-(1 row)
-
-SELECT has_table_privilege('regressuser1', 'atest4', 'SELECT WITH GRANT OPTION'); -- true
- has_table_privilege 
----------------------
- t
-(1 row)
-
--- Admin options
-SET SESSION AUTHORIZATION regressuser4;
-CREATE FUNCTION dogrant_ok() RETURNS void LANGUAGE sql SECURITY DEFINER AS
-	'GRANT regressgroup2 TO regressuser5';
-GRANT regressgroup2 TO regressuser5; -- ok: had ADMIN OPTION
-SET ROLE regressgroup2;
-GRANT regressgroup2 TO regressuser5; -- fails: SET ROLE suspended privilege
-ERROR:  must have admin option on role "regressgroup2"
-SET SESSION AUTHORIZATION regressuser1;
-GRANT regressgroup2 TO regressuser5; -- fails: no ADMIN OPTION
-ERROR:  must have admin option on role "regressgroup2"
-SELECT dogrant_ok();			-- ok: SECURITY DEFINER conveys ADMIN
-NOTICE:  role "regressuser5" is already a member of role "regressgroup2"
-CONTEXT:  SQL function "dogrant_ok" statement 1
- dogrant_ok 
-------------
- 
-(1 row)
-
-SET ROLE regressgroup2;
-GRANT regressgroup2 TO regressuser5; -- fails: SET ROLE did not help
-ERROR:  must have admin option on role "regressgroup2"
-SET SESSION AUTHORIZATION regressgroup2;
-GRANT regressgroup2 TO regressuser5; -- ok: a role can self-admin
-NOTICE:  role "regressuser5" is already a member of role "regressgroup2"
-CREATE FUNCTION dogrant_fails() RETURNS void LANGUAGE sql SECURITY DEFINER AS
-	'GRANT regressgroup2 TO regressuser5';
-SELECT dogrant_fails();			-- fails: no self-admin in SECURITY DEFINER
-ERROR:  must have admin option on role "regressgroup2"
-CONTEXT:  SQL function "dogrant_fails" statement 1
-DROP FUNCTION dogrant_fails();
-SET SESSION AUTHORIZATION regressuser4;
-DROP FUNCTION dogrant_ok();
-REVOKE regressgroup2 FROM regressuser5;
--- test that dependent privileges are revoked (or not) properly
-\c -
-set session role regressuser1;
-create table dep_priv_test (a int);
-grant select on dep_priv_test to regressuser2 with grant option;
-grant select on dep_priv_test to regressuser3 with grant option;
-set session role regressuser2;
-grant select on dep_priv_test to regressuser4 with grant option;
-set session role regressuser3;
-grant select on dep_priv_test to regressuser4 with grant option;
-set session role regressuser4;
-grant select on dep_priv_test to regressuser5;
-\dp dep_priv_test
-                                                                                     Access privileges for database "regression"
- Schema |     Name      | Type  |                                                                                  Access privileges                                                                                  
---------+---------------+-------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- public | dep_priv_test | table | {regressuser1=arwdDxt/regressuser1,regressuser2=r*/regressuser1,regressuser3=r*/regressuser1,regressuser4=r*/regressuser2,regressuser4=r*/regressuser3,regressuser5=r/regressuser4}
-(1 row)
-
-set session role regressuser2;
-revoke select on dep_priv_test from regressuser4 cascade;
-\dp dep_priv_test
-                                                                       Access privileges for database "regression"
- Schema |     Name      | Type  |                                                                   Access privileges                                                                    
---------+---------------+-------+--------------------------------------------------------------------------------------------------------------------------------------------------------
- public | dep_priv_test | table | {regressuser1=arwdDxt/regressuser1,regressuser2=r*/regressuser1,regressuser3=r*/regressuser1,regressuser4=r*/regressuser3,regressuser5=r/regressuser4}
-(1 row)
-
-set session role regressuser3;
-revoke select on dep_priv_test from regressuser4 cascade;
-\dp dep_priv_test
-                                          Access privileges for database "regression"
- Schema |     Name      | Type  |                                       Access privileges                                       
---------+---------------+-------+-----------------------------------------------------------------------------------------------
- public | dep_priv_test | table | {regressuser1=arwdDxt/regressuser1,regressuser2=r*/regressuser1,regressuser3=r*/regressuser1}
-(1 row)
-
-set session role regressuser1;
-drop table dep_priv_test;
--- clean up
-\c regression
-DROP FUNCTION testfunc2(int);
-DROP FUNCTION testfunc4(boolean);
-DROP VIEW atestv1;
-DROP VIEW atestv2;
--- this should cascade to drop atestv4
-DROP VIEW atestv3 CASCADE;
-NOTICE:  drop cascades to rule _RETURN on view atestv4
-NOTICE:  drop cascades to view atestv4
--- this should complain "does not exist"
-DROP VIEW atestv4;
-ERROR:  view "atestv4" does not exist
-DROP TABLE atest1;
-DROP TABLE atest2;
-DROP TABLE atest3;
-DROP TABLE atest4;
-DROP GROUP regressgroup1;
-DROP GROUP regressgroup2;
-REVOKE USAGE ON LANGUAGE sql FROM regressuser1;
-DROP USER regressuser1;
-DROP USER regressuser2;
-DROP USER regressuser3;
-DROP USER regressuser4;
-DROP USER regressuser5;
-reset optimizer;

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/56b44f85/src/test/regress/expected/role_optimizer.out
----------------------------------------------------------------------
diff --git a/src/test/regress/expected/role_optimizer.out b/src/test/regress/expected/role_optimizer.out
deleted file mode 100644
index 0f75ca9..0000000
--- a/src/test/regress/expected/role_optimizer.out
+++ /dev/null
@@ -1,107 +0,0 @@
--- 
--- ROLE
---
--- MPP-15479: ALTER ROLE SET statement
-DROP ROLE IF EXISTS role_112911;
-NOTICE:  role "role_112911" does not exist, skipping
-NOTICE:  role "role_112911" does not exist, skipping  (seg0 localhost:12001 pid=20806)
-NOTICE:  role "role_112911" does not exist, skipping  (seg1 localhost:12002 pid=20807)
-CREATE ROLE role_112911 WITH LOGIN;
-NOTICE:  resource queue required -- using default resource queue "pg_default"
-CREATE SCHEMA common_schema;
-/* Alter Role Set statement_mem */
-ALTER ROLE role_112911 SET statement_mem TO '150MB';
-SELECT gp_segment_id, rolname, array_to_string(rolconfig,',') as rolconfig
-  FROM pg_authid WHERE rolname = 'role_112911'
- UNION ALL
-SELECT DISTINCT 0 as gp_segment_id, rolname, array_to_string(rolconfig,',') as rolconfig
-  FROM gp_dist_random('pg_authid') WHERE rolname = 'role_112911';
- gp_segment_id |   rolname   |      rolconfig      
----------------+-------------+---------------------
-            -1 | role_112911 | statement_mem=150MB
-             0 | role_112911 | statement_mem=150MB
-(2 rows)
-
-/* Alter Role Set search_path */
-ALTER ROLE role_112911 SET search_path = common_schema;
-SELECT gp_segment_id, rolname, array_to_string(rolconfig,',') as rolconfig
-  FROM pg_authid WHERE rolname = 'role_112911'
- UNION ALL
-SELECT DISTINCT 0 as gp_segment_id, rolname, array_to_string(rolconfig,',') as rolconfig
-  FROM gp_dist_random('pg_authid') WHERE rolname = 'role_112911';
- gp_segment_id |   rolname   |                   rolconfig                   
----------------+-------------+-----------------------------------------------
-            -1 | role_112911 | statement_mem=150MB,search_path=common_schema
-             0 | role_112911 | statement_mem=150MB,search_path=common_schema
-(2 rows)
-
-/* Alter Role Reset statement_mem */
-ALTER ROLE role_112911 RESET statement_mem;
-SELECT gp_segment_id, rolname, array_to_string(rolconfig,',') as rolconfig
-  FROM pg_authid WHERE rolname = 'role_112911'
- UNION ALL
-SELECT DISTINCT 0 as gp_segment_id, rolname, array_to_string(rolconfig,',') as rolconfig
-  FROM gp_dist_random('pg_authid') WHERE rolname = 'role_112911';
- gp_segment_id |   rolname   |         rolconfig         
----------------+-------------+---------------------------
-            -1 | role_112911 | search_path=common_schema
-             0 | role_112911 | search_path=common_schema
-(2 rows)
-
-/* Alter Role Set statement_mem */
-ALTER ROLE role_112911 SET statement_mem = 100000;
-SELECT gp_segment_id, rolname, array_to_string(rolconfig,',') as rolconfig
-  FROM pg_authid WHERE rolname = 'role_112911'
- UNION ALL
-SELECT DISTINCT 0 as gp_segment_id, rolname, array_to_string(rolconfig,',') as rolconfig
-  FROM gp_dist_random('pg_authid') WHERE rolname = 'role_112911';
- gp_segment_id |   rolname   |                   rolconfig                    
----------------+-------------+------------------------------------------------
-            -1 | role_112911 | search_path=common_schema,statement_mem=100000
-             0 | role_112911 | search_path=common_schema,statement_mem=100000
-(2 rows)
-
-/* Alter Role Reset All */
-ALTER ROLE role_112911 RESET ALL;
-SELECT gp_segment_id, rolname, array_to_string(rolconfig,',') as rolconfig
-  FROM pg_authid WHERE rolname = 'role_112911'
- UNION ALL
-SELECT DISTINCT 0 as gp_segment_id, rolname, array_to_string(rolconfig,',') as rolconfig
-  FROM gp_dist_random('pg_authid') WHERE rolname = 'role_112911';
- gp_segment_id |   rolname   | rolconfig 
----------------+-------------+-----------
-            -1 | role_112911 | 
-             0 | role_112911 | 
-(2 rows)
-
-DROP ROLE role_112911;
-DROP SCHEMA common_schema;
--- SHA-256 testing
-set password_hash_algorithm to "SHA-256";
-create role sha256 password 'abc';
-NOTICE:  resource queue required -- using default resource queue "pg_default"
--- MPP-15865
--- OpenSSL SHA2 returning a different SHA2 to RSA BSAFE!
---select rolname, rolpassword from pg_authid where rolname = 'sha256';
-drop role sha256;
-create role superuser;
-NOTICE:  resource queue required -- using default resource queue "pg_default"
-create role u1;
-NOTICE:  resource queue required -- using default resource queue "pg_default"
-set role superuser;
-create table t1(a int, b int constraint c check (b>=100));
-NOTICE:  Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table.
-HINT:  The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
-create view t1_view as select * from t1;
-grant all privileges on t1, t1_view to u1;
-set role superuser;
-revoke all privileges on TABLE t1, t1_view FROM u1;
-set role u1;
-select * from t1_view order by 1;
-ERROR:  permission denied for relation t1_view
-ERROR:  GPDB exception. Aborting GPORCA plan generation. (CGPOptimizer.cpp:66)
-reset role;
-drop view t1_view;
-drop table t1;
-drop role u1;
-drop role superuser;

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/56b44f85/src/test/regress/output/constraints_optimizer.source
----------------------------------------------------------------------
diff --git a/src/test/regress/output/constraints_optimizer.source b/src/test/regress/output/constraints_optimizer.source
index b4798c0..aa3c56b 100644
--- a/src/test/regress/output/constraints_optimizer.source
+++ b/src/test/regress/output/constraints_optimizer.source
@@ -317,7 +317,7 @@ ERROR:  duplicate key violates unique constraint "primary_tbl_pkey"
 INSERT INTO PRIMARY_TBL VALUES (4, 'three');
 INSERT INTO PRIMARY_TBL VALUES (5, 'one');
 INSERT INTO PRIMARY_TBL (t) VALUES ('six');
-ERROR:  NULL value in column "i" violates not-null constraint (COptTasks.cpp:1289)
+ERROR:  NULL value in column "i" violates not-null constraint (CTranslatorUtils.cpp:2627)
 SELECT '' AS four, * FROM PRIMARY_TBL;
  four | i |   t   
 ------+---+-------
@@ -337,7 +337,7 @@ INSERT INTO PRIMARY_TBL VALUES (1, 'three');
 INSERT INTO PRIMARY_TBL VALUES (4, 'three');
 INSERT INTO PRIMARY_TBL VALUES (5, 'one');
 INSERT INTO PRIMARY_TBL (t) VALUES ('six');
-ERROR:  NULL value in column "i" violates not-null constraint (COptTasks.cpp:1289)
+ERROR:  NULL value in column "i" violates not-null constraint (CTranslatorUtils.cpp:2627)
 SELECT '' AS three, * FROM PRIMARY_TBL;
  three | i |   t   
 -------+---+-------


Mime
View raw message