Re: Index-only scan for btree_gist turns bpchar to char

2022-01-08 Thread Tom Lane
Alexander Lakhin writes: > (Unfortunately for me) I found no anomalies related to gbt_text_same() > with an index created with the previous implementation. I've added > diagnostic logging that shows when gbt_text_same() returns 0 for keys > that are the equal but have different padding. So I've ob

Re: Index-only scan for btree_gist turns bpchar to char

2022-01-08 Thread Alexander Lakhin
07.01.2022 12:00, Alexander Lakhin wrote: > Hello, > 07.01.2022 09:26, Japin Li wrote: >> On Fri, 07 Jan 2022 at 03:21, Tom Lane wrote: >> >> In any case, if we do need same() to implement the identical >> behavior to bpchareq(), then the other solution isn't sufficient >> either. >> >> So in shor

Re: Index-only scan for btree_gist turns bpchar to char

2022-01-07 Thread Alexander Lakhin
Hello, 07.01.2022 09:26, Japin Li wrote: > On Fri, 07 Jan 2022 at 03:21, Tom Lane wrote: > > In any case, if we do need same() to implement the identical > behavior to bpchareq(), then the other solution isn't sufficient > either. > > So in short, it seems like we ought to do some compatibility te

Re: Index-only scan for btree_gist turns bpchar to char

2022-01-06 Thread Japin Li
On Fri, 07 Jan 2022 at 03:21, Tom Lane wrote: > I looked at this and it does seem like it might work, as per attached > patch. The one thing that is troubling me is that the opclass is set > up to apply gbt_text_same, which is formally the Wrong Thing for bpchar, > because the equality semantic

Re: Index-only scan for btree_gist turns bpchar to char

2022-01-06 Thread Tom Lane
Japin Li writes: > On Thu, 06 Jan 2022 at 00:34, Tom Lane wrote: >> 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 g

Re: Index-only scan for btree_gist turns bpchar to char

2022-01-06 Thread Japin Li
On Thu, 06 Jan 2022 at 00:34, Tom Lane wrote: > Japin Li 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 space

Re: Index-only scan for btree_gist turns bpchar to char

2022-01-05 Thread Tom Lane
Japin Li 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. The minimum-effort fix would be to apply

Re: Index-only scan for btree_gist turns bpchar to char

2022-01-05 Thread Japin Li
On Wed, 05 Jan 2022 at 03:19, Tom Lane wrote: > Alexander Lakhin writes: >> While testing the index-only scan fix, I've discovered that replacing >> the index-only scan with the index scan changes contrib/btree_gist >> output because index-only scan for btree_gist returns a string without >> pa

Re: Index-only scan for btree_gist turns bpchar to char

2022-01-04 Thread Alexander Lakhin
04.01.2022 22:19, Tom Lane wrote: > Alexander Lakhin writes: >> While testing the index-only scan fix, I've discovered that replacing >> the index-only scan with the index scan changes contrib/btree_gist >> output because index-only scan for btree_gist returns a string without >> padding. > Ugh, y

Re: Index-only scan for btree_gist turns bpchar to char

2022-01-04 Thread Tom Lane
Alexander Lakhin writes: > While testing the index-only scan fix, I've discovered that replacing > the index-only scan with the index scan changes contrib/btree_gist > output because index-only scan for btree_gist returns a string without > padding. Ugh, yeah. This seems to be because gbt_bpchar