Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6db75ed

Browse files
committed
Update contrib/trgm_regexp's memory management.
While no code change was necessary for this code to keep working, wedon't need to use PG_TRY()/PG_FINALLY() with explicit clean-up whileworking with regexes anymore.Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://postgr.es/m/CA%2BhUKGK3PGKwcKqzoosamn36YW-fsuTdOPPF1i_rtEO%3DnEYKSg%40mail.gmail.com
1 parent4f51429 commit6db75ed

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

‎contrib/pg_trgm/trgm_regexp.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -549,22 +549,9 @@ createTrgmNFA(text *text_re, Oid collation,
549549
REG_ADVANCED |REG_NOSUB,collation);
550550
#endif
551551

552-
/*
553-
* Since the regexp library allocates its internal data structures with
554-
* malloc, we need to use a PG_TRY block to ensure that pg_regfree() gets
555-
* done even if there's an error.
556-
*/
557-
PG_TRY();
558-
{
559-
trg=createTrgmNFAInternal(&regex,graph,rcontext);
560-
}
561-
PG_FINALLY();
562-
{
563-
pg_regfree(&regex);
564-
}
565-
PG_END_TRY();
552+
trg=createTrgmNFAInternal(&regex,graph,rcontext);
566553

567-
/* Clean up all the cruft we created */
554+
/* Clean up all the cruft we created(including regex)*/
568555
MemoryContextSwitchTo(oldcontext);
569556
MemoryContextDelete(tmpcontext);
570557

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp