Abstract : In this paper we study the optimal control problem of the heat equation by a distributed control over a subset of the domain, in the presence of a state constraint. The latter is integral over the space and has to be satisfied at each time. Using for the first time the technique of alternative optimality systems in the context of optimal control of partial differential equations, we show that both the control and multiplier are continuous in time. Under some natural geometric hypotheses, we can prove that extended polyhedricity holds, allowing to obtain no-gap second-order optimality conditions, that characterize quadratic growth. An expansion of the value function and of approximate solutions can be computed for a directional perturbation of the r.h.s. of the state equation.