No, we should be keeping the lock until the end of the transaction (which in this case would be just the one statement, but it would be the whole statement and all of the calls in it). See analyze.c:268 or so, where we call relation_close(onerel, NoLock); meaning we're closing the relation but we're *not* releasing the lock on it- it'll get released at the end of the transaction.
If that's the case, then changing the two table_close() statements to NoLock should resolve any remaining concern.