Extra Systems Database
unit common;

interface

const
     ESDB_COMMAND_CREATE_DATABASE                 =  1;
     ESDB_COMMAND_CONNECT_DATABASE                =  2;
     ESDB_COMMAND_RELEASE_DATABASE                =  3;
     ESDB_COMMAND_CREATE_TABLE                    =  4;
     ESDB_COMMAND_OPEN_TABLE                      =  5;
     ESDB_COMMAND_CLOSE_TABLE                     =  6;
     ESDB_COMMAND_DROP_DATABASE                   =  7;
     ESDB_COMMAND_DATABASE_LOCAL_BACKUP           =  8;
     ESDB_COMMAND_DATABASE_REMOTE_BACKUP          =  9;
     ESDB_QUERY_TABLE_TOTAL_RECORDS_COUNT         = 11;
     ESDB_QUERY_TABLE_REAL_RECORDS_COUNT          = 12;
     ESDB_QUERY_TABLE_GET_STRUCTURE               = 13;
     ESDB_COMMAND_TABLE_APPEND_RECORD             = 14;
     ESDB_COMMAND_TABLE_GET_THIS_RECORD           = 17;
     ESDB_COMMAND_TABLE_SET_THIS_RECORD           = 20;
     ESDB_COMMAND_TABLE_DELETE_THIS_RECORD        = 23;
     ESDB_COMMAND_DATABASE_GETSTRUCTURE           = 28;
     ESDB_QUERY_GETSERVERINFO                     = 29;
     ESDB_COMMAND_DROP_TABLE                      = 30;
     ESDB_COMMAND_PACK_TABLE                      = 31;

     ESDB_RESULT_OK                               =  1;
     ESDB_RESULT_ERROR_UNKNOWN                    = -1;
     ESDB_RESULT_ERROR_DATABASENOTACTIVE          = -2;
     ESDB_RESULT_ERROR_DATABASEACTIVE             = -3;
     ESDB_RESULT_ERROR_READPARAMS                 = -4;
     ESDB_RESULT_ERROR_OUTOFMEMORY                = -5;
     ESDB_RESULT_ERROR_BADTABLENUMBER             = -6;
     ESDB_RESULT_ERROR_TABLENOTACTIVE             = -7;
     ESDB_RESULT_ERROR_RECORDDELETED              = -8;

     FIELD_TYPE_INTEGER  = 1;
     FIELD_TYPE_CHAR     = 2;
     FIELD_TYPE_DATE     = 3;
     FIELD_TYPE_BLOB     = 4;

     MaxDatabase         = 256;
     MaxTable            = 32;
     MaxFields           = 64;
     MaxIndexPerTable    =  8;

     MaxTableNameLength  = 32;
     MaxFieldNameLength  = 24;
     MaxIndexNameLength  = 24;
     MaxIndexKeyLength   = 1024;

     PageSize            = 1024;
     MaxDiskFile         = MaxDatabase;

type

     TESDBServerInfo = record
          TotalThreadsCount        : Integer;
          ActiveThreadsCount       : Integer;
          TotalDatabasesCount      : Integer;
          ActiveDatabasesCount     : Integer;
          TotalTablesCount         : Integer;
          ActiveTablesCount        : Integer;
          TotalDatasetsCount       : Integer;
          ActiveDatasetsCount      : Integer;
     end;

     TFieldDescriptor = record
          FieldType      : Integer;
          FieldLength    : Integer;
          FieldName      : array[1..MaxFieldNameLength] of Char;
     end;

     PFieldDescriptor = ^TFieldDescriptor;

     TESDBTableItem   = packed record
          TableName           : array[1..MaxTableNameLength] of Char;
          FieldsCount         : Integer;
          TotalRecordsCount   : Integer;
          RealRecordsCount    : Integer;
          IndexesCount        : Integer;
     end;

     TESDBBlob = record
          BlobPage  : Integer;
          BlobSize  : Integer;
     end;

     PESDBBlob = ^TESDBBlob;


implementation

end.