Skip to content

Loading…

DBAL-24: Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S02]: Base table or view not found: 1109 Unknown table #1415

Closed
doctrinebot opened this Issue · 11 comments

2 participants

@doctrinebot

Jira issue originally created by user hinikato:

The /Doctrine/DBAL/Platforms/MySqlPlatform->getListTableForeignKeysSQL() method returns SQL, that causes the following error:

exception 'PDOException' with message 'SQLSTATE[42S02]: Base table or view not found: 1109 Unknown table 'variables' in information_schema' in X:\home\localhost\www\incubator\doctrine2\libraries\Doctrine\DBAL\Connection.php:568
Stack trace:
#0 X:\home\localhost\www\incubator\doctrine2\libraries\Doctrine\DBAL\Connection.php(568): PDO->query('SELECT DISTINCT...')
#1 X:\home\localhost\www\incubator\doctrine2\libraries\Doctrine\DBAL\Connection.php(524): Doctrine\DBAL\Connection->executeQuery('SELECT DISTINCT...', Array)
#2 X:\home\localhost\www\incubator\doctrine2\libraries\Doctrine\DBAL\Schema\AbstractSchemaManager.php(254): Doctrine\DBAL\Connection->fetchAll('SELECT DISTINCT...')
#3 X:\home\localhost\www\incubator\doctrine2\libraries\Doctrine\DBAL\Schema\AbstractSchemaManager.php(214): Doctrine\DBAL\Schema\AbstractSchemaManager->listTableForeignKeys('variables')
#4 X:\home\localhost\www\incubator\doctrine2\libraries\Doctrine\DBAL\Schema\AbstractSchemaManager.php(199): Doctrine\DBAL\Schema\AbstractSchemaManager->listTableDetails('variables')
#5 X:\home\localhost\www\incubator\doctrine2\libraries\Doctrine\ORM\Mapping\Driver\DatabaseDriver.php(155): Doctrine\DBAL\Schema\AbstractSchemaManager->listTables()
#6 X:\home\localhost\www\incubator\doctrine2\libraries\Doctrine\ORM\Mapping\ClassMetadataFactory.php(103): Doctrine\ORM\Mapping\Driver\DatabaseDriver->getAllClassNames()
#7 X:\home\localhost\www\incubator\doctrine2\index.php(53): Doctrine\ORM\Mapping\ClassMetadataFactory->getAllMetadata()
#8 {main}

The sessions table looks like:

CREATE TABLE `sessions` (
  `id` char(32) NOT NULL DEFAULT '',
  `modified` int(11) DEFAULT NULL,
  `lifetime` int(11) DEFAULT NULL,
  `data` text,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
@doctrinebot

Comment created by @beberlei:

Can you use the sql logger to find out how exactly that failing SQL statement looks like?

$em->getConfiguration()->setSQLLogger(new \Doctrine\DBAL\Logger\EchoSQLLogger());
@doctrinebot

Comment created by hinikato:

Yes.

SELECT DISTINCT k.`CONSTRAINT*NAME`, k.`COLUMN_NAME`, k.`REFERENCED_TABLE_NAME`, k.`REFERENCED_COLUMN_NAME` /*!50116 , c.update_rule, c.delete_rule */ FROM information_schema.key_column_usage k /*!50116 INNER JOIN information_schema.referential_constraints c ON k.`CONSTRAINT_NAME` = c.constraint_name AND   c.constraint_name = k.constraint_name AND   c.table_name = 'sessions' */ WHERE k.table_name = 'sessions' AND table_schema = 'myak' AND `REFERENCED_COLUMN*NAME` is not NULL
@doctrinebot

Comment created by hinikato:

Sorry, I have replaced the table name, but bug occurs with the 'sessions' table too.

@doctrinebot

Comment created by hinikato:

Hmm., but exception text says that table name is variables, so this table looks like:

CREATE TABLE `variables` (
  `name` varchar(128) NOT NULL DEFAULT '',
  `value` longtext NOT NULL,
  PRIMARY KEY (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@doctrinebot

Comment created by @beberlei:

But if the exception still references variables then the query from your comment cannot be the one that is failing.

@doctrinebot

Comment created by hinikato:

Do you want that bug will be ignored and Doctrine will be worse product?

SHOW FULL TABLES WHERE Table_type = "BASE TABLE"
DESCRIBE sessions
SELECT DISTINCT k.`CONSTRAINT*NAME`, k.`COLUMN_NAME`, k.`REFERENCED_TABLE_NAME`, k.`REFERENCED_COLUMN_NAME` /*!50116 , c.update_rule, c.delete_rule */ FROM information_schema.key_column_usage k /*!50116 INNER JOIN information_schema.referential_constraints c ON k.`CONSTRAINT_NAME` = c.constraint_name AND   c.constraint_name = k.constraint_name AND   c.table_name = 'sessions' */ WHERE k.table_name = 'sessions' AND table_schema = 'myak' AND `REFERENCED_COLUMN*NAME` is not NULL
SHOW INDEX FROM sessions
DESCRIBE system
SELECT DISTINCT k.`CONSTRAINT*NAME`, k.`COLUMN_NAME`, k.`REFERENCED_TABLE_NAME`, k.`REFERENCED_COLUMN_NAME` /*!50116 , c.update_rule, c.delete_rule */ FROM information_schema.key_column_usage k /*!50116 INNER JOIN information_schema.referential_constraints c ON k.`CONSTRAINT_NAME` = c.constraint_name AND   c.constraint_name = k.constraint_name AND   c.table_name = 'system' */ WHERE k.table_name = 'system' AND table_schema = 'myak' AND `REFERENCED_COLUMN*NAME` is not NULL
SHOW INDEX FROM system
DESCRIBE variables
SELECT DISTINCT k.`CONSTRAINT*NAME`, k.`COLUMN_NAME`, k.`REFERENCED_TABLE_NAME`, k.`REFERENCED_COLUMN_NAME` /*!50116 , c.update_rule, c.delete_rule */ FROM information_schema.key_column_usage k /*!50116 INNER JOIN information_schema.referential_constraints c ON k.`CONSTRAINT_NAME` = c.constraint_name AND   c.constraint_name = k.constraint_name AND   c.table_name = 'variables' */ WHERE k.table_name = 'variables' AND table_schema = 'myak' AND `REFERENCED_COLUMN*NAME` is not NULL

exception 'PDOException' with message 'SQLSTATE[42S02]: Base table or view not found: 1109 Unknown table 'variables' in information_schema' in X:\home\localhost\www\incubator\doctrine2\libraries\Doctrine\DBAL\Connection.php:568
Stack trace:
#0 X:\home\localhost\www\incubator\doctrine2\libraries\Doctrine\DBAL\Connection.php(568): PDO->query('SELECT DISTINCT...')
#1 X:\home\localhost\www\incubator\doctrine2\libraries\Doctrine\DBAL\Connection.php(524): Doctrine\DBAL\Connection->executeQuery('SELECT DISTINCT...', Array)
#2 X:\home\localhost\www\incubator\doctrine2\libraries\Doctrine\DBAL\Schema\AbstractSchemaManager.php(254): Doctrine\DBAL\Connection->fetchAll('SELECT DISTINCT...')
#3 X:\home\localhost\www\incubator\doctrine2\libraries\Doctrine\DBAL\Schema\AbstractSchemaManager.php(214): Doctrine\DBAL\Schema\AbstractSchemaManager->listTableForeignKeys('variables')
#4 X:\home\localhost\www\incubator\doctrine2\libraries\Doctrine\DBAL\Schema\AbstractSchemaManager.php(199): Doctrine\DBAL\Schema\AbstractSchemaManager->listTableDetails('variables')
#5 X:\home\localhost\www\incubator\doctrine2\libraries\Doctrine\ORM\Mapping\Driver\DatabaseDriver.php(155): Doctrine\DBAL\Schema\AbstractSchemaManager->listTables()
#6 X:\home\localhost\www\incubator\doctrine2\libraries\Doctrine\ORM\Mapping\ClassMetadataFactory.php(101): Doctrine\ORM\Mapping\Driver\DatabaseDriver->getAllClassNames()
#7 X:\home\localhost\www\incubator\doctrine2\index.php(57): Doctrine\ORM\Mapping\ClassMetadataFactory->getAllMetadata()
#8 {main}
@doctrinebot

Comment created by @beberlei:

Does it seem like me is ignoring this bug? Its not that I am payed to work on Doctrine and have no day-job.

This looks like a very good re-produce case though, i am looking into it (when i have time ;-))

@doctrinebot

Comment created by hinikato:

Benjamin, thank you!

@doctrinebot

Comment created by @beberlei:

I cannot reproduce this sorry, can you try again? i have changed that method for several other bugs lately, maybe it is fixed now?

@doctrinebot

Comment created by @beberlei:

Closed, no additional feedback given.

@doctrinebot

Issue was closed with resolution "Cannot Reproduce"

@doctrinebot doctrinebot added the Bug label
@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.