Skip to content

Commit

Permalink
Also include updated regression test for previous commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernd Helmle committed Jan 12, 2016
1 parent 9e3f4d6 commit d59358f
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions sql/informix_fdw_tx.sql
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ OPTIONS(table 'text_byte_test',
database :'INFORMIXDB',
enable_blobs '1');

--
-- Foreign tables to test DATETIME and DATE values.
--
CREATE FOREIGN TABLE datetime_test(id bigserial not null, v1 timestamp with time zone,
v2 date, v3 time)
SERVER test_server
Expand All @@ -98,6 +101,14 @@ OPTIONS(table 'datetime_test',
db_locale :'DB_LOCALE',
database :'INFORMIXDB');

CREATE FOREIGN TABLE date_test(val date)
SERVER test_server
OPTIONS(table 'date_test',
client_locale :'CLIENT_LOCALE',
db_locale :'DB_LOCALE',
database :'INFORMIXDB');


--
-- Foreign table to test SERIAL values
--
Expand Down Expand Up @@ -375,6 +386,62 @@ DELETE FROM datetime_test;
-- empty set expected
SELECT v1, v2, v3 FROM datetime_test ORDER BY id ASC;

-- empty set expected
SELECT val FROM date_test ORDER BY val;

-- INSERT, should succeed
INSERT INTO date_test(val) VALUES('1941-08-19');
INSERT INTO date_test(val) VALUES('0001-01-01');
SELECT val FROM date_test ORDER BY val;

SAVEPOINT _BEFORE_FAIL;

-- INSERT, should fail
INSERT INTO date_test(val) VALUES('0000-12-31');

ROLLBACK TO _BEFORE_FAIL;

SELECT val FROM date_test ORDER BY val;

-- leap year
INSERT INTO date_test(val) VALUES('2016-02-29');
SELECT val FROM date_test ORDER BY val;

-- DELETE, should succeed
DELETE FROM date_test WHERE val = '2016-02-29';
SELECT val FROM date_test ORDER BY val;

-- UPDATE, should succeed
UPDATE date_test SET val = '2016-02-29' WHERE val = '0001-01-01';
SELECT val FROM date_test ORDER BY val;

DELETE FROM date_test;

SELECT val FROM date_test ORDER BY val;

COMMIT;

--
-- We don't support PostgreSQL timestamp/timestamptz to Informix DATE conversions
--
BEGIN;

ALTER FOREIGN TABLE date_test ALTER val TYPE timestamptz;

SAVEPOINT _BEFORE_FAIL;

-- should fail
INSERT INTO date_test(val) VALUES('2016-10-10 15:25');

ROLLBACK TO _BEFORE_FAIL;

ALTER FOREIGN TABLE date_test ALTER val TYPE timestamp;

-- should fail
INSERT INTO date_test(val) VALUES('2016-10-10 15:25');

ROLLBACK TO _BEFORE_FAIL;

COMMIT;

--------------------------------------------------------------------------------
Expand Down Expand Up @@ -818,6 +885,7 @@ DROP FOREIGN TABLE text_byte_test;
DROP FOREIGN TABLE serial_test;
DROP FOREIGN TABLE serial8_test;
DROP FOREIGN TABLE datetime_test;
DROP FOREIGN TABLE date_test;
DROP FOREIGN TABLE interval_test;
DROP FOREIGN TABLE decimal_test;

Expand Down

0 comments on commit d59358f

Please sign in to comment.