Skip to content

Commit

Permalink
disable unsupported functions, input and output syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangjinwu committed Mar 9, 2023
1 parent a50d006 commit 6adc475
Showing 1 changed file with 127 additions and 127 deletions.
254 changes: 127 additions & 127 deletions src/tests/regress/data/sql/interval.sql
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ INSERT INTO INTERVAL_TBL_OF (f1) VALUES ('2147483647 years');
INSERT INTO INTERVAL_TBL_OF (f1) VALUES ('-2147483648 years');

-- Test edge-case overflow detection in interval multiplication
select extract(epoch from '256 microseconds'::interval * (2^55)::float8);
--@ select extract(epoch from '256 microseconds'::interval * (2^55)::float8);

--@ SELECT r1.*, r2.*
--@ FROM INTERVAL_TBL_OF r1, INTERVAL_TBL_OF r2
Expand Down Expand Up @@ -144,12 +144,12 @@ select '100000000y 10mon -1000000000d -100000h -10min -10.000001s ago'::interval

-- test justify_hours() and justify_days()

SELECT justify_hours(interval '6 months 3 days 52 hours 3 minutes 2 seconds') as "6 mons 5 days 4 hours 3 mins 2 seconds";
SELECT justify_days(interval '6 months 36 days 5 hours 4 minutes 3 seconds') as "7 mons 6 days 5 hours 4 mins 3 seconds";
--@ SELECT justify_hours(interval '6 months 3 days 52 hours 3 minutes 2 seconds') as "6 mons 5 days 4 hours 3 mins 2 seconds";
--@ SELECT justify_days(interval '6 months 36 days 5 hours 4 minutes 3 seconds') as "7 mons 6 days 5 hours 4 mins 3 seconds";

-- test justify_interval()

SELECT justify_interval(interval '1 month -1 hour') as "1 month -1 hour";
--@ SELECT justify_interval(interval '1 month -1 hour') as "1 month -1 hour";

-- test fractional second input, and detection of duplicate units
SELECT '1 millisecond'::interval, '1 microsecond'::interval,
Expand All @@ -175,64 +175,64 @@ SELECT interval '3' day;
SELECT interval '4' hour;
SELECT interval '5' minute;
SELECT interval '6' second;
SELECT interval '1' year to month;
SELECT interval '1-2' year to month;
SELECT interval '1 2' day to hour;
SELECT interval '1 2:03' day to hour;
SELECT interval '1 2:03:04' day to hour;
SELECT interval '1 2' day to minute;
SELECT interval '1 2:03' day to minute;
SELECT interval '1 2:03:04' day to minute;
SELECT interval '1 2' day to second;
SELECT interval '1 2:03' day to second;
SELECT interval '1 2:03:04' day to second;
SELECT interval '1 2' hour to minute;
SELECT interval '1 2:03' hour to minute;
SELECT interval '1 2:03:04' hour to minute;
SELECT interval '1 2' hour to second;
SELECT interval '1 2:03' hour to second;
SELECT interval '1 2:03:04' hour to second;
SELECT interval '1 2' minute to second;
SELECT interval '1 2:03' minute to second;
SELECT interval '1 2:03:04' minute to second;
SELECT interval '1 +2:03' minute to second;
SELECT interval '1 +2:03:04' minute to second;
SELECT interval '1 -2:03' minute to second;
SELECT interval '1 -2:03:04' minute to second;
SELECT interval '123 11' day to hour; -- ok
--@ SELECT interval '1' year to month;
--@ SELECT interval '1-2' year to month;
--@ SELECT interval '1 2' day to hour;
--@ SELECT interval '1 2:03' day to hour;
--@ SELECT interval '1 2:03:04' day to hour;
--@ SELECT interval '1 2' day to minute;
--@ SELECT interval '1 2:03' day to minute;
--@ SELECT interval '1 2:03:04' day to minute;
--@ SELECT interval '1 2' day to second;
--@ SELECT interval '1 2:03' day to second;
--@ SELECT interval '1 2:03:04' day to second;
--@ SELECT interval '1 2' hour to minute;
--@ SELECT interval '1 2:03' hour to minute;
--@ SELECT interval '1 2:03:04' hour to minute;
--@ SELECT interval '1 2' hour to second;
--@ SELECT interval '1 2:03' hour to second;
--@ SELECT interval '1 2:03:04' hour to second;
--@ SELECT interval '1 2' minute to second;
--@ SELECT interval '1 2:03' minute to second;
--@ SELECT interval '1 2:03:04' minute to second;
--@ SELECT interval '1 +2:03' minute to second;
--@ SELECT interval '1 +2:03:04' minute to second;
--@ SELECT interval '1 -2:03' minute to second;
--@ SELECT interval '1 -2:03:04' minute to second;
--@ SELECT interval '123 11' day to hour; -- ok
SELECT interval '123 11' day; -- not ok
SELECT interval '123 11'; -- not ok, too ambiguous
SELECT interval '123 2:03 -2:04'; -- not ok, redundant hh:mm fields

-- test syntaxes for restricted precision
SELECT interval(0) '1 day 01:23:45.6789';
SELECT interval(2) '1 day 01:23:45.6789';
SELECT interval '12:34.5678' minute to second(2); -- per SQL spec
--@ SELECT interval(0) '1 day 01:23:45.6789';
--@ SELECT interval(2) '1 day 01:23:45.6789';
--@ SELECT interval '12:34.5678' minute to second(2); -- per SQL spec
SELECT interval '1.234' second;
SELECT interval '1.234' second(2);
SELECT interval '1 2.345' day to second(2);
SELECT interval '1 2:03' day to second(2);
SELECT interval '1 2:03.4567' day to second(2);
SELECT interval '1 2:03:04.5678' day to second(2);
SELECT interval '1 2.345' hour to second(2);
SELECT interval '1 2:03.45678' hour to second(2);
SELECT interval '1 2:03:04.5678' hour to second(2);
SELECT interval '1 2.3456' minute to second(2);
SELECT interval '1 2:03.5678' minute to second(2);
SELECT interval '1 2:03:04.5678' minute to second(2);
--@ SELECT interval '1.234' second(2);
--@ SELECT interval '1 2.345' day to second(2);
--@ SELECT interval '1 2:03' day to second(2);
--@ SELECT interval '1 2:03.4567' day to second(2);
--@ SELECT interval '1 2:03:04.5678' day to second(2);
--@ SELECT interval '1 2.345' hour to second(2);
--@ SELECT interval '1 2:03.45678' hour to second(2);
--@ SELECT interval '1 2:03:04.5678' hour to second(2);
--@ SELECT interval '1 2.3456' minute to second(2);
--@ SELECT interval '1 2:03.5678' minute to second(2);
--@ SELECT interval '1 2:03:04.5678' minute to second(2);

-- test casting to restricted precision (bug #14479)
SELECT f1, f1::INTERVAL DAY TO MINUTE AS "minutes",
(f1 + INTERVAL '1 month')::INTERVAL MONTH::INTERVAL YEAR AS "years"
FROM interval_tbl;
--@ SELECT f1, f1::INTERVAL DAY TO MINUTE AS "minutes",
--@ (f1 + INTERVAL '1 month')::INTERVAL MONTH::INTERVAL YEAR AS "years"
--@ FROM interval_tbl;

-- test inputting and outputting SQL standard interval literals
SET IntervalStyle TO sql_standard;
SELECT interval '0' AS "zero",
interval '1-2' year to month AS "year-month",
interval '1 2:03:04' day to second AS "day-time",
- interval '1-2' AS "negative year-month",
- interval '1 2:03:04' AS "negative day-time";
--@ SELECT interval '0' AS "zero",
--@ interval '1-2' year to month AS "year-month",
--@ interval '1 2:03:04' day to second AS "day-time",
--@ - interval '1-2' AS "negative year-month",
--@ - interval '1 2:03:04' AS "negative day-time";

-- test input of some not-quite-standard interval values in the sql style
SET IntervalStyle TO postgres;
Expand All @@ -243,45 +243,45 @@ SELECT interval '+1 -1:00:00',

-- test output of couple non-standard interval values in the sql style
SET IntervalStyle TO sql_standard;
SELECT interval '1 day -1 hours',
interval '-1 days +1 hours',
interval '1 years 2 months -3 days 4 hours 5 minutes 6.789 seconds',
- interval '1 years 2 months -3 days 4 hours 5 minutes 6.789 seconds';
--@ SELECT interval '1 day -1 hours',
--@ interval '-1 days +1 hours',
--@ interval '1 years 2 months -3 days 4 hours 5 minutes 6.789 seconds',
--@ - interval '1 years 2 months -3 days 4 hours 5 minutes 6.789 seconds';

-- test outputting iso8601 intervals
SET IntervalStyle to iso_8601;
select interval '0' AS "zero",
interval '1-2' AS "a year 2 months",
interval '1 2:03:04' AS "a bit over a day",
interval '2:03:04.45679' AS "a bit over 2 hours",
(interval '1-2' + interval '3 4:05:06.7') AS "all fields",
(interval '1-2' - interval '3 4:05:06.7') AS "mixed sign",
(- interval '1-2' + interval '3 4:05:06.7') AS "negative";
--@ select interval '0' AS "zero",
--@ interval '1-2' AS "a year 2 months",
--@ interval '1 2:03:04' AS "a bit over a day",
--@ interval '2:03:04.45679' AS "a bit over 2 hours",
--@ (interval '1-2' + interval '3 4:05:06.7') AS "all fields",
--@ (interval '1-2' - interval '3 4:05:06.7') AS "mixed sign",
--@ (- interval '1-2' + interval '3 4:05:06.7') AS "negative";

-- test inputting ISO 8601 4.4.2.1 "Format With Time Unit Designators"
SET IntervalStyle to sql_standard;
select interval 'P0Y' AS "zero",
interval 'P1Y2M' AS "a year 2 months",
interval 'P1W' AS "a week",
interval 'P1DT2H3M4S' AS "a bit over a day",
interval 'P1Y2M3DT4H5M6.7S' AS "all fields",
interval 'P-1Y-2M-3DT-4H-5M-6.7S' AS "negative",
interval 'PT-0.1S' AS "fractional second";
--@ select interval 'P0Y' AS "zero",
--@ interval 'P1Y2M' AS "a year 2 months",
--@ interval 'P1W' AS "a week",
--@ interval 'P1DT2H3M4S' AS "a bit over a day",
--@ interval 'P1Y2M3DT4H5M6.7S' AS "all fields",
--@ interval 'P-1Y-2M-3DT-4H-5M-6.7S' AS "negative",
--@ interval 'PT-0.1S' AS "fractional second";

-- test inputting ISO 8601 4.4.2.2 "Alternative Format"
SET IntervalStyle to postgres;
select interval 'P00021015T103020' AS "ISO8601 Basic Format",
interval 'P0002-10-15T10:30:20' AS "ISO8601 Extended Format";
--@ select interval 'P00021015T103020' AS "ISO8601 Basic Format",
--@ interval 'P0002-10-15T10:30:20' AS "ISO8601 Extended Format";

-- Make sure optional ISO8601 alternative format fields are optional.
select interval 'P0002' AS "year only",
interval 'P0002-10' AS "year month",
interval 'P0002-10-15' AS "year month day",
interval 'P0002T1S' AS "year only plus time",
interval 'P0002-10T1S' AS "year month plus time",
interval 'P0002-10-15T1S' AS "year month day plus time",
interval 'PT10' AS "hour only",
interval 'PT10:30' AS "hour minute";
--@ select interval 'P0002' AS "year only",
--@ interval 'P0002-10' AS "year month",
--@ interval 'P0002-10-15' AS "year month day",
--@ interval 'P0002T1S' AS "year only plus time",
--@ interval 'P0002-10T1S' AS "year month plus time",
--@ interval 'P0002-10-15T1S' AS "year month day plus time",
--@ interval 'PT10' AS "hour only",
--@ interval 'PT10:30' AS "hour minute";

-- test a couple rounding cases that changed since 8.3 w/ HAVE_INT64_TIMESTAMP.
select interval '-10 mons -3 days +03:55:06.70';
Expand All @@ -290,64 +290,64 @@ select interval '0:0:0.7', interval '@ 0.70 secs', interval '0.7 seconds';

-- check that '30 days' equals '1 month' according to the hash function
select '30 days'::interval = '1 month'::interval as t;
select interval_hash('30 days'::interval) = interval_hash('1 month'::interval) as t;
--@ select interval_hash('30 days'::interval) = interval_hash('1 month'::interval) as t;

-- numeric constructor
select make_interval(years := 2);
select make_interval(years := 1, months := 6);
select make_interval(years := 1, months := -1, weeks := 5, days := -7, hours := 25, mins := -180);

select make_interval() = make_interval(years := 0, months := 0, weeks := 0, days := 0, mins := 0, secs := 0.0);
select make_interval(hours := -2, mins := -10, secs := -25.3);

select make_interval(years := 'inf'::float::int);
select make_interval(months := 'NaN'::float::int);
select make_interval(secs := 'inf');
select make_interval(secs := 'NaN');
select make_interval(secs := 7e12);
--@ select make_interval(years := 2);
--@ select make_interval(years := 1, months := 6);
--@ select make_interval(years := 1, months := -1, weeks := 5, days := -7, hours := 25, mins := -180);
--@
--@ select make_interval() = make_interval(years := 0, months := 0, weeks := 0, days := 0, mins := 0, secs := 0.0);
--@ select make_interval(hours := -2, mins := -10, secs := -25.3);
--@
--@ select make_interval(years := 'inf'::float::int);
--@ select make_interval(months := 'NaN'::float::int);
--@ select make_interval(secs := 'inf');
--@ select make_interval(secs := 'NaN');
--@ select make_interval(secs := 7e12);

--
-- test EXTRACT
--
SELECT f1,
EXTRACT(MICROSECOND FROM f1) AS MICROSECOND,
EXTRACT(MILLISECOND FROM f1) AS MILLISECOND,
EXTRACT(SECOND FROM f1) AS SECOND,
EXTRACT(MINUTE FROM f1) AS MINUTE,
EXTRACT(HOUR FROM f1) AS HOUR,
EXTRACT(DAY FROM f1) AS DAY,
EXTRACT(MONTH FROM f1) AS MONTH,
EXTRACT(QUARTER FROM f1) AS QUARTER,
EXTRACT(YEAR FROM f1) AS YEAR,
EXTRACT(DECADE FROM f1) AS DECADE,
EXTRACT(CENTURY FROM f1) AS CENTURY,
EXTRACT(MILLENNIUM FROM f1) AS MILLENNIUM,
EXTRACT(EPOCH FROM f1) AS EPOCH
FROM INTERVAL_TBL;

SELECT EXTRACT(FORTNIGHT FROM INTERVAL '2 days'); -- error
SELECT EXTRACT(TIMEZONE FROM INTERVAL '2 days'); -- error

SELECT EXTRACT(DECADE FROM INTERVAL '100 y');
SELECT EXTRACT(DECADE FROM INTERVAL '99 y');
SELECT EXTRACT(DECADE FROM INTERVAL '-99 y');
SELECT EXTRACT(DECADE FROM INTERVAL '-100 y');

SELECT EXTRACT(CENTURY FROM INTERVAL '100 y');
SELECT EXTRACT(CENTURY FROM INTERVAL '99 y');
SELECT EXTRACT(CENTURY FROM INTERVAL '-99 y');
SELECT EXTRACT(CENTURY FROM INTERVAL '-100 y');
--@ SELECT f1,
--@ EXTRACT(MICROSECOND FROM f1) AS MICROSECOND,
--@ EXTRACT(MILLISECOND FROM f1) AS MILLISECOND,
--@ EXTRACT(SECOND FROM f1) AS SECOND,
--@ EXTRACT(MINUTE FROM f1) AS MINUTE,
--@ EXTRACT(HOUR FROM f1) AS HOUR,
--@ EXTRACT(DAY FROM f1) AS DAY,
--@ EXTRACT(MONTH FROM f1) AS MONTH,
--@ EXTRACT(QUARTER FROM f1) AS QUARTER,
--@ EXTRACT(YEAR FROM f1) AS YEAR,
--@ EXTRACT(DECADE FROM f1) AS DECADE,
--@ EXTRACT(CENTURY FROM f1) AS CENTURY,
--@ EXTRACT(MILLENNIUM FROM f1) AS MILLENNIUM,
--@ EXTRACT(EPOCH FROM f1) AS EPOCH
--@ FROM INTERVAL_TBL;
--@
--@ SELECT EXTRACT(FORTNIGHT FROM INTERVAL '2 days'); -- error
--@ SELECT EXTRACT(TIMEZONE FROM INTERVAL '2 days'); -- error
--@
--@ SELECT EXTRACT(DECADE FROM INTERVAL '100 y');
--@ SELECT EXTRACT(DECADE FROM INTERVAL '99 y');
--@ SELECT EXTRACT(DECADE FROM INTERVAL '-99 y');
--@ SELECT EXTRACT(DECADE FROM INTERVAL '-100 y');
--@
--@ SELECT EXTRACT(CENTURY FROM INTERVAL '100 y');
--@ SELECT EXTRACT(CENTURY FROM INTERVAL '99 y');
--@ SELECT EXTRACT(CENTURY FROM INTERVAL '-99 y');
--@ SELECT EXTRACT(CENTURY FROM INTERVAL '-100 y');

-- date_part implementation is mostly the same as extract, so only
-- test a few cases for additional coverage.
SELECT f1,
date_part('microsecond', f1) AS microsecond,
date_part('millisecond', f1) AS millisecond,
date_part('second', f1) AS second,
date_part('epoch', f1) AS epoch
FROM INTERVAL_TBL;
--@ SELECT f1,
--@ date_part('microsecond', f1) AS microsecond,
--@ date_part('millisecond', f1) AS millisecond,
--@ date_part('second', f1) AS second,
--@ date_part('epoch', f1) AS epoch
--@ FROM INTERVAL_TBL;

-- internal overflow test case
SELECT extract(epoch from interval '1000000000 days');
--@ SELECT extract(epoch from interval '1000000000 days');

DROP TABLE INTERVAL_TBL;

0 comments on commit 6adc475

Please sign in to comment.