Re: Trigger / constraint issue

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: Glenn Pierce <glennpierce(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Trigger / constraint issue
Date: 2012-12-05 23:51:54
Message-ID: 50BFDE1A.4030609@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 12/05/2012 02:24 PM, Glenn Pierce wrote:

>
> The error I get is
>
> new row for relation "sensor_values_2011q3" violates check constraint
> "sensor_values_2011q3_timestamp_check"<br />CONTEXT: SQL statement
> "INSERT INTO sensor_values_2011q3 VALUES (NEW.*)"<br />PL/pgSQL function
> "sensor_values_timestamp_sensor_func_insert_trigger" line 32 at SQL
> statement<br /><br />
>
> I have printed the query that causes this error and it is
>
> INSERT INTO sensor_values (timestamp, value, sensor_id) VALUES
> ('2011-06-30 23:00:00.001000+00:00', '0', '2103')
>
> So the trigger has chosen the wrong child table to insert into ?
>
> The funny thing is from psql this insert query works fine. ?
>
> I am not sure why 2011-06-30 23:00:00.001000+00:00 is selected to go
> into sensor_values_2011q3 and not sensor_values_2011q2
> I suspect its due to UTC / BST as that date time is on the border of the
> contraint. Either way I not sure why I get an error and
> why does PSQL work ?

I would suspect UTC/BST also.
Do you have 'mod' logging enabled?
If so what does the INSERT from the Python script show for a time value?
If not can you log the output from the Python script to get the value?

>
> Any suggestions / help would be great
>
> Thanks

--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2012-12-06 00:13:40 Re: Fwd: question on foreign key lock
Previous Message Glenn Pierce 2012-12-05 22:24:47 Trigger / constraint issue