Index: src/backend/access/transam/twophase.c
===================================================================
RCS file: /home/hlinnaka/pgcvsrepository/pgsql/src/backend/access/transam/twophase.c,v
retrieving revision 1.27
diff -c -r1.27 twophase.c
*** src/backend/access/transam/twophase.c	16 Jan 2007 13:28:56 -0000	1.27
--- src/backend/access/transam/twophase.c	13 Feb 2007 18:39:04 -0000
***************
*** 393,398 ****
--- 393,404 ----
  				  errmsg("permission denied to finish prepared transaction"),
  					 errhint("Must be superuser or the user that prepared the transaction.")));
  
+ 		if (MyProc->databaseId != gxact->proc.databaseId)
+ 			ereport(ERROR,
+ 					(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
+ 				  errmsg("prepared transaction belongs to another database"),
+ 					 errhint("Connect to the database where the transaction was prepared to finish it.")));
+ 
  		/* OK for me to lock it */
  		gxact->locking_xid = GetTopTransactionId();
  
