Two questions on the definition of $\mathcal{O}_X(U)$ for an affine scheme $X$. Let $X=\operatorname{Spec}(A)$ be an affine scheme. Hartshorne defines
$$
\mathcal{O}_X(U)=\{s\colon U\to\coprod_{\mathfrak{p}\in U} A_\mathfrak{p} \mid s(\mathfrak{p})\in A_\mathfrak{p} \text{ and } s \text{ is locally a quotient of elements of $A$}\}
$$
for an open set $U\subseteq X$.
I've read in a comment to another question
         ''An element $f\in \mathcal{O}_X(U)$ can be seen as a function whose value at $\mathfrak{p}\in U$ is $f(\mathfrak{p})\in\kappa(\mathfrak{p})$,
         so that the codomain of $f$ is the union of all residue fields $\kappa(\mathfrak{p})$.''
An $s\in \mathcal{O}_X(U)$  (using Hartshorne's definition) may be post-composed by the coproduct of the maps $A_\mathfrak{p}\to \kappa(\mathfrak{p})$ that factor out the maximal ideal to obtain a map
$$
f\colon U\xrightarrow{s}\coprod_{\mathfrak{p}\in U} A_\mathfrak{p}\to \coprod_{\mathfrak{p}\in U} \kappa(\mathfrak{p}).
$$

Is this assignment (of $f$ to an $s$) injective? I.e. are two $s,s'\in \mathcal{O}_X(U)$ equal if the corresponding maps to the coproducts of the residue field (i.e. the assigned $f$ and $f'$) are equal? If yes, does the comment suggest, that there is an alternative definition of $\mathcal{O}_X(U)$ as
  $$
\mathcal{O}_X(U)=\{s\colon U\to\coprod_{\mathfrak{p}\in U} \kappa(\mathfrak{p}) \mid \text{some properties}\} ?
$$

Suppose from now on that $X=\operatorname{Spec}(A)$ is an integral scheme with generic point $\xi$. Then one has injective homomorphisms
$$
\mathcal{O}_X(U) \hookrightarrow \mathcal{O}_{X,\mathfrak{p}}=A_\mathfrak{p}\hookrightarrow \mathcal{O}_{X,\xi} = A_\xi = \operatorname{Frac}(A)
$$
and inside the big ring $\operatorname{Frac}(A)$ (which is a field), one may write (or ''define'' if you like)
$$
\mathcal{O}_X(U) = \bigcap_{\mathfrak{p}\in U} \mathcal{O}_{X,\mathfrak{p}} = \bigcap_{\mathfrak{p}\in U} A_\mathfrak{p}.
$$

I am very confused: How does this last ''definition'' through an intersection of the local rings $A_\mathfrak{p}$ relate to Hartshorne's definition of $\mathcal{O}_X(U)$ which seems to me more like (a special subset of) a union of the local rings $A_\mathfrak{p}$?

 A: To answer your first question: no, the map $A \to \prod_{\mathfrak{p} \in \operatorname{Spec} A} \kappa (\mathfrak{p})$ is not injective in general. 
Indeed, since $A / \mathfrak{p} \to \kappa (\mathfrak{p})$ is injective, it suffices to consider the map $A \to \prod_{\mathfrak{p} \in \operatorname{Spec} A} A / \mathfrak{p}$. Clearly, the kernel of this map is $\bigcap_{\mathfrak{p} \in \operatorname{Spec} A} \mathfrak{p}$, which is easily seen to contain the nilradical $\{ a \in A : \exists n \in \mathbb{N} . a^n = 0 \}$. (In fact, they are equal.) Thus, if $A$ is not reduced, then $A \to \prod_{\mathfrak{p} \in \operatorname{Spec} A} \kappa (\mathfrak{p})$ is not injective. (Moreover, once you have shown that $\bigcap_{\mathfrak{p} \in \operatorname{Spec} A} \mathfrak{p}$ is precisely the nilradical, you can deduce the converse.)
By contrast, the map $A \to \prod_{\mathfrak{p} \in \operatorname{Spec} A} A_\mathfrak{p}$ is always injective. This is part of Proposition 2.2 in [Hartshorne, Ch. II].
To answer your second question: when $A$ is an integral domain and we have open subsets $U \subseteq V \subseteq \operatorname{Spec} A$, then $\mathscr{O} (U) \supseteq \mathscr{O} (V) \supseteq A$. In particular, one should expect $\mathscr{O} (U)$ to be smaller than  $A_\mathfrak{p}$ for any $\mathfrak{p} \in U$.
