1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
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.
|