@@ -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 &&);
454+ CREATE TABLE reservation (
455+ during tsrange,
456+ EXCLUDE USING gist (during WITH &&)
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>
461464INSERT INTO reservation VALUES
462- (1108, '[2010-01-01 11:30, 2010-01-01 13 :00)');
465+ ('[2010-01-01 11:30, 2010-01-01 15 :00)');
463466INSERT 0 1
464467
465468INSERT 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)');
467470ERROR: 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-01 14 :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-01 11 :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;
482486CREATE TABLE room_reservation (
483487 room text,
484488 during tsrange,
@@ -492,8 +496,8 @@ INSERT 0 1
492496INSERT INTO room_reservation VALUES
493497 ('123A', '[2010-01-01 14:30, 2010-01-01 15:30)');
494498ERROR: 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+ with existing key (room, during)=(123A, [" 2010-01-01 14:00:00"," 2010-01-01 15:00:00" )).
497501
498502INSERT INTO room_reservation VALUES
499503 ('123B', '[2010-01-01 14:30, 2010-01-01 15:30)');
0 commit comments