I am trying to find a Green's function for the wave equation: \begin{equation} \bigg(\nabla^2 - \frac{1}{c}^2\frac{\partial^2}{\partial t^2}\bigg)G(\textbf{r},t) = \delta^3(\textbf{r})\delta(t) \end{equation} After a fairly trivial calculation, one easily finds that \begin{equation} G(\textbf{r},t) = \frac{1}{4\pi^3} \int_0^\infty dk \ c^2 k^2 \frac{\sin(kr)}{kr} \int_{-\infty}^\infty d\omega \frac{e^{-i\omega t}}{(\omega-ck)(\omega+ck)} \end{equation} I am mainly interested in the integral in $\omega$: \begin{equation} \int_{-\infty}^\infty d\omega \frac{e^{-i\omega t}}{(\omega-ck)(\omega+ck)} \end{equation} We can evaluate this integral in the complex $\omega$-plane by choosing a contour running over $\text{Re}(\omega)$ but jumping over the poles at $\omega=\pm ck$. There are several choices for such a contour, and I'm wondering why choosing one contour will give a different value for this integral than another?
For example, suppose that $t<0$ so that $e^{-i \omega t} \rightarrow 0$ as $\omega\rightarrow i\infty$. This suggests that we close our contour in the upper half plane ensuring that the integral due to the upper semi-circle does not give any contribution. This contour does not enclose either pole so by the residue theorem the integral vanishes.
Now consider $t>0$. Then $e^{-i\omega t} \rightarrow 0$ as $\omega \rightarrow -i\infty$. This suggests that we close our contour in the lower half plane ensuring that the integral due t the lower semi-circle doe snot give any contribution. This time, we enclose both poles, so by the residue theorem: \begin{equation} \int_{-\infty}^\infty d\omega \frac{e^{-i\omega t}}{(\omega-ck)(\omega+ck)} = -2\pi i\bigg(\frac{e^{-ickt}}{2ck}-\frac{e^{ickt}}{2ck}\bigg) = -\frac{2\pi}{ck} \sin (kct), \ t>0 \end{equation} where the negative sign comes from the fact that the contour runs clockwise. This gives rise to a retarded Green's function.
However suppose that instead of skipping over the poles I not skip under them. The integral now evaluates to something else (which gives an advanced green's function): \begin{equation} \int_{-\infty}^\infty d\omega \frac{e^{-i\omega t}}{(\omega-ck)(\omega+ck)} = 2\pi i\bigg(\frac{e^{-ickt}}{2ck}-\frac{e^{ickt}}{2ck}\bigg) = \frac{2\pi}{ck} \sin (kct), \ t<0 \end{equation} So which of these contours am I to choose? Why do they give different values for a definite integral?


