added table locking for mysql and postgres