Commit 5812d512 authored by Thomas G. Lockhart's avatar Thomas G. Lockhart

Add test for UNION.

Add additional tests in strings for conversions of the "name" data type.
Test SQL92 string functions such as SUBSTRING() and POSITION().
parent 3955d668
...@@ -11,13 +11,60 @@ SELECT 'first line' ...@@ -11,13 +11,60 @@ SELECT 'first line'
-- illegal string continuation syntax -- illegal string continuation syntax
SELECT 'first line' SELECT 'first line'
' - next line' /* this comment is not allowed here */ ' - next line' /* this comment is not allowed here */
' - third line'; ' - third line'
AS "Illegal comment within continuation";
-- --
-- test conversions between various string types -- test conversions between various string types
-- --
SELECT text(f1) FROM CHAR_TBL; SELECT CAST(f1 AS text) AS "text(char)" FROM CHAR_TBL;
SELECT text(f1) FROM VARCHAR_TBL; SELECT CAST(f1 AS text) AS "text(varchar)" FROM VARCHAR_TBL;
SELECT CAST(name 'namefield' AS text) AS "text(name)";
SELECT CAST(f1 AS char) AS "char(text)" FROM TEXT_TBL;
SELECT CAST(f1 AS char) AS "char(varchar)" FROM VARCHAR_TBL;
SELECT CAST(name 'namefield' AS char) AS "char(name)";
SELECT CAST(f1 AS varchar) AS "varchar(text)" FROM TEXT_TBL;
SELECT CAST(f1 AS varchar) AS "varchar(char)" FROM CHAR_TBL;
SELECT CAST(name 'namefield' AS varchar) AS "varchar(name)";
--
-- test SQL92 string functions
--
SELECT TRIM(BOTH FROM ' bunch o blanks ') AS "bunch o blanks";
SELECT TRIM(LEADING FROM ' bunch o blanks ') AS "bunch o blanks ";
SELECT TRIM(TRAILING FROM ' bunch o blanks ') AS " bunch o blanks";
SELECT TRIM(BOTH 'x' FROM 'xxxxxsome Xsxxxxx') AS "some Xs";
SELECT SUBSTRING('1234567890' FROM 3) AS "34567890";
SELECT SUBSTRING('1234567890' FROM 4 FOR 3) AS "456";
SELECT POSITION('4' IN '1234567890') AS "4";
SELECT POSITION(5 IN '1234567890') AS "5";
--
-- test implicit type conversion
--
SELECT 'unknown' || ' and unknown' AS "Concat unknown types";
SELECT text 'text' || ' and unknown' AS "Concat text to unknown type";
SELECT text 'text' || char ' and char' AS "Concat text to char";
SELECT text 'text' || varchar ' and varchar' AS "Concat text to varchar";
...@@ -46,6 +46,7 @@ select_into ...@@ -46,6 +46,7 @@ select_into
select_distinct select_distinct
select_distinct_on select_distinct_on
subselect subselect
union
aggregates aggregates
transactions transactions
random random
......
--
-- union.sql
--
-- Simple UNION constructs
SELECT 1 AS two UNION SELECT 2;
SELECT 1 AS one UNION SELECT 1;
SELECT 1 AS two UNION ALL SELECT 2;
SELECT 1 AS two UNION ALL SELECT 1;
SELECT 1 AS three UNION SELECT 2 UNION SELECT 3;
SELECT 1 AS two UNION SELECT 2 UNION SELECT 2;
SELECT 1 AS three UNION SELECT 2 UNION ALL SELECT 2;
SELECT 1.1 AS two UNION SELECT 2.2;
-- Mixed types
SELECT 1.1 AS two UNION SELECT 2;
SELECT 1 AS two UNION SELECT 2.2;
SELECT 1 AS one UNION SELECT 1.1;
SELECT 1.1 AS two UNION ALL SELECT 2;
SELECT 1 AS two UNION ALL SELECT 1;
SELECT 1 AS three UNION SELECT 2 UNION SELECT 3;
SELECT 1 AS two UNION SELECT 2 UNION SELECT 2;
SELECT 1 AS three UNION SELECT 2 UNION ALL SELECT 2;
--
-- Try testing from tables...
--
SELECT f1 AS five FROM FLOAT8_TBL
UNION
SELECT f1 FROM FLOAT8_TBL;
SELECT f1 AS ten FROM FLOAT8_TBL
UNION ALL
SELECT f1 FROM FLOAT8_TBL;
SELECT f1 AS nine FROM FLOAT8_TBL
UNION
SELECT f1 FROM INT4_TBL;
SELECT f1 AS ten FROM FLOAT8_TBL
UNION ALL
SELECT f1 FROM INT4_TBL;
SELECT f1 AS five FROM FLOAT8_TBL
WHERE f1 BETWEEN -1e6 AND 1e6
UNION
SELECT f1 FROM INT4_TBL
WHERE f1 BETWEEN 0 AND 1000000;
SELECT f1 AS five FROM VARCHAR_TBL
UNION
SELECT f1 FROM CHAR_TBL;
SELECT f1 AS three FROM VARCHAR_TBL
UNION
SELECT TRIM(TRAILING FROM f1) FROM CHAR_TBL;
SELECT f1 AS eight FROM VARCHAR_TBL
UNION ALL
SELECT f1 FROM CHAR_TBL;
SELECT f1 AS five FROM TEXT_TBL
UNION
SELECT f1 FROM VARCHAR_TBL
UNION
SELECT TRIM(TRAILING FROM f1) FROM CHAR_TBL;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment