[3.0] Writes a column type MySQL knows in the SQL that rebuilds a table - #9653
Open
albertlast wants to merge 1 commit into
Open
[3.0] Writes a column type MySQL knows in the SQL that rebuilds a table#9653albertlast wants to merge 1 commit into
albertlast wants to merge 1 commit into
Conversation
list_columns() reports SMF's own name for a type the database spells differently: a varbinary(16) holding an address comes back as an inet. table_sql() wrote that name straight into its CREATE TABLE, so MySQL was asked for a column of a type it does not have. ERROR 1064 (42000): ... near 'inet DEFAULT NULL' Ten tables on a stock forum carry such a column, all of them the ones that record an address. Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
On MySQL,
table_sql()returns SQL naming a column type MySQL does not have:ERROR 1064 (42000): You have an error in your SQL syntax; ... near 'inet DEFAULT NULL'SMF has its own names for a couple of types, and
list_columns()reports those rather than the ones the database uses: avarbinary(16)holding an address comes back as aninet, and abinary(16)holding an id comes back as auuid. Everywhere else that writes DDL turns them back first, withcalculate_type().table_sql()did not, and wrote SMF's name into itsCREATE TABLE:Ten tables on a forum with nothing added to it carry such a column, and they are the ones that record an address:
ban_items,log_actions,log_banned,log_errors,log_floodcontrol,log_online,log_reported_comments,member_logins,membersandmessages.Nothing in SMF calls
table_sql(), which is why this has gone unnoticed. It is public API, reachable through thedb_table_sqlalias inDatabaseApi::$db_function_map.PostgreSQL is unaffected:
inetis a type it has.How this was verified
By taking the definition of every table on a MySQL forum upgraded from the 2.1.7 baseline and running each into an empty database, which is the only thing the output is for.
The two faults are independent and were counted separately: with only #9652 applied the ten type failures remain, and with only this one the five index failures do. Both were applied together for the 72 of 72.
The rebuilt database was then compared against the original: 72 tables and 539 columns on each side.
Not reachable from the unit suite
table_sql()is a database driver method and needs a connection.Issues References (Fixes|Related|Closes)