예제 #1
0
bool TagEntry::operator ==(const TagEntry& rhs)
{
    //Note: tree item id is not used in this function!
    bool res =
        m_scope == rhs.m_scope &&
        m_file == rhs.m_file &&
        m_kind == rhs.m_kind &&
        m_parent == rhs.m_parent &&
        m_pattern == rhs.m_pattern &&
        m_name == rhs.m_name &&
        m_path == rhs.m_path &&
        m_lineNumber == rhs.m_lineNumber &&
        GetInherits() == rhs.GetInherits() &&
        GetAccess() == rhs.GetAccess() &&
        GetSignature() == rhs.GetSignature() &&
        GetTyperef() == rhs.GetTyperef();

    bool res2 = m_scope == rhs.m_scope &&
                m_file == rhs.m_file &&
                m_kind == rhs.m_kind &&
                m_parent == rhs.m_parent &&
                m_pattern == rhs.m_pattern &&
                m_name == rhs.m_name &&
                m_path == rhs.m_path &&
                GetInherits() == rhs.GetInherits() &&
                GetAccess() == rhs.GetAccess() &&
                GetSignature() == rhs.GetSignature() &&
                GetTyperef() == rhs.GetTyperef();

    if (res2 && !res) {
        // the entries are differs only in the line numbers
        m_differOnByLineNumber = true;
    }
    return res;
}
예제 #2
0
int TagEntry::Update(wxSQLite3Statement& updatePerepareStmnt)
{
    // If this node is a dummy, (IsOk() == false) we dont update it to database
    if( !IsOk() )
        return TagOk;

    try
    {
        // see TagsDatabase::GetUpdateOneStatement() function for the order of binding
        updatePerepareStmnt.Bind(1, GetParentId());
        updatePerepareStmnt.Bind(2, GetName());
        updatePerepareStmnt.Bind(3, GetFile());
        updatePerepareStmnt.Bind(4, GetLine());
        updatePerepareStmnt.Bind(5, GetAccess());
        updatePerepareStmnt.Bind(6, GetPattern());
        updatePerepareStmnt.Bind(7, GetParent());
        updatePerepareStmnt.Bind(8, GetInherits());
        updatePerepareStmnt.Bind(9, GetTyperef());
        updatePerepareStmnt.Bind(10, GetScope());
        updatePerepareStmnt.Bind(11, GetKind());
        updatePerepareStmnt.Bind(12, GetSignature());
        updatePerepareStmnt.Bind(13, GetPath());
        updatePerepareStmnt.ExecuteUpdate();
        updatePerepareStmnt.Reset();
    }
    catch(wxSQLite3Exception& exc)
    {
        wxLogMessage(exc.GetMessage());
        return TagError;
    }
    return TagOk;
}
예제 #3
0
int TagEntry::Store(wxSQLite3Statement& insertPerepareStmnt)
{
    // If this node is a dummy, (IsOk() == false) we dont insert it to database
    if( !IsOk() )
        return TagOk;

    try
    {
        // see TagsDatabase::GetInsertOneStatement() for the order of binding
        insertPerepareStmnt.Bind(1, GetParentId());
        insertPerepareStmnt.Bind(2, GetName());
        insertPerepareStmnt.Bind(3, GetFile());
        insertPerepareStmnt.Bind(4, GetLine());
        insertPerepareStmnt.Bind(5, GetKind());
        insertPerepareStmnt.Bind(6, GetAccess());
        insertPerepareStmnt.Bind(7, GetSignature());
        insertPerepareStmnt.Bind(8, GetPattern());
        insertPerepareStmnt.Bind(9, GetParent());
        insertPerepareStmnt.Bind(10, GetInherits());
        insertPerepareStmnt.Bind(11, GetPath());
        insertPerepareStmnt.Bind(12, GetTyperef());
        insertPerepareStmnt.Bind(13, GetScope());
        insertPerepareStmnt.ExecuteUpdate();
        insertPerepareStmnt.Reset();

    }
    catch(wxSQLite3Exception& exc)
    {
        if(exc.ErrorCodeAsString(exc.GetErrorCode()) == wxT("SQLITE_CONSTRAINT"))
            return TagExist;
        wxLogMessage(exc.GetMessage());
        return TagError;
    }
    return TagOk;
}
예제 #4
0
bool TagEntry::operator ==(const TagEntry& rhs)
{
    //Note: tree item id is not used in this function!
    return
        m_parentId == rhs.m_parentId &&
        m_scope == rhs.m_scope &&
        m_file == rhs.m_file &&
        m_kind == rhs.m_kind &&
        m_parent == rhs.m_parent &&
        m_pattern == rhs.m_pattern &&
        m_lineNumber == rhs.m_lineNumber &&
        m_name == rhs.m_name &&
        m_path == rhs.m_path &&
        GetInherits() == rhs.GetInherits() &&
        GetAccess() == rhs.GetAccess() &&
        GetSignature() == rhs.GetSignature() &&
        GetPosition() == rhs.GetPosition() &&
        GetTyperef() == rhs.GetTyperef();
}
예제 #5
0
void pgRole::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane)
{
    if (!expandedKids)
    {
        expandedKids=true;
        wxString rolesquery;

        if (GetConnection()->BackendMinimumVersion(8, 2))
            rolesquery = wxT("SELECT rolname, admin_option,\n") 
                         wxT(" pg_catalog.shobj_description(r.oid, 'pg_authid') AS description\n");
        else
            rolesquery = wxT("SELECT rolname, admin_option\n"); 

        rolesquery += wxT("  FROM pg_roles r\n") 
                      wxT("  JOIN pg_auth_members ON r.oid=roleid\n") 
                      wxT(" WHERE member=") + GetOidStr() + wxT("\n") 
                      wxT(" ORDER BY rolname");

        pgSetIterator roles(GetConnection(), rolesquery);

        while (roles.RowsLeft())
        {
            wxString role=roles.GetVal(wxT("rolname"));
            if (roles.GetBool(wxT("admin_option")))
                role += PGROLE_ADMINOPTION;

            rolesIn.Add(role);
        }
    }
    if (properties)
    {
        CreateListColumns(properties);

        properties->AppendItem(_("Name"), GetName());
        properties->AppendItem(_("OID"), GetOid());
        properties->AppendItem(_("Account expires"), DateToAnsiStr(GetAccountExpires()));
        properties->AppendItem(_("Can login?"), BoolToYesNo(GetCanLogin()));
        properties->AppendItem(_("Superuser?"), BoolToYesNo(GetSuperuser()));
        properties->AppendItem(_("Create databases?"), BoolToYesNo(GetCreateDatabase()));
        properties->AppendItem(_("Create roles?"), BoolToYesNo(GetCreateRole()));
        properties->AppendItem(_("Update catalogs?"), BoolToYesNo(GetUpdateCatalog()));
        properties->AppendItem(_("Inherits?"), BoolToYesNo(GetInherits()));
        if (server->GetConnection()->BackendMinimumVersion(9, 1))
        {
            properties->AppendItem(_("Replication?"), BoolToYesNo(GetReplication()));
        }

        wxString strConnLimit;
        strConnLimit.Printf(wxT("%ld"), GetConnectionLimit()); 
        properties->AppendItem(_("Connection Limit"), strConnLimit);

        properties->AppendItem(_("Comment"), firstLineOnly(GetComment()));

        wxString roleList;

        size_t index;
        for (index=0 ; index < rolesIn.GetCount() ; index++)
        {
            if (!roleList.IsEmpty())
                roleList += wxT(", ");
            roleList += rolesIn.Item(index);
        }
        properties->AppendItem(_("Member of"), roleList);

        for (index=0; index < configList.GetCount() ; index++)
        {
            wxString item=configList.Item(index);
            properties->AppendItem(item.BeforeFirst('='), item.AfterFirst('='));
        }
    }
}
예제 #6
0
wxString pgRole::GetSql(ctlTree *browser)
{
    if (sql.IsNull())
    {
        sql = wxT("-- Role: ") + GetName() + wxT("\n\n")
            + wxT("-- DROP ROLE ") + GetQuotedFullIdentifier() + wxT(";")
            + wxT("\n\nCREATE ROLE ") + GetQuotedIdentifier();

        if (GetCanLogin())
        {
            sql += wxT(" LOGIN");
            if (GetPassword() != wxT("********") && !GetPassword().IsEmpty())
                AppendIfFilled(sql, wxT("\n  ENCRYPTED PASSWORD "), qtDbString(GetPassword()));
        }
        sql += wxT("\n ");
        if (this->GetSuperuser())   sql += wxT(" SUPERUSER");
        else                        sql += wxT(" NOSUPERUSER");
        if (GetInherits())          sql += wxT(" INHERIT");
        else                        sql += wxT(" NOINHERIT");
        if (GetCreateDatabase())    sql += wxT(" CREATEDB");
        else                        sql += wxT(" NOCREATEDB");
        if (GetCreateRole())        sql += wxT(" CREATEROLE");
        else                        sql += wxT(" NOCREATEROLE");
        if (server->GetConnection()->BackendMinimumVersion(9, 1))
        {
            if (GetReplication())       sql += wxT(" REPLICATION");
            else                        sql += wxT(" NOREPLICATION");
        }
        if (GetConnectionLimit() > 0)
                                    sql += wxT(" CONNECTION LIMIT ") + NumToStr(GetConnectionLimit());
        if (GetAccountExpires().IsValid())
        AppendIfFilled(sql, wxT(" VALID UNTIL "), qtDbString(DateToAnsiStr(GetAccountExpires())));
        if (GetRolQueueName().Length() > 0)
            AppendIfFilled(sql, wxT(" RESOURCE QUEUE "), GetRolQueueName());
        sql +=wxT(";\n");

        if (this->GetSuperuser() && !GetUpdateCatalog())
            sql += wxT("UPDATE pg_authid SET rolcatupdate=false WHERE rolname=") + qtDbString(GetIdentifier()) + wxT(";\n");

        size_t index;
        for (index=0 ; index < configList.GetCount() ; index++)
        {
            if (configList.Item(index).BeforeFirst('=') != wxT("search_path") &&
                configList.Item(index).BeforeFirst('=') != wxT("temp_tablespaces"))
                sql += wxT("ALTER ROLE ") + GetQuotedIdentifier()
                    + wxT(" SET ") + configList.Item(index).BeforeFirst('=') + wxT("='") + configList.Item(index).AfterFirst('=') + wxT("';\n");
            else
                sql += wxT("ALTER ROLE ") + GetQuotedIdentifier()
                    + wxT(" SET ") + configList.Item(index).BeforeFirst('=') + wxT("=") + configList.Item(index).AfterFirst('=') + wxT(";\n");
        }
        for (index=0 ; index < rolesIn.GetCount() ; index++)
        {
            wxString role=rolesIn.Item(index);
            bool admin=false;
            if (role.Right(PGROLE_ADMINOPTION_LEN) == PGROLE_ADMINOPTION)
            {
                admin=true;
                role=role.Left(role.Length()-PGROLE_ADMINOPTION_LEN);
            }
            sql += wxT("GRANT ") + qtIdent(role)
                +  wxT(" TO ") + GetQuotedIdentifier();

            if (admin)
                sql += wxT(" WITH ADMIN OPTION");

            sql += wxT(";\n");
        }

        if (!GetComment().IsNull())
        {
            sql += wxT("COMMENT ON ROLE ") + GetQuotedFullIdentifier() + wxT(" IS ")
                +  qtDbString(GetComment()) + wxT(";\n");
        }

    }
    return sql;
}
예제 #7
0
void pgRole::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane)
{
	if (!expandedKids)
	{
		expandedKids = true;
		wxString rolesquery;

		if (GetConnection()->BackendMinimumVersion(8, 2))
			rolesquery = wxT("SELECT rolname, admin_option,\n")
			             wxT(" pg_catalog.shobj_description(r.oid, 'pg_authid') AS description\n");
		else
			rolesquery = wxT("SELECT rolname, admin_option\n");

		rolesquery += wxT("  FROM pg_roles r\n")
		              wxT("  JOIN pg_auth_members ON r.oid=roleid\n")
		              wxT(" WHERE member=") + GetOidStr() + wxT("\n")
		              wxT(" ORDER BY rolname");

		pgSetIterator roles(GetConnection(), rolesquery);

		while (roles.RowsLeft())
		{
			wxString role = roles.GetVal(wxT("rolname"));
			if (roles.GetBool(wxT("admin_option")))
				role += PGROLE_ADMINOPTION;

			rolesIn.Add(role);
		}

		// Get configuration
		wxString query;
		if (GetConnection()->BackendMinimumVersion(9, 0))
		{
			query = wxT("WITH configs AS ")
			        wxT("(SELECT datname, unnest(setconfig) AS config")
			        wxT(" FROM pg_db_role_setting s")
			        wxT(" LEFT JOIN pg_database d ON d.oid=s.setdatabase")
			        wxT(" WHERE s.setrole=") + NumToStr(GetOid()) + wxT(")\n")
			        wxT("SELECT datname, split_part(config, '=', 1) AS variable, replace(config, split_part(config, '=', 1) || '=', '') AS value\n")
			        wxT("FROM configs");
		}
		else
		{
			wxString query_myrole = wxT("SELECT rolconfig FROM pg_roles WHERE oid=") + NumToStr(GetOid());
			query = wxT("SELECT '' AS datname, split_part(config, '=', 1) AS variable,\n")
			        wxT("       replace(config,split_part(config, '=', 1) || '=', '') AS value\n")
			        wxT("FROM (\n")
			        wxT("    SELECT\n")
			        wxT("      (\n")
			        wxT("      SELECT rolconfig[i]\n")
			        wxT("      FROM pg_roles\n")
			        wxT("      WHERE oid=") + NumToStr(GetOid()) + wxT("\n")
			        wxT("      ) AS config\n")
			        wxT("    FROM generate_series(array_lower((") + query_myrole + wxT("),1), array_upper((") + query_myrole + wxT("),1)) AS i\n")
			        wxT("     ) configs");
		}
		pgSet *configs = GetConnection()->ExecuteSet(query);
		if (configs)
		{
			while (!configs->Eof())
			{
				variables.Add(configs->GetVal(wxT("datname")));
				variables.Add(configs->GetVal(wxT("variable")));
				variables.Add(configs->GetVal(wxT("value")));
				configs->MoveNext();
			}
			delete configs;
		}
	}
	if (properties)
	{
		CreateListColumns(properties);

		properties->AppendItem(_("Name"), GetName());
		properties->AppendItem(_("OID"), GetOid());
		properties->AppendItem(_("Account expires"), DateToAnsiStr(GetAccountExpires()));
		properties->AppendItem(_("Can login?"), BoolToYesNo(GetCanLogin()));
		properties->AppendItem(_("Superuser?"), BoolToYesNo(GetSuperuser()));
		properties->AppendItem(_("Create databases?"), BoolToYesNo(GetCreateDatabase()));
		properties->AppendItem(_("Create roles?"), BoolToYesNo(GetCreateRole()));

		if (!server->GetConnection()->BackendMinimumVersion(9, 5))
			properties->AppendItem(_("Update catalogs?"), BoolToYesNo(GetUpdateCatalog()));
		properties->AppendItem(_("Inherits?"), BoolToYesNo(GetInherits()));
		if (server->GetConnection()->BackendMinimumVersion(9, 1))
		{
			properties->AppendItem(_("Replication?"), BoolToYesNo(GetReplication()));
		}

		wxString strConnLimit;
		strConnLimit.Printf(wxT("%ld"), GetConnectionLimit());
		properties->AppendItem(_("Connection Limit"), strConnLimit);

		properties->AppendItem(_("Comment"), firstLineOnly(GetComment()));

		wxString roleList;

		size_t index;
		for (index = 0 ; index < rolesIn.GetCount() ; index++)
		{
			if (!roleList.IsEmpty())
				roleList += wxT(", ");
			roleList += rolesIn.Item(index);
		}
		properties->AppendItem(_("Member of"), roleList);

		wxString dbname;
		wxString parameter;
		wxString value;
		for (index = 0; index < variables.GetCount() ; index += 3)
		{
			dbname = variables.Item(index);
			parameter = variables.Item(index + 1);
			value = variables.Item(index + 2);

			if (dbname.Length() == 0)
			{
				properties->AppendItem(parameter, value);
			}
			else
			{
				properties->AppendItem(parameter + wxT(" (database ") + dbname + wxT(")"), value);
			}
		}

		if (!GetLabels().IsEmpty())
		{
			wxArrayString seclabels = GetProviderLabelArray();
			if (seclabels.GetCount() > 0)
			{
				for (unsigned int index = 0 ; index < seclabels.GetCount() - 1 ; index += 2)
				{
					properties->AppendItem(seclabels.Item(index), seclabels.Item(index + 1));
				}
			}
		}
	}
}