@@ -98,9 +98,22 @@ static int firebird_stmt_execute(pdo_stmt_t *stmt) /* {{{ */
98
98
break ;
99
99
}
100
100
S -> cursor_open = 0 ;
101
- /* assume all params have been bound */
102
101
103
- if (isc_dsql_execute (H -> isc_status , & H -> tr , & S -> stmt , PDO_FB_SQLDA_VERSION , S -> in_sqlda )) {
102
+ /* allocate storage for the output data */
103
+ if (S -> out_sqlda .sqld ) {
104
+ unsigned int i ;
105
+ for (i = 0 ; i < S -> out_sqlda .sqld ; i ++ ) {
106
+ XSQLVAR * var = & S -> out_sqlda .sqlvar [i ];
107
+ var -> sqlind = (void * )ecalloc (1 , var -> sqllen + 2 * sizeof (short ));
108
+ var -> sqldata = & ((char * )var -> sqlind )[sizeof (short )];
109
+ }
110
+ }
111
+
112
+ if (S -> statement_type == isc_info_sql_stmt_exec_procedure ) {
113
+ if (isc_dsql_execute2 (H -> isc_status , & H -> tr , & S -> stmt , PDO_FB_SQLDA_VERSION , S -> in_sqlda , & S -> out_sqlda )) {
114
+ break ;
115
+ }
116
+ } else if (isc_dsql_execute (H -> isc_status , & H -> tr , & S -> stmt , PDO_FB_SQLDA_VERSION , S -> in_sqlda )) {
104
117
break ;
105
118
}
106
119
@@ -162,16 +175,18 @@ static int firebird_stmt_fetch(pdo_stmt_t *stmt, /* {{{ */
162
175
strcpy (stmt -> error_code , "HY000" );
163
176
H -> last_app_error = "Cannot fetch from a closed cursor" ;
164
177
} else if (!S -> exhausted ) {
178
+ if (S -> statement_type == isc_info_sql_stmt_exec_procedure ) {
179
+ stmt -> row_count = 1 ;
180
+ S -> exhausted = 1 ;
181
+ return 1 ;
182
+ }
165
183
if (isc_dsql_fetch (H -> isc_status , & S -> stmt , PDO_FB_SQLDA_VERSION , & S -> out_sqlda )) {
166
184
if (H -> isc_status [0 ] && H -> isc_status [1 ]) {
167
185
RECORD_ERROR (stmt );
168
186
}
169
187
S -> exhausted = 1 ;
170
188
return 0 ;
171
189
}
172
- if (S -> statement_type == isc_info_sql_stmt_exec_procedure ) {
173
- S -> exhausted = 1 ;
174
- }
175
190
stmt -> row_count ++ ;
176
191
return 1 ;
177
192
}
@@ -188,10 +203,6 @@ static int firebird_stmt_describe(pdo_stmt_t *stmt, int colno) /* {{{ */
188
203
int colname_len ;
189
204
char * cp ;
190
205
191
- /* allocate storage for the column */
192
- var -> sqlind = (void * )ecalloc (1 , var -> sqllen + 2 * sizeof (short ));
193
- var -> sqldata = & ((char * )var -> sqlind )[sizeof (short )];
194
-
195
206
colname_len = (S -> H -> fetch_table_names && var -> relname_length )
196
207
? (var -> aliasname_length + var -> relname_length + 1 )
197
208
: (var -> aliasname_length );
0 commit comments