fireruby 0.2.2-i586-linux → 0.3.0-i586-linux

Sign up to get free protection for your applications and to get access to all the features.
data/doc/README CHANGED
@@ -1,31 +1,57 @@
1
- == FireRuby Version 0.2.1
2
- This is a bug fix release for version 0.2.0 of the FireRuby library. FireRuby is
3
- an extension to the Ruby language that provides access to the functionality of
4
- the Firebird relational database management system.
1
+ == FireRuby Version 0.3.0
2
+ FireRuby is an extension to the Ruby language that provides access to the C API
3
+ functionality of the Firebird relational database management system.
4
+
5
+ This release extends the functionality of the Row object to allow it to be used
6
+ as a read only Hash object and adds new funcionality relating to the Firebird
7
+ RDBMS service manager.
8
+
9
+ Once again I would like to thank Ken Kunz for his support and input to the
10
+ FireRuby project. Ken performs the unit testing and creates the gem file for the
11
+ Linux version of the FireRuby library.
5
12
 
6
13
  == Enhancements & Alterations
7
14
 
8
- No new functionality added for this release.
15
+ The Row class has been extended to include equivalents for all Hash methods that
16
+ do would not alter the contents of the Hash. This effectively allows an instance
17
+ of the Row class to be used as a Hash anywhere that a Hash object can be used
18
+ without the need to change it's contents.
19
+
20
+ A ServiceManager class and a collection of task related classes have been added
21
+ for this release. The ServiceManager class represents a connection to a Firebird
22
+ service manager instance. Task classes have been provided that allow for the
23
+ backing up and restoration of databases as well as the addition or removal of
24
+ database users.
25
+
26
+ The Statement and ResultSet classes under went a major rewrite. This was done
27
+ to eliminate a dependency between these two classes (the Statement class was
28
+ using the ResultSet class to execute SQL regardless of whether the statement
29
+ being executed was a query). This was an illogical and ill-consider set up and
30
+ has now been eliminated. An effort was made to minimize changes to the interface
31
+ but there have been some (primarily the constructor for the ResultSet class).
32
+ The ResultSet class has now been restricted for use with queries only and will
33
+ generate and exception if a non-query statement is specified. Queries can still
34
+ be run through the Statement class but, if you know you're executing a query
35
+ statement, it is more efficient to go straight to a ResultSet object.
9
36
 
10
37
  == Bug Fixes
11
38
 
12
- - Fixed an intermittent bug that was causing an access violation when the Ruby
13
- interpreter attempted to clean up at exited. The access violation was
14
- occurring in a Firebird function call so I'm not exactly sure why it was
15
- happening. The code has been restructured to bypass the issue.
16
-
17
- - Fixed a bug in the code for the Generator object that was leaving an active
18
- transaction lying around whenever an exception occurred in a call to fetch a
19
- value from the Generator.
20
-
21
- - Fixed a buffer overrun bug were the size of an input string was being used
22
- to determine values written rather than the size of an output field.
39
+ The only currently outstanding bug relates to accessing methods on the ResultSet
40
+ class objects that have been created with a non-query SQL statement. This class
41
+ has been fundamentally re-written and no longer allows the use of non-query SQL
42
+ statements. This bug is therefore closed.
23
43
 
24
44
  == Issues
25
45
 
26
46
  Nothing is perfect so this section outlines those issues that are known to
27
47
  exist as of this release.
28
48
 
49
+ - The big new issue for this release (0.3.0) relates to the fact the service
50
+ manager functionality does not appear to work on the Mac OS X platform. I
51
+ don't believe that this is a problem in the FireRuby code as I have tested the
52
+ Firebird gbak utility with the -service option and it gives the same result.
53
+ If anyone knows this to be untrue or of a work around let me know.
54
+
29
55
  - The library currently does not support array columns. This may be implemented
30
56
  for a later release depending on demand.
31
57
 
@@ -46,13 +72,13 @@ the Ruby Gems package to be installed. Assuming that these installation criteria
46
72
  have been met the library can be installed on Windows by executing a command
47
73
  such as the following...
48
74
 
49
- gem install fireruby-0.2.0-mswin32.gem
75
+ gem install fireruby-0.3.0-mswin32.gem
50
76
 
51
77
  On the Mac OS X platform you may require super user privilege if your Ruby is
52
78
  installed to the default location (i.e. /usr/local/lib). In this case you can
53
79
  use the sudo command to make the installation like this...
54
80
 
55
- sudo gem install fireruby-0.2.0-powerpc-darwin.gem
81
+ sudo gem install fireruby-0.3.0-powerpc-darwin.gem
56
82
 
57
83
  Once the gem installation is complete the FireRuby functionality can be accessed
58
84
  in code with the usual gem style requires...
@@ -63,13 +89,16 @@ in code with the usual gem style requires...
63
89
  == Build Details
64
90
 
65
91
  The FireRuby library is an extension of the Ruby language written in C. For Mac
66
- OS X the library was built against Firebird installed as a framework, version
67
- 1.5.1, and with Ruby version 1.8.2. For the Windows platform the library was
68
- built against a Ruby installation created using the one-click installer, version
69
- 1.8.2. The Windows build was created using the freely available Microsoft
70
- compilers and SDKs and built against a standard installation of Firebird,
71
- version 1.5.2.
72
-
92
+ OS X the library is built on version 10.3 of the OS and against Firebird
93
+ installed as a framework, version 1.5.1, and with Ruby version 1.8.2. For the
94
+ Windows platform the library is built on Windows XP and against a Ruby
95
+ installation created using the one-click installer, version 1.8.2. The Windows
96
+ build was created using the freely available Microsoft compilers and SDKs and
97
+ built against a standard installation of Firebird, version 1.5.2. On Linux the
98
+ library (I believe) has been linked against the Firebird shared object. This
99
+ being the case then your LD_LIBRARY_PATH environment variable will have to be
100
+ set to include the Firebird lib directory if you want to use it.
101
+
73
102
  == So How Do I Use It?
74
103
 
75
104
  This section will provide some examples of usage for the the FireRuby classes.
@@ -196,17 +225,10 @@ this is and you're only using Firebird it's probably safe to use a value of
196
225
  3 here. Other values are for backward compatibility. Consult the Firebird and
197
226
  Interbase documentation for more details.
198
227
 
199
- Anyway, now that we have our Statement how do we use it. Well, there are two
200
- approaches to using the Statement object. For statements like the one used
201
- above, queries that take no parameters, you can use the Statement object to
202
- build a ResultSet object, like so...
203
-
204
- r = ResultSet.new(s)
205
-
206
- The ResultSet class will be covered in a little more detail below. The other
207
- means by which a Statement can be used is to call one of it's execute methods.
208
- The one to be called depends on whether the Statement requires parameters or
209
- not. What are parameters you ask? Well, look at the following...
228
+ Anyway, now that we have our Statement how do we use it? Well, the answer is
229
+ that we call once of the Statement objects execute methods. The one to be called
230
+ depends on whether the Statement requires parameters or not. What are parameters
231
+ you ask? Well, look at the following...
210
232
 
211
233
  s = Statement.new(cxn, tx, 'SELECT * FROM MY_TABLE WHERE MYID = ?', 3)
212
234
 
@@ -216,25 +238,34 @@ that wraps such a piece of SQL must be provided with the necessary parameters
216
238
  to execute properly. Where a Statement object represents SQL that requires a
217
239
  parameter then the execute_for method must be called, like this...
218
240
 
219
- r = s.execute_for([25])
241
+ s.execute_for([25])
220
242
 
221
243
  This code executes the SQL substituting the parameters from the array of data
222
244
  passed to the function call. If a Statement object represents SQL that does not
223
245
  require parameter values a call to the execute method will suffice, such as the
224
246
  following...
225
247
 
226
- r = s.execute
248
+ s.execute
227
249
 
228
250
  The execute methods for the Statement class, as with all of the execute methods
229
- for the FireRuby library, have two potential return values. They will either
230
- return nil or they will return a ResultSet object. A ResultSet object will only
231
- be returned for SQL statements that constitute a query, irrespective of whether
232
- that query returns any data. For all other SQL statements the various execute
233
- method will return nil.
251
+ for the FireRuby library, have three potential return values. They will either
252
+ return an Integer, a ResultSet object or nil. A ResultSet object will only be
253
+ returned for SQL statements that constitute a query, irrespective of whether
254
+ that query returns any data. For all other SQL statements (inserts, updates and
255
+ deletes) the execute method will return a count of the number of rows affected
256
+ by the statement execution. For any other SQL statements the various execute
257
+ methods will return nil.
234
258
 
235
259
  A ResultSet object represents a handle by which the data retrieved for a SQL
236
- query can be accessed. To fetch a row of data from a ResultSet object you call
237
- the fetch method, like the following...
260
+ query can be accessed. While it's possible to obtain a ResultSet from one of the
261
+ execute methods on the Connection, Transaction or Statement classes it is more
262
+ efficient to create one directly. The constructor for the ResultSet class
263
+ accepts the same arguments as the constructor for the Statement class but will
264
+ throw an exception if the SQL statement specified is not a query.
265
+
266
+ Once we have obtained a ResultSet we can extract the rows of data for a query
267
+ from it. To fetch a row of data from a ResultSet object you call the fetch
268
+ method, like the following...
238
269
 
239
270
  row = r.fetch
240
271
 
@@ -258,8 +289,9 @@ columns of data within the row like this...
258
289
  value = row[1]
259
290
 
260
291
  The index specified to the array dereference operator specifies the column that
261
- you want the data for. Column indices start at 0. Alternatively you can use the
262
- column name to access the data, like this...
292
+ you want the data for. Column indices start at 0. Alternatively you can treat
293
+ the Row object like a read only Hash object and use the column name to access
294
+ the data, like this...
263
295
 
264
296
  value = row['MYID']
265
297
 
@@ -267,9 +299,8 @@ This is beneficial as it frees you from the constraint of knowing the ordering
267
299
  of the columns within the row. For more information of the Row class please
268
300
  consult the API documentation.
269
301
 
270
- Well that covers the bulk of the classes provided by the FireRuby library. The
271
- three which haven't been touched upon are the Generator class, the Blob class
272
- and the FireRubyException class.
302
+ That covers the bulk of the SQL classes provided by the FireRuby library. The
303
+ two which haven't been touched upon are the Generator class and the Blob class.
273
304
 
274
305
  The Generator class is a wrapper around the Firebird generator facility. A
275
306
  generator, also known as a sequence, provides a means of creating a list of
@@ -282,8 +313,76 @@ The Blob class is returned as part of the Row object data obtained from a
282
313
  ResultSet. The class wraps the concept of a binary large object stored in the
283
314
  database. Consult the API documentation for further information.
284
315
 
285
- The FireRubyException class is the error class used by the FireRuby library
286
- whenever it hits trouble. If an exception is raised by the FireRuby code then
287
- its extremely likely that it will be an instance of this class. The class
288
- provides a means of finding out a little more about what exactly has gone
289
- wrong. Again, consult the API documentation for more details.
316
+ === Errors
317
+
318
+ Whenever a problem occurs within a FireRuby library class then it is likely that
319
+ a FireRubyException will be thrown. The FireRubyException class is the error
320
+ class used by the FireRuby library whenever it hits trouble. The class provides
321
+ a means of finding out a little more about what exactly has gone wrong. Again,
322
+ consult the API documentation for more details.
323
+
324
+ === Firebird Service Manager
325
+
326
+ The FireRuby library provides a set of class that provide for an interaction
327
+ with the Firebird service manager. This interaction allows for the execution of
328
+ tasks, such as the backing up of a database, on the database server. To execute
329
+ such tasks against the service manager for a Firebird instance you first need
330
+ to obtain a ServiceManager class instance. This can be done as follows...
331
+
332
+ sm = ServiceManager.new('localhost')
333
+
334
+ The constructor for the ServiceManager class takes a single parameter that is
335
+ the host name of the server running the Firebird instance. In the example above
336
+ this would be a local machine but could be any machine that can be reached over
337
+ the network (NOTE: although Firebird supports a number of underlying transport
338
+ protocols in accessing a service manager currently only TCP/IP is supported for
339
+ the FireRuby library).
340
+
341
+ The next step in executing service manager tasks involves connecting your
342
+ ServiceManager object to the service manager for a Firebird instance. To do this
343
+ you must supply a user name and password. The user name and password used must
344
+ be a user that exists on the Firebird instance. The user you connect as can
345
+ affect the access to services that you receive. For example, to connect as the
346
+ database administrator you might do the following...
347
+
348
+ sm.connect('sysdba', 'masterkey')
349
+
350
+ Assuming that this succeeds you are now ready to execute tasks through your
351
+ ServiceManager object. Within the FireRuby library individual task are broken
352
+ out into separate classes. For this release (0.3.0) there are four task classes
353
+ provided in the library - Backup, Restore, AddUser and RemoveUser. I think the
354
+ class names are relatively self explanatory but if you want more information
355
+ consult the API documentation for a class.
356
+
357
+ To use the task classes you construct a class instance, configure it as you may
358
+ need and then execute it. Here's an example of going through this procedure to
359
+ create a database backup...
360
+
361
+ b = Backup.new('c:\database\work.fdb', 'c:\temp\work.bak')
362
+ b.metadata_only = true
363
+ b.execute(sm)
364
+
365
+ The first list creates the new Backup object. The first parameter passed to this
366
+ call is the path and name of the primary file of the database to be backed up
367
+ (NOTE: All paths are relative to the database server). The second parameter is
368
+ the path and name of the database backup file to be created. The second line
369
+ sets an attribute on the class to indicate that only the metadata (i.e. it's
370
+ schema but not it's data) for the specified database should be included in the
371
+ backup. The final line begins the execution of the backup task on the database
372
+ server. This will block until completion.
373
+
374
+ Its also possible to execute a batch of tasks against a service manager. To do
375
+ this you would accumulate the tasks to be executed and then pass them all at the
376
+ same time to the ServiceManager#execute method, like so...
377
+
378
+ t = Array.new
379
+ t.push(Backup.new('c:\database\work.fdb', 'c:\temp\work.bak'))
380
+ ...
381
+ # Create more tasks here and add them to the array.
382
+
383
+ sm.execute(*t)
384
+
385
+ The tasks will be executed in the order they are specified to the ServiceManager
386
+ object. For the example above this would mean in the order they were added to
387
+ the array. For more details on the ServiceManager class and the various task
388
+ classes please consult the API documentation.
data/lib/fireruby.so CHANGED
Binary file