Search code examples
postgresqlpipelinedb

Default date for insert doesn't change in continuous transformation


I created the table below.

create table foo 
(   
  ibutton text NULL,
  severidade int4 NULL,
  dt_insercao timestamptz NULL DEFAULT now()
)

My insert:

insert into foo (ibutton, severidade) values ('aa', 4);

For any cases of the value of 'dt_insersao', which should be default "now", is always going as '2017-06-08 10:35:35'...

I don't have idea where does it's come from this value..

This insert are executed into my continuous transformation.

These inserts are executed into my continuous transformation of the pipelinedb. When I execute in my client PGAdmin, the date are correct.


Solution

  • Not sure how PipelineDB comes into play here, but in Postgres, now() returns the same value for all inserts in a single transaction:

    Quote from the manual

    Since these functions return the start time of the current transaction, their values do not change during the transaction. This is considered a feature: the intent is to allow a single transaction to have a consistent notion of the "current" time, so that multiple modifications within the same transaction bear the same time stamp.

    If you need a different value for each row that is inserted in one transaction use clock_timestamp() instead in your table definition.