From c1f75dcdf81d86e116f35c84248aabaec07f658d Mon Sep 17 00:00:00 2001 From: dimitr Date: Sun, 24 Feb 2008 15:02:04 +0000 Subject: [PATCH] Ported SQLSTATE from Vulcan. Part II: handling of isc_arg_sql_state. --- src/common/StatusHolder.cpp | 4 +++- src/common/fb_exception.cpp | 3 +++ src/dsql/errd.cpp | 1 + src/dsql/user_dsql.cpp | 1 + src/dsql/utld.cpp | 3 ++- src/jrd/err.cpp | 1 + src/jrd/gds.cpp | 9 +++++++-- src/jrd/par.cpp | 2 ++ src/jrd/sdl.cpp | 1 + src/jrd/status.cpp | 2 ++ src/jrd/why.cpp | 2 ++ src/remote/protocol.cpp | 1 + src/remote/remote.cpp | 1 + src/remote/server.cpp | 1 + 14 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/common/StatusHolder.cpp b/src/common/StatusHolder.cpp index 951076e569..e33d3bdc52 100644 --- a/src/common/StatusHolder.cpp +++ b/src/common/StatusHolder.cpp @@ -61,7 +61,8 @@ ISC_STATUS StatusHolder::save(const ISC_STATUS* status) case isc_arg_string: case isc_arg_interpreted: - { + case isc_arg_sql_state: + { const char *temp = reinterpret_cast(*from++); const size_t len = strlen(temp); @@ -97,6 +98,7 @@ void StatusHolder::clear() case isc_arg_string: case isc_arg_interpreted: + case isc_arg_sql_state: delete[] reinterpret_cast(*ptr++); break; diff --git a/src/common/fb_exception.cpp b/src/common/fb_exception.cpp index 8570e5709d..51ae148edc 100644 --- a/src/common/fb_exception.cpp +++ b/src/common/fb_exception.cpp @@ -61,6 +61,7 @@ void fill_status(ISC_STATUS *ptr, ISC_STATUS status, va_list status_args) } case isc_arg_string: case isc_arg_interpreted: + case isc_arg_sql_state: { *ptr++ = dupStringTemp(reinterpret_cast(va_arg(status_args, ISC_STATUS))); break; @@ -98,6 +99,7 @@ void StringsBuffer::makePermanentVector(ISC_STATUS* perm, const ISC_STATUS* tran break; case isc_arg_string: case isc_arg_interpreted: + case isc_arg_sql_state: { const char* temp = reinterpret_cast(*trans++); *perm++ = (ISC_STATUS)(IPTR) (alloc(temp, strlen(temp))); @@ -169,6 +171,7 @@ void status_exception::release_vector() throw() break; case isc_arg_string: case isc_arg_interpreted: + case isc_arg_sql_state: delete[] reinterpret_cast(*ptr++); break; default: diff --git a/src/dsql/errd.cpp b/src/dsql/errd.cpp index 512546e9f6..5cb45b090d 100644 --- a/src/dsql/errd.cpp +++ b/src/dsql/errd.cpp @@ -218,6 +218,7 @@ bool ERRD_post_warning(ISC_STATUS status, ...) break; case isc_arg_interpreted: + case isc_arg_sql_state: pszTmp = va_arg(args, char*); status_vector[indx++] = reinterpret_cast(ERR_cstring(pszTmp)); break; diff --git a/src/dsql/user_dsql.cpp b/src/dsql/user_dsql.cpp index b13cb5595f..bc5c087ada 100644 --- a/src/dsql/user_dsql.cpp +++ b/src/dsql/user_dsql.cpp @@ -1281,6 +1281,7 @@ static void error_post(ISC_STATUS status, ...) case isc_arg_string: case isc_arg_interpreted: + case isc_arg_sql_state: *p++ = (ISC_STATUS)(IPTR) va_arg(args, TEXT *); break; diff --git a/src/dsql/utld.cpp b/src/dsql/utld.cpp index 7e657cdc41..57081f9c1e 100644 --- a/src/dsql/utld.cpp +++ b/src/dsql/utld.cpp @@ -808,8 +808,9 @@ void UTLD_save_status_strings(ISC_STATUS* vector) case isc_arg_cstring: l = static_cast(*vector++); - case isc_arg_interpreted: case isc_arg_string: + case isc_arg_interpreted: + case isc_arg_sql_state: p = (TEXT *) * vector; if (status != isc_arg_cstring) diff --git a/src/jrd/err.cpp b/src/jrd/err.cpp index 83a9365fea..0dac5c897c 100644 --- a/src/jrd/err.cpp +++ b/src/jrd/err.cpp @@ -361,6 +361,7 @@ bool ERR_post_warning(ISC_STATUS status, ...) break; case isc_arg_interpreted: + case isc_arg_sql_state: status_vector[indx++] = va_arg(args, ISC_STATUS); break; diff --git a/src/jrd/gds.cpp b/src/jrd/gds.cpp index 0518d4f86a..9d11f279dd 100644 --- a/src/jrd/gds.cpp +++ b/src/jrd/gds.cpp @@ -902,9 +902,14 @@ static SLONG safe_interpret(char* const s, const size_t bufsize, } break; + case isc_arg_sql_state: + q = (const TEXT*) (*vector)[1]; + sprintf(s, "SQLSTATE (%s)", q); + break; + case isc_arg_unix: - // The strerror() function returns the appropriate description - // string, or an unknown error message if the error code is unknown. + // The strerror() function returns the appropriate description string, + // or an unknown error message if the error code is unknown. q = (const TEXT*) strerror(code); if (legacy) safe_strncpy(s, q, bufsize); diff --git a/src/jrd/par.cpp b/src/jrd/par.cpp index 80549d1e77..947f60d691 100644 --- a/src/jrd/par.cpp +++ b/src/jrd/par.cpp @@ -808,6 +808,7 @@ static void error(CompilerScratch* csb, ...) case isc_arg_string: case isc_arg_interpreted: + case isc_arg_sql_state: *p++ = (ISC_STATUS) va_arg(args, TEXT *); break; @@ -3393,6 +3394,7 @@ static void warning(CompilerScratch* csb, ...) case isc_arg_string: case isc_arg_interpreted: + case isc_arg_sql_state: *p++ = (ISC_STATUS) va_arg(args, TEXT *); break; diff --git a/src/jrd/sdl.cpp b/src/jrd/sdl.cpp index 73b92f55a0..e2e8afdce3 100644 --- a/src/jrd/sdl.cpp +++ b/src/jrd/sdl.cpp @@ -599,6 +599,7 @@ static ISC_STATUS error(ISC_STATUS * status_vector, ...) case isc_arg_string: case isc_arg_interpreted: + case isc_arg_sql_state: *p++ = (ISC_STATUS) va_arg(args, TEXT *); break; diff --git a/src/jrd/status.cpp b/src/jrd/status.cpp index 0f809d24bf..5c4d23cacd 100644 --- a/src/jrd/status.cpp +++ b/src/jrd/status.cpp @@ -77,6 +77,7 @@ void STUFF_STATUS_function(ISC_STATUS* status_vector, ISC_STATUS status, va_list break; case isc_arg_interpreted: + case isc_arg_sql_state: *p++ = (ISC_STATUS) va_arg(args, TEXT *); break; @@ -126,6 +127,7 @@ void PARSE_STATUS(const ISC_STATUS* status_vector, int &length, int &warning) case isc_arg_string: case isc_arg_number: case isc_arg_interpreted: + case isc_arg_sql_state: case isc_arg_vms: case isc_arg_unix: case isc_arg_win32: diff --git a/src/jrd/why.cpp b/src/jrd/why.cpp index 96f39473ee..99d1246bc6 100644 --- a/src/jrd/why.cpp +++ b/src/jrd/why.cpp @@ -5236,6 +5236,7 @@ static void check_status_vector(const ISC_STATUS* status) case isc_arg_interpreted: case isc_arg_string: + case isc_arg_sql_state: length = strlen((const char*) *s); /* This check is heuristic, not deterministic */ if (length > 1024 - 1) @@ -5844,6 +5845,7 @@ static void save_error_string(ISC_STATUS * status) case isc_arg_interpreted: case isc_arg_string: + case isc_arg_sql_state: l = (ULONG) strlen(reinterpret_cast(*status)) + 1; if (l < len) { diff --git a/src/remote/protocol.cpp b/src/remote/protocol.cpp index 1ad57d38da..a5df27d425 100644 --- a/src/remote/protocol.cpp +++ b/src/remote/protocol.cpp @@ -1679,6 +1679,7 @@ static bool_t xdr_status_vector( case isc_arg_interpreted: case isc_arg_string: + case isc_arg_sql_state: if (xdrs->x_op == XDR_ENCODE) { if (!xdr_wrapstring(xdrs, reinterpret_cast(vector++))) return FALSE; diff --git a/src/remote/remote.cpp b/src/remote/remote.cpp index 3e5967261e..7dabd0860c 100644 --- a/src/remote/remote.cpp +++ b/src/remote/remote.cpp @@ -679,6 +679,7 @@ void REMOTE_save_status_strings( ISC_STATUS* vector) case isc_arg_interpreted: case isc_arg_string: + case isc_arg_sql_state: p = (TEXT*) *vector; if (status != isc_arg_cstring) l = strlen(p) + 1; diff --git a/src/remote/server.cpp b/src/remote/server.cpp index 3bdd397c52..dc4f011c5b 100644 --- a/src/remote/server.cpp +++ b/src/remote/server.cpp @@ -4721,6 +4721,7 @@ ISC_STATUS rem_port::send_response( PACKET* sendL, continue; case isc_arg_interpreted: + case isc_arg_sql_state: *v++ = *status_vector++; *v++ = *status_vector++; continue;