This has all been discussed before. There's the crime of an insult, and that's a judicial question. If the insult is directed against a foreign politician, it carries a higher penalty or prison term - but only if the cabinet gives the go-ahead to that. And yes, the law was consciously written that way: the fact the insultee is a foreign politician makes it a political question and thus a matter of the cabinet to decide of that's politically expedient. The other elements of the crime are exactly the same as with an ordinary insult. Without Merkel's approval, Erdogan still would file charges and the prosecutor would still need to investigate and possibly prosecute, but only for the lesser charge of an ordinary insult.
Oh, and it's not the German constitution, it's the German criminal code.