unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH] extindex: --gc: use escape pathnames for SQL LIKE properly
@ 2021-04-24 10:23 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2021-04-24 10:23 UTC (permalink / raw)
  To: meta

This allows us to handle odd inboxes w/o a newsgroup configured
if they also make the strange choice of having backslashes in
their path name.  Also, ensure we use case-sensitive LIKE, since
case-insensitive FSes are not worth supporting.
---
 lib/PublicInbox/ExtSearchIdx.pm | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/PublicInbox/ExtSearchIdx.pm b/lib/PublicInbox/ExtSearchIdx.pm
index a17e7579..9d6b3b9d 100644
--- a/lib/PublicInbox/ExtSearchIdx.pm
+++ b/lib/PublicInbox/ExtSearchIdx.pm
@@ -336,9 +336,11 @@ sub eidx_gc {
 	$self->idx_init($opt); # acquire lock via V2Writable::_idx_init
 
 	my $dbh = $self->{oidx}->dbh;
+	$dbh->do('PRAGMA case_sensitive_like = ON'); # only place we use LIKE
 	my $x3_doc = $dbh->prepare('SELECT docid FROM xref3 WHERE ibx_id = ?');
 	my $ibx_ck = $dbh->prepare('SELECT ibx_id,eidx_key FROM inboxes');
-	my $lc_i = $dbh->prepare('SELECT key FROM eidx_meta WHERE key LIKE ?');
+	my $lc_i = $dbh->prepare(<<'');
+SELECT key FROM eidx_meta WHERE key LIKE ? ESCAPE ?
 
 	$ibx_ck->execute;
 	while (my ($ibx_id, $eidx_key) = $ibx_ck->fetchrow_array) {
@@ -354,8 +356,8 @@ DELETE FROM inboxes WHERE ibx_id = ?
 
 		# drop last_commit info
 		my $pat = $eidx_key;
-		$pat =~ s/([_%])/\\$1/g;
-		$lc_i->execute("lc-%:$pat//%");
+		$pat =~ s/([_%\\])/\\$1/g;
+		$lc_i->execute("lc-%:$pat//%", '\\');
 		while (my ($key) = $lc_i->fetchrow_array) {
 			next if $key !~ m!\Alc-v[1-9]+:\Q$eidx_key\E//!;
 			warn "I: removing $key\n";

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-04-24 10:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-24 10:23 [PATCH] extindex: --gc: use escape pathnames for SQL LIKE properly Eric Wong

unofficial mirror of meta@public-inbox.org

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ https://yhetil.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.mail.public-inbox.meta
	nntp://news.public-inbox.org/inbox.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git