Is the ideal of denominators preserved under flat pullback?

Let $\phi \colon A \to B$ be a flat homomorphism of rings (commutative, with unit). Let $R$ be the total ring of fractions of $A$ (obtained by inverting all nonzerodivisors), and let $S$ be the total ring of fractions of $B$. Since $B$ is flat over $A$, nonzerodivisors of $A$ map to nonzerodivisors of $B$, and so we obtain a natural extension $\phi \colon R \to S$. Let $r \in R$ be a "rational function on $\operatorname{Spec} A$". Let $I, J$ be the ideals of denominators of $r$ in $A, B$, respectively: \begin{align*} I &= \{ a \in A : a r \in A \} \\ J &= \{ b \in B : b r \in B \}. \end{align*}

Is $J = B \phi(I)$?

The statement amounts to "Flat ring homomorphisms respect ideals of denominators." I know this holds if $B$ is a localization of $A$ (although my proof is rather messy; there's a much nicer proof in the case of inverting a single element given on page 34 of this document from the stacks project). On the other hand, ideals of denominators cannot respect pullbacks in general, since a general pullback need not take a rational function to a rational function. It seems to me that counterexamples in the flat case would probably need to involve a rational function with a non-principal ideal of denominators, and I don't have a great store of such examples to test.

Motivation: The ideal of denominators of a rational function $f$ vanishes precisely where $f$ is not defined.

-
Unless, I'm missing something obvious, the following seems to work: Note that we have inclusions $B\to R\otimes_AB\to S$, and the map $B\to S$ induced by multiplication by $r$ factors through $R\otimes_AB$. In particular, $J\to B$ is the fiber-product of $r:B\to R\otimes_AB$ and the inclusion $B\to R\otimes_AB$. By flatness of $B$ over $A$, this is simply the base-change over $A$ of the fiber-product $I\to A$ of $r:A\to R$ and the inclusion $A\to R$. –  Keerthi Madapusi Pera Sep 4 '11 at 19:03
Keerthi, I've gone through your argument reasonably carefully, and I don't see any flaws. If you give this as an answer, I will accept it. –  Charles Staats Sep 4 '11 at 20:05
It looks to me like the crux of Keerthi's argument is that the ideal of denominators $I$ can be defined by the exactness of the sequence $0 \to I \stackrel{\binom{1}{1}}{\longrightarrow} A \oplus A \stackrel{\scriptscriptstyle(1,-r)}{\longrightarrow} R$. –  Charles Staats Sep 6 '11 at 18:06