Re: [Quickfix-developers] messages_log table entries
Brought to you by:
orenmnero
|
From: Caleb E. <cal...@gm...> - 2006-02-01 16:18:03
|
On 2/1/06, Oren Miller <or...@qu...> wrote:
> One option could be to add a direction column which indicates if a
> message is incoming or outgoing.
What about normalizing the data (or is that de-normalizing?) a bit more and
putting a unique ID on the sessions table and using that as a foreign key
for the event_log, message_log and messages tables. Then the *compid
columns could be per-message, if they are even needed. The single byte
direction column might be more sensible and save bit of space.
Something like (syntax may not be 100%):
CREATE TABLE sessions (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
beginstring CHAR(8) NOT NULL,
sendercompid VARCHAR(64) NOT NULL,
targetcompid VARCHAR(64) NOT NULL,
session_qualifier VARCHAR(64) NOT NULL,
creation_time DATETIME NOT NULL,
incoming_seqnum INT NOT NULL,
outgoing_seqnum INT NOT NULL,
PRIMARY KEY (id)
UNIQUE KEY session_id (beginstring, sendercompid, targetcompid,
session_qualifier)
)
CREATE TABLE message_log (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
session_id INT UNSIGNED NOT NULL,
direction ENUM ('in', 'out') NOT NULL,
text BLOB NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY (session_id) REFERENCES sessions (id)
)
CREATE TABLE messages (
session_id INT UNSIGNED NOT NULL,
msgseqnum INT NOT NULL,
message BLOB NOT NULL,
UNIQUE KEY (session_id, msgseqnum),
FOREIGN KEY (session_id) REFERENCES sessions (id)
)
FYI, I just noticed this code in MySQLLog.cpp:
void MySQLLog::clear()
{ QF_STACK_PUSH(MySQLLog::clear)
MySQLQuery incoming( "DELETE FROM incoming_log" );
MySQLQuery outgoing( "DELETE FROM outgoing_log" );
MySQLQuery event( "DELETE FROM event_log" );
m_pConnection->execute( incoming );
m_pConnection->execute( outgoing );
m_pConnection->execute( event );
QF_STACK_POP
}
Shouldn't this query be qualifying the delete to match only messages
corresponding to its session? II don't think Log::clear ever gets called
though. It seems to be called from SessionState::clear, but I don't see
anything calling that method.
--
Caleb Epstein
caleb dot epstein at gmail dot com
|