hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odiache...@apache.org
Subject incubator-hawq git commit: HAWQ-369. Hcatalog as reserved name need regression tests. [Forced Update!]
Date Tue, 02 Feb 2016 20:03:47 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/HAWQ-369 92a541f03 -> 131bb8e88 (forced update)


HAWQ-369. Hcatalog as reserved name need regression tests.


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

Branch: refs/heads/HAWQ-369
Commit: 131bb8e88f9f951bdea360765c4fcb98c415214c
Parents: 00001b8
Author: Oleksandr Diachenko <odiachenko@pivotal.io>
Authored: Mon Feb 1 13:09:53 2016 -0800
Committer: Oleksandr Diachenko <odiachenko@pivotal.io>
Committed: Tue Feb 2 12:03:37 2016 -0800

----------------------------------------------------------------------
 src/backend/commands/dbcommands.c              |  8 ++---
 src/backend/commands/schemacmds.c              | 19 ------------
 src/backend/utils/init/postinit.c              | 16 ++++++++++
 src/include/utils/errcodes.h                   |  1 -
 src/test/regress/input/hcatalog_lookup.source  | 26 ++++++++++------
 src/test/regress/output/hcatalog_lookup.source | 34 ++++++++++++---------
 6 files changed, 56 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/131bb8e8/src/backend/commands/dbcommands.c
----------------------------------------------------------------------
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index d20accb..635d986 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -852,10 +852,10 @@ createdb(CreatedbStmt *stmt)
 	 * because it's already reserved for hcatalog feature integration.
 	 */
 	if (OidIsValid(get_database_oid(dbname)))
-			if (strcmp(dbname, "hcatalog") == 0)
+			if (strcmp(dbname, HcatalogDbName) == 0)
 				ereport(ERROR,
-						(errcode(ERRCODE_RESERVED_HCATALOG_NAME),
-						 errmsg("hcatalog is a reserved name for hcatalog feature integration")));
+						(errcode(ERRCODE_RESERVED_NAME),
+						 errmsg("\"%s\" is a reserved name for hcatalog feature integration", HcatalogDbName)));
 			else
 				ereport(ERROR,
 						(errcode(ERRCODE_DUPLICATE_DATABASE),
@@ -1546,7 +1546,7 @@ RenameDatabase(const char *oldname, const char *newname)
 	 * hcatalog feature integration*/
 	if (strcmp(newname, HcatalogDbName) == 0)
 		ereport(ERROR,
-				(errcode(ERRCODE_RESERVED_HCATALOG_NAME),
+				(errcode(ERRCODE_RESERVED_NAME),
 				errmsg("\"%s\" is a reserved name for hcatalog feature integration", HcatalogDbName)));
 	/*
 	 * Look up the target database's OID, and get exclusive lock on it. We

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/131bb8e8/src/backend/commands/schemacmds.c
----------------------------------------------------------------------
diff --git a/src/backend/commands/schemacmds.c b/src/backend/commands/schemacmds.c
index 45efafd..4ce2fe1 100644
--- a/src/backend/commands/schemacmds.c
+++ b/src/backend/commands/schemacmds.c
@@ -92,15 +92,6 @@ CreateSchemaCommand(CreateSchemaStmt *stmt, const char *queryString)
 		owner_uid = saved_uid;
 
 	/* 
-	 * Make sure schema name is not "hcatalog"
-	 */
-	if (strcmp(schemaName, "hcatalog") == 0)
-	{
-		ereport(ERROR,
-				(errcode(ERRCODE_RESERVED_HCATALOG_NAME),
-				 errmsg("hcatalog is a reserved name for hcatalog feature integration")));
-	}
-	/*
 	 * If we are creating a temporary schema then we can skip a 
 	 * bunch of checks that we would otherwise make.
 	 */
@@ -397,16 +388,6 @@ RenameSchema(const char *oldname, const char *newname)
 				 errdetail("Schema %s is reserved for system use.", oldname)));
 	}
 
-	/*
-	* Make sure new schema name is not "hcatalog"
-	*/
-	if (strcmp(newname, "hcatalog") == 0)
-	{
-		ereport(ERROR,
-				(errcode(ERRCODE_RESERVED_HCATALOG_NAME),
-				errmsg("hcatalog is a reserved name for hcatalog feature integration")));
-	}
-
 	if (!allowSystemTableModsDDL &&
 		(IsReservedName(newname) || strcmp(newname, "madlib") == 0))
 	{

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/131bb8e8/src/backend/utils/init/postinit.c
----------------------------------------------------------------------
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c
index e4d0752..57848e1 100644
--- a/src/backend/utils/init/postinit.c
+++ b/src/backend/utils/init/postinit.c
@@ -368,6 +368,22 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username,
 	char		dbname[NAMEDATALEN];
 
 	/*
+	 * User is not supposed to connect to hcatalog database,
+	 * because it's reserved for hcatalog feature integration
+	 */
+	if (!bootstrap)
+	{
+		if (strcmp(in_dbname, HcatalogDbName) == 0)
+		{
+			ereport(ERROR,
+					(errcode(ERRCODE_UNDEFINED_DATABASE),
+					errmsg("\"%s\" database is only for system use",
+					HcatalogDbName)));
+		}
+	}
+
+
+	/*
 	 * Set up the global variables holding database id and path.  But note we
 	 * won't actually try to touch the database just yet.
 	 *

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/131bb8e8/src/include/utils/errcodes.h
----------------------------------------------------------------------
diff --git a/src/include/utils/errcodes.h b/src/include/utils/errcodes.h
index 2be7ee4..b13cf02 100644
--- a/src/include/utils/errcodes.h
+++ b/src/include/utils/errcodes.h
@@ -294,7 +294,6 @@
 #define ERRCODE_INVALID_NAME				MAKE_SQLSTATE('4','2', '6','0','2')
 #define ERRCODE_NAME_TOO_LONG				MAKE_SQLSTATE('4','2', '6','2','2')
 #define ERRCODE_RESERVED_NAME				MAKE_SQLSTATE('4','2', '9','3','9')
-#define ERRCODE_RESERVED_HCATALOG_NAME		MAKE_SQLSTATE('4','2', '9','4','0')
 #define ERRCODE_DATATYPE_MISMATCH			MAKE_SQLSTATE('4','2', '8','0','4')
 #define ERRCODE_INDETERMINATE_DATATYPE		MAKE_SQLSTATE('4','2', 'P','1','8')
 #define ERRCODE_WRONG_OBJECT_TYPE			MAKE_SQLSTATE('4','2', '8','0','9')

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/131bb8e8/src/test/regress/input/hcatalog_lookup.source
----------------------------------------------------------------------
diff --git a/src/test/regress/input/hcatalog_lookup.source b/src/test/regress/input/hcatalog_lookup.source
index 372e5bb..e295449 100644
--- a/src/test/regress/input/hcatalog_lookup.source
+++ b/src/test/regress/input/hcatalog_lookup.source
@@ -138,26 +138,28 @@ alter table test_schema.p exchange partition p1 with table hcatalog.test_schema.
 select pg_catalog.pg_database_size('hcatalog');
 select pg_catalog.pg_database_size(6120);
 
+--positive test: should be able to create table named "hcatalog"
+CREATE TABLE hcatalog(a int);
+
 --negative test: cannot create database named "hcatalog"
 CREATE DATABASE hcatalog;
 
---negative test: cannot create schema named "hcatalog"
-CREATE SCHEMA hcatalog;
-
 --allow renaming schemas and databases
 SET gp_called_by_pgdump = true;
 
 --negative test: cannot rename exiting database to "hcatalog"
 ALTER DATABASE regression RENAME TO hcatalog;
 
---negative test: cannot rename exiting schema to "hcatalog"
-ALTER SCHEMA regression RENAME TO hcatalog;
+--positive test: can rename exiting schema to "hcatalog"
+CREATE SCHEMA test_schema3;
+ALTER SCHEMA test_schema3 RENAME to hcatalog;
+ALTER SCHEMA hcatalog RENAME to hcatalog1;
 
---negative test: cannot rename exiting schema to "hcatalog"
-ALTER DATABASE hcatalog RENAME to hcatalog1;
+--positive test: should be able to create schema named "hcatalog"
+CREATE SCHEMA hcatalog;
 
---negative test: cannot connect to "hcatalog" database
-\connect hcatalog;
+--positive test: can rename schema "hcatalog"
+ALTER SCHEMA hcatalog RENAME to hcatalog2;
 
 --negative test: cannot create a database using "hcatalog" as a template
 CREATE DATABASE hcatalog2 TEMPLATE hcatalog;
@@ -170,11 +172,17 @@ DROP schema test_schema cascade;
 SELECT convert_to_internal_schema('test_schema');
 DROP schema test_schema cascade;
 DROP schema test_schema2 cascade;
+DROP schema hcatalog1 cascade;
+DROP schema hcatalog2 cascade;
 select nspname,nspdboid from pg_namespace where nspname='test_schema';
 
 DROP FUNCTION convert_to_hcatalog_schema(text);
 DROP FUNCTION convert_to_internal_schema(text);
 DROP FUNCTION trigger_func();
 DROP USER newuser;
+DROP TABLE hcatalog;
 -- disable GUC
 SET hcatalog_enable = false;
+
+--negative test: cannot connect to "hcatalog" database
+\connect hcatalog;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/131bb8e8/src/test/regress/output/hcatalog_lookup.source
----------------------------------------------------------------------
diff --git a/src/test/regress/output/hcatalog_lookup.source b/src/test/regress/output/hcatalog_lookup.source
index c545b07..b28b665 100644
--- a/src/test/regress/output/hcatalog_lookup.source
+++ b/src/test/regress/output/hcatalog_lookup.source
@@ -266,29 +266,27 @@ select pg_catalog.pg_database_size('hcatalog');
 ERROR:  database hcatalog (OID 6120) is reserved (SOMEFILE:SOMEFUNC)
 select pg_catalog.pg_database_size(6120);
 ERROR:  database hcatalog (OID 6120) is reserved (SOMEFILE:SOMEFUNC)
+--positive test: should be able to create table named "hcatalog"
+CREATE TABLE hcatalog(a int);
 --negative test: cannot create database named "hcatalog"
 CREATE DATABASE hcatalog;
-ERROR:  hcatalog is a reserved name for hcatalog feature integration
---negative test: cannot create schema named "hcatalog"
-CREATE SCHEMA hcatalog;
-ERROR:  hcatalog is a reserved name for hcatalog feature integration
+ERROR:  "hcatalog" is a reserved name for hcatalog feature integration
 --allow renaming schemas and databases
 SET gp_called_by_pgdump = true;
 --negative test: cannot rename exiting database to "hcatalog"
 ALTER DATABASE regression RENAME TO hcatalog;
-ERROR:  hcatalog is a reserved name for hcatalog feature integration
---negative test: cannot rename exiting schema to "hcatalog"
-ALTER SCHEMA regression RENAME TO hcatalog;
-ERROR:  hcatalog is a reserved name for hcatalog feature integration
---negative test: cannot rename exiting schema to "hcatalog"
-ALTER DATABASE hcatalog RENAME to hcatalog1;
-ERROR:  permission denied to ALTER DATABASE hcatalog is reserved for system use
---negative test: cannot connect to "hcatalog" database
-\connect hcatalog;
-ERROR:  hcatalog database is only for system use
+ERROR:  "hcatalog" is a reserved name for hcatalog feature integration
+--positive test: can rename exiting schema to "hcatalog"
+CREATE SCHEMA test_schema3;
+ALTER SCHEMA test_schema3 RENAME to hcatalog;
+ALTER SCHEMA hcatalog RENAME to hcatalog1;
+--positive test: should be able to create schema named "hcatalog"
+CREATE SCHEMA hcatalog;
+--positive test: can rename schema "hcatalog"
+ALTER SCHEMA hcatalog RENAME to hcatalog2;
 --negative test: cannot create a database using "hcatalog" as a template
 CREATE DATABASE hcatalog2 TEMPLATE hcatalog;
-ERROR: hcatalog database is only for system use and cannot be used as template
+ERROR:  copy non template database is not supported
 --restrict renaming schemas and databases
 SET gp_called_by_pgdump = false;
 -- cleanup
@@ -311,6 +309,8 @@ NOTICE:  drop cascades to append only table test_schema.tt
 NOTICE:  drop cascades to append only table test_schema.t
 NOTICE:  drop cascades to append only table test_schema.r
 DROP schema test_schema2 cascade;
+DROP schema hcatalog1 cascade;
+DROP schema hcatalog2 cascade;
 select nspname,nspdboid from pg_namespace where nspname='test_schema';
  nspname | nspdboid 
 ---------+----------
@@ -320,5 +320,9 @@ DROP FUNCTION convert_to_hcatalog_schema(text);
 DROP FUNCTION convert_to_internal_schema(text);
 DROP FUNCTION trigger_func();
 DROP USER newuser;
+DROP TABLE hcatalog;
 -- disable GUC
 SET hcatalog_enable = false;
+--negative test: cannot connect to "hcatalog" database
+\connect hcatalog;
+\connect: FATAL:  "hcatalog" database is only for system use


Mime
View raw message