Search Postgresql Archives

Re: How do I setup this Exclusion Constraint?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks, Richard, but mostly through just guessing.  I need to research
what GIST is and how the addition of col1 and col2 to that is making
this work.

With

psql -d mytest -c "CREATE EXTENSION btree_gist;"

This seems to work now:

CREATE TABLE test (
  id INTEGER NOT NULL DEFAULT nextval('test_id_seq'),
  col1 INTEGER,
  col2 VARCHAR(10),
  from_ts TIMESTAMPTZ,
  to_ts TIMESTAMPTZ,
  CHECK ( from_ts < to_ts ),
  CONSTRAINT overlapping_times EXCLUDE USING GIST (
    col1 with =,
    col2 with =,
    box(
      point( extract(epoch FROM from_ts at time zone 'UTC'),
extract(epoch FROM from_ts at time zone 'UTC') ),
      point( extract(epoch FROM to_ts at time zone 'UTC') ,
extract(epoch FROM to_ts at time zone 'UTC') )
    ) WITH &&
  )
);

On Tue, May 1, 2012 at 1:26 PM, Richard Broersma
<richard.broersma@xxxxxxxxx> wrote:
> On Tue, May 1, 2012 at 10:15 AM, bradford <fingermark@xxxxxxxxx> wrote:
>> I'm trying to used what I learned in
>> http://www.depesz.com/2010/01/03/waiting-for-8-5-exclusion-constraints/,
>> but I cannot figure out how to apply this exclusion constraint to col1
>> (integer) + col2 (varchar).
>
> Take a look at Btree_gist index:
> http://www.postgresql.org/docs/9.1/static/btree-gist.html
>
> I think this is the part that your missing.
>
>
> --
> Regards,
> Richard Broersma Jr.

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux