Fossil SCM

Begin adding forum artifact parsing code.

drh 2018-07-19 22:55 forum-v2
Commit a2b470f14cd42a053c413f91c65b7b45e5ffac937a0ca4800eb67d6f20625752
2 files changed +12 +23
--- src/manifest.c
+++ src/manifest.c
@@ -2462,10 +2462,22 @@
24622462
"REPLACE INTO event(type,mtime,objid,user,comment)"
24632463
"VALUES('g',%.17g,%d,%Q,%Q)",
24642464
p->rDate, rid, p->zUser, blob_str(&comment)+1
24652465
);
24662466
blob_reset(&comment);
2467
+ }
2468
+ if( p->type==CFTYPE_FORUM ){
2469
+ int froot, fprev, firt;
2470
+ schema_forum();
2471
+ froot = uuid_to_rid(p->zThreadRoot, 1);
2472
+ fprev = p->nParent ? uuid_to_rid(p->azParent[0],1) : 0;
2473
+ firt = p->zInReplyTo ? uuid_to_rid(p->zInReplyTo,1) : 0;
2474
+ db_multi_exec(
2475
+ "INSERT INTO forumpost(fpid,froot,fprev,firt,fmtime)"
2476
+ "VALUES(%d,%d,nullif(%d,0),nullif(%d,0),%.17g)",
2477
+ p->rid, froot, fprev, firt, p->rDate
2478
+ );
24672479
}
24682480
db_end_transaction(0);
24692481
if( permitHooks ){
24702482
rc = xfer_run_common_script();
24712483
if( rc==TH_OK ){
24722484
--- src/manifest.c
+++ src/manifest.c
@@ -2462,10 +2462,22 @@
2462 "REPLACE INTO event(type,mtime,objid,user,comment)"
2463 "VALUES('g',%.17g,%d,%Q,%Q)",
2464 p->rDate, rid, p->zUser, blob_str(&comment)+1
2465 );
2466 blob_reset(&comment);
 
 
 
 
 
 
 
 
 
 
 
 
2467 }
2468 db_end_transaction(0);
2469 if( permitHooks ){
2470 rc = xfer_run_common_script();
2471 if( rc==TH_OK ){
2472
--- src/manifest.c
+++ src/manifest.c
@@ -2462,10 +2462,22 @@
2462 "REPLACE INTO event(type,mtime,objid,user,comment)"
2463 "VALUES('g',%.17g,%d,%Q,%Q)",
2464 p->rDate, rid, p->zUser, blob_str(&comment)+1
2465 );
2466 blob_reset(&comment);
2467 }
2468 if( p->type==CFTYPE_FORUM ){
2469 int froot, fprev, firt;
2470 schema_forum();
2471 froot = uuid_to_rid(p->zThreadRoot, 1);
2472 fprev = p->nParent ? uuid_to_rid(p->azParent[0],1) : 0;
2473 firt = p->zInReplyTo ? uuid_to_rid(p->zInReplyTo,1) : 0;
2474 db_multi_exec(
2475 "INSERT INTO forumpost(fpid,froot,fprev,firt,fmtime)"
2476 "VALUES(%d,%d,nullif(%d,0),nullif(%d,0),%.17g)",
2477 p->rid, froot, fprev, firt, p->rDate
2478 );
2479 }
2480 db_end_transaction(0);
2481 if( permitHooks ){
2482 rc = xfer_run_common_script();
2483 if( rc==TH_OK ){
2484
+23
--- src/schema.c
+++ src/schema.c
@@ -542,5 +542,28 @@
542542
@
543543
@ -- Identifier for this file type.
544544
@ -- The integer is the same as 'FSLC'.
545545
@ PRAGMA application_id=252006674;
546546
;
547
+
548
+/*
549
+** The following table holds information about forum posts. It
550
+** is created on-demand whenever the manifest parser encounters
551
+** a forum-post artifact.
552
+*/
553
+static const char zForumSchema[] =
554
+@ CREATE TABLE repository.forumpost(
555
+@ fpid INTEGER PRIMARY KEY; -- BLOB.rid for the artifact
556
+@ froot INT; -- fpid of the thread root
557
+@ fprev INT; -- Previous version of this same post
558
+@ firt INT; -- This post is in-reply-to
559
+@ fmtime REAL; -- When posted. Julian day
560
+@ );
561
+@ CREATE INDEX repository.forumthread ON forumpost(froot);
562
+;
563
+
564
+/* Create the forum-post schema if it does not already exist */
565
+void schema_forum(void){
566
+ if( !db_table_exists("repository","forumpost") ){
567
+ db_multi_exec("%s",zForumSchema/*safe-for-%s*/);
568
+ }
569
+}
547570
--- src/schema.c
+++ src/schema.c
@@ -542,5 +542,28 @@
542 @
543 @ -- Identifier for this file type.
544 @ -- The integer is the same as 'FSLC'.
545 @ PRAGMA application_id=252006674;
546 ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
547
--- src/schema.c
+++ src/schema.c
@@ -542,5 +542,28 @@
542 @
543 @ -- Identifier for this file type.
544 @ -- The integer is the same as 'FSLC'.
545 @ PRAGMA application_id=252006674;
546 ;
547
548 /*
549 ** The following table holds information about forum posts. It
550 ** is created on-demand whenever the manifest parser encounters
551 ** a forum-post artifact.
552 */
553 static const char zForumSchema[] =
554 @ CREATE TABLE repository.forumpost(
555 @ fpid INTEGER PRIMARY KEY; -- BLOB.rid for the artifact
556 @ froot INT; -- fpid of the thread root
557 @ fprev INT; -- Previous version of this same post
558 @ firt INT; -- This post is in-reply-to
559 @ fmtime REAL; -- When posted. Julian day
560 @ );
561 @ CREATE INDEX repository.forumthread ON forumpost(froot);
562 ;
563
564 /* Create the forum-post schema if it does not already exist */
565 void schema_forum(void){
566 if( !db_table_exists("repository","forumpost") ){
567 db_multi_exec("%s",zForumSchema/*safe-for-%s*/);
568 }
569 }
570

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button