trgm_bugfix_v2.patch
application/octet-stream
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: context
Series: patch v2
| File | + | − |
|---|---|---|
| contrib/pg_trgm/trgm_op.c | 17 | 0 |
*** a/contrib/pg_trgm/trgm_op.c
--- b/contrib/pg_trgm/trgm_op.c
***************
*** 272,278 **** get_wildcard_part(const char *str, int lenstr,
const char *beginword = str;
const char *endword;
char *s = buf;
! bool in_wildcard_meta = false;
bool in_escape = false;
int clen;
--- 272,279 ----
const char *beginword = str;
const char *endword;
char *s = buf;
! bool in_leading_wildcard_meta = false;
! bool in_trailing_wildcard_meta = false;
bool in_escape = false;
int clen;
***************
*** 284,304 **** get_wildcard_part(const char *str, int lenstr,
{
if (in_escape)
{
- in_escape = false;
- in_wildcard_meta = false;
if (iswordchr(beginword))
break;
}
else
{
if (ISESCAPECHAR(beginword))
in_escape = true;
else if (ISWILDCARDCHAR(beginword))
! in_wildcard_meta = true;
else if (iswordchr(beginword))
break;
else
! in_wildcard_meta = false;
}
beginword += pg_mblen(beginword);
}
--- 285,305 ----
{
if (in_escape)
{
if (iswordchr(beginword))
break;
+ in_escape = false;
+ in_leading_wildcard_meta = false;
}
else
{
if (ISESCAPECHAR(beginword))
in_escape = true;
else if (ISWILDCARDCHAR(beginword))
! in_leading_wildcard_meta = true;
else if (iswordchr(beginword))
break;
else
! in_leading_wildcard_meta = false;
}
beginword += pg_mblen(beginword);
}
***************
*** 314,320 **** get_wildcard_part(const char *str, int lenstr,
* meta-character.
*/
*charlen = 0;
! if (!in_wildcard_meta)
{
if (LPADDING > 0)
{
--- 315,321 ----
* meta-character.
*/
*charlen = 0;
! if (!in_leading_wildcard_meta)
{
if (LPADDING > 0)
{
***************
*** 333,347 **** get_wildcard_part(const char *str, int lenstr,
* string boundary. Strip escapes during copy.
*/
endword = beginword;
- in_wildcard_meta = false;
- in_escape = false;
while (endword - str < lenstr)
{
clen = pg_mblen(endword);
if (in_escape)
{
in_escape = false;
- in_wildcard_meta = false;
if (iswordchr(endword))
{
memcpy(s, endword, clen);
--- 334,345 ----
***************
*** 349,355 **** get_wildcard_part(const char *str, int lenstr,
--- 347,361 ----
s += clen;
}
else
+ {
+ /*
+ * Back up endword one byte if the last two characters are
+ * an escape pair, so that subsequent get_wildcard_part will
+ * restart from its escape character.
+ */
+ endword--;
break;
+ }
}
else
{
***************
*** 357,363 **** get_wildcard_part(const char *str, int lenstr,
in_escape = true;
else if (ISWILDCARDCHAR(endword))
{
! in_wildcard_meta = true;
break;
}
else if (iswordchr(endword))
--- 363,369 ----
in_escape = true;
else if (ISWILDCARDCHAR(endword))
{
! in_trailing_wildcard_meta = true;
break;
}
else if (iswordchr(endword))
***************
*** 367,376 **** get_wildcard_part(const char *str, int lenstr,
s += clen;
}
else
- {
- in_wildcard_meta = false;
break;
- }
}
endword += clen;
}
--- 373,379 ----
***************
*** 379,385 **** get_wildcard_part(const char *str, int lenstr,
* Add right padding spaces if last character wasn't wildcard
* meta-character.
*/
! if (!in_wildcard_meta)
{
if (RPADDING > 0)
{
--- 382,388 ----
* Add right padding spaces if last character wasn't wildcard
* meta-character.
*/
! if (!in_trailing_wildcard_meta)
{
if (RPADDING > 0)
{