Global sections and Fiber products $X \times_S \operatorname{Spec} k$ Let $X $ a $S$-scheme ($S$ another scheme). Suppose $k$ is a field
and $S$ has a $k$-valued point, that is a map
$p: \operatorname{Spec} k \to S$. If $X \times_S \operatorname{Spec} k$
denotes the associated fiber product, can we say something
interesting about global sections
$H^0(X \times_S \operatorname{Spec} k, \mathcal{O}_{X \times_S \operatorname{Spec} k})$
if we know global sections of $X $ and $S$?
Say for sake of simplicity that $S= \operatorname{Spec}(A)$ is also affine
and $k$ corresponds to some prime ideal of $A$. Then the structure sheaf of
$X \times_S \operatorname{Spec} k$ is $O_X \otimes_A k$. Now if we come
back to global sections of $X \times_S \operatorname{Spec} k$ can we
pull out $k$ from
$H^0(X \times_S \operatorname{Spec} k, \mathcal{O}_X \otimes_A k)$ and
reduce the calculation to global sections of $X$?
Altoght the question seems to arise quite naturally it seems to require (at least if we deal with general fiber products $X \times_S Y$) advanced tools to find answers like in this discussion.
That's why I take here for $Y$ a field as the most simple choice with hope to find out if my question can be answered by methods from on 'non research' level.
If the answer is negative, are there any sufficient conditions when $H^0(X \times_S \operatorname{Spec} k, \mathcal{O}_{X \times_S \operatorname{Spec} k})= H^0(X,\mathcal{O}_{X}) \otimes_A k $?
 A: Question: "If the answer is negative, are there any sufficient conditions when $H^0(X×_{S} Spec(k),O_{X×_S Spec(k)})=H^0(X,O_X)⊗_A k$?"
Answer: In the affine case you get the following calculation: If $\phi: X:=Spec(B) \rightarrow S:=Spec(A)$ is a map and $i: T:=Spec(k) \rightarrow S$ is a $k$-rational point it follows $T\times_S X:=Spec(k\otimes_A B)$ and it follows
$$H^0(T\times_S X, \mathcal{O}_{T\times_S X})=k\otimes_A B\cong k\otimes_A H^0(X, \mathcal{O}_X).$$
Hence your formula is correct for affine schemes. It is not correct in general.
A: We may assume that $S=\mathrm{Spec}R$ for a DVR $R$ with residue field $k$ and a uniformizer $\pi$ and $X$ is a scheme flat over $R$.
Then $\mathcal{O}_X$ is $R$-torsion-free so there is a short exact sequence
$$
0\rightarrow \mathcal{O}_X\overset{\times \pi}{\rightarrow}\mathcal{O}_X\rightarrow \mathcal{O}_{X_k}\rightarrow 0.
$$
Taking the global section, we obtain an injection
$$H^0(X,\mathcal{O}_X)\otimes_{R}k=H^0(X,\mathcal{O}_X)/\pi H^0(X,\mathcal{O}_X)\hookrightarrow H^0(X,\mathcal{O}_{X_k}),$$
which is not necessarily surjective. Therefore, in such a case, if the $\pi$-torsion part of $H^1(X,\mathcal{O}_X)$ is trivial then you obtain the desired isomorphism.
