Is the restriction map an epimorphism of commutative rings? Let $i : U \to X$ be a quasicompact open immersion of schemes. I would like to know whether the canonical morphism $i_* \mathcal{O}_U \otimes_{\mathcal{O}_X} i_* \mathcal{O}_U \to i_* \mathcal{O}_U$ is an isomorphism.
Remark that this is trivial if $i$ is an affine morphism (base change formula), so we're good with semi-separated $X$. But I don't know what happens in general. Of course we may assume that $X$ is affine. Then $U$ is a finite union of basic open subsets of $X$ and the question is equivalent to: Is the canonical map $\mathcal{O}(U) \otimes_{\mathcal{O}(X)} \mathcal{O}(U) \to \mathcal{O}(U)$ an isomorphism?
In other words, is the restriction map $\mathcal{O}(X) \to \mathcal{O}(U)$ an epimorphism in the category of commutative rings? For example, if $U$ is basic open, then this is just a localization, thus an epimorphism. More generally, if $U$ is affine, it is an epimorphism (if you don't like the argument above) since the map on spectra is the open immersion $U \to X$, which is a monomorphism of schemes. For a simple positive example where $U$ is not affine, take $X=\mathbb{A}^2=\mathrm{Spec}(k[x,y])$ and $U = D(x) \cup D(y)$. Then the ring homomorphism is just the identity $k[x,y] \to k[x,y]$.
The best source for the theory of epimorphisms of commutative rings is: Séminaire Samuel. Algèbre commutative, 2, 1967-1968: Les épimorphismes d'anneaux, available on nundam. See also this mathoverflow discussion.
There are many characterizations of epimorphisms, but no one seems to answer the question directly.
 A: Here is a different view on your original question whether the canonical morphism $$ \tag{$\star$} 
i_* \mathscr{O}_U \otimes_{\mathscr{O}_X} i_* \mathscr{O}_U \to i_* \mathscr{O}_U$$ is an isomorphism.
It seems that the question is very different depending on the dimension of the complement of $U$. Let $Z=X\setminus U$ and observe that we may break up the embedding $U\to X$ into intermediate embeddings and so assume that $Z$ is irreducible. Then we will distinguish two cases, whether $Z$ is a divisor or has higher codimension.
1
Assume that $\mathrm{codim}(Z,X)\geq 2$.
Claim: If $X$ is noetherian and $U$ is generically reduced (reduced at all the generic points), then  $i_*\mathscr O_U$ is a coherent $\mathscr O_X$-module.
Proof: Consider the normalization $\nu:X'\to X$ and let $i':U'=\nu^{-1}U\to X'$. Then we have an injective natural map:
$$ 
i_*\mathscr O_U \to i_*\nu_*\mathscr O_{U'}\simeq \nu_*i'_*\mathscr O_{U'}\simeq \nu_*\mathscr O_{X'}.
$$
Since $\nu$ is proper (it is finite), $\nu_*\mathscr O_{X'}$ is a coherent $\mathscr O_X$-module and this exhibits $i_*\mathscr O_{U}$ as a submodule. $\square$
Let $p\in X$ be a point with residue field $\kappa(p)$ and consider the reduction of $(\star)$ at $p$:
$$
i_* \mathscr{O}_U \otimes_{\mathscr{O}_X} i_* \mathscr{O}_U\otimes\kappa(p) \to i_* \mathscr{O}_U\otimes\kappa(p)$$
For simplicity let's introduce the notation $V_p=i_*\mathscr O_U\otimes\kappa(p)$ so the above morphism is essentially 
$$ \tag{$\star\star$}V_p\otimes_{\kappa(p)}V_p\to V_p$$
It is clear that if $(\star)$ is an isomorphism, then so is $(\star\star)$. 
By the above Claim $V_p$ is finite dimensional and hence for $(\star\star)$ to be an isomorphism it is necessary that $\dim_{\kappa(p)}V_p=1$. 
In the example of the two planes meeting in a single point this fails. 
On the other hand if $X$ is reduced, then $(\star\star)$ being an isomorphism is actually equivalent to $(\star)$ being an isomorphism near $p$. Indeed, if $\dim_{\kappa(p)} V_p=1$ then this holds in a neighbourhood of $p$  and then $i_*\mathscr O_U$ is a line bundle (in the same neighbourhood) and therefore $(\star)$ is an isomorphism (in the same neighbourhood).
So (at least if $X$ is reduced and noetherian) then the remaining question is when $i_*\mathscr O_U$ is a line bundle. This  happens for example if $X$ is $S_2$. In this case the natural map $\mathscr O_X\to i_*\mathscr O_U$ is an isomorphism, so the latter is trivially a line bundle. This happens for example if $X$ is normal.
In fact, being a line bundle means being locally isomorphic to $\mathscr O_X$ so this condition is actually equivalent to being $S_2$ (assuming $X$ is reduced). (To see why, consider the natural map $\mathscr O_X\to i_*\mathscr O_U$, and observe that any section of $\mathscr O_X$ would vanish on a codimension $1$ subset, and hence this map induces an embedding on the residue fields $\kappa(p)\to V_p$, but if it is an embedding, then it is an isomorphism and hence surjective. Then by Nakayama's lemma the original map is surjective on stalks and hence an isomorphism).
If we do not require $X$ to be reduced, then a little less is enough. We always have an exact sequence of sheaves:
$$
\mathscr H^0_Z(X,\mathscr O_X) \to \mathscr O_X\to i_*\mathscr O_U \to \mathscr H^1_Z(X,\mathscr O_X).
$$
This shows that as soon as $\mathscr H^1_Z(X,\mathscr O_X)=0$, it follows that $\mathscr O_X\to i_*\mathscr O_U$ is surjective. Of course, if $X$ is reduced, then $\mathscr H^0_Z(X,\mathscr O_X)=0$, so we're back at assuming that $X$ is $S_2$. I think this gives a pretty good description of what happens in case $\mathrm{codim}(Z,X)\geq 2$.
2
Assume that $Z\subset X$ is a divisor.
2a)
If $Z$ is a $\mathbb Q$-Cartier divisor, then $U$ is  locally equal to the basic open set corresponding to the defining equation of $mZ$ (where $mZ$ is a multiple which is Cartier) and hence the natural map $\mathscr O_X\to i_*\mathscr O_U$ is an epimorphism since it is a localization.
2b)
If $Z$ is a non-$\mathbb Q$-Cartier divisor, then it seems a little more complicated, but it seems to me that it still might work.
Perhaps one can do this: blow up $X$ along $Z$ and get $\sigma: Y\to X$. This makes the preimage of $Z$ a Cartier divisor whose complement is still $U$, say $j:U\to Y$ is the embedding. Then  $\mathscr O_Y\to j_*\mathscr O_U$ is an epimorphism by part 2a). Now it seems to me that the push-forward of this to $X$ remains an epimorphism since this happens on the sections on open sets and not just on the stalks. 
Then if we assume that $X$ is normal, then $\mathscr O_X\to \sigma_*\mathscr O_Y$ is an isomorphism, so the desired condition follows. I am not entirely sure about this last part, but I have already written too much, so I will just leave this as is for now.
A: Martin, Mike is correct, $\Gamma(U)$ is indeed not free over $\Gamma(X)$, but most of what you are saying can be salvaged.
Here is what's happening:
Let $X=X_1\cup X_2$ be the union of the two copies of $\mathbb A^2$ glued at one point as you describe in your answer. Let $X'=X_1\overset{\cdot}\cup X_2$ the disjoint union of the two planes, i.e., $X'$ is the normalization of $X$. Since the normalization is $S_2$ (see here for more on that) it follows that if $i':U\to X'$ is the embedding, then the natural map  $\mathscr O_{X'}\to i'_*\mathscr O_U$ is isomorphic. In other words, 
$\Gamma(U, \mathscr O_U)\simeq\Gamma(X',\mathscr O_{X'})\simeq \Gamma(X_1, \mathscr O_{X_1})\oplus\Gamma(X_2, \mathscr O_{X_2})$ (this  is the same as what you computed). 
However, the normalization map $X'\to X$ is an isomorphism outside of $\{p\}$, so this is not going to be free over $\mathscr O_X$. In fact, as Mike suggests, $\mathscr O_X\to i_*\mathscr O_U$ is an isomorphism on $U$. Even at $\{p\}$ you do not get a rank two module over $\mathscr O_X$. Localizing the above isomorphism of rings gives that  $\left(i_*\mathscr O_{U}\right)_p\simeq \mathscr O_{X_1,p_1}\oplus \mathscr O_{X_2,p_2}$, but this is still not free over $\mathscr O_{X,p}$! What's happening is that 
$$\mathscr O_{X,p}=\{s\in \mathscr O_{U,p} | s_1(p)=s_2(p) \}$$
where $s_i(p)\in \mathscr O_{X_i,p_i}\otimes \kappa(p_i)$ is the value of the section $s$ at $p_i$ evaluated on $X_i$. 
So, to get the contradiction you want, you have to look at the residue fields at $p$, and then what you are saying is indeed true:
$\mathscr O_{U,p}\otimes \kappa(p)$ is a $2$-dimensional vector space over $\mathscr O_{X,p}\otimes \kappa(p)$ and hence $\mathscr O_{U,p}\otimes_{\mathscr O_{X,p}} \mathscr O_{U,p}\otimes  \kappa(p)$ is a $4$-dimensional vector space over the same, so it follows that $i_*\mathscr O_U\otimes_{\mathscr O_X}i_*\mathscr O_U\to i_*\mathscr O_U$ is not an isomorphism.
A: This is an elaboration of Rami's comment.
Let $X_i = \mathbb{A}^2$ with coordinates $(t_i,t'_i)$ and consider the closed point $p_i = (0,0) \in X_i$. By Karl Schwedes paper about Gluing schemes it is possible to glue $X_1$ with $X_2$ along the closed subscheme $\{p_1\} \cong \{p_2\}$. The resulting scheme $X$ looks exactly as one might expect: There are disjoint open immersions $X_i \setminus \{p_i\} \to X$, the complement being a singular point $p$. Besides, $X$ is an affine scheme with $\Gamma(X)=k[t_1,t'_1] \times_k k[t_2,t'_2]$, the fiber product with respect to the evaluations at $(0,0)$. Thus it consists of those pairs of polynomials whose constant terms agree.
Now consider $U = X \setminus \{p\} \cong X_1 \setminus \{p_1\} \sqcup X_2 \setminus \{p_2\}$. This is a quasi-compact open subscheme of $X$ with $\Gamma(U)=k[t_1,t'_1] \times k[t_2,t'_2]$ and the restriction map $\Gamma(X) \to \Gamma(U)$ now corresponds to the inclusion of the fiber product into the product.
A calculation shows that $\Gamma(U)$, as a module over $\Gamma(X)$, is free of rank $2$ with basis $(1,0)$, $(0,1)$. Thus $\Gamma(U) \otimes_{\Gamma(X)} \Gamma(U)$ is free of rank $4$ over $\Gamma(X)$ and cannot be isomorphic to $\Gamma(U)$. This is wrong, see Sandor's answer.
Besides, one can show that $X$ is of finite type over $k$ (this doesn't seem to be clear apriori), because $\Gamma(X)$ is generated by $(t_1,0)$, $(t'_1,0)$, $(0,t_2)$, $(0,t'_2)$. In particular $X$ is noetherian. Then $X \cup_U X$ is a quasi-compact quasi-separated scheme of finite type over $k$ which is not semi-separated.
