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

PHP 8.0 testcase failure #23

Closed
ashnazg opened this issue Nov 27, 2023 · 3 comments
Closed

PHP 8.0 testcase failure #23

ashnazg opened this issue Nov 27, 2023 · 3 comments
Assignees

Comments

@ashnazg
Copy link
Member

ashnazg commented Nov 27, 2023

Testcase tests/driver/16tableinfo.phpt encounters a failure when run on PHP 8.0, as seen below. The behavior differences appear to be in how the queried table characteristics are interpreted by DB. The paste below is the runtime output of the testcase... you can visually compare it to the --EXPECT-- section in the PHPT to see what's different.

As best I can tell, some flags are interpreted differently on 8.0 as compared to PHP7 and PHP5, e.g.
flags ... was 'not_null multiple_key group_by' but we expected 'not_null multiple_key'

while also some column characteristics show up differently, e.g.
type ... was 'varchar' but we expected 'string'

I thought at first that maybe the PHP 8.0 behavior should be different based on that test platform's database version (newer?) as compared to the PHP7 and PHP5 platforms, but I don't know that for sure.

@schengawegga , if you are able to research this testcase, see how it acts on your various PHP8 platforms. If you become convinced that the runtime behavior as seen below is correct, then I can adjust this testcase to only run itself against PHP7 and older... and create a sister testcase just for PHP8 and up, that is written to --EXPECT-- these flag and type differences.

RUNTIME OUTPUT FROM THE BUILD:

tests/driver/16tableinfo.out

==========================================

Passing result OBJECT to method in DB_<type>.

Output = default.

------------------------------------------

column 0:

DIDN'T match expected values...

~~~~~~~~

Expected:

table ... matched expected value

name => a

type ... matched expected value

len ... matched expected value

flags ... matched expected value

~~~~

Actual:

table ... matched expected value

name => a

type ... matched expected value

len ... matched expected value

flags ... was 'not_null multiple_key group_by' but we expected 'not_null multiple_key'

~~~~~~~~

column 9:

DIDN'T match expected values...

~~~~~~~~

Expected:

table ... matched expected value

name => d

type ... matched expected value

len ... matched expected value

flags ... matched expected value

~~~~

Actual:

table ... matched expected value

name => d

type ... was 'varchar' but we expected 'string'

len ... matched expected value

flags ... matched expected value

~~~~~~~~

==========================================

Passing result ID to method in DB_<type>.

Output = DB_TABLEINFO_ORDER.

------------------------------------------

column 0:

DIDN'T match expected values...

~~~~~~~~

Expected:

table ... matched expected value

name => a

type ... matched expected value

len ... matched expected value

flags ... matched expected value

~~~~

Actual:

table ... matched expected value

name => a

type ... matched expected value

len ... matched expected value

flags ... was 'not_null multiple_key group_by' but we expected 'not_null multiple_key'

~~~~~~~~

column 3:

DIDN'T match expected values...

~~~~~~~~

Expected:

table ... matched expected value

name => d

type ... matched expected value

len ... matched expected value

flags ... matched expected value

~~~~

Actual:

table ... matched expected value

name => d

type ... matched expected value

len ... matched expected value

flags ... was 'not_null multiple_key' but we expected 'not_null multiple_key binary'

~~~~~~~~

num_fields: matched expected result

order:

matched expected result

==========================================

Passing DB_TABLEINFO_ORDERTABLE to method in DB_result.

Output = DB_TABLEINFO_ORDERTABLE.

------------------------------------------

column 0:

DIDN'T match expected values...

~~~~~~~~

Expected:

table ... matched expected value

name => a

type ... matched expected value

len ... matched expected value

flags ... matched expected value

~~~~

Actual:

table ... matched expected value

name => a

type ... matched expected value

len ... matched expected value

flags ... was 'not_null multiple_key group_by' but we expected 'not_null multiple_key'

~~~~~~~~

column 3:

DIDN'T match expected values...

~~~~~~~~

Expected:

table ... matched expected value

name => d

type ... matched expected value

len ... matched expected value

flags ... matched expected value

~~~~

Actual:

table ... matched expected value

name => d

type ... matched expected value

len ... matched expected value

flags ... was 'not_null multiple_key' but we expected 'not_null multiple_key binary'

~~~~~~~~

num_fields: matched expected result

ordertable[phptest]: matched expected result

ordertable[phptest_fk]: matched expected result

==========================================

Passing TABLE NAME 'phptest_fk' to method in DB_<driver>.

Output = default.

------------------------------------------

column 0:

DIDN'T match expected values...

~~~~~~~~

Expected:

table ... matched expected value

name => a

type ... matched expected value

len ... matched expected value

flags ... matched expected value

~~~~

Actual:

table ... matched expected value

name => a

type ... matched expected value

len ... matched expected value

flags ... was 'not_null multiple_key group_by' but we expected 'not_null multiple_key'

~~~~~~~~

column 1:

DIDN'T match expected values...

~~~~~~~~

Expected:

table ... matched expected value

name => fk

type ... matched expected value

len ... matched expected value

flags ... matched expected value

~~~~

Actual:

table ... matched expected value

name => fk

type ... matched expected value

len ... matched expected value

flags ... was 'not_null primary_key group_by' but we expected 'not_null primary_key'

~~~~~~~~

column 2:

matched expected result

column 3:

DIDN'T match expected values...

~~~~~~~~

Expected:

table ... matched expected value

name => d

type ... matched expected value

len ... matched expected value

flags ... matched expected value

~~~~

Actual:

table ... matched expected value

name => d

type ... matched expected value

len ... matched expected value

flags ... was 'not_null multiple_key' but we expected 'not_null multiple_key binary'

~~~~~~~~

column 4:

DIDN'T match expected values...

~~~~~~~~

Expected:

table ... matched expected value

name => e

type ... matched expected value

len ... matched expected value

flags ... matched expected value

~~~~

Actual:

table ... matched expected value

name => e

type ... was 'char' but we expected 'string'

len ... matched expected value

flags ... matched expected value

~~~~~~~~

column 5:

DIDN'T match expected values...

~~~~~~~~

Expected:

table ... matched expected value

name => f

type ... matched expected value

len ... matched expected value

flags ... matched expected value

~~~~

Actual:

table ... matched expected value

name => f

type ... was 'decimal' but we expected 'real'

len ... matched expected value

flags ... matched expected value

~~~~~~~~

==========================================

Passing TABLE NAME 'phptest_fk' to method in DB_<driver>.

Output = DB_TABLEINFO_FULL.

------------------------------------------

column 0:

DIDN'T match expected values...

~~~~~~~~

Expected:

table ... matched expected value

name => a

type ... matched expected value

len ... matched expected value

flags ... matched expected value

~~~~

Actual:

table ... matched expected value

name => a

type ... matched expected value

len ... matched expected value

flags ... was 'not_null multiple_key group_by' but we expected 'not_null multiple_key'

~~~~~~~~

order:

matched expected result

ordertable[phptest_fk]:

matched expected result

==========================================

Passing TABLE NAME 'phptest_fk' to method in DB_<driver> AGAIN.

Output = DB_TABLEINFO_FULL, lowercasing turned off.

------------------------------------------

column 0:

DIDN'T match expected values...

~~~~~~~~

Expected:

table ... matched expected value

name => a

type ... matched expected value

len ... matched expected value

flags ... matched expected value

~~~~

Actual:

table ... matched expected value

name => a

type ... matched expected value

len ... matched expected value

flags ... was 'not_null multiple_key group_by' but we expected 'not_null multiple_key'
@schengawegga
Copy link
Collaborator

@ashnazg i think found the problem.

i´ve done an var_dump($dbh->tableInfo('phptest_fk')); in PHP 7.4.29 and PHP 8.1.12, and the output is exactly the same.

It is a bug in the tests since it is written.

In examineArrayData is a comparison if ($value == 0 && !$quirks[$quirk_key]['size_from_table']).

if ($value == 0

The problem is, that $value == 0 is always true in PHP7 if $value is a string.
So this test will always pass, if $value is a string, no matter what is written in $value.

This has changed in PHP8 https://www.php.net/releases/8.0/en.php#saner-string-to-number-comparisons
In PHP8 $value == 0 is false if $value is a string.

So i think, this test was always not showing the correct result before PHP8, because it always passes if $value was a string.

What do you think?

I will do an PR in the next days.
But now, it is to late and i go to sleep a little bit.
I think, we should fix this before the 1.12.0 release.

@schengawegga
Copy link
Collaborator

Created pull request PHP 8.0 testcase failure #24
@ashnazg

@ashnazg
Copy link
Member Author

ashnazg commented Jan 7, 2024

PR looks good to me... ok to close this issue once it merges.

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

2 participants