rubyfb 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/Manifest +0 -1
- data/Rakefile +1 -1
- data/ext/AddUser.c +217 -248
- data/ext/AddUser.h +3 -3
- data/ext/Backup.c +337 -404
- data/ext/Backup.h +3 -3
- data/ext/Blob.c +197 -248
- data/ext/Blob.h +30 -31
- data/ext/Common.c +17 -18
- data/ext/Common.h +10 -10
- data/ext/Connection.c +413 -487
- data/ext/Connection.h +18 -19
- data/ext/DataArea.c +172 -189
- data/ext/DataArea.h +11 -11
- data/ext/Database.c +198 -238
- data/ext/Database.h +16 -17
- data/ext/FireRuby.c +118 -142
- data/ext/FireRuby.h +17 -17
- data/ext/FireRubyException.c +68 -138
- data/ext/FireRubyException.h +14 -21
- data/ext/Generator.c +296 -377
- data/ext/Generator.h +17 -18
- data/ext/RemoveUser.c +91 -102
- data/ext/RemoveUser.h +3 -3
- data/ext/Restore.c +353 -423
- data/ext/Restore.h +3 -3
- data/ext/ResultSet.c +423 -456
- data/ext/ResultSet.h +26 -27
- data/ext/Row.c +505 -568
- data/ext/Row.h +27 -28
- data/ext/ServiceManager.c +143 -164
- data/ext/ServiceManager.h +17 -18
- data/ext/Services.c +58 -67
- data/ext/Services.h +3 -3
- data/ext/Statement.c +388 -449
- data/ext/Statement.h +30 -31
- data/ext/Transaction.c +374 -448
- data/ext/Transaction.h +17 -18
- data/ext/TypeMap.c +654 -774
- data/ext/TypeMap.h +17 -17
- data/ext/rfbint.h +3 -3
- data/lib/active_record/connection_adapters/rubyfb_adapter.rb +1 -1
- data/lib/rubyfb_lib.so +0 -0
- data/lib/src.rb +33 -0
- data/rubyfb.gemspec +3 -3
- data/test/ResultSetTest.rb +13 -0
- data/test/RowTest.rb +16 -0
- metadata +4 -5
- data/test/UnitTest.rb +0 -65
data/ext/Connection.h
CHANGED
@@ -3,20 +3,20 @@
|
|
3
3
|
*----------------------------------------------------------------------------*/
|
4
4
|
/**
|
5
5
|
* Copyright � Peter Wood, 2005
|
6
|
-
*
|
6
|
+
*
|
7
7
|
* The contents of this file are subject to the Mozilla Public License Version
|
8
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
|
9
|
+
* License. You may obtain a copy of the License at
|
10
10
|
*
|
11
11
|
* http://www.mozilla.org/MPL/
|
12
|
-
*
|
12
|
+
*
|
13
13
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
14
14
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
15
15
|
* the specificlanguage governing rights and limitations under the License.
|
16
|
-
*
|
16
|
+
*
|
17
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
|
18
|
+
*
|
19
|
+
* The Initial Developer of the Original Code is Peter Wood. All Rights
|
20
20
|
* Reserved.
|
21
21
|
*
|
22
22
|
* @author Peter Wood
|
@@ -25,7 +25,7 @@
|
|
25
25
|
#ifndef FIRERUBY_CONNECTION_H
|
26
26
|
#define FIRERUBY_CONNECTION_H
|
27
27
|
|
28
|
-
|
28
|
+
/* Includes. */
|
29
29
|
#ifndef FIRERUBY_FIRE_RUBY_H
|
30
30
|
#include "FireRuby.h"
|
31
31
|
#endif
|
@@ -34,17 +34,16 @@
|
|
34
34
|
#include "FireRubyException.h"
|
35
35
|
#endif
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
void connectionFree(void *);
|
37
|
+
/* Structure definitions. */
|
38
|
+
typedef struct {
|
39
|
+
isc_db_handle handle;
|
40
|
+
} ConnectionHandle;
|
41
|
+
|
42
|
+
/* Function prototypes. */
|
43
|
+
void Init_Connection(VALUE);
|
44
|
+
VALUE rb_connection_new(VALUE, VALUE, VALUE, VALUE);
|
45
|
+
void rb_tx_started(VALUE, VALUE);
|
46
|
+
void rb_tx_released(VALUE, VALUE);
|
47
|
+
void connectionFree(void *);
|
49
48
|
|
50
49
|
#endif /* FIRERUBY_CONNECTION_H */
|
data/ext/DataArea.c
CHANGED
@@ -40,32 +40,27 @@
|
|
40
40
|
* @return A pointer to the newly allocated XSQLDA.
|
41
41
|
*
|
42
42
|
*/
|
43
|
-
XSQLDA *allocateOutXSQLDA(int size, isc_stmt_handle *statement, short dialect)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
"Memory allocation failure preparing output SQL data "\
|
65
|
-
"definition area.");
|
66
|
-
}
|
67
|
-
|
68
|
-
return(area);
|
43
|
+
XSQLDA *allocateOutXSQLDA(int size, isc_stmt_handle *statement, short dialect) {
|
44
|
+
XSQLDA *area = (XSQLDA *)ALLOC_N(char, XSQLDA_LENGTH(size));
|
45
|
+
|
46
|
+
if(area != NULL) {
|
47
|
+
ISC_STATUS status[ISC_STATUS_LENGTH];
|
48
|
+
|
49
|
+
area->sqln = size;
|
50
|
+
area->version = SQLDA_VERSION1;
|
51
|
+
if(isc_dsql_describe(status, statement, dialect, area) != 0) {
|
52
|
+
/* Release the memory and generate an error. */
|
53
|
+
free(area);
|
54
|
+
rb_fireruby_raise(status, "Error allocating output storage space.");
|
55
|
+
}
|
56
|
+
} else {
|
57
|
+
/* Generate an error. */
|
58
|
+
rb_raise(rb_eNoMemError,
|
59
|
+
"Memory allocation failure preparing output SQL data " \
|
60
|
+
"definition area.");
|
61
|
+
}
|
62
|
+
|
63
|
+
return(area);
|
69
64
|
}
|
70
65
|
|
71
66
|
|
@@ -81,34 +76,29 @@ XSQLDA *allocateOutXSQLDA(int size, isc_stmt_handle *statement, short dialect)
|
|
81
76
|
* @return A pointer to the newly allocated XSQLDA.
|
82
77
|
*
|
83
78
|
*/
|
84
|
-
XSQLDA *allocateInXSQLDA(int size, isc_stmt_handle *statement, short dialect)
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
"Memory allocation failure preparing input SQL data "\
|
108
|
-
"definition area.");
|
109
|
-
}
|
110
|
-
|
111
|
-
return(area);
|
79
|
+
XSQLDA *allocateInXSQLDA(int size, isc_stmt_handle *statement, short dialect) {
|
80
|
+
XSQLDA *area = NULL;
|
81
|
+
|
82
|
+
area = (XSQLDA *)ALLOC_N(char, XSQLDA_LENGTH(size));
|
83
|
+
|
84
|
+
if(area != NULL) {
|
85
|
+
ISC_STATUS status[ISC_STATUS_LENGTH];
|
86
|
+
|
87
|
+
area->sqln = size;
|
88
|
+
area->version = SQLDA_VERSION1;
|
89
|
+
if(isc_dsql_describe_bind(status, statement, dialect, area) != 0) {
|
90
|
+
/* Release the memory and generate an error. */
|
91
|
+
free(area);
|
92
|
+
rb_fireruby_raise(status, "Error allocating input storage space.");
|
93
|
+
}
|
94
|
+
} else {
|
95
|
+
/* Generate an error. */
|
96
|
+
rb_raise(rb_eNoMemError,
|
97
|
+
"Memory allocation failure preparing input SQL data " \
|
98
|
+
"definition area.");
|
99
|
+
}
|
100
|
+
|
101
|
+
return(area);
|
112
102
|
}
|
113
103
|
|
114
104
|
|
@@ -119,74 +109,71 @@ XSQLDA *allocateInXSQLDA(int size, isc_stmt_handle *statement, short dialect)
|
|
119
109
|
* @param da A pointer to the XSQLDA to have data space allocated for.
|
120
110
|
*
|
121
111
|
*/
|
122
|
-
void prepareDataArea(XSQLDA *da)
|
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
|
-
field->sqlind = ALLOC(short);
|
188
|
-
*field->sqlind = 0;
|
189
|
-
}
|
112
|
+
void prepareDataArea(XSQLDA *da) {
|
113
|
+
XSQLVAR *field = da->sqlvar;
|
114
|
+
int index;
|
115
|
+
|
116
|
+
for(index = 0; index < da->sqld; index++, field++) {
|
117
|
+
int type = (field->sqltype & ~1),
|
118
|
+
total = (field->sqllen / 2) + 2;
|
119
|
+
|
120
|
+
field->sqldata = NULL;
|
121
|
+
field->sqlind = NULL;
|
122
|
+
switch(type) {
|
123
|
+
case SQL_ARRAY:
|
124
|
+
fprintf(stderr, "Allocating for an array (NOT).\n");
|
125
|
+
break;
|
126
|
+
|
127
|
+
case SQL_BLOB:
|
128
|
+
field->sqldata = (char *)ALLOC(ISC_QUAD);
|
129
|
+
break;
|
130
|
+
|
131
|
+
case SQL_DOUBLE:
|
132
|
+
field->sqldata = (char *)ALLOC(double);
|
133
|
+
break;
|
134
|
+
|
135
|
+
case SQL_FLOAT:
|
136
|
+
field->sqldata = (char *)ALLOC(float);
|
137
|
+
break;
|
138
|
+
|
139
|
+
case SQL_INT64:
|
140
|
+
field->sqldata = (char *)ALLOC(int64_t);
|
141
|
+
break;
|
142
|
+
|
143
|
+
case SQL_LONG:
|
144
|
+
field->sqldata = (char *)ALLOC(int32_t);
|
145
|
+
break;
|
146
|
+
|
147
|
+
case SQL_SHORT:
|
148
|
+
field->sqldata = (char *)ALLOC(int16_t);
|
149
|
+
break;
|
150
|
+
|
151
|
+
case SQL_TEXT:
|
152
|
+
field->sqldata = ALLOC_N(char, field->sqllen + 1);
|
153
|
+
break;
|
154
|
+
|
155
|
+
case SQL_TIMESTAMP:
|
156
|
+
field->sqldata = (char *)ALLOC(ISC_TIMESTAMP);
|
157
|
+
break;
|
158
|
+
|
159
|
+
case SQL_TYPE_DATE:
|
160
|
+
field->sqldata = (char *)ALLOC(ISC_DATE);
|
161
|
+
break;
|
162
|
+
|
163
|
+
case SQL_TYPE_TIME:
|
164
|
+
field->sqldata = (char *)ALLOC(ISC_TIME);
|
165
|
+
break;
|
166
|
+
|
167
|
+
case SQL_VARYING:
|
168
|
+
field->sqldata = (char *)ALLOC_N(short, total);
|
169
|
+
break;
|
170
|
+
|
171
|
+
default:
|
172
|
+
rb_fireruby_raise(NULL, "Unknown SQL data type encountered.");
|
173
|
+
}
|
174
|
+
field->sqlind = ALLOC(short);
|
175
|
+
*field->sqlind = 0;
|
176
|
+
}
|
190
177
|
}
|
191
178
|
|
192
179
|
|
@@ -196,71 +183,67 @@ void prepareDataArea(XSQLDA *da)
|
|
196
183
|
* @param da A reference to the XSQLDA to be cleared up.
|
197
184
|
*
|
198
185
|
*/
|
199
|
-
void releaseDataArea(XSQLDA *da)
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
field->sqldata = NULL;
|
264
|
-
field->sqlind = NULL;
|
265
|
-
}
|
186
|
+
void releaseDataArea(XSQLDA *da) {
|
187
|
+
XSQLVAR *field = da->sqlvar;
|
188
|
+
int index;
|
189
|
+
|
190
|
+
for(index = 0; index < da->sqld; index++, field++) {
|
191
|
+
int type = (field->sqltype & ~1);
|
192
|
+
|
193
|
+
switch(type) {
|
194
|
+
case SQL_ARRAY:
|
195
|
+
fprintf(stderr, "Releasing an array (NOT).\n");
|
196
|
+
break;
|
197
|
+
|
198
|
+
case SQL_BLOB:
|
199
|
+
free((ISC_QUAD *)field->sqldata);
|
200
|
+
break;
|
201
|
+
|
202
|
+
case SQL_DOUBLE:
|
203
|
+
free((double *)field->sqldata);
|
204
|
+
break;
|
205
|
+
|
206
|
+
case SQL_FLOAT:
|
207
|
+
free((float *)field->sqldata);
|
208
|
+
break;
|
209
|
+
|
210
|
+
case SQL_INT64:
|
211
|
+
free((int64_t *)field->sqldata);
|
212
|
+
break;
|
213
|
+
|
214
|
+
case SQL_LONG:
|
215
|
+
free((int32_t *)field->sqldata);
|
216
|
+
break;
|
217
|
+
|
218
|
+
case SQL_SHORT:
|
219
|
+
free((int16_t *)field->sqldata);
|
220
|
+
break;
|
221
|
+
|
222
|
+
case SQL_TEXT:
|
223
|
+
free(field->sqldata);
|
224
|
+
break;
|
225
|
+
|
226
|
+
case SQL_TIMESTAMP:
|
227
|
+
free((ISC_TIMESTAMP *)field->sqldata);
|
228
|
+
break;
|
229
|
+
|
230
|
+
case SQL_TYPE_DATE:
|
231
|
+
free((ISC_DATE *)field->sqldata);
|
232
|
+
break;
|
233
|
+
|
234
|
+
case SQL_TYPE_TIME:
|
235
|
+
free((ISC_TIME *)field->sqldata);
|
236
|
+
break;
|
237
|
+
|
238
|
+
case SQL_VARYING:
|
239
|
+
free((short *)field->sqldata);
|
240
|
+
break;
|
241
|
+
}
|
242
|
+
if(field->sqlind != NULL) {
|
243
|
+
free(field->sqlind);
|
244
|
+
}
|
245
|
+
|
246
|
+
field->sqldata = NULL;
|
247
|
+
field->sqlind = NULL;
|
248
|
+
}
|
266
249
|
}
|
data/ext/DataArea.h
CHANGED
@@ -3,20 +3,20 @@
|
|
3
3
|
*----------------------------------------------------------------------------*/
|
4
4
|
/**
|
5
5
|
* Copyright � Peter Wood, 2005
|
6
|
-
*
|
6
|
+
*
|
7
7
|
* The contents of this file are subject to the Mozilla Public License Version
|
8
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
|
9
|
+
* License. You may obtain a copy of the License at
|
10
10
|
*
|
11
11
|
* http://www.mozilla.org/MPL/
|
12
|
-
*
|
12
|
+
*
|
13
13
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
14
14
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
15
15
|
* the specificlanguage governing rights and limitations under the License.
|
16
|
-
*
|
16
|
+
*
|
17
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
|
18
|
+
*
|
19
|
+
* The Initial Developer of the Original Code is Peter Wood. All Rights
|
20
20
|
* Reserved.
|
21
21
|
*
|
22
22
|
* @author Peter Wood
|
@@ -29,10 +29,10 @@
|
|
29
29
|
#include "ibase.h"
|
30
30
|
#define IBASE_H_INCLUDED
|
31
31
|
#endif
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
37
|
|
38
38
|
#endif /* FIRERUBY_DATA_AREA_H */
|