title: Postgres - range for 'time without time zone' and exclude constraint
body: <p>I have the following table:</p>
  
  <pre><code>create table booking (
       identifier      integer                not null primary key,
       room            uuid                   not null,
       start_time      time without time zone not null,
       end_time        time without time zone not null
  );
  </code></pre>
  
  <p>I want to create an <code>exclude constraint</code> to enforce that there are no overlapping appointments for the same room.</p>
  
  <p>I tried the following:</p>
  
  <pre><code>alter table booking add constraint overlapping_times
  exclude using gist
  (
       cast(room as text) with =,
       period(start_time, end_time) with &amp;&amp;)
  );
  </code></pre>
  
  <p>This has two problems:</p>
  
  <ul>
  <li><p>Casting <code>room</code> to <code>text</code> is not enough, it gives: <code>ERROR:  data type text has no default operator class for access method "gist"</code>. I know in v10 there is <code>btree_gist</code>, but I am using v9.5 and v9.6, so I have to manually cast the <code>uuid</code> to a <code>text</code> afaik.</p></li>
  <li><p><code>period(...)</code> is wrong, but I have no idea how to construct a range of <code>time without time zone</code> type.</p></li>
  </ul>