Let $A$ and $B$ denote open convex subsets of $\mathbb{R}^n$. Suppose $f$ and $g$ are convex functions on $A$ and $B$ respectively, mapping into the real line. It seems likely that if $f$ and $g$ agree on $A \cap B$, and if $A \cup B$ is convex, then $f \cup g : A \cup B \rightarrow \mathbb{R}$ is a convex function.
Question. Is this true?
The assumption that $A$ and $B$ are open is necessary to prevent the following counterexample: $n=1$, $A = [0,1)$, $B=[1,2]$, and $f$ and $g$ are constant functions of different heights.