Background: In the old version, the fields latest and live revisions were updated always via two separate dmlDML statements. Every update causes in PostgreSQL (tested to pg 9.6) one more dead tuple, such that on busy systems, we see 30k + dead tuples per hour. These dead tuples in turn cause more auto vacuum operations and can lead to abandoned query plans.
This change can reduce the number of dead tuples on cr_items into half, by allowing both fields to be set in one operation (namely content_item__set_live_revision). This function has an optional 4th argument that can cause this optimization. For legacy applications, nothing changes.
Btw: since all commonly used applications use the live revision, the fallback of the latest_revision is unused. One can consider to remove the cr_revision_latest_tr, at least on on certain installations.
Created new proc cr_check_mime_type, centralizing the retrieval of the mime_type from uploaded file's information. Applied the new proc to the different situations in the system when we require mime_type retrieval: content-repository, file-storage and xotcl CrItem TODO: get the real mime_type from the file content, but this would require some modification in the data model.