summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--database.h6
-rw-r--r--unscoop.c18
2 files changed, 6 insertions, 18 deletions
diff --git a/database.h b/database.h
index eec6cb6..485791b 100644
--- a/database.h
+++ b/database.h
@@ -150,13 +150,9 @@ static inline int dbVersion(sqlite3 *db) {
 
 static const char *InitSQL = {
 	"BEGIN TRANSACTION;"
-	"CREATE TABLE networks ("
-		"network INTEGER PRIMARY KEY,"
-		"name TEXT NOT NULL UNIQUE"
-	");"
 	"CREATE TABLE contexts ("
 		"context INTEGER PRIMARY KEY,"
-		"network INTEGER NOT NULL REFERENCES networks,"
+		"network TEXT NOT NULL,"
 		"name TEXT NOT NULL,"
 		"query BOOLEAN NOT NULL,"
 		"UNIQUE (network, name)"
diff --git a/unscoop.c b/unscoop.c
index 8017f35..fa3a5a2 100644
--- a/unscoop.c
+++ b/unscoop.c
@@ -233,21 +233,14 @@ int main(int argc, char *argv[]) {
 		errx(EX_SOFTWARE, "regcomp: %s: %s", buf, matcher->pattern);
 	}
 
-	sqlite3_stmt *insertNetwork = dbPrepare(
-		db, 0, "INSERT OR IGNORE INTO networks (name) VALUES ($network);"
-	);
-	dbBindText(insertNetwork, 1, network, -1);
-	dbStep(insertNetwork);
-	sqlite3_finalize(insertNetwork);
-
 	sqlite3_stmt *insertContext = dbPrepare(
 		db, 0,
 		"INSERT OR IGNORE INTO contexts (network, name, query)"
-		"SELECT network, $context, $query FROM networks WHERE name = $network;"
+		"VALUES ($network, $context, $query);"
 	);
-	dbBindText(insertContext, 1, context, -1);
-	dbBindInt(insertContext, 2, context[0] != '#' && context[0] != '&');
-	dbBindText(insertContext, 3, network, -1);
+	dbBindText(insertContext, 1, network, -1);
+	dbBindText(insertContext, 2, context, -1);
+	dbBindInt(insertContext, 3, context[0] != '#' && context[0] != '&');
 	dbStep(insertContext);
 	sqlite3_finalize(insertContext);
 
@@ -255,8 +248,7 @@ int main(int argc, char *argv[]) {
 	sqlite3_stmt *selectContext = dbPrepare(
 		db, 0,
 		"SELECT context FROM contexts"
-		" JOIN networks USING (network)"
-		" WHERE networks.name = $network AND contexts.name = $context;"
+		" WHERE network = $network AND name = $context;"
 	);
 	dbBindText(selectContext, 1, network, -1);
 	dbBindText(selectContext, 2, context, -1);
9fce66&follow=1'>Share a cut buffer between all edit buffersJune McEnroe 2022-02-20Assert return values in edit testsJune McEnroe 2022-02-20Move mbs out of struct Edit, use a global bufferJune McEnroe 2022-02-20Clear edit buffer before running commandJune McEnroe 2022-02-20Show indicator in status when window has pending inputJune McEnroe 2022-02-20Use separate edit buffers for each IDJune McEnroe 2022-02-20Make sure new cap is actually larger than new lengthJune McEnroe 2022-02-20Remove unused mbs.len field from struct EditJune McEnroe 2022-02-19Remove unneeded includes in ui.cJune McEnroe 2022-02-19Reimplement tab completeJune McEnroe 2022-02-19Handle errors from editFn, etc.June McEnroe 2022-02-19Reimplement text macrosJune McEnroe 2022-02-19Factor out input handling to input.cJune McEnroe 2022-02-19Factor out window management to window.cJune McEnroe 2022-02-19Enable -Wmissing-prototypesJune McEnroe 2022-02-19Fix edit.[ch] license notice additional permissionsJune McEnroe 2022-02-19Run line editing testsJune McEnroe 2022-02-18Implement new line editing "library"June McEnroe 2022-02-18Simplify cursor positioning in inputJune McEnroe 2022-02-18Fix M-f orderingJune McEnroe 2022-02-12Move sandman build to scripts/MakefileJune McEnroe 2022-02-12Use compat_readpassphrase.c on LinuxJune McEnroe 2022-02-12Copy RPP defines from oconfigureJune McEnroe