Skip to content

armgit / Vvveb

Public Imported from GitHub
0

Powerful and easy to use cms to build websites, blogs or ecommerce stores.

Sqlite install fixes for full text search virtual tables

givanz835a51126e6d
diff --git a/install/sql/sqlite/schema/post/post_content-fts4.sql b/install/sql/sqlite/schema/post/post_content-fts4.sql
index 587f376..94fce44 100755
--- a/install/sql/sqlite/schema/post/post_content-fts4.sql
+++ b/install/sql/sqlite/schema/post/post_content-fts4.sql
@@ -8,44 +8,45 @@ CREATE TABLE `post_content` (
`content` TEXT,
`excerpt` text,
`meta_keywords` text NOT NULL DEFAULT "",
-`meta_description` text NOT NULL DEFAULT ""
-,PRIMARY KEY (`post_id`,`language_id`)
--- FULLTEXT `search` (`name`,`content`)
+`meta_description` text NOT NULL DEFAULT "",
+PRIMARY KEY (`post_id`,`language_id`)
);
CREATE INDEX `post_content_slug` ON `post_content` (`slug`);
+DROP TRIGGER IF EXISTS `afterPostContentInsert`;
+DROP TRIGGER IF EXISTS `afterPostContentDelete`;
DROP TABLE IF EXISTS `post_content_search`;
-create virtual table post_content_search using fts4(
+CREATE VIRTUAL TABLE post_content_search USING fts4(
content='post_content',
-- content_rowid='rowid',
name,
content
);
-create trigger afterPostContentInsert after insert on post_content begin
- insert into post_content_search(
+create trigger afterPostContentInsert AFTER INSERT ON post_content BEGIN
+ INSERT INTO post_content_search(
rowid,
name,
content
)
- values(
+ VALUES(
new.rowid,
new.name,
new.content
-);end;
+);END;
-create trigger afterPostContentDelete after delete on post_content begin
- insert into post_content_search(
+CREATE TRIGGER afterPostContentDelete AFTER DELETE ON post_content BEGIN
+ INSERT INTO post_content_search(
post_content_search,
rowid,
name,
content
)
- values(
+ VALUES(
'delete',
- old.rowid,
+ old.rowid,
old.name,
old.content
-);end;
+);END;
diff --git a/install/sql/sqlite/schema/post/post_content-fts5.sql b/install/sql/sqlite/schema/post/post_content-fts5.sql
index f61e8da..a627855 100755
--- a/install/sql/sqlite/schema/post/post_content-fts5.sql
+++ b/install/sql/sqlite/schema/post/post_content-fts5.sql
@@ -8,44 +8,45 @@ CREATE TABLE `post_content` (
`content` TEXT,
`excerpt` text,
`meta_keywords` text NOT NULL DEFAULT "",
-`meta_description` text NOT NULL DEFAULT ""
-,PRIMARY KEY (`post_id`,`language_id`)
--- FULLTEXT `search` (`name`,`content`)
+`meta_description` text NOT NULL DEFAULT "",
+PRIMARY KEY (`post_id`,`language_id`)
);
CREATE INDEX `post_content_slug` ON `post_content` (`slug`);
+DROP TRIGGER IF EXISTS `afterPostContentInsert`;
+DROP TRIGGER IF EXISTS `afterPostContentDelete`;
DROP TABLE IF EXISTS `post_content_search`;
-create virtual table post_content_search using fts5(
+CREATE VIRTUAL TABLE post_content_search USING fts5(
content='post_content',
content_rowid='rowid',
name,
content
);
-create trigger afterPostContentInsert after insert on post_content begin
- insert into post_content_search(
+CREATE TRIGGER afterPostContentInsert AFTER INSERT ON post_content BEGIN
+ INSERT INTO post_content_search(
rowid,
name,
content
)
- values(
+ VALUES(
new.rowid,
new.name,
new.content
-);end;
+);END;
-create trigger afterPostContentDelete after delete on post_content begin
- insert into post_content_search(
+CREATE TRIGGER afterPostContentDelete AFTER DELETE ON post_content BEGIN
+ INSERT INTO post_content_search(
post_content_search,
rowid,
name,
content
)
- values(
+ VALUES(
'delete',
old.rowid,
old.name,
old.content
-);end;
+);END;
diff --git a/install/sql/sqlite/schema/product/product_content-fts4.sql b/install/sql/sqlite/schema/product/product_content-fts4.sql
index 706038f..37f07c1 100755
--- a/install/sql/sqlite/schema/product/product_content-fts4.sql
+++ b/install/sql/sqlite/schema/product/product_content-fts4.sql
@@ -19,34 +19,39 @@ CREATE INDEX `product_content_slug` ON `product_content` (`slug`);
DROP TABLE IF EXISTS `product_content_search`;
-create virtual table product_content_search using fts4(
+DROP TRIGGER IF EXISTS `afterproductContentInsert`;
+DROP TRIGGER IF EXISTS `afterproductContentDelete`;
+DROP TABLE IF EXISTS `product_content_search`;
+
+CREATE VIRTUAL TABLE product_content_search USING fts4(
content='product_content',
-- content_rowid='rowid',
name,
content
);
-create trigger afterProductContentInsert after insert on product_content begin
- insert into product_content_search(
+create trigger afterproductContentInsert AFTER INSERT ON product_content BEGIN
+ INSERT INTO product_content_search(
rowid,
name,
content
)
- values(
+ VALUES(
new.rowid,
new.name,
new.content
-);end;
+);END;
-create trigger afterProductContentDelete after delete on product_content begin
- insert into product_content_search(
+CREATE TRIGGER afterproductContentDelete AFTER DELETE ON product_content BEGIN
+ INSERT INTO product_content_search(
product_content_search,
rowid,
name,
content
)
- values(
+ VALUES(
'delete',
+ old.rowid,
old.name,
old.content
-);end;
+);END;
diff --git a/install/sql/sqlite/schema/product/product_content-fts5.sql b/install/sql/sqlite/schema/product/product_content-fts5.sql
index 127b9bd..929a1ac 100755
--- a/install/sql/sqlite/schema/product/product_content-fts5.sql
+++ b/install/sql/sqlite/schema/product/product_content-fts5.sql
@@ -11,42 +11,43 @@ CREATE TABLE `product_content` (
`meta_description` TEXT NOT NULL DEFAULT "",
`meta_keywords` TEXT NOT NULL DEFAULT "",
PRIMARY KEY (`product_id`,`language_id`)
--- FULLTEXT `search` (`name`,`content`)
);
-
CREATE INDEX `product_content_slug` ON `product_content` (`slug`);
+DROP TRIGGER IF EXISTS `afterProductContentInsert`;
+DROP TRIGGER IF EXISTS `afterProductContentDelete`;
DROP TABLE IF EXISTS `product_content_search`;
-create virtual table product_content_search using fts5(
+CREATE VIRTUAL TABLE product_content_search USING fts5(
content='product_content',
content_rowid='rowid',
- name,
- content
+ `name`,
+ `content`
);
-create trigger afterProductContentInsert after insert on product_content begin
- insert into product_content_search(
+CREATE TRIGGER afterProductContentInsert AFTER INSERT ON product_content BEGIN
+ INSERT INTO product_content_search(
rowid,
name,
content
)
- values(
+ VALUES(
new.rowid,
new.name,
new.content
-);end;
+);END;
-create trigger afterProductContentDelete after delete on product_content begin
- insert into product_content_search(
+CREATE TRIGGER afterProductContentDelete AFTER DELETE ON product_content BEGIN
+ INSERT INTO product_content_search(
product_content_search,
rowid,
- name,
- content
+ `name`,
+ `content`
)
- values(
+ VALUES(
'delete',
+ old.rowid,
old.name,
old.content
-);end;
\ No newline at end of file
+);END;
diff --git a/system/import/sql.php b/system/import/sql.php
index b60893b..013e407 100755
--- a/system/import/sql.php
+++ b/system/import/sql.php
@@ -156,10 +156,15 @@ class Sql {
function createTables() {
if (DB_ENGINE == 'sqlite') {
+ //try to speed up install
+ $query = 'pragma journal_mode = WAL;pragma synchronous = normal;pragma temp_store = memory;pragma mmap_size = 30000000000;PRAGMA writable_schema = 1;';
+ $this->db->query($query , 'journal_mode WAL');
+
//check if sql file has minimum version and if current version is supported
//$currentVersion = \SQLite3::version()['versionString'] ?? '3.0.0';
//$fts5Support = (version_compare($currentVersion,'3.9.0') >= 0);
$fts5Support = true;
+
$query = 'DROP TABLE IF EXISTS fts5_module_available_test';
$this->db->query($query , 'fts5 test module');