Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e666422

Browse files
author
Hiroshi Inoue
committed
1)Allow the access to indexes with up to 16 keys.
2)Fix some memory leaks. 3)Change some bogus error messages.
1 parent 5490195 commit e666422

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

src/interfaces/odbc/convert.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,16 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
273273
/* this is an array of eight integers */
274274
short *short_array = (short *) ( (char *) rgbValue + rgbValueOffset);
275275

276-
len = 16;
276+
len = 32;
277277
vp = value;
278278
nval = 0;
279-
for (i = 0; i < 8; i++)
279+
mylog("index=(");
280+
for (i = 0; i < 16; i++)
280281
{
281282
if (sscanf(vp, "%hd", &short_array[i]) != 1)
282283
break;
283284

285+
mylog(" %d", short_array[i]);
284286
nval++;
285287

286288
/* skip the current token */
@@ -290,8 +292,9 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
290292
if (*vp == '\0')
291293
break;
292294
}
295+
mylog(") nval = %d\n", nval);
293296

294-
for (i = nval; i < 8; i++)
297+
for (i = nval; i < 16; i++)
295298
{
296299
short_array[i] = 0;
297300
}

src/interfaces/odbc/info.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,7 +1761,7 @@ HSTMT hindx_stmt;
17611761
RETCODE result;
17621762
char *table_name;
17631763
char index_name[MAX_INFO_STRING];
1764-
short fields_vector[8];
1764+
short fields_vector[16];
17651765
char isunique[10], isclustered[10];
17661766
SDWORD index_name_len, fields_vector_len;
17671767
TupleNode *row;
@@ -1924,7 +1924,7 @@ mylog("%s: entering...stmt=%u\n", func, stmt);
19241924
}
19251925
/* bind the vector column */
19261926
result = SQLBindCol(hindx_stmt, 2, SQL_C_DEFAULT,
1927-
fields_vector, 16, &fields_vector_len);
1927+
fields_vector, 32, &fields_vector_len);
19281928
if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
19291929
stmt->errormsg = indx_stmt->errormsg; /* "Couldn't bind column in SQLStatistics."; */
19301930
stmt->errornumber = indx_stmt->errornumber;
@@ -2003,7 +2003,7 @@ mylog("%s: entering...stmt=%u\n", func, stmt);
20032003
(fUnique == SQL_INDEX_UNIQUE && atoi(isunique))) {
20042004
i = 0;
20052005
/* add a row in this table for each field in the index */
2006-
while(i < 8 && fields_vector[i] != 0) {
2006+
while(i < 16 && fields_vector[i] != 0) {
20072007

20082008
row = (TupleNode *)malloc(sizeof(TupleNode) +
20092009
(13 - 1) * sizeof(TupleField));

src/interfaces/odbc/qresult.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ QResultClass *res;
311311
QR_set_message(self, "Error closing cursor.");
312312
return FALSE;
313313
}
314+
QR_Destructor(res);
314315

315316
/* End the transaction if there are no cursors left on this conn */
316317
if (CC_cursor_count(self->conn) == 0) {
@@ -325,6 +326,7 @@ QResultClass *res;
325326
QR_set_message(self, "Error ending transaction.");
326327
return FALSE;
327328
}
329+
QR_Destructor(res);
328330
}
329331

330332
}

src/interfaces/odbc/results.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ int len = 0, value = 0;
405405

406406
if (icol >= cols) {
407407
stmt->errornumber = STMT_INVALID_COLUMN_NUMBER_ERROR;
408-
stmt->errormsg = "Invalid column number in DescribeCol.";
408+
stmt->errormsg = "Invalid column number in ColAttributes.";
409409
SC_log_error(func, "", stmt);
410410
return SQL_ERROR;
411411
}
@@ -442,7 +442,7 @@ int len = 0, value = 0;
442442

443443
if (icol >= cols) {
444444
stmt->errornumber = STMT_INVALID_COLUMN_NUMBER_ERROR;
445-
stmt->errormsg = "Invalid column number in DescribeCol.";
445+
stmt->errormsg = "Invalid column number in ColAttributes.";
446446
SC_log_error(func, "", stmt);
447447
return SQL_ERROR;
448448
}

src/interfaces/odbc/statement.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,8 @@ mylog("recycle statement: self= %u\n", self);
404404
conn = SC_get_conn(self);
405405
if ( ! CC_is_in_autocommit(conn) && CC_is_in_trans(conn)) {
406406

407-
CC_send_query(conn, "ABORT", NULL);
407+
QResultClass *res = CC_send_query(conn, "ABORT", NULL);
408+
QR_Destructor(res);
408409
CC_set_no_trans(conn);
409410
}
410411
break;

0 commit comments

Comments
 (0)