user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 2/3] msgmap: use "CREATE TABLE IF NOT EXISTS"
  2020-08-25  3:02  4% [PATCH 0/3] SQLite-related things Eric Wong
@ 2020-08-25  3:02  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2020-08-25  3:02 UTC (permalink / raw)
  To: meta

It's fewer queries and matches what we do in OverIdx.
---
 lib/PublicInbox/Msgmap.pm | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/lib/PublicInbox/Msgmap.pm b/lib/PublicInbox/Msgmap.pm
index 7290959d..5b4cebc1 100644
--- a/lib/PublicInbox/Msgmap.pm
+++ b/lib/PublicInbox/Msgmap.pm
@@ -175,18 +175,20 @@ sub num_delete {
 
 sub create_tables {
 	my ($dbh) = @_;
-	my $e;
-
-	$e = eval { $dbh->selectrow_array('EXPLAIN SELECT * FROM msgmap;') };
-	defined $e or $dbh->do('CREATE TABLE msgmap (' .
-			'num INTEGER PRIMARY KEY AUTOINCREMENT, '.
-			'mid VARCHAR(1000) NOT NULL, ' .
-			'UNIQUE (mid) )');
-
-	$e = eval { $dbh->selectrow_array('EXPLAIN SELECT * FROM meta') };
-	defined $e or $dbh->do('CREATE TABLE meta (' .
-			'key VARCHAR(32) PRIMARY KEY, '.
-			'val VARCHAR(255) NOT NULL)');
+
+	$dbh->do(<<'');
+CREATE TABLE IF NOT EXISTS msgmap (
+	num INTEGER PRIMARY KEY AUTOINCREMENT,
+	mid VARCHAR(1000) NOT NULL,
+	UNIQUE (mid)
+)
+
+	$dbh->do(<<'');
+CREATE TABLE IF NOT EXISTS meta (
+	key VARCHAR(32) PRIMARY KEY,
+	val VARCHAR(255) NOT NULL
+)
+
 }
 
 # used by NNTP.pm

^ permalink raw reply related	[relevance 7%]

* [PATCH 0/3] SQLite-related things
@ 2020-08-25  3:02  4% Eric Wong
  2020-08-25  3:02  7% ` [PATCH 2/3] msgmap: use "CREATE TABLE IF NOT EXISTS" Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2020-08-25  3:02 UTC (permalink / raw)
  To: meta

While I'm considering options for dealing with SQLite locking
problems <https://public-inbox.org/meta/20200825001204.GA840@dcvr/>,
some obvious cleanups and improvements can be made, here.

We'll now support WAL if (and only if) a user chooses to enable
it; since we can't do it by default (see 3/3 for explanation).

Eric Wong (3):
  over: skip nodatacow on the journal
  msgmap: use "CREATE TABLE IF NOT EXISTS"
  over+msgmap: respect WAL journal_mode if set

 lib/PublicInbox/Msgmap.pm  | 29 ++++++++++++++---------------
 lib/PublicInbox/Over.pm    | 26 ++++++++++++++++++++++----
 lib/PublicInbox/OverIdx.pm |  5 -----
 t/over.t                   | 10 ++++++++++
 4 files changed, 46 insertions(+), 24 deletions(-)

^ permalink raw reply	[relevance 4%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2020-08-25  3:02  4% [PATCH 0/3] SQLite-related things Eric Wong
2020-08-25  3:02  7% ` [PATCH 2/3] msgmap: use "CREATE TABLE IF NOT EXISTS" Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).