correctly emulate Show Variables command in postgres by using the pg_settings table
This commit is contained in:
@ -5,12 +5,12 @@ class ShowVariablesSQLRewriter extends AbstractSQLRewriter
|
||||
public function rewrite(): string
|
||||
{
|
||||
$sql = $this->original();
|
||||
$table = $this->extractVariableName($sql);
|
||||
$variableName = $this->extractVariableName($sql);
|
||||
return $this->generatePostgres($sql, $variableName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts table name from a "SHOW FULL COLUMNS" SQL statement.
|
||||
* Extracts Variable name from a "SHOW VARIABLES LIKE " SQL statement.
|
||||
*
|
||||
* @param string $sql The SQL statement
|
||||
* @return string|null The table name if found, or null otherwise
|
||||
@ -37,7 +37,11 @@ class ShowVariablesSQLRewriter extends AbstractSQLRewriter
|
||||
return "SELECT '$variableName' AS \"Variable_name\", '' AS \"Value\";";
|
||||
}
|
||||
|
||||
// return untransformed sql
|
||||
return $sql;
|
||||
if ($variableName == "max_allowed_packet") {
|
||||
// Act like 1GB packet size, in practice this limit doesn't actually exist for postgres, we just want to fool WP
|
||||
return "SELECT '$variableName' AS \"Variable_name\", '1073741824' AS \"Value\";";
|
||||
}
|
||||
|
||||
return "SELECT name as \"Variable_name\", setting as \"Value\" FROM pg_settings WHERE name = '$variableName';";
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user