PostgreSQL table lock for certain select wheres
I think this could be achieved with an advisory lock

Before doing the insert every transaction would acquire an advisory lock e.g. for the user_id/make_id combination, so any subsequent transaction that tries to do something for the same user/make, would have to wait: 

-- this waits until the lock can be granted
select pg_advisory_lock(2,1);

SELECT COUNT(*) 
FROM purchase 
WHERE user_id = 2 
  AND make_id = 1;

INSERT INTO purchase (user_id, make_id) VALUES (2, 1);


You can also use pg_try_advisory_lock() which returns immediately with a boolean result whether the lock could be granted or not, if you don't want the session to wait for the lock (but show an error message "already locked" or something similar).

The lock is automatically released when you commit (or rollback) your transaction (so you have to make sure to turn off autocommit and wrap all statements in a single transaction)



As deszo pointed out: it's important that all involved parts of the code stick the to the contract that an advisory lock is required. The approach using an advisory lock does not guarantee in any way that conflicts may occur.