Index: src/test/regress/expected/namespace.out
===================================================================
RCS file: /usr/local/cvsroot/pgsql-server/src/test/regress/expected/namespace.out,v
retrieving revision 1.2
diff -r1.2 namespace.out
0a1
> -- Validate the relationship between multiple schemas and the search path.
2,3c3,197
< -- Regression tests for schemas (namespaces)
< --
---
> set search_path to public;
> SHOW search_path;--should show only public
>  search_path 
> -------------
>  public
> (1 row)
> 
> CREATE SCHEMA schm1
> 	CREATE TABLE testschmtbl ( id int primary key, a int unique);
> NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "testschmtbl_pkey" for table "testschmtbl"
> NOTICE:  CREATE TABLE / UNIQUE will create implicit index "testschmtbl_a_key" for table "testschmtbl"
> CREATE SCHEMA schm2
> 	CREATE TABLE testschmtbl ( id int primary key, a int unique);
> NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "testschmtbl_pkey" for table "testschmtbl"
> NOTICE:  CREATE TABLE / UNIQUE will create implicit index "testschmtbl_a_key" for table "testschmtbl"
> CREATE SCHEMA schm3;
> CREATE TABLE schm3.testschmtbl ( id int primary key, a int unique);
> NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "testschmtbl_pkey" for table "testschmtbl"
> NOTICE:  CREATE TABLE / UNIQUE will create implicit index "testschmtbl_a_key" for table "testschmtbl"
> SELECT current_schemas(true);--should show above three schemas
>    current_schemas   
> ---------------------
>  {pg_catalog,public}
> (1 row)
> 
> --This should be an error.
> --Because public.testschmtbl doesn't exist yet.
> INSERT INTO testschmtbl (id, a) VALUES ( 1,1);
> ERROR:  relation "testschmtbl" does not exist
> INSERT INTO schm1.testschmtbl (id, a) VALUES ( 1,1);--OK
> -- Create PUBLIC's testschmtbl
> CREATE TABLE testschmtbl ( id int primary key, a int unique);
> NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "testschmtbl_pkey" for table "testschmtbl"
> NOTICE:  CREATE TABLE / UNIQUE will create implicit index "testschmtbl_a_key" for table "testschmtbl"
> --Should not cause any error
> --Because this is PUBLIC's testschmtbl
> INSERT INTO testschmtbl (id, a) VALUES ( 1,1);
> --The following two queries below should be a duplicate error.
> INSERT INTO testschmtbl (id, a) VALUES ( 1,1);--PUBLIC's
> ERROR:  duplicate key violates unique constraint "testschmtbl_pkey"
> INSERT INTO schm1.testschmtbl (id, a) VALUES ( 1,1);--SCHM1's
> ERROR:  duplicate key violates unique constraint "testschmtbl_pkey"
> select * from public.testschmtbl;--1 row
>  id | a 
> ----+---
>   1 | 1
> (1 row)
> 
> select * from testschmtbl;--1 row. This is PUBLIC's.
>  id | a 
> ----+---
>   1 | 1
> (1 row)
> 
> select * from schm1.testschmtbl;--1 row
>  id | a 
> ----+---
>   1 | 1
> (1 row)
> 
> select * from schm2.testschmtbl;--0 row
>  id | a 
> ----+---
> (0 rows)
> 
> select * from schm3.testschmtbl;--0 row
>  id | a 
> ----+---
> (0 rows)
> 
> set search_path to schm1, public, schm2, schm3;
> SHOW search_path;
>          search_path         
> -----------------------------
>  schm1, public, schm2, schm3
> (1 row)
> 
> INSERT INTO testschmtbl (id, a) VALUES ( 2,2);
> INSERT INTO schm1.testschmtbl (id, a) VALUES ( 2,2);--duplicate error
> ERROR:  duplicate key violates unique constraint "testschmtbl_pkey"
> select * from public.testschmtbl;--1 row
>  id | a 
> ----+---
>   1 | 1
> (1 row)
> 
> select * from schm1.testschmtbl;--2 row
>  id | a 
> ----+---
>   1 | 1
>   2 | 2
> (2 rows)
> 
> select * from schm2.testschmtbl;--0 row
>  id | a 
> ----+---
> (0 rows)
> 
> select * from schm3.testschmtbl;--0 row
>  id | a 
> ----+---
> (0 rows)
> 
> INSERT INTO public.testschmtbl (id, a) VALUES ( 2,2);--should not be an error
> CREATE TABLE schm2.testschmtbl2( id int primary key, a int unique);
> NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "testschmtbl2_pkey" for table "testschmtbl2"
> NOTICE:  CREATE TABLE / UNIQUE will create implicit index "testschmtbl2_a_key" for table "testschmtbl2"
> CREATE TABLE schm3.testschmtbl2( id int primary key, a int unique);
> NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "testschmtbl2_pkey" for table "testschmtbl2"
> NOTICE:  CREATE TABLE / UNIQUE will create implicit index "testschmtbl2_a_key" for table "testschmtbl2"
> CREATE TABLE schm3.testschmtbl3( id int primary key, a int unique);
> NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "testschmtbl3_pkey" for table "testschmtbl3"
> NOTICE:  CREATE TABLE / UNIQUE will create implicit index "testschmtbl3_a_key" for table "testschmtbl3"
> set search_path to schm2, schm3, public, schm1;
> SHOW search_path;
>          search_path         
> -----------------------------
>  schm2, schm3, public, schm1
> (1 row)
> 
> --Should not cause any error
> --Insert values into schm2's testschmtbl
> INSERT INTO testschmtbl (id, a) VALUES ( 2,2);
> SET search_path TO schm1, public;
> --Should be an error.
> --Relation testchmtbl2 doesn't exist in the schm1 schema.
> INSERT INTO testchmtbl2 (id, a) VALUES (2,2);
> ERROR:  relation "testchmtbl2" does not exist
> SET search_path TO schm1, public, schm3, schm2;
> --Should not be an error
> --Insert values into schm3's testschmtbl2
> INSERT INTO testschmtbl2 (id, a) VALUES (2,2);
> select * from schm2.testschmtbl2;--0 row
>  id | a 
> ----+---
> (0 rows)
> 
> select * from schm3.testschmtbl2;--2 rows
>  id | a 
> ----+---
>   2 | 2
> (1 row)
> 
> INSERT INTO testschmtbl3 (id, a) VALUES (2,2);--Should not be an error
> select * from schm3.testschmtbl3;-- 1 row
>  id | a 
> ----+---
>   2 | 2
> (1 row)
> 
> --DROP TABLE testschmtbl CASCADE;
> set search_path to schm1, public, schm2, schm3;
> BEGIN;
> TRUNCATE testschmtbl;--This should truncate the schm1's testschmtbl
> COMMIT;
> select * from public.testschmtbl;--2 rows
>  id | a 
> ----+---
>   1 | 1
>   2 | 2
> (2 rows)
> 
> select * from schm1.testschmtbl;--0 row
>  id | a 
> ----+---
> (0 rows)
> 
> select * from schm2.testschmtbl;--1 row
>  id | a 
> ----+---
>   2 | 2
> (1 row)
> 
> select * from schm3.testschmtbl;--0 row
>  id | a 
> ----+---
> (0 rows)
> 
> DROP TABLE public.testschmtbl CASCADE;
> DROP SCHEMA schm1 CASCADE;
> NOTICE:  drop cascades to table testschmtbl
> DROP SCHEMA schm2 CASCADE;
> NOTICE:  drop cascades to table testschmtbl2
> NOTICE:  drop cascades to table testschmtbl
> DROP SCHEMA schm3 CASCADE;
> NOTICE:  drop cascades to table testschmtbl3
> NOTICE:  drop cascades to table testschmtbl2
> NOTICE:  drop cascades to table testschmtbl
> select current_schemas(true);
>    current_schemas   
> ---------------------
>  {pg_catalog,public}
> (1 row)
> 
> --Verify schema_elements
5a200
>        CREATE SEQUENCE abc_seq START WITH 1 INCREMENT BY 2
7a203,207
>        CREATE TRIGGER schmtrigger
>       BEFORE INSERT OR UPDATE ON abc
>        FOR EACH ROW
>        EXECUTE PROCEDURE
>        autoinc(b, abc_seq)
16c216
<     (SELECT oid FROM pg_namespace WHERE nspname = 'test_schema_1');
---
>     (SELECT oid FROM pg_namespace WHERE nspname = 'test_schema_1');--1 row
19c219
<      5
---
>      6
21a222,223
> --The following query will fail because the schema test_schema_1 is not
> -- on the search_path yet.
22a225,232
> ERROR:  relation "abc_seq" does not exist
> SELECT nextval('test_schema_1.abc_seq');
>  nextval 
> ---------
>        1
> (1 row)
> 
> set search_path to test_schema_1, public;
25c235
< SELECT * FROM test_schema_1.abc;
---
> SELECT * FROM test_schema_1.abc;--2 rows
28,31c238,240
<  1 |  
<  2 |  
<  3 |  
< (3 rows)
---
>  2 | 3
>  3 | 5
> (2 rows)
33c242
< SELECT * FROM test_schema_1.abc_view;
---
> SELECT * FROM test_schema_1.abc_view;--2 rows
36,39c245,284
<  2 |  
<  3 |  
<  4 |  
< (3 rows)
---
>  3 | 4
>  4 | 6
> (2 rows)
> 
> SET search_path to test_schema_1, public;
> ALTER SCHEMA test_schema_1 RENAME TO test_schema_2;
> SELECT COUNT(*) FROM pg_class WHERE relnamespace =
>     (SELECT oid FROM pg_namespace WHERE nspname = 'test_schema_1');
>  count 
> -------
>      0
> (1 row)
> 
> SELECT COUNT(*) FROM pg_class WHERE relnamespace =
>     (SELECT oid FROM pg_namespace WHERE nspname = 'test_schema_2');
>  count 
> -------
>      6
> (1 row)
> 
> SELECT * FROM test_schema_2.abc;--2 rows
>  a | b 
> ---+---
>  2 | 3
>  3 | 5
> (2 rows)
> 
> SELECT * FROM test_schema_2.abc_view;--2 rows
>  a | b 
> ---+---
>  3 | 4
>  4 | 6
> (2 rows)
> 
> --The schema name in the search_path should be altered.
> SHOW search_path;
>       search_path      
> -----------------------
>  test_schema_1, public
> (1 row)
42,44c287,292
< NOTICE:  drop cascades to view test_schema_1.abc_view
< NOTICE:  drop cascades to rule _RETURN on view test_schema_1.abc_view
< NOTICE:  drop cascades to table test_schema_1.abc
---
> ERROR:  schema "test_schema_1" does not exist
> 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 sequence test_schema_2.abc_seq
47c295
<     (SELECT oid FROM pg_namespace WHERE nspname = 'test_schema_1');
---
>     (SELECT oid FROM pg_namespace WHERE nspname = 'test_schema_2');
52a301,383
> -- Verify priviledge
> CREATE USER NSTESTER1;
> CREATE USER NSTESTER2;
> CREATE SCHEMA AUTHORIZATION nstester1;
> CREATE SCHEMA schm2 AUTHORIZATION nstester2;
> SET SESSION AUTHORIZATION nstester2;
> --This should fail because of permission denied for schema
> CREATE TABLE nstester1.testtbl ( a int unique);
> ERROR:  permission denied for schema nstester1
> CREATE TABLE schm2.testtbl ( a int unique);--OK
> NOTICE:  CREATE TABLE / UNIQUE will create implicit index "testtbl_a_key" for table "testtbl"
> INSERT INTO schm2.testtbl VALUES (1);--OK
> RESET SESSION AUTHORIZATION;
> SET SESSION AUTHORIZATION nstester1;
> --This should fail because of permission defined for schema
> INSERT INTO schm2.testtbl VALUES (1);--failed as expected
> ERROR:  permission denied for schema schm2
> RESET SESSION AUTHORIZATION;
> GRANT  ALL PRIVILEGES ON SCHEMA schm2 TO nstester1;
> SET SESSION AUTHORIZATION nstester1;
> --This should fail because of permission denied for relation.
> --because the owner of the relaiton testtbl is still nstester2.
> --If didn't fail or failed because of permission denied for schema
> --then somthing wrong with privilege
> INSERT INTO schm2.testtbl VALUES (1);--Denied!
> ERROR:  permission denied for relation testtbl
> RESET SESSION AUTHORIZATION;
> DROP USER nstester1;
> DROP USER nstester2;
> DROP SCHEMA nstester1 CASCADE;
> DROP SCHEMA schm2 CASCADE;
> NOTICE:  drop cascades to table schm2.testtbl
> CREATE USER NSTESTER1;
> CREATE USER NSTESTER2;
> CREATE SCHEMA AUTHORIZATION nstester1;
> CREATE SCHEMA schm2 AUTHORIZATION nstester2;
> GRANT  ALL PRIVILEGES ON SCHEMA schm2 TO nstester1;
> SET SESSION AUTHORIZATION nstester1;
> CREATE TABLE schm2.testtbl ( a int );
> INSERT INTO schm2.testtbl VALUES (1);
> RESET SESSION AUTHORIZATION;
> SET SESSION AUTHORIZATION nstester2;
> --This should fail because of permission denied for relation testtbl
> --because the owner of the relation testtbl is nstester1
> --if didn't fail or failed because of permission defined for schema,
> --then something wrong with privilege
> INSERT INTO schm2.testtbl VALUES (1);
> ERROR:  permission denied for relation testtbl
> RESET SESSION AUTHORIZATION;
> --GRANT  ALL PRIVILEGES ON TABLE testtbl TO nstester2;
> REVOKE ALL PRIVILEGES ON SCHEMA  schm2 FROM nstester1;
> SET SESSION AUTHORIZATION nstester1;
> --This should fail because of  permission denied for schema schm2.
> --If this didn't fail or failed because of permission denied for relation
> --then, something wrong with privilege
> INSERT INTO schm2.testtbl VALUES (1);
> ERROR:  permission denied for schema schm2
> RESET SESSION AUTHORIZATION;
> SET SESSION AUTHORIZATION nstester2;
> --This shoud fail because of permission denied for relation testtbl
> --If this didn't fail or failed because of permission denied for schema
> --then, something wrong with priviledge
> INSERT INTO schm2.testtbl VALUES (1);
> ERROR:  permission denied for relation testtbl
> RESET SESSION AUTHORIZATION;
> ALTER SCHEMA schm2 OWNER TO nstester1;
> SET SESSION AUTHORIZATION nstester1;
> --This should not fail.
> INSERT INTO schm2.testtbl VALUES (1);
> RESET SESSION AUTHORIZATION;
> SET SESSION AUTHORIZATION nstester2;
> --This shoud fail because of permission denied for schema
> --If this didn't fail or failed because of permission denied for other reason
> --then, something wrong with priviledge
> INSERT INTO schm2.testtbl VALUES (1);
> ERROR:  permission denied for schema schm2
> RESET SESSION AUTHORIZATION;
> DROP USER nstester1;
> DROP USER nstester2;
> DROP SCHEMA nstester1 CASCADE;
> DROP SCHEMA schm2 CASCADE;
> NOTICE:  drop cascades to table schm2.testtbl
> set search_path to public;
Index: src/test/regress/sql/namespace.sql
===================================================================
RCS file: /usr/local/cvsroot/pgsql-server/src/test/regress/sql/namespace.sql,v
retrieving revision 1.1
diff -r1.1 namespace.sql
0a1
> -- Validate the relationship between multiple schemas and the search path.
2,3c3,84
< -- Regression tests for schemas (namespaces)
< --
---
> set search_path to public;
> SHOW search_path;--should show only public
> CREATE SCHEMA schm1
> 	CREATE TABLE testschmtbl ( id int primary key, a int unique);
> CREATE SCHEMA schm2
> 	CREATE TABLE testschmtbl ( id int primary key, a int unique);
> CREATE SCHEMA schm3;
> CREATE TABLE schm3.testschmtbl ( id int primary key, a int unique);
> SELECT current_schemas(true);--should show above three schemas
> 
> --This should be an error.
> --Because public.testschmtbl doesn't exist yet.
> INSERT INTO testschmtbl (id, a) VALUES ( 1,1);
> 
> INSERT INTO schm1.testschmtbl (id, a) VALUES ( 1,1);--OK
> 
> -- Create PUBLIC's testschmtbl
> CREATE TABLE testschmtbl ( id int primary key, a int unique);
> --Should not cause any error
> --Because this is PUBLIC's testschmtbl
> INSERT INTO testschmtbl (id, a) VALUES ( 1,1);
> 
> --The following two queries below should be a duplicate error.
> INSERT INTO testschmtbl (id, a) VALUES ( 1,1);--PUBLIC's
> INSERT INTO schm1.testschmtbl (id, a) VALUES ( 1,1);--SCHM1's
> 
> select * from public.testschmtbl;--1 row
> select * from testschmtbl;--1 row. This is PUBLIC's.
> select * from schm1.testschmtbl;--1 row
> select * from schm2.testschmtbl;--0 row
> select * from schm3.testschmtbl;--0 row
> 
> set search_path to schm1, public, schm2, schm3;
> SHOW search_path;
> 
> INSERT INTO testschmtbl (id, a) VALUES ( 2,2);
> INSERT INTO schm1.testschmtbl (id, a) VALUES ( 2,2);--duplicate error
> select * from public.testschmtbl;--1 row
> select * from schm1.testschmtbl;--2 row
> select * from schm2.testschmtbl;--0 row
> select * from schm3.testschmtbl;--0 row
> 
> INSERT INTO public.testschmtbl (id, a) VALUES ( 2,2);--should not be an error
> 
> CREATE TABLE schm2.testschmtbl2( id int primary key, a int unique);
> CREATE TABLE schm3.testschmtbl2( id int primary key, a int unique);
> CREATE TABLE schm3.testschmtbl3( id int primary key, a int unique);
> set search_path to schm2, schm3, public, schm1;
> SHOW search_path;
> 
> --Should not cause any error
> --Insert values into schm2's testschmtbl
> INSERT INTO testschmtbl (id, a) VALUES ( 2,2);
> 
> SET search_path TO schm1, public;
> --Should be an error.
> --Relation testchmtbl2 doesn't exist in the schm1 schema.
> INSERT INTO testchmtbl2 (id, a) VALUES (2,2);
> SET search_path TO schm1, public, schm3, schm2;
> --Should not be an error
> --Insert values into schm3's testschmtbl2
> INSERT INTO testschmtbl2 (id, a) VALUES (2,2);
> select * from schm2.testschmtbl2;--0 row
> select * from schm3.testschmtbl2;--2 rows
> 
> INSERT INTO testschmtbl3 (id, a) VALUES (2,2);--Should not be an error
> select * from schm3.testschmtbl3;-- 1 row
> 
> --DROP TABLE testschmtbl CASCADE;
> set search_path to schm1, public, schm2, schm3;
> BEGIN;
> TRUNCATE testschmtbl;--This should truncate the schm1's testschmtbl
> COMMIT;
> select * from public.testschmtbl;--2 rows
> select * from schm1.testschmtbl;--0 row
> select * from schm2.testschmtbl;--1 row
> select * from schm3.testschmtbl;--0 row
> DROP TABLE public.testschmtbl CASCADE;
> DROP SCHEMA schm1 CASCADE;
> DROP SCHEMA schm2 CASCADE;
> DROP SCHEMA schm3 CASCADE;
> select current_schemas(true);
4a86
> --Verify schema_elements
7a90,91
>        CREATE SEQUENCE abc_seq START WITH 1 INCREMENT BY 2
> 
10a95,100
>        CREATE TRIGGER schmtrigger
>       BEFORE INSERT OR UPDATE ON abc
>        FOR EACH ROW
>        EXECUTE PROCEDURE
>        autoinc(b, abc_seq)
> 
18c108
<     (SELECT oid FROM pg_namespace WHERE nspname = 'test_schema_1');
---
>     (SELECT oid FROM pg_namespace WHERE nspname = 'test_schema_1');--1 row
19a110,111
> --The following query will fail because the schema test_schema_1 is not
> -- on the search_path yet.
20a113,114
> SELECT nextval('test_schema_1.abc_seq');
> set search_path to test_schema_1, public;
24,25c118,134
< SELECT * FROM test_schema_1.abc;
< SELECT * FROM test_schema_1.abc_view;
---
> SELECT * FROM test_schema_1.abc;--2 rows
> SELECT * FROM test_schema_1.abc_view;--2 rows
> 
> SET search_path to test_schema_1, public;
> 
> ALTER SCHEMA test_schema_1 RENAME TO test_schema_2;
> SELECT COUNT(*) FROM pg_class WHERE relnamespace =
>     (SELECT oid FROM pg_namespace WHERE nspname = 'test_schema_1');
> 
> SELECT COUNT(*) FROM pg_class WHERE relnamespace =
>     (SELECT oid FROM pg_namespace WHERE nspname = 'test_schema_2');
> 
> SELECT * FROM test_schema_2.abc;--2 rows
> SELECT * FROM test_schema_2.abc_view;--2 rows
> 
> --The schema name in the search_path should be altered.
> SHOW search_path;
27a137
> DROP SCHEMA test_schema_2 CASCADE;
31c141,233
<     (SELECT oid FROM pg_namespace WHERE nspname = 'test_schema_1');
---
>     (SELECT oid FROM pg_namespace WHERE nspname = 'test_schema_2');
> 
> -- Verify priviledge
> CREATE USER NSTESTER1;
> CREATE USER NSTESTER2;
> CREATE SCHEMA AUTHORIZATION nstester1;
> CREATE SCHEMA schm2 AUTHORIZATION nstester2;
> 
> SET SESSION AUTHORIZATION nstester2;
> --This should fail because of permission denied for schema
> CREATE TABLE nstester1.testtbl ( a int unique);
> CREATE TABLE schm2.testtbl ( a int unique);--OK
> INSERT INTO schm2.testtbl VALUES (1);--OK
> RESET SESSION AUTHORIZATION;
> 
> SET SESSION AUTHORIZATION nstester1;
> --This should fail because of permission defined for schema
> INSERT INTO schm2.testtbl VALUES (1);--failed as expected
> RESET SESSION AUTHORIZATION;
> 
> GRANT  ALL PRIVILEGES ON SCHEMA schm2 TO nstester1;
> 
> SET SESSION AUTHORIZATION nstester1;
> --This should fail because of permission denied for relation.
> --because the owner of the relaiton testtbl is still nstester2.
> --If didn't fail or failed because of permission denied for schema
> --then somthing wrong with privilege
> INSERT INTO schm2.testtbl VALUES (1);--Denied!
> RESET SESSION AUTHORIZATION;
> 
> DROP USER nstester1;
> DROP USER nstester2;
> DROP SCHEMA nstester1 CASCADE;
> DROP SCHEMA schm2 CASCADE;
> 
> CREATE USER NSTESTER1;
> CREATE USER NSTESTER2;
> CREATE SCHEMA AUTHORIZATION nstester1;
> CREATE SCHEMA schm2 AUTHORIZATION nstester2;
> 
> GRANT  ALL PRIVILEGES ON SCHEMA schm2 TO nstester1;
> 
> SET SESSION AUTHORIZATION nstester1;
> CREATE TABLE schm2.testtbl ( a int );
> INSERT INTO schm2.testtbl VALUES (1);
> RESET SESSION AUTHORIZATION;
> 
> SET SESSION AUTHORIZATION nstester2;
> --This should fail because of permission denied for relation testtbl
> --because the owner of the relation testtbl is nstester1
> --if didn't fail or failed because of permission defined for schema,
> --then something wrong with privilege
> INSERT INTO schm2.testtbl VALUES (1);
> RESET SESSION AUTHORIZATION;
> 
> --GRANT  ALL PRIVILEGES ON TABLE testtbl TO nstester2;
> 
> REVOKE ALL PRIVILEGES ON SCHEMA  schm2 FROM nstester1;
> 
> SET SESSION AUTHORIZATION nstester1;
> --This should fail because of  permission denied for schema schm2.
> --If this didn't fail or failed because of permission denied for relation
> --then, something wrong with privilege
> INSERT INTO schm2.testtbl VALUES (1);
> RESET SESSION AUTHORIZATION;
> 
> SET SESSION AUTHORIZATION nstester2;
> --This shoud fail because of permission denied for relation testtbl
> --If this didn't fail or failed because of permission denied for schema
> --then, something wrong with priviledge
> INSERT INTO schm2.testtbl VALUES (1);
> RESET SESSION AUTHORIZATION;
> 
> ALTER SCHEMA schm2 OWNER TO nstester1;
> 
> SET SESSION AUTHORIZATION nstester1;
> --This should not fail.
> INSERT INTO schm2.testtbl VALUES (1);
> RESET SESSION AUTHORIZATION;
> 
> SET SESSION AUTHORIZATION nstester2;
> --This shoud fail because of permission denied for schema
> --If this didn't fail or failed because of permission denied for other reason
> --then, something wrong with priviledge
> INSERT INTO schm2.testtbl VALUES (1);
> RESET SESSION AUTHORIZATION;
> 
> DROP USER nstester1;
> DROP USER nstester2;
> DROP SCHEMA nstester1 CASCADE;
> DROP SCHEMA schm2 CASCADE;
> 
> set search_path to public;
