rubyfb 0.5.2-x86-linux

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. data/CHANGELOG +6 -0
  2. data/LICENSE +411 -0
  3. data/Manifest +73 -0
  4. data/README +460 -0
  5. data/Rakefile +20 -0
  6. data/examples/example01.rb +65 -0
  7. data/ext/AddUser.c +464 -0
  8. data/ext/AddUser.h +37 -0
  9. data/ext/Backup.c +783 -0
  10. data/ext/Backup.h +37 -0
  11. data/ext/Blob.c +421 -0
  12. data/ext/Blob.h +65 -0
  13. data/ext/Common.c +54 -0
  14. data/ext/Common.h +37 -0
  15. data/ext/Connection.c +863 -0
  16. data/ext/Connection.h +50 -0
  17. data/ext/DataArea.c +274 -0
  18. data/ext/DataArea.h +38 -0
  19. data/ext/Database.c +449 -0
  20. data/ext/Database.h +48 -0
  21. data/ext/FireRuby.c +240 -0
  22. data/ext/FireRuby.h +50 -0
  23. data/ext/FireRubyException.c +268 -0
  24. data/ext/FireRubyException.h +51 -0
  25. data/ext/Generator.c +689 -0
  26. data/ext/Generator.h +53 -0
  27. data/ext/RemoveUser.c +212 -0
  28. data/ext/RemoveUser.h +37 -0
  29. data/ext/Restore.c +855 -0
  30. data/ext/Restore.h +37 -0
  31. data/ext/ResultSet.c +809 -0
  32. data/ext/ResultSet.h +60 -0
  33. data/ext/Row.c +965 -0
  34. data/ext/Row.h +55 -0
  35. data/ext/ServiceManager.c +316 -0
  36. data/ext/ServiceManager.h +48 -0
  37. data/ext/Services.c +124 -0
  38. data/ext/Services.h +42 -0
  39. data/ext/Statement.c +785 -0
  40. data/ext/Statement.h +62 -0
  41. data/ext/Transaction.c +684 -0
  42. data/ext/Transaction.h +50 -0
  43. data/ext/TypeMap.c +1182 -0
  44. data/ext/TypeMap.h +51 -0
  45. data/ext/extconf.rb +28 -0
  46. data/ext/mkmf.bat +1 -0
  47. data/lib/SQLType.rb +224 -0
  48. data/lib/active_record/connection_adapters/rubyfb_adapter.rb +805 -0
  49. data/lib/mkdoc +1 -0
  50. data/lib/rubyfb.rb +2 -0
  51. data/lib/rubyfb_lib.so +0 -0
  52. data/lib/src.rb +1800 -0
  53. data/rubyfb.gemspec +31 -0
  54. data/test/AddRemoveUserTest.rb +56 -0
  55. data/test/BackupRestoreTest.rb +99 -0
  56. data/test/BlobTest.rb +57 -0
  57. data/test/CharacterSetTest.rb +63 -0
  58. data/test/ConnectionTest.rb +111 -0
  59. data/test/DDLTest.rb +54 -0
  60. data/test/DatabaseTest.rb +83 -0
  61. data/test/GeneratorTest.rb +50 -0
  62. data/test/KeyTest.rb +140 -0
  63. data/test/ResultSetTest.rb +162 -0
  64. data/test/RoleTest.rb +73 -0
  65. data/test/RowCountTest.rb +65 -0
  66. data/test/RowTest.rb +203 -0
  67. data/test/SQLTest.rb +182 -0
  68. data/test/SQLTypeTest.rb +101 -0
  69. data/test/ServiceManagerTest.rb +29 -0
  70. data/test/StatementTest.rb +135 -0
  71. data/test/TestSetup.rb +11 -0
  72. data/test/TransactionTest.rb +112 -0
  73. data/test/TypeTest.rb +92 -0
  74. data/test/UnitTest.rb +65 -0
  75. metadata +149 -0
data/ext/Connection.h ADDED
@@ -0,0 +1,50 @@
1
+ /*------------------------------------------------------------------------------
2
+ * Connection.h
3
+ *----------------------------------------------------------------------------*/
4
+ /**
5
+ * Copyright � Peter Wood, 2005
6
+ *
7
+ * The contents of this file are subject to the Mozilla Public License Version
8
+ * 1.1 (the "License"); you may not use this file except in compliance with the
9
+ * License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.mozilla.org/MPL/
12
+ *
13
+ * Software distributed under the License is distributed on an "AS IS" basis,
14
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
15
+ * the specificlanguage governing rights and limitations under the License.
16
+ *
17
+ * The Original Code is the FireRuby extension for the Ruby language.
18
+ *
19
+ * The Initial Developer of the Original Code is Peter Wood. All Rights
20
+ * Reserved.
21
+ *
22
+ * @author Peter Wood
23
+ * @version 1.0
24
+ */
25
+ #ifndef FIRERUBY_CONNECTION_H
26
+ #define FIRERUBY_CONNECTION_H
27
+
28
+ /* Includes. */
29
+ #ifndef FIRERUBY_FIRE_RUBY_H
30
+ #include "FireRuby.h"
31
+ #endif
32
+
33
+ #ifndef FIRERUBY_FIRE_RUBY_EXCEPTION_H
34
+ #include "FireRubyException.h"
35
+ #endif
36
+
37
+ /* Structure definitions. */
38
+ typedef struct
39
+ {
40
+ isc_db_handle handle;
41
+ } ConnectionHandle;
42
+
43
+ /* Function prototypes. */
44
+ void Init_Connection(VALUE);
45
+ VALUE rb_connection_new(VALUE, VALUE, VALUE, VALUE);
46
+ void rb_tx_started(VALUE, VALUE);
47
+ void rb_tx_released(VALUE, VALUE);
48
+ void connectionFree(void *);
49
+
50
+ #endif /* FIRERUBY_CONNECTION_H */
data/ext/DataArea.c ADDED
@@ -0,0 +1,274 @@
1
+ /*------------------------------------------------------------------------------
2
+ * DataArea.c
3
+ *----------------------------------------------------------------------------*/
4
+ /**
5
+ * Copyright � Peter Wood, 2005
6
+ *
7
+ * The contents of this file are subject to the Mozilla Public License Version
8
+ * 1.1 (the "License"); you may not use this file except in compliance with the
9
+ * License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.mozilla.org/MPL/
12
+ *
13
+ * Software distributed under the License is distributed on an "AS IS" basis,
14
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
15
+ * the specificlanguage governing rights and limitations under the License.
16
+ *
17
+ * The Original Code is the FireRuby extension for the Ruby language.
18
+ *
19
+ * The Initial Developer of the Original Code is Peter Wood. All Rights
20
+ * Reserved.
21
+ *
22
+ * @author Peter Wood
23
+ * @version 1.0
24
+ */
25
+
26
+ /* Includes. */
27
+ #include "DataArea.h"
28
+ #include "FireRubyException.h"
29
+
30
+ #ifdef OS_UNIX
31
+ #include <inttypes.h>
32
+ #else
33
+ typedef short int16_t;
34
+ typedef long int32_t;
35
+ typedef long long int64_t;
36
+ #endif
37
+
38
+
39
+ /**
40
+ * This function allocates the memory for a output XSQLDA based on a specified
41
+ * XSQLDA providing base details.
42
+ *
43
+ * @param size A count of the number of entries needed in the XSQLDA.
44
+ * @param statement A pointer to the statement handle that will be used in
45
+ * preparing the data area.
46
+ * @param dialect The SQL dialect to be used in preparing the data area.
47
+ *
48
+ * @return A pointer to the newly allocated XSQLDA.
49
+ *
50
+ */
51
+ XSQLDA *allocateOutXSQLDA(int size, isc_stmt_handle *statement, short dialect)
52
+ {
53
+ XSQLDA *area = (XSQLDA *)ALLOC_N(char, XSQLDA_LENGTH(size));
54
+
55
+ if(area != NULL)
56
+ {
57
+ ISC_STATUS status[20];
58
+
59
+ area->sqln = size;
60
+ area->version = SQLDA_VERSION1;
61
+ if(isc_dsql_describe(status, statement, dialect, area) != 0)
62
+ {
63
+ /* Release the memory and generate an error. */
64
+ free(area);
65
+ rb_fireruby_raise(status, "Error allocating output storage space.");
66
+ }
67
+ }
68
+ else
69
+ {
70
+ /* Generate an error. */
71
+ rb_raise(rb_eNoMemError,
72
+ "Memory allocation failure preparing output SQL data "\
73
+ "definition area.");
74
+ }
75
+
76
+ return(area);
77
+ }
78
+
79
+
80
+ /**
81
+ * This function allocates the memory for a input XSQLDA based on a specified
82
+ * XSQLDA providing base details.
83
+ *
84
+ * @param size A count of the number of entries needed in the XSQLDA.
85
+ * @param statement A pointer to the statement handle that will be used in
86
+ * preparing the data area.
87
+ * @param dialect The SQL dialect to be used in preparing the data area.
88
+ *
89
+ * @return A pointer to the newly allocated XSQLDA.
90
+ *
91
+ */
92
+ XSQLDA *allocateInXSQLDA(int size, isc_stmt_handle *statement, short dialect)
93
+ {
94
+ XSQLDA *area = NULL;
95
+
96
+ area = (XSQLDA *)ALLOC_N(char, XSQLDA_LENGTH(size));
97
+
98
+ if(area != NULL)
99
+ {
100
+ ISC_STATUS status[20];
101
+
102
+ area->sqln = size;
103
+ area->version = SQLDA_VERSION1;
104
+ if(isc_dsql_describe_bind(status, statement, dialect, area) != 0)
105
+ {
106
+ /* Release the memory and generate an error. */
107
+ free(area);
108
+ rb_fireruby_raise(status, "Error allocating input storage space.");
109
+ }
110
+ }
111
+ else
112
+ {
113
+ /* Generate an error. */
114
+ rb_raise(rb_eNoMemError,
115
+ "Memory allocation failure preparing input SQL data "\
116
+ "definition area.");
117
+ }
118
+
119
+ return(area);
120
+ }
121
+
122
+
123
+ /**
124
+ * This function initializes a previously allocated XSQLDA with space for the
125
+ * data it will contain.
126
+ *
127
+ * @param da A pointer to the XSQLDA to have data space allocated for.
128
+ *
129
+ */
130
+ void prepareDataArea(XSQLDA *da)
131
+ {
132
+ XSQLVAR *field = da->sqlvar;
133
+ int index;
134
+
135
+ for(index = 0; index < da->sqld; index++, field++)
136
+ {
137
+ int type = (field->sqltype & ~1),
138
+ total = (field->sqllen / 2) + 2;
139
+
140
+ field->sqldata = NULL;
141
+ field->sqlind = NULL;
142
+ switch(type)
143
+ {
144
+ case SQL_ARRAY :
145
+ fprintf(stderr, "Allocating for an array (NOT).\n");
146
+ break;
147
+
148
+ case SQL_BLOB :
149
+ field->sqldata = (char *)ALLOC(ISC_QUAD);
150
+ break;
151
+
152
+ case SQL_DOUBLE :
153
+ field->sqldata = (char *)ALLOC(double);
154
+ break;
155
+
156
+ case SQL_FLOAT :
157
+ field->sqldata = (char *)ALLOC(float);
158
+ break;
159
+
160
+ case SQL_INT64 :
161
+ field->sqldata = (char *)ALLOC(int64_t);
162
+ break;
163
+
164
+ case SQL_LONG :
165
+ field->sqldata = (char *)ALLOC(int32_t);
166
+ break;
167
+
168
+ case SQL_SHORT :
169
+ field->sqldata = (char *)ALLOC(int16_t);
170
+ break;
171
+
172
+ case SQL_TEXT :
173
+ field->sqldata = ALLOC_N(char, field->sqllen + 1);
174
+ break;
175
+
176
+ case SQL_TIMESTAMP :
177
+ field->sqldata = (char *)ALLOC(ISC_TIMESTAMP);
178
+ break;
179
+
180
+ case SQL_TYPE_DATE :
181
+ field->sqldata = (char *)ALLOC(ISC_DATE);
182
+ break;
183
+
184
+ case SQL_TYPE_TIME:
185
+ field->sqldata = (char *)ALLOC(ISC_TIME);
186
+ break;
187
+
188
+ case SQL_VARYING :
189
+ field->sqldata = (char *)ALLOC_N(short, total);
190
+ break;
191
+
192
+ default :
193
+ rb_fireruby_raise(NULL, "Unknown SQL data type encountered.");
194
+ }
195
+ field->sqlind = ALLOC(short);
196
+ *field->sqlind = 0;
197
+ }
198
+ }
199
+
200
+
201
+ /**
202
+ * This method cleans up all the internal memory associated with a XSQLDA.
203
+ *
204
+ * @param da A reference to the XSQLDA to be cleared up.
205
+ *
206
+ */
207
+ void releaseDataArea(XSQLDA *da)
208
+ {
209
+ XSQLVAR *field = da->sqlvar;
210
+ int index;
211
+
212
+ for(index = 0; index < da->sqld; index++, field++)
213
+ {
214
+ int type = (field->sqltype & ~1);
215
+
216
+ switch(type)
217
+ {
218
+ case SQL_ARRAY :
219
+ fprintf(stderr, "Releasing an array (NOT).\n");
220
+ break;
221
+
222
+ case SQL_BLOB :
223
+ free((ISC_QUAD *)field->sqldata);
224
+ break;
225
+
226
+ case SQL_DOUBLE :
227
+ free((double *)field->sqldata);
228
+ break;
229
+
230
+ case SQL_FLOAT :
231
+ free((float *)field->sqldata);
232
+ break;
233
+
234
+ case SQL_INT64 :
235
+ free((int64_t *)field->sqldata);
236
+ break;
237
+
238
+ case SQL_LONG :
239
+ free((int32_t *)field->sqldata);
240
+ break;
241
+
242
+ case SQL_SHORT :
243
+ free((int16_t *)field->sqldata);
244
+ break;
245
+
246
+ case SQL_TEXT :
247
+ free(field->sqldata);
248
+ break;
249
+
250
+ case SQL_TIMESTAMP :
251
+ free((ISC_TIMESTAMP *)field->sqldata);
252
+ break;
253
+
254
+ case SQL_TYPE_DATE :
255
+ free((ISC_DATE *)field->sqldata);
256
+ break;
257
+
258
+ case SQL_TYPE_TIME:
259
+ free((ISC_TIME *)field->sqldata);
260
+ break;
261
+
262
+ case SQL_VARYING :
263
+ free((short *)field->sqldata);
264
+ break;
265
+ }
266
+ if(field->sqlind != NULL)
267
+ {
268
+ free(field->sqlind);
269
+ }
270
+
271
+ field->sqldata = NULL;
272
+ field->sqlind = NULL;
273
+ }
274
+ }
data/ext/DataArea.h ADDED
@@ -0,0 +1,38 @@
1
+ /*------------------------------------------------------------------------------
2
+ * DataArea.h
3
+ *----------------------------------------------------------------------------*/
4
+ /**
5
+ * Copyright � Peter Wood, 2005
6
+ *
7
+ * The contents of this file are subject to the Mozilla Public License Version
8
+ * 1.1 (the "License"); you may not use this file except in compliance with the
9
+ * License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.mozilla.org/MPL/
12
+ *
13
+ * Software distributed under the License is distributed on an "AS IS" basis,
14
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
15
+ * the specificlanguage governing rights and limitations under the License.
16
+ *
17
+ * The Original Code is the FireRuby extension for the Ruby language.
18
+ *
19
+ * The Initial Developer of the Original Code is Peter Wood. All Rights
20
+ * Reserved.
21
+ *
22
+ * @author Peter Wood
23
+ * @version 1.0
24
+ */
25
+ #ifndef FIRERUBY_DATA_AREA_H
26
+ #define FIRERUBY_DATA_AREA_H
27
+
28
+ #ifndef IBASE_H_INCLUDED
29
+ #include "ibase.h"
30
+ #define IBASE_H_INCLUDED
31
+ #endif
32
+
33
+ XSQLDA *allocateOutXSQLDA(int, isc_stmt_handle *, short);
34
+ XSQLDA *allocateInXSQLDA(int, isc_stmt_handle *, short);
35
+ void prepareDataArea(XSQLDA *);
36
+ void releaseDataArea(XSQLDA *);
37
+
38
+ #endif /* FIRERUBY_DATA_AREA_H */