public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Panu Matilainen <pmatilai@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/rpm] pmatilai-v6: Fix prefix search on sqlite backend (many file triggers not running)
Date: Mon, 23 Nov 2026 09:33:26 GMT [thread overview]
Message-ID: <179542640682.1.1506322305101892734.rpms-rpm-f7ecc585d0d4@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : rpms/rpm
Branch : pmatilai-v6
Commit : f7ecc585d0d46054dd396ffa55b4399bcd8512c3
Author : Panu Matilainen <pmatilai@redhat.com>
Date : 2020-06-10T10:40:39+03:00
Stats : +119/-1 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/rpm/c/f7ecc585d0d46054dd396ffa55b4399bcd8512c3?branch=pmatilai-v6
Log:
Fix prefix search on sqlite backend (many file triggers not running)
---
diff --git a/0001-Fix-completely-broken-prefix-search-on-sqlite-backen.patch b/0001-Fix-completely-broken-prefix-search-on-sqlite-backen.patch
new file mode 100644
index 0000000..ab1e2be
--- /dev/null
+++ b/0001-Fix-completely-broken-prefix-search-on-sqlite-backen.patch
@@ -0,0 +1,114 @@
+From cc897d03255e2a5aa672c40c043ca3fde88b8480 Mon Sep 17 00:00:00 2001
+Message-Id: <cc897d03255e2a5aa672c40c043ca3fde88b8480.1591774714.git.pmatilai@redhat.com>
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Wed, 10 Jun 2020 10:33:06 +0300
+Subject: [PATCH] Fix completely broken prefix search on sqlite backend
+
+The prefix search was so wrong it's a small miracle it ever did anything
+at all. What have I been thinking? Well, I do remember thinking this
+prefix stuff looks kinda fishy but then it seems to work so...
+
+The prefix search belongs to the keyed iterator fetch case of course,
+not the case where we're otherwise iterating over all keys.
+
+Fixes: #1260
+---
+ lib/backend/sqlite.c | 51 +++++++++++++++++++++++---------------------
+ 1 file changed, 27 insertions(+), 24 deletions(-)
+
+diff --git a/lib/backend/sqlite.c b/lib/backend/sqlite.c
+index 8520838df..ee9c62706 100644
+--- a/lib/backend/sqlite.c
++++ b/lib/backend/sqlite.c
+@@ -548,13 +548,24 @@ static unsigned int sqlite_pkgdbKey(dbiIndex dbi, dbiCursor dbc)
+ return sqlite3_column_int(dbc->stmt, 0);
+ }
+
+-static rpmRC sqlite_idxdbByKey(dbiIndex dbi, dbiCursor dbc, const char *keyp, size_t keylen, dbiIndexSet *set)
++static rpmRC sqlite_idxdbByKey(dbiIndex dbi, dbiCursor dbc,
++ const char *keyp, size_t keylen, int searchType,
++ dbiIndexSet *set)
+ {
+- int rc = dbiCursorPrep(dbc, "SELECT hnum, idx FROM '%q' WHERE key=?",
++ int rc = RPMRC_NOTFOUND;
++
++ if (searchType == DBC_PREFIX_SEARCH) {
++ rc = dbiCursorPrep(dbc, "SELECT hnum, idx FROM '%q' "
++ "WHERE MATCH(key,'%q',%d) "
++ "ORDER BY key",
++ dbi->dbi_file, keyp, keylen);
++ } else {
++ rc = dbiCursorPrep(dbc, "SELECT hnum, idx FROM '%q' WHERE key=?",
+ dbi->dbi_file);
++ if (!rc)
++ rc = dbiCursorBindIdx(dbc, keyp, keylen, NULL);
++ }
+
+- if (!rc)
+- rc = dbiCursorBindIdx(dbc, keyp, keylen, NULL);
+
+ if (!rc) {
+ while ((rc = sqlite3_step(dbc->stmt)) == SQLITE_ROW) {
+@@ -576,21 +587,13 @@ static rpmRC sqlite_idxdbByKey(dbiIndex dbi, dbiCursor dbc, const char *keyp, si
+ return rc;
+ }
+
+-static rpmRC sqlite_idxdbIter(dbiIndex dbi, dbiCursor dbc, const char *keyp, size_t keylen, dbiIndexSet *set, int searchType)
++static rpmRC sqlite_idxdbIter(dbiIndex dbi, dbiCursor dbc, dbiIndexSet *set)
+ {
+ int rc = RPMRC_OK;
+
+ if (dbc->stmt == NULL) {
+- if (searchType == DBC_PREFIX_SEARCH) {
+- rc = dbiCursorPrep(dbc, "SELECT DISTINCT key FROM '%q' "
+- "WHERE MATCH(key,'%q',%d) "
+- "ORDER BY key",
+- dbi->dbi_file, keyp, keylen);
+- } else {
+- rc = dbiCursorPrep(dbc, "SELECT DISTINCT key FROM '%q' "
+- "ORDER BY key",
++ rc = dbiCursorPrep(dbc, "SELECT DISTINCT key FROM '%q' ORDER BY key",
+ dbi->dbi_file);
+- }
+ if (set)
+ dbc->subc = dbiCursorInit(dbi, 0);
+ }
+@@ -605,14 +608,14 @@ static rpmRC sqlite_idxdbIter(dbiIndex dbi, dbiCursor dbc, const char *keyp, siz
+ dbc->key = sqlite3_column_blob(dbc->stmt, 0);
+ }
+ dbc->keylen = sqlite3_column_bytes(dbc->stmt, 0);
+- if (set)
+- rc = sqlite_idxdbByKey(dbi, dbc->subc, dbc->key, dbc->keylen, set);
+- rc = RPMRC_OK;
+- } else if (rc == SQLITE_DONE) {
+- if (searchType == DBC_PREFIX_SEARCH && (*set))
++ if (dbc->subc) {
++ rc = sqlite_idxdbByKey(dbi, dbc->subc, dbc->key, dbc->keylen,
++ DBC_NORMAL_SEARCH, set);
++ } else {
+ rc = RPMRC_OK;
+- else
+- rc = RPMRC_NOTFOUND;
++ }
++ } else if (rc == SQLITE_DONE) {
++ rc = RPMRC_NOTFOUND;
+ } else {
+ rc = dbiCursorResult(dbc);
+ }
+@@ -623,10 +626,10 @@ static rpmRC sqlite_idxdbIter(dbiIndex dbi, dbiCursor dbc, const char *keyp, siz
+ static rpmRC sqlite_idxdbGet(dbiIndex dbi, dbiCursor dbc, const char *keyp, size_t keylen, dbiIndexSet *set, int searchType)
+ {
+ int rc;
+- if (keyp && searchType != DBC_PREFIX_SEARCH) {
+- rc = sqlite_idxdbByKey(dbi, dbc, keyp, keylen, set);
++ if (keyp) {
++ rc = sqlite_idxdbByKey(dbi, dbc, keyp, keylen, searchType, set);
+ } else {
+- rc = sqlite_idxdbIter(dbi, dbc, keyp, keylen, set, searchType);
++ rc = sqlite_idxdbIter(dbi, dbc, set);
+ }
+
+ return rc;
+--
+2.26.2
+
diff --git a/rpm.spec b/rpm.spec
index 6624c19..60efa97 100644
--- a/rpm.spec
+++ b/rpm.spec
@@ -25,7 +25,7 @@
%global rpmver 4.16.0
%global snapver beta1
-%global rel 3
+%global rel 4
%global srcver %{rpmver}%{?snapver:-%{snapver}}
%global srcdir %{?snapver:testing}%{!?snapver:rpm-%(echo %{rpmver} | cut -d'.' -f1-2).x}
@@ -61,6 +61,7 @@ Patch6: 0001-find-debuginfo.sh-decompress-DWARF-compressed-ELF-se.patch
# Patches already upstream:
Patch100: 0001-Don-t-auto-enable-IO-flushing-on-non-rotational-disk.patch
Patch101: 0001-metainfo.attr-Fix-execution-of-the-generator.patch
+Patch102: 0001-Fix-completely-broken-prefix-search-on-sqlite-backen.patch
# These are not yet upstream
Patch906: rpm-4.7.1-geode-i686.patch
@@ -554,6 +555,9 @@ fi
%doc doc/librpm/html/*
%changelog
+* Wed Jun 10 2020 Panu Matilainen <pmatilai@redhat.com> - 4.16.0-0.beta1.4
+- Fix prefix search on sqlite backend (many file triggers not running)
+
* Mon Jun 8 2020 Panu Matilainen <pmatilai@redhat.com> - 4.16.0-0.beta1.3
- Unbreak metainfo() provide generation
reply other threads:[~2026-11-23 9:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179542640682.1.1506322305101892734.rpms-rpm-f7ecc585d0d4@fedoraproject.org \
--to=pmatilai@redhat.com \
--cc=git-commits@fedoraproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox