mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-08-26 04:17:19 +02:00
in UPDATE. We also now issue a NOTICE if a query has _any_ implicit range table entries -- in the past, we would only warn about implicit RTEs in SELECTs with at least one explicit RTE. As a result of the warning change, 25 of the regression tests had to be updated. I also took the opportunity to remove some bogus whitespace differences between some of the float4 and float8 variants. I believe I have correctly updated all the platform-specific variants, but let me know if that's not the case. Original patch for DELETE ... USING from Euler Taveira de Oliveira, reworked by Neil Conway.
123 lines
2.1 KiB
Plaintext
123 lines
2.1 KiB
Plaintext
--
|
|
-- CHAR
|
|
--
|
|
-- fixed-length by value
|
|
-- internally passed by value if <= 4 bytes in storage
|
|
SELECT char 'c' = char 'c' AS true;
|
|
true
|
|
------
|
|
t
|
|
(1 row)
|
|
|
|
--
|
|
-- Build a table for testing
|
|
--
|
|
CREATE TABLE CHAR_TBL(f1 char);
|
|
INSERT INTO CHAR_TBL (f1) VALUES ('a');
|
|
INSERT INTO CHAR_TBL (f1) VALUES ('A');
|
|
-- any of the following three input formats are acceptable
|
|
INSERT INTO CHAR_TBL (f1) VALUES ('1');
|
|
INSERT INTO CHAR_TBL (f1) VALUES (2);
|
|
INSERT INTO CHAR_TBL (f1) VALUES ('3');
|
|
-- zero-length char
|
|
INSERT INTO CHAR_TBL (f1) VALUES ('');
|
|
-- try char's of greater than 1 length
|
|
INSERT INTO CHAR_TBL (f1) VALUES ('cd');
|
|
ERROR: value too long for type character(1)
|
|
INSERT INTO CHAR_TBL (f1) VALUES ('c ');
|
|
SELECT '' AS seven, * FROM CHAR_TBL;
|
|
seven | f1
|
|
-------+----
|
|
| a
|
|
| A
|
|
| 1
|
|
| 2
|
|
| 3
|
|
|
|
|
| c
|
|
(7 rows)
|
|
|
|
SELECT '' AS six, c.*
|
|
FROM CHAR_TBL c
|
|
WHERE c.f1 <> 'a';
|
|
six | f1
|
|
-----+----
|
|
| A
|
|
| 1
|
|
| 2
|
|
| 3
|
|
|
|
|
| c
|
|
(6 rows)
|
|
|
|
SELECT '' AS one, c.*
|
|
FROM CHAR_TBL c
|
|
WHERE c.f1 = 'a';
|
|
one | f1
|
|
-----+----
|
|
| a
|
|
(1 row)
|
|
|
|
SELECT '' AS five, c.*
|
|
FROM CHAR_TBL c
|
|
WHERE c.f1 < 'a';
|
|
five | f1
|
|
------+----
|
|
| 1
|
|
| 2
|
|
| 3
|
|
|
|
|
(4 rows)
|
|
|
|
SELECT '' AS six, c.*
|
|
FROM CHAR_TBL c
|
|
WHERE c.f1 <= 'a';
|
|
six | f1
|
|
-----+----
|
|
| a
|
|
| 1
|
|
| 2
|
|
| 3
|
|
|
|
|
(5 rows)
|
|
|
|
SELECT '' AS one, c.*
|
|
FROM CHAR_TBL c
|
|
WHERE c.f1 > 'a';
|
|
one | f1
|
|
-----+----
|
|
| A
|
|
| c
|
|
(2 rows)
|
|
|
|
SELECT '' AS two, c.*
|
|
FROM CHAR_TBL c
|
|
WHERE c.f1 >= 'a';
|
|
two | f1
|
|
-----+----
|
|
| a
|
|
| A
|
|
| c
|
|
(3 rows)
|
|
|
|
DROP TABLE CHAR_TBL;
|
|
--
|
|
-- Now test longer arrays of char
|
|
--
|
|
CREATE TABLE CHAR_TBL(f1 char(4));
|
|
INSERT INTO CHAR_TBL (f1) VALUES ('a');
|
|
INSERT INTO CHAR_TBL (f1) VALUES ('ab');
|
|
INSERT INTO CHAR_TBL (f1) VALUES ('abcd');
|
|
INSERT INTO CHAR_TBL (f1) VALUES ('abcde');
|
|
ERROR: value too long for type character(4)
|
|
INSERT INTO CHAR_TBL (f1) VALUES ('abcd ');
|
|
SELECT '' AS four, * FROM CHAR_TBL;
|
|
four | f1
|
|
------+------
|
|
| a
|
|
| ab
|
|
| abcd
|
|
| abcd
|
|
(4 rows)
|
|
|