Say you had a Napoleonic-era regiment of infantry who'd run out of ammo or whose powder had got wet, and who therefore had to rely on just their bayonets to defend themselves against enemy cavalry. Would they be able to do so, or would muskets and bayonets be too short to adequately defend them without musket fire to back them up?
The cavalry is facing infantry in a square formation and, with them
not shooting, enthusiasm of the cavalry is evaporating (and its attack slows down) as it is getting closer. There is a good chance that it'll just turn back if there is no fire at 20 - 30 yards because this means that the square is going to shoot at the point blank range (see description by Clausewitz of the French cavalry attacks on his battalion after Jena ). The few remaining enthusiasts (if any) are going to be bayoneted when they come close: Except for the uhlans/lancers the regular European cavalry has only their swords and they are shorter then a musket with a bayonet, not to mentioned that the horses, in general, do not have a sense of patriotism (as was discovered and reported to Napoleon by general Nansouty) and as a result are rather unwilling to go to their death.
Funny as it may sound, cavalry of the early XVII century, the reiters, would be much more effective: they were predominantly shooting cavalry with 4 - 6 pistols per soldier and the tactics (caracole) specially developed for the effective fire. In the early XIX, while cavalry generally had pistols and some types of a cavalry (like hussars) had carbines, they were not (AFAIK) taught any effective tactics of shooting in a formation. Exception were the dragoons but their shooting was predominantly done when they were dismounted.
Even in the mid-XIX situation was pretty much the same. The famous "thin red line" (which could be thin but also it was more numerous than the attackers) made only 2 salvos from a big distance (no enemy losses) after which the attacking Russian cavalry turned back. IIRC, this cavalry included the Cossacks who did have the muskets but did not try to fire back.