Restore FireBird SQL Support http://forge.ada-ru.org/matreshka/changeset/4465 =================================================================== --- source/sql/firebird/matreshka-internals-sql_drivers-firebird-databases.adb.orig +++ source/sql/firebird/matreshka-internals-sql_drivers-firebird-databases.adb @@ -213,20 +213,25 @@ overriding function Open (Self : not null access Firebird_Database; - Options : League.Strings.Universal_String) return Boolean + Options : SQL.Options.SQL_Options) return Boolean is use type Isc_Result_Code; use League.Strings; Result : Isc_Result_Code := 0; + + Database_Name : constant League.Strings.Universal_String + := League.Strings.To_Universal_String ("database"); + Password_Name : constant League.Strings.Universal_String + := League.Strings.To_Universal_String ("password"); + User_Name : constant League.Strings.Universal_String + := League.Strings.To_Universal_String ("user"); function Get_User return League.Strings.Universal_String; function Get_Password return League.Strings.Universal_String; function Get_Database return Isc_String; procedure Create_Codec; - Pwd_Separator : constant Natural := Options.Index ('/'); - DB_Separator : constant Natural := Options.Index ('@'); Charset : constant League.Strings.Universal_String := League.Strings.To_Universal_String ("UTF8"); @@ -304,22 +309,9 @@ Empty : constant Isc_String (1 .. 0) := (others => Interfaces.C.nul); begin - if DB_Separator /= 0 then - declare - V_Item : constant Ada.Streams.Stream_Element_Array := - ASCII_Codec.Encode - (Options.Slice (DB_Separator + 1, Options.Length)). - To_Stream_Element_Array; - - S_Item : String (1 .. V_Item'Length); - - for S_Item'Address use V_Item'Address; - pragma Import (Ada, S_Item); - - begin - return Interfaces.C.To_C (S_Item); - end; - + if Options.Is_Set (Database_Name) then + return Interfaces.C.To_C + (Options.Get (Database_Name).To_UTF_8_String); else return Empty; end if; @@ -331,14 +323,8 @@ function Get_Password return League.Strings.Universal_String is begin - if Pwd_Separator /= 0 then - if DB_Separator /= 0 then - return Options.Slice (Pwd_Separator + 1, DB_Separator - 1); - - else - return Options.Slice (Pwd_Separator + 1, Options.Length); - end if; - + if Options.Is_Set (Password_Name) then + return Options.Get (Password_Name); else return League.Strings.Empty_Universal_String; end if; @@ -350,14 +336,10 @@ function Get_User return League.Strings.Universal_String is begin - if Pwd_Separator /= 0 then - return Options.Slice (1, Pwd_Separator - 1); - - elsif DB_Separator /= 0 then - return Options.Slice (1, DB_Separator - 1); - + if Options.Is_Set (User_Name) then + return Options.Get (User_Name); else - return Options; + return League.Strings.Empty_Universal_String; end if; end Get_User; --- source/sql/firebird/matreshka-internals-sql_drivers-firebird-databases.ads.orig +++ source/sql/firebird/matreshka-internals-sql_drivers-firebird-databases.ads @@ -106,7 +106,7 @@ overriding function Open (Self : not null access Firebird_Database; - Options : League.Strings.Universal_String) return Boolean; + Options : SQL.Options.SQL_Options) return Boolean; procedure Check_Result (Self : not null access Firebird_Database; --- source/sql/firebird/matreshka-internals-sql_drivers-firebird-queries.adb.orig +++ source/sql/firebird/matreshka-internals-sql_drivers-firebird-queries.adb @@ -169,6 +169,7 @@ end if; end case; + Self.Is_Valid := False; return True; exception @@ -294,6 +295,7 @@ Self.Sql_Params.Codec := Codec; Self.Sql_Record.Utf := Utf; Self.Sql_Params.Utf := Utf; + Self.Is_Valid := False; SQL_Drivers.Initialize (Self, Database_Access (Database)); end Initialize; @@ -327,6 +329,16 @@ begin return Self.State = Active; end Is_Active; + + -------------- + -- Is_Valid -- + -------------- + + overriding function Is_Valid + (Self : not null access Firebird_Query) return Boolean is + begin + return Self.Is_Valid; + end Is_Valid; ---------- -- Next -- @@ -349,6 +361,7 @@ if Result > 0 then if Result = 100 then + Self.Is_Valid := False; return False; else @@ -358,11 +371,13 @@ begin if Check_For_Error (Self.Status'Access, EC) then + Self.Is_Valid := False; return False; else Self.Error := Get_Error (Self.Status'Access); Self.Finish; + Self.Is_Valid := False; return False; end if; @@ -370,6 +385,7 @@ end if; else + Self.Is_Valid := True; return True; end if; end Next; --- source/sql/firebird/matreshka-internals-sql_drivers-firebird-queries.ads.orig +++ source/sql/firebird/matreshka-internals-sql_drivers-firebird-queries.ads @@ -81,6 +81,7 @@ Cursor_Name : Isc_String (1 .. 10); Status : aliased Isc_Results := (others => 0); Error : League.Strings.Universal_String; + Is_Valid : Boolean := False; end record; overriding procedure Bind_Value @@ -110,6 +111,9 @@ overriding function Next (Self : not null access Firebird_Query) return Boolean; + overriding function Is_Valid + (Self : not null access Firebird_Query) return Boolean; + overriding function Prepare (Self : not null access Firebird_Query; Query : League.Strings.Universal_String) return Boolean; --- source/sql/matreshka-internals-sql_drivers.ads.orig +++ source/sql/matreshka-internals-sql_drivers.ads @@ -154,7 +154,7 @@ (Self : not null access Abstract_Query'Class) return Boolean; -- Returns True when query object is valid. - function Is_Valid + not overriding function Is_Valid (Self : not null access Abstract_Query) return Boolean is abstract; -- Returns True if the query is currently positioned on a valid record; -- otherwise returns false.