When inserting zero rows into an empty table (as can happen with INSERT FROM SELECT), the default $options['return']
value of Database::RETURN_INSERT_ID
can cause an error in Postgres after the INSERT
has (successfully) competed:
'SQLSTATE[55000]: Object not in prerequisite state: 7 ERROR: currval of sequence "(table)_(column)_seq" is not yet defined in this session'
In particular this can block the taxonomy module's upgrade path: http://drupal.org/node/1759144#comment-6828288 (taxonomy_update_7005() creates a new table and then inserts into it), but it might potentially cause problems elsewhere as well.
Setting an explicit return option of Database::RETURN_NULL
fixes this, and can safely be done everywhere that the return value of the db_insert() is not needed.