What happens if a SHA-256 input is too long (longer than 512 bits)? What I understand is: When we parse a message into 512 bit message blocks. Then we extend the first message block to 64 entry array and start with the compression function. 

What happens if the message is longer than 512 bits? As a result, we would receive several message blocks, but where are these fed into the function.
If the input message is longer than 512 bits, the input is chopped in “chunks” (read: pieces) with fitting length (512 bits) and those are successively fed to the hash compression function.

See, in layman’s terms, SHA-256 processes things like this:


init SHA-256
while there are input chunks,
update hash compression function with the next input chunk (pad to 512 bits if needed)
finalize SHA-256 and return the result (which is the hash output)


As mentioned in “2”, when SHA-256 reaches a chunk which is less than 512 bits, it is padded accordingly… so that all input chunks fed to the hash compression function are exactly 512 bits long. For details on the padding itself, see “How is input message for SHA-2 padded?” and “SHA256: Padding a 512 bits length message”.

A note aside: The maximum message size which can handled by SHA-256 is $2^{64}-1$ bits, which means SHA-256’s compression function can handle up to $\lceil(2^{64}+64)/512\rceil$ of 512-bit input  chunks. In the (unlikely) case when you try to feed more input than the maximum, the hash function should refuse output (read: fail with error).