Commit 95f529d3 authored by Kevin Atkinson's avatar Kevin Atkinson

Refactor "log" table to move some stuff into a new table.
parent 56c7e21c
......@@ -1225,8 +1225,6 @@ CREATE TABLE location_info (
CREATE TABLE log (
seq int(10) unsigned NOT NULL auto_increment,
stamp int(10) unsigned NOT NULL default '0',
exptidx int(11) NOT NULL default '0',
uid int(11) default NULL,
session int(10) unsigned NOT NULL default '0',
invocation int(10) unsigned NOT NULL default '0',
parent int(10) unsigned NOT NULL default '0',
......@@ -2116,6 +2114,17 @@ CREATE TABLE scripts (
UNIQUE KEY id (script_name)
) TYPE=MyISAM;
--
-- Table structure for table `session_info`
--
CREATE TABLE session_info (
session int(11) NOT NULL default '0',
uid int(11) NOT NULL default '0',
exptidx int(11) NOT NULL default '0',
PRIMARY KEY (session)
) TYPE=MyISAM;
--
-- Table structure for table `sitevariables`
--
......
......@@ -796,7 +796,6 @@ REPLACE INTO table_regex VALUES ('virt_node_motelog','logfileid','text','regex',
REPLACE INTO table_regex VALUES ('virt_node_motelog','pid','text','redirect','projects:pid',0,0,NULL);
REPLACE INTO table_regex VALUES ('virt_node_motelog','eid','text','redirect','experiments:eid',0,0,NULL);
--
-- Dumping data for table `testsuite_preentables`
--
......
......@@ -3311,3 +3311,30 @@ last_net_act,last_cpu_act,last_ext_act);
4.55: Changes to templates.sql. Skip this revision for now.
4.56: Refactor "log" table to move some stuff into a new table.
CREATE TABLE session_info (
session int(11) NOT NULL default '0',
uid int(11) NOT NULL default '0',
exptidx int(11) NOT NULL default '0',
PRIMARY KEY (session)
);
lock tables log write;
insert into session_info
select session, uid, exptidx from log
where uid != 0 or exptidx != 0
group by session;
[If either of the above queries failed. Stop now and fix it as
the next will destroy the information.]
alter table log
drop column uid,
drop column exptidx;
[Now install the new code, do it before you unlock the table, as
the last statement made an incompatible change to the "log" table]
unlock tables;
......@@ -3,8 +3,6 @@
CREATE TABLE log (
seq int unsigned NOT NULL auto_increment,
stamp int unsigned NOT NULL, -- timestamp
exptidx int NOT NULL, -- unique experment id
uid int default NULL, -- numeric user id
session int unsigned NOT NULL, -- session id (1)
invocation int unsigned NOT NULL, -- invocation id - unique id for a
-- particular execution of a script (1)
......@@ -38,6 +36,13 @@ CREATE TABLE log (
KEY (session)
);
CREATE TABLE session_info (
session int NOT NULL, -- session id (1)
uid int default NULL, -- numeric user id
exptidx int NOT NULL, -- unique experment id
PRIMARY KEY (session)
);
-- (1) These ids are equal to the sequence number of the "entering" log
-- message
-- (2) Due to a number of factors every "exiting" message in not
......@@ -47,8 +52,7 @@ CREATE TABLE log (
-- multiple exiting messages. (2) If "exec" is used the script
-- will not have an exiting message.
-- NOTE: It may be beneficial to split this table into three:
-- session pidx uid
-- NOTE: It may be beneficial to factor out "invocation" specific info:
-- invocation session parent script level
-- seq stamp [session] invocation priority inferred cause type relevant mesg
-- ...
......
......@@ -490,8 +490,8 @@ sub tblog_set_info ( $$$ )
DBQuerySingleFatal("select idx from experiments where pid='$pid' and eid='$eid'");
$ENV{'TBLOG_UID'} = $uid;
DBQueryFatal
sprintf('update log set exptidx=%d,uid=%s where session=%s',
$ENV{TBLOG_EXPTIDX}, $ENV{TBLOG_UID}, $ENV{TBLOG_SESSION});
sprintf('replace into session_info values(%d,%d,%d)',
$ENV{TBLOG_SESSION}, $ENV{TBLOG_EXPTIDX}, $ENV{TBLOG_UID});
}
=item tblog_set_default_cause CAUSE
......@@ -600,10 +600,8 @@ sub dblog_real ( $$@ ) {
unless defined $cause;
my $query =
sprintf('insert into log (stamp,exptidx,uid,session,parent,invocation,script,level,sublevel,priority,inferred,cause,type,mesg) '.
'VALUES (UNIX_TIMESTAMP(now()),%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%s,%s,%s)',
$ENV{TBLOG_EXPTIDX},
$ENV{TBLOG_UID},
sprintf('insert into log (stamp,session,parent,invocation,script,level,sublevel,priority,inferred,cause,type,mesg) '.
'VALUES (UNIX_TIMESTAMP(now()),%d,%d,%d,%d,%d,%d,%d,%d,%s,%s,%s)',
$ENV{TBLOG_SESSION},
$ENV{TBLOG_PARENT_INVOCATION},
$ENV{TBLOG_INVOCATION},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment