OSDN Git Service

Provide hashing support for arrays.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 31 Oct 2010 01:55:20 +0000 (21:55 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 31 Oct 2010 01:56:11 +0000 (21:56 -0400)
commit186cbbda8f8dc5e42f68fc7892f206a76d56a20f
tree2c909d8365726683a61515b639c02a9ac00682f4
parentbd1ff9713369c2f54391112b92e0c22ab5c99180
Provide hashing support for arrays.

The core of this patch is hash_array() and associated typcache
infrastructure, which works just about exactly like the existing support
for array comparison.

In addition I did some work to ensure that the planner won't think that an
array type is hashable unless its element type is hashable, and similarly
for sorting.  This includes adding a datatype parameter to op_hashjoinable
and op_mergejoinable, and adding an explicit "hashable" flag to
SortGroupClause.  The lack of a cross-check on the element type was a
pre-existing bug in mergejoin support --- but it didn't matter so much
before, because if you couldn't sort the element type there wasn't any good
alternative to failing anyhow.  Now that we have the alternative of hashing
the array type, there are cases where we can avoid a failure by being picky
at the planner stage, so it's time to be picky.

The issue of exactly how to combine the per-element hash values to produce
an array hash is still open for discussion, but the rest of this is pretty
solid, so I'll commit it as-is.
30 files changed:
src/backend/commands/analyze.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/nodes/outfuncs.c
src/backend/nodes/readfuncs.c
src/backend/optimizer/path/equivclass.c
src/backend/optimizer/plan/createplan.c
src/backend/optimizer/plan/initsplan.c
src/backend/optimizer/plan/planagg.c
src/backend/optimizer/plan/subselect.c
src/backend/optimizer/util/pathnode.c
src/backend/optimizer/util/tlist.c
src/backend/parser/analyze.c
src/backend/parser/parse_clause.c
src/backend/parser/parse_oper.c
src/backend/utils/adt/arrayfuncs.c
src/backend/utils/cache/lsyscache.c
src/backend/utils/cache/typcache.c
src/include/catalog/catversion.h
src/include/catalog/pg_amop.h
src/include/catalog/pg_amproc.h
src/include/catalog/pg_opclass.h
src/include/catalog/pg_operator.h
src/include/catalog/pg_opfamily.h
src/include/catalog/pg_proc.h
src/include/nodes/parsenodes.h
src/include/parser/parse_oper.h
src/include/utils/array.h
src/include/utils/lsyscache.h
src/include/utils/typcache.h