From 15427bec92209a6dbee55356cb8386bccba08abd Mon Sep 17 00:00:00 2001
From: Jean-Paul Smets <jp@nexedi.com>
Date: Sun, 25 Jan 2004 13:13:52 +0000
Subject: [PATCH] new transaction / distribute API

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@318 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 ...ocessMessage.zsql => SQLDict_assignMessage.zsql} |  8 +++-----
 .../skins/activity/SQLDict_createMessageTable.zsql  | 10 +++-------
 .../skins/activity/SQLDict_delMessage.zsql          |  5 +++--
 .../skins/activity/SQLDict_lockMessage.zsql         | 11 -----------
 .../skins/activity/SQLDict_readMessage.zsql         |  8 +++++---
 .../skins/activity/SQLDict_readMessageList.zsql     | 13 +++++++------
 .../skins/activity/SQLDict_unlockMessage.zsql       | 11 -----------
 .../skins/activity/SQLDict_writeMessage.zsql        |  2 +-
 8 files changed, 22 insertions(+), 46 deletions(-)
 rename product/CMFActivity/skins/activity/{SQLDict_processMessage.zsql => SQLDict_assignMessage.zsql} (58%)
 delete mode 100755 product/CMFActivity/skins/activity/SQLDict_lockMessage.zsql
 delete mode 100755 product/CMFActivity/skins/activity/SQLDict_unlockMessage.zsql

diff --git a/product/CMFActivity/skins/activity/SQLDict_processMessage.zsql b/product/CMFActivity/skins/activity/SQLDict_assignMessage.zsql
similarity index 58%
rename from product/CMFActivity/skins/activity/SQLDict_processMessage.zsql
rename to product/CMFActivity/skins/activity/SQLDict_assignMessage.zsql
index f5051f3051..4e2424530d 100755
--- a/product/CMFActivity/skins/activity/SQLDict_processMessage.zsql
+++ b/product/CMFActivity/skins/activity/SQLDict_assignMessage.zsql
@@ -1,17 +1,15 @@
 <dtml-comment>
 title:
 connection_id:erp5_sql_connection
-max_rows:1000
-max_cache:100
+max_rows:1
+max_cache:0
 cache_time:0
 class_name:
 class_file:
 </dtml-comment>
 <params>path
-method_id
 processing_node</params>
 UPDATE message
 SET processing_node=<dtml-sqlvar processing_node type="int">
 WHERE
-  path = <dtml-sqlvar path type="string">
-<dtml-if method_id>AND method_id = <dtml-sqlvar method_id type="string"></dtml-if>
+  path = <dtml-sqlvar path type="string">
\ No newline at end of file
diff --git a/product/CMFActivity/skins/activity/SQLDict_createMessageTable.zsql b/product/CMFActivity/skins/activity/SQLDict_createMessageTable.zsql
index 2cc6a04390..62f3c2e1f3 100755
--- a/product/CMFActivity/skins/activity/SQLDict_createMessageTable.zsql
+++ b/product/CMFActivity/skins/activity/SQLDict_createMessageTable.zsql
@@ -8,16 +8,12 @@ class_name:
 class_file:
 </dtml-comment>
 <params></params>
-# Host: 
-# Database: test
-# Table: 'stock'
-# 
 CREATE TABLE `message` (
   `path` VARCHAR(255),
   `method_id` VARCHAR(40),
+  `processing_node` INT DEFAULT -1,
   `message` BLOB,
-  `processing_node` INT DEFAULT NULL,
   KEY `path` (`path`),
-  KEY `processing_node` (`processing_node`),
   KEY `method_id` (`method_id`),
-) TYPE = InnoDB; 
+  KEY `processing_node` (`processing_node`),
+) TYPE = InnoDB;
diff --git a/product/CMFActivity/skins/activity/SQLDict_delMessage.zsql b/product/CMFActivity/skins/activity/SQLDict_delMessage.zsql
index c347a15842..46069df472 100755
--- a/product/CMFActivity/skins/activity/SQLDict_delMessage.zsql
+++ b/product/CMFActivity/skins/activity/SQLDict_delMessage.zsql
@@ -8,10 +8,11 @@ class_name:
 class_file:
 </dtml-comment>
 <params>path
-method_id</params>
+method_id
+processing_node</params>
 DELETE FROM
   message
 WHERE
   path = <dtml-sqlvar path type="string">
 <dtml-if method_id>AND method_id = <dtml-sqlvar method_id type="string"></dtml-if>
-  
+<dtml-if processing_node>AND processing_node = <dtml-sqlvar processing_node type="int"></dtml-if>
diff --git a/product/CMFActivity/skins/activity/SQLDict_lockMessage.zsql b/product/CMFActivity/skins/activity/SQLDict_lockMessage.zsql
deleted file mode 100755
index 1d058479a3..0000000000
--- a/product/CMFActivity/skins/activity/SQLDict_lockMessage.zsql
+++ /dev/null
@@ -1,11 +0,0 @@
-<dtml-comment>
-title:
-connection_id:erp5_sql_connection
-max_rows:1000
-max_cache:100
-cache_time:0
-class_name:
-class_file:
-</dtml-comment>
-<params></params>
-LOCK TABLES message WRITE
diff --git a/product/CMFActivity/skins/activity/SQLDict_readMessage.zsql b/product/CMFActivity/skins/activity/SQLDict_readMessage.zsql
index b6436bbf64..ae22571b61 100755
--- a/product/CMFActivity/skins/activity/SQLDict_readMessage.zsql
+++ b/product/CMFActivity/skins/activity/SQLDict_readMessage.zsql
@@ -7,8 +7,10 @@ cache_time:0
 class_name:
 class_file:
 </dtml-comment>
-<params></params>
+<params>processing_node</params>
 SELECT * FROM
   message
-WHERE 
-  processing_node is NULL
+<dtml-if processing_node>
+WHERE
+  processing_node = <dtml-sqlvar processing_node type="int">
+</dtml-if>
\ No newline at end of file
diff --git a/product/CMFActivity/skins/activity/SQLDict_readMessageList.zsql b/product/CMFActivity/skins/activity/SQLDict_readMessageList.zsql
index d6e23a56af..91cd95603d 100755
--- a/product/CMFActivity/skins/activity/SQLDict_readMessageList.zsql
+++ b/product/CMFActivity/skins/activity/SQLDict_readMessageList.zsql
@@ -8,12 +8,13 @@ class_name:
 class_file:
 </dtml-comment>
 <params>path
-method_id</params>
+method_id
+processing_node</params>
 SELECT * FROM
   message
-<dtml-if "path or method_id"> 
+<dtml-if "path or method_id or processing_node">
 WHERE
-<dtml-if path>  path = <dtml-sqlvar path type="string"></dtml-if>
-<dtml-if method_id>AND method_id = <dtml-sqlvar method_id type="string"></dtml-if>
-</dtml-if>
-  
+<dtml-if processing_node> processing_node = <dtml-sqlvar processing_node type="int"> </dtml-if>
+<dtml-if path><dtml-if processing_node>AND</dtml-if> path = <dtml-sqlvar path type="string"></dtml-if>
+<dtml-if method_id><dtml-if "processing_node or path">AND</dtml-if> method_id = <dtml-sqlvar method_id type="string"></dtml-if>
+</dtml-if>
\ No newline at end of file
diff --git a/product/CMFActivity/skins/activity/SQLDict_unlockMessage.zsql b/product/CMFActivity/skins/activity/SQLDict_unlockMessage.zsql
deleted file mode 100755
index 73ca876698..0000000000
--- a/product/CMFActivity/skins/activity/SQLDict_unlockMessage.zsql
+++ /dev/null
@@ -1,11 +0,0 @@
-<dtml-comment>
-title:
-connection_id:erp5_sql_connection
-max_rows:1000
-max_cache:100
-cache_time:0
-class_name:
-class_file:
-</dtml-comment>
-<params></params>
-UNLOCK TABLES
diff --git a/product/CMFActivity/skins/activity/SQLDict_writeMessage.zsql b/product/CMFActivity/skins/activity/SQLDict_writeMessage.zsql
index a1803e2a14..5d13141a54 100755
--- a/product/CMFActivity/skins/activity/SQLDict_writeMessage.zsql
+++ b/product/CMFActivity/skins/activity/SQLDict_writeMessage.zsql
@@ -12,4 +12,4 @@ method_id
 message</params>
 INSERT INTO message
 VALUES
- (<dtml-sqlvar path type="string">,<dtml-sqlvar method_id type="string">,<dtml-sqlvar message type="string">,NULL);
+ (<dtml-sqlvar path type="string">,<dtml-sqlvar method_id type="string">,-1,<dtml-sqlvar message type="string">);
-- 
2.30.9