mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
* Fix compiler warnings due to implicit AnsiString to (Unicode)String or vice versa
* Remove workaround for Unicode text to and from clipboard * Fix writing/reading wrong encoded text into/from registry - no need to use Utf8Encode() any longer * Implement TMySQLQuery.ColAsAnsi() for cases in which we read binary data.
This commit is contained in:
@ -35,8 +35,8 @@ type
|
||||
procedure SetModified(NewVal: Boolean);
|
||||
property Modified: Boolean read FModified write SetModified;
|
||||
public
|
||||
function GetText: WideString;
|
||||
procedure SetText(text: WideString);
|
||||
function GetText: String;
|
||||
procedure SetText(text: String);
|
||||
procedure SetMaxLength(len: integer);
|
||||
procedure SetFont(font: TFont);
|
||||
end;
|
||||
@ -48,12 +48,12 @@ implementation
|
||||
{$R *.dfm}
|
||||
|
||||
|
||||
function TfrmBinEditor.GetText: WideString;
|
||||
function TfrmBinEditor.GetText: String;
|
||||
begin
|
||||
Result := '0x' + memoText.Text;
|
||||
end;
|
||||
|
||||
procedure TfrmBinEditor.SetText(text: WideString);
|
||||
procedure TfrmBinEditor.SetText(text: String);
|
||||
begin
|
||||
// Skip '0x'.
|
||||
memoText.Text := Copy(text, 3);
|
||||
|
@ -85,7 +85,7 @@ type
|
||||
FSessionNames: TStringlist;
|
||||
FSessionModified, FSessionAdded: Boolean;
|
||||
FOrgNetType: Byte;
|
||||
FOrgHost, FOrgUser, FOrgPassword: WideString;
|
||||
FOrgHost, FOrgUser, FOrgPassword: String;
|
||||
FOrgCompressed: Boolean;
|
||||
FOrgPort: Integer;
|
||||
FWidthListSessions: Byte; // Percentage values
|
||||
|
@ -37,7 +37,7 @@ type
|
||||
procedure chkSelectAllClick(Sender: TObject);
|
||||
private
|
||||
{ Private declarations }
|
||||
oldTableName : WideString;
|
||||
oldTableName : String;
|
||||
public
|
||||
{ Public declarations }
|
||||
end;
|
||||
@ -158,12 +158,12 @@ end;
|
||||
|
||||
procedure TCopyTableForm.ButtonOKClick(Sender: TObject);
|
||||
var
|
||||
strquery : WideString;
|
||||
strquery : String;
|
||||
i,which,k : Integer;
|
||||
keylist : Array of TMyKey;
|
||||
keystr : WideString;
|
||||
keystr : String;
|
||||
notnull,
|
||||
default : WideString;
|
||||
default : String;
|
||||
Results : TMySQLQuery;
|
||||
isFulltext : Boolean;
|
||||
struc_data : Byte;
|
||||
|
@ -26,7 +26,7 @@ type
|
||||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
function GetCreateStatement: WideString;
|
||||
function GetCreateStatement: String;
|
||||
private
|
||||
{ Private declarations }
|
||||
CollationTable: TMySQLQuery;
|
||||
@ -34,7 +34,7 @@ type
|
||||
currentCollation : String;
|
||||
public
|
||||
{ Public declarations }
|
||||
modifyDB : WideString;
|
||||
modifyDB : String;
|
||||
end;
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ procedure TCreateDatabaseForm.FormShow(Sender: TObject);
|
||||
var
|
||||
selectCharset,
|
||||
currentCharset,
|
||||
sql_create : WideString;
|
||||
sql_create : String;
|
||||
Charset: String;
|
||||
colpos: Integer;
|
||||
begin
|
||||
@ -101,14 +101,14 @@ begin
|
||||
|
||||
// Detect current charset and collation to be able to preselect them in the pulldowns
|
||||
sql_create := Mainform.Connection.GetVar('SHOW CREATE DATABASE '+Mainform.mask(modifyDB), 1);
|
||||
currentCharset := Copy( sql_create, pos(WideString('CHARACTER SET'), sql_create)+14, Length(sql_create));
|
||||
currentCharset := Copy( sql_create, pos('CHARACTER SET', sql_create)+14, Length(sql_create));
|
||||
currentCharset := GetFirstWord( currentCharset );
|
||||
if currentCharset <> '' then
|
||||
selectCharset := currentCharset
|
||||
else
|
||||
selectCharset := defaultCharset;
|
||||
currentCollation := '';
|
||||
colpos := pos(WideString('COLLATE'), sql_create);
|
||||
colpos := pos('COLLATE', sql_create);
|
||||
if colpos > 0 then begin
|
||||
currentCollation := Copy( sql_create, colpos+8, Length(sql_create));
|
||||
currentCollation := GetFirstWord( currentCollation );
|
||||
@ -203,7 +203,7 @@ end;
|
||||
}
|
||||
procedure TCreateDatabaseForm.btnOKClick(Sender: TObject);
|
||||
var
|
||||
sql : WideString;
|
||||
sql : String;
|
||||
AllDatabases, Unions, ObjectsLeft: TWideStringList;
|
||||
ObjectsInNewDb, ObjectsInOldDb: TDBObjectList;
|
||||
i, j: Integer;
|
||||
@ -315,7 +315,7 @@ end;
|
||||
{**
|
||||
Generate CREATE DATABASE statement, used for preview and execution
|
||||
}
|
||||
function TCreateDatabaseForm.GetCreateStatement: WideString;
|
||||
function TCreateDatabaseForm.GetCreateStatement: String;
|
||||
begin
|
||||
Result := 'CREATE DATABASE ' + Mainform.mask( editDBName.Text );
|
||||
if comboCharset.Enabled and (comboCharset.Text <> '') then
|
||||
|
@ -20,7 +20,7 @@ type
|
||||
{ Private declarations }
|
||||
public
|
||||
{ Public declarations }
|
||||
VarName, VarValue: WideString;
|
||||
VarName, VarValue: String;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@ -50,7 +50,7 @@ end;
|
||||
}
|
||||
procedure TfrmEditVariable.btnOKClick(Sender: TObject);
|
||||
var
|
||||
sql: WideString;
|
||||
sql: String;
|
||||
begin
|
||||
// Syntax taken from http://dev.mysql.com/doc/refman/4.1/en/using-system-variables.html
|
||||
sql := 'SET @@';
|
||||
|
@ -38,7 +38,7 @@ type
|
||||
function BeginEdit: Boolean; virtual; stdcall;
|
||||
function CancelEdit: Boolean; virtual; stdcall;
|
||||
function EndEdit: Boolean; virtual; stdcall; abstract;
|
||||
function EndEditHelper(NewText: WideString): Boolean;
|
||||
function EndEditHelper(NewText: String): Boolean;
|
||||
function GetBounds: TRect; virtual; stdcall; // Normally useless and unused
|
||||
procedure ProcessMessage(var Message: TMessage); stdcall;
|
||||
procedure SetBounds(R: TRect); virtual; stdcall; abstract;
|
||||
@ -142,7 +142,7 @@ type
|
||||
procedure TextChange(Sender: TObject);
|
||||
public
|
||||
DefaultType: TColumnDefaultType;
|
||||
DefaultText: WideString;
|
||||
DefaultText: String;
|
||||
constructor Create(Tree: TVirtualStringTree); override;
|
||||
destructor Destroy; override;
|
||||
function BeginEdit: Boolean; override;
|
||||
@ -176,8 +176,8 @@ type
|
||||
procedure SetBounds(R: TRect); override;
|
||||
end;
|
||||
|
||||
function GetColumnDefaultType(var Text: WideString): TColumnDefaultType;
|
||||
function GetColumnDefaultClause(DefaultType: TColumnDefaultType; Text: WideString): WideString;
|
||||
function GetColumnDefaultType(var Text: String): TColumnDefaultType;
|
||||
function GetColumnDefaultClause(DefaultType: TColumnDefaultType; Text: String): String;
|
||||
|
||||
|
||||
implementation
|
||||
@ -279,7 +279,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TBaseGridEditorLink.EndEditHelper(NewText: WideString): Boolean;
|
||||
function TBaseGridEditorLink.EndEditHelper(NewText: String): Boolean;
|
||||
begin
|
||||
Result := not FStopping;
|
||||
if FStopping then Exit;
|
||||
@ -501,7 +501,7 @@ end;
|
||||
function TDateTimeEditorLink.PrepareEdit(Tree: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex): Boolean; stdcall;
|
||||
var
|
||||
MinColWidth: Integer;
|
||||
CellText: WideString;
|
||||
CellText: String;
|
||||
begin
|
||||
Result := inherited PrepareEdit(Tree, Node, Column);
|
||||
if not Result then
|
||||
@ -788,7 +788,7 @@ end;
|
||||
|
||||
function TSetEditorLink.EndEdit: Boolean; stdcall;
|
||||
var
|
||||
newtext: WideString;
|
||||
newtext: String;
|
||||
i: Integer;
|
||||
begin
|
||||
Result := not FStopping;
|
||||
@ -908,7 +908,7 @@ end;
|
||||
|
||||
function TInplaceEditorLink.EndEdit: Boolean;
|
||||
var
|
||||
NewText: WideString;
|
||||
NewText: String;
|
||||
begin
|
||||
Result := not FStopping;
|
||||
if FStopping then Exit;
|
||||
@ -1133,7 +1133,7 @@ end;
|
||||
|
||||
function TColumnDefaultEditorLink.EndEdit: Boolean; stdcall;
|
||||
var
|
||||
newText: WideString;
|
||||
newText: String;
|
||||
newDefaultType: TColumnDefaultType;
|
||||
begin
|
||||
Result := not FStopping;
|
||||
@ -1190,14 +1190,14 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function GetColumnDefaultType(var Text: WideString): TColumnDefaultType;
|
||||
function GetColumnDefaultType(var Text: String): TColumnDefaultType;
|
||||
begin
|
||||
Result := TColumnDefaultType(MakeInt(Copy(Text, 1, 1)));
|
||||
Text := Copy(Text, 2, Length(Text)-1);
|
||||
end;
|
||||
|
||||
|
||||
function GetColumnDefaultClause(DefaultType: TColumnDefaultType; Text: WideString): WideString;
|
||||
function GetColumnDefaultClause(DefaultType: TColumnDefaultType; Text: String): String;
|
||||
begin
|
||||
case DefaultType of
|
||||
cdtNothing: Result := '';
|
||||
@ -1381,7 +1381,7 @@ end;
|
||||
procedure TDataTypeEditorLink.DoTreeSelectHotChange(Sender: TBaseVirtualTree; OldNode, NewNode: PVirtualNode);
|
||||
var
|
||||
R: TRect;
|
||||
NodeText: WideString;
|
||||
NodeText: String;
|
||||
bmp: TBitMap;
|
||||
begin
|
||||
// Display help box for hovered datatype
|
||||
|
@ -31,25 +31,17 @@ type
|
||||
|
||||
TFileCharset = (fcsAnsi, fcsUnicode, fcsUnicodeSwapped, fcsUtf8);
|
||||
|
||||
TUniClipboard = class(TClipboard)
|
||||
private
|
||||
procedure SetAsWideString(Value: WideString);
|
||||
function GetAsWideString:WideString;
|
||||
public
|
||||
property AsWideString: WideString read GetAsWideString write SetAsWideString;
|
||||
end;
|
||||
|
||||
// Structures for result grids, mapped from a TMySQLQuery to some handy VirtualTree structure
|
||||
TGridCell = record
|
||||
Text: WideString;
|
||||
NewText: WideString; // Used to create UPDATE clauses with needed columns
|
||||
Text: String;
|
||||
NewText: String; // Used to create UPDATE clauses with needed columns
|
||||
IsNull: Boolean;
|
||||
NewIsNull: Boolean;
|
||||
Modified: Boolean;
|
||||
end;
|
||||
PGridCell = ^TGridCell;
|
||||
TGridColumn = record
|
||||
Name: WideString;
|
||||
Name: String;
|
||||
Datatype: TDatatypeIndex; // @see mysql_structures.pas
|
||||
DatatypeCat: TDatatypeCategoryIndex;
|
||||
MaxLength: Cardinal;
|
||||
@ -80,7 +72,7 @@ type
|
||||
end;
|
||||
|
||||
TOrderCol = class(TObject)
|
||||
ColumnName: WideString;
|
||||
ColumnName: String;
|
||||
SortDirection: Byte;
|
||||
end;
|
||||
TOrderColArray = Array of TOrderCol;
|
||||
@ -101,13 +93,13 @@ type
|
||||
|
||||
// Column object, many of them in a TObjectList
|
||||
TTableColumn = class(TObject)
|
||||
Name, OldName: WideString;
|
||||
Name, OldName: String;
|
||||
DataType: TDatatype;
|
||||
LengthSet: WideString;
|
||||
LengthSet: String;
|
||||
Unsigned, AllowNull: Boolean;
|
||||
DefaultType: TColumnDefaultType;
|
||||
DefaultText: WideString;
|
||||
Comment, Collation: WideString;
|
||||
DefaultText: String;
|
||||
Comment, Collation: String;
|
||||
FStatus: TEditingStatus;
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
@ -119,7 +111,7 @@ type
|
||||
PTableColumn = ^TTableColumn;
|
||||
|
||||
TTableKey = class(TObject)
|
||||
Name, OldName: WideString;
|
||||
Name, OldName: String;
|
||||
IndexType: String;
|
||||
Columns, SubParts: TWideStringlist;
|
||||
Modified, Added: Boolean;
|
||||
@ -130,7 +122,7 @@ type
|
||||
|
||||
// Helper object to manage foreign keys in a TObjectList
|
||||
TForeignKey = class(TObject)
|
||||
KeyName, ReferenceTable, OnUpdate, OnDelete: WideString;
|
||||
KeyName, ReferenceTable, OnUpdate, OnDelete: String;
|
||||
Columns, ForeignColumns: TWideStringList;
|
||||
Modified, Added: Boolean;
|
||||
constructor Create;
|
||||
@ -142,11 +134,11 @@ type
|
||||
FModified: Boolean;
|
||||
procedure SetModified(Value: Boolean);
|
||||
protected
|
||||
FEditObjectName: WideString;
|
||||
FEditObjectName: String;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
procedure Init(ObjectName: WideString=''; ObjectType: TListNodeType=lntNone); virtual;
|
||||
procedure Init(ObjectName: String=''; ObjectType: TListNodeType=lntNone); virtual;
|
||||
procedure DeInit;
|
||||
property Modified: Boolean read FModified write SetModified;
|
||||
procedure ApplyModifications; virtual; abstract;
|
||||
@ -155,30 +147,29 @@ type
|
||||
|
||||
{$I const.inc}
|
||||
|
||||
function implodestr(seperator: WideString; a: TWideStringList) :WideString;
|
||||
function explode(separator, a: WideString) :TWideStringList;
|
||||
procedure ExplodeQuotedList(Text: WideString; var List: TWideStringList);
|
||||
function implodestr(seperator: String; a: TWideStringList) :String;
|
||||
function explode(separator, a: String) :TWideStringList;
|
||||
procedure ExplodeQuotedList(Text: String; var List: TWideStringList);
|
||||
procedure ensureValidIdentifier(name: String);
|
||||
function getEnumValues(str: WideString): WideString;
|
||||
function getEnumValues(str: String): String;
|
||||
function IsWhitespace(const c: WideChar): Boolean;
|
||||
function IsLetter(const c: WideChar): Boolean;
|
||||
function IsNumber(const c: WideChar): Boolean;
|
||||
function parsesql(sql: WideString) : TWideStringList;
|
||||
function sstr(str: WideString; len: Integer) : WideString;
|
||||
function parsesql(sql: String) : TWideStringList;
|
||||
function sstr(str: String; len: Integer) : String;
|
||||
function encrypt(str: String): String;
|
||||
function decrypt(str: String): String;
|
||||
function htmlentities(str: WideString): WideString;
|
||||
procedure GridToHtml(Grid: TVirtualStringTree; Title: WideString; S: TStream);
|
||||
function htmlentities(str: String): String;
|
||||
procedure GridToHtml(Grid: TVirtualStringTree; Title: String; S: TStream);
|
||||
procedure GridToCsv(Grid: TVirtualStringTree; Separator, Encloser, Terminator: String; S: TStream);
|
||||
procedure GridToXml(Grid: TVirtualStringTree; root: WideString; S: TStream);
|
||||
procedure GridToSql(Grid: TVirtualStringTree; Tablename: WideString; S: TStream);
|
||||
procedure GridToXml(Grid: TVirtualStringTree; root: String; S: TStream);
|
||||
procedure GridToSql(Grid: TVirtualStringTree; Tablename: String; S: TStream);
|
||||
function esc2ascii(str: String): String;
|
||||
function StrCmpBegin(Str1, Str2: string): Boolean;
|
||||
function Max(A, B: Integer): Integer; assembler;
|
||||
function Min(A, B: Integer): Integer; assembler;
|
||||
function urlencode(url: String): String;
|
||||
procedure StreamWrite(S: TStream; Text: WideString = '');
|
||||
function fixSQL( sql: WideString; sql_version: Integer = SQL_VERSION_ANSI; cli_workarounds: Boolean = false ): WideString;
|
||||
procedure StreamWrite(S: TStream; Text: String = '');
|
||||
function fixSQL( sql: String; sql_version: Integer = SQL_VERSION_ANSI; cli_workarounds: Boolean = false ): String;
|
||||
procedure ToggleCheckListBox(list: TCheckListBox; state: Boolean); Overload;
|
||||
procedure ToggleCheckListBox(list: TCheckListBox; state: Boolean; list_toggle: TWideStringList); Overload;
|
||||
function _GetFileSize(filename: String): Int64;
|
||||
@ -186,12 +177,12 @@ type
|
||||
function MakeInt( Str: String ) : Int64;
|
||||
function MakeFloat( Str: String ): Extended;
|
||||
function CleanupNumber(Str: String): String;
|
||||
function esc(Text: WideString; ProcessJokerChars: Boolean=false): WideString;
|
||||
function ScanNulChar(Text: WideString): Boolean;
|
||||
function ScanLineBreaks(Text: WideString): TLineBreaks;
|
||||
function RemoveNulChars(Text: WideString): WideString;
|
||||
function esc(Text: String; ProcessJokerChars: Boolean=false): String;
|
||||
function ScanNulChar(Text: String): Boolean;
|
||||
function ScanLineBreaks(Text: String): TLineBreaks;
|
||||
function RemoveNulChars(Text: String): String;
|
||||
procedure debug(txt: String);
|
||||
function fixNewlines(txt: Widestring): Widestring;
|
||||
function fixNewlines(txt: String): String;
|
||||
function GetShellFolder(CSIDL: integer): string;
|
||||
function getFilesFromDir( dir: String; pattern: String = '*.*'; hideExt: Boolean = false ): TStringList;
|
||||
function goodfilename( str: String ): String;
|
||||
@ -202,7 +193,7 @@ type
|
||||
procedure setLocales;
|
||||
procedure ShellExec(cmd: String; path: String=''; params: String='');
|
||||
function getFirstWord( text: String ): String;
|
||||
function LastPos(needle: WideChar; haystack: WideString): Integer;
|
||||
function LastPos(needle: WideChar; haystack: String): Integer;
|
||||
function FormatByteNumber( Bytes: Int64; Decimals: Byte = 1 ): String; Overload;
|
||||
function FormatByteNumber( Bytes: String; Decimals: Byte = 1 ): String; Overload;
|
||||
function FormatTimeNumber( Seconds: Cardinal ): String;
|
||||
@ -210,20 +201,19 @@ type
|
||||
procedure SetVTSelection( VT: TVirtualStringTree; Selected: TWideStringList );
|
||||
function GetTempDir: String;
|
||||
procedure SetWindowSizeGrip(hWnd: HWND; Enable: boolean);
|
||||
procedure SaveUnicodeFile(Filename: String; Text: WideString);
|
||||
procedure SaveUnicodeFile(Filename: String; Text: String);
|
||||
procedure OpenTextFile(const Filename: String; out Stream: TFileStream; out FileCharset: TFileCharset);
|
||||
function GetFileCharset(Stream: TFileStream): TFileCharset;
|
||||
function ReadTextfileChunk(Stream: TFileStream; FileCharset: TFileCharset; ChunkSize: Int64 = 0): WideString;
|
||||
function ReadTextfile(Filename: String): WideString;
|
||||
function ReadBinaryFile(Filename: String; MaxBytes: Int64): string;
|
||||
procedure CopyToClipboard(Value: WideString);
|
||||
function ReadTextfileChunk(Stream: TFileStream; FileCharset: TFileCharset; ChunkSize: Int64 = 0): String;
|
||||
function ReadTextfile(Filename: String): String;
|
||||
function ReadBinaryFile(Filename: String; MaxBytes: Int64): AnsiString;
|
||||
procedure StreamToClipboard(S: TMemoryStream);
|
||||
function WideHexToBin(text: WideString): AnsiString;
|
||||
function BinToWideHex(bin: AnsiString): WideString;
|
||||
procedure CheckHex(text: WideString; errorMessage: string);
|
||||
function WideHexToBin(text: String): AnsiString;
|
||||
function BinToWideHex(bin: AnsiString): String;
|
||||
procedure CheckHex(text: String; errorMessage: string);
|
||||
procedure FixVT(VT: TVirtualStringTree);
|
||||
function ColorAdjustBrightness(Col: TColor; Shift: SmallInt; BestFit: Boolean): TColor;
|
||||
function ComposeOrderClause(Cols: TOrderColArray): WideString;
|
||||
function ComposeOrderClause(Cols: TOrderColArray): String;
|
||||
procedure OpenRegistry(Session: String = '');
|
||||
function GetRegValue( valueName: String; defaultValue: Integer; Session: String = '' ) : Integer; Overload;
|
||||
function GetRegValue( valueName: String; defaultValue: Boolean; Session: String = '' ) : Boolean; Overload;
|
||||
@ -231,15 +221,15 @@ type
|
||||
procedure DeInitializeVTNodes(Sender: TBaseVirtualTree);
|
||||
procedure EnableProgressBar(MaxValue: Integer);
|
||||
function CompareNumbers(List: TStringList; Index1, Index2: Integer): Integer;
|
||||
function ListIndexByRegExpr(List: TStrings; Expression: WideString): Integer;
|
||||
function ListIndexByRegExpr(List: TStrings; Expression: String): Integer;
|
||||
procedure SelectNode(VT: TVirtualStringTree; idx: Cardinal; ParentNode: PVirtualNode=nil); overload;
|
||||
procedure SelectNode(VT: TVirtualStringTree; Node: PVirtualNode); overload;
|
||||
function DateBackFriendlyCaption(d: TDateTime): String;
|
||||
procedure InheritFont(AFont: TFont);
|
||||
function GetLightness(AColor: TColor): Byte;
|
||||
procedure ParseTableStructure(CreateTable: WideString; Columns: TObjectList=nil; Keys: TObjectList=nil; ForeignKeys: TObjectList=nil);
|
||||
procedure ParseViewStructure(ViewName: WideString; Columns: TObjectList);
|
||||
function ReformatSQL(SQL: WideString): WideString;
|
||||
procedure ParseTableStructure(CreateTable: String; Columns: TObjectList=nil; Keys: TObjectList=nil; ForeignKeys: TObjectList=nil);
|
||||
procedure ParseViewStructure(ViewName: String; Columns: TObjectList);
|
||||
function ReformatSQL(SQL: String): String;
|
||||
|
||||
var
|
||||
MainReg : TRegistry;
|
||||
@ -273,25 +263,25 @@ var
|
||||
|
||||
|
||||
|
||||
function WideHexToBin(text: WideString): AnsiString;
|
||||
function WideHexToBin(text: String): AnsiString;
|
||||
var
|
||||
buf: AnsiString;
|
||||
begin
|
||||
buf := AnsiString(text);
|
||||
Result := StringOfChar(' ', Length(text) div 2);
|
||||
SetLength(Result, Length(text) div 2);
|
||||
HexToBin(PAnsiChar(buf), @Result[1], Length(Result));
|
||||
end;
|
||||
|
||||
function BinToWideHex(bin: AnsiString): WideString;
|
||||
function BinToWideHex(bin: AnsiString): String;
|
||||
var
|
||||
buf: AnsiString;
|
||||
begin
|
||||
buf := StringOfChar(' ', Length(bin) * 2);
|
||||
SetLength(buf, Length(bin) * 2);
|
||||
BinToHex(@bin[1], PAnsiChar(buf), Length(bin));
|
||||
Result := buf;
|
||||
Result := String(buf);
|
||||
end;
|
||||
|
||||
procedure CheckHex(text: WideString; errorMessage: string);
|
||||
procedure CheckHex(text: String; errorMessage: string);
|
||||
const
|
||||
allowed: string = '0123456789abcdefABCDEF';
|
||||
var
|
||||
@ -313,7 +303,7 @@ end;
|
||||
@param a TStringList Containing strings
|
||||
@return string
|
||||
}
|
||||
function implodestr(seperator: WideString; a: TWideStringList) :WideString;
|
||||
function implodestr(seperator: String; a: TWideStringList) :String;
|
||||
var
|
||||
i : Integer;
|
||||
begin
|
||||
@ -334,10 +324,10 @@ end;
|
||||
@param string Separator
|
||||
@return TStringList
|
||||
}
|
||||
function explode(separator, a: WideString) :TWideStringList;
|
||||
function explode(separator, a: String) :TWideStringList;
|
||||
var
|
||||
i : Integer;
|
||||
item : WideString;
|
||||
item : String;
|
||||
begin
|
||||
result := TWideStringList.Create;
|
||||
|
||||
@ -435,7 +425,7 @@ end;
|
||||
@param string Type definition, fx: enum('Y','N')
|
||||
@return string Content of brackets
|
||||
}
|
||||
function getEnumValues(str: WideString): WideString;
|
||||
function getEnumValues(str: String): String;
|
||||
var
|
||||
p1,p2 : Integer;
|
||||
begin
|
||||
@ -460,7 +450,7 @@ end;
|
||||
@param string to enclose added string in (use %s)
|
||||
@return void
|
||||
}
|
||||
procedure addResult(list: TWideStringList; s: WideString; enclose: WideString = '');
|
||||
procedure addResult(list: TWideStringList; s: String; enclose: String = '');
|
||||
begin
|
||||
s := trim(s);
|
||||
if length(s) > 0 then begin
|
||||
@ -513,7 +503,7 @@ end;
|
||||
Limitations: in case insensitive mode, input must be ANSI and lower case (for speed).
|
||||
Eligible for inlining, hope the compiler does this automatically.
|
||||
}
|
||||
function scanReverse(const haystack: WideString; hayIndex: integer; const needle: WideString; needleEnd: integer; insensitive: boolean): boolean;
|
||||
function scanReverse(const haystack: String; hayIndex: integer; const needle: String; needleEnd: integer; insensitive: boolean): boolean;
|
||||
var
|
||||
b: word;
|
||||
c: widechar;
|
||||
@ -544,16 +534,16 @@ end;
|
||||
@param String SQL start delimiter
|
||||
@return TStringList Separated statements
|
||||
}
|
||||
function parsesql(sql: WideString) : TWideStringList;
|
||||
function parsesql(sql: String) : TWideStringList;
|
||||
var
|
||||
i, j, start, len : Integer;
|
||||
tmp : WideString;
|
||||
tmp : String;
|
||||
instring, backslash, incomment : Boolean;
|
||||
inconditional, condterminated : Boolean;
|
||||
inbigcomment, indelimiter : Boolean;
|
||||
delimiter_length : Integer;
|
||||
encloser, secchar, thdchar : WideChar;
|
||||
conditional : WideString;
|
||||
conditional : String;
|
||||
begin
|
||||
result := TWideStringList.Create;
|
||||
sql := trim(sql);
|
||||
@ -596,7 +586,7 @@ begin
|
||||
if start = i then start := start + 1;
|
||||
i := i + 1;
|
||||
end;
|
||||
if incomment and (not inbigcomment) and (sql[i] in [WideChar(#13), WideChar(#10)]) then begin
|
||||
if incomment and (not inbigcomment) and CharInSet(sql[i], [#13, #10]) then begin
|
||||
incomment := false;
|
||||
end;
|
||||
if inbigcomment and (sql[i] + secchar = '*/') then begin
|
||||
@ -618,7 +608,7 @@ begin
|
||||
end;
|
||||
|
||||
// Avoid parsing stuff inside string literals.
|
||||
if (sql[i] in [WideChar(''''), WideChar('"'), WideChar('`')]) and (not (backslash and instring)) and (not incomment) and (not indelimiter) then begin
|
||||
if CharInSet(sql[i], ['''', '"', '`']) and (not (backslash and instring)) and (not incomment) and (not indelimiter) then begin
|
||||
if instring and (sql[i] = encloser) then begin
|
||||
if secchar = encloser then
|
||||
i := i + 1 // encoded encloser-char
|
||||
@ -647,7 +637,7 @@ begin
|
||||
end;
|
||||
|
||||
if indelimiter then begin
|
||||
if (sql[i] in [WideChar(#13), WideChar(#10)]) or (i = len) then begin
|
||||
if CharInSet(sql[i], [#13, #10]) or (i = len) then begin
|
||||
if (i = len) then j := 1 else j := 0;
|
||||
try
|
||||
Mainform.Delimiter := copy(sql, start + 10, i + j - (start + 10));
|
||||
@ -734,7 +724,7 @@ end;
|
||||
@param integer Wished Length of string
|
||||
@return string
|
||||
}
|
||||
function sstr(str: WideString; len: Integer) : WideString;
|
||||
function sstr(str: String; len: Integer) : String;
|
||||
begin
|
||||
if length(str) > len then
|
||||
begin
|
||||
@ -806,7 +796,7 @@ end;
|
||||
@param string Text used for search+replace
|
||||
@return string Text with entities
|
||||
}
|
||||
function htmlentities(str: WideString) : WideString;
|
||||
function htmlentities(str: String) : String;
|
||||
begin
|
||||
result := WideStringReplace(str, '&', '&', [rfReplaceAll]);
|
||||
result := WideStringReplace(result, '<', '<', [rfReplaceAll]);
|
||||
@ -828,10 +818,10 @@ end;
|
||||
@param Grid Object which holds data to export
|
||||
@param string Text used in <title>
|
||||
}
|
||||
procedure GridToHtml(Grid: TVirtualStringTree; Title: WideString; S: TStream);
|
||||
procedure GridToHtml(Grid: TVirtualStringTree; Title: String; S: TStream);
|
||||
var
|
||||
i, MaxSize: Integer;
|
||||
tmp, Data, Generator: WideString;
|
||||
tmp, Data, Generator: String;
|
||||
Node: PVirtualNode;
|
||||
GridData: TGridResult;
|
||||
SelectionOnly: Boolean;
|
||||
@ -967,7 +957,7 @@ end;
|
||||
procedure GridToCsv(Grid: TVirtualStringTree; Separator, Encloser, Terminator: String; S: TStream);
|
||||
var
|
||||
i, MaxSize: Integer;
|
||||
tmp, Data: WideString;
|
||||
tmp, Data: String;
|
||||
Node: PVirtualNode;
|
||||
GridData: TGridResult;
|
||||
SelectionOnly: Boolean;
|
||||
@ -1062,10 +1052,10 @@ end;
|
||||
@param Grid Object which holds data to export
|
||||
@param string Text used as root-element
|
||||
}
|
||||
procedure GridToXml(Grid: TVirtualStringTree; root: WideString; S: TStream);
|
||||
procedure GridToXml(Grid: TVirtualStringTree; root: String; S: TStream);
|
||||
var
|
||||
i, MaxSize: Integer;
|
||||
tmp, Data: WideString;
|
||||
tmp, Data: String;
|
||||
Node: PVirtualNode;
|
||||
GridData: TGridResult;
|
||||
SelectionOnly: Boolean;
|
||||
@ -1148,10 +1138,10 @@ end;
|
||||
@param Grid Object which holds data to export
|
||||
@param string Text used as tablename in INSERTs
|
||||
}
|
||||
procedure GridToSql(Grid: TVirtualStringTree; Tablename: WideString; S: TStream);
|
||||
procedure GridToSql(Grid: TVirtualStringTree; Tablename: String; S: TStream);
|
||||
var
|
||||
i, MaxSize: Integer;
|
||||
tmp, Data: WideString;
|
||||
tmp, Data: String;
|
||||
Node: PVirtualNode;
|
||||
GridData: TGridResult;
|
||||
SelectionOnly: Boolean;
|
||||
@ -1279,25 +1269,6 @@ asm
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{***
|
||||
Left hand string-comparison
|
||||
|
||||
@param string Text 1 to compare
|
||||
@param string Text 2 to compare
|
||||
@return boolean Does the longer string of both contain the shorter string at the beginning?
|
||||
}
|
||||
function StrCmpBegin(Str1, Str2: string): Boolean;
|
||||
begin
|
||||
if ((Str1 = '') or (Str2 = '')) and (Str1 <> Str2) then
|
||||
Result := False
|
||||
else
|
||||
Result := (StrLComp(PChar(Str1), PChar(Str2),
|
||||
Min(Length(Str1), Length(Str2))) = 0);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{***
|
||||
Encode spaces (and more to come) in URLs
|
||||
|
||||
@ -1313,7 +1284,7 @@ end;
|
||||
{**
|
||||
Write some UTF8 text to a file- or memorystream
|
||||
}
|
||||
procedure StreamWrite(S: TStream; Text: WideString = '');
|
||||
procedure StreamWrite(S: TStream; Text: String = '');
|
||||
var
|
||||
utf8: AnsiString;
|
||||
begin
|
||||
@ -1338,7 +1309,7 @@ end;
|
||||
@param integer MySQL-version or SQL_VERSION_ANSI
|
||||
@return string SQL
|
||||
}
|
||||
function fixSQL( sql: WideString; sql_version: Integer = SQL_VERSION_ANSI; cli_workarounds: Boolean = false ): WideString;
|
||||
function fixSQL( sql: String; sql_version: Integer = SQL_VERSION_ANSI; cli_workarounds: Boolean = false ): String;
|
||||
var
|
||||
rx : TRegExpr;
|
||||
begin
|
||||
@ -1542,7 +1513,7 @@ begin
|
||||
Result := '';
|
||||
HasDecimalSep := False;
|
||||
for i:=1 to Length(Str) do begin
|
||||
if (Str[i] in ['0'..'9', DecimalSeparator]) or ((Str[i] = '-') and (Result='')) then
|
||||
if CharInSet(Str[i], ['0'..'9', DecimalSeparator]) or ((Str[i] = '-') and (Result='')) then
|
||||
begin
|
||||
// Avoid confusion and AV in StrToFloat()
|
||||
if (ThousandSeparator = DecimalSeparator) and (Str[i] = DecimalSeparator) then
|
||||
@ -1595,7 +1566,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function esc(Text: WideString; ProcessJokerChars: Boolean=false): WideString;
|
||||
function esc(Text: String; ProcessJokerChars: Boolean=false): String;
|
||||
begin
|
||||
Result := Mainform.Connection.EscapeString(Text, ProcessJokerChars);
|
||||
end;
|
||||
@ -1605,7 +1576,7 @@ end;
|
||||
Detect NUL character in a text.
|
||||
Useful because fx SynEdit cuts of all text after it encounters a NUL.
|
||||
}
|
||||
function ScanNulChar(Text: WideString): boolean;
|
||||
function ScanNulChar(Text: String): boolean;
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
@ -1630,7 +1601,7 @@ end;
|
||||
@param string Text to test
|
||||
@return TLineBreaks
|
||||
}
|
||||
function ScanLineBreaks(Text: WideString): TLineBreaks;
|
||||
function ScanLineBreaks(Text: String): TLineBreaks;
|
||||
var
|
||||
i: integer;
|
||||
c: WideChar;
|
||||
@ -1675,7 +1646,7 @@ end;
|
||||
@param string Text to test
|
||||
@return Boolean
|
||||
}
|
||||
function RemoveNulChars(Text: WideString): WideString;
|
||||
function RemoveNulChars(Text: String): String;
|
||||
var
|
||||
i: integer;
|
||||
c: WideChar;
|
||||
@ -1716,7 +1687,7 @@ end;
|
||||
@param string Text to fix
|
||||
@return string
|
||||
}
|
||||
function fixNewlines(txt: Widestring): WideString;
|
||||
function fixNewlines(txt: String): String;
|
||||
begin
|
||||
txt := WidestringReplace(txt, CRLF, #10, [rfReplaceAll]);
|
||||
txt := WidestringReplace(txt, #13, #10, [rfReplaceAll]);
|
||||
@ -1927,7 +1898,7 @@ end;
|
||||
function getFirstWord( text: String ): String;
|
||||
var
|
||||
i : Integer;
|
||||
wordChars, wordCharsFirst : Set of Char;
|
||||
wordChars, wordCharsFirst : TSysCharSet;
|
||||
begin
|
||||
result := '';
|
||||
text := trim( text );
|
||||
@ -1943,7 +1914,7 @@ begin
|
||||
// @see bug #1692828
|
||||
while i < Length(text) do
|
||||
begin
|
||||
if (text[i] in wordCharsFirst) then
|
||||
if CharInSet(text[i], wordCharsFirst) then
|
||||
begin
|
||||
// Found beginning of word!
|
||||
break;
|
||||
@ -1961,7 +1932,7 @@ begin
|
||||
// Add chars as long as they're alpha-numeric
|
||||
while i <= Length(text) do
|
||||
begin
|
||||
if ((result = '') and (text[i] in wordCharsFirst)) or (text[i] in wordChars) then
|
||||
if ((result = '') and CharInSet(text[i], wordCharsFirst)) or CharInSet(text[i], wordChars) then
|
||||
begin
|
||||
result := result + text[i];
|
||||
end
|
||||
@ -1982,9 +1953,9 @@ end;
|
||||
@param string Text
|
||||
@return Integer Last position
|
||||
}
|
||||
function LastPos(needle: WideChar; haystack: WideString): Integer;
|
||||
function LastPos(needle: WideChar; haystack: String): Integer;
|
||||
var
|
||||
reverse: WideString;
|
||||
reverse: String;
|
||||
i, len, w: Integer;
|
||||
begin
|
||||
// Reverse string.
|
||||
@ -2256,7 +2227,7 @@ end;
|
||||
{**
|
||||
Save a textfile with unicode
|
||||
}
|
||||
procedure SaveUnicodeFile(Filename: String; Text: WideString);
|
||||
procedure SaveUnicodeFile(Filename: String; Text: String);
|
||||
var
|
||||
f: TFileStream;
|
||||
begin
|
||||
@ -2432,7 +2403,7 @@ end;
|
||||
{**
|
||||
Read a chunk out of a textfile unicode safe by passing a stream and its charset
|
||||
}
|
||||
function ReadTextfileChunk(Stream: TFileStream; FileCharset: TFileCharset; ChunkSize: Int64 = 0): WideString;
|
||||
function ReadTextfileChunk(Stream: TFileStream; FileCharset: TFileCharset; ChunkSize: Int64 = 0): String;
|
||||
var
|
||||
SA: AnsiString;
|
||||
P: PWord;
|
||||
@ -2460,19 +2431,19 @@ begin
|
||||
// BOM indicates UTF-8 text stream
|
||||
SetLength(SA, ChunkSize div SizeOf(AnsiChar));
|
||||
Stream.Read(PAnsiChar(SA)^, ChunkSize);
|
||||
Result := UTF8Decode(SA);
|
||||
Result := UTF8ToString(SA);
|
||||
end else begin
|
||||
// without byte order mark it is assumed that we are loading ANSI text
|
||||
SetLength(SA, ChunkSize div SizeOf(AnsiChar));
|
||||
Stream.Read(PAnsiChar(SA)^, ChunkSize);
|
||||
Result := SA;
|
||||
Result := String(SA);
|
||||
end;
|
||||
end;
|
||||
|
||||
{**
|
||||
Read a unicode or ansi file into memory
|
||||
}
|
||||
function ReadTextfile(Filename: String): WideString;
|
||||
function ReadTextfile(Filename: String): String;
|
||||
var
|
||||
Stream: TFileStream;
|
||||
FileCharset: TFileCharset;
|
||||
@ -2482,7 +2453,7 @@ begin
|
||||
Stream.Free;
|
||||
end;
|
||||
|
||||
function ReadBinaryFile(Filename: String; MaxBytes: Int64): string;
|
||||
function ReadBinaryFile(Filename: String; MaxBytes: Int64): AnsiString;
|
||||
var
|
||||
Stream: TFileStream;
|
||||
begin
|
||||
@ -2490,50 +2461,19 @@ begin
|
||||
Stream.Position := 0;
|
||||
if (MaxBytes < 1) or (MaxBytes > Stream.Size) then MaxBytes := Stream.Size;
|
||||
SetLength(Result, MaxBytes);
|
||||
Stream.Read(PChar(Result)^, Length(Result));
|
||||
Stream.Read(PAnsiChar(Result)^, Length(Result));
|
||||
Stream.Free;
|
||||
end;
|
||||
|
||||
{ TUniClipboard }
|
||||
|
||||
function TUniClipboard.GetAsWideString: WideString;
|
||||
var Data: THandle;
|
||||
begin
|
||||
Open;
|
||||
Data := GetClipboardData(CF_UNICODETEXT);
|
||||
try
|
||||
if Data <> 0 then
|
||||
Result := PWideChar(GlobalLock(Data))
|
||||
else
|
||||
Result := '';
|
||||
finally
|
||||
if Data <> 0 then GlobalUnlock(Data);
|
||||
Close;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TUniClipboard.SetAsWideString(Value: WideString);
|
||||
begin
|
||||
SetBuffer(CF_UNICODETEXT, PWideChar(Value)^, 2 * (Length(Value) + 1));
|
||||
end;
|
||||
|
||||
procedure CopyToClipboard(Value: WideString);
|
||||
var
|
||||
CB: TUniClipboard;
|
||||
begin
|
||||
CB := TUniClipboard.Create;
|
||||
CB.AsWideString := Value;
|
||||
end;
|
||||
|
||||
|
||||
procedure StreamToClipboard(S: TMemoryStream);
|
||||
var
|
||||
Content: String;
|
||||
Content: AnsiString;
|
||||
begin
|
||||
SetLength(Content, S.Size);
|
||||
S.Position := 0;
|
||||
S.Read(Pointer(Content)^, S.Size);
|
||||
CopyToClipboard(Utf8Decode(Content));
|
||||
S.Read(PAnsiChar(Content)^, S.Size);
|
||||
Clipboard.AsText := Utf8ToString(Content);
|
||||
// Free memory
|
||||
SetString(Content, nil, 0);
|
||||
end;
|
||||
@ -2595,7 +2535,7 @@ end;
|
||||
{**
|
||||
Concat all sort options to a ORDER clause
|
||||
}
|
||||
function ComposeOrderClause(Cols: TOrderColArray): WideString;
|
||||
function ComposeOrderClause(Cols: TOrderColArray): String;
|
||||
var
|
||||
i : Integer;
|
||||
sort : String;
|
||||
@ -2711,7 +2651,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function ListIndexByRegExpr(List: TStrings; Expression: WideString): Integer;
|
||||
function ListIndexByRegExpr(List: TStrings; Expression: String): Integer;
|
||||
var
|
||||
rx: TRegExpr;
|
||||
i: Integer;
|
||||
@ -2780,12 +2720,12 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure ExplodeQuotedList(Text: WideString; var List: TWideStringList);
|
||||
procedure ExplodeQuotedList(Text: String; var List: TWideStringList);
|
||||
var
|
||||
i: Integer;
|
||||
Quote: WideChar;
|
||||
Opened, Closed: Boolean;
|
||||
Item: WideString;
|
||||
Item: String;
|
||||
begin
|
||||
Text := Trim(Text);
|
||||
if Length(Text) > 0 then
|
||||
@ -2834,9 +2774,9 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure ParseTableStructure(CreateTable: WideString; Columns: TObjectList=nil; Keys: TObjectList=nil; ForeignKeys: TObjectList=nil);
|
||||
procedure ParseTableStructure(CreateTable: String; Columns: TObjectList=nil; Keys: TObjectList=nil; ForeignKeys: TObjectList=nil);
|
||||
var
|
||||
ColSpec: WideString;
|
||||
ColSpec: String;
|
||||
rx, rxCol: TRegExpr;
|
||||
i: Integer;
|
||||
InLiteral: Boolean;
|
||||
@ -3024,7 +2964,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure ParseViewStructure(ViewName: WideString; Columns: TObjectList);
|
||||
procedure ParseViewStructure(ViewName: String; Columns: TObjectList);
|
||||
var
|
||||
rx: TRegExpr;
|
||||
Col: TTableColumn;
|
||||
@ -3051,13 +2991,13 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function ReformatSQL(SQL: WideString): WideString;
|
||||
function ReformatSQL(SQL: String): String;
|
||||
var
|
||||
AllKeywords, ImportantKeywords: TWideStringlist;
|
||||
i, Run, KeywordMaxLen: Integer;
|
||||
IsEsc, IsQuote, InComment, InBigComment, InString, InKeyword, InIdent, LastWasComment: Boolean;
|
||||
c, p: WideChar;
|
||||
Keyword, PreviousKeyword, TestPair: WideString;
|
||||
Keyword, PreviousKeyword, TestPair: String;
|
||||
begin
|
||||
// Known SQL keywords, get converted to UPPERCASE
|
||||
AllKeywords := TWideStringlist.Create;
|
||||
@ -3240,7 +3180,7 @@ begin
|
||||
FModified := Value;
|
||||
end;
|
||||
|
||||
procedure TDBObjectEditor.Init(ObjectName: WideString=''; ObjectType: TListNodeType=lntNone);
|
||||
procedure TDBObjectEditor.Init(ObjectName: String=''; ObjectType: TListNodeType=lntNone);
|
||||
begin
|
||||
DeInit;
|
||||
Mainform.showstatus('Initializing editor ...');
|
||||
@ -3252,7 +3192,7 @@ end;
|
||||
|
||||
procedure TDBObjectEditor.DeInit;
|
||||
var
|
||||
Msg, ObjType: WideString;
|
||||
Msg, ObjType: String;
|
||||
begin
|
||||
// Ask for saving modifications
|
||||
if Modified then begin
|
||||
|
@ -354,9 +354,9 @@ var
|
||||
dt: TDateTime;
|
||||
y, m, d, h, mi, s, ms: Word;
|
||||
FileStream: TFileStream;
|
||||
readBuf: String;
|
||||
readBuf: AnsiString;
|
||||
bytesRead: Integer;
|
||||
sql, data: WideString;
|
||||
sql, data: String;
|
||||
begin
|
||||
Screen.Cursor := crHourglass;
|
||||
EnableProgressBar(ListViewFiles.Items.Count);
|
||||
@ -389,7 +389,7 @@ begin
|
||||
// TODO: Indicate this character set on the GUI.
|
||||
//
|
||||
SetLength(readBuf, ChunkSize div SizeOf(Char));
|
||||
bytesRead := FileStream.Read(PChar(readBuf)^, ChunkSize);
|
||||
bytesRead := FileStream.Read(PAnsiChar(readBuf)^, ChunkSize);
|
||||
SetLength(readBuf, bytesRead div SizeOf(Char));
|
||||
data := data + BinToWideHex(readBuf);
|
||||
end;
|
||||
|
@ -138,7 +138,7 @@ procedure Tloaddataform.comboDatabaseChange(Sender: TObject);
|
||||
var
|
||||
count, i, selCharsetIndex, v: Integer;
|
||||
DBObjects: TDBObjectList;
|
||||
seldb, seltable, dbcreate: WideString;
|
||||
seldb, seltable, dbcreate: String;
|
||||
rx: TRegExpr;
|
||||
DefCharset: String;
|
||||
CharsetTable: TMySQLQuery;
|
||||
@ -212,7 +212,7 @@ end;
|
||||
|
||||
procedure Tloaddataform.btnImportClick(Sender: TObject);
|
||||
var
|
||||
query : WideString;
|
||||
query : String;
|
||||
col : TWideStringList;
|
||||
i : Integer;
|
||||
|
||||
|
245
source/main.pas
245
source/main.pas
@ -39,7 +39,7 @@ type
|
||||
Grid: TVirtualStringTree;
|
||||
TabSheet: TTabSheet;
|
||||
GridResult: TGridResult;
|
||||
FilterText: WideString;
|
||||
FilterText: String;
|
||||
end;
|
||||
|
||||
TMainForm = class(TForm)
|
||||
@ -476,7 +476,7 @@ type
|
||||
procedure actPrintListExecute(Sender: TObject);
|
||||
procedure actCopyTableExecute(Sender: TObject);
|
||||
procedure showstatus(msg: string=''; panel: Integer=6);
|
||||
function mask(str: WideString) : WideString;
|
||||
function mask(str: String) : String;
|
||||
procedure actExecuteQueryExecute(Sender: TObject);
|
||||
procedure actExecuteSelectionExecute(Sender: TObject);
|
||||
procedure actCopyAsXMLExecute(Sender: TObject);
|
||||
@ -539,16 +539,16 @@ type
|
||||
procedure ValidateControls(Sender: TObject);
|
||||
procedure ValidateQueryControls(Sender: TObject);
|
||||
procedure RefreshQueryHelpers;
|
||||
procedure LoadDatabaseProperties(db: WideString);
|
||||
procedure LoadDatabaseProperties(db: String);
|
||||
procedure ShowHost;
|
||||
procedure ShowDatabase(db: WideString);
|
||||
procedure ShowDBProperties(db: WideString);
|
||||
procedure ShowDatabase(db: String);
|
||||
procedure ShowDBProperties(db: String);
|
||||
function EnsureFullWidth(Grid: TBaseVirtualTree; Column: TColumnIndex; Node: PVirtualNode): Boolean;
|
||||
procedure EnsureNodeLoaded(Sender: TBaseVirtualTree; Node: PVirtualNode; WhereClause: WideString);
|
||||
procedure EnsureNodeLoaded(Sender: TBaseVirtualTree; Node: PVirtualNode; WhereClause: String);
|
||||
procedure EnsureChunkLoaded(Sender: TBaseVirtualTree; Node: PVirtualNode; FullWidth: Boolean = False);
|
||||
procedure DiscardNodeData(Sender: TVirtualStringTree; Node: PVirtualNode);
|
||||
procedure viewdata(Sender: TObject);
|
||||
procedure LogSQL(Msg: WideString; Category: TMySQLLogCategory=lcInfo);
|
||||
procedure LogSQL(Msg: String; Category: TMySQLLogCategory=lcInfo);
|
||||
procedure KillProcess(Sender: TObject);
|
||||
procedure ExecSQLClick(Sender: TObject; Selection: Boolean = false;
|
||||
CurrentLine: Boolean=false);
|
||||
@ -724,7 +724,7 @@ type
|
||||
SelectedTableKeys,
|
||||
SelectedTableForeignKeys : TObjectList;
|
||||
FilterPanelManuallyOpened : Boolean;
|
||||
DataGridDB, DataGridTable : WideString;
|
||||
DataGridDB, DataGridTable : String;
|
||||
PrevTableColWidths : TWideStringList;
|
||||
DataGridHasChanges : Boolean;
|
||||
FLastMouseUpOnPageControl : Cardinal;
|
||||
@ -733,25 +733,25 @@ type
|
||||
DataGridResult : TGridResult;
|
||||
// Filter text per tab for filter panel
|
||||
FilterTextVariables, FilterTextStatus, FilterTextProcessList, FilterTextCommandStats,
|
||||
FilterTextDatabase, FilterTextData: WideString;
|
||||
FilterTextDatabase, FilterTextData: String;
|
||||
PreviousFocusedNode: PVirtualNode;
|
||||
function GetParamValue(const paramChar: Char; const paramName:
|
||||
string; var curIdx: Byte; out paramValue: string): Boolean;
|
||||
procedure SetDelimiter(Value: String);
|
||||
procedure DisplayRowCountStats(MatchingRows: Int64 = -1);
|
||||
procedure insertFunction(Sender: TObject);
|
||||
function GetActiveDatabase: WideString;
|
||||
function GetActiveDatabase: String;
|
||||
function GetSelectedTable: TDBObject;
|
||||
procedure SetSelectedDatabase(db: WideString);
|
||||
procedure SetSelectedDatabase(db: String);
|
||||
procedure SetVisibleListColumns( List: TVirtualStringTree; Columns: TWideStringList );
|
||||
procedure ToggleFilterPanel(ForceVisible: Boolean = False);
|
||||
procedure AutoCalcColWidths(Tree: TVirtualStringTree; PrevLayout: TWideStringlist = nil);
|
||||
function PlaceObjectEditor(Which: TListNodeType): TDBObjectEditor;
|
||||
procedure SetTabCaption(PageIndex: Integer; Text: WideString);
|
||||
procedure SetTabCaption(PageIndex: Integer; Text: String);
|
||||
function ConfirmTabClose(PageIndex: Integer): Boolean;
|
||||
procedure SaveQueryMemo(Tab: TQueryTab; Filename: String; OnlySelection: Boolean);
|
||||
procedure UpdateFilterPanel(Sender: TObject);
|
||||
procedure DatabaseChanged(Database: WideString);
|
||||
procedure DatabaseChanged(Database: String);
|
||||
public
|
||||
Connection: TMySQLConnection;
|
||||
cancelling: Boolean;
|
||||
@ -766,7 +766,7 @@ type
|
||||
OptionsForm: Toptionsform;
|
||||
SessionManager: TConnForm;
|
||||
AllDatabases, Databases: TWideStringList;
|
||||
TemporaryDatabase : WideString;
|
||||
TemporaryDatabase : String;
|
||||
dataselected : Boolean;
|
||||
editing : Boolean;
|
||||
WindowNumber : Integer;
|
||||
@ -784,7 +784,7 @@ type
|
||||
prefMaxTotalRows : Integer;
|
||||
prefCSVSeparator,
|
||||
prefCSVEncloser,
|
||||
prefCSVTerminator : String[10];
|
||||
prefCSVTerminator : String;
|
||||
prefLogToFile,
|
||||
prefEnableBinaryEditor,
|
||||
prefEnableDatetimeEditor,
|
||||
@ -805,10 +805,10 @@ type
|
||||
DataGridCurrentFullSelect,
|
||||
DataGridCurrentFrom,
|
||||
DataGridCurrentFilter,
|
||||
DataGridCurrentSort : WideString;
|
||||
DataGridCurrentSort : String;
|
||||
btnAddTab : TPngSpeedButton;
|
||||
QueryTabs : TObjectList;
|
||||
SelectedTableCreateStatement: WideString;
|
||||
SelectedTableCreateStatement: String;
|
||||
|
||||
property Delimiter: String read FDelimiter write SetDelimiter;
|
||||
procedure CallSQLHelpWithKeyword( keyword: String );
|
||||
@ -818,13 +818,13 @@ type
|
||||
procedure FillPopupQueryLoad;
|
||||
procedure PopupQueryLoadRemoveAbsentFiles( sender: TObject );
|
||||
procedure SessionConnect(Sender: TObject);
|
||||
function InitConnection(parHost, parSocketname, parPort, parUser, parPass, parCompress, parSession: WideString): Boolean;
|
||||
function InitConnection(parHost, parSocketname, parPort, parUser, parPass, parCompress, parSession: String): Boolean;
|
||||
|
||||
function ActiveGrid: TVirtualStringTree;
|
||||
function GridResult(Grid: TBaseVirtualTree): TGridResult; overload;
|
||||
function GridResult(PageIndex: Integer): TGridResult; overload;
|
||||
|
||||
property ActiveDatabase : WideString read GetActiveDatabase write SetSelectedDatabase;
|
||||
property ActiveDatabase : String read GetActiveDatabase write SetSelectedDatabase;
|
||||
property SelectedTable : TDBObject read GetSelectedTable;
|
||||
|
||||
procedure TestVTreeDataArray( P: PVTreeDataArray );
|
||||
@ -834,15 +834,15 @@ type
|
||||
procedure TrimSQLLog;
|
||||
function GetTreeNodeType(Tree: TBaseVirtualTree; Node: PVirtualNode): TListNodeType;
|
||||
function GetFocusedTreeNodeType: TListNodeType;
|
||||
procedure RefreshTree(DoResetTableCache: Boolean; SelectDatabase: WideString = '');
|
||||
procedure RefreshTreeDB(db: WideString);
|
||||
function FindDBNode(db: WideString): PVirtualNode;
|
||||
procedure RefreshTree(DoResetTableCache: Boolean; SelectDatabase: String = '');
|
||||
procedure RefreshTreeDB(db: String);
|
||||
function FindDBNode(db: String): PVirtualNode;
|
||||
function GridPostUpdate(Sender: TBaseVirtualTree): Boolean;
|
||||
function GridPostInsert(Sender: TBaseVirtualTree): Boolean;
|
||||
function GridPostDelete(Sender: TBaseVirtualTree): Boolean;
|
||||
function DataGridPostUpdateOrInsert(Node: PVirtualNode): Boolean;
|
||||
procedure GridFinalizeEditing(Sender: TBaseVirtualTree);
|
||||
function GetWhereClause(Row: PGridRow; Columns: PGridColumns): WideString;
|
||||
function GetWhereClause(Row: PGridRow; Columns: PGridColumns): String;
|
||||
function GetKeyColumns: TWideStringlist;
|
||||
function CheckUniqueKeyClause: Boolean;
|
||||
procedure DataGridInsertRow(CopyValuesFromNode: PVirtualNode);
|
||||
@ -852,11 +852,11 @@ type
|
||||
function GetRegKeyTable: String;
|
||||
procedure SaveListSetup( List: TVirtualStringTree );
|
||||
procedure RestoreListSetup( List: TVirtualStringTree );
|
||||
procedure SetEditorTabCaption(Editor: TDBObjectEditor; ObjName: WideString);
|
||||
procedure SetEditorTabCaption(Editor: TDBObjectEditor; ObjName: String);
|
||||
procedure SetWindowCaption;
|
||||
procedure OnMessageHandler(var Msg: TMsg; var Handled: Boolean);
|
||||
function MaskMulti(str: WideString): WideString;
|
||||
procedure SelectDBObject(Text: WideString; NodeType: TListNodeType);
|
||||
function MaskMulti(str: String): String;
|
||||
procedure SelectDBObject(Text: String; NodeType: TListNodeType);
|
||||
procedure SetupSynEditors;
|
||||
procedure ParseSelectedTableStructure;
|
||||
end;
|
||||
@ -1541,7 +1541,7 @@ end;
|
||||
procedure TMainForm.DoAfterConnect;
|
||||
var
|
||||
i, j: Integer;
|
||||
lastUsedDB: WideString;
|
||||
lastUsedDB: String;
|
||||
functioncats : TStringList;
|
||||
miGroup,
|
||||
miFilterGroup,
|
||||
@ -1562,7 +1562,7 @@ begin
|
||||
Mainreg.WriteInteger(REGNAME_SERVERVERSION, Connection.ServerVersionInt);
|
||||
Mainreg.WriteString(REGNAME_LASTCONNECT, DateTimeToStr(Now));
|
||||
|
||||
comboOnlyDBs.Items.Text := Utf8Decode(GetRegValue(REGNAME_ONLYDBS, '', SessionName));
|
||||
comboOnlyDBs.Items.Text := GetRegValue(REGNAME_ONLYDBS, '', SessionName);
|
||||
if comboOnlyDBs.Items.Count > 0 then
|
||||
comboOnlyDBs.ItemIndex := 0
|
||||
else
|
||||
@ -1575,7 +1575,7 @@ begin
|
||||
|
||||
// Reselect last used database
|
||||
if GetRegValue( REGNAME_RESTORELASTUSEDDB, DEFAULT_RESTORELASTUSEDDB ) then begin
|
||||
lastUsedDB := Utf8Decode(GetRegValue(REGNAME_LASTUSEDDB, '', SessionName));
|
||||
lastUsedDB := GetRegValue(REGNAME_LASTUSEDDB, '', SessionName);
|
||||
if lastUsedDB <> '' then try
|
||||
ActiveDatabase := lastUsedDB;
|
||||
except
|
||||
@ -1647,8 +1647,8 @@ begin
|
||||
// Open server-specific registry-folder.
|
||||
// relative from already opened folder!
|
||||
OpenRegistry(SessionName);
|
||||
MainReg.WriteString( REGNAME_LASTUSEDDB, Utf8Encode(ActiveDatabase) );
|
||||
MainReg.WriteString( REGNAME_ONLYDBS, Utf8Encode(comboOnlyDBs.Items.Text) );
|
||||
MainReg.WriteString( REGNAME_LASTUSEDDB, ActiveDatabase );
|
||||
MainReg.WriteString( REGNAME_ONLYDBS, comboOnlyDBs.Items.Text );
|
||||
|
||||
// Post pending UPDATE
|
||||
if DataGridHasChanges then
|
||||
@ -1908,14 +1908,14 @@ end;
|
||||
|
||||
|
||||
// Escape database, table, field, index or key name.
|
||||
function TMainform.mask(str: WideString) : WideString;
|
||||
function TMainform.mask(str: String) : String;
|
||||
begin
|
||||
result := Connection.QuoteIdent(str);
|
||||
end;
|
||||
|
||||
|
||||
// Quote identifier, probably with multiple segments, e.g. db.table.column
|
||||
function TMainform.MaskMulti(str: WideString): WideString;
|
||||
function TMainform.MaskMulti(str: String): String;
|
||||
var
|
||||
Segments: TWideStringlist;
|
||||
i: Integer;
|
||||
@ -1981,7 +1981,7 @@ end;
|
||||
procedure TMainForm.actCopyAsHTMLExecute(Sender: TObject);
|
||||
var
|
||||
S: TMemoryStream;
|
||||
Title: WideString;
|
||||
Title: String;
|
||||
begin
|
||||
// Copy data in focused grid as HTML table
|
||||
Screen.Cursor := crHourglass;
|
||||
@ -2003,7 +2003,7 @@ end;
|
||||
procedure TMainForm.actCopyAsXMLExecute(Sender: TObject);
|
||||
var
|
||||
S: TMemoryStream;
|
||||
Root: WideString;
|
||||
Root: String;
|
||||
begin
|
||||
// Copy data in focused grid as XML
|
||||
Screen.Cursor := crHourglass;
|
||||
@ -2025,7 +2025,7 @@ end;
|
||||
procedure TMainForm.actCopyAsSQLExecute(Sender: TObject);
|
||||
var
|
||||
S: TMemoryStream;
|
||||
Tablename: WideString;
|
||||
Tablename: String;
|
||||
begin
|
||||
// Copy data in focused grid as SQL
|
||||
Screen.Cursor := crHourglass;
|
||||
@ -2048,7 +2048,7 @@ procedure TMainForm.actExportDataExecute(Sender: TObject);
|
||||
var
|
||||
Dialog: TSaveDialog;
|
||||
FS: TFileStream;
|
||||
Title: WideString;
|
||||
Title: String;
|
||||
begin
|
||||
// Save data in current dataset as CSV, HTML or XML
|
||||
Dialog := SaveDialogExportData;
|
||||
@ -2089,7 +2089,7 @@ var
|
||||
g : TVirtualStringTree;
|
||||
filename : String;
|
||||
f : Textfile;
|
||||
Header, Content : String;
|
||||
Header, Content : AnsiString;
|
||||
IsBinary : Boolean;
|
||||
SaveBinary : Boolean;
|
||||
begin
|
||||
@ -2108,10 +2108,10 @@ begin
|
||||
end else if IsBinary and (Copy(Header, 2, 3) = 'PNG') then begin
|
||||
SaveBinary := true;
|
||||
filename := filename + 'png';
|
||||
end else if IsBinary and StrCmpBegin('GIF', Header) then begin
|
||||
end else if IsBinary and (Copy(Header, 1, 3) = 'GIF') then begin
|
||||
SaveBinary := true;
|
||||
filename := filename + 'gif';
|
||||
end else if IsBinary and StrCmpBegin('BM', Header) then begin
|
||||
end else if IsBinary and (Copy(Header, 1, 2) = 'BM') then begin
|
||||
SaveBinary := true;
|
||||
filename := filename + 'bmp';
|
||||
end;
|
||||
@ -2147,7 +2147,7 @@ procedure TMainForm.actDropObjectsExecute(Sender: TObject);
|
||||
var
|
||||
AllCount : Integer;
|
||||
Tables, Views, Functions, Procedures, Triggers: TWideStringList;
|
||||
msg, activeDB : WideString;
|
||||
msg, activeDB : String;
|
||||
InDBTree: Boolean;
|
||||
Act: TAction;
|
||||
Node: PVirtualNode;
|
||||
@ -2155,7 +2155,7 @@ var
|
||||
procedure DoDrop(Kind: String; List: TWideStringlist; MultiDrops: Boolean);
|
||||
var
|
||||
i: Integer;
|
||||
baseSql, sql: WideString;
|
||||
baseSql, sql: String;
|
||||
begin
|
||||
if List.Count > 0 then begin
|
||||
baseSql := 'DROP '+Kind+' ';
|
||||
@ -2326,7 +2326,7 @@ procedure TMainForm.SessionConnect(Sender: TObject);
|
||||
var
|
||||
Session: String;
|
||||
NetType: Integer;
|
||||
parHost, parSocketname, parPort, parUser, parPass, parCompress: WideString;
|
||||
parHost, parSocketname, parPort, parUser, parPass, parCompress: String;
|
||||
begin
|
||||
Session := (Sender as TMenuItem).Caption;
|
||||
NetType := GetRegValue(REGNAME_NETTYPE, NETTYPE_TCPIP, Session);
|
||||
@ -2350,7 +2350,7 @@ end;
|
||||
Receive connection parameters and create the mdi-window
|
||||
Paremeters are either sent by connection-form or by commandline.
|
||||
}
|
||||
function TMainform.InitConnection(parHost, parSocketname, parPort, parUser, parPass, parCompress, parSession: WideString): Boolean;
|
||||
function TMainform.InitConnection(parHost, parSocketname, parPort, parUser, parPass, parCompress, parSession: String): Boolean;
|
||||
var
|
||||
ConnectionAttempt: TMySQLConnection;
|
||||
SessionExists: Boolean;
|
||||
@ -2633,7 +2633,7 @@ end;
|
||||
|
||||
procedure TMainForm.SaveQueryMemo(Tab: TQueryTab; Filename: String; OnlySelection: Boolean);
|
||||
var
|
||||
Text, LB: WideString;
|
||||
Text, LB: String;
|
||||
begin
|
||||
Screen.Cursor := crHourGlass;
|
||||
if OnlySelection then
|
||||
@ -2660,7 +2660,7 @@ procedure TMainForm.actSaveSQLSnippetExecute(Sender: TObject);
|
||||
var
|
||||
snippetname : String;
|
||||
mayChange : Boolean;
|
||||
Text, LB: WideString;
|
||||
Text, LB: String;
|
||||
begin
|
||||
// Save snippet
|
||||
if InputQuery( 'Save snippet', 'Snippet name:', snippetname) then
|
||||
@ -2978,7 +2978,7 @@ begin
|
||||
// Recreate recent filters list
|
||||
Filters := TStringList.Create;
|
||||
OldNumbers := TStringList.Create;
|
||||
Filters.Add(Trim(Utf8Encode(SynMemoFilter.Text)));
|
||||
Filters.Add(Trim(SynMemoFilter.Text));
|
||||
MainReg.OpenKey(GetRegKeyTable+'\'+REGNAME_FILTERS, True);
|
||||
MainReg.GetValueNames(OldNumbers);
|
||||
OldNumbers.CustomSort(CompareNumbers);
|
||||
@ -3075,7 +3075,7 @@ end;
|
||||
{**
|
||||
Add a SQL-command or comment to SynMemoSQLLog
|
||||
}
|
||||
procedure TMainForm.LogSQL(Msg: WideString; Category: TMySQLLogCategory=lcInfo);
|
||||
procedure TMainForm.LogSQL(Msg: String; Category: TMySQLLogCategory=lcInfo);
|
||||
var
|
||||
snip, IsSQL: Boolean;
|
||||
begin
|
||||
@ -3152,7 +3152,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TMainForm.ShowDatabase(db: WideString);
|
||||
procedure TMainForm.ShowDatabase(db: String);
|
||||
begin
|
||||
if (not DBtree.Dragging) and (
|
||||
(PageControlMain.ActivePage = tabHost) or
|
||||
@ -3173,7 +3173,7 @@ var
|
||||
i, j : Integer;
|
||||
select_base,
|
||||
select_base_full,
|
||||
select_from : WideString;
|
||||
select_from : String;
|
||||
sl_query : TWideStringList;
|
||||
KeyCols : TWideStringList;
|
||||
col : TVirtualTreeColumn;
|
||||
@ -3416,7 +3416,7 @@ procedure TMainForm.DisplayRowCountStats(MatchingRows: Int64);
|
||||
var
|
||||
DBObject: TDBObject;
|
||||
IsFiltered: Boolean;
|
||||
cap: WideString;
|
||||
cap: String;
|
||||
begin
|
||||
DBObject := SelectedTable;
|
||||
cap := ActiveDatabase + '.' + DBObject.Name;
|
||||
@ -3491,7 +3491,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TMainForm.LoadDatabaseProperties(db: WideString);
|
||||
procedure TMainForm.LoadDatabaseProperties(db: String);
|
||||
var
|
||||
i, img : Integer;
|
||||
Obj: TDBObject;
|
||||
@ -3573,7 +3573,7 @@ end;
|
||||
|
||||
|
||||
{ Show tables and their properties on the tabsheet "Database" }
|
||||
procedure TMainForm.ShowDBProperties(db: WideString);
|
||||
procedure TMainForm.ShowDBProperties(db: String);
|
||||
begin
|
||||
Screen.Cursor := crHourglass;
|
||||
PageControlMainChange(Self);
|
||||
@ -3659,7 +3659,7 @@ procedure TMainForm.ValidateQueryControls(Sender: TObject);
|
||||
var
|
||||
NotEmpty, HasSelection: Boolean;
|
||||
Tab: TQueryTab;
|
||||
cap: WideString;
|
||||
cap: String;
|
||||
InQueryTab: Boolean;
|
||||
begin
|
||||
InQueryTab := QueryTabActive;
|
||||
@ -3731,7 +3731,7 @@ var
|
||||
i, j, QueryCount: Integer;
|
||||
SQLTime, SQLNetTime: Cardinal;
|
||||
Results: TMySQLQuery;
|
||||
ColName, Text, LB: WideString;
|
||||
ColName, Text, LB: String;
|
||||
col: TVirtualTreeColumn;
|
||||
ResultLabel: TLabel;
|
||||
ActiveGridResult: TGridResult;
|
||||
@ -3844,7 +3844,7 @@ begin
|
||||
for j:=0 to Results.ColumnCount-1 do begin
|
||||
case ActiveGridResult.Columns[j].DatatypeCat of
|
||||
dtcInteger, dtcReal: ActiveGridResult.Rows[i].Cells[j].Text := FormatNumber(Results.Col(j), False);
|
||||
dtcBinary: ActiveGridResult.Rows[i].Cells[j].Text := '0x' + BinToWideHex(Results.Col(j));
|
||||
dtcBinary: ActiveGridResult.Rows[i].Cells[j].Text := '0x' + BinToWideHex(Results.ColAsAnsi(j));
|
||||
else ActiveGridResult.Rows[i].Cells[j].Text := Results.Col(j);
|
||||
end;
|
||||
ActiveGridResult.Rows[i].Cells[j].IsNull := Results.IsNull(j);
|
||||
@ -3892,9 +3892,9 @@ var
|
||||
i,j : Integer;
|
||||
Results : TMySQLQuery;
|
||||
DBObjects : TDBObjectList;
|
||||
sql, TableClauses: WideString;
|
||||
sql, TableClauses: String;
|
||||
Tables : TStringList;
|
||||
tablename : WideString;
|
||||
tablename : String;
|
||||
rx : TRegExpr;
|
||||
PrevShortToken,
|
||||
PrevLongToken,
|
||||
@ -3921,9 +3921,9 @@ var
|
||||
Proposal.ItemList.Add( WideFormat(SYNCOMPLETION_PATTERN, [Icon, LowerCase(Obj.ObjType), Obj.Name]) );
|
||||
end;
|
||||
|
||||
procedure addColumns( tablename: WideString );
|
||||
procedure addColumns( tablename: String );
|
||||
var
|
||||
dbname : WideString;
|
||||
dbname : String;
|
||||
Columns: TMySQLQuery;
|
||||
begin
|
||||
dbname := ActiveDatabase;
|
||||
@ -4200,7 +4200,7 @@ end;
|
||||
}
|
||||
procedure TMainForm.QuickFilterClick(Sender: TObject);
|
||||
var
|
||||
filter,value,column : WideString;
|
||||
filter,value,column : String;
|
||||
menuitem : TMenuItem;
|
||||
IsNull: Boolean;
|
||||
begin
|
||||
@ -4350,7 +4350,7 @@ procedure TMainForm.SynMemoQueryDragDrop(Sender, Source: TObject; X,
|
||||
Y: Integer);
|
||||
var
|
||||
src : TControl;
|
||||
Text : WideString;
|
||||
Text : String;
|
||||
LoadText : Boolean;
|
||||
i: Integer;
|
||||
begin
|
||||
@ -4493,7 +4493,7 @@ end;
|
||||
procedure TMainForm.QueryLoad( filename: String; ReplaceContent: Boolean = true );
|
||||
|
||||
var
|
||||
filecontent : WideString;
|
||||
filecontent : String;
|
||||
msgtext : String;
|
||||
LineBreaks : TLineBreaks;
|
||||
begin
|
||||
@ -4674,7 +4674,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function TMainForm.GetActiveDatabase: WideString;
|
||||
function TMainForm.GetActiveDatabase: String;
|
||||
var
|
||||
s: PVirtualNode;
|
||||
begin
|
||||
@ -4726,7 +4726,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TMainForm.SelectDBObject(Text: WideString; NodeType: TListNodeType);
|
||||
procedure TMainForm.SelectDBObject(Text: String; NodeType: TListNodeType);
|
||||
var
|
||||
dbnode, tnode, snode: PVirtualNode;
|
||||
begin
|
||||
@ -4774,12 +4774,12 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TMainForm.SetSelectedDatabase(db: WideString);
|
||||
procedure TMainForm.SetSelectedDatabase(db: String);
|
||||
var
|
||||
n, f: PVirtualNode;
|
||||
i: Integer;
|
||||
DBObjects: TDBObjectList;
|
||||
Tables: WideString;
|
||||
Tables: String;
|
||||
begin
|
||||
if db = '' then
|
||||
n := DBtree.GetFirst
|
||||
@ -4931,7 +4931,7 @@ end;
|
||||
}
|
||||
procedure TMainForm.lboxQueryHelpersDblClick(Sender: TObject);
|
||||
var
|
||||
text: WideString;
|
||||
text: String;
|
||||
i: Integer;
|
||||
begin
|
||||
if ActiveQueryTabset.TabIndex = 3 then begin
|
||||
@ -5366,7 +5366,7 @@ procedure TMainForm.RestoreListSetup( List: TVirtualStringTree );
|
||||
var
|
||||
i : Byte;
|
||||
colwidth, colpos : Integer;
|
||||
Value : WideString;
|
||||
Value : String;
|
||||
ValueList : TWideStringList;
|
||||
Regname: String;
|
||||
frm: TCustomForm;
|
||||
@ -5642,10 +5642,10 @@ var
|
||||
VT : TVirtualStringTree;
|
||||
i : Integer;
|
||||
match : Boolean;
|
||||
search : WideString;
|
||||
search : String;
|
||||
tab: TTabSheet;
|
||||
VisibleCount: Cardinal;
|
||||
CellText: WideString;
|
||||
CellText: String;
|
||||
begin
|
||||
// Disable timer to avoid filtering in a loop
|
||||
TimerFilterVT.Enabled := False;
|
||||
@ -5680,7 +5680,7 @@ begin
|
||||
Exit;
|
||||
// Loop through all nodes and hide non matching
|
||||
Node := VT.GetFirst;
|
||||
search := WideLowerCase( editFilterVT.Text );
|
||||
search := LowerCase( editFilterVT.Text );
|
||||
VisibleCount := 0;
|
||||
while Assigned(Node) do begin
|
||||
// Don't filter anything if the filter text is empty
|
||||
@ -5688,7 +5688,7 @@ begin
|
||||
// Search for given text in node's captions
|
||||
if not match then for i := 0 to VT.Header.Columns.Count - 1 do begin
|
||||
CellText := VT.Text[Node, i];
|
||||
if Pos( search, WideLowerCase(CellText)) > 0 then begin
|
||||
if Pos( search, LowerCase(CellText)) > 0 then begin
|
||||
match := True;
|
||||
break;
|
||||
end;
|
||||
@ -5748,7 +5748,7 @@ procedure TMainForm.DBtreeGetText(Sender: TBaseVirtualTree; Node:
|
||||
PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var CellText: String);
|
||||
var
|
||||
DBObjects: TDBObjectList;
|
||||
db: WideString;
|
||||
db: String;
|
||||
i, j: Integer;
|
||||
Bytes: Int64;
|
||||
AllListsCached: Boolean;
|
||||
@ -5953,7 +5953,7 @@ end;
|
||||
procedure TMainForm.DBtreeFocusChanged(Sender: TBaseVirtualTree;
|
||||
Node: PVirtualNode; Column: TColumnIndex);
|
||||
var
|
||||
newDb, newDbObject: WideString;
|
||||
newDb, newDbObject: String;
|
||||
begin
|
||||
debug('DBtreeFocusChanged()');
|
||||
SelectedTableCreateStatement := '';
|
||||
@ -6035,7 +6035,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TMainForm.DatabaseChanged(Database: WideString);
|
||||
procedure TMainForm.DatabaseChanged(Database: String);
|
||||
begin
|
||||
if (Database='') or (Databases.IndexOf(Database) > -1) then
|
||||
ActiveDatabase := Database;
|
||||
@ -6073,9 +6073,9 @@ end;
|
||||
{**
|
||||
Refresh the whole tree
|
||||
}
|
||||
procedure TMainForm.RefreshTree(DoResetTableCache: Boolean; SelectDatabase: WideString = '');
|
||||
procedure TMainForm.RefreshTree(DoResetTableCache: Boolean; SelectDatabase: String = '');
|
||||
var
|
||||
oldActiveDatabase, oldSelectedTableName: WideString;
|
||||
oldActiveDatabase, oldSelectedTableName: String;
|
||||
oldSelectedTableType: TListNodeType;
|
||||
begin
|
||||
// Remember currently active database and table
|
||||
@ -6110,9 +6110,9 @@ end;
|
||||
{**
|
||||
Refresh one database node in the db tree
|
||||
}
|
||||
procedure TMainForm.RefreshTreeDB(db: WideString);
|
||||
procedure TMainForm.RefreshTreeDB(db: String);
|
||||
var
|
||||
oldActiveDatabase, oldSelectedTableName: WideString;
|
||||
oldActiveDatabase, oldSelectedTableName: String;
|
||||
oldSelectedTableType: TListNodeType;
|
||||
DBNode, FNode: PVirtualNode;
|
||||
TableHereHadFocus: Boolean;
|
||||
@ -6153,7 +6153,7 @@ end;
|
||||
{**
|
||||
Find a database node in the tree by passing its name
|
||||
}
|
||||
function TMainForm.FindDBNode(db: WideString): PVirtualNode;
|
||||
function TMainForm.FindDBNode(db: String): PVirtualNode;
|
||||
var
|
||||
i, s: Integer;
|
||||
n: PVirtualNode;
|
||||
@ -6211,7 +6211,7 @@ end;
|
||||
|
||||
procedure TMainForm.editFilterSearchChange(Sender: TObject);
|
||||
var
|
||||
Add, Clause: WideString;
|
||||
Add, Clause: String;
|
||||
i: Integer;
|
||||
ed: TEdit;
|
||||
Col: TTableColumn;
|
||||
@ -6272,10 +6272,10 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TMainForm.EnsureNodeLoaded(Sender: TBaseVirtualTree; Node: PVirtualNode; WhereClause: WideString);
|
||||
procedure TMainForm.EnsureNodeLoaded(Sender: TBaseVirtualTree; Node: PVirtualNode; WhereClause: String);
|
||||
var
|
||||
res: TGridResult;
|
||||
query: WideString;
|
||||
query: String;
|
||||
Results: TMySQLQuery;
|
||||
i, j: LongInt;
|
||||
begin
|
||||
@ -6311,7 +6311,7 @@ begin
|
||||
for j := 0 to Results.ColumnCount - 1 do begin
|
||||
case res.Columns[j].DatatypeCat of
|
||||
dtcInteger, dtcReal: res.Rows[i].Cells[j].Text := FormatNumber(Results.Col(j), False);
|
||||
dtcBinary: res.Rows[i].Cells[j].Text := '0x' + BinToWideHex(Results.Col(j));
|
||||
dtcBinary: res.Rows[i].Cells[j].Text := '0x' + BinToWideHex(Results.ColAsAnsi(j));
|
||||
else res.Rows[i].Cells[j].Text := Results.Col(j);
|
||||
end;
|
||||
res.Rows[i].Cells[j].IsNull := Results.IsNull(j);
|
||||
@ -6328,7 +6328,7 @@ procedure TMainForm.EnsureChunkLoaded(Sender: TBaseVirtualTree; Node: PVirtualNo
|
||||
var
|
||||
res: TGridResult;
|
||||
start, limit: Cardinal;
|
||||
query: WideString;
|
||||
query: String;
|
||||
Results: TMySQLQuery;
|
||||
i, j: LongInt;
|
||||
hi: LongInt;
|
||||
@ -6387,7 +6387,7 @@ begin
|
||||
for j:=0 to Results.ColumnCount-1 do begin
|
||||
case res.Columns[j].DatatypeCat of
|
||||
dtcInteger, dtcReal: res.Rows[i].Cells[j].Text := FormatNumber(Results.Col(j), False);
|
||||
dtcBinary: res.Rows[i].Cells[j].Text := '0x' + BinToWideHex(Results.Col(j));
|
||||
dtcBinary: res.Rows[i].Cells[j].Text := '0x' + BinToWideHex(Results.ColAsAnsi(j));
|
||||
else res.Rows[i].Cells[j].Text := Results.Col(j);
|
||||
end;
|
||||
res.Rows[i].Cells[j].IsNull := Results.IsNull(j);
|
||||
@ -6518,7 +6518,7 @@ var
|
||||
frm: TForm;
|
||||
i, j : Integer;
|
||||
columnexists : Boolean;
|
||||
ColName: WideString;
|
||||
ColName: String;
|
||||
begin
|
||||
if HitInfo.Column = NoColumn then
|
||||
Exit;
|
||||
@ -6664,7 +6664,7 @@ end;
|
||||
function TMainForm.GridPostUpdate(Sender: TBaseVirtualTree): Boolean;
|
||||
var
|
||||
i: Integer;
|
||||
sql, Val: WideString;
|
||||
sql, Val: String;
|
||||
Row: PGridRow;
|
||||
begin
|
||||
sql := 'UPDATE '+mask(DataGridDB)+'.'+mask(DataGridTable)+' SET';
|
||||
@ -6746,10 +6746,10 @@ end;
|
||||
{**
|
||||
Compose a WHERE clause used for UPDATEs and DELETEs
|
||||
}
|
||||
function TMainForm.GetWhereClause(Row: PGridRow; Columns: PGridColumns): WideString;
|
||||
function TMainForm.GetWhereClause(Row: PGridRow; Columns: PGridColumns): String;
|
||||
var
|
||||
i, j: Integer;
|
||||
KeyVal: WideString;
|
||||
KeyVal: String;
|
||||
KeyCols: TWideStringlist;
|
||||
begin
|
||||
Result := '';
|
||||
@ -6828,7 +6828,7 @@ end;
|
||||
procedure TMainForm.DataGridInsertRow(CopyValuesFromNode: PVirtualNode);
|
||||
var
|
||||
i, j: Integer;
|
||||
Val: WideString;
|
||||
Val: String;
|
||||
begin
|
||||
// Scroll to the bottom to ensure we append the new row at the very last DataGridResult chunk
|
||||
DataGrid.FocusedNode := DataGrid.GetLast;
|
||||
@ -6863,7 +6863,7 @@ end;
|
||||
function TMainForm.GridPostInsert(Sender: TBaseVirtualTree): Boolean;
|
||||
var
|
||||
Row: PGridRow;
|
||||
sql, Cols, Val, Vals: WideString;
|
||||
sql, Cols, Val, Vals: String;
|
||||
i: Integer;
|
||||
Node: PVirtualNode;
|
||||
begin
|
||||
@ -6930,7 +6930,7 @@ function TMainForm.GridPostDelete(Sender: TBaseVirtualTree): Boolean;
|
||||
var
|
||||
Node, FocusAfterDelete: PVirtualNode;
|
||||
Nodes: TNodeArray;
|
||||
sql: WideString;
|
||||
sql: String;
|
||||
Affected, Matching: Int64;
|
||||
Selected, i, j: Integer;
|
||||
msg: String;
|
||||
@ -7050,7 +7050,7 @@ var
|
||||
Cell: PGridCell;
|
||||
Row: PGridRow;
|
||||
Col: PGridColumn;
|
||||
sql: WideString;
|
||||
sql: String;
|
||||
len: Int64;
|
||||
Results: TMySQLQuery;
|
||||
begin
|
||||
@ -7077,7 +7077,7 @@ begin
|
||||
Results := Connection.GetResults(sql);
|
||||
case Col.DatatypeCat of
|
||||
dtcInteger, dtcReal: Cell.Text := FormatNumber(Results.Col(0), False);
|
||||
dtcBinary: Cell.Text := '0x' + BinToWideHex(Results.Col(0));
|
||||
dtcBinary: Cell.Text := '0x' + BinToWideHex(Results.ColAsAnsi(0));
|
||||
else Cell.Text := Results.Col(0);
|
||||
end;
|
||||
Cell.IsNull := Results.IsNull(0);
|
||||
@ -7293,7 +7293,7 @@ var
|
||||
Col: TTableColumn;
|
||||
HiddenCols: TWideStringList;
|
||||
TestList: TStringList;
|
||||
Sort: WideString;
|
||||
Sort: String;
|
||||
begin
|
||||
OpenRegistry;
|
||||
MainReg.OpenKey(GetRegKeyTable, True);
|
||||
@ -7318,20 +7318,20 @@ begin
|
||||
HiddenCols.Add(Col.Name);
|
||||
end;
|
||||
if HiddenCols.Count > 0 then
|
||||
MainReg.WriteString(REGNAME_HIDDENCOLUMNS, Utf8Encode(HiddenCols.DelimitedText))
|
||||
MainReg.WriteString(REGNAME_HIDDENCOLUMNS, HiddenCols.DelimitedText)
|
||||
else if MainReg.ValueExists(REGNAME_HIDDENCOLUMNS) then
|
||||
MainReg.DeleteValue(REGNAME_HIDDENCOLUMNS);
|
||||
FreeAndNil(HiddenCols);
|
||||
|
||||
if SynMemoFilter.GetTextLen > 0 then
|
||||
MainReg.WriteString(REGNAME_FILTER, Utf8Encode(SynMemoFilter.Text))
|
||||
MainReg.WriteString(REGNAME_FILTER, SynMemoFilter.Text)
|
||||
else if MainReg.ValueExists(REGNAME_FILTER) then
|
||||
MainReg.DeleteValue(REGNAME_FILTER);
|
||||
|
||||
for i := 0 to High(FDataGridSort) do
|
||||
Sort := Sort + IntToStr(FDataGridSort[i].SortDirection) + '_' + FDataGridSort[i].ColumnName + REGDELIM;
|
||||
if Sort <> '' then
|
||||
MainReg.WriteString(REGNAME_SORT, Utf8Encode(Sort))
|
||||
MainReg.WriteString(REGNAME_SORT, Sort)
|
||||
else if MainReg.ValueExists(REGNAME_SORT) then
|
||||
MainReg.DeleteValue(REGNAME_SORT);
|
||||
|
||||
@ -7358,7 +7358,7 @@ begin
|
||||
HiddenCols := TWideStringlist.Create;
|
||||
HiddenCols.Delimiter := REGDELIM;
|
||||
HiddenCols.StrictDelimiter := True;
|
||||
HiddenCols.DelimitedText := Utf8Decode(MainReg.ReadString(REGNAME_HIDDENCOLUMNS));
|
||||
HiddenCols.DelimitedText := MainReg.ReadString(REGNAME_HIDDENCOLUMNS);
|
||||
FDataGridSelect.Clear;
|
||||
for i:=0 to SelectedTableColumns.Count-1 do begin
|
||||
Col := TTableColumn(SelectedTableColumns[i]);
|
||||
@ -7370,7 +7370,7 @@ begin
|
||||
|
||||
// Filter
|
||||
if MainReg.ValueExists(REGNAME_FILTER) then begin
|
||||
SynMemoFilter.Text := Utf8Decode(MainReg.ReadString(REGNAME_FILTER));
|
||||
SynMemoFilter.Text := MainReg.ReadString(REGNAME_FILTER);
|
||||
if SynMemoFilter.GetTextLen > 0 then
|
||||
ToggleFilterPanel(True);
|
||||
end;
|
||||
@ -7381,7 +7381,7 @@ begin
|
||||
rx := TRegExpr.Create;
|
||||
rx.Expression := '\b(\d)_(.+)\'+REGDELIM;
|
||||
rx.ModifierG := False;
|
||||
if rx.Exec(Utf8Decode(MainReg.ReadString(REGNAME_SORT))) then while true do begin
|
||||
if rx.Exec(MainReg.ReadString(REGNAME_SORT)) then while true do begin
|
||||
idx := Length(FDataGridSort);
|
||||
SetLength(FDataGridSort, idx+1);
|
||||
FDataGridSort[idx] := TOrderCol.Create;
|
||||
@ -7399,7 +7399,7 @@ function TMainForm.GetRegKeyTable: String;
|
||||
begin
|
||||
// Return the slightly complex registry path to \Servers\ThisServer\curdb|curtable
|
||||
Result := REGPATH + REGKEY_SESSIONS + SessionName + '\' +
|
||||
Utf8Encode(ActiveDatabase) + REGDELIM + Utf8Encode(SelectedTable.Name);
|
||||
ActiveDatabase + REGDELIM + SelectedTable.Name;
|
||||
end;
|
||||
|
||||
|
||||
@ -7487,7 +7487,7 @@ var
|
||||
valcount: Int64;
|
||||
tmpval: Double;
|
||||
Results: TMySQLQuery;
|
||||
val, avg_perhour, avg_persec: WideString;
|
||||
val, avg_perhour, avg_persec: String;
|
||||
valIsBytes, valIsNumber: Boolean;
|
||||
vt: TVirtualStringTree;
|
||||
Sel: TWideStringList;
|
||||
@ -7560,7 +7560,7 @@ var
|
||||
Results: TMySQLQuery;
|
||||
vt: TVirtualStringTree;
|
||||
Sel: TWideStringList;
|
||||
Text: WideString;
|
||||
Text: String;
|
||||
const
|
||||
InfoLen = SIZE_KB*10;
|
||||
begin
|
||||
@ -7620,7 +7620,7 @@ end;
|
||||
|
||||
|
||||
procedure TMainForm.ListCommandStatsBeforePaint(Sender: TBaseVirtualTree; TargetCanvas: TCanvas);
|
||||
procedure addLVitem( idx: Integer; caption: WideString; commandCount: Int64; totalCount: Int64 );
|
||||
procedure addLVitem( idx: Integer; caption: String; commandCount: Int64; totalCount: Int64 );
|
||||
var
|
||||
tmpval : Double;
|
||||
begin
|
||||
@ -7716,7 +7716,7 @@ begin
|
||||
end else if Control is TCustomComboBox then begin
|
||||
Combo := TCustomComboBox(Control);
|
||||
if Combo.SelLength > 0 then begin
|
||||
CopyToClipboard(Combo.SelText);
|
||||
Clipboard.AsText := Combo.SelText;
|
||||
if DoCut then Combo.SelText := '';
|
||||
Success := True;
|
||||
end;
|
||||
@ -7725,7 +7725,7 @@ begin
|
||||
if Assigned(Grid.FocusedNode) then begin
|
||||
if Grid = ActiveGrid then
|
||||
EnsureFullWidth(Grid, Grid.FocusedColumn, Grid.FocusedNode);
|
||||
CopyToClipboard(Grid.Text[Grid.FocusedNode, Grid.FocusedColumn]);
|
||||
Clipboard.AsText := Grid.Text[Grid.FocusedNode, Grid.FocusedColumn];
|
||||
if (Grid = ActiveGrid) and DoCut then
|
||||
Grid.Text[Grid.FocusedNode, Grid.FocusedColumn] := '';
|
||||
Success := True;
|
||||
@ -7751,12 +7751,10 @@ var
|
||||
Grid: TVirtualStringTree;
|
||||
SynMemo: TSynMemo;
|
||||
Success: Boolean;
|
||||
CB: TUniClipboard;
|
||||
begin
|
||||
// Paste text into the focused control
|
||||
Success := False;
|
||||
Control := Screen.ActiveControl;
|
||||
CB := TUniClipboard.Create;
|
||||
// Do not handle Search/replace dialog
|
||||
if not Control.Focused then Exit;
|
||||
if not Clipboard.HasFormat(CF_TEXT) then begin
|
||||
@ -7770,13 +7768,13 @@ begin
|
||||
end else if Control is TComboBox then begin
|
||||
Combo := TComboBox(Control);
|
||||
if Combo.Style = csDropDown then begin
|
||||
Combo.SelText := CB.AsWideString;
|
||||
Combo.SelText := ClipBoard.AsText;
|
||||
Success := True;
|
||||
end;
|
||||
end else if Control is TVirtualStringTree then begin
|
||||
Grid := Control as TVirtualStringTree;
|
||||
if Assigned(Grid.FocusedNode) and (Grid = ActiveGrid) then begin
|
||||
Grid.Text[Grid.FocusedNode, Grid.FocusedColumn] := CB.AsWideString;
|
||||
Grid.Text[Grid.FocusedNode, Grid.FocusedColumn] := ClipBoard.AsText;
|
||||
Success := True;
|
||||
end;
|
||||
end else if Control is TSynMemo then begin
|
||||
@ -7887,7 +7885,6 @@ begin
|
||||
item.Tag := MakeInt(flt[i]);
|
||||
item.OnClick := LoadRecentFilter;
|
||||
menuRecentFilters.Add(item);
|
||||
capt := Utf8Decode(capt);
|
||||
comboRecentFilters.Items.Add(sstr(capt, 100));
|
||||
end;
|
||||
FreeAndNil(rx);
|
||||
@ -7919,7 +7916,7 @@ begin
|
||||
SynMemoFilter.UndoList.AddGroupBreak;
|
||||
SynMemoFilter.BeginUpdate;
|
||||
SynMemoFilter.SelectAll;
|
||||
SynMemoFilter.SelText := Utf8Decode( MainReg.ReadString(IntToStr(key)) );
|
||||
SynMemoFilter.SelText := MainReg.ReadString(IntToStr(key));
|
||||
SynMemoFilter.EndUpdate;
|
||||
end;
|
||||
end;
|
||||
@ -8006,9 +8003,9 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TMainForm.SetEditorTabCaption(Editor: TDBObjectEditor; ObjName: WideString);
|
||||
procedure TMainForm.SetEditorTabCaption(Editor: TDBObjectEditor; ObjName: String);
|
||||
var
|
||||
ObjType, Cap: WideString;
|
||||
ObjType, Cap: String;
|
||||
IconIndex: Integer;
|
||||
begin
|
||||
if Editor = TableEditor then begin
|
||||
@ -8038,7 +8035,7 @@ end;
|
||||
procedure TMainForm.actEditObjectExecute(Sender: TObject);
|
||||
var
|
||||
NodeData: PVTreeData;
|
||||
db: WideString;
|
||||
db: String;
|
||||
begin
|
||||
debug('actEditObjectExecute()');
|
||||
if ListTables.Focused then begin
|
||||
@ -8508,7 +8505,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TMainForm.SetTabCaption(PageIndex: Integer; Text: WideString);
|
||||
procedure TMainForm.SetTabCaption(PageIndex: Integer; Text: String);
|
||||
begin
|
||||
// Special case if passed text is empty: Reset query tab caption to "Query #123"
|
||||
if (PageIndex = tabQuery.PageIndex) and (Text = '') then
|
||||
@ -8565,7 +8562,7 @@ end;
|
||||
procedure TMainForm.comboOnlyDBsExit(Sender: TObject);
|
||||
var
|
||||
i, idx: Integer;
|
||||
FilterText: WideString;
|
||||
FilterText: String;
|
||||
begin
|
||||
// Add (move) custom filter text to (in) drop down history, if not empty
|
||||
FilterText := comboOnlyDBs.Text;
|
||||
@ -8595,7 +8592,7 @@ end;
|
||||
procedure TMainForm.comboOnlyDBsDragDrop(Sender, Source: TObject; X, Y: Integer);
|
||||
var
|
||||
dbs: TWideStringList;
|
||||
newdb: WideString;
|
||||
newdb: String;
|
||||
begin
|
||||
// DBtree node dropped on DB filter dropdown
|
||||
dbs := Explode(';', comboOnlyDBs.Text);
|
||||
@ -8645,7 +8642,7 @@ end;
|
||||
procedure TMainForm.UpdateFilterPanel(Sender: TObject);
|
||||
var
|
||||
tab: TTabSheet;
|
||||
f: WideString;
|
||||
f: String;
|
||||
FilterPanelVisible: Boolean;
|
||||
begin
|
||||
// Called when active tab changes
|
||||
@ -8765,7 +8762,7 @@ var
|
||||
Control: TWinControl;
|
||||
m: TCustomSynEdit;
|
||||
CursorPosStart, CursorPosEnd: Integer;
|
||||
NewSQL: WideString;
|
||||
NewSQL: String;
|
||||
begin
|
||||
// Reformat SQL query
|
||||
m := nil;
|
||||
@ -8822,7 +8819,7 @@ end;
|
||||
procedure TMainForm.menuQueryHelpersGenerateStatementClick(Sender: TObject);
|
||||
var
|
||||
MenuItem: TMenuItem;
|
||||
sql, Val, WhereClause: WideString;
|
||||
sql, Val, WhereClause: String;
|
||||
i, idx: Integer;
|
||||
ColumnNames, DefaultValues, KeyColumns: TWideStringlist;
|
||||
Column: TTableColumn;
|
||||
|
@ -12,7 +12,7 @@ type
|
||||
TListNodeType = (lntNone, lntDb, lntTable, lntView, lntFunction, lntProcedure, lntTrigger, lntColumn);
|
||||
TListNodeTypes = Set of TListNodeType;
|
||||
TDBObject = class
|
||||
Name, Database, Engine, Comment, RowFormat, CreateOptions, Collation, ObjType: WideString;
|
||||
Name, Database, Engine, Comment, RowFormat, CreateOptions, Collation, ObjType: String;
|
||||
Created, Updated, LastChecked: TDateTime;
|
||||
Rows, Size, Version, AvgRowLen, MaxDataLen, IndexLen, DataLen, DataFree, AutoInc, CheckSum: Int64;
|
||||
NodeType: TListNodeType;
|
||||
@ -31,8 +31,8 @@ type
|
||||
{ TMySQLConnection }
|
||||
|
||||
TMySQLLogCategory = (lcInfo, lcSQL, lcError, lcWarning, lcDebug);
|
||||
TMySQLLogEvent = procedure(Msg: WideString; Category: TMySQLLogCategory=lcInfo) of object;
|
||||
TMySQLDatabaseChangedEvent = procedure(Database: WideString) of object;
|
||||
TMySQLLogEvent = procedure(Msg: String; Category: TMySQLLogCategory=lcInfo) of object;
|
||||
TMySQLDatabaseChangedEvent = procedure(Database: String) of object;
|
||||
|
||||
TMySQLServerCapability = (
|
||||
cpShowEngines, // SHOW ENGINES
|
||||
@ -89,35 +89,35 @@ type
|
||||
FActive: Boolean;
|
||||
FConnectionStarted: Integer;
|
||||
FServerStarted: Integer;
|
||||
FHostname: AnsiString;
|
||||
FSocketname: AnsiString;
|
||||
FHostname: String;
|
||||
FSocketname: String;
|
||||
FPort: Integer;
|
||||
FUsername: AnsiString;
|
||||
FPassword: AnsiString;
|
||||
FDatabase: WideString;
|
||||
FLogPrefix: WideString;
|
||||
FUsername: String;
|
||||
FPassword: String;
|
||||
FDatabase: String;
|
||||
FLogPrefix: String;
|
||||
FOnLog: TMySQLLogEvent;
|
||||
FOnDatabaseChanged: TMySQLDatabaseChangedEvent;
|
||||
FOptions: TMySQLClientOptions;
|
||||
FCapabilities: TMySQLServerCapabilities;
|
||||
FRowsFound: Int64;
|
||||
FRowsAffected: Int64;
|
||||
FServerVersionUntouched: AnsiString;
|
||||
FServerVersionUntouched: String;
|
||||
FLastQueryDuration, FLastQueryNetworkDuration: Cardinal;
|
||||
FIsUnicode: Boolean;
|
||||
FTableEngines: TStringList;
|
||||
FTableEngineDefault: AnsiString;
|
||||
FTableEngineDefault: String;
|
||||
FCollationTable: TMySQLQuery;
|
||||
FCharsetTable: TMySQLQuery;
|
||||
FInformationSchemaObjects: TWideStringlist;
|
||||
FDBObjectLists: TWideStringList;
|
||||
procedure SetActive(Value: Boolean);
|
||||
procedure SetDatabase(Value: WideString);
|
||||
procedure SetDatabase(Value: String);
|
||||
function GetThreadId: Cardinal;
|
||||
function GetCharacterSet: AnsiString;
|
||||
procedure SetCharacterSet(CharsetName: AnsiString);
|
||||
function GetLastError: WideString;
|
||||
function GetServerVersionStr: AnsiString;
|
||||
function GetCharacterSet: String;
|
||||
procedure SetCharacterSet(CharsetName: String);
|
||||
function GetLastError: String;
|
||||
function GetServerVersionStr: String;
|
||||
function GetServerVersionInt: Integer;
|
||||
function GetTableEngines: TStringList;
|
||||
function GetCollationTable: TMySQLQuery;
|
||||
@ -127,33 +127,33 @@ type
|
||||
function GetInformationSchemaObjects: TWideStringlist;
|
||||
function GetConnectionUptime: Integer;
|
||||
function GetServerUptime: Integer;
|
||||
procedure Log(Category: TMySQLLogCategory; Msg: WideString);
|
||||
procedure Log(Category: TMySQLLogCategory; Msg: String);
|
||||
procedure DetectCapabilities;
|
||||
procedure ClearCache;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
function Query(SQL: WideString; DoStoreResult: Boolean=False): PMYSQL_RES;
|
||||
function EscapeString(Text: WideString; ProcessJokerChars: Boolean=False): WideString;
|
||||
function escChars(const Text: WideString; EscChar, Char1, Char2, Char3, Char4: WideChar): WideString;
|
||||
function QuoteIdent(Identifier: WideString): WideString;
|
||||
function DeQuoteIdent(Identifier: WideString): WideString;
|
||||
function ConvertServerVersion(Version: Integer): AnsiString;
|
||||
function GetResults(SQL: WideString): TMySQLQuery;
|
||||
function GetCol(SQL: WideString; Column: Integer=0): TWideStringList;
|
||||
function GetVar(SQL: WideString; Column: Integer=0): WideString; overload;
|
||||
function GetVar(SQL: WideString; Column: WideString): WideString; overload;
|
||||
function Query(SQL: String; DoStoreResult: Boolean=False): PMYSQL_RES;
|
||||
function EscapeString(Text: String; ProcessJokerChars: Boolean=False): String;
|
||||
function escChars(const Text: String; EscChar, Char1, Char2, Char3, Char4: WideChar): String;
|
||||
function QuoteIdent(Identifier: String): String;
|
||||
function DeQuoteIdent(Identifier: String): String;
|
||||
function ConvertServerVersion(Version: Integer): String;
|
||||
function GetResults(SQL: String): TMySQLQuery;
|
||||
function GetCol(SQL: String; Column: Integer=0): TWideStringList;
|
||||
function GetVar(SQL: String; Column: Integer=0): String; overload;
|
||||
function GetVar(SQL: String; Column: String): String; overload;
|
||||
function Ping: Boolean;
|
||||
function GetDBObjects(db: WideString; Refresh: Boolean=False): TDBObjectList;
|
||||
function DbObjectsCached(db: WideString): Boolean;
|
||||
procedure ClearDbObjects(db: WideString='');
|
||||
function GetDBObjects(db: String; Refresh: Boolean=False): TDBObjectList;
|
||||
function DbObjectsCached(db: String): Boolean;
|
||||
procedure ClearDbObjects(db: String='');
|
||||
property ThreadId: Cardinal read GetThreadId;
|
||||
property ConnectionUptime: Integer read GetConnectionUptime;
|
||||
property ServerUptime: Integer read GetServerUptime;
|
||||
property CharacterSet: AnsiString read GetCharacterSet write SetCharacterSet;
|
||||
property LastError: WideString read GetLastError;
|
||||
property ServerVersionUntouched: AnsiString read FServerVersionUntouched;
|
||||
property ServerVersionStr: AnsiString read GetServerVersionStr;
|
||||
property CharacterSet: String read GetCharacterSet write SetCharacterSet;
|
||||
property LastError: String read GetLastError;
|
||||
property ServerVersionUntouched: String read FServerVersionUntouched;
|
||||
property ServerVersionStr: String read GetServerVersionStr;
|
||||
property ServerVersionInt: Integer read GetServerVersionInt;
|
||||
property Capabilities: TMySQLServerCapabilities read FCapabilities;
|
||||
property RowsFound: Int64 read FRowsFound;
|
||||
@ -162,7 +162,7 @@ type
|
||||
property LastQueryNetworkDuration: Cardinal read FLastQueryNetworkDuration;
|
||||
property IsUnicode: Boolean read FIsUnicode;
|
||||
property TableEngines: TStringList read GetTableEngines;
|
||||
property TableEngineDefault: AnsiString read FTableEngineDefault;
|
||||
property TableEngineDefault: String read FTableEngineDefault;
|
||||
property CollationTable: TMySQLQuery read GetCollationTable;
|
||||
property CollationList: TStringList read GetCollationList;
|
||||
property CharsetTable: TMySQLQuery read GetCharsetTable;
|
||||
@ -170,14 +170,14 @@ type
|
||||
property InformationSchemaObjects: TWideStringlist read GetInformationSchemaObjects;
|
||||
published
|
||||
property Active: Boolean read FActive write SetActive default False;
|
||||
property Hostname: AnsiString read FHostname write FHostname;
|
||||
property Socketname: AnsiString read FSocketname write FSocketname;
|
||||
property Hostname: String read FHostname write FHostname;
|
||||
property Socketname: String read FSocketname write FSocketname;
|
||||
property Port: Integer read FPort write FPort default MYSQL_PORT;
|
||||
property Username: AnsiString read FUsername write FUsername;
|
||||
property Password: AnsiString read FPassword write FPassword;
|
||||
property Database: WideString read FDatabase write SetDatabase;
|
||||
property Username: String read FUsername write FUsername;
|
||||
property Password: String read FPassword write FPassword;
|
||||
property Database: String read FDatabase write SetDatabase;
|
||||
property Options: TMySQLClientOptions read FOptions write FOptions default [opCompress, opLocalFiles, opInteractive, opProtocol41];
|
||||
property LogPrefix: WideString read FLogPrefix write FLogPrefix;
|
||||
property LogPrefix: String read FLogPrefix write FLogPrefix;
|
||||
// Events
|
||||
property OnLog: TMySQLLogEvent read FOnLog write FOnLog;
|
||||
property OnDatabaseChanged: TMySQLDatabaseChangedEvent read FOnDatabaseChanged write FOnDatabaseChanged;
|
||||
@ -188,7 +188,7 @@ type
|
||||
|
||||
TMySQLQuery = class(TComponent)
|
||||
private
|
||||
FSQL: WideString;
|
||||
FSQL: String;
|
||||
FConnection: TMySQLConnection;
|
||||
FRecNo,
|
||||
FRecordCount: Int64;
|
||||
@ -197,7 +197,7 @@ type
|
||||
FCurrentRow: PMYSQL_ROW;
|
||||
FEof: Boolean;
|
||||
FDatatypes: Array of TDatatype;
|
||||
procedure SetSQL(Value: WideString);
|
||||
procedure SetSQL(Value: String);
|
||||
procedure SetRecNo(Value: Int64);
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
@ -206,20 +206,21 @@ type
|
||||
procedure First;
|
||||
procedure Next;
|
||||
function ColumnCount: Integer;
|
||||
function Col(Column: Integer; IgnoreErrors: Boolean=False): WideString; overload;
|
||||
function Col(ColumnName: WideString; IgnoreErrors: Boolean=False): WideString; overload;
|
||||
function Col(Column: Integer; IgnoreErrors: Boolean=False): String; overload;
|
||||
function Col(ColumnName: String; IgnoreErrors: Boolean=False): String; overload;
|
||||
function ColAsAnsi(Column: Integer; IgnoreErrors: Boolean=False): AnsiString;
|
||||
function DataType(Column: Integer): TDataType;
|
||||
function ColExists(Column: WideString): Boolean;
|
||||
function ColExists(Column: String): Boolean;
|
||||
function ColIsPrimaryKeyPart(Column: Integer): Boolean;
|
||||
function IsNull(Column: Integer): Boolean; overload;
|
||||
function IsNull(Column: WideString): Boolean; overload;
|
||||
function IsNull(Column: String): Boolean; overload;
|
||||
function HasResult: Boolean;
|
||||
property RecNo: Int64 read FRecNo write SetRecNo;
|
||||
property Eof: Boolean read FEof;
|
||||
property RecordCount: Int64 read FRecordCount;
|
||||
property ColumnNames: TWideStringList read FColumnNames;
|
||||
published
|
||||
property SQL: WideString read FSQL write SetSQL;
|
||||
property SQL: String read FSQL write SetSQL;
|
||||
property Connection: TMySQLConnection read FConnection write FConnection;
|
||||
end;
|
||||
|
||||
@ -259,8 +260,8 @@ procedure TMySQLConnection.SetActive( Value: Boolean );
|
||||
var
|
||||
Connected: PMYSQL;
|
||||
ClientFlags: Integer;
|
||||
Error, tmpdb: WideString;
|
||||
UsingPass, Protocol, CurCharset: AnsiString;
|
||||
Error, tmpdb: String;
|
||||
UsingPass, Protocol, CurCharset: String;
|
||||
begin
|
||||
FActive := Value;
|
||||
|
||||
@ -299,12 +300,12 @@ begin
|
||||
', using password: '+UsingPass+' ...');
|
||||
Connected := mysql_real_connect(
|
||||
FHandle,
|
||||
PAnsiChar(FHostname),
|
||||
PAnsiChar(FUsername),
|
||||
PAnsiChar(FPassword),
|
||||
PAnsiChar(Utf8Encode(FHostname)),
|
||||
PAnsiChar(Utf8Encode(FUsername)),
|
||||
PAnsiChar(Utf8Encode(FPassword)),
|
||||
nil,
|
||||
FPort,
|
||||
PAnsiChar(FSocketname),
|
||||
PAnsiChar(Utf8Encode(FSocketname)),
|
||||
ClientFlags
|
||||
);
|
||||
if Connected = nil then begin
|
||||
@ -322,7 +323,7 @@ begin
|
||||
FIsUnicode := CurCharset = 'utf8';
|
||||
FConnectionStarted := GetTickCount div 1000;
|
||||
FServerStarted := FConnectionStarted - StrToIntDef(GetVar('SHOW STATUS LIKE ''Uptime''', 1), 1);
|
||||
FServerVersionUntouched := mysql_get_server_info(FHandle);
|
||||
FServerVersionUntouched := Utf8ToString(mysql_get_server_info(FHandle));
|
||||
DetectCapabilities;
|
||||
if FDatabase <> '' then begin
|
||||
tmpdb := FDatabase;
|
||||
@ -362,7 +363,7 @@ end;
|
||||
{**
|
||||
Executes a query
|
||||
}
|
||||
function TMySQLConnection.Query(SQL: WideString; DoStoreResult: Boolean=False): PMYSQL_RES;
|
||||
function TMySQLConnection.Query(SQL: String; DoStoreResult: Boolean=False): PMYSQL_RES;
|
||||
var
|
||||
querystatus: Integer;
|
||||
NativeSQL: AnsiString;
|
||||
@ -418,7 +419,7 @@ end;
|
||||
{**
|
||||
Set "Database" property and select that db if connected
|
||||
}
|
||||
procedure TMySQLConnection.SetDatabase(Value: WideString);
|
||||
procedure TMySQLConnection.SetDatabase(Value: String);
|
||||
begin
|
||||
if Value <> FDatabase then begin
|
||||
if Value = '' then begin
|
||||
@ -443,30 +444,30 @@ end;
|
||||
{**
|
||||
Return currently used character set
|
||||
}
|
||||
function TMySQLConnection.GetCharacterSet: AnsiString;
|
||||
function TMySQLConnection.GetCharacterSet: String;
|
||||
begin
|
||||
Result := mysql_character_set_name(FHandle);
|
||||
Result := Utf8ToString(mysql_character_set_name(FHandle));
|
||||
end;
|
||||
|
||||
|
||||
{**
|
||||
Switch character set
|
||||
}
|
||||
procedure TMySQLConnection.SetCharacterSet(CharsetName: AnsiString);
|
||||
procedure TMySQLConnection.SetCharacterSet(CharsetName: String);
|
||||
begin
|
||||
mysql_set_character_set(FHandle, PAnsiChar(CharsetName));
|
||||
mysql_set_character_set(FHandle, PAnsiChar(Utf8Encode(CharsetName)));
|
||||
end;
|
||||
|
||||
|
||||
{**
|
||||
Return the last error nicely formatted
|
||||
}
|
||||
function TMySQLConnection.GetLastError: WideString;
|
||||
function TMySQLConnection.GetLastError: String;
|
||||
var
|
||||
Msg, Additional: WideString;
|
||||
Msg, Additional: String;
|
||||
rx: TRegExpr;
|
||||
begin
|
||||
Msg := Utf8Decode(mysql_error(FHandle));
|
||||
Msg := Utf8ToString(mysql_error(FHandle));
|
||||
// Find "(errno: 123)" in message and add more meaningful message from perror.exe
|
||||
rx := TRegExpr.Create;
|
||||
rx.Expression := '.+\(errno\:\s+(\d+)\)';
|
||||
@ -487,7 +488,7 @@ end;
|
||||
function TMySQLConnection.GetServerVersionInt: Integer;
|
||||
var
|
||||
i, dots: Byte;
|
||||
v1, v2, v3: AnsiString;
|
||||
v1, v2, v3: String;
|
||||
begin
|
||||
Result := -1;
|
||||
|
||||
@ -501,7 +502,7 @@ begin
|
||||
// We expect exactly 2 dots.
|
||||
if dots > 2 then
|
||||
break;
|
||||
end else if FServerVersionUntouched[i] in ['0'..'9'] then begin
|
||||
end else if CharInSet(FServerVersionUntouched[i], ['0'..'9']) then begin
|
||||
if dots = 0 then
|
||||
v1 := v1 + FServerVersionUntouched[i]
|
||||
else if dots = 1 then
|
||||
@ -522,7 +523,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function TMySQLConnection.GetServerVersionStr: AnsiString;
|
||||
function TMySQLConnection.GetServerVersionStr: String;
|
||||
begin
|
||||
Result := ConvertServerVersion(ServerVersionInt);
|
||||
end;
|
||||
@ -531,9 +532,9 @@ end;
|
||||
{**
|
||||
Convert integer version to real version string
|
||||
}
|
||||
function TMySQLConnection.ConvertServerVersion(Version: Integer): AnsiString;
|
||||
function TMySQLConnection.ConvertServerVersion(Version: Integer): String;
|
||||
var
|
||||
v : AnsiString;
|
||||
v : String;
|
||||
v1, v2 : Byte;
|
||||
begin
|
||||
v := IntToStr( Version );
|
||||
@ -543,7 +544,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function TMySQLConnection.GetResults(SQL: WideString): TMySQLQuery;
|
||||
function TMySQLConnection.GetResults(SQL: String): TMySQLQuery;
|
||||
begin
|
||||
Result := TMySQLQuery.Create(Self);
|
||||
Result.Connection := Self;
|
||||
@ -560,7 +561,7 @@ end;
|
||||
{**
|
||||
Call log event if assigned to object
|
||||
}
|
||||
procedure TMySQLConnection.Log(Category: TMySQLLogCategory; Msg: WideString);
|
||||
procedure TMySQLConnection.Log(Category: TMySQLLogCategory; Msg: String);
|
||||
begin
|
||||
if Assigned(FOnLog) then
|
||||
FOnLog(FLogPrefix+Msg, Category);
|
||||
@ -579,7 +580,7 @@ end;
|
||||
@param boolean Escape text so it can be used in a LIKE-comparison
|
||||
@return string
|
||||
}
|
||||
function TMySQLConnection.EscapeString(Text: WideString; ProcessJokerChars: Boolean=false): WideString;
|
||||
function TMySQLConnection.EscapeString(Text: String; ProcessJokerChars: Boolean=false): String;
|
||||
var
|
||||
c1, c2, c3, c4, EscChar: WideChar;
|
||||
begin
|
||||
@ -615,7 +616,7 @@ end;
|
||||
{***
|
||||
Attempt to do string replacement faster than StringReplace and WideStringReplace.
|
||||
}
|
||||
function TMySQLConnection.escChars(const Text: WideString; EscChar, Char1, Char2, Char3, Char4: WideChar): WideString;
|
||||
function TMySQLConnection.escChars(const Text: String; EscChar, Char1, Char2, Char3, Char4: WideChar): String;
|
||||
const
|
||||
// Attempt to match whatever the CPU cache will hold.
|
||||
block: Cardinal = 65536;
|
||||
@ -667,14 +668,14 @@ end;
|
||||
Add backticks to identifier
|
||||
Todo: Support ANSI style
|
||||
}
|
||||
function TMySQLConnection.QuoteIdent(Identifier: WideString): WideString;
|
||||
function TMySQLConnection.QuoteIdent(Identifier: String): String;
|
||||
begin
|
||||
Result := WideStringReplace(Identifier, '`', '``', [rfReplaceAll]);
|
||||
Result := '`' + Result + '`';
|
||||
end;
|
||||
|
||||
|
||||
function TMySQLConnection.DeQuoteIdent(Identifier: WideString): WideString;
|
||||
function TMySQLConnection.DeQuoteIdent(Identifier: String): String;
|
||||
begin
|
||||
Result := Identifier;
|
||||
if (Result[1] = '`') and (Result[Length(Identifier)] = '`') then
|
||||
@ -718,7 +719,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function TMySQLConnection.GetCol(SQL: WideString; Column: Integer=0): TWideStringList;
|
||||
function TMySQLConnection.GetCol(SQL: String; Column: Integer=0): TWideStringList;
|
||||
var
|
||||
Results: TMySQLQuery;
|
||||
begin
|
||||
@ -735,7 +736,7 @@ end;
|
||||
{**
|
||||
Get single cell value via SQL query, identified by column number
|
||||
}
|
||||
function TMySQLConnection.GetVar(SQL: WideString; Column: Integer=0): WideString;
|
||||
function TMySQLConnection.GetVar(SQL: String; Column: Integer=0): String;
|
||||
var
|
||||
Results: TMySQLQuery;
|
||||
begin
|
||||
@ -751,7 +752,7 @@ end;
|
||||
{**
|
||||
Get single cell value via SQL query, identified by column name
|
||||
}
|
||||
function TMySQLConnection.GetVar(SQL: WideString; Column: WideString): WideString;
|
||||
function TMySQLConnection.GetVar(SQL: String; Column: String): String;
|
||||
var
|
||||
Results: TMySQLQuery;
|
||||
begin
|
||||
@ -767,7 +768,7 @@ end;
|
||||
function TMySQLConnection.GetTableEngines: TStringList;
|
||||
var
|
||||
ShowEngines, HaveEngines: TMySQLQuery;
|
||||
engineName, engineSupport: AnsiString;
|
||||
engineName, engineSupport: String;
|
||||
PossibleEngines: TStringList;
|
||||
begin
|
||||
if not Assigned(FTableEngines) then begin
|
||||
@ -903,7 +904,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TMySQLConnection.ClearDbObjects(db: WideString='');
|
||||
procedure TMySQLConnection.ClearDbObjects(db: String='');
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
@ -924,14 +925,14 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function TMySQLConnection.DbObjectsCached(db: WideString): Boolean;
|
||||
function TMySQLConnection.DbObjectsCached(db: String): Boolean;
|
||||
begin
|
||||
// Check if a table list is stored in cache
|
||||
Result := Assigned(FDBObjectLists) and (FDBObjectLists.IndexOf(db) > -1);
|
||||
end;
|
||||
|
||||
|
||||
function TMySQLConnection.GetDbObjects(db: WideString; Refresh: Boolean=False): TDBObjectList;
|
||||
function TMySQLConnection.GetDbObjects(db: String; Refresh: Boolean=False): TDBObjectList;
|
||||
var
|
||||
obj: TDBObject;
|
||||
Results: TMySQLQuery;
|
||||
@ -1158,7 +1159,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TMySQLQuery.SetSQL(Value: WideString);
|
||||
procedure TMySQLQuery.SetSQL(Value: String);
|
||||
begin
|
||||
FSQL := Value;
|
||||
end;
|
||||
@ -1177,7 +1178,7 @@ begin
|
||||
SetLength(FDatatypes, NumFields);
|
||||
for i:=0 to NumFields-1 do begin
|
||||
Field := mysql_fetch_field_direct(FLastResult, i);
|
||||
FColumnNames.Add(Utf8Decode(Field.name));
|
||||
FColumnNames.Add(Utf8ToString(Field.name));
|
||||
|
||||
FDatatypes[i] := Datatypes[Low(Datatypes)];
|
||||
if (Field.flags and ENUM_FLAG) = ENUM_FLAG then
|
||||
@ -1240,32 +1241,23 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function TMySQLQuery.Col(Column: Integer; IgnoreErrors: Boolean=False): WideString;
|
||||
var
|
||||
LengthPointer: PLongInt;
|
||||
BinLen: LongInt;
|
||||
Bin: AnsiString;
|
||||
function TMySQLQuery.Col(Column: Integer; IgnoreErrors: Boolean=False): String;
|
||||
begin
|
||||
if (Column > -1) and (Column < ColumnCount) then begin
|
||||
if FDatatypes[Column].Category = dtcBinary then begin
|
||||
LengthPointer := mysql_fetch_lengths(FLastResult);
|
||||
if LengthPointer <> nil then begin
|
||||
BinLen := PLongInt(LongInt(LengthPointer) + Column * SizeOf(LongInt))^;
|
||||
SetString(Bin, FCurrentRow[Column], BinLen);
|
||||
Result := WideString(Bin);
|
||||
end;
|
||||
end else begin
|
||||
if FDatatypes[Column].Category = dtcBinary then
|
||||
Raise Exception.CreateFmt('Column "%s" has binary collation. Please use ColAsAnsi() instead Col().', [FColumnNames[Column]])
|
||||
else begin
|
||||
if Connection.IsUnicode then
|
||||
Result := UTF8ToWideString(FCurrentRow[Column])
|
||||
Result := UTF8ToString(FCurrentRow[Column])
|
||||
else
|
||||
Result := FCurrentRow[Column];
|
||||
Result := String(FCurrentRow[Column]);
|
||||
end;
|
||||
end else if not IgnoreErrors then
|
||||
Raise Exception.CreateFmt('Column #%d not available. Query returned %d columns and %d rows.', [Column, ColumnCount, RecordCount]);
|
||||
end;
|
||||
|
||||
|
||||
function TMySQLQuery.Col(ColumnName: WideString; IgnoreErrors: Boolean=False): WideString;
|
||||
function TMySQLQuery.Col(ColumnName: String; IgnoreErrors: Boolean=False): String;
|
||||
var
|
||||
idx: Integer;
|
||||
begin
|
||||
@ -1277,13 +1269,33 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function TMySQLQuery.ColAsAnsi(Column: Integer; IgnoreErrors: Boolean=False): AnsiString;
|
||||
var
|
||||
LengthPointer: PLongInt;
|
||||
BinLen: LongInt;
|
||||
begin
|
||||
// Return column value, explicitely as AnsiString. Should be used for binary columns.
|
||||
if (Column > -1) and (Column < ColumnCount) then begin
|
||||
if FDatatypes[Column].Category = dtcBinary then begin
|
||||
LengthPointer := mysql_fetch_lengths(FLastResult);
|
||||
if LengthPointer <> nil then begin
|
||||
BinLen := PLongInt(LongInt(LengthPointer) + Column * SizeOf(LongInt))^;
|
||||
SetString(Result, FCurrentRow[Column], BinLen);
|
||||
end;
|
||||
end else
|
||||
Result := FCurrentRow[Column];
|
||||
end else if not IgnoreErrors then
|
||||
Raise Exception.CreateFmt('Column #%d not available. Query returned %d columns and %d rows.', [Column, ColumnCount, RecordCount]);
|
||||
end;
|
||||
|
||||
|
||||
function TMySQLQuery.DataType(Column: Integer): TDataType;
|
||||
begin
|
||||
Result := FDatatypes[Column];
|
||||
end;
|
||||
|
||||
|
||||
function TMySQLQuery.ColExists(Column: WideString): Boolean;
|
||||
function TMySQLQuery.ColExists(Column: String): Boolean;
|
||||
begin
|
||||
Result := (ColumnNames <> nil) and (ColumnNames.IndexOf(Column) > -1);
|
||||
end;
|
||||
@ -1307,7 +1319,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function TMySQLQuery.IsNull(Column: WideString): Boolean;
|
||||
function TMySQLQuery.IsNull(Column: String): Boolean;
|
||||
begin
|
||||
Result := IsNull(FColumnNames.IndexOf(Column));
|
||||
end;
|
||||
|
@ -29,7 +29,7 @@ type
|
||||
TDatatype = record
|
||||
Index: TDatatypeIndex;
|
||||
NativeType: Cardinal; // See field types in mysql_api.pas
|
||||
Name: String[18];
|
||||
Name: String;
|
||||
Description: String;
|
||||
HasLength: Boolean; // Can have Length- or Set-attribute?
|
||||
RequiresLength: Boolean; // Must have a Length- or Set-attribute?
|
||||
@ -44,7 +44,7 @@ type
|
||||
// MySQL data type category structure
|
||||
TDatatypeCategory = record
|
||||
Index: TDatatypeCategoryIndex;
|
||||
Name: String[32];
|
||||
Name: String;
|
||||
Color: TColor;
|
||||
NullColor: TColor;
|
||||
end;
|
||||
|
@ -627,7 +627,7 @@ procedure Toptionsform.TreeShortcutItemsGetText(Sender: TBaseVirtualTree; Node:
|
||||
var
|
||||
Data: PShortcutItemData;
|
||||
i: Integer;
|
||||
t: WideString;
|
||||
t: String;
|
||||
begin
|
||||
// Fetch text of shortcut item
|
||||
case Sender.GetNodeLevel(Node) of
|
||||
@ -657,7 +657,7 @@ procedure Toptionsform.TreeShortcutItemsInitChildren(Sender: TBaseVirtualTree; N
|
||||
var ChildCount: Cardinal);
|
||||
var
|
||||
i: Integer;
|
||||
Category: WideString;
|
||||
Category: String;
|
||||
begin
|
||||
// First initialization of shortcut items
|
||||
if Sender.GetNodeLevel(Node) = 0 then begin
|
||||
@ -680,7 +680,7 @@ procedure Toptionsform.TreeShortcutItemsInitNode(Sender: TBaseVirtualTree; Paren
|
||||
var
|
||||
Data: PShortcutItemData;
|
||||
ItemIndex, i: Integer;
|
||||
Category: WideString;
|
||||
Category: String;
|
||||
begin
|
||||
if Sender.GetNodeLevel(Node) = 0 then
|
||||
Include(InitialStates, ivsHasChildren);
|
||||
|
@ -54,7 +54,7 @@ type
|
||||
procedure listParametersCreateEditor(Sender: TBaseVirtualTree;
|
||||
Node: PVirtualNode; Column: TColumnIndex; out EditLink: IVTEditLink);
|
||||
procedure listParametersNewText(Sender: TBaseVirtualTree;
|
||||
Node: PVirtualNode; Column: TColumnIndex; NewText: WideString);
|
||||
Node: PVirtualNode; Column: TColumnIndex; NewText: String);
|
||||
procedure listParametersEditing(Sender: TBaseVirtualTree;
|
||||
Node: PVirtualNode; Column: TColumnIndex; var Allowed: Boolean);
|
||||
procedure Modification(Sender: TObject);
|
||||
@ -72,7 +72,7 @@ type
|
||||
public
|
||||
{ Public declarations }
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
procedure Init(ObjectName: WideString=''; ObjectType: TListNodeType=lntNone); override;
|
||||
procedure Init(ObjectName: String=''; ObjectType: TListNodeType=lntNone); override;
|
||||
procedure ApplyModifications; override;
|
||||
end;
|
||||
|
||||
@ -111,10 +111,10 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TfrmRoutineEditor.Init(ObjectName: WideString=''; ObjectType: TListNodeType=lntNone);
|
||||
procedure TfrmRoutineEditor.Init(ObjectName: String=''; ObjectType: TListNodeType=lntNone);
|
||||
var
|
||||
Results: TMySQLQuery;
|
||||
Create, Params: WideString;
|
||||
Create, Params: String;
|
||||
ParenthesesCount: Integer;
|
||||
Context: String;
|
||||
rx: TRegExpr;
|
||||
@ -317,10 +317,10 @@ end;
|
||||
|
||||
|
||||
procedure TfrmRoutineEditor.listParametersNewText(Sender: TBaseVirtualTree;
|
||||
Node: PVirtualNode; Column: TColumnIndex; NewText: WideString);
|
||||
Node: PVirtualNode; Column: TColumnIndex; NewText: String);
|
||||
var
|
||||
OldValues: TWideStringList;
|
||||
new: WideString;
|
||||
new: String;
|
||||
begin
|
||||
OldValues := explode(DELIM, Parameters[Node.Index]);
|
||||
case Column of
|
||||
@ -407,7 +407,7 @@ end;
|
||||
|
||||
procedure TfrmRoutineEditor.ApplyModifications;
|
||||
var
|
||||
BaseSQL, TempSQL, FinalSQL, TempName: WideString;
|
||||
BaseSQL, TempSQL, FinalSQL, TempName: String;
|
||||
i: Integer;
|
||||
par, allRoutineNames: TWideStringList;
|
||||
ProcOrFunc: String;
|
||||
|
@ -66,14 +66,14 @@ procedure TRunSQLFileForm.FormActivate(Sender: TObject);
|
||||
var
|
||||
Stream : TFileStream;
|
||||
FileCharset : TFileCharset;
|
||||
lines : WideString;
|
||||
lines : String;
|
||||
filesize,
|
||||
querycount,
|
||||
rowsaffected : Int64;
|
||||
starttime : Cardinal;
|
||||
SQL : TWideStringList;
|
||||
i : Integer;
|
||||
lines_remaining : WideString;
|
||||
lines_remaining : String;
|
||||
begin
|
||||
if Running then
|
||||
abort;
|
||||
|
@ -181,10 +181,10 @@ type
|
||||
procedure ValidateIndexControls;
|
||||
procedure MoveFocusedIndexPart(NewIdx: Cardinal);
|
||||
procedure ResetModificationFlags;
|
||||
function ComposeCreateStatement: WideString;
|
||||
function ComposeAlterStatement: WideString;
|
||||
function GetIndexSQL(idx: Integer): WideString;
|
||||
function GetForeignKeySQL(idx: Integer): WideString;
|
||||
function ComposeCreateStatement: String;
|
||||
function ComposeAlterStatement: String;
|
||||
function GetIndexSQL(idx: Integer): String;
|
||||
function GetForeignKeySQL(idx: Integer): String;
|
||||
procedure UpdateSQLcode;
|
||||
function CellEditingAllowed(Node: PVirtualNode; Column: TColumnIndex): Boolean;
|
||||
function GetIndexIcon(idx: Integer): Integer;
|
||||
@ -192,7 +192,7 @@ type
|
||||
{ Public declarations }
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
procedure Init(ObjectName: WideString=''; ObjectType: TListNodeType=lntNone); override;
|
||||
procedure Init(ObjectName: String=''; ObjectType: TListNodeType=lntNone); override;
|
||||
procedure ApplyModifications; override;
|
||||
end;
|
||||
|
||||
@ -247,9 +247,9 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TfrmTableEditor.Init(ObjectName: WideString=''; ObjectType: TListNodeType=lntNone);
|
||||
procedure TfrmTableEditor.Init(ObjectName: String=''; ObjectType: TListNodeType=lntNone);
|
||||
var
|
||||
CreateTable, AttrName, AttrValue: WideString;
|
||||
CreateTable, AttrName, AttrValue: String;
|
||||
rx: TRegExpr;
|
||||
begin
|
||||
inherited;
|
||||
@ -355,7 +355,7 @@ end;
|
||||
|
||||
procedure TfrmTableEditor.ApplyModifications;
|
||||
var
|
||||
sql: WideString;
|
||||
sql: String;
|
||||
i: Integer;
|
||||
Specs: TWideStringlist;
|
||||
Key: TForeignKey;
|
||||
@ -447,10 +447,10 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function TfrmTableEditor.ComposeAlterStatement: WideString;
|
||||
function TfrmTableEditor.ComposeAlterStatement: String;
|
||||
var
|
||||
Specs: TWideStringlist;
|
||||
ColSpec, OldColName, IndexSQL: WideString;
|
||||
ColSpec, OldColName, IndexSQL: String;
|
||||
i: Integer;
|
||||
Results: TMySQLQuery;
|
||||
TblKey: TTableKey;
|
||||
@ -601,12 +601,12 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function TfrmTableEditor.ComposeCreateStatement: WideString;
|
||||
function TfrmTableEditor.ComposeCreateStatement: String;
|
||||
var
|
||||
i, IndexCount: Integer;
|
||||
Col: PTableColumn;
|
||||
Node: PVirtualNode;
|
||||
tmp: WideString;
|
||||
tmp: String;
|
||||
begin
|
||||
// Compose CREATE query, called by buttons and for SQL code tab
|
||||
Result := 'CREATE TABLE '+Mainform.mask(editName.Text)+' ('+CRLF;
|
||||
@ -677,7 +677,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function TfrmTableEditor.GetIndexSQL(idx: Integer): WideString;
|
||||
function TfrmTableEditor.GetIndexSQL(idx: Integer): String;
|
||||
var
|
||||
TblKey: TTableKey;
|
||||
i: Integer;
|
||||
@ -708,7 +708,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function TfrmTableEditor.GetForeignKeySQL(idx: Integer): WideString;
|
||||
function TfrmTableEditor.GetForeignKeySQL(idx: Integer): String;
|
||||
var
|
||||
Key: TForeignKey;
|
||||
i: Integer;
|
||||
@ -1275,7 +1275,7 @@ procedure TfrmTableEditor.menuAddIndexColumnClick(Sender: TObject);
|
||||
var
|
||||
Node: PVirtualNode;
|
||||
i, j: Integer;
|
||||
NewCol, PartLength: WideString;
|
||||
NewCol, PartLength: String;
|
||||
ColExists: Boolean;
|
||||
Column: TTableColumn;
|
||||
TblKey: TTableKey;
|
||||
@ -1486,7 +1486,7 @@ procedure TfrmTableEditor.treeIndexesEditing(Sender: TBaseVirtualTree;
|
||||
Node: PVirtualNode; Column: TColumnIndex; var Allowed: Boolean);
|
||||
var
|
||||
VT: TVirtualStringtree;
|
||||
IndexedColName: WideString;
|
||||
IndexedColName: String;
|
||||
Col: TTableColumn;
|
||||
i: Integer;
|
||||
begin
|
||||
@ -1617,7 +1617,7 @@ procedure TfrmTableEditor.treeIndexesDragDrop(Sender: TBaseVirtualTree;
|
||||
Shift: TShiftState; Pt: TPoint; var Effect: Integer; Mode: TDropMode);
|
||||
var
|
||||
Node: PVirtualNode;
|
||||
ColName, PartLength: WideString;
|
||||
ColName, PartLength: String;
|
||||
ColPos: Integer;
|
||||
VT, SourceVT: TVirtualStringtree;
|
||||
Col: PTableColumn;
|
||||
@ -1758,7 +1758,7 @@ var
|
||||
Item: TMenuItem;
|
||||
PrimaryKeyExists,
|
||||
ColumnsSelected: Boolean;
|
||||
IndexName: WideString;
|
||||
IndexName: String;
|
||||
Node: PVirtualNode;
|
||||
Col: PTableColumn;
|
||||
TblKey: TTableKey;
|
||||
@ -1810,7 +1810,7 @@ procedure TfrmTableEditor.AddIndexByColumn(Sender: TObject);
|
||||
var
|
||||
Item: TMenuItem;
|
||||
i: Integer;
|
||||
NewType: WideString;
|
||||
NewType: String;
|
||||
NewParts: TWideStringlist;
|
||||
TblKey: TTableKey;
|
||||
begin
|
||||
|
@ -110,13 +110,13 @@ type
|
||||
FToolMode: TToolMode;
|
||||
OutputFiles, OutputDirs: TWideStringList;
|
||||
ExportStream: TStream;
|
||||
ExportLastDatabase: Widestring;
|
||||
ExportLastDatabase: String;
|
||||
FTargetConnection: TMySQLConnection;
|
||||
FLastOutputSelectedIndex: Integer;
|
||||
FModifiedDbs: TWideStringList;
|
||||
procedure SetToolMode(Value: TToolMode);
|
||||
procedure AddResults(SQL: WideString);
|
||||
procedure AddNotes(Col1, Col2, Col3, Col4: WideString);
|
||||
procedure AddResults(SQL: String);
|
||||
procedure AddNotes(Col1, Col2, Col3, Col4: String);
|
||||
procedure SetupResultGrid(Results: TMySQLQuery=nil);
|
||||
procedure UpdateResultGrid;
|
||||
procedure DoMaintenance(DBObj: TDBObject);
|
||||
@ -135,7 +135,7 @@ implementation
|
||||
uses main, mysql_structures;
|
||||
|
||||
const
|
||||
STRSKIPPED: WideString = 'Skipped - ';
|
||||
STRSKIPPED: String = 'Skipped - ';
|
||||
OUTPUT_FILE = 'One big file';
|
||||
OUTPUT_DIR = 'Directory - one file per object';
|
||||
OUTPUT_DB = 'Database';
|
||||
@ -164,7 +164,7 @@ begin
|
||||
TreeObjects.Width := GetRegValue(REGNAME_TOOLSTREEWIDTH, TreeObjects.Width);
|
||||
|
||||
// Find text tab
|
||||
memoFindText.Text := Utf8Decode(GetRegValue(REGNAME_TOOLSFINDTEXT, ''));
|
||||
memoFindText.Text := GetRegValue(REGNAME_TOOLSFINDTEXT, '');
|
||||
comboDatatypes.Items.Add('All data types');
|
||||
for i:=Low(DatatypeCategories) to High(DatatypeCategories) do
|
||||
comboDatatypes.Items.Add(DatatypeCategories[i].Name);
|
||||
@ -215,7 +215,7 @@ begin
|
||||
MainReg.WriteInteger( REGNAME_TOOLSWINHEIGHT, Height );
|
||||
MainReg.WriteInteger( REGNAME_TOOLSTREEWIDTH, TreeObjects.Width);
|
||||
|
||||
MainReg.WriteString( REGNAME_TOOLSFINDTEXT, Utf8Encode(memoFindText.Text));
|
||||
MainReg.WriteString( REGNAME_TOOLSFINDTEXT, memoFindText.Text);
|
||||
MainReg.WriteInteger( REGNAME_TOOLSDATATYPE, comboDatatypes.ItemIndex);
|
||||
|
||||
MainReg.WriteBool(REGNAME_EXP_CREATEDB, chkExportDatabasesCreate.Checked);
|
||||
@ -499,7 +499,7 @@ end;
|
||||
|
||||
procedure TfrmTableTools.DoMaintenance(DBObj: TDBObject);
|
||||
var
|
||||
SQL: WideString;
|
||||
SQL: String;
|
||||
begin
|
||||
if not (DBObj.NodeType in [lntTable, lntView]) then begin
|
||||
AddNotes(DBObj.Database, DBObj.Name, STRSKIPPED+'a '+LowerCase(DBObj.ObjType)+' cannot be maintained.', '');
|
||||
@ -519,7 +519,7 @@ end;
|
||||
procedure TfrmTableTools.DoFind(DBObj: TDBObject);
|
||||
var
|
||||
Results: TMySQLQuery;
|
||||
SQL: WideString;
|
||||
SQL: String;
|
||||
HasSelectedDatatype: Boolean;
|
||||
i: Integer;
|
||||
begin
|
||||
@ -552,7 +552,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TfrmTableTools.AddResults(SQL: WideString);
|
||||
procedure TfrmTableTools.AddResults(SQL: String);
|
||||
var
|
||||
i: Integer;
|
||||
Row: TWideStringlist;
|
||||
@ -582,7 +582,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TfrmTableTools.AddNotes(Col1, Col2, Col3, Col4: WideString);
|
||||
procedure TfrmTableTools.AddNotes(Col1, Col2, Col3, Col4: String);
|
||||
var
|
||||
Row: TWideStringlist;
|
||||
begin
|
||||
@ -670,7 +670,7 @@ procedure TfrmTableTools.ResultGridPaintText(Sender: TBaseVirtualTree; const Tar
|
||||
Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType);
|
||||
var
|
||||
VT: TVirtualStringTree;
|
||||
Msg: WideString;
|
||||
Msg: String;
|
||||
begin
|
||||
// Red text color for errors, purple for notes, grey for skipped tables
|
||||
if not (vsSelected in Node.States) then begin
|
||||
@ -709,7 +709,7 @@ end;
|
||||
|
||||
procedure TfrmTableTools.comboExportOutputTypeChange(Sender: TObject);
|
||||
var
|
||||
OldItem: WideString;
|
||||
OldItem: String;
|
||||
NewIdx, NetType: Integer;
|
||||
DBNode: PVirtualNode;
|
||||
SessionName: String;
|
||||
@ -889,7 +889,7 @@ end;
|
||||
procedure TfrmTableTools.DoExport(DBObj: TDBObject);
|
||||
var
|
||||
ToFile, ToDir, ToDb, ToServer, IsLastRowInChunk, NeedsDBStructure: Boolean;
|
||||
Struc, Header, FinalDbName, BaseInsert, Row, TargetDbAndObject: WideString;
|
||||
Struc, Header, FinalDbName, BaseInsert, Row, TargetDbAndObject: String;
|
||||
LogRow, MultiSQL: TWideStringlist;
|
||||
i: Integer;
|
||||
RowCount, MaxRowsInChunk, RowsInChunk, Limit, Offset, ResultCount: Int64;
|
||||
@ -900,13 +900,13 @@ const
|
||||
TempDelim = '//';
|
||||
|
||||
// Short version of Mainform.Mask()
|
||||
function m(s: WideString): WideString;
|
||||
function m(s: String): String;
|
||||
begin
|
||||
Result := Mainform.mask(s);
|
||||
end;
|
||||
|
||||
// Pass output to file or query, and append semicolon if needed
|
||||
procedure Output(SQL: WideString; IsEndOfQuery, ForFile, ForDir, ForDb, ForServer: Boolean);
|
||||
procedure Output(SQL: String; IsEndOfQuery, ForFile, ForDir, ForDb, ForServer: Boolean);
|
||||
var
|
||||
SA: AnsiString;
|
||||
ChunkSize: Integer;
|
||||
@ -924,7 +924,7 @@ const
|
||||
SetLength(SA, ChunkSize div SizeOf(AnsiChar));
|
||||
ExportStream.Read(PAnsiChar(SA)^, ChunkSize);
|
||||
ExportStream.Size := 0;
|
||||
SQL := UTF8Decode(SA);
|
||||
SQL := UTF8ToString(SA);
|
||||
if ToDB then Mainform.Connection.Query(SQL)
|
||||
else if ToServer then FTargetConnection.Query(SQL);
|
||||
SQL := '';
|
||||
@ -990,7 +990,7 @@ begin
|
||||
if Mainform.Connection.ServerVersionInt >= 40100 then begin
|
||||
Struc := Mainform.Connection.GetVar('SHOW CREATE DATABASE '+m(DBObj.Database), 1);
|
||||
// Gracefully ignore it when target database exists, important in server mode
|
||||
Insert('IF NOT EXISTS ', Struc, Pos(WideString('DATABASE'), Struc) + 9);
|
||||
Insert('IF NOT EXISTS ', Struc, Pos('DATABASE', Struc) + 9);
|
||||
// Create the right dbname
|
||||
Struc := WideStringReplace(Struc, DBObj.Database, FinalDbName, []);
|
||||
end else
|
||||
@ -1026,12 +1026,12 @@ begin
|
||||
Struc := rx.Replace(Struc, ' ', false);
|
||||
rx.Free;
|
||||
if DBObj.NodeType = lntTable then
|
||||
Insert('IF NOT EXISTS ', Struc, Pos(WideString('TABLE'), Struc) + 6);
|
||||
Insert('IF NOT EXISTS ', Struc, Pos('TABLE', Struc) + 6);
|
||||
if ToDb then begin
|
||||
if DBObj.NodeType = lntTable then
|
||||
Insert(m(FinalDbName)+'.', Struc, Pos(WideString('EXISTS'), Struc) + 7 )
|
||||
Insert(m(FinalDbName)+'.', Struc, Pos('EXISTS', Struc) + 7 )
|
||||
else if DBObj.NodeType = lntView then
|
||||
Insert(m(FinalDbName)+'.', Struc, Pos(WideString('VIEW'), Struc) + 5 );
|
||||
Insert(m(FinalDbName)+'.', Struc, Pos('VIEW', Struc) + 5 );
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -1111,7 +1111,7 @@ begin
|
||||
Row := Row + 'NULL'
|
||||
else case Data.DataType(i).Category of
|
||||
dtcInteger, dtcReal: Row := Row + Data.Col(i);
|
||||
dtcBinary: Row := Row + '_binary 0x' + BinToWideHex(Data.Col(i));
|
||||
dtcBinary: Row := Row + '_binary 0x' + BinToWideHex(Data.ColAsAnsi(i));
|
||||
else Row := Row + esc(Data.Col(i));
|
||||
end;
|
||||
if i<Data.ColumnCount-1 then
|
||||
@ -1169,7 +1169,7 @@ end;
|
||||
procedure TfrmTableTools.DoBulkTableEdit(DBObj: TDBObject);
|
||||
var
|
||||
Specs, LogRow: TWideStringList;
|
||||
CreateView: WideString;
|
||||
CreateView: String;
|
||||
rx: TRegExpr;
|
||||
begin
|
||||
AddResults('SELECT '+esc(DBObj.Database)+' AS '+Mainform.mask('Database')+', ' +
|
||||
|
@ -44,8 +44,8 @@ type
|
||||
SelectedLineBreaks: TLineBreaks;
|
||||
procedure SetModified(NewVal: Boolean);
|
||||
public
|
||||
function GetText: WideString;
|
||||
procedure SetText(text: WideString);
|
||||
function GetText: String;
|
||||
procedure SetText(text: String);
|
||||
procedure SetMaxLength(len: integer);
|
||||
procedure SetFont(font: TFont);
|
||||
property Modified: Boolean read FModified write SetModified;
|
||||
@ -59,9 +59,9 @@ uses main;
|
||||
{$R *.dfm}
|
||||
|
||||
|
||||
function TfrmTextEditor.GetText: WideString;
|
||||
function TfrmTextEditor.GetText: String;
|
||||
var
|
||||
LB: WideString;
|
||||
LB: String;
|
||||
begin
|
||||
Result := memoText.Text;
|
||||
// Convert linebreaks back to selected
|
||||
@ -76,9 +76,9 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TfrmTextEditor.SetText(text: WideString);
|
||||
procedure TfrmTextEditor.SetText(text: String);
|
||||
var
|
||||
LB: WideString;
|
||||
LB: String;
|
||||
Detected: TMenuItem;
|
||||
begin
|
||||
DetectedLineBreaks := ScanLineBreaks(text);
|
||||
|
@ -34,7 +34,7 @@ type
|
||||
public
|
||||
{ Public declarations }
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
procedure Init(ObjectName: WideString=''; ObjectType: TListNodeType=lntNone); override;
|
||||
procedure Init(ObjectName: String=''; ObjectType: TListNodeType=lntNone); override;
|
||||
procedure ApplyModifications; override;
|
||||
end;
|
||||
|
||||
@ -72,7 +72,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure TfrmTriggerEditor.Init(ObjectName: WideString=''; ObjectType: TListNodeType=lntNone);
|
||||
procedure TfrmTriggerEditor.Init(ObjectName: String=''; ObjectType: TListNodeType=lntNone);
|
||||
var
|
||||
Definitions: TMySQLQuery;
|
||||
DBObjects: TDBObjectList;
|
||||
@ -149,7 +149,7 @@ end;
|
||||
|
||||
procedure TfrmTriggerEditor.ApplyModifications;
|
||||
var
|
||||
sql: WideString;
|
||||
sql: String;
|
||||
begin
|
||||
// Edit mode means we drop the trigger and recreate it, as there is no ALTER TRIGGER.
|
||||
try
|
||||
@ -185,7 +185,7 @@ procedure TfrmTriggerEditor.SynCompletionProposalStatementExecute(Kind: SynCompl
|
||||
var CurrentInput: String; var x, y: Integer; var CanExecute: Boolean);
|
||||
var
|
||||
Proposal: TSynCompletionProposal;
|
||||
Token: WideString;
|
||||
Token: String;
|
||||
Columns: TMySQLQuery;
|
||||
begin
|
||||
// Propose column names from referencing table
|
||||
|
@ -401,7 +401,7 @@ var
|
||||
u: TUser;
|
||||
OneSelected, Enable: Boolean;
|
||||
t: TNotifyEvent;
|
||||
pname: WideString;
|
||||
pname: String;
|
||||
begin
|
||||
lblWarning.Visible := False;
|
||||
uid := comboUsers.ItemIndex;
|
||||
@ -1267,7 +1267,7 @@ constructor TUsers.Create;
|
||||
var
|
||||
u: TUser;
|
||||
i: Integer;
|
||||
user, host: WideString;
|
||||
user, host: String;
|
||||
begin
|
||||
dsUser := Mainform.Connection.GetResults('SELECT * FROM '+db+'.'+Mainform.Mask(PRIVTABLE_USERS) + ' ORDER BY '
|
||||
+ Mainform.Mask('User')+', '
|
||||
@ -1711,7 +1711,7 @@ end;
|
||||
function TPrivilege.GetPrettyPrivNames: TWideStringList;
|
||||
var
|
||||
i: Integer;
|
||||
p: WideString;
|
||||
p: String;
|
||||
begin
|
||||
Result := TWideStringList.Create;
|
||||
for i := 0 to PrivNames.Count - 1 do begin
|
||||
|
@ -29,7 +29,7 @@ type
|
||||
public
|
||||
{ Public declarations }
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
procedure Init(ObjectName: WideString=''; ObjectType: TListNodeType=lntNone); override;
|
||||
procedure Init(ObjectName: String=''; ObjectType: TListNodeType=lntNone); override;
|
||||
procedure ApplyModifications; override;
|
||||
end;
|
||||
|
||||
@ -56,10 +56,10 @@ end;
|
||||
{**
|
||||
FormShow: Fill controls with content in edit mode
|
||||
}
|
||||
procedure TfrmView.Init(ObjectName: WideString=''; ObjectType: TListNodeType=lntNone);
|
||||
procedure TfrmView.Init(ObjectName: String=''; ObjectType: TListNodeType=lntNone);
|
||||
var
|
||||
Results: TMySQLQuery;
|
||||
db: WideString;
|
||||
db: String;
|
||||
rx: TRegExpr;
|
||||
begin
|
||||
inherited;
|
||||
|
Reference in New Issue
Block a user