Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for information_schema tables #146

Open
JanJakes opened this issue Aug 7, 2024 · 0 comments
Open

Support for information_schema tables #146

JanJakes opened this issue Aug 7, 2024 · 0 comments

Comments

@JanJakes
Copy link
Collaborator

JanJakes commented Aug 7, 2024

Queries to information_schema appear to succeed without errors, but they may not be returning correct results. I found out that there seems to be some rewriting done, but my guess is it may only be handling a few cases.

Checking for whether a table, column, or an index exist seems to return wrong result.

Here are the failing test cases:

public function testTableExists() {
	$this->assertQuery( 'CREATE TABLE test (id INT)' );
	$return = $this->assertQuery( "SELECT 1 FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'test'" );
	$this->assertEquals( [(object) ["1" => "1"]], $return );
}

public function testColumnExists() {
	$this->assertQuery( 'CREATE TABLE test (id INT)' );
	$return = $this->assertQuery( "SELECT 1 FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'test' AND column_name = 'id'" );
	$this->assertEquals( [(object) ["1" => "1"]], $return );
}

public function testIndexExists() {
	$this->assertQuery( 'CREATE TABLE test (id INT)' );
	$this->assertQuery( 'ALTER TABLE test ADD INDEX test_id_idx (id)' );
	$return = $this->assertQuery( "SELECT 1 FROM information_schema.statistics WHERE table_schema = DATABASE() AND table_name = 'test' AND index_name = 'test_id_idx'" );
	$this->assertEquals( [(object) ["1" => "1"]], $return );
}

What is the status of information_schema support? Is it technically possible to rewrite all kinds of information schema queries, or would an easier approach be to create and manage the tables?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant