94
97
apdopts->parameters[ipar].precision = ipdopts->parameters[ipar].precision;
95
98
apdopts->parameters[ipar].scale = ipdopts->parameters[ipar].scale;
99
101
* If rebinding a parameter that had data-at-exec stuff in it, then
100
102
* free that stuff
102
if (apdopts->parameters[ipar].EXEC_used)
104
if (pdata_info->pdata[ipar].EXEC_used)
104
free(apdopts->parameters[ipar].EXEC_used);
105
apdopts->parameters[ipar].EXEC_used = NULL;
106
free(pdata_info->pdata[ipar].EXEC_used);
107
pdata_info->pdata[ipar].EXEC_used = NULL;
108
if (apdopts->parameters[ipar].EXEC_buffer)
110
if (pdata_info->pdata[ipar].EXEC_buffer)
110
free(apdopts->parameters[ipar].EXEC_buffer);
111
apdopts->parameters[ipar].EXEC_buffer = NULL;
112
free(pdata_info->pdata[ipar].EXEC_buffer);
113
pdata_info->pdata[ipar].EXEC_buffer = NULL;
114
116
if (pcbValue && apdopts->param_offset_ptr)
182
188
case SQL_C_BOOKMARK:
183
#if (ODBCVER >= 0x0300)
184
189
case SQL_C_VARBOOKMARK:
188
193
SC_set_error(stmt, STMT_PROGRAM_TYPE_OUT_OF_RANGE, "Bind column 0 is not of type SQL_C_BOOKMARK");
189
inolog("Bind column 0 is type %d not of type SQL_C_BOOKMARK", fCType);
194
mylog("Bind column 0 is type %d not of type SQL_C_BOOKMARK\n", fCType);
190
195
SC_log_error(func, "", stmt);
191
196
return SQL_ERROR;
194
opts->bookmark->buffer = rgbValue;
195
opts->bookmark->used = pcbValue;
196
opts->bookmark->buflen = cbValueMax;
197
opts->bookmark->returntype = fCType;
199
bookmark = ARD_AllocBookmark(opts);
200
bookmark->buffer = rgbValue;
201
bookmark->used = (Int4 *) pcbValue;
202
bookmark->buflen = cbValueMax;
203
bookmark->returntype = fCType;
199
205
return SQL_SUCCESS;
228
237
opts->bindings[icol].buffer = NULL;
229
238
opts->bindings[icol].used = NULL;
230
239
opts->bindings[icol].returntype = SQL_C_CHAR;
231
if (opts->bindings[icol].ttlbuf)
232
free(opts->bindings[icol].ttlbuf);
233
opts->bindings[icol].ttlbuf = NULL;
234
opts->bindings[icol].ttlbuflen = 0;
235
opts->bindings[icol].ttlbufused = 0;
236
240
opts->bindings[icol].precision = 0;
237
241
opts->bindings[icol].scale = 0;
242
if (gdata_info->gdata[icol].ttlbuf)
243
free(gdata_info->gdata[icol].ttlbuf);
244
gdata_info->gdata[icol].ttlbuf = NULL;
245
gdata_info->gdata[icol].ttlbuflen = 0;
246
gdata_info->gdata[icol].ttlbufused = 0;
241
250
/* ok, bind that column */
242
251
opts->bindings[icol].buflen = cbValueMax;
243
252
opts->bindings[icol].buffer = rgbValue;
244
opts->bindings[icol].used = pcbValue;
253
opts->bindings[icol].used = (Int4 *) pcbValue;
245
254
opts->bindings[icol].returntype = fCType;
246
#if (ODBCVER >= 0x0300)
247
256
if (SQL_C_NUMERIC == fCType)
248
257
opts->bindings[icol].precision = 32;
251
259
opts->bindings[icol].precision = 0;
252
260
opts->bindings[icol].scale = 0;
553
545
APD_free_params(APDFields *apdopts, char option)
557
547
mylog("APD_free_params: ENTER, self=%d\n", apdopts);
559
549
if (!apdopts->parameters)
562
for (i = 0; i < apdopts->allocated; i++)
564
if (apdopts->parameters[i].data_at_exec)
566
if (apdopts->parameters[i].EXEC_used)
568
free(apdopts->parameters[i].EXEC_used);
569
apdopts->parameters[i].EXEC_used = NULL;
571
if (apdopts->parameters[i].EXEC_buffer)
573
free(apdopts->parameters[i].EXEC_buffer);
574
apdopts->parameters[i].EXEC_buffer = NULL;
579
552
if (option == STMT_FREE_PARAMS_ALL)
581
if (apdopts->parameters)
582
free(apdopts->parameters);
554
free(apdopts->parameters);
583
555
apdopts->parameters = NULL;
584
556
apdopts->allocated = 0;
708
713
self->bindings = NULL;
709
714
self->allocated = 0;
717
void GDATA_unbind_cols(GetDataInfo *self, BOOL freeall)
721
mylog("GDATA_unbind_cols freeall=%d allocated=%d gdata=%x\n", freeall, self->allocated, self->gdata);
722
if (self->fdata.ttlbuf)
724
free(self->fdata.ttlbuf);
725
self->fdata.ttlbuf = NULL;
727
self->fdata.ttlbuflen = self->fdata.ttlbufused = 0;
728
self->fdata.data_left = -1;
729
for (lf = 1; lf <= self->allocated; lf++)
730
reset_a_getdata_info(self, lf);
740
void GetDataInfoInitialize(GetDataInfo *gdata_info)
742
gdata_info->fdata.data_left = -1;
743
gdata_info->fdata.ttlbuf = NULL;
744
gdata_info->fdata.ttlbuflen = gdata_info->fdata.ttlbufused = 0;
745
gdata_info->allocated = 0;
746
gdata_info->gdata = NULL;
748
static GetDataClass *
749
create_empty_gdata(int num_columns)
751
GetDataClass *new_gdata;
754
new_gdata = (GetDataClass *) malloc(num_columns * sizeof(GetDataClass));
758
for (i = 0; i < num_columns; i++)
760
new_gdata[i].data_left = -1;
761
new_gdata[i].ttlbuf = NULL;
762
new_gdata[i].ttlbuflen = 0;
763
new_gdata[i].ttlbufused = 0;
769
extend_getdata_info(GetDataInfo *self, int num_columns, BOOL shrink)
771
CSTR func = "extend_getdata_info";
772
GetDataClass *new_gdata;
775
mylog("%s: entering ... self=%u, gdata_allocated=%d, num_columns=%d\n", func, self, self->allocated, num_columns);
778
* if we have too few, allocate room for more, and copy the old
779
* entries into the new structure
781
if (self->allocated < num_columns)
783
new_gdata = create_empty_gdata(num_columns);
786
mylog("%s: unable to create %d new gdata from %d old gdata\n", func, num_columns, self->allocated);
798
for (i = 0; i < self->allocated; i++)
799
new_gdata[i] = self->gdata[i];
802
self->gdata = new_gdata;
803
self->allocated = num_columns;
805
else if (shrink && self->allocated > num_columns)
807
for (i = self->allocated; i > num_columns; i--)
808
reset_a_getdata_info(self, i);
809
self->allocated = num_columns;
810
if (0 == num_columns)
818
* There is no reason to zero out extra gdata if there are more
819
* than needed. If an app has allocated extra gdata, let it worry
820
* about it by unbinding those columns.
823
mylog("exit extend_gdata_info\n");
825
void reset_a_getdata_info(GetDataInfo *gdata_info, int icol)
827
if (icol < 1 || icol > gdata_info->allocated)
830
if (gdata_info->gdata[icol].ttlbuf)
832
free(gdata_info->gdata[icol].ttlbuf);
833
gdata_info->gdata[icol].ttlbuf = NULL;
835
gdata_info->gdata[icol].ttlbuflen =
836
gdata_info->gdata[icol].ttlbufused = 0;
837
gdata_info->gdata[icol].data_left = -1;
840
void PutDataInfoInitialize(PutDataInfo *pdata_info)
842
pdata_info->allocated = 0;
843
pdata_info->pdata = NULL;
846
extend_putdata_info(PutDataInfo *self, int num_params, BOOL shrink)
848
CSTR func = "extend_putdata_info";
849
PutDataClass *new_pdata;
851
mylog("%s: entering ... self=%u, parameters_allocated=%d, num_params=%d\n", func, self, self->allocated, num_params);
854
* if we have too few, allocate room for more, and copy the old
855
* entries into the new structure
857
if (self->allocated < num_params)
859
new_pdata = (PutDataClass *) realloc(self->pdata, sizeof(PutDataClass) * num_params);
862
mylog("%s: unable to create %d new pdata from %d old pdata\n", func, num_params, self->allocated);
868
memset(&new_pdata[self->allocated], 0,
869
sizeof(PutDataClass) * (num_params - self->allocated));
871
self->pdata = new_pdata;
872
self->allocated = num_params;
874
else if (shrink && self->allocated > num_params)
878
for (i = self->allocated; i > num_params; i--)
879
reset_a_putdata_info(self, i);
880
self->allocated = num_params;
888
mylog("exit extend_putdata_info\n");
890
void reset_a_putdata_info(PutDataInfo *pdata_info, int ipar)
892
if (ipar < 1 || ipar > pdata_info->allocated)
895
if (pdata_info->pdata[ipar].EXEC_used)
897
free(pdata_info->pdata[ipar].EXEC_used);
898
pdata_info->pdata[ipar].EXEC_used = NULL;
900
if (pdata_info->pdata[ipar].EXEC_buffer)
902
free(pdata_info->pdata[ipar].EXEC_buffer);
903
pdata_info->pdata[ipar].EXEC_buffer = NULL;
905
pdata_info->pdata[ipar].lobj_oid = 0;