Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/DatabaseInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,28 @@ public function getConnectionEncryption(): string;
*/
public function isConnectionEncryptionSupported(): bool;

/**
* Method to get the sql_big_selects session variable.
*
* If the connector doesn't support reporting this value please return false.
*
* @return boolean Whether sql_big_selects is enabled or not.
*
* @since __DEPLOY_VERSION__
*/
public function getSqlBigSelects(): bool;

/**
* Method to get the max_join_size session variable.
*
* If the connector doesn't support reporting this value please return an empty string.
*
* @return string max_join_size value.
*
* @since __DEPLOY_VERSION__
*/
public function getMaxJoinSize(): string;

/**
* Method to check whether the installed database version is supported by the database driver
*
Expand Down
46 changes: 46 additions & 0 deletions src/Mysql/MysqlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ public function __construct(array $options)
$options['charset'] = $options['charset'] ?? 'utf8';
$options['sqlModes'] = isset($options['sqlModes']) ? (array) $options['sqlModes'] : $sqlModes;

// Ignore sqlBigSelects if maxJoinSize is explicitly set.
$options['sqlBigSelects'] = isset($options['sqlBigSelects']) && !isset($options['maxJoinSize']) ? (bool) $options['sqlBigSelects'] : null;

// Ignore maxJoinSize if sqlBigSelects is explicitly enabled.
$options['maxJoinSize'] = isset($options['maxJoinSize']) && $options['sqlBigSelects'] !== true ? $options['maxJoinSize'] : null;

$this->charset = $options['charset'];

/*
Expand Down Expand Up @@ -221,6 +227,16 @@ public function connect()
$this->connection->query('SET @@SESSION.sql_mode = \'' . implode(',', $this->options['sqlModes']) . '\';');
}

// Set sql_big_selects if value provided in options
if ($this->options['sqlBigSelects'] !== null) {
$this->connection->query('SET @@SESSION.sql_big_selects = ' . ($this->options['sqlBigSelects'] ? '1' : '0') . ';');
}

// Set max_join_size if value provided in options
if ($this->options['maxJoinSize'] !== null) {
$this->connection->query('SET @@SESSION.max_join_size = ' . $this->options['maxJoinSize'] . ';');
}

$this->setOption(\PDO::ATTR_EMULATE_PREPARES, true);
}

Expand Down Expand Up @@ -369,6 +385,36 @@ public function isConnectionEncryptionSupported(): bool
return !empty($variables['have_ssl']->Value) && $variables['have_ssl']->Value === 'YES';
}

/**
* Method to get the sql_big_selects session variable.
*
* If the connector doesn't support reporting this value please return false.
*
* @return boolean Whether sql_big_selects is enabled or not.
*
* @since __DEPLOY_VERSION__
*/
public function getSqlBigSelects(): bool
{
$this->connect();

return $this->setQuery('SELECT @@sql_big_selects;')->loadResult() == 1;
}

/**
* Method to get the max_join_size session variable.
*
* If the connector doesn't support reporting this value please return an empty string.
*
* @return string max_join_size value.
*
* @since __DEPLOY_VERSION__
*/
public function getMaxJoinSize(): string
{
return $this->setQuery('SELECT @@max_join_size;')->loadResult();
}

/**
* Return the query string to create new Database.
*
Expand Down
45 changes: 45 additions & 0 deletions src/Mysqli/MysqliDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ public function __construct(array $options)
$options['ssl']['verify_server_cert'] = isset($options['ssl']['verify_server_cert']) ? $options['ssl']['verify_server_cert'] : null;
}

// Ignore sqlBigSelects if maxJoinSize is explicitly set.
$options['sqlBigSelects'] = isset($options['sqlBigSelects']) && !isset($options['maxJoinSize']) ? (bool) $options['sqlBigSelects'] : null;

// Ignore maxJoinSize if sqlBigSelects is explicitly enabled.
$options['maxJoinSize'] = isset($options['maxJoinSize']) && $options['sqlBigSelects'] !== true ? $options['maxJoinSize'] : null;

// Finalize initialisation.
parent::__construct($options);
}
Expand Down Expand Up @@ -307,6 +313,15 @@ public function connect()
// And read the real sql mode to mitigate changes in mysql > 5.7.+
$this->options['sqlModes'] = explode(',', $this->setQuery('SELECT @@SESSION.sql_mode;')->loadResult());

// Set sql_big_selects if value provided in options
if ($this->options['sqlBigSelects'] !== null) {
$this->connection->query('SET @@SESSION.sql_big_selects = ' . ($this->options['sqlBigSelects'] ? '1' : '0') . ';');
}

// Set max_join_size if value provided in options
if ($this->options['maxJoinSize'] !== null) {
$this->connection->query('SET @@SESSION.max_join_size = ' . $this->options['maxJoinSize'] . ';');
}
// If auto-select is enabled select the given database.
if ($this->options['select'] && !empty($this->options['database'])) {
$this->select($this->options['database']);
Expand Down Expand Up @@ -514,6 +529,36 @@ public function isConnectionEncryptionSupported(): bool
return !empty($variables['have_ssl']->Value) && $variables['have_ssl']->Value === 'YES';
}

/**
* Method to get the sql_big_selects session variable.
*
* If the connector doesn't support reporting this value please return false.
*
* @return boolean Whether sql_big_selects is enabled or not.
*
* @since __DEPLOY_VERSION__
*/
public function getSqlBigSelects(): bool
{
$this->connect();

return $this->setQuery('SELECT @@sql_big_selects;')->loadResult() == 1;
}

/**
* Method to get the max_join_size session variable.
*
* If the connector doesn't support reporting this value please return an empty string.
*
* @return string max_join_size value.
*
* @since __DEPLOY_VERSION__
*/
public function getMaxJoinSize(): string
{
return $this->setQuery('SELECT @@max_join_size;')->loadResult();
}

/**
* Return the query string to create new Database.
*
Expand Down
28 changes: 28 additions & 0 deletions src/Pgsql/PgsqlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,34 @@ public function isConnectionEncryptionSupported(): bool
return !empty($variables['ssl']) && $variables['ssl'] === 'on';
}

/**
* Method to get the sql_big_selects session variable.
*
* If the connector doesn't support reporting this value please return false.
*
* @return boolean Whether sql_big_selects is enabled or not.
*
* @since __DEPLOY_VERSION__
*/
public function getSqlBigSelects(): bool
{
return false;
}

/**
* Method to get the max_join_size session variable.
*
* If the connector doesn't support reporting this value please return an empty string.
*
* @return string max_join_size value.
*
* @since __DEPLOY_VERSION__
*/
public function getMaxJoinSize(): string
{
return '';
}

/**
* Internal function to get the name of the default schema for the current PostgreSQL connection.
* That is the schema where tables are created by Joomla.
Expand Down
28 changes: 28 additions & 0 deletions src/Sqlite/SqliteDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,34 @@ public function isConnectionEncryptionSupported(): bool
return false;
}

/**
* Method to get the sql_big_selects session variable.
*
* If the connector doesn't support reporting this value please return false.
*
* @return boolean Whether sql_big_selects is enabled or not.
*
* @since __DEPLOY_VERSION__
*/
public function getSqlBigSelects(): bool
{
return false;
}

/**
* Method to get the max_join_size session variable.
*
* If the connector doesn't support reporting this value please return an empty string.
*
* @return string max_join_size value.
*
* @since __DEPLOY_VERSION__
*/
public function getMaxJoinSize(): string
{
return '';
}

/**
* Shows the table CREATE statement that creates the given tables.
*
Expand Down
28 changes: 28 additions & 0 deletions src/Sqlsrv/SqlsrvDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,34 @@ public function isConnectionEncryptionSupported(): bool
return false;
}

/**
* Method to get the sql_big_selects session variable.
*
* If the connector doesn't support reporting this value please return false.
*
* @return boolean Whether sql_big_selects is enabled or not.
*
* @since __DEPLOY_VERSION__
*/
public function getSqlBigSelects(): bool
{
return false;
}

/**
* Method to get the max_join_size session variable.
*
* If the connector doesn't support reporting this value please return an empty string.
*
* @return string max_join_size value.
*
* @since __DEPLOY_VERSION__
*/
public function getMaxJoinSize(): string
{
return '';
}

/**
* Retrieves field information about the given tables.
*
Expand Down