THE calm that has followed Mario Draghi’s vow in July to do whatever it takes to save the euro is deceptive. The head of the European Central Bank (ECB) pledged to make potentially unlimited purchases of short-term government bonds of euro-zone countries that ask for (and receive) help from international lenders. But his pledge is yet to be tested. When it is, the supplicant will probably be Spain, the fourth-largest euro-area economy.

The government of Mariano Rajoy hopes that Spain can get a bail-out of its public finances (it has already won support for its banks) without having to sign up to harsher austerity measures than those it has already implemented. It argues that Spain is suffering a temporary liquidity problem. It wants the European Stability Mechanism (ESM), the euro area’s permanent rescue fund, to buy some of Spain’s newly issued debt while the ECB acts to bring down bond yields in the secondary markets. Markets will stay open to Spain, and its public finances will right themselves on their own. To sceptics, all this sounds like wishful thinking.

The past year has been a confidence-sapping story of missed fiscal targets. The budget deficit was supposed to have fallen from 9.2% of GDP (now revised up to 9.7%) in 2010 to 6% in 2011. But there was a big overshoot and the eventual deficit last year was 9.4%. This year’s target, which excludes bank support, has been raised to 6.3%, but even this higher goal will be missed: the IMF projects a 7% deficit.

Spain’s performance this year has been particularly dire in comparison with other rich countries. Comparing its April and October forecasts for 2012, the IMF finds that Spain’s budget balance deteriorated the most out of 30 advanced economies. The upward revision for debt (largely because of the cost of bank rescues) was second only to that for Greece. Further disappointments seem likely for Spain’s goal of reducing the deficit to 4.5% of GDP in 2013, not least since the government’s prediction that the economy will shrink by only 0.5% in 2013 is optimistic. The Economist’s panel of forecasters projects a fall of 1.4%.

The failure to hit fiscal goals is not for want of effort. Since his election victory last November, Mr Rajoy has introduced no fewer than four budget packages. The problem runs deeper. Unlike Greece, Spain appeared to be a model pupil before the financial crisis. In 2007 it ran a budget surplus of 1.9% of GDP and public debt was a modest 36% (see chart 1). But the figures flattered to deceive in two main ways. First, Spain’s revenues were pumped up by unreliable taxes generated both directly, by the property boom, and indirectly, as the economy sucked in imports (which unlike exports are subject to VAT, a consumption tax). These cash gushers have run dry since the housing bust. This helps to explain why Spanish tax receipts as a share of GDP will be over five percentage points lower in 2012 than in 2007, the biggest drop in the European Union.

Second, Spain’s ability to get its national finances under control has been compromised by a flawed system of regional financing (see chart 2). Spain’s 17 regions were mainly responsible for the budgetary overshoot last year and look certain to contribute to an overrun this year. Under changes that have gathered pace in the past two decades, the regions spend more than one public euro in three but raise less than a fifth of taxes. They thus require big transfers from the centre to fill the gap. Such a mismatch is a recipe for fiscal indiscipline anywhere. But Spain is particularly decentralised: its regions are responsible not only for education but for health care, too, the stuff of fiscal nightmares in any rich economy. Moreover, the taxes they fully control, on financial and capital transactions, were especially vulnerable to the housing bust; and the regions are reluctant to use the discretion they have in varying personal-income tax rates. They make little use of the autonomy they have, preferring to rely on transfers from the centre to deal with financial shortfalls, says the OECD’s Hansjörg Blöchliger. Moody’s, a credit-rating agency, reinforced the worries this week by downgrading five regions. Tackling these two flaws will be painful. Raising more revenue requires not just an increase in rates but a comprehensive shake-up of the tax system. Reforms to increase the share of consumption taxes by widening the VAT tax base and raising other indirect taxes are essential, says Rafael Doménech, chief economist for developed economies at BBVA, a bank. But such an overhaul would be unpopular since it would involve hiking fuel duties and raising currently low VAT rates on essentials such as food. Dealing with the regional imbroglio may prove even trickier. Mr Rajoy is trying hard to tighten Madrid’s grip. Under new legislation the central government can now act towards its regions rather as the dreaded troika (the ECB, the European Commission and the IMF) has done towards bailed-out economies. But pressure from the centre is already meeting resistance, notably in Catalonia, the country’s biggest economic region, which is holding an early election in November. Separatist sentiment is running high.

The structural weaknesses of the public finances are such that even if a Spanish bail-out began without demands from the troika for further reforms, it would not prove sustainable. And the more that European lenders get embroiled in Spain’s public finances, the more politically contentious it may become. They will surely want even stricter controls on the regions’ finances, for example, but that may provoke further secessionist fervour in Catalonia.

All this would unfold against a backdrop of higher borrowing needs. The Spanish government says it will need to issue debt worth €207 billion ($271 billion) in 2013—and that is on the assumption that the 4.5% of GDP deficit target is met. European leaders who believe that they need do no more than dip into the ESM to tide Spain over are likely to be disappointed. If Spain asks for help, the rescuers will have to keep helping for years.