Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4e21023

Browse files
committed
Unmark 'hashable' operators that can't really be used for
hashjoins. Extend opr_sanity regress test to help detect similar mistakes.
1 parent 7fcbc5d commit 4e21023

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

src/include/catalog/pg_operator.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: pg_operator.h,v 1.53 1999/03/28 02:01:38 tgl Exp $
10+
* $Id: pg_operator.h,v 1.54 1999/04/07 04:21:10 tgl Exp $
1111
*
1212
* NOTES
1313
* the genbki.sh script reads this file and generates .bki
@@ -88,8 +88,8 @@ typedef FormData_pg_operator *Form_pg_operator;
8888
* ----------------
8989
*/
9090

91-
DATA(insert OID = 15 ( "=" PGUID 0 b t t 23 20 16 416 36 97 412 int48eq eqsel eqjoinsel ));
92-
DATA(insert OID = 36 ( "<>" PGUID 0 b t t 23 20 16 417 15 0 0 int48ne neqsel neqjoinsel ));
91+
DATA(insert OID = 15 ( "=" PGUID 0 b t f 23 20 16 416 36 97 412 int48eq eqsel eqjoinsel ));
92+
DATA(insert OID = 36 ( "<>" PGUID 0 b t f 23 20 16 417 15 0 0 int48ne neqsel neqjoinsel ));
9393
DATA(insert OID = 37 ( "<" PGUID 0 b t f 23 20 16 419 82 0 0 int48lt intltsel intltjoinsel ));
9494
DATA(insert OID = 76 ( ">" PGUID 0 b t f 23 20 16 418 80 0 0 int48gt intgtsel intgtjoinsel ));
9595
DATA(insert OID = 80 ( "<=" PGUID 0 b t f 23 20 16 430 76 0 0 int48le intlesel intlejoinsel ));
@@ -137,14 +137,14 @@ DATA(insert OID = 400 ( "=" PGUID 0 b t t 1027 1027 16 400 0 0 0 array_e
137137
DATA(insert OID = 401 ( "=" PGUID 0 b t t 1034 1034 16 401 0 0 0 array_eq eqsel eqjoinsel ));
138138

139139
DATA(insert OID = 410 ( "=" PGUID 0 b t t 20 20 16 410 411 412 412 int8eq eqsel eqjoinsel ));
140-
DATA(insert OID = 411 ( "<>" PGUID 0 b t t 20 20 16 411 410 0 0 int8ne neqsel neqjoinsel ));
140+
DATA(insert OID = 411 ( "<>" PGUID 0 b t f 20 20 16 411 410 0 0 int8ne neqsel neqjoinsel ));
141141
DATA(insert OID = 412 ( "<" PGUID 0 b t f 20 20 16 413 415 0 0 int8lt intltsel intltjoinsel ));
142142
DATA(insert OID = 413 ( ">" PGUID 0 b t f 20 20 16 412 414 0 0 int8gt intgtsel intgtjoinsel ));
143143
DATA(insert OID = 414 ( "<=" PGUID 0 b t f 20 20 16 415 413 0 0 int8le intlesel intlejoinsel ));
144144
DATA(insert OID = 415 ( ">=" PGUID 0 b t f 20 20 16 414 412 0 0 int8ge intgesel intgejoinsel ));
145145

146-
DATA(insert OID = 416 ( "=" PGUID 0 b t t 20 23 16 15 417 412 97 int84eq eqsel eqjoinsel ));
147-
DATA(insert OID = 417 ( "<>" PGUID 0 b t t 20 23 16 36 416 0 0 int84ne neqsel neqjoinsel ));
146+
DATA(insert OID = 416 ( "=" PGUID 0 b t f 20 23 16 15 417 412 97 int84eq eqsel eqjoinsel ));
147+
DATA(insert OID = 417 ( "<>" PGUID 0 b t f 20 23 16 36 416 0 0 int84ne neqsel neqjoinsel ));
148148
DATA(insert OID = 418 ( "<" PGUID 0 b t f 20 23 16 76 430 0 0 int84lt intltsel intltjoinsel ));
149149
DATA(insert OID = 419 ( ">" PGUID 0 b t f 20 23 16 37 420 0 0 int84gt intgtsel intgtjoinsel ));
150150
DATA(insert OID = 420 ( "<=" PGUID 0 b t f 20 23 16 82 419 0 0 int84le intlesel intlejoinsel ));
@@ -198,8 +198,8 @@ DATA(insert OID = 528 ( "/" PGUID 0 b t f 23 23 23 0 0 0 0 int4div
198198
DATA(insert OID = 529 ( "%" PGUID 0 b t f 21 21 21 0 0 0 0 int2mod - - ));
199199
DATA(insert OID = 530 ( "%" PGUID 0 b t f 23 23 23 0 0 0 0 int4mod - - ));
200200
DATA(insert OID = 531 ( "<>" PGUID 0 b t f 25 25 16 531 98 0 0 textne neqsel neqjoinsel ));
201-
DATA(insert OID = 532 ( "=" PGUID 0 b t t 21 23 16 533 538 95 97 int24eq eqsel eqjoinsel ));
202-
DATA(insert OID = 533 ( "=" PGUID 0 b t t 23 21 16 532 539 97 95 int42eq eqsel eqjoinsel ));
201+
DATA(insert OID = 532 ( "=" PGUID 0 b t f 21 23 16 533 538 95 97 int24eq eqsel eqjoinsel ));
202+
DATA(insert OID = 533 ( "=" PGUID 0 b t f 23 21 16 532 539 97 95 int42eq eqsel eqjoinsel ));
203203
DATA(insert OID = 534 ( "<" PGUID 0 b t f 21 23 16 537 542 0 0 int24lt intltsel intltjoinsel ));
204204
DATA(insert OID = 535 ( "<" PGUID 0 b t f 23 21 16 536 543 0 0 int42lt intltsel intltjoinsel ));
205205
DATA(insert OID = 536 ( ">" PGUID 0 b t f 21 23 16 535 540 0 0 int24gt intgtsel intgtjoinsel ));
@@ -238,7 +238,7 @@ DATA(insert OID = 568 ( "<" PGUID 0 b t f 703 703 16 569 571 0 0 reltimelt
238238
DATA(insert OID = 569 ( ">" PGUID 0 b t f 703 703 16 568 570 0 0 reltimegt - - ));
239239
DATA(insert OID = 570 ( "<=" PGUID 0 b t f 703 703 16 571 569 0 0 reltimele - - ));
240240
DATA(insert OID = 571 ( ">=" PGUID 0 b t f 703 703 16 570 568 0 0 reltimege - - ));
241-
DATA(insert OID = 572 ( "~=" PGUID 0 b t t 704 704 16 572 0 0 0 intervalsame - - ));
241+
DATA(insert OID = 572 ( "~=" PGUID 0 b t f 704 704 16 572 0 0 0 intervalsame - - ));
242242
DATA(insert OID = 573 ( "<<" PGUID 0 b t f 704 704 16 0 0 0 0 intervalct - - ));
243243
DATA(insert OID = 574 ( "&&" PGUID 0 b t f 704 704 16 0 0 0 0 intervalov - - ));
244244
DATA(insert OID = 575 ( "#=" PGUID 0 b t f 704 703 16 0 576 0 0 intervalleneq - - ));
@@ -476,7 +476,7 @@ DATA(insert OID = 1116 ( "+" PGUID 0 b t f 700 701 701 1126 0 0 0 float48pl
476476
DATA(insert OID = 1117 ( "-" PGUID 0 b t f 700 701 701 0 0 0 0 float48mi - - ));
477477
DATA(insert OID = 1118 ( "/" PGUID 0 b t f 700 701 701 0 0 0 0 float48div - - ));
478478
DATA(insert OID = 1119 ( "*" PGUID 0 b t f 700 701 701 1129 0 0 0 float48mul - - ));
479-
DATA(insert OID = 1120 ( "=" PGUID 0 b t t 700 701 16 1130 1121 622 672 float48eq eqsel eqjoinsel ));
479+
DATA(insert OID = 1120 ( "=" PGUID 0 b t f 700 701 16 1130 1121 622 672 float48eq eqsel eqjoinsel ));
480480
DATA(insert OID = 1121 ( "<>" PGUID 0 b t f 700 701 16 1131 1120 0 0 float48ne neqsel neqjoinsel ));
481481
DATA(insert OID = 1122 ( "<" PGUID 0 b t f 700 701 16 1133 1125 0 0 float48lt intltsel intltjoinsel ));
482482
DATA(insert OID = 1123 ( ">" PGUID 0 b t f 700 701 16 1132 1124 0 0 float48gt intgtsel intgtjoinsel ));
@@ -488,7 +488,7 @@ DATA(insert OID = 1126 ( "+" PGUID 0 b t f 701 700 701 1116 0 0 0 float84pl
488488
DATA(insert OID = 1127 ( "-" PGUID 0 b t f 701 700 701 0 0 0 0 float84mi - - ));
489489
DATA(insert OID = 1128 ( "/" PGUID 0 b t f 701 700 701 0 0 0 0 float84div - - ));
490490
DATA(insert OID = 1129 ( "*" PGUID 0 b t f 701 700 701 1119 0 0 0 float84mul - - ));
491-
DATA(insert OID = 1130 ( "=" PGUID 0 b t t 701 700 16 1120 1131 672 622 float84eq eqsel eqjoinsel ));
491+
DATA(insert OID = 1130 ( "=" PGUID 0 b t f 701 700 16 1120 1131 672 622 float84eq eqsel eqjoinsel ));
492492
DATA(insert OID = 1131 ( "<>" PGUID 0 b t f 701 700 16 1121 1130 0 0 float84ne neqsel neqjoinsel ));
493493
DATA(insert OID = 1132 ( "<" PGUID 0 b t f 701 700 16 1123 1135 0 0 float84lt intltsel intltjoinsel ));
494494
DATA(insert OID = 1133 ( ">" PGUID 0 b t f 701 700 16 1122 1134 0 0 float84gt intgtsel intgtjoinsel ));

src/test/regress/expected/opr_sanity.out

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,13 @@ oid|oprname
135135
QUERY: SELECT p1.oid, p1.oprname
136136
FROM pg_operator as p1
137137
WHERE p1.oprcanhash AND NOT
138-
(p1.oprkind = 'b' AND p1.oprresult = 16 AND p1.oprcom != 0);
139-
oid|oprname
140-
---+-------
141-
(0 rows)
138+
(p1.oprkind = 'b' AND p1.oprresult = 16 AND p1.oprleft = p1.oprright AND
139+
p1.oprname = '=' AND p1.oprcom = p1.oid);
140+
oid|oprname
141+
----+-------
142+
1136|=
143+
1137|=
144+
(2 rows)
142145

143146
QUERY: SELECT p1.oid, p1.oprcode, p2.oid, p2.oprcode
144147
FROM pg_operator AS p1, pg_operator AS p2

src/test/regress/sql/opr_sanity.sql

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,15 @@ WHERE (p1.oprleft = 0 and p1.oprkind != 'l') OR
132132
(p1.oprright = 0 and p1.oprkind != 'r') OR
133133
(p1.oprright != 0 and p1.oprkind = 'r');
134134

135-
-- Hash operators should be commutative binary ops returning bool.
135+
-- Hashing only works on simple equality operators "type = sametype",
136+
-- since the hash itself depends on the bitwise representation of the type.
137+
-- Check that allegedly hashable operators look like they might be "=".
136138

137139
SELECT p1.oid, p1.oprname
138140
FROM pg_operator as p1
139141
WHERE p1.oprcanhash AND NOT
140-
(p1.oprkind = 'b' AND p1.oprresult = 16 AND p1.oprcom != 0);
142+
(p1.oprkind = 'b' AND p1.oprresult = 16 AND p1.oprleft = p1.oprright AND
143+
p1.oprname = '=' AND p1.oprcom = p1.oid);
141144

142145
-- Look for conflicting operator definitions (same names and input datatypes).
143146

0 commit comments

Comments
 (0)