-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
create schema trycast; | ||
set search_path = trycast; | ||
|
||
-- no way to cast | ||
select try_cast(12 as date); | ||
date | ||
------ | ||
|
||
(1 row) | ||
|
||
-- typecast via I/O | ||
select try_cast('11/11/20111' as int); | ||
int4 | ||
------ | ||
|
||
(1 row) | ||
select try_cast('111d' as int); | ||
int4 | ||
------ | ||
|
||
(1 row) | ||
|
||
-- typecast from pg_proc | ||
select try_cast('112344466343'::int8 as int4); | ||
int4 | ||
------ | ||
|
||
(1 row) | ||
|
||
-- arrays | ||
select try_cast('{1, 2, 31111111111}'::int8[] as int4[]); -- pg_proc | ||
int4 | ||
------ | ||
{1,2,NULL} | ||
(1 row) | ||
select try_cast('{1, 2, lol}'::text[] as int4[]); -- via I/O | ||
int4 | ||
------ | ||
{1,2,NULL} | ||
(1 row) | ||
select try_cast('{1, 2, 31111111111}' as int4[]); -- | ||
int4 | ||
------ | ||
{1,2,NULL} | ||
(1 row) | ||
|
||
reset search_path; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
create schema trycast; | ||
set search_path = trycast; | ||
|
||
-- no way to cast | ||
select try_cast(12 as date); | ||
|
||
-- typecast via I/O | ||
select try_cast('11/11/20111' as int); | ||
select try_cast('111d' as int); | ||
|
||
-- typecast from pg_proc | ||
select try_cast('112344466343'::int8 as int4); | ||
|
||
-- arrays | ||
select try_cast('{1, 2, 31111111111}'::int8[] as int4[]); -- pg_proc | ||
select try_cast('{1, 2, lol}'::text[] as int4[]); -- via I/O | ||
select try_cast('{1, 2, 31111111111}' as int4[]); -- | ||
|
||
reset search_path; |