--
-- BOOLEAN
--
--
-- sanity check - if this fails go insane!
--
SELECT 1 AS one;
 one 
-----
   1
(1 row)

-- ******************testing built-in type bool********************
-- check bool input syntax
SELECT true AS true;
 true 
------
 t
(1 row)

SELECT false AS false;
 false 
-------
 f
(1 row)

SELECT bool 't' AS true;
 true 
------
 t
(1 row)

SELECT bool '   f           ' AS false;
 false 
-------
 f
(1 row)

SELECT bool 'true' AS true;
 true 
------
 t
(1 row)

SELECT bool 'test' AS error;
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/boolean.sql:25: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(54): ERROR:  invalid input syntax for type boolean: "test"



SELECT bool 'false' AS false;
 false 
-------
 f
(1 row)

SELECT bool 'foo' AS error;
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/boolean.sql:29: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(53): ERROR:  invalid input syntax for type boolean: "foo"



SELECT bool 'y' AS true;
 true 
------
 t
(1 row)

SELECT bool 'yes' AS true;
 true 
------
 t
(1 row)

SELECT bool 'yeah' AS error;
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/boolean.sql:35: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(54): ERROR:  invalid input syntax for type boolean: "yeah"



SELECT bool 'n' AS false;
 false 
-------
 f
(1 row)

SELECT bool 'no' AS false;
 false 
-------
 f
(1 row)

SELECT bool 'nay' AS error;
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/boolean.sql:41: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(53): ERROR:  invalid input syntax for type boolean: "nay"



SELECT bool 'on' AS true;
 true 
------
 t
(1 row)

SELECT bool 'off' AS false;
 false 
-------
 f
(1 row)

SELECT bool 'of' AS false;
 false 
-------
 f
(1 row)

SELECT bool 'o' AS error;
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/boolean.sql:49: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(51): ERROR:  invalid input syntax for type boolean: "o"



SELECT bool 'on_' AS error;
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/boolean.sql:51: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(53): ERROR:  invalid input syntax for type boolean: "on_"



SELECT bool 'off_' AS error;
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/boolean.sql:53: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(54): ERROR:  invalid input syntax for type boolean: "off_"



SELECT bool '1' AS true;
 true 
------
 t
(1 row)

SELECT bool '11' AS error;
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/boolean.sql:57: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(52): ERROR:  invalid input syntax for type boolean: "11"



SELECT bool '0' AS false;
 false 
-------
 f
(1 row)

SELECT bool '000' AS error;
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/boolean.sql:61: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(53): ERROR:  invalid input syntax for type boolean: "000"



SELECT bool '' AS error;
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/boolean.sql:63: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(50): ERROR:  invalid input syntax for type boolean: ""



-- and, or, not in qualifications
SELECT bool 't' or bool 'f' AS true;
 true 
------
 t
(1 row)

SELECT bool 't' and bool 'f' AS false;
 false 
-------
 f
(1 row)

SELECT not bool 'f' AS true;
 true 
------
 t
(1 row)

SELECT bool 't' = bool 'f' AS false;
 false 
-------
 f
(1 row)

SELECT bool 't' <> bool 'f' AS true;
 true 
------
 t
(1 row)

SELECT bool 't' > bool 'f' AS true;
 true 
------
 t
(1 row)

SELECT bool 't' >= bool 'f' AS true;
 true 
------
 t
(1 row)

SELECT bool 'f' < bool 't' AS true;
 true 
------
 t
(1 row)

SELECT bool 'f' <= bool 't' AS true;
 true 
------
 t
(1 row)

-- explicit casts to/from text
SELECT 'TrUe'::text::boolean AS true, 'fAlse'::text::boolean AS false;
 true | false 
------+-------
 t    | f
(1 row)

SELECT '    true   '::text::boolean AS true,
       '     FALSE'::text::boolean AS false;
 true | false 
------+-------
 t    | f
(1 row)

SELECT true::boolean::text AS true, false::boolean::text AS false;
 true | false 
------+-------
 true | false
(1 row)

SELECT '  tru e '::text::boolean AS invalid;    -- error
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/boolean.sql:91: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(58): ERROR:  invalid input syntax for type boolean: "  tru e "



SELECT ''::text::boolean AS invalid;            -- error
psql:/home/runner/.ya/build/build_root/f6zk/0031e5/environment/arcadia/ydb/tests/functional/postgresql/cases/boolean.sql:92: Status: PRECONDITION_FAILED
Issues: 
<main>: Error: Terminate was called, reason(50): ERROR:  invalid input syntax for type boolean: ""



