Sql_Module

MySQL and PostgreSQL operations
extends Module\Support\Sql
Methods Summary
public
# __construct( )
{{{ void __construct(void)

ignore


Overrides

public
# mysql_user_exists( $user , $host = 'localhost' )
public
# delete_mysql_user( string $user , string $host , string $cascade = true )
bool delete_mysql_user(string, string[, bool = false]) Delete a MySQL user
public
# pgsql_user_exists( $user )
public
# delete_pgsql_user( string $user , bool $cascade = false )
bool delete_pgsql_user(string[, bool = false]) Delete a PostgreSQL user
public
# store_sql_password( string $sqlpasswd , string $type )
bool store_sql_password (string, string)
public
# set_mysql_option( string $option , string $value = NULL, string $group = 'client' )
Set MySQL client option Reads from ~/.my.cnf and creates if necessary. Specify a value of null to remove an option.
public
# set_pgsql_password( $password )
public
public
# get_pgsql_password( $user = NULL )
public
# get_mysql_option( string $option , string $group = 'client' )
Get option from MySQL client/server configuration
public
public
# import_mysql( $db , $file )
bool mysql_import(string, string, string, strin)
public
# list_mysql_databases( )
array list_mysql_databases () Queries the db table in the mysql database for applicable grants
public
# change_prefix( string $prefix )
Change account database prefix

todo


public
public
public
# list_mysql_users( )
array list_mysql_users () Lists all created users for MySQL
public
# add_mysql_user( $user , $host , $password , $maxconn = 5, $maxupdates = 0, $maxquery = 0, $ssl = '', $cipher = '', $issuer = '', $subject = '' )
bool add_mysql_user(string, string, string[, int[, int[, int[, string[, string[, string[, string]]]]]]])
public
public
# create_mysql_database( string $db , string $charset = 'latin1', string $collation = 'latin1_general_ci' )
Create a new mysql database
public
# mysql_charset_valid( $charset )
public
public
# mysql_collation_valid( string $collation )
Validate collation name
public
public
# mysql_collation_compatible( string $collation , string $charset )
Verify collation + charset combination are compatible
public
# mysql_database_exists( string $db )
Query information_schema for existence of MySQL database
public
# add_mysql_user_permissions( string $user , string $host , string $db , array $opts )
bool add_mysql_user_permissions (string, string, string, array)

Deprecated


see

set_mysql_privileges()
public
# set_mysql_privileges( string $user , string $host , string $db , array $privileges )
Set grants for a MySQL user
public
# delete_mysql_user_permissions( $user , $host , $db )

Deprecated


see

revoke_from_mysql_db()
public
# revoke_from_mysql_db( string $user , string $host , string $db )
Revoke all privileges on a database from a MySQL user
public
# get_mysql_user_permissions( $user , $host , $db )
public
# get_mysql_privileges( string $user , string $host , string $db )
Get MySQL grants for a user on a database
public
# mysql_version( $pretty = false )
Returns the version of the MySQL server as an integer The form of this version number is main_version * 10000 + minor_version * 100 + sub_version (i.e. version 4.1.0 is 40100)
public
# delete_mysql_database( string $db )
Delete MySQL database from system
public
# delete_mysql_backup( string $db )
Remove MySQL Backup
public
# assert_mysql_permissions( )
Ensure that /var/lib/mysql/ has mysql:<group id> ownership
public
# edit_mysql_user( string $user , string $host , array $opts )
bool edit_mysql_user(string, string, array) Note when calling through SOAP, all options must be given, otherwise the will default to server preferences.
public
# service_enabled( string $service )
bool service_enabled (string) Checks to see if a service is enabled

Deprecated


public
# enabled( string $svc_name )
MySQL/PostgreSQL service enabled on account Checks to see if either MySQL or PostgreSQL is enabled on an account
public
# add_pgsql_user( $user , $password , $maxconn = 5 )
bool add_pgsql_user(string, string[, int])
public
# create_pgsql_database( string $db )
bool create_pgsql_database (string)
public
# pgsql_database_exists( string $db )
Query PostgreSQL system table for existence of database
public
# prep_tablespace( )
void prep_tablespace () Checks to see if tablespace exists, if not, creates it

private


public
# add_pgsql_extension( $db , $extension )
public
# list_pgsql_databases( )
array list_mysql_databases () Queries the db table in the mysql database for applicable grants
public
# add_pgsql_user_permissions( string $user , string $db , array $opts )
bool add_pgsql_user_permissions (string, string, string, array) Add/removes privileges for a user to a table, any value listed as false or not supplied as an array key will revoke the privilege
public
public
# get_pgsql_user_permissions( $user , $db )
void get_pgsql_user_permissions(string, string) Function not implemented in PostgreSQL
public
# delete_pgsql_database( string $db )
bool delete_pgsql_database(string) Drops the database and revokes all permssions
public
# delete_pgsql_backup( string $db )
Remove PostgreSQL Backup
public
# edit_pgsql_user( string $user , string $password , int $maxconn = NULL )
Modify use password and connection limit NOTE: Not implemented with PostgreSQL, owner of database automatically receives grants. Varying degrees of grants impact the usability of this function, i.e. common grants [SELECT, INSERT, UPDATE, DELETE] exist solely on the table level, while [CREATE, TEMP] exist on the database level
public
public
# list_pgsql_users( )
array list_pgsql_users () Lists all created users for PostgreSQL
public
# pg_vacuum_db( $db )
string pg_vacuum_db (string) Vacuums a database
public
public
# pgsql_version( $pretty = false )
public
public
# import_pgsql( $db , $file )
bool pgsql_import(string, string, string, strin)
public
public
public
# export_mysql( string $db , string|null $file = NULL )
Export a MySQL database
public
# get_database_size( string $type , string $db )
Get disk space occupied by database
public
# export_mysql_pipe( $db )
Export a db to a named pipe for immediate download
public
# export_mysql_pipe_real( $db , $user )
Export a database to a named pipe Differs from export_mysql_pipe in that it may only be called internally or from backend, no API access
public
# export_pgsql( $db , $file = NULL )
public
# export_pgsql_pipe( $db )
Export a PGSQL db to a named pipe for immediate download
public
# get_pgsql_uptime( )
int get_pgsql_uptime
public
# get_mysql_uptime( )
int get_mysql_uptime
public
# add_mysql_backup( $db , $extension = 'zip', $span = 5, $preserve = '0', $email = '' )
public
# add_pgsql_backup( $db , $extension = 'zip', $span = 5, $preserve = '0', $email = '' )
public
# edit_mysql_backup( $db , $extension , $span = '0', $preserve = '0', $email = '' )
public
# edit_pgsql_backup( $db , $extension , $span = '0', $preserve = '0', $email = '' )
public
public
public
# get_mysql_backup_config( string $db )
Fetch MySQL backup task information span => (integer) days between backups hold => (integer) number of backups to preserve next => (integer) unix timestamp of next backup ext => (string) extension of backup email => (string) notify address after backup
public
# get_pgsql_backup_config( string $db )
Fetch backup information

see

get_mysql_backup_config()
public
public
# mysql_kill( int $id )
Kill a mysql connection

link

public
# mysql_processlist( )
Get active mysql connections Array ( [0] => Array ( [id] => 11024 [user] => debug [host] => localhost [db] => debug [command] => Query [state] => User sleep [info] => select sleep(1000) ) )
public
# mysql_schema_column_maxlen( string $field )
Get max length of a column in mysql schema
public
# _delete( )
public
# _create( )
public
# _edit_user( string $userold , string $usernew , array $oldpwd )
public
# _edit( )
public
# _verify_conf( Opcenter\Service\ConfigurationContext $ctx )
public
# _create_user( string $user )
public
# _delete_user( string $user )
Methods inherited from Module\Support\Sql
renameDatabasePrefix(), renameDatabasePrefixByType(), pedantize(), renameUserPrefix(), renameUser(), renameUserPrefixByType(), renameUserByType(), installDatabaseService(), uninstallDatabaseService(), _register_temp_user(), _connect_root(), _get_elevated_password(), add_backup_real(), svc_enabled(), edit_backup_real(), list_backups_real(), get_backup_config_real(), delete_backup_real(), _escape(), _preImport(), _postImport()
Methods inherited from Module\Skeleton\Standard
__construct(), setUserParameters(), autoloadModule(), __wakeup(), _invoke(), __debugInfo(), getExportedFunctions(), _reset(), cleanUserParameters(), query()
Constants Summary
public int MYSQL_USER_FIELD_SIZE
# 16
public string PG_TEMP_PASSWORD
# '23f!eoj3'
public string MYSQL_DATADIR
# '/var/lib/mysql'
public string PGSQL_DATADIR
# '/var/lib/pgsql'
public int MIN_PASSWORD_LENGTH
# 3
public int PER_DATABASE_CONNECTION_LIMIT
# 20
public int MIN_PREFIX_LENGTH
# 3
public string MASTER_USER
# 'root'
public double DB_BIN2TXT_MULT
a bullshit constant to decide whether to up the ulimit fsize or not before exporting a db
# 1.5
protected array PGSQL_PERMITTED_EXTENSIONS
# array ( 0 => 'pg_trgm', 1 => 'hstore', )
Constants inherited from Module\Support\Sql
DEFAULT_CONCURRENCY_LIMIT , MIN_PASSWORD_LENGTH , MIN_PREFIX_LENGTH , MASTER_USER , DB_BIN2TXT_MULT
Constants inherited from Module\Skeleton\Standard
DEPENDENCY_MAP
Properties Summary
protected $exportedFunctions


# array ( '*' => 2, 'get_prefix' => 3, 'pgsql_version' => 15, 'mysql_version' => 15, 'version' => 15, 'get_mysql_uptime' => 15, 'assert_mysql_permissions' => 18, 'get_pgsql_uptime' => 15, 'set_mysql_option' => 15, 'get_mysql_option' => 15, 'get_pgsql_username' => 15, 'get_pgsql_password' => 15, 'set_pgsql_password' => 15, 'export_mysql_pipe_real' => 18, 'export_pgsql_pipe_real' => 18, 'enabled' => 3, 'repair_mysql_database' => 10, 'get_database_size' => 10, 'mysql_database_exists' => 10, 'pgsql_database_exists' => 10, '_export_mysql_old' => 18, )
Properties inherited from Module\Support\Sql
$_tempUsers
Properties inherited from Module\Skeleton\Standard
$exportedFunctions, $username, $password, $domain, $user_id, $group_id, $permission_level, $session_id, $site, $site_id