Changeset 23 for trunk/epic/test/test_globals.sql
- Timestamp:
- 09/07/08 23:57:57 (4 years ago)
- Files:
-
- 1 modified
-
trunk/epic/test/test_globals.sql (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/epic/test/test_globals.sql
r22 r23 4 4 CREATE OR REPLACE FUNCTION test._test_global() RETURNS VOID AS $$ 5 5 DECLARE 6 g text; 7 g2 text; 6 8 rec record; 7 9 trec record; 8 10 BEGIN 9 rec:= global('pg_namespace WHERE nspname = ''test'';');11 g := global('pg_namespace WHERE nspname = ''test'';'); 10 12 11 -- The result of global() should be a normal record. 13 -- The returned string MUST be the name of the TEMP table. 14 PERFORM test.assert(g LIKE E'\_global\_%', g || ' not like _global'); 15 16 rec := get(g); 17 18 -- The result of get() should be a normal record. 12 19 PERFORM test.assert_equal(rec.nspname, 'test'); 13 20 … … 15 22 PERFORM test.assert(rec.__name__ LIKE E'\_global\_%', rec.__name__ || ' not like _global'); 16 23 17 -- The .__name__MUST reference a temporary table with the same fields.18 EXECUTE 'SELECT * FROM ' || rec.__name__INTO trec;24 -- The global MUST reference a temporary table with the same fields. 25 EXECUTE 'SELECT * FROM ' || g INTO trec; 19 26 PERFORM test.assert_equal(trec.nspname, 'test'); 20 27 PERFORM test.assert_equal(trec.nspowner, rec.nspowner); 21 28 PERFORM test.assert_equal(trec.nspacl, rec.nspacl); 22 29 23 -- The returned record MUST possess a .__create__ attribute.24 PERFORM test.assert_equal( rec.__create__, 'SELECT * FROM pg_namespace WHERE nspname = ''test''');30 -- The TEMP table MUST possess its own constructor SQL string in a COMMENT 31 PERFORM test.assert_equal(constructor(g), 'SELECT * FROM pg_namespace WHERE nspname = ''test'''); 25 32 26 -- T he returned record MUST possess a .__record__ attribute.27 PERFORM test.assert_equal(rec.__record__,28 'SELECT * FROM _global_record(''' || rec.__name__ || ''', ''' || rec.__create__ || ''')');33 -- Test the iter() function. 34 g2 := global('iter(''' || g || ''')'); 35 PERFORM test.assert_not_empty(g2); 29 36 30 -- T he returned record MUST possess an .__iter__ attribute.31 PERFORM test.assert_ equal(rec.__iter__, 'SELECT * FROM ' || rec.__name__);32 PERFORM test.assert_not_empty(rec.__iter__);37 -- Test the attributes() function. 38 PERFORM test.assert_column('SELECT attname FROM attributes(''' || g || ''')', 39 ARRAY['nspname', 'nspowner', 'nspacl']); 33 40 34 -- The returned record MUST possess an .__attributes__ attribute. 35 PERFORM test.assert_equal(rec.__attributes__, 'SELECT attname FROM test.attributes(''' || rec.__name__ || ''')'); 36 PERFORM test.assert_column(rec.__attributes__, ARRAY['nspname', 'nspowner', 'nspacl']); 37 38 -- The returned record MUST possess a .__len__ attribute. 39 PERFORM test.assert_equal(rec.__len__, 1); 41 -- Test the len() function. 42 PERFORM test.assert_equal(len(g), 1); 40 43 41 44 -- Raise an exception to test deletion of the TEMP table ON COMMIT 42 RAISE EXCEPTION '%', rec.__name__;45 RAISE EXCEPTION '%', g; 43 46 END; 44 47 $$ LANGUAGE plpgsql;
