The definition of the structure sheaf of an affine scheme $\operatorname{Spec} R$ is often done by extending a sheaf defined on the standard opens $D(f)$, $f\in R$. From this definition it is not quite clear what the rings $\mathcal{O}(U)$ look like for general $U\subset \operatorname{Spec} R$. As Ravi Vakil notes in the lecture notes, one might hope that $$\mathcal{O}(U)\cong R_S$$ where $$S=\{r\in R\mid \forall \mathfrak{p}\in U: r\not\in \mathfrak{p}\}$$ He also notes that this is not true, and gives an example of two planes intersecting at a point, and then removing the point. More precisely $$X=\operatorname{Spec} \mathbb{C}[w,x,y,z]/(wy,wz,xy,xz), U=X\setminus\{(w,x,y,z)\}$$ But $U$ is clearly the union of two open subsets: $U_1$ the $xw$-plane with the origin removed and $U_2$ the $yz$-plane with the origin removed. So then one can construct sections on $U_1$ and $_2$ separately and glue them to a section on $U$. This makes it clear the $\mathcal{O}(U)$ is not a localisation of $\mathbb{C}[w,x,y,z]/(wy,wz,xy,xz)$.
However, this example is in some sense trivial in that it relies upon the fact that if $U$ is a disjoint union of $U_1$ and $U_2$ then $$\mathcal{O}(U)=\mathcal{O}(U_1)\times \mathcal{O}(U_2)$$ So I wonder if there are examples that do not rely on this fact. So if there is an affine scheme $\operatorname{Spec} R$ with an irreducible open subset $U$ such that $\mathcal{O}(U)$ is not a localisation of $R$.
Edit: another way of looking at the same question is by taking Hartshornes perspective. Sections over $U$ are maps to the stalks that can locally be realised by fractions. So is there an example of an irreducible $U$ and a section $s:U\to \bigcup_{\mathfrak{p}\in U}R_\mathfrak{p}$ so that locally $s=\frac{g}{h}$, but it is not possible to write $s$ like this on all of $U$?
Here is my example.
Let $$A=k[x,y,z,w]/(xw-yz)$$ and $$U=D(y)\cup D(w).$$
Now to the proof !
Note first that $A$ is an integral domain. Because $k[x,y,z,w]$ is a unique factorization domain and $xw-yz$ is irreducible (clearly not the product of linear factors).
This implies that $U$ is irreducible. Since if there are $p,q\in A$ such that $$pq=0 \ \text{on} \ U$$ then $$ywpq=0\ \text{on} \ Spec \ A$$ and this means $p=0$ or $q=0$.
Now we show that $\mathcal{O}_X(U)$ is not a localization. The fact that $A$ is an integral domain simplifies the definition of localization, we no longer have to multiply by a factor $f^n$, and it implies that maps between localizations are injective. Further if $A_f \subseteq A_g$ then $$\frac{1}{f}=\frac{s}{g}$$ and so $$g=sf,$$ that is $f$ divides $g$. (But $A$ is not a unique factorization domain.)
Now $$\mathcal{O}_X(D(y))=A_y$$ $$\mathcal{O}_X(D(w))=A_w$$ $$\mathcal{O}_X(D(y)\cap D(w))=A_{yw}$$
Thus the restriction $$\mathcal{O}_X(U)=\mathcal{O}_X(D(y)\cup D(w))\rightarrow \mathcal{O}_X(D(y)\cap D(w))=A_{yw}$$ sends $\mathcal{O}_X(U)$ into $A_y\cap A_w$.
Now $$\mathcal{O}_X(U)\neq A$$ since
$$\frac{x}{y}=\frac{z}{w}\in \mathcal{O}_X(U)$$ (this is the core idea).
To finish remark that if $$A_f \subseteq A_y\cap A_w$$ then $A_f=A$. Since by the above remarks we would have
$$y=sf$$ $$w=rf$$ and this implies that $f\in k$.