As I was updating ready for installing the new patches on a site I have inherited, I found this in my reports:
a:5:{i:0;s:313:"SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`__COMPANYNAME___magento`.`__COMPANYNAME__catalog_compare_item`, CONSTRAINT `FK___COMPANYNAME__CAT_CMP_ITEM_PRD_ID___COMPANYNAME__CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`product_id`) REFERENCES `__COMPANYNAME__catalog_product_entit)";i:1;s:2270:"#0 lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#3 lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `ge...', Array)
#4 lib/Varien/Db/Adapter/Pdo/Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `ge...', Array)
#5 lib/Zend/Db/Adapter/Abstract.php(576): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `ge...', Array)
#6 app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(453): Zend_Db_Adapter_Abstract->insert('__COMPANYNAME__catalog...', Array)
#7 app/code/core/Mage/Core/Model/Abstract.php(318): Mage_Core_Model_Resource_Db_Abstract->save(Object(Mage_Catalog_Model_Product_Compare_Item))
#8 app/code/core/Mage/Catalog/Model/Product/Compare/List.php(51): Mage_Core_Model_Abstract->save()
#9 app/code/core/Mage/Catalog/Model/Product/Compare/List.php(67): Mage_Catalog_Model_Product_Compare_List->addProduct('http:')
#10 app/code/core/Mage/Catalog/controllers/Product/CompareController.php(63): Mage_Catalog_Model_Product_Compare_List->addProducts(Array)
#11 app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Catalog_Product_CompareController->indexAction()
#12 app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('index')
#13 app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#14 app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#15 app/Mage.php(684): Mage_Core_Model_App->run(Array)
#16 index.php(87): Mage::run('', 'store')
#17 {main}";s:3:"url";s:329:"/catalog/product_compare/index/items/244,http://some-inexistent-website.acu/some_inexistent_file_with_long_name%3F.jpg,246,251,253,254,255,256,257,258,264,266,267,268,269,271,272,273,274,275,276,277,278,287,339/uenc/aHR0cDovL3d3dy5nZWxwYWNrc2RpcmVjdC5jby51ay9jYXRhbG9nc2VhcmNoL3Jlc3VsdC9pbmRleC8_bW9kZT1saXN0JnE9aWNlJTIwd3JhcA,,/";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:7:"default";}
By accessing the url example.com/catalog/product_compare/index/items/244,http://some-inexistent-website.acu/some_inexistent_file_with_long_name%3F.jpg,246,251,253,254,255,256,257,258,264,266,267,268,269,271,272,273,274,275,276,277,278,287,339/uenc/aHR0cDovL3d3dy5nZWxwYWNrc2RpcmVjdC5jby51ay9jYXRhbG9nc2VhcmNoL3Jlc3VsdC9pbmRleC8_bW9kZT1saXN0JnE9aWNlJTIwd3JhcA,,/
I would have thought it would fail before getting to the MySQL error and this is not normal, although everything is the stack trace is from the Core codepool.
Magento version is CE 1.9.0.1