Magento deleting product BIGINT UNSIGNED value is out of range

Written by Peter Davies on .

Several of our clients get an unusual recurring error in their Magento stores looking like:

SQLSTATE[22003]: Numeric value out of range: 1690 BIGINT UNSIGNED value is out of range in '(`magento_store`.`q`.`items_count` - 1)'

Option 1

DELETE FROM magento_sales_flat_quote WHERE updated_at < DATE_SUB(Now(),INTERVAL 30 DAY);

Option 2

DELETE FROM magento_sales_flat_quote WHERE customer_is_guest = 0;

Option 3

SET FOREIGN_KEY_CHECKS=0;
#truncate magento_enterprise_customer_sales_flat_quote;
#truncate magento_enterprise_customer_sales_flat_quote_address;
truncate magento_sales_flat_quote;
truncate magento_sales_flat_quote_item;
truncate magento_sales_flat_quote_address;
truncate magento_sales_flat_quote_shipping_rate;
SET FOREIGN_KEY_CHECKS=1;