Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbe6fcb6

Browse files
committed
Improve Range Types and Exclusion Constraints example.
Make the examples self-contained to avoid confusion. Per bug report8367 from KOIZUMI Satoru.
1 parentf5c2f5a commitbe6fcb6

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

‎doc/src/sgml/rangetypes.sgml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -451,22 +451,25 @@ CREATE INDEX reservation_idx ON reservation USING gist (during);
451451
range type. For example:
452452

453453
<programlisting>
454-
ALTER TABLE reservation ADD EXCLUDE USING gist (during WITH &amp;&amp;);
454+
CREATE TABLE reservation (
455+
during tsrange,
456+
EXCLUDE USING gist (during WITH &amp;&amp;)
457+
);
455458
</programlisting>
456459

457460
That constraint will prevent any overlapping values from existing
458461
in the table at the same time:
459462

460463
<programlisting>
461464
INSERT INTO reservation VALUES
462-
(1108,'[2010-01-01 11:30, 2010-01-0113:00)');
465+
('[2010-01-01 11:30, 2010-01-0115:00)');
463466
INSERT 0 1
464467

465468
INSERT INTO reservation VALUES
466-
(1108,'[2010-01-01 14:45, 2010-01-01 15:45)');
469+
('[2010-01-01 14:45, 2010-01-01 15:45)');
467470
ERROR: conflicting key value violates exclusion constraint "reservation_during_excl"
468-
DETAIL: Key (during)=([2010-01-01 14:45:00,2010-01-01 15:45:00)) conflicts
469-
with existing key (during)=([2010-01-0114:30:00,2010-01-01 15:30:00)).
471+
DETAIL: Key (during)=(["2010-01-01 14:45:00","2010-01-01 15:45:00")) conflicts
472+
with existing key (during)=(["2010-01-0111:30:00","2010-01-01 15:00:00")).
470473
</programlisting>
471474
</para>
472475

@@ -479,6 +482,7 @@ with existing key (during)=([ 2010-01-01 14:30:00, 2010-01-01 15:30:00 )).
479482
are equal:
480483

481484
<programlisting>
485+
CREATE EXTENSION btree_gist;
482486
CREATE TABLE room_reservation (
483487
room text,
484488
during tsrange,
@@ -492,8 +496,8 @@ INSERT 0 1
492496
INSERT INTO room_reservation VALUES
493497
('123A', '[2010-01-01 14:30, 2010-01-01 15:30)');
494498
ERROR: conflicting key value violates exclusion constraint "room_reservation_room_during_excl"
495-
DETAIL: Key (room, during)=(123A, [2010-01-01 14:30:00,2010-01-01 15:30:00)) conflicts with
496-
existing key (room, during)=(123A, [2010-01-01 14:00:00,2010-01-01 15:00:00)).
499+
DETAIL: Key (room, during)=(123A, ["2010-01-01 14:30:00","2010-01-01 15:30:00")) conflicts
500+
withexisting key (room, during)=(123A, ["2010-01-01 14:00:00","2010-01-01 15:00:00")).
497501

498502
INSERT INTO room_reservation VALUES
499503
('123B', '[2010-01-01 14:30, 2010-01-01 15:30)');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp