Definition of extension for relations. Consider the following definition from Sohrab, Basic Real Analysis:
Definition 1.2.4 (Restriction, Extension)
Let $f, g\subset X\times Y$ be two relations. If $f\subset g$, we say that $f$ is a restriction of $g$ or that $g$ is an extension of $f$. If $\text{dom}(f)=D$, then $f\subset g$ is also denoted by $f=g|_D$.
Question / example
NOTE: We are working with relations, not necessarily functions
Consider the case $X=\{1\}$, $Y=\{1,2\}$, $f\subset g\subset X\times Y$, $f=\{(1,1)\}$, $g=\{(1,1),(1,2)\}$. $f\subset g$ but the notation $f=g\mid_{\text{dom}(f)}$ is misleading or wrong: $\text{dom}(f)=\{1\}$, $f(1)=\{1\}$, but $g(1)=g_{\text{dom}(f)}(1)=\{1,2\}$.
What I mean is that althought $f\subset g$, $f\neq g\mid_{\text{dom}(f)}$ in the common meaning.
EDIT Question: What is the minimal change to the definition of Sohrab to make it correct?
 A: You're right, the definition given of $g|_D$ is incorrect:


*

*As you point out, perhaps $f$ restricts from $g$ too much: while it has the domain $D$, it doesn't contain all the pairs from $g$ whose first element was in $D$.

*But there is another problem: we want $g|_D$ to be defined even when $g$ is not defined on some of the elements of $D$. For example, let $X = Y = \{1,2,3\}$, $D = \{1,2\}$, $g = \{(1,1),(1,3),(3,3)\}$. If $f = \{(1,1),(1,3)\}$ then we would probably like to say $f = g|_D$, but the definition in question doesn't cover it because $\operatorname{dom} f = \{1\} \ne D$.
There are different, equivalent ways to give a correct definition.


*

*The usual definition would be
$$
g|_D  = \Big\{(x,y) \::\; x \in D \text{ and } (x,y) \in g\Big\}
$$

*More concisely,
$$
g|_D = g \cap (D \times Y)
$$

*More along the lines of the definition given in your book, we could also say
$$
f = g|_D \quad\textbf{if} \quad f \subseteq g, \text{dom f} \subseteq D, \text{ and } 
f(x) = g(x) \text{ for all } x \in D.
$$
