level int null,
arrived datetime not null,
-
+ ulm mediumblob not null, -- testing (1)
primary key (jobid,event),
index (time_stamp),
index (arrived)
) engine=innodb;
+-- testing (2)
+create table events_flesh (
+ jobid char(32) binary not null,
+ event int not null,
+ ulm mediumblob binary not null;
+
+ primary key (jobid,event),
+) engine=innodb;
+
+-- for compatibility
create table short_fields (
jobid char(32) binary not null,
event int not null,
primary key (jobid,event,name)
) engine=innodb;
+-- for compatibility
create table long_fields (
jobid char(32) binary not null,
event int not null,
glite_lbu_Statement sh;
int ret,t;
const char *tables[] = { "short_fields","long_fields" };
+ edg_wll_Event *f;
edg_wll_ResetError(ctx);
+ trio_asprintf(&q, "select ulm from events_flesh where jobid = '%|Ss' and event = %d", jobid, n);
+ if ((ret=edg_wll_ExecSQL(ctx,q,&sh)) < 0) goto cleanup;
+ if (edg_wll_FetchRow(ctx,sh,1,NULL,&nameval[0]) == 1) {
+ //fprintf(stderr, "got ulm: '%s'\n", nameval[0]);
+ // nasty ;-)
+ edg_wll_ParseEvent(ctx,nameval[0],&f);
+ memcpy(e, f, sizeof *e);
+ free(f);
+ ret=edg_wll_CheckEvent(ctx,e);
+ } else ret = ENOENT;
+ free(q); q = NULL;
+
+ // old way keeped for compatibility/slow migration
+ if (ret != 0) {
for (t=0; t<=1; t++) {
trio_asprintf(&q,"select name,value from %s "
"where jobid = '%|Ss' and event = %d ",
glite_lbu_FreeStmt(&sh);
free(q); q=NULL;
}
-
ret=edg_wll_CheckEvent(ctx,e);
+ }
cleanup:
if (sh) glite_lbu_FreeStmt(&sh);
static int store_job_block(edg_wll_Context, glite_jobid_const_t, const char *, glite_lbu_bufInsert *, int, int);
#endif
static int store_job_grey(edg_wll_Context,glite_jobid_const_t,time_t);
-static int store_flesh(edg_wll_Context,edg_wll_Event *,char *,int);
+static int store_flesh(edg_wll_Context,edg_wll_Event *,const char *ulm, char *,int);
static int store_seq(edg_wll_Context,edg_wll_Event *,int);
static int check_dup(edg_wll_Context,edg_wll_Event *);
static int check_auth(edg_wll_Context,edg_wll_Event *e);
ctx->allowAnonymous = anon;
}
-int edg_wll_StoreEvent(edg_wll_Context ctx,edg_wll_Event *e,int *seq)
+int edg_wll_StoreEvent(edg_wll_Context ctx,edg_wll_Event *e,const char *ulm,int *seq)
{
edg_wll_ErrorCode err = 0;
char *userid = NULL,*jobid,*stmt;
free(stmt); stmt = NULL;
if ((err = store_seq(ctx,e,next)) ||
- (err = store_flesh(ctx,e,jobid,next))) {
+ (err = store_flesh(ctx,e,ulm,jobid,next))) {
/* attempt to cleanup, ignore new errors */
char *desc;
edg_wll_ErrorCode oerr = edg_wll_Error(ctx,NULL,&desc);
#define SHORT_LEN 255 /* short_fiels.value db column lenght */
-static int store_flesh(edg_wll_Context ctx,edg_wll_Event *e,char *jobid,int no)
+static int store_flesh(edg_wll_Context ctx,edg_wll_Event *e,const char *ulm,char *jobid,int no)
{
struct {
char *key;
unsigned int i;
int err = 0;
+ assert(ulm || e);
edg_wll_ResetError(ctx);
+ if (!ulm) ulm = edg_wll_UnparseEvent(ctx, e);
+ if (!ulm) return edg_wll_Error(ctx, NULL, NULL);
+
+#ifndef LB_EVENTS_BLOB
+ // in both ways if some preparsed flesh fields in events too
+ if (!e) {
+ if (edg_wll_ParseEvent(ctx, (char *)ulm, &e) != 0) return edg_wll_Error(ctx, NULL, NULL);
+ }
+
memset(f,0,sizeof(f)); assert(f[0].key == NULL);
switch (e->type) {
if (edg_wll_ExecSQL(ctx,stmt,NULL) < 0) err = edg_wll_Error(ctx,NULL,NULL);
free(stmt);
}
+#else
+ if (!ulm) ulm = edg_wll_UnparseEvent(ctx, e);
+ trio_asprintf(&stmt, "insert into events_flesh (jobid, event, ulm) values ('%|Ss', %d, '%|Ss')", jobid, no, ulm);
+ if (edg_wll_ExecSQL(ctx,stmt,NULL) < 0) err = edg_wll_Error(ctx,NULL,NULL);
+#endif
return err;
}
e2.regJob.jobtype = EDG_WLL_REGJOB_SIMPLE;
e2.regJob.jdl = strdup("");
- switch (edg_wll_StoreEvent(ctx,&e2,&seq)) {
+ switch (edg_wll_StoreEvent(ctx,&e2,NULL,&seq)) {
case 0: break;
/* maybe some non-ignorable errors should be handled here */
free(stmt);
trio_asprintf(&stmt,
+ "delete from events_flesh where jobid='%|Ss' and event=%d",
+ jobid,event);
+ edg_wll_ExecSQL(ctx,stmt,NULL);
+ free(stmt);
+
+ trio_asprintf(&stmt,
"delete from events where jobid='%|Ss' and event=%d",
jobid,event);
edg_wll_ExecSQL(ctx,stmt,NULL);