code: def namedb_assert_fields_match( cur, record, table_name, record_matches_columns=True, columns_match_record=True ):
      
      rec_missing, rec_extra = namedb_find_missing_and_extra(cur, record, table_name)
      if (len(rec_missing) > 0 and columns_match_record) or (len(rec_extra) > 0 and record_matches_columns):
          raise Exception("Invalid record: missing = %s, extra = %s" % 
                          (",".join(rec_missing), ",".join(rec_extra)))
  
      return True
docs: Ensure that the fields of a given record match
      the columns of the given table.
      * if record_match_columns, then the keys in record must match all columns.
      * if columns_match_record, then the columns must match the keys in the record.
  
      Return True if so.
      Raise an exception if not.