Changes in feed table structure (not documented in design paper yet!).
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Thu, 22 Sep 2005 17:35:32 +0000 (17:35 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Thu, 22 Sep 2005 17:35:32 +0000 (17:35 +0000)
Init feeds table too.

org.glite.jp.index/config/glite-jp-index-dbsetup.sql
org.glite.jp.index/src/db_ops.c
org.glite.jp.index/src/db_ops.h

index f3a97e2..21122f2 100644 (file)
@@ -22,14 +22,17 @@ create table attrs (
 );
 
 create table feeds (
-        feedid         char(32)        binary not null,
+       uniqueid        int             auto_increment not null,
+       feedid          char(32)        binary unique,
        state           int             not null,
+       locked          int             not null,
        source          varchar(255)    not null,
-       expires         datetime        not null,
+       expires         datetime,
        attrs           mediumblob      null,
        condition       mediumblob      null,
 
-        primary key (feedid),
+        primary key (uniqueid),
+        index (uniqueid),
         index (feedid),
        index (state)
 );
index f5cf47a..164f402 100644 (file)
@@ -10,6 +10,7 @@
 #include <glite/jp/strmd5.h>
 
 #include "conf.h"
+#include "db_ops.h"
 
 
 #define TABLE_PREFIX_DATA "attr_"
@@ -51,10 +52,11 @@ int glite_jpis_initDatabase(glite_jp_context_t ctx, glite_jp_is_conf *conf) {
        const char *type_index, *type_full;
        size_t i;
        MYSQL_BIND param[4];
-       unsigned long attrid_len, name_len, type_len;
-       char attrid[33], name[256], type[33];
-       int indexed;
+       unsigned long attrid_len, name_len, type_len, source_len;
+       char attrid[33], name[256], type[33], source[256];
+       int indexed, state, locked;
        char sql[512];
+       glite_jp_is_feed **feeds;
 
        glite_jp_db_assign_param(&param[0], MYSQL_TYPE_VAR_STRING, attrid, &attrid_len);
        glite_jp_db_assign_param(&param[1], MYSQL_TYPE_VAR_STRING, name, &name_len);
@@ -64,6 +66,7 @@ int glite_jpis_initDatabase(glite_jp_context_t ctx, glite_jp_is_conf *conf) {
 
        memset(attrid, 0, sizeof(attrid));
 
+       // attrs table and attrid_* tables
        attrs = conf->attrs;
        i = 0;
        while (attrs[i]) {
@@ -92,8 +95,28 @@ int glite_jpis_initDatabase(glite_jp_context_t ctx, glite_jp_is_conf *conf) {
 
                i++;
        }
+       glite_jp_db_freestmt(&stmt);
+
+       // feeds table
+       glite_jp_db_assign_param(&param[0], MYSQL_TYPE_LONG, &state);
+       glite_jp_db_assign_param(&param[1], MYSQL_TYPE_LONG, &locked);
+       glite_jp_db_assign_param(&param[2], MYSQL_TYPE_VAR_STRING, source, &source_len);
+       if (glite_jp_db_prepare(ctx, "INSERT INTO feeds (state, locked, source) VALUES (?, ?, ?)", &stmt, param, NULL) != 0) goto fail;
+       feeds = conf->feeds;
+       i = 0;
+       memset(source, 0, sizeof(source));
+       while (feeds[i]) {
+               state = (feeds[i]->history ? GLITE_JP_IS_STATE_HIST : 0) |
+                       (feeds[i]->continuous ? GLITE_JP_IS_STATE_CONT : 0);
+               locked = 0;
+               strncpy(source, feeds[i]->PS_URL, sizeof(source) - 1);
+               source_len = strlen(source);
+               if (glite_jp_db_execute(stmt) == -1) goto fail_stmt;
 
+               i++;
+       }
        glite_jp_db_freestmt(&stmt);
+
        return 0;
 
 fail_stmt:
index 8e4faf4..6c8b5f1 100644 (file)
@@ -7,6 +7,11 @@
 #include <glite/jp/context.h>
 #include "conf.h"
 
+
+#define GLITE_JP_IS_STATE_HIST 1
+#define GLITE_JP_IS_STATE_CONT 2
+
+
 int glite_jpis_initDatabase(glite_jp_context_t ctx, glite_jp_is_conf *conf);
 int glite_jpis_dropDatabase(glite_jp_context_t ctx);
 int glite_jpis_lockUninitializedFeed(glite_jp_context_t ctx, char **PS_URL);