Exemplo n.º 1
0
/* {{{ MySQL_Connection::prepareStatement() -U- */
sql::PreparedStatement *
MySQL_Connection::prepareStatement(const sql::SQLString& /* sql */, int /* columnIndexes */ [])
{
	CPP_ENTER_WL(intern->logger, "MySQL_Connection::prepareStatement");
	checkClosed();
	throw sql::MethodNotImplementedException("MySQL_Connection::prepareStatement(const sql::SQLString& sql, int* columnIndexes)");
	return NULL; // fool compiler
}
Exemplo n.º 2
0
/* {{{ MySQL_Connection::prepareStatement() -U- */
sql::PreparedStatement *
MySQL_Connection::prepareStatement(const sql::SQLString& /* sql */, int /* resultSetType */, int /* resultSetConcurrency */)
{
	CPP_ENTER_WL(intern->logger, "MySQL_Connection::prepareStatement");
	checkClosed();
	throw sql::MethodNotImplementedException("MySQL_Connection::prepareStatement(const sql::SQLString& sql, int resultSetType, int resultSetConcurrency)");
	return NULL; // fool compiler
}
Exemplo n.º 3
0
/* {{{ MySQL_Connection::isReadOnly() -U- */
bool
MySQL_Connection::isReadOnly()
{
	CPP_ENTER_WL(intern->logger, "MySQL_Connection::isReadOnly");
	checkClosed();
	throw sql::MethodNotImplementedException("MySQL_Connection::isReadOnly");
	return false; // fool compiler
}
/* {{{ MySQL_Connection::close() -I- */
void
MySQL_Connection::close()
{
	CPP_ENTER_WL(intern->logger, "MySQL_Connection::close");
	checkClosed();
	proxy.reset();
	clearWarnings();
	intern->is_valid = false;
}
Exemplo n.º 5
0
ResultSet* MySQLPreparedStatement::getResultSet()
{
    checkClosed();

    if (mysql_more_results(stmt->mysql))
        mysql_next_result(stmt->mysql);

    return new MySQLPreparedResultSet(this, stmt);
}
/* {{{ MySQL_Connection::getSchema() -I- */
sql::SQLString
MySQL_Connection::getSchema()
{
	CPP_ENTER_WL(intern->logger, "MySQL_Connection::getSchema");
	checkClosed();
	boost::scoped_ptr< sql::Statement > stmt(createStatement());
	boost::scoped_ptr< sql::ResultSet > rset(stmt->executeQuery("SELECT DATABASE()")); //SELECT SCHEMA()
	rset->next();
	return rset->getString(1);
}
/* {{{ MySQL_Connection::setSchema() -I- (not part of JDBC) */
void
MySQL_Connection::setSchema(const sql::SQLString& catalog)
{
	CPP_ENTER_WL(intern->logger, "MySQL_Connection::setCatalog");
	checkClosed();
	sql::SQLString sql("USE `");
	sql.append(catalog).append("`");

	boost::scoped_ptr< sql::Statement > stmt(createStatement());
	stmt->execute(sql);
}
Exemplo n.º 8
0
void MySQLPreparedStatement::doQuery()
{
    checkClosed();
    MYSQL* mysql = mysqlConn->getMySQLHandle();

    if (mysql_stmt_bind_param(stmt, bind))
        throw MySQLException("MySQLPreparedStatement::doQuery, mysql_stmt_bind_param error",mysql);

    if (mysql_stmt_execute(stmt))
        throw MySQLException("MySQLPreparedStatement::doQuery, mysql_stmt_execute error",mysql);
}
Exemplo n.º 9
0
bool MgCmdDrawLines::touchMoved(const MgMotion* sender)
{
    Point2d pnt(snapPoint(sender));
    dynshape()->shape()->setPoint(m_index, pnt);
    
    checkClosed(sender, pnt);
    
    dynshape()->shape()->update();
    _lastClicked = false;
    
    return MgCommandDraw::touchMoved(sender);
}
Exemplo n.º 10
0
/* {{{ MySQL_Connection::getWarnings() -I- */
const SQLWarning *
MySQL_Connection::getWarnings()
{
	CPP_ENTER_WL(intern->logger, "MySQL_Connection::getWarnings");
	checkClosed();

	clearWarnings();

	intern->warnings.reset(loadMysqlWarnings(this));

	return intern->warnings.get();
}
Exemplo n.º 11
0
/* {{{ MySQL_Connection::rollback() -I- */
void
MySQL_Connection::rollback(Savepoint * savepoint)
{
	CPP_ENTER_WL(intern->logger, "MySQL_Connection::rollback");
	checkClosed();
	if (getAutoCommit()) {
		throw sql::InvalidArgumentException("The connection is in autoCommit mode");
	}
	sql::SQLString sql("ROLLBACK TO SAVEPOINT ");
	sql.append(savepoint->getSavepointName());

	boost::scoped_ptr< sql::Statement > stmt(createStatement());
	stmt->execute(sql);
}
Exemplo n.º 12
0
int main (void)
{
  FILE *fle = NULL;
  char s[10];

  checkClosed (fle); /* okay */
  checkOpen (fle); /* error */

  fle = fopen ("test", "r");

  if (fle == NULL) 
    {
      return 0;
    }

  checkClosed (fle); /* error */
  checkOpen (fle); /* okay */

  (void) fclose (fle);
  checkOpen (fle); /* error */
  checkClosed (fle); /* okay */

  return 0; 
} 
Exemplo n.º 13
0
void McServerSession::onTransactionCompleted(bool isSubRequest) {
  DestructorGuard dg(this);

  assert(inFlight_ > 0);
  --inFlight_;
  if (!isSubRequest) {
    assert(realRequestsInFlight_ > 0);
    --realRequestsInFlight_;
  }

  checkClosed();
  if (options_.maxInFlight > 0 &&
      realRequestsInFlight_ < options_.maxInFlight) {
    resume(PAUSE_THROTTLED);
  }
}
Exemplo n.º 14
0
/* {{{ MySQL_Connection::releaseSavepoint() -I- */
void
MySQL_Connection::releaseSavepoint(Savepoint * savepoint)
{
	CPP_ENTER_WL(intern->logger, "MySQL_Connection::releaseSavepoint");
	checkClosed();
	if (proxy->get_server_version() < 50001) {
		throw sql::MethodNotImplementedException("releaseSavepoint not available in this server version");
	}
	if (getAutoCommit()) {
		throw sql::InvalidArgumentException("The connection is in autoCommit mode");
	}
	sql::SQLString sql("RELEASE SAVEPOINT ");
	sql.append(savepoint->getSavepointName());

	boost::scoped_ptr<sql::Statement> stmt(createStatement());
	stmt->execute(sql);
}
Exemplo n.º 15
0
ResultSet* MySQLStatement::getResultSet()
{
    checkClosed();
    MYSQL* mysql = mysqlConn->getMySQLHandle();
    MYSQL_RES* res = NULL;

    res = mysql_store_result(mysql);

    if (!res) {
        // check possible error
        if (mysql_errno(mysql) !=0) // an error occurred
            throw MySQLException("MySQLStatement::getResultSet mysql_store_result error",mysql);

        // INSERT, UPDATE, DELETE : no result set
        return NULL;
    }

    return new MySQLResultSet(this, res);
}
Exemplo n.º 16
0
/* {{{ MySQL_Connection::setSessionVariable() -I- */
void
MySQL_Connection::setSessionVariable(const sql::SQLString & varname, unsigned int value)
{
	CPP_ENTER_WL(intern->logger, "MySQL_Connection::setSessionVariable");
	checkClosed();

	sql::SQLString query("SET SESSION ");
	query.append(varname).append("=");

	if (!value) {
		query.append("0");
	} else {
		std::ostringstream qstr;
		qstr << value;
		query.append(qstr.str());
	}

	service->executeUpdate(query);
}
Exemplo n.º 17
0
/* {{{ MySQL_Connection::setSavepoint() -I- */
sql::Savepoint *
MySQL_Connection::setSavepoint(const sql::SQLString& name)
{
	CPP_ENTER_WL(intern->logger, "MySQL_Connection::setSavepoint");
	checkClosed();
	if (getAutoCommit()) {
		throw sql::InvalidArgumentException("The connection is in autoCommit mode");
	}
	if (!name.length()) {
		throw sql::InvalidArgumentException("Savepoint name cannot be empty string");
	}
	sql::SQLString sql("SAVEPOINT ");
	sql.append(name);

	boost::scoped_ptr< sql::Statement > stmt(createStatement());
	stmt->execute(sql);

	return new MySQL_Savepoint(name);
}
Exemplo n.º 18
0
/* {{{ MySQL_Connection::setSessionVariable() -I- */
void
MySQL_Connection::setSessionVariable(const sql::SQLString & varname, const sql::SQLString & value)
{
	CPP_ENTER_WL(intern->logger, "MySQL_Connection::setSessionVariable");
	checkClosed();

	sql::SQLString q("SET SESSION ");
	q.append(varname).append("=");

	if (!value.compare("NULL")) {
		q.append("NULL");
	} else {
		q.append("'").append(value).append("'");
	}

	service->executeUpdate(q);
	if (intern->cache_sql_mode && !strncasecmp(varname.c_str(), "sql_mode", sizeof("sql_mode") - 1)) {
		intern->sql_mode= value;
	}
}
Exemplo n.º 19
0
/* {{{ MySQL_Connection::getSessionVariable() -I- */
sql::SQLString
MySQL_Connection::getSessionVariable(const sql::SQLString & varname)
{
	CPP_ENTER_WL(intern->logger, "MySQL_Connection::getSessionVariable");
	checkClosed();

	if (intern->cache_sql_mode && intern->sql_mode_set == true && !varname.compare("sql_mode")) {
		CPP_INFO_FMT("sql_mode=%s", intern->sql_mode.c_str());
		return intern->sql_mode;
	}
	sql::SQLString q("SHOW SESSION VARIABLES LIKE '");
	q.append(varname).append("'");

	boost::scoped_ptr< sql::ResultSet > rset(service->executeQuery(q));

	if (rset->next()) {
		if (intern->cache_sql_mode && intern->sql_mode_set == false && !varname.compare("sql_mode")) {
			intern->sql_mode = rset->getString(2);
			intern->sql_mode_set = true;
		}
		return rset->getString(2);
	}
	return "";
}
Exemplo n.º 20
0
void MySQLPreparedStatement::close()
{
    checkClosed();
    closed = true;
}
Exemplo n.º 21
0
/* {{{ MySQL_Connection::escapeString() -I- */
sql::SQLString MySQL_Connection::escapeString(const sql::SQLString & s)
{
	CPP_ENTER_WL(intern->logger, "MySQL_Connection::escapeString");
	checkClosed();
	return proxy->escapeString(s);
}
Exemplo n.º 22
0
/* {{{ MySQL_Connection::createStatement() -I- */
sql::Statement * MySQL_Connection::createStatement()
{
	CPP_ENTER_WL(intern->logger, "MySQL_Connection::createStatement");
	checkClosed();
	return new MySQL_Statement(this, proxy, intern->defaultStatementResultType, intern->logger);
}
Exemplo n.º 23
0
void McServerSession::close() {
  state_ = CLOSING;
  checkClosed();
}
Exemplo n.º 24
0
/* {{{ MySQL_Connection::setCatalog() -I- */
void
MySQL_Connection::setCatalog(const sql::SQLString&)
{
	CPP_ENTER_WL(intern->logger, "MySQL_Connection::setCatalog");
	checkClosed();
}
Exemplo n.º 25
0
void MySQLStatement::close()
{
    checkClosed();
    closed = true;
}