Reduce dependency to money data type in main regression test suite
authorMichael Paquier <michael@paquier.xyz>
Mon, 15 Jan 2024 00:30:16 +0000 (09:30 +0900)
committerMichael Paquier <michael@paquier.xyz>
Mon, 15 Jan 2024 00:30:16 +0000 (09:30 +0900)
Most of these tests have been introduced in 6dd8b0080787, to check for
behaviors related to hashing and hash plans, and money is a data type
with btree support but no hash functions.  These tests are switched to
use varbit instead, to provide the same coverage.

Some other tests historically used money but don't really need it for
what they wanted to test (see rules.sql).  Plans and coverage are
unchanged after the modifications done here.

Support for money may be removed a a later point, but this needs more
discussion.

Discussion: https://postgr.es/m/18240-c5da758d7dc1ecf0@postgresql.org

14 files changed:
src/test/regress/expected/hash_func.out
src/test/regress/expected/multirangetypes.out
src/test/regress/expected/rangetypes.out
src/test/regress/expected/rules.out
src/test/regress/expected/stats_ext.out
src/test/regress/expected/union.out
src/test/regress/expected/with.out
src/test/regress/sql/hash_func.sql
src/test/regress/sql/multirangetypes.sql
src/test/regress/sql/rangetypes.sql
src/test/regress/sql/rules.sql
src/test/regress/sql/stats_ext.sql
src/test/regress/sql/union.sql
src/test/regress/sql/with.sql

index 8e23dc39783692cf7831424bc60d819edc8f4c4e..2d625a247bb91ca1b7eeed79032cb604e76117fe 100644 (file)
@@ -179,11 +179,11 @@ WHERE  hash_array(v)::bit(32) != hash_array_extended(v, 0)::bit(32)
 
 -- array hashing with non-hashable element type
 SELECT v as value, hash_array(v)::bit(32) as standard
-FROM   (VALUES ('{0}'::money[])) x(v);
-ERROR:  could not identify a hash function for type money
+FROM   (VALUES ('{101}'::varbit[])) x(v);
+ERROR:  could not identify a hash function for type bit varying
 SELECT v as value, hash_array_extended(v, 0)::bit(32) as extended0
-FROM   (VALUES ('{0}'::money[])) x(v);
-ERROR:  could not identify an extended hash function for type money
+FROM   (VALUES ('{101}'::varbit[])) x(v);
+ERROR:  could not identify an extended hash function for type bit varying
 SELECT v as value, hashbpchar(v)::bit(32) as standard,
        hashbpcharextended(v, 0)::bit(32) as extended0,
        hashbpcharextended(v, 1)::bit(32) as extended1
@@ -331,13 +331,13 @@ WHERE  hash_record(v)::bit(32) != hash_record_extended(v, 0)::bit(32)
 
 DROP TYPE hash_test_t1;
 -- record hashing with non-hashable field type
-CREATE TYPE hash_test_t2 AS (a money, b text);
+CREATE TYPE hash_test_t2 AS (a varbit, b text);
 SELECT v as value, hash_record(v)::bit(32) as standard
-FROM   (VALUES (row(1, 'aaa')::hash_test_t2)) x(v);
-ERROR:  could not identify a hash function for type money
+FROM   (VALUES (row('10'::varbit, 'aaa')::hash_test_t2)) x(v);
+ERROR:  could not identify a hash function for type bit varying
 SELECT v as value, hash_record_extended(v, 0)::bit(32) as extended0
-FROM   (VALUES (row(1, 'aaa')::hash_test_t2)) x(v);
-ERROR:  could not identify an extended hash function for type money
+FROM   (VALUES (row('11'::varbit, 'aaa')::hash_test_t2)) x(v);
+ERROR:  could not identify an extended hash function for type bit varying
 DROP TYPE hash_test_t2;
 --
 -- Check special cases for specific data types
index a0cb8754928383f9df74e0c14a05a73295e0adeb..9808587532cdb2a56e9906779e361ed98d2d2c53 100644 (file)
@@ -3273,10 +3273,10 @@ NOTICE:  drop cascades to type two_ints_range
 -- Check behavior when subtype lacks a hash function
 --
 set enable_sort = off;  -- try to make it pick a hash setop implementation
-select '{(2,5)}'::cashmultirange except select '{(5,6)}'::cashmultirange;
- cashmultirange  
------------------
- {($2.00,$5.00)}
+select '{(01,10)}'::varbitmultirange except select '{(10,11)}'::varbitmultirange;
+ varbitmultirange 
+------------------
+ {(01,10)}
 (1 row)
 
 reset enable_sort;
index ee02ff016315ad2cfe1125b920c2fdce90178502..07d5621ef873ef46433ebe8a0ec103646c4def72 100644 (file)
@@ -1761,12 +1761,12 @@ NOTICE:  drop cascades to type two_ints_range
 --
 -- Check behavior when subtype lacks a hash function
 --
-create type cashrange as range (subtype = money);
+create type varbitrange as range (subtype = varbit);
 set enable_sort = off;  -- try to make it pick a hash setop implementation
-select '(2,5)'::cashrange except select '(5,6)'::cashrange;
-   cashrange   
----------------
- ($2.00,$5.00)
+select '(01,10)'::varbitrange except select '(10,11)'::varbitrange;
+ varbitrange 
+-------------
+ (01,10)
 (1 row)
 
 reset enable_sort;
index d878a971df92bd5c2b3bf688e3cdfc66cdabfe34..55f2e95352fca6c656194ed04a4b098dd7e9327e 100644 (file)
@@ -51,9 +51,9 @@ create rule rtest_pers_del as on delete to rtest_person do also
 --
 -- Tables and rules for the logging test
 --
-create table rtest_emp (ename char(20), salary money);
-create table rtest_emplog (ename char(20), who name, action char(10), newsal money, oldsal money);
-create table rtest_empmass (ename char(20), salary money);
+create table rtest_emp (ename char(20), salary numeric);
+create table rtest_emplog (ename char(20), who name, action char(10), newsal numeric, oldsal numeric);
+create table rtest_empmass (ename char(20), salary numeric);
 create rule rtest_emp_ins as on insert to rtest_emp do
    insert into rtest_emplog values (new.ename, current_user,
            'hired', new.salary, '0.00');
@@ -410,13 +410,13 @@ update rtest_emp set ename = 'wieck', salary = '6000.00' where ename = 'wiecx';
 update rtest_emp set salary = '7000.00' where ename = 'wieck';
 delete from rtest_emp where ename = 'gates';
 select ename, who = current_user as "matches user", action, newsal, oldsal from rtest_emplog order by ename, action, newsal;
-        ename         | matches user |   action   |   newsal   |   oldsal   
-----------------------+--------------+------------+------------+------------
- gates                | t            | fired      |      $0.00 | $80,000.00
- gates                | t            | hired      | $80,000.00 |      $0.00
- wiecc                | t            | hired      |  $5,000.00 |      $0.00
- wieck                | t            | honored    |  $6,000.00 |  $5,000.00
- wieck                | t            | honored    |  $7,000.00 |  $6,000.00
+        ename         | matches user |   action   |  newsal  |  oldsal  
+----------------------+--------------+------------+----------+----------
+ gates                | t            | fired      |     0.00 | 80000.00
+ gates                | t            | hired      | 80000.00 |     0.00
+ wiecc                | t            | hired      |  5000.00 |     0.00
+ wieck                | t            | honored    |  6000.00 |  5000.00
+ wieck                | t            | honored    |  7000.00 |  6000.00
 (5 rows)
 
 insert into rtest_empmass values ('meyer', '4000.00');
@@ -424,54 +424,54 @@ insert into rtest_empmass values ('maier', '5000.00');
 insert into rtest_empmass values ('mayr', '6000.00');
 insert into rtest_emp select * from rtest_empmass;
 select ename, who = current_user as "matches user", action, newsal, oldsal from rtest_emplog order by ename, action, newsal;
-        ename         | matches user |   action   |   newsal   |   oldsal   
-----------------------+--------------+------------+------------+------------
- gates                | t            | fired      |      $0.00 | $80,000.00
- gates                | t            | hired      | $80,000.00 |      $0.00
- maier                | t            | hired      |  $5,000.00 |      $0.00
- mayr                 | t            | hired      |  $6,000.00 |      $0.00
- meyer                | t            | hired      |  $4,000.00 |      $0.00
- wiecc                | t            | hired      |  $5,000.00 |      $0.00
- wieck                | t            | honored    |  $6,000.00 |  $5,000.00
- wieck                | t            | honored    |  $7,000.00 |  $6,000.00
+        ename         | matches user |   action   |  newsal  |  oldsal  
+----------------------+--------------+------------+----------+----------
+ gates                | t            | fired      |     0.00 | 80000.00
+ gates                | t            | hired      | 80000.00 |     0.00
+ maier                | t            | hired      |  5000.00 |     0.00
+ mayr                 | t            | hired      |  6000.00 |     0.00
+ meyer                | t            | hired      |  4000.00 |     0.00
+ wiecc                | t            | hired      |  5000.00 |     0.00
+ wieck                | t            | honored    |  6000.00 |  5000.00
+ wieck                | t            | honored    |  7000.00 |  6000.00
 (8 rows)
 
 update rtest_empmass set salary = salary + '1000.00';
 update rtest_emp set salary = rtest_empmass.salary from rtest_empmass where rtest_emp.ename = rtest_empmass.ename;
 select ename, who = current_user as "matches user", action, newsal, oldsal from rtest_emplog order by ename, action, newsal;
-        ename         | matches user |   action   |   newsal   |   oldsal   
-----------------------+--------------+------------+------------+------------
- gates                | t            | fired      |      $0.00 | $80,000.00
- gates                | t            | hired      | $80,000.00 |      $0.00
- maier                | t            | hired      |  $5,000.00 |      $0.00
- maier                | t            | honored    |  $6,000.00 |  $5,000.00
- mayr                 | t            | hired      |  $6,000.00 |      $0.00
- mayr                 | t            | honored    |  $7,000.00 |  $6,000.00
- meyer                | t            | hired      |  $4,000.00 |      $0.00
- meyer                | t            | honored    |  $5,000.00 |  $4,000.00
- wiecc                | t            | hired      |  $5,000.00 |      $0.00
- wieck                | t            | honored    |  $6,000.00 |  $5,000.00
- wieck                | t            | honored    |  $7,000.00 |  $6,000.00
+        ename         | matches user |   action   |  newsal  |  oldsal  
+----------------------+--------------+------------+----------+----------
+ gates                | t            | fired      |     0.00 | 80000.00
+ gates                | t            | hired      | 80000.00 |     0.00
+ maier                | t            | hired      |  5000.00 |     0.00
+ maier                | t            | honored    |  6000.00 |  5000.00
+ mayr                 | t            | hired      |  6000.00 |     0.00
+ mayr                 | t            | honored    |  7000.00 |  6000.00
+ meyer                | t            | hired      |  4000.00 |     0.00
+ meyer                | t            | honored    |  5000.00 |  4000.00
+ wiecc                | t            | hired      |  5000.00 |     0.00
+ wieck                | t            | honored    |  6000.00 |  5000.00
+ wieck                | t            | honored    |  7000.00 |  6000.00
 (11 rows)
 
 delete from rtest_emp using rtest_empmass where rtest_emp.ename = rtest_empmass.ename;
 select ename, who = current_user as "matches user", action, newsal, oldsal from rtest_emplog order by ename, action, newsal;
-        ename         | matches user |   action   |   newsal   |   oldsal   
-----------------------+--------------+------------+------------+------------
- gates                | t            | fired      |      $0.00 | $80,000.00
- gates                | t            | hired      | $80,000.00 |      $0.00
- maier                | t            | fired      |      $0.00 |  $6,000.00
- maier                | t            | hired      |  $5,000.00 |      $0.00
- maier                | t            | honored    |  $6,000.00 |  $5,000.00
- mayr                 | t            | fired      |      $0.00 |  $7,000.00
- mayr                 | t            | hired      |  $6,000.00 |      $0.00
- mayr                 | t            | honored    |  $7,000.00 |  $6,000.00
- meyer                | t            | fired      |      $0.00 |  $5,000.00
- meyer                | t            | hired      |  $4,000.00 |      $0.00
- meyer                | t            | honored    |  $5,000.00 |  $4,000.00
- wiecc                | t            | hired      |  $5,000.00 |      $0.00
- wieck                | t            | honored    |  $6,000.00 |  $5,000.00
- wieck                | t            | honored    |  $7,000.00 |  $6,000.00
+        ename         | matches user |   action   |  newsal  |  oldsal  
+----------------------+--------------+------------+----------+----------
+ gates                | t            | fired      |     0.00 | 80000.00
+ gates                | t            | hired      | 80000.00 |     0.00
+ maier                | t            | fired      |     0.00 |  6000.00
+ maier                | t            | hired      |  5000.00 |     0.00
+ maier                | t            | honored    |  6000.00 |  5000.00
+ mayr                 | t            | fired      |     0.00 |  7000.00
+ mayr                 | t            | hired      |  6000.00 |     0.00
+ mayr                 | t            | honored    |  7000.00 |  6000.00
+ meyer                | t            | fired      |     0.00 |  5000.00
+ meyer                | t            | hired      |  4000.00 |     0.00
+ meyer                | t            | honored    |  5000.00 |  4000.00
+ wiecc                | t            | hired      |  5000.00 |     0.00
+ wieck                | t            | honored    |  6000.00 |  5000.00
+ wieck                | t            | honored    |  7000.00 |  6000.00
 (14 rows)
 
 --
index a430153b225d840888b01b094493b6227a46160a..10903bdab092f5ec78aacf9c30e9bd15a3f7e79e 100644 (file)
@@ -359,7 +359,7 @@ CREATE TABLE ndistinct (
 WITH (autovacuum_enabled = off);
 -- over-estimates when using only per-column statistics
 INSERT INTO ndistinct (a, b, c, filler1)
-     SELECT i/100, i/100, i/100, cash_words((i/100)::money)
+     SELECT i/100, i/100, i/100, (i/100) || ' dollars and zero cents'
        FROM generate_series(1,1000) s(i);
 ANALYZE ndistinct;
 -- Group Aggregate, due to over-estimate of the number of groups
@@ -499,7 +499,7 @@ TRUNCATE TABLE ndistinct;
 -- under-estimates when using only per-column statistics
 INSERT INTO ndistinct (a, b, c, filler1)
      SELECT mod(i,13), mod(i,17), mod(i,19),
-            cash_words(mod(i,23)::int::money)
+            mod(i,23) || ' dollars and zero cents'
        FROM generate_series(1,1000) s(i);
 ANALYZE ndistinct;
 SELECT s.stxkind, d.stxdndistinct
index 64cebe483367c79b59ee8505e12eb57f2afa2cd4..73e320bad47af91560942084fd227953dc711419 100644 (file)
@@ -479,7 +479,7 @@ reset enable_hashagg;
 -- non-hashable type
 set enable_hashagg to on;
 explain (costs off)
-select x from (values (100::money), (200::money)) _(x) union select x from (values (100::money), (300::money)) _(x);
+select x from (values ('11'::varbit), ('10'::varbit)) _(x) union select x from (values ('11'::varbit), ('10'::varbit)) _(x);
                   QUERY PLAN                   
 -----------------------------------------------
  Unique
@@ -492,7 +492,7 @@ select x from (values (100::money), (200::money)) _(x) union select x from (valu
 
 set enable_hashagg to off;
 explain (costs off)
-select x from (values (100::money), (200::money)) _(x) union select x from (values (100::money), (300::money)) _(x);
+select x from (values ('11'::varbit), ('10'::varbit)) _(x) union select x from (values ('11'::varbit), ('10'::varbit)) _(x);
                   QUERY PLAN                   
 -----------------------------------------------
  Unique
@@ -563,7 +563,7 @@ select x from (values (array[1, 2]), (array[1, 3])) _(x) except select x from (v
 
 -- non-hashable type
 explain (costs off)
-select x from (values (array[100::money]), (array[200::money])) _(x) union select x from (values (array[100::money]), (array[300::money])) _(x);
+select x from (values (array['10'::varbit]), (array['11'::varbit])) _(x) union select x from (values (array['10'::varbit]), (array['01'::varbit])) _(x);
                   QUERY PLAN                   
 -----------------------------------------------
  Unique
@@ -574,12 +574,12 @@ select x from (values (array[100::money]), (array[200::money])) _(x) union selec
                ->  Values Scan on "*VALUES*_1"
 (6 rows)
 
-select x from (values (array[100::money]), (array[200::money])) _(x) union select x from (values (array[100::money]), (array[300::money])) _(x);
-     x     
------------
- {$100.00}
- {$200.00}
- {$300.00}
+select x from (values (array['10'::varbit]), (array['11'::varbit])) _(x) union select x from (values (array['10'::varbit]), (array['01'::varbit])) _(x);
+  x   
+------
+ {01}
+ {10}
+ {11}
 (3 rows)
 
 set enable_hashagg to off;
@@ -710,7 +710,7 @@ select x from (values (row(1, 2)), (row(1, 3))) _(x) except select x from (value
 -- With an anonymous row type, the typcache does not report that the
 -- type is hashable.  (Otherwise, this would fail at execution time.)
 explain (costs off)
-select x from (values (row(100::money)), (row(200::money))) _(x) union select x from (values (row(100::money)), (row(300::money))) _(x);
+select x from (values (row('10'::varbit)), (row('11'::varbit))) _(x) union select x from (values (row('10'::varbit)), (row('01'::varbit))) _(x);
                   QUERY PLAN                   
 -----------------------------------------------
  Unique
@@ -721,19 +721,19 @@ select x from (values (row(100::money)), (row(200::money))) _(x) union select x
                ->  Values Scan on "*VALUES*_1"
 (6 rows)
 
-select x from (values (row(100::money)), (row(200::money))) _(x) union select x from (values (row(100::money)), (row(300::money))) _(x);
-     x     
------------
- ($100.00)
- ($200.00)
- ($300.00)
+select x from (values (row('10'::varbit)), (row('11'::varbit))) _(x) union select x from (values (row('10'::varbit)), (row('01'::varbit))) _(x);
+  x   
+------
+ (01)
+ (10)
+ (11)
 (3 rows)
 
 -- With a defined row type, the typcache can inspect the type's fields
 -- for hashability.
-create type ct1 as (f1 money);
+create type ct1 as (f1 varbit);
 explain (costs off)
-select x from (values (row(100::money)::ct1), (row(200::money)::ct1)) _(x) union select x from (values (row(100::money)::ct1), (row(300::money)::ct1)) _(x);
+select x from (values (row('10'::varbit)::ct1), (row('11'::varbit)::ct1)) _(x) union select x from (values (row('10'::varbit)::ct1), (row('01'::varbit)::ct1)) _(x);
                   QUERY PLAN                   
 -----------------------------------------------
  Unique
@@ -744,12 +744,12 @@ select x from (values (row(100::money)::ct1), (row(200::money)::ct1)) _(x) union
                ->  Values Scan on "*VALUES*_1"
 (6 rows)
 
-select x from (values (row(100::money)::ct1), (row(200::money)::ct1)) _(x) union select x from (values (row(100::money)::ct1), (row(300::money)::ct1)) _(x);
-     x     
------------
- ($100.00)
- ($200.00)
- ($300.00)
+select x from (values (row('10'::varbit)::ct1), (row('11'::varbit)::ct1)) _(x) union select x from (values (row('10'::varbit)::ct1), (row('01'::varbit)::ct1)) _(x);
+  x   
+------
+ (01)
+ (10)
+ (11)
 (3 rows)
 
 drop type ct1;
index 3cf969d938257ea251b6845140614758e9f0ea4a..7d796ea69cd7637d7daa030141070707ae41d636 100644 (file)
@@ -51,11 +51,11 @@ SELECT * FROM t;
 
 -- UNION DISTINCT requires hashable type
 WITH RECURSIVE t(n) AS (
-    VALUES (1::money)
+    VALUES ('01'::varbit)
 UNION
-    SELECT n+1::money FROM t WHERE n < 100::money
+    SELECT n || '10'::varbit FROM t WHERE n < '100'::varbit
 )
-SELECT sum(n) FROM t;
+SELECT n FROM t;
 ERROR:  could not implement recursive UNION
 DETAIL:  All column datatypes must be hashable.
 -- recursive view
index 5ad33c1f9d4bbd196f771797a3ceaaed871dd966..33756bd288ff3f517d3d8537ae422fea1d6c29dd 100644 (file)
@@ -132,9 +132,9 @@ WHERE  hash_array(v)::bit(32) != hash_array_extended(v, 0)::bit(32)
 
 -- array hashing with non-hashable element type
 SELECT v as value, hash_array(v)::bit(32) as standard
-FROM   (VALUES ('{0}'::money[])) x(v);
+FROM   (VALUES ('{101}'::varbit[])) x(v);
 SELECT v as value, hash_array_extended(v, 0)::bit(32) as extended0
-FROM   (VALUES ('{0}'::money[])) x(v);
+FROM   (VALUES ('{101}'::varbit[])) x(v);
 
 SELECT v as value, hashbpchar(v)::bit(32) as standard,
        hashbpcharextended(v, 0)::bit(32) as extended0,
@@ -247,11 +247,11 @@ WHERE  hash_record(v)::bit(32) != hash_record_extended(v, 0)::bit(32)
 DROP TYPE hash_test_t1;
 
 -- record hashing with non-hashable field type
-CREATE TYPE hash_test_t2 AS (a money, b text);
+CREATE TYPE hash_test_t2 AS (a varbit, b text);
 SELECT v as value, hash_record(v)::bit(32) as standard
-FROM   (VALUES (row(1, 'aaa')::hash_test_t2)) x(v);
+FROM   (VALUES (row('10'::varbit, 'aaa')::hash_test_t2)) x(v);
 SELECT v as value, hash_record_extended(v, 0)::bit(32) as extended0
-FROM   (VALUES (row(1, 'aaa')::hash_test_t2)) x(v);
+FROM   (VALUES (row('11'::varbit, 'aaa')::hash_test_t2)) x(v);
 DROP TYPE hash_test_t2;
 
 --
index fefb4b4d422d3634d6d5aeb9bf87e66957e30fe8..cadf312031ff95df793fcada3e55621dbf60ca0b 100644 (file)
@@ -802,7 +802,7 @@ drop type two_ints cascade;
 
 set enable_sort = off;  -- try to make it pick a hash setop implementation
 
-select '{(2,5)}'::cashmultirange except select '{(5,6)}'::cashmultirange;
+select '{(01,10)}'::varbitmultirange except select '{(10,11)}'::varbitmultirange;
 
 reset enable_sort;
 
index c23be928c323f989a46f638c34502d5fec2cc012..c5dbe0c04f1bb6f503a9ce80fd536b6ece853ec5 100644 (file)
@@ -575,11 +575,11 @@ drop type two_ints cascade;
 -- Check behavior when subtype lacks a hash function
 --
 
-create type cashrange as range (subtype = money);
+create type varbitrange as range (subtype = varbit);
 
 set enable_sort = off;  -- try to make it pick a hash setop implementation
 
-select '(2,5)'::cashrange except select '(5,6)'::cashrange;
+select '(01,10)'::varbitrange except select '(10,11)'::varbitrange;
 
 reset enable_sort;
 
index 8b7e255dcd22d560fb660b69dbcaa895f868bce3..93aff4e66fff5e8b8a52b69b84dee66ea9f0244c 100644 (file)
@@ -57,9 +57,9 @@ create rule rtest_pers_del as on delete to rtest_person do also
 --
 -- Tables and rules for the logging test
 --
-create table rtest_emp (ename char(20), salary money);
-create table rtest_emplog (ename char(20), who name, action char(10), newsal money, oldsal money);
-create table rtest_empmass (ename char(20), salary money);
+create table rtest_emp (ename char(20), salary numeric);
+create table rtest_emplog (ename char(20), who name, action char(10), newsal numeric, oldsal numeric);
+create table rtest_empmass (ename char(20), salary numeric);
 
 create rule rtest_emp_ins as on insert to rtest_emp do
    insert into rtest_emplog values (new.ename, current_user,
index 90b625a5a2016ebeeaeea3ce740a9886ca533775..42cb7dd97d4af05f8c5eb78fa4faa5a060798a6e 100644 (file)
@@ -234,7 +234,7 @@ WITH (autovacuum_enabled = off);
 
 -- over-estimates when using only per-column statistics
 INSERT INTO ndistinct (a, b, c, filler1)
-     SELECT i/100, i/100, i/100, cash_words((i/100)::money)
+     SELECT i/100, i/100, i/100, (i/100) || ' dollars and zero cents'
        FROM generate_series(1,1000) s(i);
 
 ANALYZE ndistinct;
@@ -299,7 +299,7 @@ TRUNCATE TABLE ndistinct;
 -- under-estimates when using only per-column statistics
 INSERT INTO ndistinct (a, b, c, filler1)
      SELECT mod(i,13), mod(i,17), mod(i,19),
-            cash_words(mod(i,23)::int::money)
+            mod(i,23) || ' dollars and zero cents'
        FROM generate_series(1,1000) s(i);
 
 ANALYZE ndistinct;
index 599013e7c9d290620626f7656e300e213eb14b6e..6c509ac80cb6830f603a071ff352890af3e8fad9 100644 (file)
@@ -162,12 +162,12 @@ reset enable_hashagg;
 set enable_hashagg to on;
 
 explain (costs off)
-select x from (values (100::money), (200::money)) _(x) union select x from (values (100::money), (300::money)) _(x);
+select x from (values ('11'::varbit), ('10'::varbit)) _(x) union select x from (values ('11'::varbit), ('10'::varbit)) _(x);
 
 set enable_hashagg to off;
 
 explain (costs off)
-select x from (values (100::money), (200::money)) _(x) union select x from (values (100::money), (300::money)) _(x);
+select x from (values ('11'::varbit), ('10'::varbit)) _(x) union select x from (values ('11'::varbit), ('10'::varbit)) _(x);
 
 reset enable_hashagg;
 
@@ -186,8 +186,8 @@ select x from (values (array[1, 2]), (array[1, 3])) _(x) except select x from (v
 
 -- non-hashable type
 explain (costs off)
-select x from (values (array[100::money]), (array[200::money])) _(x) union select x from (values (array[100::money]), (array[300::money])) _(x);
-select x from (values (array[100::money]), (array[200::money])) _(x) union select x from (values (array[100::money]), (array[300::money])) _(x);
+select x from (values (array['10'::varbit]), (array['11'::varbit])) _(x) union select x from (values (array['10'::varbit]), (array['01'::varbit])) _(x);
+select x from (values (array['10'::varbit]), (array['11'::varbit])) _(x) union select x from (values (array['10'::varbit]), (array['01'::varbit])) _(x);
 
 set enable_hashagg to off;
 
@@ -221,15 +221,15 @@ select x from (values (row(1, 2)), (row(1, 3))) _(x) except select x from (value
 -- With an anonymous row type, the typcache does not report that the
 -- type is hashable.  (Otherwise, this would fail at execution time.)
 explain (costs off)
-select x from (values (row(100::money)), (row(200::money))) _(x) union select x from (values (row(100::money)), (row(300::money))) _(x);
-select x from (values (row(100::money)), (row(200::money))) _(x) union select x from (values (row(100::money)), (row(300::money))) _(x);
+select x from (values (row('10'::varbit)), (row('11'::varbit))) _(x) union select x from (values (row('10'::varbit)), (row('01'::varbit))) _(x);
+select x from (values (row('10'::varbit)), (row('11'::varbit))) _(x) union select x from (values (row('10'::varbit)), (row('01'::varbit))) _(x);
 
 -- With a defined row type, the typcache can inspect the type's fields
 -- for hashability.
-create type ct1 as (f1 money);
+create type ct1 as (f1 varbit);
 explain (costs off)
-select x from (values (row(100::money)::ct1), (row(200::money)::ct1)) _(x) union select x from (values (row(100::money)::ct1), (row(300::money)::ct1)) _(x);
-select x from (values (row(100::money)::ct1), (row(200::money)::ct1)) _(x) union select x from (values (row(100::money)::ct1), (row(300::money)::ct1)) _(x);
+select x from (values (row('10'::varbit)::ct1), (row('11'::varbit)::ct1)) _(x) union select x from (values (row('10'::varbit)::ct1), (row('01'::varbit)::ct1)) _(x);
+select x from (values (row('10'::varbit)::ct1), (row('11'::varbit)::ct1)) _(x) union select x from (values (row('10'::varbit)::ct1), (row('01'::varbit)::ct1)) _(x);
 drop type ct1;
 
 set enable_hashagg to off;
index ff68e21e2e6d226a1b33d23953525ed571f8fecd..f8a213e357040915e905c5ec8711cea72dc1a20d 100644 (file)
@@ -33,11 +33,11 @@ SELECT * FROM t;
 
 -- UNION DISTINCT requires hashable type
 WITH RECURSIVE t(n) AS (
-    VALUES (1::money)
+    VALUES ('01'::varbit)
 UNION
-    SELECT n+1::money FROM t WHERE n < 100::money
+    SELECT n || '10'::varbit FROM t WHERE n < '100'::varbit
 )
-SELECT sum(n) FROM t;
+SELECT n FROM t;
 
 -- recursive view
 CREATE RECURSIVE VIEW nums (n) AS