I recently encountered a similar symptom (line breaks added for readability):
# pkg info
pkg: Warning: Major OS version upgrade detected. \
Running "pkg-static install -f pkg" recommended
pkg: warning: database version 34 is newer than libpkg(3) version 33, \
but still compatible
pkg: sqlite error while executing INSERT OR ROLLBACK INTO pkg_search(id, name, origin) \
VALUES (?1, ?2 || '-' || ?3, ?4); in file pkgdb.c:1544: \
no such table: pkg_search
I focused on this part of the error message:
no such table: pkg_search
and in my specific case, I was able to resolve my problem by doing:
# cp -p /var/db/pkg/local.sqlite /var/db/pkg/local.sqlite.safety
# sqlite3 /var/db/pkg/local.sqlite
SQLite version 3.28.0 2019-04-16 19:49:53
Enter ".help" for usage hints.
sqlite> CREATE VIRTUAL TABLE pkg_search USING fts4(id, name, origin);
sqlite> .quit
That particular SQL query is mentioned in this thread from January 2017.
After that SQL incantation, pkg
became functional again and I was able to upgrade to the latest version of pkg
and then upgrade or reinstall the rest of the packages. This had been a 10.x to 12.x migration, so after upgrading pkg
I did pkg upgrade -f
on everything, and wound up with no more warnings or sqlite3
errors:
# pkg -N; pkg info; pkg upgrade
pkg: 15 packages installed
apache24-2.4.41 Version 2.4.x of Apache web server
apr-1.7.0.1.6.1 Apache Portability Library
bash-5.0.7 GNU Project's Bourne Again SHell
db5-5.3.28_7 Oracle Berkeley DB, revision 5.3
expat-2.2.6_1 XML 1.0 parser written in C
gdbm-1.18.1_1 GNU database manager
gettext-runtime-0.20.1 GNU gettext runtime libraries and programs
indexinfo-0.3.1 Utility to regenerate the GNU info page index
libnghttp2-1.39.2 HTTP/2.0 C Library
libxml2-2.9.9 XML parser library for GNOME
linux_base-f10-10_10 Base set of packages needed in Linux mode for i386/amd64 (Linux Fedora 10)
pcre-8.43_2 Perl Compatible Regular Expressions library
perl5-5.30.0 Practical Extraction and Report Language
pkg-1.11.1 Package manager
readline-8.0.0 Library for editing command lines as they are typed
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Checking for upgrades (0 candidates): 100%
Processing candidates (0 candidates): 100%
Checking integrity... done (0 conflicting)
Your packages are up to date.