Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
4.1 KiB

  1. //====== Copyright �, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose: Contains the job that's responsible for updating the database schema
  4. //
  5. //=============================================================================
  6. #ifndef UPDATESCHEMA_H
  7. #define UPDATESCHEMA_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. namespace GCSDK
  12. {
  13. typedef CUtlMap<const char *,CRecordInfo *> CMapPRecordInfo;
  14. enum EConversionMode
  15. {
  16. k_EConversionModeInspectOnly,
  17. k_EConversionModeConvertSafe,
  18. k_EConversionModeConvertIrreversible
  19. };
  20. class CSchemaUpdate : public CRefCount
  21. {
  22. public:
  23. CSchemaUpdate();
  24. void AddRecordInfoDesired( CRecordInfo *pRecordInfo );
  25. void AddFTSInfo( const CFTSCatalogInfo &refFTSInfo );
  26. void AddTriggerInfos( const CUtlVector< CTriggerInfo > &refTriggerInfo );
  27. // input parameters
  28. CMapPRecordInfo m_mapPRecordInfoDesired;
  29. EConversionMode m_eConversionMode;
  30. CUtlLinkedList< CFTSCatalogInfo > m_listFTSCatalogInfo;
  31. CUtlVector< CTriggerInfo > m_vecTriggerInfo;
  32. // output parameters
  33. bool m_bConversionNeeded;
  34. bool m_bSkippedAChange;
  35. int m_cTablesDesiredMissing;
  36. int m_cTablesActualDifferent;
  37. int m_cTablesActualUnknown;
  38. int m_cTablesNeedingChange;
  39. int m_cColumnsDesiredMissing;
  40. int m_cColumnsActualDifferent;
  41. int m_cColumnsActualUnknown;
  42. CFmtStr1024 m_sDetail;
  43. private:
  44. virtual ~CSchemaUpdate();
  45. };
  46. // --------------------------------------------------------------------------
  47. class CJobUpdateSchema : public CGCJob
  48. {
  49. public:
  50. CJobUpdateSchema( CGCBase *pGC, int iTableCount ) : CGCJob( pGC ), m_mapSQLTypeToEType( DefLessFunc(int) ), m_iTableCount( iTableCount ) { }
  51. bool BYieldingRunJob( void * );
  52. private:
  53. bool BYieldingUpdateSchema( ESchemaCatalog eSchemaCatalog );
  54. SQLRETURN YieldingEnsureDatabaseSchemaCorrect( ESchemaCatalog eSchemaCatalog, CSchemaUpdate *pSchemaUpdate );
  55. EGCSQLType GetEGCSQLTypeForMSSQLType( int nType );
  56. bool YieldingBuildTypeMap( ESchemaCatalog eSchemaCatalog );
  57. SQLRETURN YieldingGetSchemaID( ESchemaCatalog eSchemaCatalog, int *pSchemaID );
  58. SQLRETURN YieldingGetRecordInfoForAllTables( ESchemaCatalog eSchemaCatalog, int nSchemaID, CMapPRecordInfo &mapPRecordInfo );
  59. SQLRETURN YieldingGetColumnInfoForTable( ESchemaCatalog eSchemaCatalog, CMapPRecordInfo &mapPRecordInfo, int nTableID, const char *pchTableName );
  60. SQLRETURN YieldingGetTableFKConstraints( ESchemaCatalog eSchemaCatalog, CRecordInfo *pRecordInfo );
  61. SQLRETURN YieldingGetColumnIndexes( ESchemaCatalog eSchemaCatalog, CRecordInfo *pRecordInfo );
  62. SQLRETURN YieldingGetTriggers( ESchemaCatalog eSchemaCatalog, int nSchemaID, CUtlVector< CTriggerInfo > &vecTriggerInfo );
  63. SQLRETURN YieldingCreateTable( ESchemaCatalog eSchemaCatalog, CRecordInfo *pRecordInfo );
  64. SQLRETURN YieldingAddIndex( ESchemaCatalog eSchemaCatalog, CRecordInfo *pRecordInfo, const CColumnInfo *pColumnInfo );
  65. SQLRETURN YieldingAddIndex( ESchemaCatalog eSchemaCatalog, CRecordInfo *pRecordInfo, const FieldSet_t &refFields );
  66. SQLRETURN YieldingRemoveIndex( ESchemaCatalog eSchemaCatalog, CRecordInfo *pRecordInfo, const CColumnInfo *pColumnInfo );
  67. SQLRETURN YieldingAlterTableAddColumn( ESchemaCatalog eSchemaCatalog, CRecordInfo *pRecordInfo, const CColumnInfo *pColumnInfo );
  68. SQLRETURN YieldingAddConstraint( ESchemaCatalog eSchemaCatalog, CRecordInfo *pRecordInfo, const CColumnInfo *pColumnInfo, int nColFlagConstraint );
  69. SQLRETURN YieldingRemoveConstraint( ESchemaCatalog eSchemaCatalog, CRecordInfo *pRecordInfo, const CColumnInfo *pColumnInfo, int nColFlagConstraint );
  70. SQLRETURN YieldingChangeColumnTypeOrLength( ESchemaCatalog eSchemaCatalog, CRecordInfo *pRecordInfo, const CColumnInfo *pColumnInfoDesired );
  71. SQLRETURN YieldingChangeColumnProperties( ESchemaCatalog eSchemaCatalog, CRecordInfo *pRecordInfo, const CColumnInfo *pColumnInfoActual, const CColumnInfo *pColumnInfoDesired );
  72. SQLRETURN YieldingCreateTrigger( ESchemaCatalog eSchemaCatalog, CTriggerInfo &refTriggerInfo );
  73. SQLRETURN YieldingDropTrigger( ESchemaCatalog eSchemaCatalog, CTriggerInfo &refTriggerInfo );
  74. CUtlMap<int,EGCSQLType> m_mapSQLTypeToEType;
  75. int m_iTableCount;
  76. };
  77. } // namespace GCSDK
  78. #endif // UPDATESCHEMA_H