From: František Dvořák Date: Thu, 22 Sep 2005 17:35:32 +0000 (+0000) Subject: Changes in feed table structure (not documented in design paper yet!). X-Git-Tag: merge_rc1_dst_2~10 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=7b1492be91a82531002b4ee8a9d25f77bb5ff65f;p=jra1mw.git Changes in feed table structure (not documented in design paper yet!). Init feeds table too. --- diff --git a/org.glite.jp.index/config/glite-jp-index-dbsetup.sql b/org.glite.jp.index/config/glite-jp-index-dbsetup.sql index f3a97e2..21122f2 100644 --- a/org.glite.jp.index/config/glite-jp-index-dbsetup.sql +++ b/org.glite.jp.index/config/glite-jp-index-dbsetup.sql @@ -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) ); diff --git a/org.glite.jp.index/src/db_ops.c b/org.glite.jp.index/src/db_ops.c index f5cf47a..164f402 100644 --- a/org.glite.jp.index/src/db_ops.c +++ b/org.glite.jp.index/src/db_ops.c @@ -10,6 +10,7 @@ #include #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(¶m[0], MYSQL_TYPE_VAR_STRING, attrid, &attrid_len); glite_jp_db_assign_param(¶m[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(¶m[0], MYSQL_TYPE_LONG, &state); + glite_jp_db_assign_param(¶m[1], MYSQL_TYPE_LONG, &locked); + glite_jp_db_assign_param(¶m[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: diff --git a/org.glite.jp.index/src/db_ops.h b/org.glite.jp.index/src/db_ops.h index 8e4faf4..6c8b5f1 100644 --- a/org.glite.jp.index/src/db_ops.h +++ b/org.glite.jp.index/src/db_ops.h @@ -7,6 +7,11 @@ #include #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);