Magento Forum

   
foreign key error
 
gnum
Member
 
Total Posts:  38
Joined:  2009-02-16
 

From time to time i am getting error when pressing order button in cart:

SQLSTATE[HY000]: General error: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`gifts/sales_flat_quote_shipping_rate`, CONSTRAINT `FK_SALES_QUOTE_SHIPPING_RATE_ADDRESS` FOREIGN KEY (`address_id`) REFERENCES `sales_flat_quote_address` (`address_id`))
Trace:
#0 D:\www\gifts\lib\Zend\Db\Statement.php(283): Zend_Db_Statement_Pdo->_execute(Array)
#1 D:\www\gifts\lib\Zend\Db\Adapter\Abstract.php(457): Zend_Db_Statement->execute(Array)
#2 D:\www\gifts\lib\Zend\Db\Adapter\Pdo\Abstract.php(230): Zend_Db_Adapter_Abstract->query(’DELETE FROM `sa...’, Array)
#3 D:\www\gifts\lib\Varien\Db\Adapter\Pdo\Mysql.php(258): Zend_Db_Adapter_Pdo_Abstract->query(’DELETE FROM `sa...’, Array)
#4 D:\www\gifts\lib\Zend\Db\Adapter\Abstract.php(604): Varien_Db_Adapter_Pdo_Mysql->query(’DELETE FROM `sa...’)
#5 D:\www\gifts\app\code\core\Mage\Core\Model\Mysql4\Abstract.php(370): Zend_Db_Adapter_Abstract->delete(’sales_flat_quot...’, ‘address_id=’42’’)
#6 D:\www\gifts\app\code\core\Mage\Core\Model\Mysql4\Abstract.php(339): Mage_Core_Model_Mysql4_Abstract->delete(Object(Mage_Sales_Model_Quote_Address))
#7 D:\www\gifts\app\code\core\Mage\Core\Model\Abstract.php(251): Mage_Core_Model_Mysql4_Abstract->save(Object(Mage_Sales_Model_Quote_Address))
#8 D:\www\gifts\app\code\core\Mage\Core\Model\Mysql4\Collection\Abstract.php(206): Mage_Core_Model_Abstract->save()
#9 D:\www\gifts\app\code\core\Mage\Sales\Model\Quote.php(203): Mage_Core_Model_Mysql4_Collection_Abstract->save()
#10 D:\www\gifts\app\code\core\Mage\Core\Model\Abstract.php(252): Mage_Sales_Model_Quote->_afterSave()
#11 D:\www\gifts\app\code\core\Mage\Checkout\Model\Cart.php(338): Mage_Core_Model_Abstract->save()
#12 D:\www\gifts\app\code\core\Mage\Checkout\controllers\CartController.php(110): Mage_Checkout_Model_Cart->save()
#13 D:\www\gifts\app\code\core\Mage\Core\Controller\Varien\Action.php(367): Mage_Checkout_CartController->indexAction()
#14 D:\www\gifts\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(163): Mage_Core_Controller_Varien_Action->dispatch(’index’)
#15 D:\www\gifts\app\code\core\Mage\Core\Controller\Varien\Front.php(158): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#16 D:\www\gifts\app\Mage.php(457): Mage_Core_Controller_Varien_Front->dispatch()
#17 D:\www\gifts\index.php(52): Mage::run()
#18 {main}

Looks like Magento tryed to clear some order cache or something like this.

Can someone advice?

 
Magento Community Magento Community
Magento Community
Magento Community
 
rainman127
Sr. Member
 
Avatar
Total Posts:  218
Joined:  2008-06-30
 

Hi,
Is your mySql database using the InnoDB engine?

 
Magento Community Magento Community
Magento Community
Magento Community
 
gnum
Member
 
Total Posts:  38
Joined:  2009-02-16
 

hi,
rainman127, yes

 
Magento Community Magento Community
Magento Community
Magento Community
 
rainman127
Sr. Member
 
Avatar
Total Posts:  218
Joined:  2008-06-30
 

Ok, so lets do the logic on this:

have you added any modules to the default install? shipping module maybe?
It only does it some of the time. when it happens look at the customer address.
See anything in common when it fails?

just some thoughts..

thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
mrmiagi
Jr. Member
 
Total Posts:  9
Joined:  2009-03-26
 
gnum - 23 March 2009 08:38 AM

From time to time i am getting error when pressing order button in cart:


SQLSTATE[HY000]: General error: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`gifts/sales_flat_quote_shipping_rate`, CONSTRAINT `FK_SALES_QUOTE_SHIPPING_RATE_ADDRESS` FOREIGN KEY (`address_id`) REFERENCES `sales_flat_quote_address` (`address_id`))
Trace:
#0 D:\www\gifts\lib\Zend\Db\Statement.php(283): Zend_Db_Statement_Pdo->_execute(Array)
#1 D:\www\gifts\lib\Zend\Db\Adapter\Abstract.php(457): Zend_Db_Statement->execute(Array)
#2 D:\www\gifts\lib\Zend\Db\Adapter\Pdo\Abstract.php(230): Zend_Db_Adapter_Abstract->query(’DELETE FROM `sa...’, Array)
#3 D:\www\gifts\lib\Varien\Db\Adapter\Pdo\Mysql.php(258): Zend_Db_Adapter_Pdo_Abstract->query(’DELETE FROM `sa...’, Array)
#4 D:\www\gifts\lib\Zend\Db\Adapter\Abstract.php(604): Varien_Db_Adapter_Pdo_Mysql->query(’DELETE FROM `sa...’)
#5 D:\www\gifts\app\code\core\Mage\Core\Model\Mysql4\Abstract.php(370): Zend_Db_Adapter_Abstract->delete(’sales_flat_quot...’, ‘address_id=’42’’)
#6 D:\www\gifts\app\code\core\Mage\Core\Model\Mysql4\Abstract.php(339): Mage_Core_Model_Mysql4_Abstract->delete(Object(Mage_Sales_Model_Quote_Address))
#7 D:\www\gifts\app\code\core\Mage\Core\Model\Abstract.php(251): Mage_Core_Model_Mysql4_Abstract->save(Object(Mage_Sales_Model_Quote_Address))
#8 D:\www\gifts\app\code\core\Mage\Core\Model\Mysql4\Collection\Abstract.php(206): Mage_Core_Model_Abstract->save()
#9 D:\www\gifts\app\code\core\Mage\Sales\Model\Quote.php(203): Mage_Core_Model_Mysql4_Collection_Abstract->save()
#10 D:\www\gifts\app\code\core\Mage\Core\Model\Abstract.php(252): Mage_Sales_Model_Quote->_afterSave()
#11 D:\www\gifts\app\code\core\Mage\Checkout\Model\Cart.php(338): Mage_Core_Model_Abstract->save()
#12 D:\www\gifts\app\code\core\Mage\Checkout\controllers\CartController.php(110): Mage_Checkout_Model_Cart->save()
#13 D:\www\gifts\app\code\core\Mage\Core\Controller\Varien\Action.php(367): Mage_Checkout_CartController->indexAction()
#14 D:\www\gifts\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(163): Mage_Core_Controller_Varien_Action->dispatch(’index’)
#15 D:\www\gifts\app\code\core\Mage\Core\Controller\Varien\Front.php(158): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#16 D:\www\gifts\app\Mage.php(457): Mage_Core_Controller_Varien_Front->dispatch()
#17 D:\www\gifts\index.php(52): Mage::run()
#18 {main}

Looks like Magento tryed to clear some order cache or something like this.

Can someone advice?

i get nearly the same error.
have you found a solution for that problem?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Rennes007
Jr. Member
 
Total Posts:  19
Joined:  2011-10-19
 

Hi there,

I have about the SAME error!

“SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`database_name`.`sales_flat_quote_shipping_rate`, CONSTRAINT `FK_B1F177EFB73D3EDF5322BA64AC48D150` FOREIGN KEY (`address_id`) REFERENCES `sales_flat_quote_address` (`address_id`) ON DELETE CASC)";i:1;s:13638:"#0 /pathtomyinstallation/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)

Did you ever found out the problem?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top