When creating new rows with postgresql when primary key is a serial, the sequence must be updated if rows contain values for the primary key.
Thanks to PmGs for reporting issue and for the fix.