I have some questions about exercise I.3.20 of Robin Hartshorne's Algebraic Geometry:
Let $Y$ be a variety of dimensions $\geq 2$, and $P\in Y$ be a normal point. Let $f$ be a regular function on $Y − P$. Show that $f$ extends to a regular function on $Y$.
$P$ is a normal point means the local ring $O_P$ at $P$ is integrally closed.
There are some posts about this question here on MSE, here on MO, and again on MSE.
The proofs of the above posts are similar, but I have a common question about the proof. Take the proof in the first post for example:
Firstly, we can reduce this question to the affine case, and use a theorem in commutative ring theory to see that :
$$(\mathcal{O}(Y))_{\mathfrak{m} P}=\bigcap_{\text {height } \mathrm{q}=1, \mathrm{q} \in \operatorname{Spec}\mathcal{O}(Y), \mathfrak{q} \subset \mathfrak{m}_P} \mathcal{O}(Y)_\mathfrak{q}.$$
Now it suffices to prove that the regular function is included on the right-hand side.
My question is, a regular function $f$ on $Y-P$ is locally a rational function of polynomials, which doesn't mean it can be expressed as a rational function globally. So how do we know that $f\in \mathcal{O}(Y)_\mathfrak{q}\simeq A(Y)_\mathfrak{q} \subset \operatorname{Frac}(A(Y))?$ since it means $f$ can be expressed globally.