Exemplo n.º 1
0
bool pgForeignServer::DropObject(wxFrame *frame, ctlTree *browser, bool cascaded)
{
	wxString sql = wxT("DROP SERVER ") + GetQuotedFullIdentifier();
	if (cascaded)
		sql += wxT(" CASCADE");
	return GetDatabase()->ExecuteVoid(sql);
}
Exemplo n.º 2
0
bool gpExtTable::DropObject(wxFrame *frame, ctlTree *browser, bool cascaded)
{
	wxString sql = wxT("DROP EXTERNAL TABLE ") + this->GetSchema()->GetQuotedIdentifier() + wxT(".") + this->GetQuotedIdentifier();
	if (cascaded)
		sql += wxT(" CASCADE");
	return GetDatabase()->ExecuteVoid(sql);
}
Exemplo n.º 3
0
bool pgDatabaseObjCollection::CanCreate()
{
	if (IsCollectionForType(PGM_CATALOG))
		return false;

	return GetDatabase()->GetCreatePrivilege();
}
Exemplo n.º 4
0
bool pgCast::DropObject(wxFrame *frame, ctlTree *browser, bool cascaded)
{
	wxString sql = wxT("DROP CAST (") + GetSourceType() + wxT(" AS ") + GetTargetType() + wxT(")");
	if (cascaded)
		sql += wxT(" CASCADE");
	return GetDatabase()->ExecuteVoid(sql);
}
Exemplo n.º 5
0
bool pgCheck::DropObject(wxFrame *frame, ctlTree *browser, bool cascaded)
{
	wxString sql = wxT("ALTER ") + objectKind + wxT(" ") + qtIdent(objectSchema) + wxT(".") + qtIdent(objectName)
	               + wxT(" DROP CONSTRAINT ") + GetQuotedIdentifier();
	if (cascaded)
		sql += wxT(" CASCADE");
	return GetDatabase()->ExecuteVoid(sql);
}
Exemplo n.º 6
0
bool slPath::DropObject(wxFrame *frame, ctlTree *browser, bool cascaded)
{
	return GetDatabase()->ExecuteVoid(
	           wxT("SELECT ") + GetCluster()->GetSchemaPrefix()
	           + wxT("droppath(") + NumToStr(GetSlId())
	           + wxT(", ") + NumToStr(GetNode()->GetSlId())
	           + wxT(");\n"));
}
Exemplo n.º 7
0
bool pgForeignKey::DropObject(wxFrame *frame, ctlTree *browser, bool cascaded)
{
	wxString sql = wxT("ALTER TABLE ") + this->GetSchema()->GetQuotedIdentifier() + wxT(".") + qtIdent(fkTable)
	               + wxT(" DROP CONSTRAINT ") + GetQuotedIdentifier();
	if (cascaded)
		sql += wxT(" CASCADE");
	return GetDatabase()->ExecuteVoid(sql);
}
Exemplo n.º 8
0
bool pgProcedure::DropObject(wxFrame *frame, ctlTree *browser, bool cascaded)
{
	if (!GetConnection()->EdbMinimumVersion(8, 0))
		return pgFunction::DropObject(frame, browser, cascaded);

	wxString sql = wxT("DROP PROCEDURE ") + this->GetSchema()->GetQuotedIdentifier() + wxT(".") + this->GetQuotedIdentifier();
	return GetDatabase()->ExecuteVoid(sql);
}
Exemplo n.º 9
0
void pgView::RefreshMatView(bool concurrently)
{
	wxString sql = wxT("REFRESH MATERIALIZED VIEW ");
	if (concurrently)
		sql += wxT("CONCURRENTLY ");
	sql += GetQuotedFullIdentifier();
	GetDatabase()->ExecuteVoid(sql);
}
void CDialogT3::Fresh()
{
    SetTimer(T3_MODEL,1000,NULL);
    GetDatabase();
    ShowDialogData();
    //Updatedatabase();

}
Exemplo n.º 11
0
void pgForeignKey::Validate(frmMain *form)
{
	wxString sql = wxT("ALTER TABLE ") + GetQuotedSchemaPrefix(fkSchema) + qtIdent(fkTable)
	               + wxT("\n  VALIDATE CONSTRAINT ") + GetQuotedIdentifier();
	GetDatabase()->ExecuteVoid(sql);

	iSetValid(true);
	UpdateIcon(form->GetBrowser());
}
Exemplo n.º 12
0
bool pgTextSearchParser::DropObject(wxFrame *frame, ctlTree *browser, bool cascaded)
{
	wxString sql = wxT("DROP TEXT SEARCH PARSER ") + this->GetSchema()->GetQuotedIdentifier() + wxT(".") + this->GetIdentifier();

	if (cascaded)
		sql += wxT(" CASCADE");

	return GetDatabase()->ExecuteVoid(sql);
}
Exemplo n.º 13
0
bool pgTextSearchConfiguration::DropObject(wxFrame *frame, ctlTree *browser, bool cascaded)
{
	wxString sql = wxT("DROP TEXT SEARCH CONFIGURATION ") + this->GetSchema()->GetQuotedIdentifier() + wxT(".") + qtIdent(this->GetIdentifier());

	if (cascaded)
		sql += wxT(" CASCADE");

	return GetDatabase()->ExecuteVoid(sql);
}
Exemplo n.º 14
0
bool slSubscription::DropObject(wxFrame *frame, ctlTree *browser, bool cascaded)
{
    return GetDatabase()->ExecuteVoid(
               wxT("SELECT ") + GetCluster()->GetSchemaPrefix()
               + wxT("unsubscribeset(") + NumToStr(GetSet()->GetSlId())
               + wxT(", ") + NumToStr(GetReceiverId())
               + wxT(");"));

}
Exemplo n.º 15
0
void pgDomain::Validate(frmMain *form)
{
    wxString sql = wxT("ALTER DOMAIN ") + GetQuotedFullIdentifier()
                   + wxT("\n  VALIDATE CONSTRAINT ") + GetCheckConstraintName();
    GetDatabase()->ExecuteVoid(sql);

    iSetValid(true);
    UpdateIcon(form->GetBrowser());
}
Exemplo n.º 16
0
bool edbPrivateSynonym::DropObject(wxFrame *frame, ctlTree *browser, bool cascaded)
{
    wxString sql;
    if (isPublic)
        sql = wxT("DROP PUBLIC SYNONYM ") + GetQuotedIdentifier();
    else
        sql = wxT("DROP SYNONYM ") + this->GetSchema()->GetQuotedIdentifier() + wxT(".") + GetQuotedIdentifier();
       
    return GetDatabase()->ExecuteVoid(sql);
}
Exemplo n.º 17
0
void CConnection::SetDbName(const string& name, CDB_Connection* conn)
{
    m_database = name;

    if( GetDatabase().empty() )
        return;

    CDB_Connection* work = (conn == 0 ? GetCDB_Connection() : conn);
    work->SetDatabaseName(name);
}
Exemplo n.º 18
0
long slNode::GetOutstandingAcks()
{
	long l = StrToLong(GetDatabase()->ExecuteScalar(
	                       wxT("SELECT SUM(st_lag_num_events) AS sumlagevents\n")
	                       wxT("  FROM ") + GetCluster()->GetSchemaPrefix() + wxT("sl_status\n")
	                       wxT(" WHERE st_origin = ") + NumToStr(GetCluster()->GetLocalNodeID()) + wxT("\n")
	                       wxT("  GROUP BY st_last_event")));

	return l;
}
Exemplo n.º 19
0
MockImapSession& MockTestSetup::GetSession()
{
	if(!m_session.get()) {
		m_session.reset(new MockImapSession(GetClientPtr(), GetDatabase()));
		m_session->SetBusClient(*GetClientPtr());
		m_session->SetAccount(m_account);
	}

	return *m_session;
}
Exemplo n.º 20
0
void pgCheck::Validate(frmMain *form)
{
	wxString sql = wxT("ALTER ") + objectKind + wxT(" ")
	               + GetQuotedSchemaPrefix(objectSchema) + qtIdent(objectName)
	               + wxT("\n  VALIDATE CONSTRAINT ") + GetQuotedIdentifier();
	GetDatabase()->ExecuteVoid(sql);

	iSetValid(true);
	UpdateIcon(form->GetBrowser());
}
Exemplo n.º 21
0
FdoPtr<FdoSmPhRdSchemaReader> FdoSmPhOdbcMgr::CreateRdSchemaReader( FdoSmPhRowsP rows, FdoSmPhOwnerP owner, bool dsInfo )
{
    rdbi_vndr_info_def info;
	rdbi_vndr_info(GetRdbiContext(), &info );
    
    if( info.dbversion == RDBI_DBVERSION_ODBC_TERADATA )
        return new FdoSmPhRdTeraSchemaReader( rows, GetDatabase(), owner );
    else
        return new FdoSmPhRdOdbcSchemaReader( rows, owner, dsInfo );
}
Exemplo n.º 22
0
bool Query::execute(const std::string& sql)
{		// query, no result
	m_last_query = sql;
	if (odb && res)
	{
		GetDatabase().error(*this, "execute: query busy");
	}
	if (odb && !res)
	{
		if (mysql_real_query(&odb -> mysql,sql.c_str(),sql.length()))
		{
			GetDatabase().error(*this,"query failed");
		}
		else
		{
			return true;
		}
	}
	return false;
}
Exemplo n.º 23
0
bool pgView::DropObject(wxFrame *frame, ctlTree *browser, bool cascaded)
{
	if (GetMaterializedView())
		sql = wxT("DROP MATERIALIZED VIEW ") + this->GetSchema()->GetQuotedIdentifier() + wxT(".") + this->GetQuotedIdentifier();
	else
		sql = wxT("DROP VIEW ") + this->GetSchema()->GetQuotedIdentifier() + wxT(".") + this->GetQuotedIdentifier();

	if (cascaded)
		sql += wxT(" CASCADE");
	return GetDatabase()->ExecuteVoid(sql);
}
Exemplo n.º 24
0
wxString pgDomain::GetSql(ctlTree *browser)
{
    if (sql.IsNull())
    {
        sql = wxT("-- Domain: ") + GetQuotedFullIdentifier() + wxT("\n\n")
              + wxT("-- DROP DOMAIN ") + GetQuotedFullIdentifier() + wxT(";")
              + wxT("\n\nCREATE DOMAIN ") + GetQuotedFullIdentifier()
              + wxT("\n  AS ") + GetQuotedBasetype();
        if (GetCollationOid() > 0)
            sql += wxT("\n  COLLATE ") + GetQuotedCollation();
        AppendIfFilled(sql, wxT("\n  DEFAULT "), GetDefault());
        // CONSTRAINT Name Dont know where it's stored, may be omitted anyway
        if (notNull)
            sql += wxT("\n  NOT NULL");

        // Get a count of the constraints.
        int consCount = 0;
        pgCollection *constraints = browser->FindCollection(checkFactory, GetId());
        if (constraints)
        {
            constraints->ShowTreeDetail(browser);
            treeObjectIterator consIt(browser, constraints);

            pgObject *data;

            while ((data = consIt.GetNextObject()) != 0)
            {
                data->ShowTreeDetail(browser);

                sql += wxT("\n  CONSTRAINT ") + data->GetQuotedIdentifier()
                       + wxT(" ") + data->GetTypeName().Upper()
                       + wxT(" ") ;

                switch (data->GetMetaType())
                {
                case PGM_CHECK:
                    sql += wxT("(") + ((pgCheck *)data)->GetDefinition() + wxT(")");
                    if (GetDatabase()->BackendMinimumVersion(9, 2) && !((pgCheck *)data)->GetValid())
                        sql += wxT(" NOT VALID");
                    break;
                }
            }
        }

        sql += wxT(";\n")
               + GetOwnerSql(7, 4)
               + GetCommentSql();

        if (GetConnection()->BackendMinimumVersion(9, 1))
            sql += GetSeqLabelsSql();
    }

    return sql;
}
Exemplo n.º 25
0
Query::~Query()
{
	if (res)
	{
		GetDatabase().error(*this, "mysql_free_result in destructor");
		mysql_free_result(res);
	}
	if (odb)
	{
		m_db.freedb(odb);
	}
}
Exemplo n.º 26
0
bool Query::Connected()
{
	if (odb)
	{
		if (mysql_ping(&odb -> mysql))
		{
			GetDatabase().error(*this, "mysql_ping() failed");
			return false;
		}
	}
	return odb ? true : false;
}
Exemplo n.º 27
0
Query::~Query()
{
	if (res)
	{
		GetDatabase().error(*this, "sqlite3_finalize in destructor");
		sqlite3_finalize(res);
	}
	if (odb)
	{
		m_db.freedb(odb);
	}
}
Exemplo n.º 28
0
sqlite3_stmt *Query::get_result(const std::string& sql)
{
	// query, result
	m_last_query = sql;
	if (odb && res)
	{
		GetDatabase().error(*this, "get_result: query busy");
	}
	if (odb && !res)
	{
		const char *s = NULL;
		int rc = sqlite3_prepare(odb -> db, sql.c_str(), sql.size(), &res, &s);
		if (rc != SQLITE_OK)
		{
			GetDatabase().error(*this, "get_result: prepare query failed");
			return NULL;
		}
		if (!res)
		{
			GetDatabase().error(*this, "get_result: query failed");
			return NULL;
		}
		// get column names from result
		{
			int i = 0;
			do
			{
				const char *p = sqlite3_column_name(res, i);
				if (!p)
					break;
				m_nmap[p] = ++i;
			} while (true);
			m_num_cols = i;
		}
		cache_rc = sqlite3_step(res);
		cache_rc_valid = true;
		m_row_count = (cache_rc == SQLITE_ROW) ? 1 : 0;
	}
	return res;
}
Exemplo n.º 29
0
void CApplicationImpl::OpenDataFile(const CString& csFileName)
{ 
	if (!IsDataFileOpened(csFileName))
	{
		Database::IDataFile* pTempDataFile = GetDatabase()->OpenDataFile(csFileName);
		try
		{
			if (pTempDataFile->IsEmpty())
			{
				CreateDefaultContent(pTempDataFile);
			}
			else
			{
				CheckContent(pTempDataFile);
			}

			CheckModules(pTempDataFile);

			if (!m_spDataFile.is_null())
			{
				GetDatabase()->CloseDataFile(m_spDataFile.get());
			}
			m_spDataFile = pTempDataFile;

			m_mru.AddToList(m_spDataFile->GetFileName());
			m_mru.WriteToRegistry(GetOptionsPath(_T("Application")));

			UpdateViews(UNM_FILE_OPENED, (WPARAM)m_spDataFile->GetFileName());
		}
		catch(...)
		{
			// close new opened temp data file and throw exception up
			GetDatabase()->CloseDataFile(pTempDataFile);
			throw;
		}
	}
}
Exemplo n.º 30
0
void pgTrigger::SetEnabled(ctlTree *browser, const bool b)
{
	if (GetQuotedFullTable().Len() > 0 && ((enabled && !b) || (!enabled && b)))
	{
		wxString sql = wxT("ALTER TABLE ") + GetQuotedFullTable() + wxT(" ");
		if (enabled && !b)
			sql += wxT("DISABLE");
		else if (!enabled && b)
			sql += wxT("ENABLE");
		sql += wxT(" TRIGGER ") + GetQuotedIdentifier();
		GetDatabase()->ExecuteVoid(sql);
	}
	enabled = b;
	UpdateIcon(browser);
}