It all depends on your citizenship, presentation of documents, VISA in needed(yes there are transit VISA coded VH) and boarding pass/itinerary.
If for example, you're a chinese citizen, you're required to have a VISA to enter Canada, even if only for a few hours. If transiting, you are entering the country since there are avenues to leave the secure area at YYZ and then enter the country.