Given a polynomial function $f \colon \mathbb{R}^n \rightarrow \mathbb{R}$ and a unbounded basic closed semi-algebraic set $S \subset \mathbb{R}^n,$ in this paper we show that the conditions listed below are characterized exactly in terms of the so-called {\em tangency variety} of $f$ on $S$: (i) The $f$ is bounded from below on $S;$ (ii) The $f$ attains its infimum on $S;$ (iii) The sublevel set $\{x \in S \ | \ f(x) \le \lambda\}$ for $\lambda \in \mathbb{R}$ is compact; (iv) The $f$ is coercive on $S.$ Besides, we also provide some stability criteria for boundedness and coercivity of $f$ on $S.$