Checkout the upsert from core-queries

* insert place holders
Removed the trigger* function.

* the synchronization between the tmp tables and the master
  results table is not triggered by R anymore.
* instead, we have a "success" table, that list the write status
 of the tmp tables- an internal postgres trigger will hopefully
 handle all the rest.