From: | Japin Li <japinli(at)hotmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Alexander Lakhin <exclusion(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Index-only scan for btree_gist turns bpchar to char |
Date: | 2022-01-06 10:50:45 |
Message-ID: | MEYP282MB1669E021101B962C53C59511B64C9@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, 06 Jan 2022 at 00:34, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Japin Li <japinli(at)hotmail(dot)com> writes:
>> Here is a patch for POC testing.
>
> This is certainly not right. You've made gbt_bpchar_consistent
> work identically to gbt_text_consistent, but it needs to implement
> a test equivalent to bpchareq, ie ignore trailing spaces in both
> inputs.
>
Thanks for your explaintion! The bpchareq already ignore trailing spaces
in both inputs. The question is that the bpchar in btree_gist do not call
bpchareq, it always call texteq. I tried the patch[1] and it works as
expected, howerver, I don't think it's good way to fix this problem.
> The minimum-effort fix would be to apply rtrim1 to both strings
> in gbt_bpchar_consistent, but I wonder if we can improve on that
> by pushing the ignore-trailing-spaces behavior further down.
> I didn't look yet at whether gbt_var_consistent can support
> any type-specific behavior.
>
Adding type-specific for gbt_var_consistent looks like more generally.
For example, for bpchar type, we should call bpchareq rather than texteq.
Am I understand right?
--
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.
[1]
diff --git a/contrib/btree_gist/btree_text.c b/contrib/btree_gist/btree_text.c
index 8019d11281..7f45ee6e3b 100644
--- a/contrib/btree_gist/btree_text.c
+++ b/contrib/btree_gist/btree_text.c
@@ -121,16 +121,7 @@ gbt_bpchar_compress(PG_FUNCTION_ARGS)
}
if (entry->leafkey)
- {
-
- Datum d = DirectFunctionCall1(rtrim1, entry->key);
- GISTENTRY trim;
-
- gistentryinit(trim, d,
- entry->rel, entry->page,
- entry->offset, true);
- retval = gbt_var_compress(&trim, &tinfo);
- }
+ retval = gbt_var_compress(entry, &tinfo);
else
retval = entry;
@@ -189,6 +180,11 @@ gbt_bpchar_consistent(PG_FUNCTION_ARGS)
tinfo.eml = pg_database_encoding_max_length();
}
+ r.lower = (bytea *) DatumGetPointer(DirectFunctionCall1(rtrim1,
+ PointerGetDatum(r.lower)));
+ r.upper = (bytea *) DatumGetPointer(DirectFunctionCall1(rtrim1,
+ PointerGetDatum(r.upper)));
+
retval = gbt_var_consistent(&r, trim, strategy, PG_GET_COLLATION(),
GIST_LEAF(entry), &tinfo, fcinfo->flinfo);
PG_RETURN_BOOL(retval);
From | Date | Subject | |
---|---|---|---|
Next Message | Julien Rouhaud | 2022-01-06 10:58:14 | Re: Emit "checkpoint skipped because system is idle" message at LOG level if log_checkpoints is set |
Previous Message | Simon Riggs | 2022-01-06 10:24:09 | Re: Add 64-bit XIDs into PostgreSQL 15 |