pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #6391: insert does not insert correct value
6+ messages / 4 participants
[nested] [flat]
* BUG #6391: insert does not insert correct value
@ 2012-01-10 22:52 john.udick@zionsbancorp.com
2012-01-11 15:13 ` Re: BUG #6391: insert does not insert correct value Kevin Grittner <Kevin.Grittner@wicourts.gov>
2012-01-11 15:21 ` Re: BUG #6391: insert does not insert correct value Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 6+ messages in thread
From: john.udick@zionsbancorp.com @ 2012-01-10 22:52 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 6391
Logged by: John
Email address: john.udick@zionsbancorp.com
PostgreSQL version: 8.4.1
Operating system: CentOS
Description:
I would expect that at the time/date of the of now() and clock_timestamp()
to be equal; which they are. However for the insert this is not true.
select localtimestamp::date, now()::date, clock_timestamp()::date
"2012-01-10";"2012-01-10";"2012-01-10"
multiple row insert:
insert into v002235.array_stg values (1, date_trunc('hours',now()),
current_date, array['101','113'], 'Y')
, (2, localtimestamp::date, current_date
, array['101','113'], 'Y')
, (3, now(), clock_timestamp()::DATE,
array['101','113'], 'Y')
Results
1;"1999-12-31";"1999-12-31";"{101,113}";"Y"
2;"1999-12-31";"1999-12-31";"{101,113}";"Y"
3;"1999-12-31";"2012-01-10";"{101,113}";"Y"
Why is this not the case? I would expect that my records should all have the
same value, not some arbitrary date from the past.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #6391: insert does not insert correct value
2012-01-10 22:52 BUG #6391: insert does not insert correct value john.udick@zionsbancorp.com
@ 2012-01-11 15:13 ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
1 sibling, 0 replies; 6+ messages in thread
From: Kevin Grittner @ 2012-01-11 15:13 UTC (permalink / raw)
To: pgsql-bugs; john.udick@zionsbancorp.com
<john.udick@zionsbancorp.com> wrote:
> PostgreSQL version: 8.4.1
You are missing years of bug fixes. You should be staying more
up-to-date on minor releases.
http://www.postgresql.org/support/versioning/
To review what has been fixed between 8.4.1 and 8.4.10, please look
through the links from 8.4.2 and up on this page and see if any of
them seem to be related:
http://www.postgresql.org/docs/8.4/static/release.html
Or just apply all of those bug fixes and try again.
> I would expect that at the time/date of the of now() and
> clock_timestamp() to be equal;
You would be wrong. The fine manual describes them here:
http://www.postgresql.org/docs/current/interactive/functions-datetime.html#FUNCTIONS-DATETIME-CURREN...
Picking sentences out of that page:
| now() is a traditional PostgreSQL equivalent to
| transaction_timestamp().
| transaction_timestamp() is equivalent to CURRENT_TIMESTAMP, but is
| named to clearly reflect what it returns.
| clock_timestamp() returns the actual current time, and therefore
| its value changes even within a single SQL command.
now() returns the timestamp for the start of the transaction, while
clock_timestamp() grabs a new value from the system clock for every
execution.
None of that, however, seems to be very directly related to the
issue you describe below.
> [results obtained in some unknown fashion from a table of unknown
> description doesn't have expected dates]
> Why is this not the case? I would expect that my records should
> all have the same value, not some arbitrary date from the past.
You haven't provided near enough information for anyone to hazard a
guess why this might be. Are they time columns instead of
timestamp? Do you have triggers which modify the values? There are
all sorts of things that might be happening that you're not telling
us about.
A self-contained test case on a fairly recent minor release would be
useful, if you can create one. Something like this:
intclient=# create table t (id int primary key, d1 date not null, d2
date not null);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"t_pkey" for table "t"
CREATE TABLE
intclient=# insert into t
values
(1, date_trunc('hours',now()), current_date),
(2, localtimestamp::date, current_date),
(3, now(), clock_timestamp()::DATE);
INSERT 0 3
intclient=# select * from t;
id | d1 | d2
----+------------+------------
1 | 2012-01-11 | 2012-01-11
2 | 2012-01-11 | 2012-01-11
3 | 2012-01-11 | 2012-01-11
(3 rows)
You might find this page helpful:
http://wiki.postgresql.org/wiki/Guide_to_reporting_problems
-Kevin
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #6391: insert does not insert correct value
2012-01-10 22:52 BUG #6391: insert does not insert correct value john.udick@zionsbancorp.com
@ 2012-01-11 15:21 ` Tom Lane <tgl@sss.pgh.pa.us>
2012-01-11 16:16 ` Re: BUG #6391: insert does not insert correct value John Udick <John.Udick@zionsbancorp.com>
1 sibling, 1 reply; 6+ messages in thread
From: Tom Lane @ 2012-01-11 15:21 UTC (permalink / raw)
To: john.udick@zionsbancorp.com; +Cc: pgsql-bugs
john.udick@zionsbancorp.com writes:
> I would expect that at the time/date of the of now() and clock_timestamp()
> to be equal; which they are.
Well, they are not in general, but that doesn't appear to be your
problem. You have not shown us a reproducible test case, but I wonder
whether your table has a trigger that is doing date_trunc('year',...)
or something like that on the column value.
regards, tom lane
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #6391: insert does not insert correct value
2012-01-10 22:52 BUG #6391: insert does not insert correct value john.udick@zionsbancorp.com
2012-01-11 15:21 ` Re: BUG #6391: insert does not insert correct value Tom Lane <tgl@sss.pgh.pa.us>
@ 2012-01-11 16:16 ` John Udick <John.Udick@zionsbancorp.com>
2012-01-11 16:37 ` Re: BUG #6391: insert does not insert correct value Kevin Grittner <Kevin.Grittner@wicourts.gov>
0 siblings, 1 reply; 6+ messages in thread
From: John Udick @ 2012-01-11 16:16 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; Kevin.Grittner@wicourts.gov <Kevin.Grittner@wicourts.gov>; +Cc: pgsql-bugs
Following the example provided, this still appears to be a bug. The results are very different when we run the example. We did notice that although now() failed, changing this to 'now()'::date works (using single quotes around now()). I will be working with our administrators to review patches and version levels.
Also, apparently we are not truly a Postgres database, but EMC's Greenplum database. I will be working with our admins and EMC, unless someone in Postgres can point out a specific version that resolved this issue.
drop table if exists t;
create table t
(id int primary key,
d1 date not null,
d2 date not null);
insert into t
values
(1, now(), current_date),
(2, localtimestamp::date, date_in(date_out(current_date))),
(3, 'now()'::date, clock_timestamp()::DATE);
select * from t order by 1;
id | d1 | d2
----+------------+------------
1 | 1999-12-31 | 1999-12-31
2 | 1999-12-31 | 1999-12-31
3 | 2012-01-11 | 2012-01-11
Additional information - select version();
"PostgreSQL 8.2.15 (Greenplum Database 4.1.1.5 build 1) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled on Sep 20 2011 11:09:08"
John Udick | Enterprise Data Warehouse Development
-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: Wednesday, January 11, 2012 8:21 AM
To: John Udick
Cc: pgsql-bugs@postgresql.org
Subject: Re: [BUGS] BUG #6391: insert does not insert correct value
john.udick@zionsbancorp.com writes:
> I would expect that at the time/date of the of now() and clock_timestamp()
> to be equal; which they are.
Well, they are not in general, but that doesn't appear to be your
problem. You have not shown us a reproducible test case, but I wonder
whether your table has a trigger that is doing date_trunc('year',...)
or something like that on the column value.
regards, tom lane
======================================================================
THIS ELECTRONIC MESSAGE, INCLUDING ANY ACCOMPANYING DOCUMENTS, IS CONFIDENTIAL and may contain information that is privileged and exempt from disclosure under applicable law. If you are neither the intended recipient nor responsible for delivering the message to the intended recipient, please note that any dissemination, distribution, copying or the taking of any action in reliance upon the message is strictly prohibited. If you have received this communication in error, please notify the sender immediately. Thank you.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #6391: insert does not insert correct value
2012-01-10 22:52 BUG #6391: insert does not insert correct value john.udick@zionsbancorp.com
2012-01-11 15:21 ` Re: BUG #6391: insert does not insert correct value Tom Lane <tgl@sss.pgh.pa.us>
2012-01-11 16:16 ` Re: BUG #6391: insert does not insert correct value John Udick <John.Udick@zionsbancorp.com>
@ 2012-01-11 16:37 ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
2012-01-11 16:58 ` Re: BUG #6391: insert does not insert correct value Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 6+ messages in thread
From: Kevin Grittner @ 2012-01-11 16:37 UTC (permalink / raw)
To: John Udick <John.Udick@zionsbancorp.com>; +Cc: pgsql-bugs; Tom Lane <tgl@sss.pgh.pa.us>
John Udick <John.Udick@zionsbancorp.com> wrote:
> We did notice that although now() failed, changing this to
> 'now()'::date works (using single quotes around now()).
That seem unrelated to the now() function. Casting a literal to a
date/time/timestamp supports parsing out certain keywords, like
'now', 'today', 'yesterday', and 'tomorrow'. It's probably ignoring
those parentheses.
> Also, apparently we are not truly a Postgres database, but EMC's
> Greenplum database. I will be working with our admins and EMC,
> unless someone in Postgres can point out a specific version that
> resolved this issue.
> "PostgreSQL 8.2.15 (Greenplum Database 4.1.1.5 build 1) on
> x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled
> on Sep 20 2011 11:09:08"
Yeah, I don't know how much the community lists can help with that
implementation. It seems there is a bug in that version, but it
might not be present in the community version.
-Kevin
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #6391: insert does not insert correct value
2012-01-10 22:52 BUG #6391: insert does not insert correct value john.udick@zionsbancorp.com
2012-01-11 15:21 ` Re: BUG #6391: insert does not insert correct value Tom Lane <tgl@sss.pgh.pa.us>
2012-01-11 16:16 ` Re: BUG #6391: insert does not insert correct value John Udick <John.Udick@zionsbancorp.com>
2012-01-11 16:37 ` Re: BUG #6391: insert does not insert correct value Kevin Grittner <Kevin.Grittner@wicourts.gov>
@ 2012-01-11 16:58 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 6+ messages in thread
From: Tom Lane @ 2012-01-11 16:58 UTC (permalink / raw)
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>; +Cc: John Udick <John.Udick@zionsbancorp.com>; pgsql-bugs
"Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
> John Udick <John.Udick@zionsbancorp.com> wrote:
>> "PostgreSQL 8.2.15 (Greenplum Database 4.1.1.5 build 1) on
>> x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled
>> on Sep 20 2011 11:09:08"
> Yeah, I don't know how much the community lists can help with that
> implementation. It seems there is a bug in that version, but it
> might not be present in the community version.
The provided example works for me on PG 8.2.23:
regression=# select * from t order by 1;
id | d1 | d2
----+------------+------------
1 | 2012-01-11 | 2012-01-11
2 | 2012-01-11 | 2012-01-11
3 | 2012-01-11 | 2012-01-11
(3 rows)
and it does not remind me of any known/fixed bug in community 8.2.x.
So I'd have to say this is a Greenplum bug.
regards, tom lane
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2012-01-11 16:58 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-01-10 22:52 BUG #6391: insert does not insert correct value john.udick@zionsbancorp.com
2012-01-11 15:13 ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
2012-01-11 15:21 ` Tom Lane <tgl@sss.pgh.pa.us>
2012-01-11 16:16 ` John Udick <John.Udick@zionsbancorp.com>
2012-01-11 16:37 ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
2012-01-11 16:58 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox