Gluing together functions on a closed subvariety I'm trying to get an intuition for what sheafification does. I came across a passage from Perrin's algebraic geometry book about closed subvarieties.
If says that if X is an algebraic variety and Y is a closed subvariety, we can inherit a sheaf on Y from X. It suggests the natural thing to do would be to define:
$O'(V) := \{ f : V \rightarrow K | \text{there is an open } U \in X \text{ such that } U \cap Y = V \text{ and } g|_V = f \text{ for some } g \in O_U \}$
And then it goes on to claim that this is typically not a sheaf, but merely a presheaf, and that the correct thing to do is to sheafify it.
I was trying to justify this last line by finding a counterexample to the gluing axiom. This is what I came up with:
Let $X = \mathbb{A}^2$, let $Y = \mathbb{V}(xy)$. 
Then let $U_1 = D(x)$ and $U_2 = D(y)$, which forms a cover of the open subset $Y - {(0,0)}$ of $Y$. Define $f_1 = 0$ and $f_2 = 1$, which are elements of $O'(U_1)$ and $O'(U_2)$ respectively. They have no overlap, since their would-be intersection at the origin has been left out. But when you glue them together, you seem to run into trouble near the origin. (Informally, the polynomial's value seems to approach both $0$ and $1$ as you approach the orign. Less informally, the density of this open set in $Y$ ought to allow you to extend the polynomial to the origin in two distinct ways).
My question is simply, is my analysis above valid? I feel like I may have overlooked some assumption somewhere.
If it is valid, then what function do you get when you glue together these two functions? 
If I made a mistake somewhere, could I get some guidance towards a true counter-example?

EDIT: Incorrect
Your analysis is correct. Letting $U = U_1 \cup U_2$, we do indeed have a regular function on $U$ that is $0$ on $U_1$ and $1$ on $U_2$ (it is locally rational on $U$). There is clearly no regular function on $\mathbb{A}^2 \supseteq Y$ that restricts to our 'weird function'. However, if we sheafify the naive presheaf then such a section is allowed
