you may use a slack variable in order to transform the problem to a DAE. Thereby use odeset to set the NonNegative option for the slack variable. The Matlab routines 'ode15s' and 'ode23t' can solve DAEs.
You could have a slack variable s and require s^2 = 2 - x(1). But funny things will happen when you hit x(1) == 2. In fact, normally there will not be any solution. Take for example, dx/dt = -x, x_0 = 1 with the constraint x >= 1/2. The solution is x(t) = exp(-t) *until* x(t^*) = 1/2, beyond which there is no solution. Something has to be brought in to prevent x(t) going below 1/2.
What is supposed to happen when the limit is reached? Is that the end of the simulation (in which case integrate the ODE as normal, but tell it to stop when the limit is reached -- this is available in Matlab solvers)? Or does something else happen, as occurs in contact mechanics for example?