@@ -56,8 +56,8 @@ int dpiStmt__allocate(dpiConn *conn, int scrollable, dpiStmt **stmt,
56
56
// Bind the variable to the statement using either a position or a name. A
57
57
// reference to the variable will be retained.
58
58
//-----------------------------------------------------------------------------
59
- static int dpiStmt__bind (dpiStmt * stmt , dpiVar * var , int addReference ,
60
- uint32_t pos , const char * name , uint32_t nameLength , dpiError * error )
59
+ static int dpiStmt__bind (dpiStmt * stmt , dpiVar * var , uint32_t pos ,
60
+ const char * name , uint32_t nameLength , dpiError * error )
61
61
{
62
62
dpiBindVar * bindVars , * entry = NULL ;
63
63
int found , dynamicBind , status ;
@@ -148,8 +148,7 @@ static int dpiStmt__bind(dpiStmt *stmt, dpiVar *var, int addReference,
148
148
}
149
149
150
150
// perform actual bind
151
- if (addReference )
152
- dpiGen__setRefCount (var , error , 1 );
151
+ dpiGen__setRefCount (var , error , 1 );
153
152
entry -> var = var ;
154
153
dynamicBind = stmt -> isReturning || var -> isDynamic ;
155
154
if (pos > 0 ) {
@@ -368,6 +367,7 @@ static int dpiStmt__createBindVar(dpiStmt *stmt,
368
367
dpiData * varData ;
369
368
dpiVar * tempVar ;
370
369
uint32_t size ;
370
+ int status ;
371
371
372
372
// determine the type (and size) of bind variable to create
373
373
size = 0 ;
@@ -418,13 +418,11 @@ static int dpiStmt__createBindVar(dpiStmt *stmt,
418
418
return DPI_FAILURE ;
419
419
420
420
// bind variable to statement
421
- if (dpiStmt__bind (stmt , tempVar , 0 , pos , name , nameLength , error ) < 0 ) {
422
- dpiVar__free (tempVar , error );
423
- return DPI_FAILURE ;
424
- }
425
-
426
- * var = tempVar ;
427
- return DPI_SUCCESS ;
421
+ status = dpiStmt__bind (stmt , tempVar , pos , name , nameLength , error );
422
+ dpiGen__setRefCount (tempVar , error , -1 );
423
+ if (status == DPI_SUCCESS )
424
+ * var = tempVar ;
425
+ return status ;
428
426
}
429
427
430
428
@@ -1057,7 +1055,7 @@ static int dpiStmt__reExecute(dpiStmt *stmt, uint32_t numIters,
1057
1055
continue ;
1058
1056
var = bindVar -> var ;
1059
1057
bindVar -> var = NULL ;
1060
- if (dpiStmt__bind (stmt , var , 0 , bindVar -> pos , bindVar -> name ,
1058
+ if (dpiStmt__bind (stmt , var , bindVar -> pos , bindVar -> name ,
1061
1059
bindVar -> nameLength , error ) < 0 ) {
1062
1060
dpiGen__setRefCount (var , error , -1 );
1063
1061
return DPI_FAILURE ;
@@ -1094,7 +1092,7 @@ int dpiStmt_bindByName(dpiStmt *stmt, const char *name, uint32_t nameLength,
1094
1092
DPI_CHECK_PTR_NOT_NULL (stmt , name )
1095
1093
if (dpiGen__checkHandle (var , DPI_HTYPE_VAR , "bind by name" , & error ) < 0 )
1096
1094
return dpiGen__endPublicFn (stmt , DPI_FAILURE , & error );
1097
- status = dpiStmt__bind (stmt , var , 1 , 0 , name , nameLength , & error );
1095
+ status = dpiStmt__bind (stmt , var , 0 , name , nameLength , & error );
1098
1096
return dpiGen__endPublicFn (stmt , status , & error );
1099
1097
}
1100
1098
@@ -1112,7 +1110,7 @@ int dpiStmt_bindByPos(dpiStmt *stmt, uint32_t pos, dpiVar *var)
1112
1110
return dpiGen__endPublicFn (stmt , DPI_FAILURE , & error );
1113
1111
if (dpiGen__checkHandle (var , DPI_HTYPE_VAR , "bind by pos" , & error ) < 0 )
1114
1112
return dpiGen__endPublicFn (stmt , DPI_FAILURE , & error );
1115
- status = dpiStmt__bind (stmt , var , 1 , pos , NULL , 0 , & error );
1113
+ status = dpiStmt__bind (stmt , var , pos , NULL , 0 , & error );
1116
1114
return dpiGen__endPublicFn (stmt , status , & error );
1117
1115
}
1118
1116
@@ -1132,10 +1130,8 @@ int dpiStmt_bindValueByName(dpiStmt *stmt, const char *name,
1132
1130
return dpiGen__endPublicFn (stmt , DPI_FAILURE , & error );
1133
1131
DPI_CHECK_PTR_NOT_NULL (stmt , name )
1134
1132
DPI_CHECK_PTR_NOT_NULL (stmt , data )
1135
- if (dpiStmt__createBindVar (stmt , nativeTypeNum , data , & var , 0 , name ,
1136
- nameLength , & error ) < 0 )
1137
- return dpiGen__endPublicFn (stmt , DPI_FAILURE , & error );
1138
- status = dpiStmt__bind (stmt , var , 1 , 0 , name , nameLength , & error );
1133
+ status = dpiStmt__createBindVar (stmt , nativeTypeNum , data , & var , 0 , name ,
1134
+ nameLength , & error );
1139
1135
return dpiGen__endPublicFn (stmt , status , & error );
1140
1136
}
1141
1137
@@ -1154,10 +1150,8 @@ int dpiStmt_bindValueByPos(dpiStmt *stmt, uint32_t pos,
1154
1150
if (dpiStmt__check (stmt , __func__ , & error ) < 0 )
1155
1151
return dpiGen__endPublicFn (stmt , DPI_FAILURE , & error );
1156
1152
DPI_CHECK_PTR_NOT_NULL (stmt , data )
1157
- if (dpiStmt__createBindVar (stmt , nativeTypeNum , data , & var , pos , NULL , 0 ,
1158
- & error ) < 0 )
1159
- return dpiGen__endPublicFn (stmt , DPI_FAILURE , & error );
1160
- status = dpiStmt__bind (stmt , var , 1 , pos , NULL , 0 , & error );
1153
+ status = dpiStmt__createBindVar (stmt , nativeTypeNum , data , & var , pos , NULL ,
1154
+ 0 , & error );
1161
1155
return dpiGen__endPublicFn (stmt , status , & error );
1162
1156
}
1163
1157
0 commit comments