This might be a somewhat silly and inconsequential question, but it's aroused my curiosity. One has the theorem in commutative algebra that the integral closure of a domain $A$ in its field of fractions $Q(A)$ is the intersection of all the valuation subrings of $Q(A)$ containing $A$. This naturally leads to the impulse to define the ring of integers of an arbitrary field $k$, independent of any particular subring, to be the intersection of all valuation subrings of $k$. Really what one is doing here is taking the integral closure of the prime ring, which is to say the minimal integrally closed subring. This gives the answer one would expect for $\mathbb{Q}$ and for number fields. I believe that the ring of integers under this definition of $\mathbb{C}$ is $\overline{\mathbb{Z}}$, and the ring of integers of $\mathbb{R}$ is $\overline{\mathbb{Z}} \cap \mathbb{R}$. So far, so good.

Now here's the question: what happens in algebraic geometry? We could ask about the ring of integers $\mathcal{O}$ of the function field $Q(A)$ of an irreducible affine variety $\textbf{Spec }A$ over an algebraically closed field $k$, and naïvely hope that it coincides with $A$; but there may be many subalgebras of $Q(A)$ whose field of fractions is $Q(A)$, and at most one of these will be its ring of integers. Can we characterise geometrically those affine varieties whose coordinate ring is the ring of integers of its function field?

And what happens for function fields of more general varieties? For projective varieties, whose global ring of functions isn't much to write home about, we might hope for a more interesting answer.

Edit: It occurs to me that as it stands, the (boring) answer to my question is that the ring of integers is always inside the ground field. Let me instead ask the following, related question: for affine or general function fields $k(X)$, is it always true that there is a minimal (but not necessarily unique minimal) subring $R$ such that

$R$ is integrally closed in $k(X)$, and

$k(X)$ is algebraic over the field of fractions $Q(R)$?

If so, what is the geometric meaning of $R$, and when must we have $Q(R) = k(X)$?