Hello,
The code
// Alter value field length in fields table
db_query("ALTER TABLE `{$field_table}` CHANGE `{$field_column}` `{$field_column}` VARCHAR( {$new_length} )");
// Alter value field length in fields revision table
db_query("ALTER TABLE `{$field_revision_table}` CHANGE `{$field_column}` `{$field_column}` VARCHAR( {$new_length} )");
Does not use the databse abstraction layer : it will succeed for mysql but fail with other (postgre...).
You should use db_change_field() instead.
https://api.drupal.org/api/drupal/core%21includes%21database.inc/function/db_change_field/8.2.x