hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shiv...@apache.org
Subject [1/2] incubator-hawq git commit: HAWQ-18. Error out database_size function on hcatalog
Date Wed, 30 Sep 2015 21:37:22 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/master 8bce795db -> 3581ed37a


HAWQ-18. Error out database_size function on hcatalog


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

Branch: refs/heads/master
Commit: 621bc97830c9b4fcd320f6ce6e2d5c4388466954
Parents: 8bce795
Author: Jimmy Da <jda@pivotal.io>
Authored: Fri Sep 18 11:05:11 2015 -0700
Committer: Jimmy Da <jda@pivotal.io>
Committed: Wed Sep 30 14:32:30 2015 -0700

----------------------------------------------------------------------
 src/backend/utils/adt/dbsize.c                 | 6 ++++++
 src/test/regress/input/hcatalog_lookup.source  | 4 +++-
 src/test/regress/output/hcatalog_lookup.source | 5 +++++
 3 files changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/621bc978/src/backend/utils/adt/dbsize.c
----------------------------------------------------------------------
diff --git a/src/backend/utils/adt/dbsize.c b/src/backend/utils/adt/dbsize.c
index ab5e04b..7103a99 100644
--- a/src/backend/utils/adt/dbsize.c
+++ b/src/backend/utils/adt/dbsize.c
@@ -24,6 +24,7 @@
 #include "catalog/catalog.h"
 #include "catalog/catquery.h"
 #include "catalog/namespace.h"
+#include "catalog/pg_database.h"
 #include "catalog/pg_tablespace.h"
 #include "commands/dbcommands.h"
 #include "commands/tablespace.h"
@@ -178,6 +179,11 @@ calculate_database_size(Oid dbOid)
 
 	Assert(Gp_role != GP_ROLE_EXECUTE);
 
+	if (dbOid == HcatalogDbOid)
+		ereport(ERROR,
+			(ERRCODE_UNDEFINED_DATABASE,
+			errmsg("database hcatalog (OID 6120) is reserved")));
+
 	/* User must have connect privilege for target database */
 	aclresult = pg_database_aclcheck(dbOid, GetUserId(), ACL_CONNECT);
 	if (aclresult != ACLCHECK_OK)

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/621bc978/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 06c6389..a011abf 100644
--- a/src/test/regress/input/hcatalog_lookup.source
+++ b/src/test/regress/input/hcatalog_lookup.source
@@ -134,7 +134,9 @@ select r1.*, r2.* from hcatalog.test_schema.r r1, test_schema.r r2;
 -- negative test: partitioned tables and hcatalog
 alter table test_schema.p exchange partition p1 with table hcatalog.test_schema.r;
 
-
+-- negative test: cannot run pg_database_size on hcatalog
+select pg_catalog.pg_database_size('hcatalog');
+select pg_catalog.pg_database_size(6120);
 
 -- cleanup
 DROP schema test_schema cascade;

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/621bc978/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 c649215..8708e59 100644
--- a/src/test/regress/output/hcatalog_lookup.source
+++ b/src/test/regress/output/hcatalog_lookup.source
@@ -261,6 +261,11 @@ select r1.*, r2.* from hcatalog.test_schema.r r1, test_schema.r r2;
 -- negative test: partitioned tables and hcatalog
 alter table test_schema.p exchange partition p1 with table hcatalog.test_schema.r;
 ERROR:  reference to hcatalog table "hcatalog.test_schema.r" is not allowed in this context
+-- negative test: cannot run pg_database_size on hcatalog
+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)
 -- cleanup
 DROP schema test_schema cascade;
 NOTICE:  drop cascades to append only table test_schema.r


Mime
View raw message