- Mass: Mercury - $3.3022×10^{23} \text{ kg}$; Sun - $1.98855×10^{30} \text{ kg}$. Mercury clearly won't so much as jostle the Sun. There should be no major changes in the Sun's orbit around the galactic center.
- Composition: Mercury - oxygen, sodium, hydrogen, and iron; Sun - hydrogen and helium. The extra elements shouldn't affect the Sun's fusion process, especially given how scarce they are.
Jupiter vs. the Sun
Mass: Jupiter - $1.8986×10^{27} \text{ kg}$; Sun - $1.98855×10^{30} \text{ kg}$. Jupiter could perhaps perturb the Sun a little if it hit it right on.
Composition: Jupiter - hydrogen and helium; Sun - hydrogen and helium. The Sun would gain a little fuel, but not enough to cause a substantial change in the Sun's fusion.
In both cases, the Earth should be fine. Sure, there could be a solar flare or two, but not anything substantial enough to severely impact the Earth.
There are two interesting side effects of such a collision, and while they wouldn't impact Earth, they're still worthy of mention. First, the collision of a gas giant with a star would increase the lithium-6 concentration in the star (see this article aboutIsraelian et al. (2001) and Melendez et al. (2016), who studied HD 82943 and HIP 68468, respectively). Second, if the planet (again, assuming it's a gas giant) was a victim of orbital decay, then it could be torn apart when it reached the Roche limit. The resulting angular momentum transfer could drastically increase the star's rotation rate (see Hellier et al. (2009)).