0001-Unbreak-index-optimization-for-LIKE-on-bytea.patch

text/plain

Filename: 0001-Unbreak-index-optimization-for-LIKE-on-bytea.patch
Type: text/plain
Part: 0
Message: Re: cache lookup failed for collation 0

Patch

Format: format-patch
Series: patch 0001
Subject: Unbreak index optimization for LIKE on bytea
File+
src/backend/utils/adt/like_support.c 3 1
From acb1542a1f8ebee9c9d6d9322c64c849b2f23e15 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Fri, 12 Apr 2019 09:49:10 +0200
Subject: [PATCH] Unbreak index optimization for LIKE on bytea

The same code is used to handle both text and bytea, but bytea is not
collation-aware, so we shouldn't call get_collation_isdeterministic()
in that case.
---
 src/backend/utils/adt/like_support.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/backend/utils/adt/like_support.c b/src/backend/utils/adt/like_support.c
index a65e63736c..7528c80f7c 100644
--- a/src/backend/utils/adt/like_support.c
+++ b/src/backend/utils/adt/like_support.c
@@ -267,8 +267,10 @@ match_pattern_prefix(Node *leftop,
 	 * precise error messages.)  (It should be possible to support at least
 	 * Pattern_Prefix_Exact, but no point as along as the actual
 	 * pattern-matching implementations don't support it.)
+	 *
+	 * expr_coll is not set for a non-collation-aware data type such as bytea.
 	 */
-	if (!get_collation_isdeterministic(expr_coll))
+	if (expr_coll && !get_collation_isdeterministic(expr_coll))
 		return NIL;
 
 	/*
-- 
2.21.0