Repository: incubator-hawq Updated Branches: refs/heads/master 32e9dd2ac -> 0ffcd45a6
Refactor alter owner installcheck case using new test framework Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/0ffcd45a Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/0ffcd45a Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/0ffcd45a Branch: refs/heads/master Commit: 0ffcd45a64c52ea8aaff8d11772bbd4eadf01072 Parents: 32e9dd2 Author: YI JIN <[email protected]> Authored: Mon Jun 13 16:48:39 2016 +1000 Committer: YI JIN <[email protected]> Committed: Mon Jun 13 16:48:39 2016 +1000 ---------------------------------------------------------------------- src/test/feature/catalog/ans/alter-owner.ans | 47 ++++++++++++++++++++ src/test/feature/catalog/ans/alter-owner.out | 51 ++++++++++++++++++++++ src/test/feature/catalog/sql/alter-owner.sql | 28 ++++++++++++ src/test/feature/catalog/test_alter_owner.cpp | 27 ++++++++++++ 4 files changed, 153 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/0ffcd45a/src/test/feature/catalog/ans/alter-owner.ans ---------------------------------------------------------------------- diff --git a/src/test/feature/catalog/ans/alter-owner.ans b/src/test/feature/catalog/ans/alter-owner.ans new file mode 100644 index 0000000..9d2eeaf --- /dev/null +++ b/src/test/feature/catalog/ans/alter-owner.ans @@ -0,0 +1,47 @@ +create role super superuser; +CREATE ROLE +set session authorization super; +SET +create role u1; +psql:/tmp/TestAlterOwner_TestAlterOwnerAll.sql:6: NOTICE: resource queue required -- using default resource queue "pg_default" +CREATE ROLE +create database u1; +CREATE DATABASE +create schema u1; +CREATE SCHEMA +select + nspname, rolname + from + pg_namespace n, pg_authid a + where + n.nspowner = a.oid and nspname = 'u1'; + nspname | rolname +---------+--------- + u1 | super +(1 row) + +select + datname, rolname + from + pg_database d, pg_authid a + where + d.datdba = a.oid and datname = 'u1'; + datname | rolname +---------+--------- + u1 | super +(1 row) + +alter database u1 owner to u1; +psql:/tmp/TestAlterOwner_TestAlterOwnerAll.sql:24: ERROR: Cannot support alter database owner statement yet +alter schema u1 owner to u1; +psql:/tmp/TestAlterOwner_TestAlterOwnerAll.sql:25: ERROR: Cannot support alter schema owner statement yet +reset session authorization; +RESET +drop database u1; +DROP DATABASE +drop schema u1; +DROP SCHEMA +drop role u1; +DROP ROLE +drop role super; +DROP ROLE http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/0ffcd45a/src/test/feature/catalog/ans/alter-owner.out ---------------------------------------------------------------------- diff --git a/src/test/feature/catalog/ans/alter-owner.out b/src/test/feature/catalog/ans/alter-owner.out new file mode 100644 index 0000000..c03ac67 --- /dev/null +++ b/src/test/feature/catalog/ans/alter-owner.out @@ -0,0 +1,51 @@ +-- start_ignore +SET SEARCH_PATH=TestAlterOwner_TestAlterOwnerAll; +SET +-- end_ignore +create role super superuser; +CREATE ROLE +set session authorization super; +SET +create role u1; +psql:/tmp/TestAlterOwner_TestAlterOwnerAll.sql:6: NOTICE: resource queue required -- using default resource queue "pg_default" +CREATE ROLE +create database u1; +CREATE DATABASE +create schema u1; +CREATE SCHEMA +select + nspname, rolname + from + pg_namespace n, pg_authid a + where + n.nspowner = a.oid and nspname = 'u1'; + nspname | rolname +---------+--------- + u1 | super +(1 row) + +select + datname, rolname + from + pg_database d, pg_authid a + where + d.datdba = a.oid and datname = 'u1'; + datname | rolname +---------+--------- + u1 | super +(1 row) + +alter database u1 owner to u1; +psql:/tmp/TestAlterOwner_TestAlterOwnerAll.sql:24: ERROR: Cannot support alter database owner statement yet +alter schema u1 owner to u1; +psql:/tmp/TestAlterOwner_TestAlterOwnerAll.sql:25: ERROR: Cannot support alter schema owner statement yet +reset session authorization; +RESET +drop database u1; +DROP DATABASE +drop schema u1; +DROP SCHEMA +drop role u1; +DROP ROLE +drop role super; +DROP ROLE http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/0ffcd45a/src/test/feature/catalog/sql/alter-owner.sql ---------------------------------------------------------------------- diff --git a/src/test/feature/catalog/sql/alter-owner.sql b/src/test/feature/catalog/sql/alter-owner.sql new file mode 100644 index 0000000..a6e7b77 --- /dev/null +++ b/src/test/feature/catalog/sql/alter-owner.sql @@ -0,0 +1,28 @@ +create role super superuser; +set session authorization super; +create role u1; +create database u1; +create schema u1; + +select + nspname, rolname + from + pg_namespace n, pg_authid a + where + n.nspowner = a.oid and nspname = 'u1'; + +select + datname, rolname + from + pg_database d, pg_authid a + where + d.datdba = a.oid and datname = 'u1'; + +alter database u1 owner to u1; +alter schema u1 owner to u1; + +reset session authorization; +drop database u1; +drop schema u1; +drop role u1; +drop role super; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/0ffcd45a/src/test/feature/catalog/test_alter_owner.cpp ---------------------------------------------------------------------- diff --git a/src/test/feature/catalog/test_alter_owner.cpp b/src/test/feature/catalog/test_alter_owner.cpp new file mode 100644 index 0000000..7e7fcc4 --- /dev/null +++ b/src/test/feature/catalog/test_alter_owner.cpp @@ -0,0 +1,27 @@ +#include <pwd.h> +#include <sys/types.h> +#include <unistd.h> +#include <vector> +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> +#include <iostream> + +#include "lib/command.h" +#include "lib/data_gen.h" +#include "lib/hawq_config.h" +#include "lib/sql_util.h" + +#include "gtest/gtest.h" + +class TestAlterOwner : public ::testing::Test { + public: + TestAlterOwner() {} + ~TestAlterOwner() {} +}; + +TEST_F(TestAlterOwner, TestAlterOwnerAll) { + hawq::test::SQLUtility util; + util.execSQLFile("catalog/sql/alter-owner.sql", + "catalog/ans/alter-owner.ans"); +}
