diff options
| author | Tom Lane | 2003-11-21 22:32:49 +0000 |
|---|---|---|
| committer | Tom Lane | 2003-11-21 22:32:49 +0000 |
| commit | 42ce74bf17478cc8a8323601deaa63950dda9923 (patch) | |
| tree | 917bf7d6c05971885302cd43b8c60c16c7e12bab /src/test | |
| parent | 0a97cb37fc29dac05fd5aa13df91ba8431faea23 (diff) | |
COMMENT ON casts, conversions, languages, operator classes, and
large objects. Dump all these in pg_dump; also add code to pg_dump
user-defined conversions. Make psql's large object code rely on
the backend for inserting/deleting LOB comments, instead of trying to
hack pg_description directly. Documentation and regression tests added.
Christopher Kings-Lynne, code reviewed by Tom
Diffstat (limited to 'src/test')
24 files changed, 124 insertions, 2 deletions
diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out index 61a3965fe59..cc50cb86dae 100644 --- a/src/test/regress/expected/alter_table.out +++ b/src/test/regress/expected/alter_table.out @@ -3,6 +3,10 @@ -- add attribute -- CREATE TABLE tmp (initial int4); +COMMENT ON TABLE tmp_wrong IS 'table comment'; +ERROR: relation "tmp_wrong" does not exist +COMMENT ON TABLE tmp IS 'table comment'; +COMMENT ON TABLE tmp IS NULL; ALTER TABLE tmp ADD COLUMN a int4; ALTER TABLE tmp ADD COLUMN b name; ALTER TABLE tmp ADD COLUMN c text; diff --git a/src/test/regress/expected/conversion.out b/src/test/regress/expected/conversion.out index 289bd0a27f1..c0e85b85a1d 100644 --- a/src/test/regress/expected/conversion.out +++ b/src/test/regress/expected/conversion.out @@ -18,6 +18,11 @@ CREATE DEFAULT CONVERSION public.mydef FOR 'LATIN1' TO 'UNICODE' FROM iso8859_1_ -- CREATE DEFAULT CONVERSION public.mydef2 FOR 'LATIN1' TO 'UNICODE' FROM iso8859_1_to_utf8; ERROR: default conversion for LATIN1 to UNICODE already exists +-- test comments +COMMENT ON CONVERSION myconv_bad IS 'foo'; +ERROR: conversion "myconv_bad" does not exist +COMMENT ON CONVERSION myconv IS 'bar'; +COMMENT ON CONVERSION myconv IS NULL; -- -- drop user defined conversion -- diff --git a/src/test/regress/expected/create_aggregate.out b/src/test/regress/expected/create_aggregate.out index ef83c886a11..b0fec460cbb 100644 --- a/src/test/regress/expected/create_aggregate.out +++ b/src/test/regress/expected/create_aggregate.out @@ -7,6 +7,11 @@ CREATE AGGREGATE newavg ( finalfunc = numeric_avg, initcond1 = '{0,0,0}' ); +-- test comments +COMMENT ON AGGREGATE newavg_wrong (int4) IS 'an agg comment'; +ERROR: aggregate newavg_wrong(integer) does not exist +COMMENT ON AGGREGATE newavg (int4) IS 'an agg comment'; +COMMENT ON AGGREGATE newavg (int4) IS NULL; -- without finalfunc; test obsolete spellings 'sfunc1' etc CREATE AGGREGATE newsum ( sfunc1 = int4pl, basetype = int4, stype1 = int4, @@ -17,3 +22,7 @@ CREATE AGGREGATE newcnt ( sfunc = int4inc, basetype = 'any', stype = int4, initcond = '0' ); +COMMENT ON AGGREGATE nosuchagg (*) IS 'should fail'; +ERROR: aggregate nosuchagg(*) does not exist +COMMENT ON AGGREGATE newcnt (*) IS 'an any agg comment'; +COMMENT ON AGGREGATE newcnt (*) IS NULL; diff --git a/src/test/regress/expected/create_index.out b/src/test/regress/expected/create_index.out index 46d2657d015..6643070e717 100644 --- a/src/test/regress/expected/create_index.out +++ b/src/test/regress/expected/create_index.out @@ -18,6 +18,11 @@ CREATE INDEX tenk2_hundred ON tenk2 USING btree(hundred int4_ops); CREATE INDEX rix ON road USING btree (name text_ops); CREATE INDEX iix ON ihighway USING btree (name text_ops); CREATE INDEX six ON shighway USING btree (name text_ops); +-- test comments +COMMENT ON INDEX six_wrong IS 'bad index'; +ERROR: relation "six_wrong" does not exist +COMMENT ON INDEX six IS 'good index'; +COMMENT ON INDEX six IS NULL; -- -- BTREE ascending/descending cases -- diff --git a/src/test/regress/expected/create_operator.out b/src/test/regress/expected/create_operator.out index 2338b7c7108..7685dbe802c 100644 --- a/src/test/regress/expected/create_operator.out +++ b/src/test/regress/expected/create_operator.out @@ -26,3 +26,8 @@ CREATE OPERATOR #%# ( leftarg = int4, -- right unary procedure = int4fac ); +-- Test comments +COMMENT ON OPERATOR ###### (int4, NONE) IS 'bad right unary'; +ERROR: operator does not exist: integer ###### +COMMENT ON OPERATOR #%# (int4, NONE) IS 'right unary'; +COMMENT ON OPERATOR #%# (int4, NONE) IS NULL; diff --git a/src/test/regress/expected/create_type.out b/src/test/regress/expected/create_type.out index 210da92cf2d..101382e7392 100644 --- a/src/test/regress/expected/create_type.out +++ b/src/test/regress/expected/create_type.out @@ -71,6 +71,11 @@ SELECT * FROM get_default_test(); zippo | 42 (1 row) +-- Test comments +COMMENT ON TYPE bad IS 'bad comment'; +ERROR: type "bad" does not exist +COMMENT ON TYPE default_test_row IS 'good comment'; +COMMENT ON TYPE default_test_row IS NULL; DROP TYPE default_test_row CASCADE; NOTICE: drop cascades to function get_default_test() DROP TABLE default_test; diff --git a/src/test/regress/expected/create_view.out b/src/test/regress/expected/create_view.out index 630855ed37c..04e62f70846 100644 --- a/src/test/regress/expected/create_view.out +++ b/src/test/regress/expected/create_view.out @@ -15,6 +15,11 @@ CREATE VIEW iexit AS CREATE VIEW toyemp AS SELECT name, age, location, 12*salary AS annualsal FROM emp; +-- Test comments +COMMENT ON VIEW noview IS 'no view'; +ERROR: relation "noview" does not exist +COMMENT ON VIEW toyemp IS 'is a view'; +COMMENT ON VIEW toyemp IS NULL; -- -- CREATE OR REPLACE VIEW -- diff --git a/src/test/regress/expected/foreign_key.out b/src/test/regress/expected/foreign_key.out index bfb90979f68..57a4ae16471 100644 --- a/src/test/regress/expected/foreign_key.out +++ b/src/test/regress/expected/foreign_key.out @@ -64,6 +64,11 @@ CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, ptest3 text, PRIMARY KEY(ptest1, NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "pktable_pkey" for table "pktable" CREATE TABLE FKTABLE ( ftest1 int, ftest2 int, ftest3 int, CONSTRAINT constrname FOREIGN KEY(ftest1, ftest2) REFERENCES PKTABLE MATCH FULL ON DELETE SET NULL ON UPDATE SET NULL); +-- Test comments +COMMENT ON CONSTRAINT constrname_wrong ON FKTABLE IS 'fk constraint comment'; +ERROR: constraint "constrname_wrong" for table "fktable" does not exist +COMMENT ON CONSTRAINT constrname ON FKTABLE IS 'fk constraint comment'; +COMMENT ON CONSTRAINT constrname ON FKTABLE IS NULL; -- Insert test data into PKTABLE INSERT INTO PKTABLE VALUES (1, 2, 'Test1'); INSERT INTO PKTABLE VALUES (1, 3, 'Test1-2'); diff --git a/src/test/regress/expected/plpgsql.out b/src/test/regress/expected/plpgsql.out index a7a380b5c6c..694165e506a 100644 --- a/src/test/regress/expected/plpgsql.out +++ b/src/test/regress/expected/plpgsql.out @@ -264,6 +264,11 @@ begin return 0; end; ' language 'plpgsql'; +-- Test comments +COMMENT ON FUNCTION tg_hub_adjustslots_wrong(bpchar, integer, integer) IS 'function with args'; +ERROR: function tg_hub_adjustslots_wrong(character, integer, integer) does not exist +COMMENT ON FUNCTION tg_hub_adjustslots(bpchar, integer, integer) IS 'function with args'; +COMMENT ON FUNCTION tg_hub_adjustslots(bpchar, integer, integer) IS NULL; -- ************************************************************ -- * BEFORE INSERT or UPDATE on HSlot -- * - prevent from manual manipulation diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out index 7ae49e8b442..ae7d0feea63 100644 --- a/src/test/regress/expected/rules.out +++ b/src/test/regress/expected/rules.out @@ -17,6 +17,11 @@ create rule rtest_v1_upd as on update to rtest_v1 do instead where a = old.a; create rule rtest_v1_del as on delete to rtest_v1 do instead delete from rtest_t1 where a = old.a; +-- Test comments +COMMENT ON RULE rtest_v1_bad ON rtest_v1 IS 'bad rule'; +ERROR: rule "rtest_v1_bad" for relation "rtest_v1" does not exist +COMMENT ON RULE rtest_v1_del ON rtest_v1 IS 'delete rule'; +COMMENT ON RULE rtest_v1_del ON rtest_v1 IS NULL; -- -- Tables and rules for the constraint update/delete test -- diff --git a/src/test/regress/expected/sequence.out b/src/test/regress/expected/sequence.out index 49b783a805a..d09e5db1701 100644 --- a/src/test/regress/expected/sequence.out +++ b/src/test/regress/expected/sequence.out @@ -71,3 +71,8 @@ SELECT nextval('sequence_test2'); 5 (1 row) +-- Test comments +COMMENT ON SEQUENCE asdf IS 'won''t work'; +ERROR: relation "asdf" does not exist +COMMENT ON SEQUENCE sequence_test2 IS 'will work'; +COMMENT ON SEQUENCE sequence_test2 IS NULL; diff --git a/src/test/regress/expected/triggers.out b/src/test/regress/expected/triggers.out index 086c9f602c8..c44a81a75f8 100644 --- a/src/test/regress/expected/triggers.out +++ b/src/test/regress/expected/triggers.out @@ -37,6 +37,11 @@ create trigger check_fkeys2_pkey_exist for each row execute procedure check_primary_key ('fkey21', 'fkey22', 'pkeys', 'pkey1', 'pkey2'); +-- Test comments +COMMENT ON TRIGGER check_fkeys2_pkey_bad ON fkeys2 IS 'wrong'; +ERROR: trigger "check_fkeys2_pkey_bad" for table "fkeys2" does not exist +COMMENT ON TRIGGER check_fkeys2_pkey_exist ON fkeys2 IS 'right'; +COMMENT ON TRIGGER check_fkeys2_pkey_exist ON fkeys2 IS NULL; -- -- For pkeys: -- ON DELETE/UPDATE (pkey1, pkey2) CASCADE: diff --git a/src/test/regress/sql/alter_table.sql b/src/test/regress/sql/alter_table.sql index 9bdc8cd1eaf..33187c83526 100644 --- a/src/test/regress/sql/alter_table.sql +++ b/src/test/regress/sql/alter_table.sql @@ -5,6 +5,10 @@ CREATE TABLE tmp (initial int4); +COMMENT ON TABLE tmp_wrong IS 'table comment'; +COMMENT ON TABLE tmp IS 'table comment'; +COMMENT ON TABLE tmp IS NULL; + ALTER TABLE tmp ADD COLUMN a int4; ALTER TABLE tmp ADD COLUMN b name; diff --git a/src/test/regress/sql/conversion.sql b/src/test/regress/sql/conversion.sql index 979a7cc0fdd..c84ffee95fe 100644 --- a/src/test/regress/sql/conversion.sql +++ b/src/test/regress/sql/conversion.sql @@ -16,6 +16,10 @@ CREATE DEFAULT CONVERSION public.mydef FOR 'LATIN1' TO 'UNICODE' FROM iso8859_1_ -- cannot make default conversion with same shcema/for_encoding/to_encoding -- CREATE DEFAULT CONVERSION public.mydef2 FOR 'LATIN1' TO 'UNICODE' FROM iso8859_1_to_utf8; +-- test comments +COMMENT ON CONVERSION myconv_bad IS 'foo'; +COMMENT ON CONVERSION myconv IS 'bar'; +COMMENT ON CONVERSION myconv IS NULL; -- -- drop user defined conversion -- diff --git a/src/test/regress/sql/create_aggregate.sql b/src/test/regress/sql/create_aggregate.sql index 5d42ed057e3..4188760c87c 100644 --- a/src/test/regress/sql/create_aggregate.sql +++ b/src/test/regress/sql/create_aggregate.sql @@ -9,6 +9,11 @@ CREATE AGGREGATE newavg ( initcond1 = '{0,0,0}' ); +-- test comments +COMMENT ON AGGREGATE newavg_wrong (int4) IS 'an agg comment'; +COMMENT ON AGGREGATE newavg (int4) IS 'an agg comment'; +COMMENT ON AGGREGATE newavg (int4) IS NULL; + -- without finalfunc; test obsolete spellings 'sfunc1' etc CREATE AGGREGATE newsum ( sfunc1 = int4pl, basetype = int4, stype1 = int4, @@ -21,3 +26,6 @@ CREATE AGGREGATE newcnt ( initcond = '0' ); +COMMENT ON AGGREGATE nosuchagg (*) IS 'should fail'; +COMMENT ON AGGREGATE newcnt (*) IS 'an any agg comment'; +COMMENT ON AGGREGATE newcnt (*) IS NULL; diff --git a/src/test/regress/sql/create_index.sql b/src/test/regress/sql/create_index.sql index d904bacd66b..6fa0b91e83c 100644 --- a/src/test/regress/sql/create_index.sql +++ b/src/test/regress/sql/create_index.sql @@ -32,6 +32,11 @@ CREATE INDEX iix ON ihighway USING btree (name text_ops); CREATE INDEX six ON shighway USING btree (name text_ops); +-- test comments +COMMENT ON INDEX six_wrong IS 'bad index'; +COMMENT ON INDEX six IS 'good index'; +COMMENT ON INDEX six IS NULL; + -- -- BTREE ascending/descending cases -- diff --git a/src/test/regress/sql/create_operator.sql b/src/test/regress/sql/create_operator.sql index c4251144ca3..4167bf3ab82 100644 --- a/src/test/regress/sql/create_operator.sql +++ b/src/test/regress/sql/create_operator.sql @@ -32,3 +32,9 @@ CREATE OPERATOR #%# ( procedure = int4fac ); +-- Test comments +COMMENT ON OPERATOR ###### (int4, NONE) IS 'bad right unary'; +COMMENT ON OPERATOR #%# (int4, NONE) IS 'right unary'; +COMMENT ON OPERATOR #%# (int4, NONE) IS NULL; + + diff --git a/src/test/regress/sql/create_type.sql b/src/test/regress/sql/create_type.sql index ddcba72624e..6e8fa84b7dc 100644 --- a/src/test/regress/sql/create_type.sql +++ b/src/test/regress/sql/create_type.sql @@ -69,6 +69,11 @@ CREATE FUNCTION get_default_test() RETURNS SETOF default_test_row AS ' SELECT * FROM get_default_test(); +-- Test comments +COMMENT ON TYPE bad IS 'bad comment'; +COMMENT ON TYPE default_test_row IS 'good comment'; +COMMENT ON TYPE default_test_row IS NULL; + DROP TYPE default_test_row CASCADE; DROP TABLE default_test; diff --git a/src/test/regress/sql/create_view.sql b/src/test/regress/sql/create_view.sql index 8c15fc12417..acc82b3e0e0 100644 --- a/src/test/regress/sql/create_view.sql +++ b/src/test/regress/sql/create_view.sql @@ -19,6 +19,11 @@ CREATE VIEW toyemp AS SELECT name, age, location, 12*salary AS annualsal FROM emp; +-- Test comments +COMMENT ON VIEW noview IS 'no view'; +COMMENT ON VIEW toyemp IS 'is a view'; +COMMENT ON VIEW toyemp IS NULL; + -- -- CREATE OR REPLACE VIEW -- diff --git a/src/test/regress/sql/foreign_key.sql b/src/test/regress/sql/foreign_key.sql index 009588db065..10e4da0baf0 100644 --- a/src/test/regress/sql/foreign_key.sql +++ b/src/test/regress/sql/foreign_key.sql @@ -50,6 +50,11 @@ CREATE TABLE PKTABLE ( ptest1 int, ptest2 int, ptest3 text, PRIMARY KEY(ptest1, CREATE TABLE FKTABLE ( ftest1 int, ftest2 int, ftest3 int, CONSTRAINT constrname FOREIGN KEY(ftest1, ftest2) REFERENCES PKTABLE MATCH FULL ON DELETE SET NULL ON UPDATE SET NULL); +-- Test comments +COMMENT ON CONSTRAINT constrname_wrong ON FKTABLE IS 'fk constraint comment'; +COMMENT ON CONSTRAINT constrname ON FKTABLE IS 'fk constraint comment'; +COMMENT ON CONSTRAINT constrname ON FKTABLE IS NULL; + -- Insert test data into PKTABLE INSERT INTO PKTABLE VALUES (1, 2, 'Test1'); INSERT INTO PKTABLE VALUES (1, 3, 'Test1-2'); diff --git a/src/test/regress/sql/plpgsql.sql b/src/test/regress/sql/plpgsql.sql index b4d0186458d..9cb7f7c9407 100644 --- a/src/test/regress/sql/plpgsql.sql +++ b/src/test/regress/sql/plpgsql.sql @@ -326,6 +326,10 @@ begin end; ' language 'plpgsql'; +-- Test comments +COMMENT ON FUNCTION tg_hub_adjustslots_wrong(bpchar, integer, integer) IS 'function with args'; +COMMENT ON FUNCTION tg_hub_adjustslots(bpchar, integer, integer) IS 'function with args'; +COMMENT ON FUNCTION tg_hub_adjustslots(bpchar, integer, integer) IS NULL; -- ************************************************************ -- * BEFORE INSERT or UPDATE on HSlot @@ -1603,4 +1607,4 @@ END;' language 'plpgsql'; SELECT perform_test_func(); SELECT * FROM perform_test; -drop table perform_test;
\ No newline at end of file +drop table perform_test; diff --git a/src/test/regress/sql/rules.sql b/src/test/regress/sql/rules.sql index d797144d9d1..55c3805bd5f 100644 --- a/src/test/regress/sql/rules.sql +++ b/src/test/regress/sql/rules.sql @@ -19,7 +19,10 @@ create rule rtest_v1_upd as on update to rtest_v1 do instead where a = old.a; create rule rtest_v1_del as on delete to rtest_v1 do instead delete from rtest_t1 where a = old.a; - +-- Test comments +COMMENT ON RULE rtest_v1_bad ON rtest_v1 IS 'bad rule'; +COMMENT ON RULE rtest_v1_del ON rtest_v1 IS 'delete rule'; +COMMENT ON RULE rtest_v1_del ON rtest_v1 IS NULL; -- -- Tables and rules for the constraint update/delete test -- diff --git a/src/test/regress/sql/sequence.sql b/src/test/regress/sql/sequence.sql index 6f3c1f22ddb..07f5765faf2 100644 --- a/src/test/regress/sql/sequence.sql +++ b/src/test/regress/sql/sequence.sql @@ -37,3 +37,8 @@ SELECT nextval('sequence_test2'); SELECT nextval('sequence_test2'); SELECT nextval('sequence_test2'); +-- Test comments +COMMENT ON SEQUENCE asdf IS 'won''t work'; +COMMENT ON SEQUENCE sequence_test2 IS 'will work'; +COMMENT ON SEQUENCE sequence_test2 IS NULL; + diff --git a/src/test/regress/sql/triggers.sql b/src/test/regress/sql/triggers.sql index 37bfb3bfd57..f766e625545 100644 --- a/src/test/regress/sql/triggers.sql +++ b/src/test/regress/sql/triggers.sql @@ -44,6 +44,11 @@ create trigger check_fkeys2_pkey_exist execute procedure check_primary_key ('fkey21', 'fkey22', 'pkeys', 'pkey1', 'pkey2'); +-- Test comments +COMMENT ON TRIGGER check_fkeys2_pkey_bad ON fkeys2 IS 'wrong'; +COMMENT ON TRIGGER check_fkeys2_pkey_exist ON fkeys2 IS 'right'; +COMMENT ON TRIGGER check_fkeys2_pkey_exist ON fkeys2 IS NULL; + -- -- For pkeys: -- ON DELETE/UPDATE (pkey1, pkey2) CASCADE: |
