HE was the dinner guest from hell. David Cameron bored for Britain last week, lecturing the assembled heads of EU countries as they tried to eat their duck and truffles on his plan to stop migrants getting access to in-work benefits for four years.

What a dismal Scrooge-like Christmas spectacle that must have made. A narrow-minded, ignorant whinge from the leader of one of the richest countries on the planet demanding that Britain alone in Europe should be allowed to deprive EU workers of their rights.

The Prime Minister droned on for fully 45 minutes – which we are told is a record at EU summit dinners – holding the politicians to gastronomic ransom until they finally agreed to give him what he wanted. Another fig leaf.

The deal was that there was no deal. The communiques merely contained a reference to something called the Edinburgh Agreement. This is nothing to do with the agreement of the same name in 2012 that legalised the Scottish independence referendum, but refers to an EU promise, apparently given to the Danes in 1992, that their reservations about the Maastricht Treaty on common currency would be listened to.

But only if they are legal. The problem is discrimination. Member states are not allowed to treat EU workers differently as regards working conditions and social security benefits than their own citizens. It's the same reason that EU students get free higher education in Scotland whereas English students do not.

It is all about that cardinal principle of the European Union: free movement. A level playing field for all workers everywhere within the 28 countries of the EU. And the other 27 member states are not going to abandon it just because David Cameron wants to look tough on skivers and on immigration.

Cameron knows this, but he is playing to the Eurosceptic gallery back home, where the press demonise people on benefits and assume foreigners are all on the take. Yet countless EU studies have shown that benefits tourism is a myth.

One of the British Government's own senior economic advisers, Sir Stephen Nickell, was asked by MPs on the House of Commons Treasury Committee only last week about whether the proposed curb on benefits would reduce EU migration to Britain. “Not much,” he said.

Migrants from countries like Poland come to Britain to work, not lounge around on benefits, which anyway are among the lowest in Europe. Even in cash-strapped Ireland, the standard unemployment pay is more than twice British jobseekers allowance of £71 a week (and only if you are over 21).

The Council of Europe censured Britain last year for our dismally low benefits rates, which it said were in breach of the EU Social Charter. In countries like France, Germany and Finland, unemployment benefit is 60% of previous net salary. So why come here?

Cameron's other three demands – assurances on British sovereignty, measures to promote economic competitiveness and the removal of the words “ever-closer union” from treaty preambles – are no problem to Brussels because they are platitudes. No-one wants to diminish national sovereignty in the EU just now; quite the reverse. And everyone is against red tape – except their own.

It’s a case of ever-wider disunion. What the member states of the European Union really wanted to talk about at their summit dinner on Thursday was restoring borders against terrorist tourists. And how to cope with mass migration from countries outside the EU, such as Syria. The Schengen no-passport zone is toast.

But that doesn’t mean the Maastricht Treaty is a burnt offering. Britain can impose any rules it likes to keep out non-EU migrants, and it does. We are seeing non-EU nurses and music teachers being sent home because they aren't earning more than £35,000 a year under our daft immigration rules. But such discrimination against people from EU countries is simply not legal.

No doubt some compromise will be cobbled together before February, Cameron's negotiation deadline. There can be concessions if it can be proved that “exceptional circumstances” have put undue pressure on a member state's social services.

Austria apparently got away with applying temporary quotas of students 10 years ago. But only for a while. Francois Hollande suggested the EU might buy Britain by imposing a benefit freeze of two years rather than four.

The PM will then declare a famous victory, and his ministers lined up to portray him as a latter-day St George, slaying the European dragon. But this will go nowhere near satisfying the growing number of Brexit supporters on the Tory backbenches.

One of them, Jacob Rees-Mogg, censured Cameron openly last week on BBC's Question Time, saying that the Prime Minister's demands were worthless even if they were delivered, and anyway are offensive to migrants.

And given the growing hostility of the UK press to Europe, it's hardly surprising that SNP MEPs like Alyn Smith are urging Nicola Sturgeon to take seriously the possibility of a No vote in the European referendum, which David Cameron wishes to hold as early as next June, shortly after the Holyrood elections.

If anything, the opinion polls on Europe are moving in different directions north and south of the Border. The last Ipsos Mori poll for STV suggested that 65% of Scots favour staying in Europe against 22% who are for coming out. That's with don't-knows excluded.

South of the Border, the “outers” have been closing the gap, and most polls put it neck and neck, with supporters of staying in the EU holding on to a very narrow majority. If Scotland votes overwhelmingly Yes to remaining in Europe, but still has to leave, we would have a real doomsday scenario.

The First Minister is on record as saying that, if Scotland is forced out on the strength of votes in England, this would be a justification for another referendum on Scottish independence. It would be a “change in material circumstances”.

It would certainly be a constitutional rupture of immense significance, and would perhaps cause some regret among Scots who voted to remain in the UK in September 2014. But would an early repeat referendum be wise?

The SNP still want a currency union with England. But how does that work if the UK has left the EU, while Scotland tries to remain in Europe? Scotland doesn't want to join the euro, so if Scotland became independent we would be in the EU for legal purposes but out of it as far as economy is concerned.

There is a degree of cognitive dissonance about the SNP's entire attitude on the European Union. Nicola Sturgeon is firmly for remaining in the EU on the grounds that Scotland benefits materially from inward investment and trading advantages.

But that was the narrow, economistic argument that was used by the Unionist Better Together campaign in the Scottish referendum campaign, and the Nationalists rejected it. Supporters of Scottish independence said that giving Scotland full autonomy and control of its own economic affairs would counter any short-term difficulties. On the face of it, that could also apply to leaving Europe.

Then there's referendum fatigue. Do Scots want yet another referendum after having had two in 18 months, plus two parliamentary elections? I’m fed up with politics, and it’s my job.

Some of the First Minister's advisers are still gung ho for another referendum after Brexit, but I suspect that Nicola Sturgeon will think very carefully before she fires the starting gun on another indyref. It might just backfire.