title: Check constraint with dynamic parameters
body: <p>I am creating partition table with PostgreSQL.</p>
  
  <pre><code>CREATE TABLE tt_parent
  (
      id integer,
      log_time timestamp with time zone,
      server_id integer,
      name text,
      CONSTRAINT tt_parent_pkey PRIMARY KEY (id)
  )
  
  CREATE TABLE tt_1_2015_week42 (
   CHECK ( server_id = 1 AND log_time &gt;= (to_timestamp('2015-42', 'IYYY-IW')) AND log_time &lt;= (to_timestamp('2015-42', 'IYYY-IW') + '6 days'::interval)
  ) INHERITS (tt_parent);
  
  CREATE TABLE tt_1_2015_week43 (
   CHECK ( server_id = 1 AND log_time &gt;= (to_timestamp('2015-43', 'IYYY-IW')) AND log_time &lt;= (to_timestamp('2015-43', 'IYYY-IW') + '6 days'::interval)
  ) INHERITS (tt_parent);
  
  CREATE TABLE tt_1_2015_week44 (
   CHECK ( server_id = 1 AND log_time &gt;= (to_timestamp('2015-44', 'IYYY-IW')) AND log_time &lt;= (to_timestamp('2015-44', 'IYYY-IW') + '6 days'::interval)
  ) INHERITS (tt_parent);
  </code></pre>
  
  <p>After creating the above child table when i fire below query then it scan all the child table.</p>
  
  <pre><code>EXPLAIN SELECT * FROM tt_parent 
  WHERE server_id = 1 
  AND (log_time &gt;= '2015-10-12 00:00:00'::TIMESTAMP WITH TIME ZONE) 
  AND (log_time &lt;= '2015-10-15 00:00:00'::TIMESTAMP WITH TIME ZONE);
  </code></pre>
  
  <p>From the above query, log_time in where clause is with week 42. So the query should scan only "tt_1_2015_week42" child table.
  Why above query scan all the 3 child tables ?</p>
  
  <p>Check constraint with dynamic value does not work ? We can not use "to_timestamp" function inside Check constraint ?
  How to modify the above child table check constraint so that query can scan only week 42 table.</p>