From 121af76de73450e9a93a497c528ee62401f7ceb5 Mon Sep 17 00:00:00 2001 From: alexpeshkoff Date: Wed, 10 Sep 2008 12:31:54 +0000 Subject: [PATCH] Made XSQLDA parameter const in isc_dsql_fetch and a family of isc_dsql_exec functions as suggested by Dmitry Kovalenko. Minor related cleanup in utld. --- src/dsql/utld.cpp | 36 +++++++++++++++--------------------- src/dsql/utld_proto.h | 2 +- src/include/fb_api_proto.h | 14 +++++++------- src/jrd/extds/IscDS.cpp | 12 ++++++------ src/jrd/extds/IscDS.h | 14 +++++++------- src/jrd/ibase.h | 14 +++++++------- src/jrd/why.cpp | 17 +++++++++-------- src/jrd/why_proto.h | 12 ++++++------ 8 files changed, 58 insertions(+), 63 deletions(-) diff --git a/src/dsql/utld.cpp b/src/dsql/utld.cpp index 039246056f..486006ef00 100644 --- a/src/dsql/utld.cpp +++ b/src/dsql/utld.cpp @@ -359,13 +359,14 @@ ISC_STATUS UTLD_parse_sqlda( USHORT* msg_type, USHORT* msg_length, USHORT dialect, - XSQLDA* xsqlda, + const XSQLDA* xsqlda, const USHORT clause) { USHORT n; - XSQLVAR *xvar, xsqlvar; - SQLDA* sqlda; - SQLVAR* qvar; + XSQLVAR xsqlvar; + const XSQLVAR* xvar = &xsqlvar; + const SQLVAR* qvar; + const SQLDA* sqlda = NULL; if (!xsqlda) n = 0; @@ -378,10 +379,9 @@ ISC_STATUS UTLD_parse_sqlda( } else { - sqlda = (SQLDA *) xsqlda; + sqlda = reinterpret_cast(xsqlda); n = sqlda->sqld; xsqlda = NULL; - xvar = &xsqlvar; } @@ -427,11 +427,9 @@ ISC_STATUS UTLD_parse_sqlda( for (i = 0; i < n; i++) { if (xsqlda) - xvar++; - else { - qvar++; - sqlvar_to_xsqlvar(qvar, xvar); - } + ++xvar; + else + sqlvar_to_xsqlvar(++qvar, &xsqlvar); const USHORT dtype = xvar->sqltype & ~1; switch (dtype) @@ -519,12 +517,10 @@ ISC_STATUS UTLD_parse_sqlda( for (i = 0; i < n; i++) { if (xsqlda) - xvar++; + ++xvar; else - { - qvar++; - sqlvar_to_xsqlvar(qvar, xvar); - } + sqlvar_to_xsqlvar(++qvar, &xsqlvar); + USHORT dtype = xvar->sqltype & ~1; USHORT len = xvar->sqllen; switch (dtype) @@ -655,12 +651,10 @@ ISC_STATUS UTLD_parse_sqlda( for (i = 0; i < n; i++) { if (xsqlda) - xvar++; + ++xvar; else - { - qvar++; - sqlvar_to_xsqlvar(qvar, xvar); - } + sqlvar_to_xsqlvar(++qvar, &xsqlvar); + USHORT dtype = xvar->sqltype & ~1; USHORT len = xvar->sqllen; switch (dtype) diff --git a/src/dsql/utld_proto.h b/src/dsql/utld_proto.h index 845cd6663c..7af20ea23c 100644 --- a/src/dsql/utld_proto.h +++ b/src/dsql/utld_proto.h @@ -37,7 +37,7 @@ USHORT UTLD_char_length_to_byte_length(USHORT lengthInChars, USHORT maxBytesPer ISC_STATUS UTLD_copy_status(const ISC_STATUS*, ISC_STATUS*); ISC_STATUS UTLD_parse_sql_info(ISC_STATUS*, USHORT, const SCHAR*, XSQLDA*, USHORT*); ISC_STATUS UTLD_parse_sqlda(ISC_STATUS*, sqlda_sup* const, USHORT*, USHORT*, - USHORT*, USHORT, XSQLDA*, const USHORT); + USHORT*, USHORT, const XSQLDA*, const USHORT); void UTLD_save_status_strings(ISC_STATUS*); SCHAR* UTLD_skip_sql_info(SCHAR*); diff --git a/src/include/fb_api_proto.h b/src/include/fb_api_proto.h index f8bb889819..80e38ae076 100644 --- a/src/include/fb_api_proto.h +++ b/src/include/fb_api_proto.h @@ -189,21 +189,21 @@ typedef ISC_STATUS ISC_EXPORT prototype_isc_dsql_exec_immed2(ISC_STATUS *, unsigned short, const char*, unsigned short, - XSQLDA *, - XSQLDA *); + const XSQLDA *, + const XSQLDA *); typedef ISC_STATUS ISC_EXPORT prototype_isc_dsql_execute(ISC_STATUS *, isc_tr_handle *, isc_stmt_handle *, unsigned short, - XSQLDA *); + const XSQLDA *); typedef ISC_STATUS ISC_EXPORT prototype_isc_dsql_execute2(ISC_STATUS *, isc_tr_handle *, isc_stmt_handle *, unsigned short, - XSQLDA *, - XSQLDA *); + const XSQLDA *, + const XSQLDA *); typedef ISC_STATUS ISC_EXPORT prototype_isc_dsql_execute_immediate(ISC_STATUS *, isc_db_handle *, @@ -211,12 +211,12 @@ typedef ISC_STATUS ISC_EXPORT prototype_isc_dsql_execute_immediate(ISC_STATUS *, unsigned short, const char*, unsigned short, - XSQLDA *); + const XSQLDA *); typedef ISC_STATUS ISC_EXPORT prototype_isc_dsql_fetch(ISC_STATUS *, isc_stmt_handle *, unsigned short, - XSQLDA *); + const XSQLDA *); typedef ISC_STATUS ISC_EXPORT prototype_isc_dsql_finish(isc_db_handle *); diff --git a/src/jrd/extds/IscDS.cpp b/src/jrd/extds/IscDS.cpp index e1efcec9b9..4e7a9bd4a3 100644 --- a/src/jrd/extds/IscDS.cpp +++ b/src/jrd/extds/IscDS.cpp @@ -925,15 +925,15 @@ ISC_STATUS ISC_EXPORT IscProvider::isc_dsql_exec_immed2(ISC_STATUS *user_status, unsigned short, const char*, unsigned short, - XSQLDA *, - XSQLDA *) + const XSQLDA *, + const XSQLDA *) { return notImplemented(user_status); } ISC_STATUS ISC_EXPORT IscProvider::isc_dsql_execute(ISC_STATUS *user_status, isc_tr_handle *tra_handle, isc_stmt_handle *stmt_handle, unsigned short dialect, - XSQLDA *sqlda) + const XSQLDA *sqlda) { if (!m_api.isc_dsql_execute) return notImplemented(user_status); @@ -943,7 +943,7 @@ ISC_STATUS ISC_EXPORT IscProvider::isc_dsql_execute(ISC_STATUS *user_status, ISC_STATUS ISC_EXPORT IscProvider::isc_dsql_execute2(ISC_STATUS *user_status, isc_tr_handle *tra_handle, isc_stmt_handle *stmt_handle, unsigned short dialect, - XSQLDA *in_sqlda, XSQLDA *out_sqlda) + const XSQLDA *in_sqlda, const XSQLDA *out_sqlda) { if (!m_api.isc_dsql_execute2) return notImplemented(user_status); @@ -958,13 +958,13 @@ ISC_STATUS ISC_EXPORT IscProvider::isc_dsql_execute_immediate(ISC_STATUS *user_s unsigned short, const char*, unsigned short, - XSQLDA *) + const XSQLDA *) { return notImplemented(user_status); } ISC_STATUS ISC_EXPORT IscProvider::isc_dsql_fetch(ISC_STATUS *user_status, - isc_stmt_handle *stmt_handle, unsigned short da_version, XSQLDA *sqlda) + isc_stmt_handle *stmt_handle, unsigned short da_version, const XSQLDA *sqlda) { if (!m_api.isc_dsql_fetch) return notImplemented(user_status); diff --git a/src/jrd/extds/IscDS.h b/src/jrd/extds/IscDS.h index 96de7ca371..9b4a43adb5 100644 --- a/src/jrd/extds/IscDS.h +++ b/src/jrd/extds/IscDS.h @@ -233,21 +233,21 @@ public: unsigned short, const char*, unsigned short, - XSQLDA *, - XSQLDA *); + const XSQLDA *, + const XSQLDA *); virtual ISC_STATUS ISC_EXPORT isc_dsql_execute(ISC_STATUS *, isc_tr_handle *, isc_stmt_handle *, unsigned short, - XSQLDA *); + const XSQLDA *); virtual ISC_STATUS ISC_EXPORT isc_dsql_execute2(ISC_STATUS *, isc_tr_handle *, isc_stmt_handle *, unsigned short, - XSQLDA *, - XSQLDA *); + const XSQLDA *, + const XSQLDA *); virtual ISC_STATUS ISC_EXPORT isc_dsql_execute_immediate(ISC_STATUS *, isc_db_handle *, @@ -255,12 +255,12 @@ public: unsigned short, const char*, unsigned short, - XSQLDA *); + const XSQLDA *); virtual ISC_STATUS ISC_EXPORT isc_dsql_fetch(ISC_STATUS *, isc_stmt_handle *, unsigned short, - XSQLDA *); + const XSQLDA *); virtual ISC_STATUS ISC_EXPORT isc_dsql_finish(isc_db_handle *); diff --git a/src/jrd/ibase.h b/src/jrd/ibase.h index 3962ffc941..7e3d303294 100644 --- a/src/jrd/ibase.h +++ b/src/jrd/ibase.h @@ -415,21 +415,21 @@ ISC_STATUS ISC_EXPORT isc_dsql_exec_immed2(ISC_STATUS*, unsigned short, const ISC_SCHAR*, unsigned short, - XSQLDA*, - XSQLDA*); + const XSQLDA*, + const XSQLDA*); ISC_STATUS ISC_EXPORT isc_dsql_execute(ISC_STATUS*, isc_tr_handle*, isc_stmt_handle*, unsigned short, - XSQLDA*); + const XSQLDA*); ISC_STATUS ISC_EXPORT isc_dsql_execute2(ISC_STATUS*, isc_tr_handle*, isc_stmt_handle*, unsigned short, - XSQLDA*, - XSQLDA*); + const XSQLDA*, + const XSQLDA*); ISC_STATUS ISC_EXPORT isc_dsql_execute_immediate(ISC_STATUS*, isc_db_handle*, @@ -437,12 +437,12 @@ ISC_STATUS ISC_EXPORT isc_dsql_execute_immediate(ISC_STATUS*, unsigned short, const ISC_SCHAR*, unsigned short, - XSQLDA*); + const XSQLDA*); ISC_STATUS ISC_EXPORT isc_dsql_fetch(ISC_STATUS *, isc_stmt_handle *, unsigned short, - XSQLDA *); + const XSQLDA *); ISC_STATUS ISC_EXPORT isc_dsql_finish(isc_db_handle *); diff --git a/src/jrd/why.cpp b/src/jrd/why.cpp index 8c9e0e5540..f3008e4c4e 100644 --- a/src/jrd/why.cpp +++ b/src/jrd/why.cpp @@ -2373,7 +2373,7 @@ ISC_STATUS API_ROUTINE GDS_DSQL_EXECUTE(ISC_STATUS* user_status, FB_API_HANDLE* tra_handle, FB_API_HANDLE* stmt_handle, USHORT dialect, - XSQLDA* sqlda) + const XSQLDA* sqlda) { /************************************** * @@ -2395,8 +2395,8 @@ ISC_STATUS API_ROUTINE GDS_DSQL_EXECUTE2(ISC_STATUS* user_status, FB_API_HANDLE* tra_handle, FB_API_HANDLE* stmt_handle, USHORT dialect, - XSQLDA* in_sqlda, - XSQLDA* out_sqlda) + const XSQLDA* in_sqlda, + const XSQLDA* out_sqlda) { /************************************** * @@ -2571,7 +2571,7 @@ ISC_STATUS API_ROUTINE GDS_DSQL_EXEC_IMMED(ISC_STATUS* user_status, USHORT length, const SCHAR* string, USHORT dialect, - XSQLDA* sqlda) + const XSQLDA* sqlda) { /************************************** * @@ -2594,7 +2594,8 @@ ISC_STATUS API_ROUTINE GDS_DSQL_EXECUTE_IMMED(ISC_STATUS* user_status, FB_API_HANDLE* tra_handle, USHORT length, const SCHAR* string, - USHORT dialect, XSQLDA* sqlda) + USHORT dialect, + const XSQLDA* sqlda) { /************************************** * @@ -2619,8 +2620,8 @@ ISC_STATUS API_ROUTINE GDS_DSQL_EXEC_IMMED2(ISC_STATUS* user_status, USHORT length, const SCHAR* string, USHORT dialect, - XSQLDA* in_sqlda, - XSQLDA* out_sqlda) + const XSQLDA* in_sqlda, + const XSQLDA* out_sqlda) { /************************************** * @@ -2943,7 +2944,7 @@ ISC_STATUS API_ROUTINE GDS_DSQL_EXEC_IMM3_M(ISC_STATUS* user_status, ISC_STATUS API_ROUTINE GDS_DSQL_FETCH(ISC_STATUS* user_status, FB_API_HANDLE* stmt_handle, USHORT dialect, - XSQLDA* sqlda) + const XSQLDA* sqlda) { /************************************** * diff --git a/src/jrd/why_proto.h b/src/jrd/why_proto.h index 578dfcdc76..40edcd4da4 100644 --- a/src/jrd/why_proto.h +++ b/src/jrd/why_proto.h @@ -36,11 +36,11 @@ ISC_STATUS API_ROUTINE isc_dsql_describe(ISC_STATUS *, FB_API_HANDLE*, USHORT, X ISC_STATUS API_ROUTINE isc_dsql_describe_bind(ISC_STATUS*, FB_API_HANDLE*, USHORT, XSQLDA*); ISC_STATUS API_ROUTINE isc_dsql_execute(ISC_STATUS*, FB_API_HANDLE*, FB_API_HANDLE*, - USHORT, XSQLDA*); + USHORT, const XSQLDA*); ISC_STATUS API_ROUTINE isc_dsql_execute_m(ISC_STATUS*, FB_API_HANDLE*, FB_API_HANDLE*, USHORT, const SCHAR*, USHORT, USHORT, SCHAR*); ISC_STATUS API_ROUTINE isc_dsql_execute2(ISC_STATUS*, FB_API_HANDLE*, FB_API_HANDLE*, USHORT, - XSQLDA*, XSQLDA*); + const XSQLDA*, const XSQLDA*); ISC_STATUS API_ROUTINE isc_dsql_execute2_m(ISC_STATUS*, FB_API_HANDLE*, FB_API_HANDLE*, USHORT, const SCHAR*, USHORT, USHORT, SCHAR*, USHORT, @@ -49,11 +49,11 @@ ISC_STATUS API_ROUTINE isc_dsql_execute2_m(ISC_STATUS*, FB_API_HANDLE*, ISC_STATUS API_ROUTINE isc_dsql_execute_immediate(ISC_STATUS*, FB_API_HANDLE*, FB_API_HANDLE*, USHORT, const SCHAR*, USHORT, - XSQLDA*); + const XSQLDA*); ISC_STATUS API_ROUTINE isc_dsql_exec_immed2(ISC_STATUS*, FB_API_HANDLE*, FB_API_HANDLE*, USHORT, - const SCHAR*, USHORT, XSQLDA*, - XSQLDA*); + const SCHAR*, USHORT, const XSQLDA*, + const XSQLDA*); ISC_STATUS API_ROUTINE isc_dsql_execute_immediate_m(ISC_STATUS*, FB_API_HANDLE*, FB_API_HANDLE*, USHORT, @@ -73,7 +73,7 @@ ISC_STATUS API_ROUTINE isc_dsql_exec_immed3_m(ISC_STATUS*, FB_API_HANDLE*, SCHAR*, USHORT, USHORT, const SCHAR*, USHORT, SCHAR*, USHORT, USHORT, SCHAR*); -ISC_STATUS API_ROUTINE isc_dsql_fetch(ISC_STATUS*, FB_API_HANDLE*, USHORT, XSQLDA*); +ISC_STATUS API_ROUTINE isc_dsql_fetch(ISC_STATUS*, FB_API_HANDLE*, USHORT, const XSQLDA*); #ifdef SCROLLABLE_CURSORS ISC_STATUS API_ROUTINE isc_dsql_fetch2(ISC_STATUS*, FB_API_HANDLE*, USHORT, XSQLDA*, USHORT, SLONG);