Browse Source

* Fix bug in SQL -- comment handling (by Andrea Urbani, bug ID #28333)

git-svn-id: trunk@32800 -
michael 9 years ago
parent
commit
2b2bf19981
1 changed files with 8 additions and 9 deletions
  1. 8 9
      packages/fcl-db/src/base/sqlscript.pp

+ 8 - 9
packages/fcl-db/src/base/sqlscript.pp

@@ -278,7 +278,11 @@ function TCustomSQLScript.Available: Boolean;
 
 
 begin
 begin
   With FSQL do
   With FSQL do
-    Result:=(FLine<Count) or (FCol<Length(Strings[Count-1]))
+    Result:=(FLine<Count) or
+            (
+              ( FLine = Count ) and
+              ( FCol < Length(Strings[Count-1] ) )
+            );
 end;
 end;
 
 
 procedure TCustomSQLScript.InternalStatement(Statement: TStrings;  var StopExecution: Boolean);
 procedure TCustomSQLScript.InternalStatement(Statement: TStrings;  var StopExecution: Boolean);
@@ -442,12 +446,11 @@ function TCustomSQLScript.NextStatement: AnsiString;
 
 
 var
 var
   pnt: AnsiString;
   pnt: AnsiString;
-  addnewline,terminator_found: Boolean;
+  terminator_found: Boolean;
 
 
 begin
 begin
   terminator_found:=False;
   terminator_found:=False;
   ClearStatement;
   ClearStatement;
-  addnewline:=false;
   while FLine <= FSQL.Count do
   while FLine <= FSQL.Count do
     begin
     begin
     pnt:=FindNextSeparator([FTerminator, '/*', '"', '''', '--']);
     pnt:=FindNextSeparator([FTerminator, '/*', '"', '''', '--']);
@@ -477,12 +480,9 @@ begin
       begin
       begin
       FComment:=True;
       FComment:=True;
       if FCommentsInSQL then
       if FCommentsInSQL then
-        begin
         AddToStatement(Copy(FSQL[FLine-1],FCol,Length(FSQL[FLine-1])-FCol+1),False);
         AddToStatement(Copy(FSQL[FLine-1],FCol,Length(FSQL[FLine-1])-FCol+1),False);
-        AddNewLine:=true;
-        end;
       Inc(Fline);
       Inc(Fline);
-      FCol:=0;
+      FCol:=1;
       FComment:=False;
       FComment:=False;
       end
       end
     else if pnt = '"' then
     else if pnt = '"' then
@@ -498,8 +498,7 @@ begin
       AddToStatement(pnt,False);
       AddToStatement(pnt,False);
       FCol:=FCol + length(pnt);
       FCol:=FCol + length(pnt);
       pnt:=FindNextSeparator(['''']);
       pnt:=FindNextSeparator(['''']);
-      AddToStatement(pnt,addnewline);
-      addnewline:=False;
+      AddToStatement(pnt,false);
       FCol:=FCol + length(pnt);
       FCol:=FCol + length(pnt);
       end;
       end;
     end;
     end;