diff options
| author | Tom Lane | 2009-04-04 04:53:51 +0000 |
|---|---|---|
| committer | Tom Lane | 2009-04-04 04:53:51 +0000 |
| commit | bb11b0e53c321578258b4c0f14d70762a55a02c9 (patch) | |
| tree | 278efce284c9619a7a224a8e09928b409bd83baf /src/test | |
| parent | af4ebb272e21dec5cb59223ea2ac95d82900ad77 (diff) | |
Rewrite interval_hash() so that the hashcodes are equal for values that
interval_eq() considers equal. I'm not sure how that fundamental requirement
escaped us through multiple revisions of this hash function, but there it is;
it's been wrong since interval_hash was first written for PG 7.1.
Per bug #4748 from Roman Kononov.
Backpatch to all supported releases.
This patch changes the contents of hash indexes for interval columns. That's
no particular problem for PG 8.4, since we've broken on-disk compatibility
of hash indexes already; but it will require a migration warning note in
the next minor releases of all existing branches: "if you have any hash
indexes on columns of type interval, REINDEX them after updating".
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/interval.out | 13 | ||||
| -rw-r--r-- | src/test/regress/sql/interval.sql | 6 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/test/regress/expected/interval.out b/src/test/regress/expected/interval.out index 17b18a1a0f9..0a54b06cda1 100644 --- a/src/test/regress/expected/interval.out +++ b/src/test/regress/expected/interval.out @@ -264,3 +264,16 @@ SELECT '5.5 seconds 3 milliseconds'::interval; -- error ERROR: invalid input syntax for type interval: "5.5 seconds 3 milliseconds" SELECT '1:20:05 5 microseconds'::interval; -- error ERROR: invalid input syntax for type interval: "1:20:05 5 microseconds" +-- check that '30 days' equals '1 month' according to the hash function +select '30 days'::interval = '1 month'::interval as t; + t +--- + t +(1 row) + +select interval_hash('30 days'::interval) = interval_hash('1 month'::interval) as t; + t +--- + t +(1 row) + diff --git a/src/test/regress/sql/interval.sql b/src/test/regress/sql/interval.sql index 920ce8a09a4..540b887992d 100644 --- a/src/test/regress/sql/interval.sql +++ b/src/test/regress/sql/interval.sql @@ -85,4 +85,8 @@ SELECT '3 days 5 milliseconds'::interval; SELECT '1 second 2 seconds'::interval; -- error SELECT '10 milliseconds 20 milliseconds'::interval; -- error SELECT '5.5 seconds 3 milliseconds'::interval; -- error -SELECT '1:20:05 5 microseconds'::interval; -- error
\ No newline at end of file +SELECT '1:20:05 5 microseconds'::interval; -- error + +-- check that '30 days' equals '1 month' according to the hash function +select '30 days'::interval = '1 month'::interval as t; +select interval_hash('30 days'::interval) = interval_hash('1 month'::interval) as t; |
