Skip to content

Commit

Permalink
Drop method admin
Browse files Browse the repository at this point in the history
It was already removed from DBD::mysql documentation in commit
e35a628.
  • Loading branch information
pali committed Feb 19, 2018
1 parent d34214a commit 1ece8cd
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 139 deletions.
114 changes: 0 additions & 114 deletions MariaDB.xs
Original file line number Diff line number Diff line change
Expand Up @@ -46,120 +46,6 @@ constant(name, arg)
RETVAL


MODULE = DBD::MariaDB PACKAGE = DBD::MariaDB::dr

void
_admin_internal(drh,dbh,command,dbname=NULL,host=NULL,port=NULL,user=NULL,password=NULL)
SV* drh
SV* dbh
char* command
char* dbname
char* host
char* port
char* user
char* password
PPCODE:
{
MYSQL mysql;
int retval;
MYSQL* sock;
#if MYSQL_VERSION_ID >= 50709
const char *shutdown = "SHUTDOWN";
#endif

/*
* Connect to the database, if required.
*/
if (SvOK(dbh)) {
D_imp_dbh(dbh);
sock = imp_dbh->pmysql;
}
else
{
mysql.net.fd = -1;
sock = mariadb_dr_connect(drh, &mysql, NULL, host, port, user, password, NULL, NULL);
if (sock == NULL)
{
mariadb_dr_do_error(drh, mysql_errno(&mysql), mysql_error(&mysql),
mysql_sqlstate(&mysql));
XSRETURN_NO;
}
}

if (strEQ(command, "shutdown"))
#if MYSQL_VERSION_ID < 40103
retval = mysql_shutdown(sock);
#else
#if MYSQL_VERSION_ID < 50709
retval = mysql_shutdown(sock, SHUTDOWN_DEFAULT);
#else
retval = mysql_real_query(sock, shutdown, strlen(shutdown));
#endif
#endif
else if (strEQ(command, "reload"))
retval = mysql_reload(sock);
else if (strEQ(command, "createdb"))
{
#if MYSQL_VERSION_ID < 40000
retval = mysql_create_db(sock, dbname);
#else
char* buffer = malloc(strlen(dbname)+50);
if (buffer == NULL)
{
mariadb_dr_do_error(drh, JW_ERR_MEM, "Out of memory" ,NULL);
XSRETURN_NO;
}
else
{
strcpy(buffer, "CREATE DATABASE ");
strcat(buffer, dbname);
retval = mysql_real_query(sock, buffer, strlen(buffer));
free(buffer);
}
#endif
}
else if (strEQ(command, "dropdb"))
{
#if MYSQL_VERSION_ID < 40000
retval = mysql_drop_db(sock, dbname);
#else
char* buffer = malloc(strlen(dbname)+50);
if (buffer == NULL)
{
mariadb_dr_do_error(drh, JW_ERR_MEM, "Out of memory" ,NULL);
XSRETURN_NO;
}
else
{
strcpy(buffer, "DROP DATABASE ");
strcat(buffer, dbname);
retval = mysql_real_query(sock, buffer, strlen(buffer));
free(buffer);
}
#endif
}
else
{
mariadb_dr_do_error(drh, JW_ERR_INVALID_ATTRIBUTE, SvPVX(sv_2mortal(newSVpvf("Unknown command %s", command))), "HY000");
XSRETURN_NO;
}
if (retval)
{
mariadb_dr_do_error(SvOK(dbh) ? dbh : drh, mysql_errno(sock),
mysql_error(sock) ,mysql_sqlstate(sock));
}

if (SvOK(dbh))
{
mysql_close(sock);
}
if (retval)
XSRETURN_NO;
else
XSRETURN_YES;
}


MODULE = DBD::MariaDB PACKAGE = DBD::MariaDB::db


Expand Down
25 changes: 0 additions & 25 deletions lib/DBD/MariaDB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -179,22 +179,6 @@ sub data_sources {
return $dbh->data_sources();
}

sub admin {
my($drh) = shift;
my($command) = shift;
my($dbname) = ($command eq 'createdb' || $command eq 'dropdb') ?
shift : undef;
my($host, $port) = DBD::MariaDB->_OdbcParseHost(shift(@_));
my($user) = shift;
my($password) = shift;

$drh->func(undef, $command,
$dbname,
$host,
$port,
$user, $password, '_admin_internal');
}

package DBD::MariaDB::db; # ====== DATABASE ======
use strict;
use DBI qw(:sql_types);
Expand Down Expand Up @@ -257,15 +241,6 @@ sub ANSI2db {
return $DBD::MariaDB::db::ANSI2db{"$type"};
}

sub admin {
my($dbh) = shift;
my($command) = shift;
my($dbname) = ($command eq 'createdb' || $command eq 'dropdb') ?
shift : undef;
$dbh->{'Driver'}->func($dbh, $command, $dbname, undef, undef, undef,
'_admin_internal');
}

sub table_info ($) {
my ($dbh, $catalog, $schema, $table, $type, $attr) = @_;
local $dbh->{mariadb_server_prepare} = 0;
Expand Down

0 comments on commit 1ece8cd

Please sign in to comment.