I'm using MySQL-3.23.49a

I use MySQL to replace plain text log files. The logging happens in a
table named "current".
Every midnight, at 00:00:00, i perform a table rotation with this
command from a cron job:

CREATE TABLE new ....
RENAME TABLE current TO $date, new TO current

where $date is yesterday's date.

The problem is, it's impossible to prevent today's messages from
creeping into the old, rotated table. The reason is, there's always a
very short delay before the rotation is performed, and some of today's
messages always get into "current" before rotating it.
I wonder if i can use locking to correct this problem.

I mean: i create table "new", lock it, perform the rotation (so now
"new" is "current", while the old "current" is "$date"), flush today's
record from "$date" into "current", then unlock "current".
Will it work this way?

I'm not sure what happens to locking after RENAME; if i lock "new" and
RENAME it to "current", will the lock be inherited by "current"?

-- 
Florin Andrei

You know you're in trouble when packet floods are competing to flood
you.


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to