pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Unit tests and ordering
3+ messages / 2 participants
[nested] [flat]

* Unit tests and ordering
@ 2009-04-19 18:17 John Lister <john.lister-ps@kickstone.com>
  2009-04-20 01:09 ` Re: Unit tests and ordering Craig Ringer <craig@postnewspapers.com.au>
  0 siblings, 1 reply; 3+ messages in thread

From: John Lister @ 2009-04-19 18:17 UTC (permalink / raw)
  To: pgsql-jdbc

Hi, i'm just running the unit tests against my database and came across
a couple of errors:

For example in the date tests, a number of dates are inserted and then
read back. In my setup this fails with the wrong values being returned.

This seems to be an ordering problem.. The dates are inserted and then
the test relies on them being returned in the same order they were
inserted. I'm fairly sure that this isn't guaranteed when using SQL,
however it looks like it probably worked before. I'm using server
version 8.3.5 and the latest cvs jdbc source.

Anyone else experienced this?






^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Unit tests and ordering
  2009-04-19 18:17 Unit tests and ordering John Lister <john.lister-ps@kickstone.com>
@ 2009-04-20 01:09 ` Craig Ringer <craig@postnewspapers.com.au>
  2009-04-20 08:47   ` Re: Unit tests and ordering John Lister <john.lister-ps@kickstone.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Craig Ringer @ 2009-04-20 01:09 UTC (permalink / raw)
  To: John Lister <john.lister-ps@kickstone.com>; +Cc: pgsql-jdbc

John Lister wrote:

> This seems to be an ordering problem.. The dates are inserted and then
> the test relies on them being returned in the same order they were
> inserted. I'm fairly sure that this isn't guaranteed when using SQL,

Correct. Your tests are broken, you REALLY need an ORDER BY clause if 
you depend on the order of the result set. Alternately, adjust your 
tests to not care about the result set order.

> however it looks like it probably worked before.

The only major change I can personally think of that might've affected 
that is synchronized scans. If you have more than one backend reading 
the table at once using a sequential scan, one of them will usually pick 
up part-way through the table then go back to the beginning once it hits 
the end. I'm not sure if that's likely to be related to what you're seeing.

In any case, you REALLY need an appropriate ORDER BY clause.

--
Craig Ringer



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Unit tests and ordering
  2009-04-19 18:17 Unit tests and ordering John Lister <john.lister-ps@kickstone.com>
  2009-04-20 01:09 ` Re: Unit tests and ordering Craig Ringer <craig@postnewspapers.com.au>
@ 2009-04-20 08:47   ` John Lister <john.lister-ps@kickstone.com>
  0 siblings, 0 replies; 3+ messages in thread

From: John Lister @ 2009-04-20 08:47 UTC (permalink / raw)
  To: Craig Ringer <craig@postnewspapers.com.au>; +Cc: pgsql-jdbc

>> This seems to be an ordering problem.. The dates are inserted and then
>> the test relies on them being returned in the same order they were
>> inserted. I'm fairly sure that this isn't guaranteed when using SQL,
>
> Correct. Your tests are broken, you REALLY need an ORDER BY clause if you 
> depend on the order of the result set. Alternately, adjust your tests to 
> not care about the result set order.

I thought so...

>> however it looks like it probably worked before.
>
> The only major change I can personally think of that might've affected 
> that is synchronized scans. If you have more than one backend reading the 
> table at once using a sequential scan, one of them will usually pick up 
> part-way through the table then go back to the beginning once it hits the 
> end. I'm not sure if that's likely to be related to what you're seeing.
>
> In any case, you REALLY need an appropriate ORDER BY clause.

It should be simple to correct the tests, by adding a serial id field and 
ordering on that...

Thanks

JOHN 




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2009-04-20 08:47 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-04-19 18:17 Unit tests and ordering John Lister <john.lister-ps@kickstone.com>
2009-04-20 01:09 ` Craig Ringer <craig@postnewspapers.com.au>
2009-04-20 08:47   ` John Lister <john.lister-ps@kickstone.com>

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