Let $S$ be a scheme. We consider the functor, called *affine hull,* from the category of quasicompact and quasiseparated $S$-schemes to the category of affine $S$-schemes, defined as a left adjoint to the inclusion functor between these two full subcategories of the category of $S$-schemes (cf. EGA I.9.1.21). This functor commutes with *flat* base change in an obvious sense. My question, mostly out of pure curiosity, is how much we need flatness for this to hold. More precisely I would like to ask the following two things:



> 
> A. What are examples showing that flatness cannot be omitted in the above statement?
> 
> 
> B. Are there any other conditions on the base change morphism under which formation of affine hulls commutes with base change?
> 
> 
> 



Affine hulls and base change
First of all, I think that the affine hull functor can be extended to the category of all $S$-schemes, that is, not only the quasicompact quasiseparated ones [**EDIT** this may be true but the argument given here is not correct as it stands, see below]. The assumption qcqs is useful in that it ensures that the sheaf $A$ which is the pushforward of the structure sheaf is quasicoherent and then one defines the affine hull to be relative Spec of $A$. However, in full generality, there is a largest quasi-coherent submodule of $A$, equal to the image of the canonical map $\oplus F\_i\to A$ where the $F\_i$ are all the quasi-coherent submodules of $A$. Call this largest submodule $A'$. It is easy to see that $A'$ has an induced multiplication, i.e. it is a subalgebra. Then one sees that the scheme $Spec(A')$ serves as an affine hull on all $S$-schemes.


[**EDIT.** In fact Fred points out that the image of $\oplus F\_i\to A$ may not be quasi-coherent and in this case the argument breaks down. Sorry.]


Concerning your questions:


A. Start from the projective line over the ring of rational integers, and let $D$ be a section of that line, i.e. a $\mathbb{Z}$-point. Remove the closed point $D\_2$ from the fibre at $2$ and call the result $X$. Let $S=Spec(\mathbb{Z})$ and $S'=Spec(\mathbb{F}\_2)$. A global function on $X$ restricts to the generic fibre to a function on $\mathbb{P}^1\_{\mathbb{Q}}$ i.e. a rational constant, and it restricts to the affine line $\mathbb{P}^1\_{\mathbb{Z}}\setminus D$ to a polynomial in $\mathbb{Z}[T]$, $T$ a coordinate. Thus the ring of global functions on $X$ is in fact $\mathbb{Z}$. On the other hand, clearly the ring of global functions on the special fibre $X\_2$ is a big polynomial ring, therefore the formation of the affine hull does not commute with the base change $S'\to S$.


B. Here is one simple example: if $X$ is affine over $S$, then it is equal to its affine hull and this remains true universally, i.e. after any base change (flat or not).


