~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/test/regress/expected/create_type.out

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--
 
2
-- CREATE_TYPE
 
3
--
 
4
CREATE TYPE widget (
 
5
   internallength = 24, 
 
6
   input = widget_in,
 
7
   output = widget_out,
 
8
   alignment = double
 
9
);
 
10
CREATE TYPE city_budget ( 
 
11
   internallength = 16, 
 
12
   input = int44in, 
 
13
   output = int44out, 
 
14
   element = int4
 
15
);
 
16
-- Test type-related default values (broken in releases before PG 7.2)
 
17
-- Make dummy I/O routines using the existing internal support for int4, text
 
18
CREATE FUNCTION int42_in(cstring)
 
19
   RETURNS int42
 
20
   AS 'int4in'
 
21
   LANGUAGE 'internal' WITH (isStrict);
 
22
NOTICE:  type "int42" is not yet defined
 
23
DETAIL:  Creating a shell type definition.
 
24
CREATE FUNCTION int42_out(int42)
 
25
   RETURNS cstring
 
26
   AS 'int4out'
 
27
   LANGUAGE 'internal' WITH (isStrict);
 
28
NOTICE:  argument type int42 is only a shell
 
29
CREATE FUNCTION text_w_default_in(cstring)
 
30
   RETURNS text_w_default
 
31
   AS 'textin'
 
32
   LANGUAGE 'internal' WITH (isStrict);
 
33
NOTICE:  type "text_w_default" is not yet defined
 
34
DETAIL:  Creating a shell type definition.
 
35
CREATE FUNCTION text_w_default_out(text_w_default)
 
36
   RETURNS cstring
 
37
   AS 'textout'
 
38
   LANGUAGE 'internal' WITH (isStrict);
 
39
NOTICE:  argument type text_w_default is only a shell
 
40
CREATE TYPE int42 (
 
41
   internallength = 4,
 
42
   input = int42_in,
 
43
   output = int42_out,
 
44
   alignment = int4,
 
45
   default = 42,
 
46
   passedbyvalue
 
47
);
 
48
CREATE TYPE text_w_default (
 
49
   internallength = variable,
 
50
   input = text_w_default_in,
 
51
   output = text_w_default_out,
 
52
   alignment = int4,
 
53
   default = 'zippo'
 
54
);
 
55
CREATE TABLE default_test (f1 text_w_default, f2 int42);
 
56
INSERT INTO default_test DEFAULT VALUES;
 
57
SELECT * FROM default_test;
 
58
  f1   | f2 
 
59
-------+----
 
60
 zippo | 42
 
61
(1 row)
 
62
 
 
63
-- Test stand-alone composite type
 
64
CREATE TYPE default_test_row AS (f1 text_w_default, f2 int42);
 
65
CREATE FUNCTION get_default_test() RETURNS SETOF default_test_row AS '
 
66
  SELECT * FROM default_test;
 
67
' LANGUAGE SQL;
 
68
SELECT * FROM get_default_test();
 
69
  f1   | f2 
 
70
-------+----
 
71
 zippo | 42
 
72
(1 row)
 
73
 
 
74
-- Test comments
 
75
COMMENT ON TYPE bad IS 'bad comment';
 
76
ERROR:  type "bad" does not exist
 
77
COMMENT ON TYPE default_test_row IS 'good comment';
 
78
COMMENT ON TYPE default_test_row IS NULL;
 
79
DROP TYPE default_test_row CASCADE;
 
80
NOTICE:  drop cascades to function get_default_test()
 
81
DROP TABLE default_test;