magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

Unable to view Admin Catalog - SQL 1103 Incorrect table name '' #2809

Closed chrissm79 closed 8 years ago

chrissm79 commented 8 years ago

Created a brand new Magento 2 install and migrated data (not settings as I originally thought that was the issue) from Magento 1.7.0.2 store. When I attempt to navigate to the Admin > Products > Catalog I get the following error message:

SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name '', query was: SELECT COUNT(DISTINCT main_table.attribute_id) FROM `eav_attribute` AS `main_table`
 INNER JOIN `eav_entity_type` AS `entity_type` ON main_table.entity_type_id = entity_type.entity_type_id
 INNER JOIN `eav_entity_attribute` ON main_table.attribute_id = eav_entity_attribute.attribute_id
 INNER JOIN `` AS `additional_table` ON main_table.attribute_id = additional_table.attribute_id WHERE (`entity_type_code` = 'catalog_product') AND (`additional_table`.`is_used_in_grid` = 1)

Stack Trace:

SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name '', query was: SELECT COUNT(DISTINCT main_table.attribute_id) FROM `eav_attribute` AS `main_table`
 INNER JOIN `eav_entity_type` AS `entity_type` ON main_table.entity_type_id = entity_type.entity_type_id
 INNER JOIN `eav_entity_attribute` ON main_table.attribute_id = eav_entity_attribute.attribute_id
 INNER JOIN `` AS `additional_table` ON main_table.attribute_id = additional_table.attribute_id WHERE (`entity_type_code` = 'catalog_product') AND (`additional_table`.`is_used_in_grid` = 1)
#0 /home/vagrant/magento2/vendor/magento/framework/DB/Statement/Pdo/Mysql.php(95): Zend_Db_Statement_Pdo->_execute(Array)
#1 /home/vagrant/magento2/vendor/magento/zendframework1/library/Zend/Db/Statement.php(303): Magento\Framework\DB\Statement\Pdo\Mysql->_execute(Array)
#2 /home/vagrant/magento2/vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#3 /home/vagrant/magento2/vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT COUNT(DI...', Array)
#4 /home/vagrant/magento2/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(444): Zend_Db_Adapter_Pdo_Abstract->query('SELECT COUNT(DI...', Array)
#5 /home/vagrant/magento2/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(499): Magento\Framework\DB\Adapter\Pdo\Mysql->_query('SELECT COUNT(DI...', Array)
#6 /home/vagrant/magento2/vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php(828): Magento\Framework\DB\Adapter\Pdo\Mysql->query(Object(Magento\Framework\DB\Select), Array)
#7 /home/vagrant/magento2/vendor/magento/framework/Data/Collection/AbstractDb.php(217): Zend_Db_Adapter_Abstract->fetchOne(Object(Magento\Framework\DB\Select), Array)
#8 /home/vagrant/magento2/vendor/magento/module-eav/Model/AttributeRepository.php(130): Magento\Framework\Data\Collection\AbstractDb->getSize()
#9 /home/vagrant/magento2/vendor/magento/module-catalog/Model/Product/Attribute/Repository.php(97): Magento\Eav\Model\AttributeRepository->getList('catalog_product', Object(Magento\Framework\Api\SearchCriteria))
#10 /home/vagrant/magento2/var/generation/Magento/Catalog/Model/Product/Attribute/Repository/Interceptor.php(37): Magento\Catalog\Model\Product\Attribute\Repository->getList(Object(Magento\Framework\Api\SearchCriteria))
#11 /home/vagrant/magento2/vendor/magento/module-catalog/Ui/Component/Listing/Attribute/AbstractRepository.php(42): Magento\Catalog\Model\Product\Attribute\Repository\Interceptor->getList(Object(Magento\Framework\Api\SearchCriteria))
#12 /home/vagrant/magento2/vendor/magento/module-catalog/Ui/Component/Listing/Columns.php(54): Magento\Catalog\Ui\Component\Listing\Attribute\AbstractRepository->getList()
#13 /home/vagrant/magento2/vendor/magento/framework/View/Layout/Generator/UiComponent.php(148): Magento\Catalog\Ui\Component\Listing\Columns->prepare()
#14 /home/vagrant/magento2/vendor/magento/framework/View/Layout/Generator/UiComponent.php(145): Magento\Framework\View\Layout\Generator\UiComponent->prepareComponent(Object(Magento\Catalog\Ui\Component\Listing\Columns))
#15 /home/vagrant/magento2/vendor/magento/framework/View/Layout/Generator/UiComponent.php(126): Magento\Framework\View\Layout\Generator\UiComponent->prepareComponent(Object(Magento\Ui\Component\Listing))
#16 /home/vagrant/magento2/vendor/magento/framework/View/Layout/Generator/UiComponent.php(93): Magento\Framework\View\Layout\Generator\UiComponent->generateComponent(Object(Magento\Framework\View\Layout\Data\Structure), 'product_listing', Array, Object(Magento\Framework\View\Layout\Interceptor))
#17 /home/vagrant/magento2/vendor/magento/framework/View/Layout/GeneratorPool.php(86): Magento\Framework\View\Layout\Generator\UiComponent->process(Object(Magento\Framework\View\Layout\Reader\Context), Object(Magento\Framework\View\Layout\Generator\Context))
#18 /home/vagrant/magento2/vendor/magento/framework/View/Layout.php(327): Magento\Framework\View\Layout\GeneratorPool->process(Object(Magento\Framework\View\Layout\Reader\Context), Object(Magento\Framework\View\Layout\Generator\Context))
#19 /home/vagrant/magento2/var/generation/Magento/Framework/View/Layout/Interceptor.php(89): Magento\Framework\View\Layout->generateElements()
#20 /home/vagrant/magento2/vendor/magento/framework/View/Layout/Builder.php(129): Magento\Framework\View\Layout\Interceptor->generateElements()
#21 /home/vagrant/magento2/vendor/magento/framework/View/Page/Builder.php(55): Magento\Framework\View\Layout\Builder->generateLayoutBlocks()
#22 /home/vagrant/magento2/vendor/magento/framework/View/Layout/Builder.php(65): Magento\Framework\View\Page\Builder->generateLayoutBlocks()
#23 /home/vagrant/magento2/vendor/magento/framework/View/Layout.php(244): Magento\Framework\View\Layout\Builder->build()
#24 /home/vagrant/magento2/vendor/magento/framework/View/Layout.php(859): Magento\Framework\View\Layout->build()
#25 /home/vagrant/magento2/var/generation/Magento/Framework/View/Layout/Interceptor.php(414): Magento\Framework\View\Layout->getBlock('menu')
#26 /home/vagrant/magento2/vendor/magento/module-backend/Model/View/Result/Page.php(59): Magento\Framework\View\Layout\Interceptor->getBlock('menu')
#27 /home/vagrant/magento2/var/generation/Magento/Backend/Model/View/Result/Page/Interceptor.php(24): Magento\Backend\Model\View\Result\Page->setActiveMenu('Magento_Catalog...')
#28 /home/vagrant/magento2/vendor/magento/module-catalog/Controller/Adminhtml/Product/Index.php(39): Magento\Backend\Model\View\Result\Page\Interceptor->setActiveMenu('Magento_Catalog...')
#29 /home/vagrant/magento2/var/generation/Magento/Catalog/Controller/Adminhtml/Product/Index/Interceptor.php(24): Magento\Catalog\Controller\Adminhtml\Product\Index->execute()
#30 /home/vagrant/magento2/vendor/magento/framework/App/Action/Action.php(102): Magento\Catalog\Controller\Adminhtml\Product\Index\Interceptor->execute()
#31 /home/vagrant/magento2/vendor/magento/module-backend/App/AbstractAction.php(226): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
#32 [internal function]: Magento\Backend\App\AbstractAction->dispatch(Object(Magento\Framework\App\Request\Http))
#33 /home/vagrant/magento2/vendor/magento/framework/Interception/Interceptor.php(74): call_user_func_array(Array, Array)
#34 /home/vagrant/magento2/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Catalog\Controller\Adminhtml\Product\Index\Interceptor->___callParent('dispatch', Array)
#35 /home/vagrant/magento2/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Catalog...', 'dispatch', Object(Magento\Catalog\Controller\Adminhtml\Product\Index\Interceptor), Array, 'adminAuthentica...')
#36 /home/vagrant/magento2/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#37 [internal function]: Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(Object(Magento\Catalog\Controller\Adminhtml\Product\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#38 /home/vagrant/magento2/vendor/magento/framework/Interception/Chain/Chain.php(67): call_user_func_array(Array, Array)
#39 /home/vagrant/magento2/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Catalog...', 'dispatch', Object(Magento\Catalog\Controller\Adminhtml\Product\Index\Interceptor), Array, 'designLoader')
#40 /home/vagrant/magento2/vendor/magento/framework/App/Action/Plugin/Design.php(39): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#41 [internal function]: Magento\Framework\App\Action\Plugin\Design->aroundDispatch(Object(Magento\Catalog\Controller\Adminhtml\Product\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#42 /home/vagrant/magento2/vendor/magento/framework/Interception/Chain/Chain.php(67): call_user_func_array(Array, Array)
#43 /home/vagrant/magento2/vendor/magento/framework/Interception/Interceptor.php(136): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Catalog...', 'dispatch', Object(Magento\Catalog\Controller\Adminhtml\Product\Index\Interceptor), Array, 'adminMassaction...')
#44 /home/vagrant/magento2/vendor/magento/module-backend/App/Action/Plugin/MassactionKey.php(33): Magento\Catalog\Controller\Adminhtml\Product\Index\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#45 [internal function]: Magento\Backend\App\Action\Plugin\MassactionKey->aroundDispatch(Object(Magento\Catalog\Controller\Adminhtml\Product\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#46 /home/vagrant/magento2/vendor/magento/framework/Interception/Interceptor.php(140): call_user_func_array(Array, Array)
#47 /home/vagrant/magento2/var/generation/Magento/Catalog/Controller/Adminhtml/Product/Index/Interceptor.php(39): Magento\Catalog\Controller\Adminhtml\Product\Index\Interceptor->___callPlugins('dispatch', Array, Array)
#48 /home/vagrant/magento2/vendor/magento/framework/App/FrontController.php(55): Magento\Catalog\Controller\Adminhtml\Product\Index\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#49 [internal function]: Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#50 /home/vagrant/magento2/vendor/magento/framework/Interception/Interceptor.php(74): call_user_func_array(Array, Array)
#51 /home/vagrant/magento2/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#52 /home/vagrant/magento2/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'install')
#53 /home/vagrant/magento2/vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#54 [internal function]: Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#55 /home/vagrant/magento2/vendor/magento/framework/Interception/Chain/Chain.php(67): call_user_func_array(Array, Array)
#56 /home/vagrant/magento2/vendor/magento/framework/Interception/Interceptor.php(136): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'storeCookieVali...')
#57 /home/vagrant/magento2/vendor/magento/module-store/Model/Plugin/StoreCookie.php(78): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#58 [internal function]: Magento\Store\Model\Plugin\StoreCookie->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#59 /home/vagrant/magento2/vendor/magento/framework/Interception/Interceptor.php(140): call_user_func_array(Array, Array)
#60 /home/vagrant/magento2/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#61 /home/vagrant/magento2/vendor/magento/framework/App/Http.php(115): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#62 /home/vagrant/magento2/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#63 /home/vagrant/magento2/pub/index.php(37): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#64 {main}
rakeshpatel27 commented 8 years ago

I have same error arrive after migrates data magento 1.9.2.1 to magento 2.0.0 version. Admin Product page open with above same error.

chrissm79 commented 8 years ago

Just adding some additional information that can hopefully help.

When I attempt to reindex from the command line I got the following error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'catalog_product_entity.store_id' in 'field list', query was: SELECT `catalog_product_entity`.`entity_id`, `catalog_product_entity`.`store_id`, `catalog_product_entity`.`value` FROM `catalog_product_entity` WHERE (attribute_id = 98) 

I added the column, and got the same error with the 'value' column so I deleted all of the Catalog and Cart Price Rules and it is now able to complete the reindex. However, the issue above is still occurring.

When attempting to utilize the REST API, I get the same error is OP when I attempt to get details on a category, product, or product attributes.

chrissm79 commented 8 years ago

Attempted to follow the same steps with v1.8.1.0 but got the same error.

Steps taken for migrating from v1.7.0.2, v1.8.1.0, & v1.9.2.2: Used data migration tool

andidhouse commented 8 years ago

We have the same error migrating from 1.7.0.2 to 2.0 migration steps finished without error.

Did you find a solution for this?

ghost commented 8 years ago

this error can be replicated on a fresh install "magento-1.9.2.3-2016-01-20-03-04-11" , totally out of the box with no mods or 3rd party additions. steps taken to reproduce,

My best guess at this point is the install script(s)/upgrade script(s) do not add/alter tables to include the required fields, a pretty big oversight.

Category Products index process unknown error:
exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name ''' in /mypath/public_html/lib/Zend/Db/Statement/Pdo.php:228
Stack trace:
#0 /mypath/public_html/lib/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array)
#1 /mypath/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#2 /mypath/public_html/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#3 /mypath/public_html/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#4 /mypath/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('DELETE FROM ``', Array)
#5 /mypath/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(504): Zend_Db_Adapter_Pdo_Abstract->query('DELETE FROM ``', Array)
#6 /mypath/public_html/lib/Zend/Db/Adapter/Abstract.php(664): Varien_Db_Adapter_Pdo_Mysql->query('DELETE FROM ``')
#7 /mypath/public_html/app/code/core/Mage/Catalog/Model/Resource/Category/Indexer/Product.php(941): Zend_Db_Adapter_Abstract->delete(NULL)
#8 /mypath/public_html/app/code/core/Mage/Index/Model/Indexer/Abstract.php(143): Mage_Catalog_Model_Resource_Category_Indexer_Product->reindexAll()
#9 /mypath/public_html/app/code/core/Mage/Index/Model/Process.php(212): Mage_Index_Model_Indexer_Abstract->reindexAll()
#10 /mypath/public_html/app/code/core/Mage/Index/Model/Process.php(260): Mage_Index_Model_Process->reindexAll()
#11 /mypath/public_html/shell/indexer.php(168): Mage_Index_Model_Process->reindexEverything()
#12 /mypath/public_html/shell/indexer.php(216): Mage_Shell_Compiler->run()
#13 {main}

Next exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name '', query was: DELETE FROM ``' in /mypath/public_html/lib/Zend/Db/Statement/Pdo.php:235
Stack trace:
#0 /mypath/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /mypath/public_html/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /mypath/public_html/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#3 /mypath/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('DELETE FROM ``', Array)
#4 /mypath/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(504): Zend_Db_Adapter_Pdo_Abstract->query('DELETE FROM ``', Array)
#5 /mypath/public_html/lib/Zend/Db/Adapter/Abstract.php(664): Varien_Db_Adapter_Pdo_Mysql->query('DELETE FROM ``')
#6 /mypath/public_html/app/code/core/Mage/Catalog/Model/Resource/Category/Indexer/Product.php(941): Zend_Db_Adapter_Abstract->delete(NULL)
#7 /mypath/public_html/app/code/core/Mage/Index/Model/Indexer/Abstract.php(143): Mage_Catalog_Model_Resource_Category_Indexer_Product->reindexAll()
#8 /mypath/public_html/app/code/core/Mage/Index/Model/Process.php(212): Mage_Index_Model_Indexer_Abstract->reindexAll()
#9 /mypath/public_html/app/code/core/Mage/Index/Model/Process.php(260): Mage_Index_Model_Process->reindexAll()
#10 /mypath/public_html/shell/indexer.php(168): Mage_Index_Model_Process->reindexEverything()
#11 /mypath/public_html/shell/indexer.php(216): Mage_Shell_Compiler->run()
#12 {main}
victor-v-rad commented 8 years ago

Hi @chrissm79

I have just migrated 1.7.0.2 (without any extensions) to Magento 2.0.2 and everything is ok Product/order/customer grids shows its data in Admin Panel of Magento 2. I assume you have some extensions that changed your DB in Magento 1 in the way that migration did not pass correctly. There are more causes could be. For example:

  1. You may used develop branch of Magento 2 which is not stable. Make sure your version of Data Migration Tool is the same as version Magento 2
  2. You may had created some Products/Customers/Orders etc. in Magento 2 before migration. Your Magento 2 DB should be in state as right after its installation

@chrissm79 @rakeshjesadiya I can provide meaningful help only if I have exactly the environment you have. The code and DB. Please get in touch with me if you still have the issue "SQL 1103 Incorrect table name ''"

toonvd commented 8 years ago

I have the same problem, my database was delivered to Gordon Knoppe.

victor-v-rad commented 8 years ago

@toonvd would great if you privately share the DB of Magento 1 with me and I run the migration and see the issue you faced. But before you must clean your DB from passwords (e.g. empty core_config_data, admin_user tables).

victor-v-rad commented 8 years ago

@chrissm79 @rakeshjesadiya @toonvd Regarding "SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name ''" which occurs in Admin > Products > Catalog after migration. I believe hotfix is to check and fix the field additional_attribute_table of eav_entity_type table in Magento 2 DB

  1. For the record where eav_entity_type.entity_type_code with value 'customer' the field additional_attribute_table should contain 'customer_eav_attribute'
  2. For the record where eav_entity_type.entity_type_code with value 'customer_address' the field additional_attribute_table should contain 'customer_eav_attribute'
  3. For the record where eav_entity_type.entity_type_code with value 'catalog_category' the field additional_attribute_table should contain 'catalog_eav_attribute'
  4. For the record where eav_entity_type.entity_type_code with value 'customer_address' the field additional_attribute_table should contain 'catalog_eav_attribute'

See the screenshot

eav_entity_type

toonvd commented 8 years ago

Hi, I will check this tonight, thanks!

victor-v-rad commented 8 years ago

Here is the fix to try out

toonvd commented 8 years ago

@victor-v-rad looks fine here! thx! @chrissm79 ok for you too? cc @andidhouse @from-scotland

andidhouse commented 8 years ago

yes! i can confirm that this fix is fixing the product admin grid.

however it does not fix our problem that we can't access the products in the admin panel - but this is another topic.

vzabaznov commented 8 years ago

Hi @chrissm79 fix was delivered, thank you for contributing

baltechies commented 8 years ago

@victor-v-rad I am still facing this issue. Hot fix is not working. Magento version is 2.0.7 and I have migrated data from magento 1.9.2.2 using data migration tool version 2.0.7

a:4:{i:0;s:568:"SQLSTATE[42000]: Syntax error or access violation: 1103 Incorrect table name '', query was: SELECT COUNT(DISTINCT main_table.attribute_id) FROM eav_attribute AS main_table INNER JOIN eav_entity_type AS entity_type ON main_table.entity_type_id = entity_type.entity_type_id INNER JOIN eav_entity_attribute ON main_table.attribute_id = eav_entity_attribute.attribute_id INNER JOIN `ASadditional_tableON main_table.attribute_id = additional_table.attribute_id WHERE (entity_type_code= 'catalog_product') AND (additional_table.is_used_in_grid` = 1)"

baltechies commented 8 years ago

Working after reindex and clean cache.