1
- /* Module: bind.c
1
+ /*-------
2
+ * Module: bind.c
2
3
*
3
4
* Description: This module contains routines related to binding
4
5
* columns and parameters.
9
10
* SQLParamOptions(NI)
10
11
*
11
12
* Comments: See "notice.txt" for copyright and license information.
12
- *
13
+ *-------
13
14
*/
14
15
15
16
#ifdef HAVE_CONFIG_H
33
34
#include "sqlext.h"
34
35
#endif
35
36
36
- /* Bind parameters on a statement handle */
37
37
38
+ /* Bind parameters on a statement handle */
38
39
RETCODE SQL_API
39
40
SQLBindParameter (
40
41
HSTMT hstmt ,
@@ -112,8 +113,8 @@ SQLBindParameter(
112
113
}
113
114
}
114
115
115
- ipar -- ; /* use zero based column numbers for the
116
- * below part */
116
+ /* use zero based column numbers for the below part */
117
+ ipar -- ;
117
118
118
119
/* store the given info */
119
120
stmt -> parameters [ipar ].buflen = cbValueMax ;
@@ -158,9 +159,8 @@ SQLBindParameter(
158
159
return SQL_SUCCESS ;
159
160
}
160
161
161
- /* - - - - - - - - - */
162
162
163
- /* Associate a user-supplied buffer with a database column. */
163
+ /* Associate a user-supplied buffer with a database column. */
164
164
RETCODE SQL_API
165
165
SQLBindCol (
166
166
HSTMT hstmt ,
@@ -197,7 +197,6 @@ SQLBindCol(
197
197
/* If the bookmark column is being bound, then just save it */
198
198
if (icol == 0 )
199
199
{
200
-
201
200
if (rgbValue == NULL )
202
201
{
203
202
stmt -> bookmark .buffer = NULL ;
@@ -220,10 +219,12 @@ SQLBindCol(
220
219
return SQL_SUCCESS ;
221
220
}
222
221
223
- /* allocate enough bindings if not already done */
224
- /* Most likely, execution of a statement would have setup the */
225
- /* necessary bindings. But some apps call BindCol before any */
226
- /* statement is executed. */
222
+ /*
223
+ * Allocate enough bindings if not already done.
224
+ * Most likely, execution of a statement would have setup the
225
+ * necessary bindings. But some apps call BindCol before any
226
+ * statement is executed.
227
+ */
227
228
if (icol > stmt -> bindings_allocated )
228
229
extend_bindings (stmt , icol );
229
230
@@ -236,8 +237,8 @@ SQLBindCol(
236
237
return SQL_ERROR ;
237
238
}
238
239
239
- icol -- ; /* use zero based col numbers from here
240
- * out */
240
+ /* use zero based col numbers from here out */
241
+ icol -- ;
241
242
242
243
/* Reset for SQLGetData */
243
244
stmt -> bindings [icol ].data_left = -1 ;
@@ -264,15 +265,15 @@ SQLBindCol(
264
265
return SQL_SUCCESS ;
265
266
}
266
267
267
- /* - - - - - - - - - */
268
-
269
- /* Returns the description of a parameter marker. */
270
- /* This function is listed as not being supported by SQLGetFunctions() because it is */
271
- /* used to describe "parameter markers" (not bound parameters), in which case, */
272
- /* the dbms should return info on the markers. Since Postgres doesn't support that, */
273
- /* it is best to say this function is not supported and let the application assume a */
274
- /* data type (most likely varchar). */
275
268
269
+ /*
270
+ * Returns the description of a parameter marker.
271
+ * This function is listed as not being supported by SQLGetFunctions() because it is
272
+ * used to describe "parameter markers" (not bound parameters), in which case,
273
+ * the dbms should return info on the markers. Since Postgres doesn't support that,
274
+ * it is best to say this function is not supported and let the application assume a
275
+ * data type (most likely varchar).
276
+ */
276
277
RETCODE SQL_API
277
278
SQLDescribeParam (
278
279
HSTMT hstmt ,
@@ -323,10 +324,8 @@ SQLDescribeParam(
323
324
return SQL_SUCCESS ;
324
325
}
325
326
326
- /* - - - - - - - - - */
327
-
328
- /* Sets multiple values (arrays) for the set of parameter markers. */
329
327
328
+ /* Sets multiple values (arrays) for the set of parameter markers. */
330
329
RETCODE SQL_API
331
330
SQLParamOptions (
332
331
HSTMT hstmt ,
@@ -341,15 +340,16 @@ SQLParamOptions(
341
340
return SQL_ERROR ;
342
341
}
343
342
344
- /* - - - - - - - - - */
345
343
346
- /* This function should really talk to the dbms to determine the number of */
347
- /* "parameter markers" (not bound parameters) in the statement. But, since */
348
- /* Postgres doesn't support that, the driver should just count the number of markers */
349
- /* and return that. The reason the driver just can't say this function is unsupported */
350
- /* like it does for SQLDescribeParam is that some applications don't care and try */
351
- /* to call it anyway. */
352
- /* If the statement does not have parameters, it should just return 0. */
344
+ /*
345
+ * This function should really talk to the dbms to determine the number of
346
+ * "parameter markers" (not bound parameters) in the statement. But, since
347
+ * Postgres doesn't support that, the driver should just count the number of markers
348
+ * and return that. The reason the driver just can't say this function is unsupported
349
+ * like it does for SQLDescribeParam is that some applications don't care and try
350
+ * to call it anyway.
351
+ * If the statement does not have parameters, it should just return 0.
352
+ */
353
353
RETCODE SQL_API
354
354
SQLNumParams (
355
355
HSTMT hstmt ,
@@ -387,10 +387,8 @@ SQLNumParams(
387
387
}
388
388
else
389
389
{
390
-
391
390
for (i = 0 ; i < strlen (stmt -> statement ); i ++ )
392
391
{
393
-
394
392
if (stmt -> statement [i ] == '?' && !in_quote )
395
393
(* pcpar )++ ;
396
394
else
@@ -399,12 +397,12 @@ SQLNumParams(
399
397
in_quote = (in_quote ? FALSE : TRUE);
400
398
}
401
399
}
402
-
403
400
return SQL_SUCCESS ;
404
401
}
405
402
}
406
403
407
- /********************************************************************
404
+
405
+ /*
408
406
* Bindings Implementation
409
407
*/
410
408
BindInfoClass *
@@ -428,6 +426,7 @@ create_empty_bindings(int num_columns)
428
426
return new_bindings ;
429
427
}
430
428
429
+
431
430
void
432
431
extend_bindings (StatementClass * stmt , int num_columns )
433
432
{
@@ -437,11 +436,12 @@ extend_bindings(StatementClass *stmt, int num_columns)
437
436
438
437
mylog ("%s: entering ... stmt=%u, bindings_allocated=%d, num_columns=%d\n" , func , stmt , stmt -> bindings_allocated , num_columns );
439
438
440
- /* if we have too few, allocate room for more, and copy the old */
441
- /* entries into the new structure */
439
+ /*
440
+ * if we have too few, allocate room for more, and copy the old
441
+ * entries into the new structure
442
+ */
442
443
if (stmt -> bindings_allocated < num_columns )
443
444
{
444
-
445
445
new_bindings = create_empty_bindings (num_columns );
446
446
if (!new_bindings )
447
447
{
@@ -466,11 +466,12 @@ extend_bindings(StatementClass *stmt, int num_columns)
466
466
467
467
stmt -> bindings = new_bindings ;
468
468
stmt -> bindings_allocated = num_columns ;
469
-
470
469
}
471
- /* There is no reason to zero out extra bindings if there are */
472
- /* more than needed. If an app has allocated extra bindings, */
473
- /* let it worry about it by unbinding those columns. */
470
+ /*
471
+ * There is no reason to zero out extra bindings if there are
472
+ * more than needed. If an app has allocated extra bindings,
473
+ * let it worry about it by unbinding those columns.
474
+ */
474
475
475
476
/* SQLBindCol(1..) ... SQLBindCol(10...) # got 10 bindings */
476
477
/* SQLExecDirect(...) # returns 5 cols */
0 commit comments