Depending on the countries involved, both are possible and there are a few other scenarios too.


You are arrested, prosecuted locally and serve your sentence where you committed your crime. As others have said, local law fully applies, it happens all the time. Your home country should be informed and can at most complain and try to exert some pressure on a political level but you don't have any extraordinary legal protection only because you are a foreign national. For a famous recent case illustrating this, see Amanda Knox.
You are arrested, prosecuted and sentenced but you are allowed to serve your sentence in your home country. As @MastaBaba pointed out, there are international agreements to organise this on a bilateral basis.
You are arrested, prosecuted, sentenced and you serve your sentence but it doesn't end there. You can still be deported and/or banned after the end of your sentence. Many European countries have actually introduced or strengthened legislation to this end in the last decade. So it's not either face trial or be deported, if you are really “lucky” it could be both!
You are arrested and criminal proceedings are initiated but you manage to come back home at some point during the procedure. In Europe, for a simple theft with no prior offence or aggravating circumstances, a jail sentence is unlikely and it is therefore unusual to be detained prior to trial. If you choose to “jump bail” and somehow manage to leave the country, things become a bit complicated. Among the possibilities:


The country where you committed your crime seeks your extradition to force you to appear in court and/or execute your sentence (not always possible because some countries never extradite their own citizens). For another prominent example, see Roman Polanski.
You are sentenced in absentia. Institutions like the Council of Europe have been pushing against this practice but some countries still do it. You might or might not be entitled to a retrial when you are finally caught but one effect is typically to suspend or extend statutes of limitation so that such a sentence means you will have to look over your shoulder and avoid going back to the country of your crime (or possibly all the countries that have an extradition treaty with that country) for the rest of your life.
You could still face prosecution in your home country (see below), although that would seem exceedingly unlikely for a theft.

Nothing happens, you come back home and are prosecuted in your country of origin. Many countries do that for particularly serious crimes but some countries also allow it for pretty much everything, in particular because they never extradite their own citizens. In the latter case, the crime in question must typically exist in the laws of both countries whereas in the former case, it's sometimes even possible to prosecute people for things that were not illegal where and when they happened (e.g. in many European countries, laws against child prostitution typically apply to offences committed abroad, without any reference to local law).
You are prosecuted in another, unrelated third country. It's unusual and typically limited to particularly heinous crimes (and in particular war crimes, crimes against humanity and genocide) but it does happen. Among those that might take interest are your country or countries of residence or the country of origin or residence of any of your victims and Baltasar Garzón. See also Wikipedia.


Among other curiosities, the fact that it might sometimes be possible to be prosecuted in several places also raises questions related to the application of the non bis in idem principle.

In short, it depends a lot on the details, there is no overarching principle or international agreement that would apply in all cases. 

Can I be prosecuted in a European country while on vacation?
I had an error (related to Date module I think? Can't remember.) on my site so I tried to do an update. Caused a WSOD so I svn reverted. Didn't help. Manually disabled each module in the database. Didn't help. Fixed some permissions. Helped... sort of. 

Now I get this:


  Drupal already installed To start over, you must empty your existing
  database. To install to a different database, edit the appropriate
  settings.php file in the sites folder. To upgrade an existing
  installation, proceed to the update script. View your existing site.


Running the upgrade script gives this error:


  PDOException: SQLSTATE[HY000] [2002] Can't connect to local MySQL
  server through socket '/var/lib/mysql/mysql.sock' (2) in
  drupal_get_installed_schema_version() (line 150 of
  /public_html/includes/install.inc).


Any other page redirects back to install.php.

So it seems like it can see the database to know that it's not empty, but can't really connect to it... what does this mean? What do I do about it.
