mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-26 03:01:07 +08:00
Try a new approach in TDBConnection.ParseRoutineStructure(). Should fix stripped backslashes from routine body, issue #3107.
* Use SHOW CREATE PROCEDURE/FUNCTION result again, instead of code from IS.ROUTINES * Remove every known CREATE PROCEDURE/FUNCTION clause and use remaining text as routine body. * Respect MS SQL function options, taken from http://msdn.microsoft.com/en-us/library/ms186755.aspx * Introduce helpers.ExtractComment() for usage in ParseRoutineStructure() and ParseTableStructure()
This commit is contained in:
@ -257,6 +257,7 @@ type
|
||||
function ScanLineBreaks(Text: String): TLineBreaks;
|
||||
function RemoveNulChars(Text: String): String;
|
||||
function fixNewlines(txt: String): String;
|
||||
function ExtractComment(var SQL: String): String;
|
||||
function GetShellFolder(CSIDL: integer): string;
|
||||
// Common directories
|
||||
function DirnameCommonAppData: String;
|
||||
@ -741,6 +742,33 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function ExtractComment(var SQL: String): String;
|
||||
var
|
||||
i, LitStart: Integer;
|
||||
InLiteral: Boolean;
|
||||
rx: TRegExpr;
|
||||
begin
|
||||
// Return comment from SQL and remove it from the original string
|
||||
// Single quotes are escaped by a second single quote
|
||||
rx := TRegExpr.Create;
|
||||
rx.Expression := '^\s*COMMENT\s+''';
|
||||
rx.ModifierI := True;
|
||||
if rx.Exec(SQL) then begin
|
||||
LitStart := rx.MatchLen[0]+1;
|
||||
InLiteral := True;
|
||||
for i:=LitStart to Length(SQL) do begin
|
||||
if SQL[i] = '''' then
|
||||
InLiteral := not InLiteral
|
||||
else if not InLiteral then
|
||||
break;
|
||||
end;
|
||||
Result := Copy(SQL, LitStart, i-LitStart-1);
|
||||
Result := StringReplace(Result, '''''', '''', [rfReplaceAll]);
|
||||
Delete(SQL, 1, i);
|
||||
end;
|
||||
rx.Free;
|
||||
end;
|
||||
|
||||
|
||||
{***
|
||||
Get the path of a Windows(r)-shellfolder, specified by an integer or a constant
|
||||
|
Reference in New Issue
Block a user