@ -2711,15 +2711,16 @@ check_hashjoinable(RestrictInfo *restrictinfo)
/*
/*
* check_memoizable
* check_memoizable
* If the restrictinfo ' s clause is suitable to be used for a Memoize node ,
* If the restrictinfo ' s clause is suitable to be used for a Memoize node ,
* set the hasheqoperator to the hash equality operator that will be needed
* set the lefthasheqoperator and right hasheqoperator to the hash equality
* during caching .
* operator that will be needed during caching .
*/
*/
static void
static void
check_memoizable ( RestrictInfo * restrictinfo )
check_memoizable ( RestrictInfo * restrictinfo )
{
{
TypeCacheEntry * typentry ;
TypeCacheEntry * typentry ;
Expr * clause = restrictinfo - > clause ;
Expr * clause = restrictinfo - > clause ;
Node * leftarg ;
Oid lefttype ;
Oid righttype ;
if ( restrictinfo - > pseudoconstant )
if ( restrictinfo - > pseudoconstant )
return ;
return ;
@ -2728,13 +2729,24 @@ check_memoizable(RestrictInfo *restrictinfo)
if ( list_length ( ( ( OpExpr * ) clause ) - > args ) ! = 2 )
if ( list_length ( ( ( OpExpr * ) clause ) - > args ) ! = 2 )
return ;
return ;
leftarg = linitial ( ( ( OpExpr * ) clause ) - > args ) ;
lefttype = exprType ( linitial ( ( ( OpExpr * ) clause ) - > args ) ) ;
typentry = lookup_type_cache ( exprType ( leftarg ) , TYPECACHE_HASH_PROC |
typentry = lookup_type_cache ( lefttype , TYPECACHE_HASH_PROC |
TYPECACHE_EQ_OPR ) ;
TYPECACHE_EQ_OPR ) ;
if ( ! OidIsValid ( typentry - > hash_proc ) | | ! OidIsValid ( typentry - > eq_opr ) )
if ( OidIsValid ( typentry - > hash_proc ) & & OidIsValid ( typentry - > eq_opr ) )
return ;
restrictinfo - > left_hasheqoperator = typentry - > eq_opr ;
righttype = exprType ( lsecond ( ( ( OpExpr * ) clause ) - > args ) ) ;
/*
* Lookup the right type , unless it ' s the same as the left type , in which
* case typentry is already pointing to the required TypeCacheEntry .
*/
if ( lefttype ! = righttype )
typentry = lookup_type_cache ( righttype , TYPECACHE_HASH_PROC |
TYPECACHE_EQ_OPR ) ;
restrictinfo - > hasheqoperator = typentry - > eq_opr ;
if ( OidIsValid ( typentry - > hash_proc ) & & OidIsValid ( typentry - > eq_opr ) )
restrictinfo - > right_hasheqoperator = typentry - > eq_opr ;
}
}