~ubuntu-branches/ubuntu/hardy/postgresql-8.4/hardy-backports

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-03-20 12:00:13 UTC
  • Revision ID: james.westby@ubuntu.com-20090320120013-hogj7egc5mjncc5g
Tags: upstream-8.4~0cvs20090328
ImportĀ upstreamĀ versionĀ 8.4~0cvs20090328

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, * FROM 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
      |  
 
67
(1 row)
 
68
 
 
69
SELECT '' AS six, c.*
 
70
   FROM CHAR_TBL c
 
71
   WHERE c.f1 <= 'a';
 
72
 six | f1 
 
73
-----+----
 
74
     | a
 
75
     |  
 
76
(2 rows)
 
77
 
 
78
SELECT '' AS one, c.*
 
79
   FROM CHAR_TBL c
 
80
   WHERE c.f1 > 'a';
 
81
 one | f1 
 
82
-----+----
 
83
     | A
 
84
     | 1
 
85
     | 2
 
86
     | 3
 
87
     | c
 
88
(5 rows)
 
89
 
 
90
SELECT '' AS two, c.*
 
91
   FROM CHAR_TBL c
 
92
   WHERE c.f1 >= 'a';
 
93
 two | f1 
 
94
-----+----
 
95
     | a
 
96
     | A
 
97
     | 1
 
98
     | 2
 
99
     | 3
 
100
     | c
 
101
(6 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, * FROM CHAR_TBL;
 
115
 four |  f1  
 
116
------+------
 
117
      | a   
 
118
      | ab  
 
119
      | abcd
 
120
      | abcd
 
121
(4 rows)
 
122