1- /* Module:bind.c
1+ /*-------
2+ * Module:bind.c
23 *
34 * Description:This module contains routines related to binding
45 *columns and parameters.
910 *SQLParamOptions(NI)
1011 *
1112 * Comments:See "notice.txt" for copyright and license information.
12- *
13+ *-------
1314 */
1415
1516#ifdef HAVE_CONFIG_H
3334#include "sqlext.h"
3435#endif
3536
36- /*Bind parameters on a statement handle */
3737
38+ /*Bind parameters on a statement handle */
3839RETCODE SQL_API
3940SQLBindParameter (
4041HSTMT hstmt ,
@@ -112,8 +113,8 @@ SQLBindParameter(
112113}
113114}
114115
115- ipar -- ; /* use zero based column numbers for the
116- * below part */
116+ /* use zero based column numbers for the below part */
117+ ipar -- ;
117118
118119/* store the given info */
119120stmt -> parameters [ipar ].buflen = cbValueMax ;
@@ -158,9 +159,8 @@ SQLBindParameter(
158159return SQL_SUCCESS ;
159160}
160161
161- /*--------- */
162162
163- /* Associate a user-supplied buffer with a database column. */
163+ /* Associate a user-supplied buffer with a database column. */
164164RETCODE SQL_API
165165SQLBindCol (
166166HSTMT hstmt ,
@@ -197,7 +197,6 @@ SQLBindCol(
197197/* If the bookmark column is being bound, then just save it */
198198if (icol == 0 )
199199{
200-
201200if (rgbValue == NULL )
202201{
203202stmt -> bookmark .buffer = NULL ;
@@ -220,10 +219,12 @@ SQLBindCol(
220219return SQL_SUCCESS ;
221220}
222221
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+ */
227228if (icol > stmt -> bindings_allocated )
228229extend_bindings (stmt ,icol );
229230
@@ -236,8 +237,8 @@ SQLBindCol(
236237return SQL_ERROR ;
237238}
238239
239- icol -- ; /* use zero based col numbers from here
240- * out */
240+ /* use zero based col numbers from here out */
241+ icol -- ;
241242
242243/* Reset for SQLGetData */
243244stmt -> bindings [icol ].data_left = -1 ;
@@ -264,15 +265,15 @@ SQLBindCol(
264265return SQL_SUCCESS ;
265266}
266267
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). */
275268
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+ */
276277RETCODE SQL_API
277278SQLDescribeParam (
278279HSTMT hstmt ,
@@ -323,10 +324,8 @@ SQLDescribeParam(
323324return SQL_SUCCESS ;
324325}
325326
326- /*--------- */
327-
328- /*Sets multiple values (arrays) for the set of parameter markers. */
329327
328+ /*Sets multiple values (arrays) for the set of parameter markers. */
330329RETCODE SQL_API
331330SQLParamOptions (
332331HSTMT hstmt ,
@@ -341,15 +340,16 @@ SQLParamOptions(
341340return SQL_ERROR ;
342341}
343342
344- /*--------- */
345343
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+ */
353353RETCODE SQL_API
354354SQLNumParams (
355355HSTMT hstmt ,
@@ -387,10 +387,8 @@ SQLNumParams(
387387}
388388else
389389{
390-
391390for (i = 0 ;i < strlen (stmt -> statement );i ++ )
392391{
393-
394392if (stmt -> statement [i ]== '?' && !in_quote )
395393(* pcpar )++ ;
396394else
@@ -399,12 +397,12 @@ SQLNumParams(
399397in_quote = (in_quote ? FALSE : TRUE);
400398}
401399}
402-
403400return SQL_SUCCESS ;
404401}
405402}
406403
407- /********************************************************************
404+
405+ /*
408406 * Bindings Implementation
409407 */
410408BindInfoClass *
@@ -428,6 +426,7 @@ create_empty_bindings(int num_columns)
428426return new_bindings ;
429427}
430428
429+
431430void
432431extend_bindings (StatementClass * stmt ,int num_columns )
433432{
@@ -437,11 +436,12 @@ extend_bindings(StatementClass *stmt, int num_columns)
437436
438437mylog ("%s: entering ... stmt=%u, bindings_allocated=%d, num_columns=%d\n" ,func ,stmt ,stmt -> bindings_allocated ,num_columns );
439438
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+ */
442443if (stmt -> bindings_allocated < num_columns )
443444{
444-
445445new_bindings = create_empty_bindings (num_columns );
446446if (!new_bindings )
447447{
@@ -466,11 +466,12 @@ extend_bindings(StatementClass *stmt, int num_columns)
466466
467467stmt -> bindings = new_bindings ;
468468stmt -> bindings_allocated = num_columns ;
469-
470469}
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+ */
474475
475476/* SQLBindCol(1..) ... SQLBindCol(10...) # got 10 bindings */
476477/* SQLExecDirect(...) # returns 5 cols */