How does a miner verify a transaction which is spending an output of another transaction in the same block? It is mentioned in this post that:

If all validation of all transactions in a block succeeds, the consumed inputs are removed from the database, and all outputs of those transactions added as fresh unspent outputs in the database, allowing them to be spent by future blocks.

But if the UTXO set is updated only after appending a block, and a miner only checks the UTXO set for understanding the spent/unspent outputs, how will verification happen if a transaction (say tx_B) in a block spends an output of another transaction (say tx_A) in the same block? In another word, how will tx_B understand the state of the output of tx_A if the output is not stored in the UTXO set yet?
While a miner is building a block template, they are maintaining a &quot;virtual&quot; UTXO set to keep track of the consumed UTXOs and the newly created UTXOs. A transaction can only be included in a block once all of its inputs are available for spending, so this approach is also sufficient to achieve the required topological order of transactions.