4 -- fixed-length by value
5 -- internally passed by value if <= 4 bytes in storage
6 SELECT char 'c' = char 'c' AS true;
13 -- Build a table for testing
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');
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;
61 SELECT '' AS five, c.*
105 -- Now test longer arrays of char
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;