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

Comparing ibx/trunk/runtime/IBDatabase.pas (file contents):
Revision 45 by tony, Tue Dec 6 10:33:46 2016 UTC vs.
Revision 60 by tony, Mon Mar 27 15:21:02 2017 UTC

# Line 240 | Line 240 | type
240      procedure CloseDataSets;
241      procedure CheckActive;
242      procedure CheckInactive;
243 <    procedure CreateDatabase;
243 >    procedure CreateDatabase; overload;
244 >    procedure CreateDatabase(createDatabaseSQL: string); overload;
245      procedure DropDatabase;
246      procedure ForceClose;
247      procedure GetFieldNames(const TableName: string; List: TStrings);
# Line 475 | Line 476 | function GenerateTPB(sl: TStrings): ITPB
476   implementation
477  
478   uses  IBSQLMonitor, IBCustomDataSet, IBDatabaseInfo, IBSQL, IBUtils,
479 <     typInfo, FBMessages, IBErrorCodes;
479 >     typInfo, FBMessages, IBErrorCodes, RegExpr;
480  
481   { TIBDatabase }
482  
# Line 609 | Line 610 | begin
610    Connected := true;
611   end;
612  
613 + procedure TIBDataBase.CreateDatabase(createDatabaseSQL: string);
614 + var RegexObj: TRegExpr;
615 + begin
616 +  CheckInactive;
617 +  FAttachment := FirebirdAPI.CreateDatabase(createDatabaseSQL,FSQLDialect);
618 +  RegexObj := TRegExpr.Create;
619 +  try
620 +    {extact database file spec}
621 +    RegexObj.ModifierG := false; {turn off greedy matches}
622 +    RegexObj.Expression := '^ *CREATE +(DATABASE|SCHEMA) +''(.*)''';
623 +    if RegexObj.Exec(AnsiUpperCase(createDatabaseSQL)) then
624 +      FDBName := system.copy(createDatabaseSQL,RegexObj.MatchPos[2],RegexObj.MatchLen[2]);
625 +  finally
626 +    RegexObj.Free;
627 +  end;
628 +  if assigned(FOnCreateDatabase) and (FAttachment <> nil) then
629 +    OnCreateDatabase(self);
630 + end;
631 +
632   procedure TIBDataBase.DropDatabase;
633   begin
634    CheckActive;
# Line 939 | Line 959 | begin
959     if UseDefaultSystemCodePage then
960     begin
961       {$ifdef WINDOWS}
962 <     if FirebirdAPI.CodePage2CharSetID(GetACP,CharSetID) then
963 <       TempDBParams.Values['lc_ctype'] := FirebirdAPI.GetCharsetName(CharSetID)
962 >     if Attachment.CodePage2CharSetID(GetACP,CharSetID) then
963 >       TempDBParams.Values['lc_ctype'] := Attachment.GetCharsetName(CharSetID)
964       {$else}
965 <     if FirebirdAPI.CodePage2CharSetID(DefaultSystemCodePage,CharSetID) then
966 <       TempDBParams.Values['lc_ctype'] := FirebirdAPI.GetCharsetName(CharSetID)
965 >     if Attachment.CodePage2CharSetID(DefaultSystemCodePage,CharSetID) then
966 >       TempDBParams.Values['lc_ctype'] := Attachment.GetCharsetName(CharSetID)
967       {$endif}
968       else
969         TempDBParams.Values['lc_ctype'] :='UTF8';
# Line 956 | Line 976 | begin
976     end;
977  
978     FDefaultCharSetName := AnsiUpperCase(TempDBParams.Values['lc_ctype']);
959   if FDefaultCharSetName <> '' then
960     FirebirdAPI.CharSetName2CharSetID(FDefaultCharSetName,FDefaultCharSetID);
961   FirebirdAPI.CharSetID2CodePage(FDefaultCharSetID,FDefaultCodePage);
979     { Generate a new DPB if necessary }
980     if (FDBParamsChanged or (TempDBParams.Text <> FDBParams.Text)) then
981     begin
# Line 1012 | Line 1029 | begin
1029          raise EIBInterBaseError.Create(Status);
1030      end;
1031    until FAttachment <> nil;
1032 +
1033 +  if FDefaultCharSetName <> '' then
1034 +    Attachment.CharSetName2CharSetID(FDefaultCharSetName,FDefaultCharSetID);
1035 +  Attachment.CharSetID2CodePage(FDefaultCharSetID,FDefaultCodePage);
1036 +
1037    if not (csDesigning in ComponentState) then
1038      FDBName := aDBName; {Synchronise at run time}
1039    FDBSQLDialect := GetDBSQLDialect;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines