Gravitational effects. It would almost certainly disturb a lot of asteroids and comets into new orbits. It wouldn't be a catastrophe for Earth , given the protection of the gas giants, but it would probably increase risks for the next few decades/centuries/millenniums. Depending on the exact trajectory of the planet, it would probably also disturb other planets' orbits a little. Anything radically different would be unlikely, but maybe something light and relatively unstable like Mercury would go nuts. As for Earth, in the likeliest scenarios, at most maybe the length of a year is altered.
The collision (perfectly head-on). It vastly depends on the speed. If it's very slow, it'll probably be diverted from the sun by the other planets and solar winds. If it's fast but not relativistic, it'll probably cause massive solar flares and very obvious sun spots for a while. At relativistic speeds (a sizeable fraction of the speed of light), though, it would be a lot of energy. Something big would probably happen when the extremely fast planet smashes into the dense core of the sun, probably. I'm not sure what though. Maybe it would temporarily strengthen fusion and cause some sort of micro supernova?
The collision(glancing blow). The sun is massive but most of its volume is pretty wispy. Most of its volume is a lot less dense than a planet, so the planet would likely have a pretty dramatic effect on it. If it's fast enough, it might even come out on the other side, smashed to pieces by gravitational forces and thermal shock. It might expel a lot of plasma in a stream, like a squishy body shot with the fastest bullet in the world. A bullet on a curved trajectory though, because the proximity to the sun's core would likely steer it significantly. If the planet was going fast enough to escape despite the friction having it slowed down and the massive gravitational pull, then I could imagine pretty much a shotgun of planet chunks shot through the solar system. It might not hit anything, and probably won't considering how much of the solar system is empty space, but if it does, it would be catastrophic for, say, Earth.
As for long term effects, if the planet indeed merges into the sun, it would increase the sun' metallicity (content in elements heavier than helium) by a tiny percentage. It might affect its long term evolution by a very small margin. If it's a glancing blow that's not extremely fast and it's just right to create a mostly stable orbit, it might form a new asteroid belt that may or may not coalesce into a new planet in time.