diff --git a/src/bin/pg_dump/pg_dump.cpp b/src/bin/pg_dump/pg_dump.cpp index fe14de68f..3a2c8855a 100644 --- a/src/bin/pg_dump/pg_dump.cpp +++ b/src/bin/pg_dump/pg_dump.cpp @@ -18091,7 +18091,8 @@ static void dumpViewSchema( /* set definer for CREATE VIEW statement */ appendPQExpBuffer(q, "CREATE "); - if (tbinfo->rolname != NULL && strlen(tbinfo->rolname) > 0) { + if ((gdatcompatibility != NULL) && strcmp(gdatcompatibility, B_FORMAT) == 0 && + tbinfo->rolname != NULL && strlen(tbinfo->rolname) > 0) { appendPQExpBuffer(q, " DEFINER = %s ", tbinfo->rolname); } appendPQExpBuffer(q, " VIEW %s(%s)", fmtId(tbinfo->dobj.name), schemainfo); diff --git a/src/test/regress/input/view_definer_test.source b/src/test/regress/input/view_definer_test.source index 77dce4fe4..a3eb63dad 100644 --- a/src/test/regress/input/view_definer_test.source +++ b/src/test/regress/input/view_definer_test.source @@ -45,8 +45,21 @@ SELECT c.relname as view_name, u.usename as rolname FROM pg_class c, pg_user u W RESET ROLE; +create database test_1; +\c test_1 +create table startwith_t(id int, level int, connect_by_isleaf int, connect_by_iscycle int); +create view startwith_v as select id, connect_by_isleaf as level, level as connect_by_isleaf from startwith_t; + +\! @abs_bindir@/gs_dump test_1 -p @portstring@ -f @abs_bindir@/dump_postgres.sql +drop database if exists test_2; +create database test_2; +\! @abs_bindir@/gsql -d test_2 -p @portstring@ -f @abs_bindir@/dump_postgres.sql +\! @abs_bindir@/gsql -d test_2 -p @portstring@ -c "select * from startwith_v;" + \c regression drop database test_db; +drop database test_1; +drop database test_2; DROP USER test_user; DROP USER test_user2; DROP USER root_test CASCADE; diff --git a/src/test/regress/output/view_definer_test.source b/src/test/regress/output/view_definer_test.source index 0439629e5..40dd11bb3 100644 --- a/src/test/regress/output/view_definer_test.source +++ b/src/test/regress/output/view_definer_test.source @@ -101,8 +101,46 @@ SELECT c.relname as view_name, u.usename as rolname FROM pg_class c, pg_user u W (3 rows) RESET ROLE; +create database test_1; +\c test_1 +create table startwith_t(id int, level int, connect_by_isleaf int, connect_by_iscycle int); +create view startwith_v as select id, connect_by_isleaf as level, level as connect_by_isleaf from startwith_t; +\! @abs_bindir@/gs_dump test_1 -p @portstring@ -f @abs_bindir@/dump_postgres.sql +--?.* +--?.* +--?.* +--?.* +drop database if exists test_2; +NOTICE: database "test_2" does not exist, skipping +create database test_2; +\! @abs_bindir@/gsql -d test_2 -p @portstring@ -f @abs_bindir@/dump_postgres.sql +SET +SET +SET +SET +SET +SET +SET +SET +SET +CREATE TABLE +ALTER TABLE +CREATE VIEW +ALTER VIEW +REVOKE +REVOKE +GRANT +GRANT +--?.* +\! @abs_bindir@/gsql -d test_2 -p @portstring@ -c "select * from startwith_v;" + id | level | connect_by_isleaf +----+-------+------------------- +(0 rows) + \c regression drop database test_db; +drop database test_1; +drop database test_2; DROP USER test_user; DROP USER test_user2; DROP USER root_test CASCADE;