ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/runtime/ibxscript.pas
(Generate patch)

Comparing ibx/trunk/runtime/ibxscript.pas (file contents):
Revision 47 by tony, Mon Jan 9 15:31:51 2017 UTC vs.
Revision 108 by tony, Thu Jan 18 14:37:46 2018 UTC

# Line 214 | Line 214 | type
214      function AnalyseXML(SymbolStream: TSymbolStream): string;
215      procedure NextStatement;
216      class function FormatBlob(Field: ISQLData): string;
217 <    class function FormatArray(ar: IArray): string;
217 >    class function FormatArray(Database: TIBDatabase; ar: IArray): string;
218      property BlobData[index: integer]: TBlobData read GetBlobData;
219      property BlobDataCount: integer read GetBlobDataCount;
220      property ArrayData[index: integer]: TArrayData read GetArrayData;
# Line 253 | Line 253 | type
253    TLogEvent = procedure(Sender: TObject; Msg: string) of Object;
254    TOnSelectSQL = procedure (Sender: TObject; SQLText: string) of object;
255    TOnSetStatement = procedure(Sender: TObject; command, aValue, stmt: string; var Done: boolean) of object;
256 +  TOnCreateDatabase = procedure (Sender: TObject; var DatabaseFileName: string) of object;
257  
258    { TCustomIBXScript }
259  
# Line 274 | Line 275 | type
275      FDatabase: TIBDatabase;
276      FDataOutputFormatter: TIBCustomDataOutput;
277      FIgnoreGrants: boolean;
278 +    FOnCreateDatabase: TOnCreateDatabase;
279      FOnErrorLog: TLogEvent;
280      FOnSelectSQL: TOnSelectSQL;
281      FOnSetStatement: TOnSetStatement;
# Line 325 | Line 327 | type
327      property OnProgressEvent: TOnProgressEvent read GetOnProgressEvent write SetOnProgressEvent; {Progress Bar Support}
328      property OnSelectSQL: TOnSelectSQL read FOnSelectSQL write FOnSelectSQL; {Handle Select SQL Statements}
329      property OnSetStatement: TOnSetStatement read FOnSetStatement write FOnSetStatement;
330 +    property OnCreateDatabase: TOnCreateDatabase read FOnCreateDatabase write FOnCreateDatabase;
331    end;
332  
333    {
# Line 649 | Line 652 | end;
652  
653   procedure TCustomIBXScript.SetDatabase(AValue: TIBDatabase);
654   begin
655 < if FDatabase = AValue then Exit;
655 > if not (csLoading in ComponentState) and (FDatabase = AValue) then Exit;
656   FDatabase := AValue;
657   FISQL.Database := AValue;
658   FIBXMLProcessor.Database := AValue;
# Line 723 | Line 726 | begin
726  
727    except on E:Exception do
728        begin
729 <        Add2Log(Format(sStatementError,[FSymbolStream.GetErrorPrefix,
730 <                           E.Message,stmt]),true);
731 <        if StopOnFirstError then Exit;
729 >        if FInternalTransaction.InTransaction then
730 >          FInternalTransaction.Rollback;
731 >        if assigned(OnErrorLog) then
732 >        begin
733 >          Add2Log(Format(sStatementError,[FSymbolStream.GetErrorPrefix,
734 >                             E.Message,stmt]),true);
735 >                             if StopOnFirstError then Exit;
736 >        end
737 >        else
738 >          raise;
739        end
740    end;
741    Result := true;
# Line 838 | Line 848 | var  RegexObj: TRegExpr;
848       charsetid: integer;
849       param: string;
850       Terminator: char;
851 +     FileName: string;
852   begin
853    Result := false;
854    ucStmt := AnsiUpperCase(stmt);
# Line 845 | Line 856 | begin
856    RegexObj := TRegExpr.Create;
857    try
858      {process create database}
859 <    RegexObj.Expression := '^ *CREATE +(DATABASE|SCHEMA) +(.*) *(\' + Terminator + '|)';
859 >    RegexObj.Expression := '^ *CREATE +(DATABASE|SCHEMA) +''(.*)''(.*)(\' + Terminator + '|)';
860      if RegexObj.Exec(ucStmt) then
861      begin
862 +      FileName := system.copy(stmt,RegexObj.MatchPos[2], RegexObj.MatchLen[2]);
863 +      if assigned(FOnCreateDatabase) then
864 +        OnCreateDatabase(self,FileName);
865 +      stmt := 'CREATE DATABASE ''' + FileName + '''' + system.copy(stmt,RegexObj.MatchPos[3], RegexObj.MatchLen[3]);
866 +      ucStmt := AnsiUpperCase(stmt);
867        UpdateUserPassword;
868        FDatabase.Connected := false;
869        FDatabase.CreateDatabase(stmt);
# Line 948 | Line 964 | begin
964        else
965        if command = 'NAMES' then
966        begin
967 <        if FirebirdAPI.CharSetName2CharSetID(param,charsetid) then
967 >        if Database.Attachment.CharSetName2CharSetID(param,charsetid) then
968          begin
969            Database.Params.Values['lc_ctype'] := param;
970            if Database.Connected then
# Line 1263 | Line 1279 | begin
1279      begin
1280        Database.Connected := true;
1281        Transaction.Active := true;
1282 <      FirebirdAPI.CharSetName2CharSetID(CharSet,aCharSetID);
1282 >      Database.Attachment.CharSetName2CharSetID(CharSet,aCharSetID);
1283        SetLength(Index,dim);
1284        ArrayIntf := Database.Attachment.CreateArray(
1285                       Transaction.TransactionIntf,
# Line 1706 | Line 1722 | begin
1722    end;
1723   end;
1724  
1725 < class function TIBXMLProcessor.FormatArray(ar: IArray): string;
1725 > class function TIBXMLProcessor.FormatArray(Database: TIBDatabase; ar: IArray
1726 >  ): string;
1727   var index: array of integer;
1728      TextOut: TStrings;
1729  
# Line 1751 | Line 1768 | begin
1768         s += Format(' scale = "%d"',[ ar.GetScale]);
1769      SQL_TEXT,
1770      SQL_VARYING:
1771 <      s += Format(' charset = "%s"',[FirebirdAPI.GetCharsetName(ar.GetCharSetID)]);
1771 >      s += Format(' charset = "%s"',[Database.Attachment.GetCharsetName(ar.GetCharSetID)]);
1772      end;
1773      bounds := ar.GetBounds;
1774      boundsList := '';

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines