?? myldbtypes.pas
字號:
unit MYLDBTypes;
interface
{$I MYLDBVer.inc}
uses
SysUtils, Classes, Windows,
// MYLDBoluteDatabase units
{$IFDEF DEBUG_LOG}
MYLDBDebug,
{$ENDIF}
MYLDBSecurity,
MYLDBMemory,
MYLDBConst,
MYLDBExcept;
type
//------------------------------------------------------------------------------
// general types
//------------------------------------------------------------------------------
TMYLDBErrorCode = Integer;
TMYLDBPageNo = Integer;
PMYLDBPageNo = ^TMYLDBPageNo;
TMYLDBPageBuffer = PChar;
TMYLDBGetRecordMode = (grmCurrent, grmNext, grmPrior);
TMYLDBGetRecordResult = (grrOK, grrBOF, grrEOF, grrError);
TMYLDBBLOBOpenMode = (bomWrite, bomRead, bomReadWrite);
TMYLDBRecordBuffer = PChar;
TMYLDBState = Integer;
TMYLDBObjectID = Integer;
TMYLDBTableID = TMYLDBObjectID;
TMYLDBObjectName = ShortString;
TMYLDBSessionID = Integer;
TMYLDBRecordNo = Int64;
TMYLDBPageItemID = packed record
PageNo: TMYLDBPageNo; // page number or record number (disk engine or memory, temporary engine)
PageItemNo: Word;
end;
PMYLDBPageItemID = ^TMYLDBPageItemID;
TMYLDBRecordID = TMYLDBPageItemID;
PMYLDBRecordID = ^TMYLDBRecordID;
{ Paradox graphic BLOB header }
type
TGraphicHeader = record
Count: Word; { Fixed at 1 }
HType: Word; { Fixed at $0100 }
Size: Longint; { Size not including header }
end;
//------------------------------------------------------------------------------
// disk types
//------------------------------------------------------------------------------
TMYLDBPageRecordCount = Word;
PMYLDBPageRecordCount = ^TMYLDBPageRecordCount;
TMYLDBDBFileType = (dbftUnknown,dbftTablesList,dbftActiveSessionsList);
TMYLDBLockType = (ltIS,ltS,ltSIRW,ltXIRW,ltRW,ltU,ltX); // U - record lock
const LocksCompatible: array [ltIS..ltX, ltIS..ltX] of Boolean =
(
//IS S SIRW XIRW RW U X
{IS} (True, True, True, True, True, True, False),
{S} (True, True, True, True, False, True, False),
{SIRW} (True, True, True, False, True, True, False),
{XIRW} (True, True, False, False, False, True, False),
{RW} (True, False, True, False, False, True, False),
{U} (True, True, True, True, True, True, False),
{X} (False, False, False, False, False, False, False)
);
// SIRW-SIRW, SIRW-XIRW compatibility have some exceptions from this table
type
//TMYLDBLockType = (ltIS = 0,ltS = 1,ltIRW = 2,ltRW = 3,ltU = 4,ltX = 5);
TMYLDBLockObjectType = (lotDatabase,lotTable,lotRecord);
TMYLDBTablePageType = (tptRowStart,tptRowContinue,tptVarchar,tptBLOB);
PMYLDBDBHeader = ^TMYLDBDBHeader;
TMYLDBDBHeader = packed record
Signature: Array [0..15] of Char;
HeaderSize: Smallint;
Version: Double;
PageSize: Word;
PageCountInExtent:Word;
TotalPageCount: TMYLDBPageNo;
LastUsedPageNo: TMYLDBPageNo;
State: Integer;
WriteChangesState:Byte;
Encrypted: ByteBool;
Reserved: array [1..32] of Byte;
end;
TMYLDBCryptoHeader = packed record
CryptoHeaderSize: Smallint;
CryptoAlgorithm: Byte;
CryptoMode: Byte;
ControlBlock: array [0..MYLDB_CONTROL_BLOCK_SIZE-1] of Byte;
ControlBlockCRC: Cardinal;
Reserverd: array [1..16] of Byte;
end;
TMYLDBLockedBytes = packed record
LockedByteSize: Smallint;
FSMByte: Byte;
TablesByte: Byte;
DBHeaderByte: Byte;
Reserved: array [1..15] of Byte;
end;
TMYLDBLastObjectID = Integer;
TMYLDBPageTypeID = Word;
TMYLDBDiskPageHeader = packed record
Signature: Array [0..3] of Char;
State: Integer;
PageType: TMYLDBPageTypeID;
NextPageNo: TMYLDBPageNo;
CRC32: Longword;
CRCType: Byte;
HashType: Byte;
Cipherype: Byte;
MACType: Byte;
ObjectID: TMYLDBObjectID;
RecordID: TMYLDBRecordID;
Reserved: Array [0..7] of Byte;
end; // 40 bytes
PMYLDBDiskPageHeader = ^TMYLDBDiskPageHeader;
// MYLDBDatabaseFile Mode Types
TMYLDBShareMode = (smExclusive, smShareDenyNone, smShareDenyWrite);
TMYLDBAccessMode = (amReadOnly, amReadWrite);
// Any list header
PMYLDBListHeader = ^TMYLDBListHeader;
TMYLDBListHeader = packed record
Count: Integer;
ItemSize: Integer;
NextPageNo: TMYLDBPageNo; // or INVALID_PAGE_NO
end;// 12 byte
// Header for internal file
PMYLDBInternalFileHeader = ^TMYLDBInternalFileHeader;
TMYLDBInternalFileHeader = packed record
FileHeaderSize: Byte;
FileSize: Integer;
DecompressedSize: Integer;
CompressionAlgorithm: Byte;
end;
// System Directory List Item
TMYLDBSystemDirectoryListItem = packed record
FileID: TMYLDBDBFileType;
FirstPageNo: TMYLDBPageNo;
end;// 6 byte
// Table List Item
PMYLDBTableListItem = ^TMYLDBTableListItem;
TMYLDBTableListItem = packed record
TableName: ShortString;
TableID: TMYLDBTableID;
MetaDataFilePageNo: TMYLDBPageNo;
MostUpdatedFilePageNo: TMYLDBPageNo;
LocksFilePageNo: TMYLDBPageNo;
end;
TMYLDBTablePFSPageMapItem = packed record
PageNo: TMYLDBPageNo;
PageRecordCount: TMYLDBPageRecordCount;
end;
TMYLDBLockParams = record
SessionID: Integer;
LockType: TMYLDBLockType;
ObjectType: TMYLDBLockObjectType;
RowID: TMYLDBPageItemID;
TableID: TMYLDBObjectID;
end;
//------------------------------------------------------------------------------
// SQL types
//------------------------------------------------------------------------------
// join type
TMYLDBJoinType = (ajtCross, ajtInner, ajtLeftOuter,
ajtRightOuter, ajtFullOuter);
// union type
TMYLDBUnionType = (autUnion, autIntersect, autExcept);
// table | joined table | subquery
TMYLDBTableType = (attTable, attJoinedTable, attSubQuery);
// table | joined table | subquery
TMYLDBQueryExprType = (qetSelect, qetUnion, qetExcept, qetIntersect);
TMYLDBBatchMoveType = (bmtAppend, bmtAppendUpdate, bmtCopy, bmtDelete, bmtUpdate, bmtSynchronize);
// field types
TMYLDBBaseFieldType = (
bftUnknown,
bftChar,
bftWideChar,
bftVarchar,
bftWideVarchar,
bftSignedInt8, // Shortint
bftSignedInt16, // Smallint
bftSignedInt32, // Integer
bftSignedInt64, // Int64
bftUnsignedInt8, // Byte
bftUnsignedInt16, // Word
bftUnsignedInt32, // Cardinal
//bftUnSignedInt64,
bftSingle,
bftDouble,
bftExtended,
bftDate,
bftTime,
bftDateTime,
bftBlob,
bftClob,
bftWideClob,
bftLogical,
bftCurrency,
bftBytes,
bftVarBytes,
//bftTimeStamp, == bftDateTime
bftBFile
);
TMYLDBAdvancedFieldType = (
aftUnknown,
aftChar, // = bftChar
aftString, // = bftVarChar
aftWideChar, // = bftChar
aftWideString, // = bftWideVarChar
aftShortint, // = bftSignedInt8
aftSmallint, // = bftSignedInt16
aftInteger, // = bftSignedInt32
aftLargeint, // = bftSignedInt64
aftByte, // = bftUnsignedInt8
aftWord, // = bftUnsignedInt16
aftCardinal, // = bftUnsignedInt32
aftAutoInc, // = bftSignedInt32
aftAutoIncShortint, // = bftSignedInt8
aftAutoIncSmallint, // = bftSignedInt16
aftAutoIncInteger, // = bftSignedInt32
aftAutoIncLargeint, // = bftSignedInt64
aftAutoIncByte, // = bftUnsignedInt8
aftAutoIncWord, // = bftUnsignedInt16
aftAutoIncCardinal, // = bftUnsignedInt32
aftSingle, // = bftSingle
aftDouble, // = bftDouble
aftExtended, // = bftExtended
aftBoolean, // = bftLogical
aftCurrency, // = bftCurrency
aftDate, // = bftDate
aftTime, // = bftTime
aftDateTime, // = bftDateTime
aftTimeStamp, // = bftDateTime
aftBytes, // = bftBytes
aftVarBytes, // = bftVarBytes
aftBlob, // = bftBlob
aftGraphic, // = bftBlob
aftMemo, // = bftClob
aftFormattedMemo, // = bftClob
aftWideMemo, // = bftWideClob
aftGuid // = bftChar(38)
//aftArray,
// aftParadoxOle,
// aftDBaseOle,
// aftTypedBinary,
// aftCursor,
// aftReference,
// aftDataSet,
// aftVariant,
// aftInterface,
// aftIDispatch,
);
//TMYLDBDefaultValueType = (dvtNull, dvtConst, dvtSequence, dvtFunction, dvtQuery);
TMYLDBConstraintType = (ctPK, ctFK, ctUnique, ctNotNull, ctCheck);
TMYLDBCompareResult = (cmprEqual, cmprLower, cmprGreater,
cmprLeftNull, cmprRightNull, cmprBothNull);
// unary / binary Value operators
TMYLDBDataOperator = (
doUNDEFINED, // error
//George doCMP, // compare <0,=0,>0
{Comparison}
doEQ, // equal
doNE, // NOT equal
doGT, // greater than
doLT, // less than
doGE, // greater or equal
doLE, // less or equal
{Boolean}
doNOT, // NOT
doAND, // AND
doOR, // OR
doIN, // in (a,b,c, ...)
doNOTIN, // not in (a,b,c, ...)
doEXISTS, // exists (subquery)
doBETWEEN, // between (a,b)
doNOTBETWEEN, // not between (a,b)
doLIKE, // like 'a?b%'
doNOTLIKE, // not like
doISNULL, // is null
doISNOTNULL, // is not null
doTRUE, // TRUE const
doFALSE, // FALSE const
{Arithmetic}
doADD, // addition
doSUB, // subtraction
doMUL, // multiplication
doDIV, // division
{Functions}
//doPOSITION, // Position (str1) in (str2)
doCONCAT, // str1 || str2
doUPPER, // Upper(str)
doLOWER, // Lower(str)
doTRIM, // TRIM
doLTRIM, // LTRIM
doRTRIM, // RTRIM
doLENGTH, // LENGTH(str)
doPOS, // POS(substr in|, str) { 1 - first char, 0 - not found }
doSUBSTRING, // SUBSTRING(str from|, startindex [for|, length])
{aggregated functions}
doSUM, // SUM([distinct]expression)
doAVG, // AVG([distinct]expression)
doMIN, // min(expression)
doMAX, // max(expression)
doCOUNT, // COUNT([distinct]expression)
doCOUNTALL, // count(*)
{datetime functions}
doSYSDATE, // SYSDATE - return current DateTime
doCURRENT_DATE, // CURRENT_DATE
doCURRENT_TIME, // CURRENT_TIME
doTODATE, // TODATE(string, format)
doTOSTRING, // TOSTRING(date, format)
doEXTRACT, // EXTRACT (YEAR FROM datetime_field)
{cast types}
doCAST, // Cast(expression, type)
{system}
doLASTAUTOINC,
{blob}
doMIMETOBIN, // MimeToBin(MimeString)
doROWNUM, // selected row number (iterated)
{math}
doMYLDB, // ABS(number)
doACOS,
doASIN,
doATAN,
doCEIL,
doCOS,
doEXP,
doFLOOR,
doLOG,
doPOWER,
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -