Dbagent upsert

These patches adds a feature called upsert (insert or update if exists).
That's nice idea. I'll do it.