How add/update a record conditionally based on existence of primary key?
No, you do not "must know if the record already exists or not". If you will look at drupal_write_record source code, you will see these lines:

 if (empty($primary_keys)) {
    // We are doing an insert.


On else, this function will update instead of insert. The only problem with this is that Drupal's record system expects you will leave key management to Drupal. No saving at arbitrary key, because it breaks autoincrement.

If you need to manage keys on your own, use lower level db_merge function instead.