Exemple #1
0
void CAeonEngine::MsgGetTables (const SArchonMessage &Msg, const CHexeSecurityCtx *pSecurityCtx)

//	MsgGetTables
//
//	Aeon.getTables

	{
	int i;

	if (!m_bReady)
		{
		SendMessageReplyError(MSG_ERROR_UNABLE_TO_COMPLY, ERR_NOT_READY, Msg);
		return;
		}

	//	Get a list of all tables

	TArray<CAeonTable *> AllTables;
	GetTables(&AllTables);

	//	Return an array of table descriptors

	CComplexArray *pArray = new CComplexArray;
	for (i = 0; i < AllTables.GetCount(); i++)
		{
		if (pSecurityCtx && !pSecurityCtx->IsNamespaceAccessible(AllTables[i]->GetName()))
			continue;

		pArray->Insert(AllTables[i]->GetDesc());
		}

	//	Reply

	SendMessageReply(MSG_AEON_RESULT_TABLES, CDatum(pArray), Msg);
	}
Exemple #2
0
bool CAeonEngine::FlushTableRows (void)

//	FlushTableRows
//
//	Save all in-memory rows to disk

	{
	int i;

	//	Get a list of all tables

	TArray<CAeonTable *> AllTables;
	GetTables(&AllTables);

	//	Loop over each table

	bool bAllSucceeded = true;
	for (i = 0; i < AllTables.GetCount(); i++)
		{
		CString sError;
		if (!AllTables[i]->Save(&sError))
			{
			Log(MSG_LOG_ERROR, strPattern("Unable to save table %s: %s", AllTables[i]->GetName(), sError));
			bAllSucceeded = false;
			//	Continue saving other tables
			}
		}
	
	//	Done

	return bAllSucceeded;
	}
Exemple #3
0
void CAeonEngine::MsgHousekeeping (const SArchonMessage &Msg, const CHexeSecurityCtx *pSecurityCtx)

//	MsgHousekeeping
//
//	Arc.housekeeping

	{
	int i;

	ASSERT(pSecurityCtx == NULL);

	//	Get the list of all tables (in a semaphore)

	TArray<CAeonTable *> AllTables;
	GetTables(&AllTables);
	if (AllTables.GetCount() == 0)
		return;

	//	Compute how much memory data we want each table to keep in memory
	//	before it flushes to disk. (x2 because most tables won't use the
	//	maximum.

	DWORD dwMemoryPerTable = 2 * m_dwMaxMemoryUse / AllTables.GetCount();

	//	Loop over all tables and let them do some housekeeping tasks (such as
	//	saving updated rows and compacting segments).

	for (i = 0; i < AllTables.GetCount(); i++)
		AllTables[i]->Housekeeping(dwMemoryPerTable);
	}
Exemple #4
0
/** \fn DBUtil::IsNewDatabase(void)
 *  \brief Returns true for a new (empty) database.
 */
bool DBUtil::IsNewDatabase(void)
{
    const QStringList tables = GetTables();
    const int size = tables.size();
    // Usually there will be a single table called schemalock, but check for
    // no tables, also, just in case.
    return (((size == 1) && (tables.at(0).endsWith(".`schemalock`"))) ||
            (size == 0));
}
Exemple #5
0
		int OcTree::Create(Engine* engine, const TRI* tris, int triCount, int trisPerNode)
		{
			this->engine = engine;

			// Build our root node
			if (!BuildRootNode(tris, triCount))
				return 0;

			// Build tree recursively
			BuildTree((OctNode*)OctNodeList.GetLast(), trisPerNode, tris, triCount);

			// Get the table and find neighbors
			int octCount;
			OctNode** octTable = (OctNode**)OctNodeList.BuildTable(&octCount);

			for (int i = 0; i < octCount; i++)
			{
				OctNode* node = octTable[i];

				for (int j = 0; j < NUM_NEIGHBORS; j++)
				{
					int found = NULL_NODE;
					float foundSize = (float)(unsigned int)(1 << 31); // Max val

					BoxSide side;
					side.SetFromBox(node->BBox, j);

					FindNeighbor(octTable, octTable[0], &side, j, &found, &foundSize);

					node->NeighborIdx[j] = found;

				} // for (j)
			} // for (i)

		
			free(octTable);

			this->triangles = tris;

			// Get the final tables
			GetTables(&octreeTable, &octreeCount, &triangleIdxTable, &triangleIdxCount);



			return 1;
		}
Exemple #6
0
/** \fn DBUtil::CheckTables(const bool repair, const QString options)
 *  \brief Checks database tables
 *
 *   This function will check database tables.
 *
 *  \param repair Repair any tables whose status is not OK
 *  \param options Options to be passed to CHECK TABLE; defaults to QUICK
 *  \return false if any tables have status other than OK; if repair is true,
 *          returns true if those tables were repaired successfully
 *  \sa DBUtil::RepairTables(const QStringList)
 */
bool DBUtil::CheckTables(const bool repair, const QString options)
{
    MSqlQuery query(MSqlQuery::InitCon());
    if (!query.isConnected())
        return false;

    const QStringList all_tables = GetTables(QStringList("MyISAM"));

    if (all_tables.empty())
        return true;

    QString sql = QString("CHECK TABLE %1 %2;").arg(all_tables.join(", "))
                                               .arg(options);

    LOG(VB_GENERAL, LOG_CRIT, "Checking database tables.");
    if (!query.exec(sql))
    {
        MythDB::DBError("DBUtil Checking Tables", query);
        return false;
    }

    QStringList tables = CheckRepairStatus(query);
    bool result = true;
    if (!tables.empty())
    {
        LOG(VB_GENERAL, LOG_CRIT, QString("Found crashed database table(s): %1")
                                      .arg(tables.join(", ")));
        if (repair == true)
            // If RepairTables() repairs the crashed tables, return true
            result = RepairTables(tables);
        else
            result = false;
    }

    return result;
}
Exemple #7
0
bool
StatementObject::Invoke(NPIdentifier name, const NPVariant *args,
                               uint32_t argCount, NPVariant *result)
{
//sprintf(tmp, "stmt Invoke [%s]\n", NPN_UTF8FromIdentifier(name)); log(tmp);
  NPError rc;
  VOID_TO_NPVARIANT(*result);
  int index = 0;

  if (name == mc_Init_id) {

    if (argCount < 2) {
      NPN_SetException(this, "Too few parameters count");
      return true;
    }
#if 0
    if (!(NPVARIANT_IS_INT32(args[0]) && NPVARIANT_IS_OBJECT(args[1]))) {
      NPN_SetException(this, "Wrong argument type");
      return true;
    }

    SQLHANDLE hdbc = (SQLHANDLE)(long)NPVARIANT_TO_INT32(args[0]);
#else
    if (!(NPVARIANT_IS_OBJECT(args[0]) && NPVARIANT_IS_OBJECT(args[1]))) {
      NPN_SetException(this, "Wrong argument type");
      return true;
    }

    SQLHANDLE hdbc = (SQLHANDLE)NPVARIANT_TO_OBJECT(args[0]);
#endif

    Init(hdbc, NPVARIANT_TO_OBJECT(args[1]));

    return true;

  } else if (name == mc_AddParameter_id) {
    if (argCount < 1) {
      NPN_SetException(this, "Too few parameters count");
      return true;
    }

    AddParam(args);
    return true;

  } else if (name == mc_Execute_id) {
    if (argCount < 1) {
      NPN_SetException(this, "Too few parameters count");
      return true;
    }
    if (!NPVARIANT_IS_STRING(args[0])) {
      NPN_SetException(this, "Wrong argument type");
      return true;
    }

    Execute((NPString*)&NPVARIANT_TO_STRING(args[0]));
    return true;

  } else if (name == mc_Close_id) {
    Close();
    return true;

  } else if (name == mc_Fetch_id) {
    bool ret;
    rc = Fetch(&ret);
    if (rc != NPERR_NO_ERROR)
      return true;
    BOOLEAN_TO_NPVARIANT(ret, *result);
    return true;

  } else if (name == mc_MoreResults_id) {
    bool ret;
    rc = MoreResults(&ret);
    if (rc != NPERR_NO_ERROR)
      return true;
    BOOLEAN_TO_NPVARIANT(ret, *result);
    return true;

  } else if (name == mc_GetColumnName_id) {
    const char *ret;
    if (argCount < 1) {
      NPN_SetException(this, "Too few parameters count");
      return true;
    }

    if (NPVARIANT_IS_INT32(args[0]))
      index = NPVARIANT_TO_INT32(args[0]);
    else if (NPVARIANT_IS_DOUBLE(args[0]))
      index = (int)NPVARIANT_TO_DOUBLE(args[0]);
    else {
      NPN_SetException(this, "Wrong argument type");
      return true;
    }

    rc = GetColumnName(index, &ret);
    if (rc != NPERR_NO_ERROR)
      return true;
    STRING_TO_NPVARIANT(ret, *result);
    return true;

  } else if (name == mc_GetVariant_id) {
    if (argCount < 1) {
      NPN_SetException(this, "Too few parameters count");
      return true;
    }

    if (NPVARIANT_IS_INT32(args[0]))
      index = NPVARIANT_TO_INT32(args[0]);
    else if (NPVARIANT_IS_DOUBLE(args[0]))
      index = (int)NPVARIANT_TO_DOUBLE(args[0]);
    else {
      NPN_SetException(this, "Wrong argument type");
      return true;
    }

    GetVariant(index, result);
    return true;

  } else if (name == mc_GetColumnType_id) {
    int ret;
    if (argCount < 1) {
      NPN_SetException(this, "Too few parameters count");
      return true;
    }

    if (NPVARIANT_IS_INT32(args[0]))
      index = NPVARIANT_TO_INT32(args[0]);
    else if (NPVARIANT_IS_DOUBLE(args[0]))
      index = (int)NPVARIANT_TO_DOUBLE(args[0]);
    else {
      NPN_SetException(this, "Wrong argument type");
      return true;
    }

    rc = GetColumnType(index, &ret);
    if (rc != NPERR_NO_ERROR)
      return true;
    INT32_TO_NPVARIANT(ret, *result);
    return true;

  } else if (name == mc_IsColumnNullable_id) {
    bool ret;
    if (argCount < 1) {
      NPN_SetException(this, "Too few parameters count");
      return true;
    }

    if (NPVARIANT_IS_INT32(args[0]))
      index = NPVARIANT_TO_INT32(args[0]);
    else if (NPVARIANT_IS_DOUBLE(args[0]))
      index = (int)NPVARIANT_TO_DOUBLE(args[0]);
    else {
      NPN_SetException(this, "Wrong argument type");
      return true;
    }

    rc = IsColumnNullable(index, &ret);
    if (rc != NPERR_NO_ERROR)
      return true;
    BOOLEAN_TO_NPVARIANT(ret, *result);
    return true;

  } else if (name == mc_GetTables_id) {
    if (argCount < 4) {
      NPN_SetException(this, "Too few parameters count");
      return true;
    }
    if (!(NPVARIANT_IS_NULL(args[0]) || NPVARIANT_IS_STRING(args[0]))) {
      NPN_SetException(this, "Wrong 1 argument type");
      return true;
    }
    if (!(NPVARIANT_IS_NULL(args[1]) || NPVARIANT_IS_STRING(args[1]))) {
      NPN_SetException(this, "Wrong 2 argument type");
      return true;
    }
    if (!(NPVARIANT_IS_NULL(args[2]) || NPVARIANT_IS_STRING(args[2]))) {
      NPN_SetException(this, "Wrong 3 argument type");
      return true;
    }
    if (!(NPVARIANT_IS_NULL(args[3]) || NPVARIANT_IS_STRING(args[3]))) {
      NPN_SetException(this, "Wrong 4 argument type");
      return true;
    }

    GetTables(&args[0], &args[1], &args[2], &args[3]);
    return true;

  } else if (name == mc_GetColumns_id) {
    if (argCount < 4) {
      NPN_SetException(this, "Too few parameters count");
      return true;
    }
    if (!(NPVARIANT_IS_NULL(args[0]) || NPVARIANT_IS_STRING(args[0]))) {
      NPN_SetException(this, "Wrong 1 argument type");
      return true;
    }
    if (!(NPVARIANT_IS_NULL(args[1]) || NPVARIANT_IS_STRING(args[1]))) {
      NPN_SetException(this, "Wrong 2 argument type");
      return true;
    }
    if (!(NPVARIANT_IS_NULL(args[2]) || NPVARIANT_IS_STRING(args[2]))) {
      NPN_SetException(this, "Wrong 3 argument type");
      return true;
    }
    if (!(NPVARIANT_IS_NULL(args[3]) || NPVARIANT_IS_STRING(args[3]))) {
      NPN_SetException(this, "Wrong 4 argument type");
      return true;
    }

    GetColumns(&args[0], &args[1], &args[2], &args[3]);
    return true;

  } else if (name == mc_GetTypeInfo_id) {
    if (argCount < 1) {
      NPN_SetException(this, "Too few parameters count");
      return true;
    }

    if (NPVARIANT_IS_INT32(args[0]))
      index = NPVARIANT_TO_INT32(args[0]);
    else if (NPVARIANT_IS_DOUBLE(args[0]))
      index = (int)NPVARIANT_TO_DOUBLE(args[0]);
    else {
      NPN_SetException(this, "Wrong argument type");
      return true;
    }

    GetTypeInfo(index);
    return true;

  } else if (name == mc_GetPrimaryKeys_id) {
    if (argCount < 3) {
      NPN_SetException(this, "Too few parameters count");
      return true;
    }
    if (!(NPVARIANT_IS_NULL(args[0]) || NPVARIANT_IS_STRING(args[0]))) {
      NPN_SetException(this, "Wrong 1 argument type");
      return true;
    }
    if (!(NPVARIANT_IS_NULL(args[1]) || NPVARIANT_IS_STRING(args[1]))) {
      NPN_SetException(this, "Wrong 2 argument type");
      return true;
    }
    if (!(NPVARIANT_IS_NULL(args[2]) || NPVARIANT_IS_STRING(args[2]))) {
      NPN_SetException(this, "Wrong 3 argument type");
      return true;
    }

    GetPrimaryKeys(&args[0], &args[1], &args[2]);
    return true;

  } else if (name == mc_GetForeignKeys_id) {
    if (argCount < 6) {
      NPN_SetException(this, "Too few parameters count");
      return true;
    }
    if (!(NPVARIANT_IS_NULL(args[0]) || NPVARIANT_IS_STRING(args[0]))) {
      NPN_SetException(this, "Wrong 1 argument type");
      return true;
    }
    if (!(NPVARIANT_IS_NULL(args[1]) || NPVARIANT_IS_STRING(args[1]))) {
      NPN_SetException(this, "Wrong 2 argument type");
      return true;
    }
    if (!(NPVARIANT_IS_NULL(args[2]) || NPVARIANT_IS_STRING(args[2]))) {
      NPN_SetException(this, "Wrong 3 argument type");
      return true;
    }
    if (!(NPVARIANT_IS_NULL(args[3]) || NPVARIANT_IS_STRING(args[3]))) {
      NPN_SetException(this, "Wrong 4 argument type");
      return true;
    }
    if (!(NPVARIANT_IS_NULL(args[4]) || NPVARIANT_IS_STRING(args[4]))) {
      NPN_SetException(this, "Wrong 5 argument type");
      return true;
    }
    if (!(NPVARIANT_IS_NULL(args[5]) || NPVARIANT_IS_STRING(args[5]))) {
      NPN_SetException(this, "Wrong 6 argument type");
      return true;
    }

    GetForeignKeys(&args[0], &args[1], &args[2], &args[3], &args[4], &args[5]);
    return true;

  } else if (name == mc_GetProcedures_id) {
    if (argCount < 3) {
      NPN_SetException(this, "Too few parameters count");
      return true;
    }
    if (!(NPVARIANT_IS_NULL(args[0]) || NPVARIANT_IS_STRING(args[0]))) {
      NPN_SetException(this, "Wrong 1 argument type");
      return true;
    }
    if (!(NPVARIANT_IS_NULL(args[1]) || NPVARIANT_IS_STRING(args[1]))) {
      NPN_SetException(this, "Wrong 2 argument type");
      return true;
    }
    if (!(NPVARIANT_IS_NULL(args[2]) || NPVARIANT_IS_STRING(args[2]))) {
      NPN_SetException(this, "Wrong 3 argument type");
      return true;
    }

    GetProcedures(&args[0], &args[1], &args[2]);
    return true;

  } else if (name == mc_GetProcedureColumns_id) {
    if (argCount < 4) {
      NPN_SetException(this, "Too few parameters count");
      return true;
    }
    if (!(NPVARIANT_IS_NULL(args[0]) || NPVARIANT_IS_STRING(args[0]))) {
      NPN_SetException(this, "Wrong 1 argument type");
      return true;
    }
    if (!(NPVARIANT_IS_NULL(args[1]) || NPVARIANT_IS_STRING(args[1]))) {
      NPN_SetException(this, "Wrong 2 argument type");
      return true;
    }
    if (!(NPVARIANT_IS_NULL(args[2]) || NPVARIANT_IS_STRING(args[2]))) {
      NPN_SetException(this, "Wrong 3 argument type");
      return true;
    }
    if (!(NPVARIANT_IS_NULL(args[3]) || NPVARIANT_IS_STRING(args[3]))) {
      NPN_SetException(this, "Wrong 4 argument type");
      return true;
    }

    GetProcedureColumns(&args[0], &args[1], &args[2], &args[3]);
    return true;
  
  }  

  return false;
}