~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/test/regress/expected/char_1.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
-- CHAR
 
3
--
 
4
-- fixed-length by value
 
5
-- internally passed by value if <= 4 bytes in storage
 
6
SELECT char 'c' = char 'c' AS true;
 
7
 true 
 
8
------
 
9
 t
 
10
(1 row)
 
11
 
 
12
--
 
13
-- Build a table for testing
 
14
--
 
15
CREATE TABLE CHAR_TBL(f1 char);
 
16
INSERT INTO CHAR_TBL (f1) VALUES ('a');
 
17
INSERT INTO CHAR_TBL (f1) VALUES ('A');
 
18
-- any of the following three input formats are acceptable 
 
19
INSERT INTO CHAR_TBL (f1) VALUES ('1');
 
20
INSERT INTO CHAR_TBL (f1) VALUES (2);
 
21
INSERT INTO CHAR_TBL (f1) VALUES ('3');
 
22
-- zero-length char 
 
23
INSERT INTO CHAR_TBL (f1) VALUES ('');
 
24
-- try char's of greater than 1 length 
 
25
INSERT INTO CHAR_TBL (f1) VALUES ('cd');
 
26
ERROR:  value too long for type character(1)
 
27
INSERT INTO CHAR_TBL (f1) VALUES ('c     ');
 
28
SELECT '' AS seven, CHAR_TBL.*;
 
29
 seven | f1 
 
30
-------+----
 
31
       | a
 
32
       | A
 
33
       | 1
 
34
       | 2
 
35
       | 3
 
36
       |  
 
37
       | c
 
38
(7 rows)
 
39
 
 
40
SELECT '' AS six, c.*
 
41
   FROM CHAR_TBL c
 
42
   WHERE c.f1 <> 'a';
 
43
 six | f1 
 
44
-----+----
 
45
     | A
 
46
     | 1
 
47
     | 2
 
48
     | 3
 
49
     |  
 
50
     | c
 
51
(6 rows)
 
52
 
 
53
SELECT '' AS one, c.*
 
54
   FROM CHAR_TBL c
 
55
   WHERE c.f1 = 'a';
 
56
 one | f1 
 
57
-----+----
 
58
     | a
 
59
(1 row)
 
60
 
 
61
SELECT '' AS five, c.*
 
62
   FROM CHAR_TBL c
 
63
   WHERE c.f1 < 'a';
 
64
 five | f1 
 
65
------+----
 
66
      | 1
 
67
      | 2
 
68
      | 3
 
69
      |  
 
70
(4 rows)
 
71
 
 
72
SELECT '' AS six, c.*
 
73
   FROM CHAR_TBL c
 
74
   WHERE c.f1 <= 'a';
 
75
 six | f1 
 
76
-----+----
 
77
     | a
 
78
     | 1
 
79
     | 2
 
80
     | 3
 
81
     |  
 
82
(5 rows)
 
83
 
 
84
SELECT '' AS one, c.*
 
85
   FROM CHAR_TBL c
 
86
   WHERE c.f1 > 'a';
 
87
 one | f1 
 
88
-----+----
 
89
     | A
 
90
     | c
 
91
(2 rows)
 
92
 
 
93
SELECT '' AS two, c.*
 
94
   FROM CHAR_TBL c
 
95
   WHERE c.f1 >= 'a';
 
96
 two | f1 
 
97
-----+----
 
98
     | a
 
99
     | A
 
100
     | c
 
101
(3 rows)
 
102
 
 
103
DROP TABLE CHAR_TBL;
 
104
--
 
105
-- Now test longer arrays of char
 
106
--
 
107
CREATE TABLE CHAR_TBL(f1 char(4));
 
108
INSERT INTO CHAR_TBL (f1) VALUES ('a');
 
109
INSERT INTO CHAR_TBL (f1) VALUES ('ab');
 
110
INSERT INTO CHAR_TBL (f1) VALUES ('abcd');
 
111
INSERT INTO CHAR_TBL (f1) VALUES ('abcde');
 
112
ERROR:  value too long for type character(4)
 
113
INSERT INTO CHAR_TBL (f1) VALUES ('abcd    ');
 
114
SELECT '' AS four, CHAR_TBL.*;
 
115
 four |  f1  
 
116
------+------
 
117
      | a   
 
118
      | ab  
 
119
      | abcd
 
120
      | abcd
 
121
(4 rows)
 
122