[m-rev.] for review: <gcc4 fixes in extras/odbc>
Keri Harris
harriskeri at clear.net.nz
Wed Mar 29 21:05:45 AEDT 2006
Estimated hours taken: 2
extras/odbc/odbc.m
- multiline string literals that appear to be caused by a missing escape
sequence. (i.e. '\n' instead of '\\n').
- lvalue cast fix in odbc_do_get_data
- suppress warning about variable 'stat' shadowing global declaration.
--- mercury-extras-0.12.2.orig/odbc/odbc.m 2005-02-13 02:50:41.000000000 +1300
+++ mercury-extras-0.12.2/odbc/odbc.m 2006-03-29 21:41:48.000000000 +1200
@@ -1316,38 +1316,38 @@
Status::out, DB0::di, DB::uo),
may_call_mercury,
"{
- MODBC_Statement *stat;
+ MODBC_Statement *statement;
- stat = (MODBC_Statement *) Statement0;
+ statement = (MODBC_Statement *) Statement0;
- MR_assert(stat != NULL);
+ MR_assert(statement != NULL);
- if (stat->num_rows == 0 ) {
+ if (statement->num_rows == 0 ) {
MR_DEBUG(printf(""Fetching rows...\\n""));
}
/* Fetching new row */
- Status = SQLFetch(stat->stat_handle);
+ Status = SQLFetch(statement->stat_handle);
if (Status != SQL_NO_DATA_FOUND &&
! odbc_check(odbc_env_handle, odbc_connection,
- stat->stat_handle, Status))
+ statement->stat_handle, Status))
{
- odbc_do_cleanup_statement(stat);
+ odbc_do_cleanup_statement(statement);
odbc_throw();
/* not reached */
}
/* Update number of rows fetched */
if (Status == SQL_SUCCESS) {
- stat->num_rows++;
+ statement->num_rows++;
}
if (Status == SQL_NO_DATA_FOUND) {
- MR_DEBUG(printf(""Fetched %d rows\\n"", stat->num_rows));
+ MR_DEBUG(printf(""Fetched %d rows\\n"", statement->num_rows));
}
- Statement = (MR_Word) stat;
+ Statement = (MR_Word) statement;
DB = DB0;
}").
@@ -1362,13 +1362,13 @@
Statement::uo, DB0::di, DB::uo),
will_not_call_mercury,
"{
- MODBC_Statement * stat;
+ MODBC_Statement * statement;
- stat = (MODBC_Statement *) Statement0;
+ statement = (MODBC_Statement *) Statement0;
- MR_assert(stat != NULL);
+ MR_assert(statement != NULL);
- NumColumns = stat->num_columns;
+ NumColumns = statement->num_columns;
DB = DB0;
Statement = Statement0;
}").
@@ -1384,25 +1384,25 @@
may_call_mercury,
"{
- MODBC_Statement *stat;
+ MODBC_Statement *statement;
MODBC_Column *col;
SQLRETURN rc;
SDWORD column_info;
- stat = (MODBC_Statement *) Statement0;
+ statement = (MODBC_Statement *) Statement0;
- MR_assert(stat != NULL);
- MR_assert(stat->row != NULL);
+ MR_assert(statement != NULL);
+ MR_assert(statement->row != NULL);
- MR_DEBUG(printf(""Getting column %i\n"", (int) Column));
+ MR_DEBUG(printf(""Getting column %i\\n"", (int) Column));
- if (stat->binding_type == MODBC_GET_DATA) {
+ if (statement->binding_type == MODBC_GET_DATA) {
/* Slurp up the data for this column. */
- odbc_do_get_data(stat, Column);
+ odbc_do_get_data(statement, Column);
}
- col = &(stat->row[Column]);
+ col = &(statement->row[Column]);
if (col->value_info == SQL_NULL_DATA) {
Type = MODBC_NULL;
@@ -1430,7 +1430,7 @@
odbc_message_list =
MR_list_cons(overflow_message,
odbc_message_list);
- odbc_do_cleanup_statement(stat);
+ odbc_do_cleanup_statement(statement);
odbc_throw();
}
break;
@@ -1475,7 +1475,7 @@
break;
} /* end switch (Type) */
- Statement = (MR_Word) stat;
+ Statement = (MR_Word) statement;
DB = DB0;
} /* end odbc__get_data() */
@@ -1484,7 +1484,7 @@
:- pragma c_code("
void
-odbc_do_get_data(MODBC_Statement *stat, int column_id)
+odbc_do_get_data(MODBC_Statement *statement, int column_id)
{
MODBC_Column *column;
SQLRETURN rc;
@@ -1494,11 +1494,11 @@
** byte and nothing else.
*/
- column = &(stat->row[column_id]);
+ column = &(statement->row[column_id]);
if (column->attr_type == MODBC_VAR_STRING) {
/* Just get the length first time through. */
- rc = SQLGetData(stat->stat_handle, column_id,
+ rc = SQLGetData(statement->stat_handle, column_id,
column->conversion_type, dummy_buffer,
1, &(column->value_info));
@@ -1510,9 +1510,9 @@
if (rc != SQL_SUCCESS_WITH_INFO &&
! odbc_check(odbc_env_handle,
odbc_connection,
- stat->stat_handle, rc))
+ statement->stat_handle, rc))
{
- odbc_do_cleanup_statement(stat);
+ odbc_do_cleanup_statement(statement);
odbc_throw();
}
@@ -1535,7 +1535,7 @@
** length of the available data, rather than the
** total length of data available.
*/
- odbc_get_data_in_chunks(stat, column_id);
+ odbc_get_data_in_chunks(statement, column_id);
} else {
MR_Word data;
@@ -1543,42 +1543,42 @@
** column->value_info == length of data
*/
column->size = column->value_info + 1;
- MR_incr_hp_atomic(MR_LVALUE_CAST(MR_Word, column->data),
+ MR_incr_hp_atomic((*(MR_Word*)&(column->data)),
(column->size + sizeof(MR_Word)) / sizeof(MR_Word));
- odbc_get_data_in_one_go(stat, column_id);
+ odbc_get_data_in_one_go(statement, column_id);
}
} else {
/*
** It's a fixed length column, so we can
** get the lot in one go.
*/
- odbc_get_data_in_one_go(stat, column_id);
+ odbc_get_data_in_one_go(statement, column_id);
}
}
void
-odbc_get_data_in_one_go(MODBC_Statement *stat, int column_id)
+odbc_get_data_in_one_go(MODBC_Statement *statement, int column_id)
{
MODBC_Column *col;
SQLRETURN rc;
- MR_DEBUG(printf(""getting column %i in one go\n"", column_id));
+ MR_DEBUG(printf(""getting column %i in one go\\n"", column_id));
- col = &(stat->row[column_id]);
+ col = &(statement->row[column_id]);
- rc = SQLGetData(stat->stat_handle, column_id, col->conversion_type,
+ rc = SQLGetData(statement->stat_handle, column_id, col->conversion_type,
(SQLPOINTER) col->data, col->size, &(col->value_info));
if (! odbc_check(odbc_env_handle, odbc_connection,
- stat->stat_handle, rc))
+ statement->stat_handle, rc))
{
- odbc_do_cleanup_statement(stat);
+ odbc_do_cleanup_statement(statement);
odbc_throw();
}
}
void
-odbc_get_data_in_chunks(MODBC_Statement *stat, int column_id)
+odbc_get_data_in_chunks(MODBC_Statement *statement, int column_id)
{
MODBC_Column *col;
SQLRETURN rc;
@@ -1586,11 +1586,11 @@
MR_Word chunk_list;
String result;
- MR_DEBUG(printf(""getting column %i in chunks\n"", column_id));
+ MR_DEBUG(printf(""getting column %i in chunks\\n"", column_id));
chunk_list = MR_list_empty();
- col = &(stat->row[column_id]);
+ col = &(statement->row[column_id]);
rc = SQL_SUCCESS_WITH_INFO;
@@ -1601,7 +1601,7 @@
*/
while (rc == SQL_SUCCESS_WITH_INFO) {
- rc = SQLGetData(stat->stat_handle, column_id,
+ rc = SQLGetData(statement->stat_handle, column_id,
col->conversion_type, (SQLPOINTER) this_bit,
MODBC_CHUNK_SIZE - 1, &(col->value_info));
@@ -1611,9 +1611,9 @@
if (rc != SQL_SUCCESS_WITH_INFO &&
! odbc_check(odbc_env_handle, odbc_connection,
- stat->stat_handle, rc))
+ statement->stat_handle, rc))
{
- odbc_do_cleanup_statement(stat);
+ odbc_do_cleanup_statement(statement);
odbc_throw();
}
@@ -1655,12 +1655,12 @@
odbc__cleanup_statement_check_error(Statement::di, DB0::di, DB::uo),
may_call_mercury,
"{
- MODBC_Statement *stat;
+ MODBC_Statement *statement;
SQLRETURN rc;
- stat = (MODBC_Statement *) Statement;
+ statement = (MODBC_Statement *) Statement;
- rc = odbc_do_cleanup_statement(stat);
+ rc = odbc_do_cleanup_statement(statement);
if (! odbc_check(odbc_env_handle, odbc_connection,
SQL_NULL_HSTMT, rc))
{
@@ -1672,29 +1672,29 @@
:- pragma c_code("
static SQLRETURN
-odbc_do_cleanup_statement(MODBC_Statement *stat)
+odbc_do_cleanup_statement(MODBC_Statement *statement)
{
int i;
SQLRETURN rc;
- if (stat != NULL) {
+ if (statement != NULL) {
MR_DEBUG(printf(""cleaning up statement\\n""));
- if (stat->row != NULL) {
- for (i = 1; i <= stat->num_columns; i++) {
+ if (statement->row != NULL) {
+ for (i = 1; i <= statement->num_columns; i++) {
/*
** Variable length types are allocated directly
** onto the Mercury heap, so don't free them here.
*/
if (! is_variable_length_sql_type(
- stat->row[i].sql_type))
+ statement->row[i].sql_type))
{
- MR_GC_free(stat->row[i].data);
+ MR_GC_free(statement->row[i].data);
}
}
- MR_GC_free(stat->row);
+ MR_GC_free(statement->row);
}
- rc = SQLFreeStmt(stat->stat_handle, SQL_DROP);
- MR_GC_free(stat);
+ rc = SQLFreeStmt(statement->stat_handle, SQL_DROP);
+ MR_GC_free(statement);
return rc;
} else {
return SQL_SUCCESS;
Regards,
Keri.
--
Public Key:
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x756D6F67
Key fingerprint = 7319 FA7D D2DD AED9 DF17 460B 2486 B12A 756D 6F67
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20060329/aa8eb40a/attachment.sig>
More information about the reviews
mailing list