// The libmysqlclient driver supports utf8mb4 starting at version 5.5.3.
if(version_compare($version,'5.5.3','<')){
returnFALSE;
}
}
// Ensure that the MySQL server supports large prefixes and utf8mb4.
try{
$this->query("CREATE TABLE {drupal_utf8mb4_test} (id VARCHAR(255), PRIMARY KEY(id(255))) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ROW_FORMAT=DYNAMIC ENGINE=INNODB");
thrownewDatabaseSchemaObjectDoesNotExistException(t("Cannot set default value of field %table.%field: field doesn't exist.",array('%table'=>$table,'%field'=>$field)));
thrownewDatabaseSchemaObjectDoesNotExistException(t("Cannot set default value of field @table.@field: field doesn't exist.",array('@table'=>$table,'@field'=>$field)));
}
if(!isset($default)){
...
...
@@ -371,7 +384,7 @@ public function fieldSetDefault($table, $field, $default) {
publicfunctionfieldSetNoDefault($table,$field){
if(!$this->fieldExists($table,$field)){
thrownewDatabaseSchemaObjectDoesNotExistException(t("Cannot remove default value of field %table.%field: field doesn't exist.",array('%table'=>$table,'%field'=>$field)));
thrownewDatabaseSchemaObjectDoesNotExistException(t("Cannot remove default value of field @table.@field: field doesn't exist.",array('@table'=>$table,'@field'=>$field)));
}
$this->connection->query('ALTER TABLE {'.$table.'} ALTER COLUMN `'.$field.'` DROP DEFAULT');
...
...
@@ -381,15 +394,15 @@ public function indexExists($table, $name) {
// Returns one row for each column in the index. Result is string or FALSE.
// Details at http://dev.mysql.com/doc/refman/5.0/en/show-index.html
$row=$this->connection->query('SHOW INDEX FROM {'.$table."} WHERE key_name = '$name'")->fetchAssoc();
returnisset($row['key_name']);
returnisset($row['Key_name']);
}
publicfunctionaddPrimaryKey($table,$fields){
if(!$this->tableExists($table)){
thrownewDatabaseSchemaObjectDoesNotExistException(t("Cannot add primary key to table %table: table doesn't exist.",array('%table'=>$table)));
thrownewDatabaseSchemaObjectDoesNotExistException(t("Cannot add primary key to table @table: table doesn't exist.",array('@table'=>$table)));
@@ -426,10 +439,10 @@ public function dropUniqueKey($table, $name) {
publicfunctionaddIndex($table,$name,$fields){
if(!$this->tableExists($table)){
thrownewDatabaseSchemaObjectDoesNotExistException(t("Cannot add index %name to table %table: table doesn't exist.",array('%table'=>$table,'%name'=>$name)));
thrownewDatabaseSchemaObjectDoesNotExistException(t("Cannot add index @name to table @table: table doesn't exist.",array('@table'=>$table,'@name'=>$name)));
}
if($this->indexExists($table,$name)){
thrownewDatabaseSchemaObjectExistsException(t("Cannot add index %name to table %table: index already exists.",array('%table'=>$table,'%name'=>$name)));
thrownewDatabaseSchemaObjectExistsException(t("Cannot add index @name to table @table: index already exists.",array('@table'=>$table,'@name'=>$name)));
}
$this->connection->query('ALTER TABLE {'.$table.'} ADD INDEX `'.$name.'` ('.$this->createKeySql($fields).')');
...
...
@@ -446,10 +459,10 @@ public function dropIndex($table, $name) {
thrownewDatabaseSchemaObjectDoesNotExistException(t("Cannot change the definition of field %table.%name: field doesn't exist.",array('%table'=>$table,'%name'=>$field)));
thrownewDatabaseSchemaObjectDoesNotExistException(t("Cannot change the definition of field @table.@name: field doesn't exist.",array('@table'=>$table,'@name'=>$field)));
thrownewDatabaseSchemaObjectExistsException(t("Cannot rename field %table.%name to %name_new: target field already exists.",array('%table'=>$table,'%name'=>$field,'%name_new'=>$field_new)));
thrownewDatabaseSchemaObjectExistsException(t("Cannot rename field @table.@name to @name_new: target field already exists.",array('@table'=>$table,'@name'=>$field,'@name_new'=>$field_new)));
@@ -314,10 +314,10 @@ protected function _createKeySql($fields) {
functionrenameTable($table,$new_name){
if(!$this->tableExists($table)){
thrownewDatabaseSchemaObjectDoesNotExistException(t("Cannot rename %table to %table_new: table %table doesn't exist.",array('%table'=>$table,'%table_new'=>$new_name)));
thrownewDatabaseSchemaObjectDoesNotExistException(t("Cannot rename @table to @table_new: table @table doesn't exist.",array('@table'=>$table,'@table_new'=>$new_name)));
}
if($this->tableExists($new_name)){
thrownewDatabaseSchemaObjectExistsException(t("Cannot rename %table to %table_new: table %table_new already exists.",array('%table'=>$table,'%table_new'=>$new_name)));
thrownewDatabaseSchemaObjectExistsException(t("Cannot rename @table to @table_new: table @table_new already exists.",array('@table'=>$table,'@table_new'=>$new_name)));
}
// Get the schema and tablename for the old table.
...
...
@@ -328,9 +328,9 @@ function renameTable($table, $new_name) {
// rename them when renaming the table.
$indexes=$this->connection->query('SELECT indexname FROM pg_indexes WHERE schemaname = :schema AND tablename = :table',array(':schema'=>$old_schema,':table'=>$old_table_name));
thrownewDatabaseSchemaObjectDoesNotExistException(t("Cannot set default value of field %table.%field: field doesn't exist.",array('%table'=>$table,'%field'=>$field)));
thrownewDatabaseSchemaObjectDoesNotExistException(t("Cannot set default value of field @table.@field: field doesn't exist.",array('@table'=>$table,'@field'=>$field)));
}
if(!isset($default)){
...
...
@@ -408,7 +408,7 @@ public function fieldSetDefault($table, $field, $default) {
publicfunctionfieldSetNoDefault($table,$field){
if(!$this->fieldExists($table,$field)){
thrownewDatabaseSchemaObjectDoesNotExistException(t("Cannot remove default value of field %table.%field: field doesn't exist.",array('%table'=>$table,'%field'=>$field)));
thrownewDatabaseSchemaObjectDoesNotExistException(t("Cannot remove default value of field @table.@field: field doesn't exist.",array('@table'=>$table,'@field'=>$field)));
}
$this->connection->query('ALTER TABLE {'.$table.'} ALTER COLUMN "'.$field.'" DROP DEFAULT');
...
...
@@ -435,10 +435,10 @@ protected function constraintExists($table, $name) {
publicfunctionaddPrimaryKey($table,$fields){
if(!$this->tableExists($table)){
thrownewDatabaseSchemaObjectDoesNotExistException(t("Cannot add primary key to table %table: table doesn't exist.",array('%table'=>$table)));
thrownewDatabaseSchemaObjectDoesNotExistException(t("Cannot add primary key to table @table: table doesn't exist.",array('@table'=>$table)));
@@ -475,10 +475,10 @@ public function dropUniqueKey($table, $name) {
publicfunctionaddIndex($table,$name,$fields){
if(!$this->tableExists($table)){
thrownewDatabaseSchemaObjectDoesNotExistException(t("Cannot add index %name to table %table: table doesn't exist.",array('%table'=>$table,'%name'=>$name)));
thrownewDatabaseSchemaObjectDoesNotExistException(t("Cannot add index @name to table @table: table doesn't exist.",array('@table'=>$table,'@name'=>$name)));
}
if($this->indexExists($table,$name)){
thrownewDatabaseSchemaObjectExistsException(t("Cannot add index %name to table %table: index already exists.",array('%table'=>$table,'%name'=>$name)));
thrownewDatabaseSchemaObjectExistsException(t("Cannot add index @name to table @table: index already exists.",array('@table'=>$table,'@name'=>$name)));
thrownewDatabaseSchemaObjectDoesNotExistException(t("Cannot change the definition of field %table.%name: field doesn't exist.",array('%table'=>$table,'%name'=>$field)));
thrownewDatabaseSchemaObjectDoesNotExistException(t("Cannot change the definition of field @table.@name: field doesn't exist.",array('@table'=>$table,'@name'=>$field)));
thrownewDatabaseSchemaObjectExistsException(t("Cannot rename field %table.%name to %name_new: target field already exists.",array('%table'=>$table,'%name'=>$field,'%name_new'=>$field_new)));
thrownewDatabaseSchemaObjectExistsException(t("Cannot rename field @table.@name to @name_new: target field already exists.",array('@table'=>$table,'@name'=>$field,'@name_new'=>$field_new)));
@@ -119,7 +127,7 @@ public function __destruct() {
try{
$count=$this->query('SELECT COUNT(*) FROM '.$prefix.'.sqlite_master WHERE type = :type AND name NOT LIKE :pattern',array(':type'=>'table',':pattern'=>'sqlite_%'))->fetchField();
// We can prune the database file if it doens't have any tables.
// We can prune the database file if it doesn't have any tables.