You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
"temporal_rng3_uq" UNIQUE (id1, id2, valid_at WITHOUT OVERLAPS)
182
183
@@ -209,15 +210,15 @@ DROP TYPE textrange2;
209
210
DROP TABLE temporal_rng;
210
211
CREATE TABLE temporal_rng (
211
212
id int4range,
212
-
valid_attsrange
213
+
valid_atdaterange
213
214
);
214
215
ALTER TABLE temporal_rng
215
216
ADD CONSTRAINT temporal_rng_pk
216
217
PRIMARY KEY (id, valid_at WITHOUT OVERLAPS);
217
218
-- PK with USING INDEX (not possible):
218
219
CREATE TABLE temporal3 (
219
220
id int4range,
220
-
valid_attsrange
221
+
valid_atdaterange
221
222
);
222
223
CREATE INDEX idx_temporal3_uq ON temporal3 USING gist (id, valid_at);
223
224
ALTER TABLE temporal3
@@ -231,7 +232,7 @@ DROP TABLE temporal3;
231
232
-- UNIQUE with USING INDEX (not possible):
232
233
CREATE TABLE temporal3 (
233
234
id int4range,
234
-
valid_attsrange
235
+
valid_atdaterange
235
236
);
236
237
CREATE INDEX idx_temporal3_uq ON temporal3 USING gist (id, valid_at);
237
238
ALTER TABLE temporal3
@@ -245,7 +246,7 @@ DROP TABLE temporal3;
245
246
-- UNIQUE with USING [UNIQUE] INDEX (possible but not a temporal constraint):
246
247
CREATE TABLE temporal3 (
247
248
id int4range,
248
-
valid_attsrange
249
+
valid_atdaterange
249
250
);
250
251
CREATE UNIQUE INDEX idx_temporal3_uq ON temporal3 (id, valid_at);
251
252
ALTER TABLE temporal3
@@ -258,7 +259,7 @@ CREATE TABLE temporal3 (
258
259
id int4range
259
260
);
260
261
ALTER TABLE temporal3
261
-
ADD COLUMN valid_attsrange,
262
+
ADD COLUMN valid_atdaterange,
262
263
ADD CONSTRAINT temporal3_pk
263
264
PRIMARY KEY (id, valid_at WITHOUT OVERLAPS);
264
265
DROP TABLE temporal3;
@@ -267,25 +268,25 @@ CREATE TABLE temporal3 (
267
268
id int4range
268
269
);
269
270
ALTER TABLE temporal3
270
-
ADD COLUMN valid_attsrange,
271
+
ADD COLUMN valid_atdaterange,
271
272
ADD CONSTRAINT temporal3_uq
272
273
UNIQUE (id, valid_at WITHOUT OVERLAPS);
273
274
DROP TABLE temporal3;
274
275
--
275
276
-- test PK inserts
276
277
--
277
278
-- okay:
278
-
INSERT INTO temporal_rng VALUES ('[1,1]',tsrange('2018-01-02', '2018-02-03'));
279
-
INSERT INTO temporal_rng VALUES ('[1,1]',tsrange('2018-03-03', '2018-04-04'));
280
-
INSERT INTO temporal_rng VALUES ('[2,2]',tsrange('2018-01-01', '2018-01-05'));
281
-
INSERT INTO temporal_rng VALUES ('[3,3]',tsrange('2018-01-01', NULL));
279
+
INSERT INTO temporal_rng VALUES ('[1,1]',daterange('2018-01-02', '2018-02-03'));
280
+
INSERT INTO temporal_rng VALUES ('[1,1]',daterange('2018-03-03', '2018-04-04'));
281
+
INSERT INTO temporal_rng VALUES ('[2,2]',daterange('2018-01-01', '2018-01-05'));
282
+
INSERT INTO temporal_rng VALUES ('[3,3]',daterange('2018-01-01', NULL));
282
283
-- should fail:
283
-
INSERT INTO temporal_rng VALUES ('[1,1]',tsrange('2018-01-01', '2018-01-05'));
284
+
INSERT INTO temporal_rng VALUES ('[1,1]',daterange('2018-01-01', '2018-01-05'));
284
285
ERROR: conflicting key value violates exclusion constraint "temporal_rng_pk"
285
-
DETAIL: Key (id, valid_at)=([1,2), ["Mon Jan 01 00:00:002018","Fri Jan 05 00:00:002018")) conflicts with existing key (id, valid_at)=([1,2), ["Tue Jan 02 00:00:002018","Sat Feb 03 00:00:002018")).
286
-
INSERT INTO temporal_rng VALUES (NULL,tsrange('2018-01-01', '2018-01-05'));