codimension of “jumping” of the dimension of fibers

Let $f:X\rightarrow Y$ be a dominant morphism of projective (and smooth if you like) varieties over an algebraically closed field $k$ such that $n=\dim(X)=\dim(Y)$. Then $f$ is proper, so by Chevalley's upper semi-continuity theorem, $\dim(X_y)$ is upper semi-continuous on $Y$. Since $f$ is dominant, on an open subset $U\subseteq Y$, $X_y$ is 0 dimensional for all $y\in U$. My question is, can we say $Y\setminus U$ must have codimension at least 2?

We can construct an example where the codimension is exactly two by taking the blowup $B$ of $\mathbb{P}^2$ at a point and looking at the natural map $B\rightarrow\mathbb{P}^2$. If we did not impose that $X$ is irreduicible this need not be true, for example $(xy)\subseteq \mathbb{P}^2$ mapping to $\mathbb{P}^1$ via projection has a one dimensional fiber above the origin. I cannot seem to find an irreducible example and am hoping the answer to the above is positive.

Thanks

-

Suppose there is a codimension one locus $Z$ in $Y$ such that each fibre over a point $z \in Z$ is of positive dimension. Then $f^{-1}(Z)$ has dimension $\geq 1 + Z = \dim Y = \dim X$, and thus $f^{-1}(Z)$ is of the same dimension of $X$, and so must be a component of $X$. Hence, if $X$ is irreducible, no such $Z$ exists. In conclusion, the answer is positive.