diff --git a/src/common/StatusArg.cpp b/src/common/StatusArg.cpp index ef35bc0ed1..0b8fbd13c8 100644 --- a/src/common/StatusArg.cpp +++ b/src/common/StatusArg.cpp @@ -143,6 +143,20 @@ void StatusVector::raise() const Str("Attempt to raise empty exception")); } +ISC_STATUS StatusVector::copyTo(ISC_STATUS* dest) const throw() +{ + if (hasData()) + { + memcpy(dest, value(), (length() + 1) * sizeof(ISC_STATUS)); + } + else { + dest[0] = isc_arg_gds; + dest[1] = FB_SUCCESS; + dest[2] = isc_arg_end; + } + return dest[1]; +} + Gds::Gds(ISC_STATUS s) throw() : StatusVector(isc_arg_gds, s) { } diff --git a/src/common/StatusArg.h b/src/common/StatusArg.h index e7d812416a..675fd373a4 100644 --- a/src/common/StatusArg.h +++ b/src/common/StatusArg.h @@ -73,6 +73,7 @@ public: void clear() throw(); void append(const StatusVector& v) throw(); void raise() const; + ISC_STATUS copyTo(ISC_STATUS* dest) const throw(); // generic argument insert StatusVector& operator<<(const Base& arg) throw(); diff --git a/src/dsql/array.epp b/src/dsql/array.epp index 1463418ccb..5e0413fd20 100644 --- a/src/dsql/array.epp +++ b/src/dsql/array.epp @@ -40,6 +40,9 @@ #include "../dsql/array_proto.h" #include "../dsql/utld_proto.h" #include "../jrd/gds_proto.h" +#include "../common/StatusArg.h" + +using namespace Firebird; DATABASE DB = STATIC FILENAME "yachts.lnk"; @@ -57,7 +60,7 @@ typedef gen_t *GEN_T; static void adjust_length(ISC_ARRAY_DESC*); static void copy_exact_name (const char*, char*, SSHORT); -static ISC_STATUS error(ISC_STATUS*, SSHORT, ...); +static ISC_STATUS error(ISC_STATUS* status, const Arg::StatusVector& v); static ISC_STATUS gen_sdl(ISC_STATUS*, const ISC_ARRAY_DESC*, SSHORT*, UCHAR**, SSHORT*, bool); static ISC_STATUS lookup_desc(ISC_STATUS*, FB_API_HANDLE*, FB_API_HANDLE*, const SCHAR*, @@ -317,14 +320,11 @@ ISC_STATUS API_ROUTINE isc_array_set_desc(ISC_STATUS* status, desc->array_desc_dtype = blr_quad; break; default: - return error(status, 7, (ISC_STATUS) isc_sqlerr, - (ISC_STATUS) isc_arg_number, (ISC_STATUS) - 804, - (ISC_STATUS) isc_arg_gds, (ISC_STATUS) isc_random, - (ISC_STATUS) isc_arg_string, - (ISC_STATUS) "data type not understood"); + return error(status, Arg::Gds(isc_sqlerr) << Arg::Num(-804) << + Arg::Gds(isc_random) << Arg::Str("data type not understood")); } - return error(status, 1, (ISC_STATUS) FB_SUCCESS); + return error(status, Arg::Gds(FB_SUCCESS)); } @@ -370,7 +370,7 @@ static void copy_exact_name ( } -static ISC_STATUS error( ISC_STATUS* status, SSHORT count, ...) +static ISC_STATUS error(ISC_STATUS* status, const Arg::StatusVector& v) { /************************************** * @@ -382,20 +382,7 @@ static ISC_STATUS error( ISC_STATUS* status, SSHORT count, ...) * Stuff a status vector. * **************************************/ - ISC_STATUS* stat; - va_list ptr; - - va_start(ptr, count); - stat = status; - *stat++ = isc_arg_gds; - - for (; count; --count) - *stat++ = (ISC_STATUS) va_arg(ptr, ISC_STATUS); - - va_end(ptr); - *stat = isc_arg_end; - - return status[1]; + return v.copyTo(status); } @@ -418,9 +405,7 @@ static ISC_STATUS gen_sdl(ISC_STATUS* status, const SSHORT dimensions = desc->array_desc_dimensions; if (dimensions > 16) - return error(status, 5, (ISC_STATUS) isc_invalid_dimension, - (ISC_STATUS) isc_arg_number, (ISC_STATUS) dimensions, - (ISC_STATUS) isc_arg_number, (ISC_STATUS) 16); + return error(status, Arg::Gds(isc_invalid_dimension) << Arg::Num(dimensions) << Arg::Num(16)); gen_t gen_block; gen_t* gen = &gen_block; @@ -501,7 +486,7 @@ static ISC_STATUS gen_sdl(ISC_STATUS* status, return status[1]; *sdl_length = gen->gen_sdl - *gen->gen_sdl_ptr; - return error(status, 1, (ISC_STATUS) FB_SUCCESS); + return error(status, Arg::Gds(FB_SUCCESS)); } @@ -561,13 +546,10 @@ static ISC_STATUS lookup_desc(ISC_STATUS* status, isc_release_request(isc_status, &handle); if (!flag) - return error(status, 5, (ISC_STATUS) isc_fldnotdef, - (ISC_STATUS) isc_arg_string, - (ISC_STATUS) desc->array_desc_field_name, - (ISC_STATUS) isc_arg_string, - (ISC_STATUS) desc->array_desc_relation_name); + return error(status, Arg::Gds(isc_fldnotdef) << Arg::Str(desc->array_desc_field_name) << + Arg::Str(desc->array_desc_relation_name)); - return error(status, 1, (ISC_STATUS) FB_SUCCESS); + return error(status, Arg::Gds(FB_SUCCESS)); } @@ -588,9 +570,7 @@ static ISC_STATUS stuff_args(gen_t* gen, SSHORT count, ...) if (gen->gen_sdl + count >= gen->gen_end) { if (gen->gen_internal < 0) { - return error(gen->gen_status, 3, (ISC_STATUS) isc_misc_interpreted, - (ISC_STATUS) isc_arg_string, - (ISC_STATUS) "SDL buffer overflow"); + return error(gen->gen_status, Arg::Gds(isc_misc_interpreted) << Arg::Str("SDL buffer overflow")); } // The sdl buffer is too small. Allocate a larger one. @@ -598,10 +578,8 @@ static ISC_STATUS stuff_args(gen_t* gen, SSHORT count, ...) const SSHORT new_len = gen->gen_end - *gen->gen_sdl_ptr + 512 + count; UCHAR* const new_sdl = (UCHAR*) gds__alloc(new_len); if (!new_sdl) { - return error(gen->gen_status, 5, (ISC_STATUS) isc_misc_interpreted, - (ISC_STATUS) isc_arg_string, - (ISC_STATUS) "SDL buffer overflow", (ISC_STATUS) isc_arg_gds, - (ISC_STATUS) isc_virmemexh); + return error(gen->gen_status, Arg::Gds(isc_misc_interpreted) << Arg::Str("SDL buffer overflow") << + Arg::Gds(isc_virmemexh)); } const SSHORT current_len = gen->gen_sdl - *gen->gen_sdl_ptr; diff --git a/src/dsql/blob.epp b/src/dsql/blob.epp index 552967cd55..ec77bfdd74 100644 --- a/src/dsql/blob.epp +++ b/src/dsql/blob.epp @@ -36,11 +36,14 @@ #include "../jrd/intl.h" #include "../dsql/blob_proto.h" #include "../dsql/utld_proto.h" +#include "../common/StatusArg.h" + +using namespace Firebird; DATABASE DB = STATIC "yachts.lnk"; static void copy_exact_name (const UCHAR*, UCHAR*, SSHORT); -static ISC_STATUS error(ISC_STATUS*, SSHORT, ...); +static ISC_STATUS error(ISC_STATUS* status, const Arg::StatusVector& v); void API_ROUTINE isc_blob_default_desc( @@ -95,9 +98,7 @@ ISC_STATUS API_ROUTINE isc_blob_gen_bpb( * **************************************/ if (bpb_buffer_length < 17) - return error(status, 3, (ISC_STATUS) isc_random, - (ISC_STATUS) isc_arg_string, - (ISC_STATUS) "BPB buffer too small"); + return error(status, Arg::Gds(isc_random) << Arg::Str("BPB buffer too small")); UCHAR* p = bpb_buffer; *p++ = isc_bpb_version1; @@ -120,7 +121,7 @@ ISC_STATUS API_ROUTINE isc_blob_gen_bpb( *bpb_length = p - bpb_buffer; - return error(status, 1, (ISC_STATUS) FB_SUCCESS); + return error(status, Arg::Gds(FB_SUCCESS)); } @@ -211,13 +212,10 @@ ISC_STATUS API_ROUTINE isc_blob_lookup_desc(ISC_STATUS* status, } if (!flag) - return error(status, 5, (ISC_STATUS) isc_fldnotdef, - (ISC_STATUS) isc_arg_string, - (ISC_STATUS) desc->blob_desc_field_name, - (ISC_STATUS) isc_arg_string, - (ISC_STATUS) desc->blob_desc_relation_name); + return error(status, Arg::Gds(isc_fldnotdef) << Arg::Str((const char *)(desc->blob_desc_field_name)) << + Arg::Str((const char *)(desc->blob_desc_relation_name))); - return error(status, 1, (ISC_STATUS) FB_SUCCESS); + return error(status, Arg::Gds(FB_SUCCESS)); } @@ -253,7 +251,7 @@ ISC_STATUS API_ROUTINE isc_blob_set_desc(ISC_STATUS* status, desc->blob_desc_charset = charset; desc->blob_desc_segment_size = segment_size; - return error(status, 1, (ISC_STATUS) FB_SUCCESS); + return error(status, Arg::Gds(FB_SUCCESS)); } @@ -287,7 +285,7 @@ static void copy_exact_name ( } -static ISC_STATUS error( ISC_STATUS* status, SSHORT count, ...) +static ISC_STATUS error(ISC_STATUS* status, const Arg::StatusVector& v) { /************************************** * @@ -299,19 +297,6 @@ static ISC_STATUS error( ISC_STATUS* status, SSHORT count, ...) * Stuff a status vector. * **************************************/ - ISC_STATUS *stat; - va_list ptr; - - va_start(ptr, count); - stat = status; - *stat++ = isc_arg_gds; - - for (; count; --count) - *stat++ = (ISC_STATUS) va_arg(ptr, ISC_STATUS); - - va_end(ptr); - *stat = isc_arg_end; - - return status[1]; + return v.copyTo(status); } diff --git a/src/dsql/ddl.cpp b/src/dsql/ddl.cpp index 9640a5547d..57ec9cfa8b 100644 --- a/src/dsql/ddl.cpp +++ b/src/dsql/ddl.cpp @@ -96,6 +96,7 @@ #include "../jrd/why_proto.h" #include "../common/utils_proto.h" #include "../dsql/DdlNodes.h" +#include "../common/StatusArg.h" #ifdef DSQL_DEBUG #include "../gpre/prett_proto.h" @@ -103,6 +104,7 @@ using namespace Jrd; using namespace Dsql; +using namespace Firebird; const int BLOB_BUFFER_SIZE = 4096; // to read in blr blob for default values @@ -273,7 +275,7 @@ void CompiledStatement::append_raw_string(const UCHAR* string, USHORT len) // // Write out a string valued attribute. (Overload 2.) // -inline void CompiledStatement::append_string(UCHAR verb, const Firebird::MetaName& name) +inline void CompiledStatement::append_string(UCHAR verb, const MetaName& name) { append_string(verb, name.c_str(), name.length()); } @@ -282,7 +284,7 @@ inline void CompiledStatement::append_string(UCHAR verb, const Firebird::MetaNam // // Write out a string valued attribute. (Overload 3.) // -inline void CompiledStatement::append_string(UCHAR verb, const Firebird::string& name) +inline void CompiledStatement::append_string(UCHAR verb, const string& name) { append_string(verb, name.c_str(), name.length()); } @@ -416,7 +418,7 @@ void DDL_generate(CompiledStatement* statement, dsql_nod* node) **************************************/ if (statement->req_dbb->dbb_read_only) { - ERRD_post(isc_read_only_database, isc_arg_end); + ERRD_post(Arg::Gds(isc_read_only_database)); return; } @@ -522,12 +524,9 @@ void DDL_resolve_intl_type2(CompiledStatement* statement, { if (ENCODE_ODS(statement->req_dbb->dbb_ods_version, statement->req_dbb->dbb_minor_version) < ODS_11_1) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -804, - isc_arg_gds, isc_dsql_feature_not_supported_ods, - isc_arg_number, 11, - isc_arg_number, 1, + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-804) << // Feature not supported on ODS version older than %d.%d - isc_arg_end); + Arg::Gds(isc_dsql_feature_not_supported_ods) << Arg::Num(11) << Arg::Num(1)); } if (field->fld_type_of_table) @@ -537,7 +536,7 @@ void DDL_resolve_intl_type2(CompiledStatement* statement, if (relation) { - const Firebird::MetaName fieldName(field->fld_type_of_name); + const MetaName fieldName(field->fld_type_of_name); for (fld = relation->rel_fields; fld; fld = fld->fld_next) { if (fieldName == fld->fld_name) @@ -560,25 +559,19 @@ void DDL_resolve_intl_type2(CompiledStatement* statement, if (!fld) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_dyn_column_does_not_exist, - isc_arg_string, field->fld_type_of_name.c_str(), - isc_arg_string, field->fld_type_of_table->str_data, + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << Arg::Gds(isc_dsql_command_err) << // column @1 does not exist in table/view @2 - isc_arg_end); + Arg::Gds(isc_dyn_column_does_not_exist) << + Arg::Str(field->fld_type_of_name) << Arg::Str(field->fld_type_of_table->str_data)); } } else { if (!METD_get_domain(statement, field, field->fld_type_of_name.c_str())) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_dsql_domain_not_found, - isc_arg_string, field->fld_type_of_name.c_str(), + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << Arg::Gds(isc_dsql_command_err) << // Specified domain or source field does not exist - isc_arg_end); + Arg::Gds(isc_dsql_domain_not_found) << Arg::Str(field->fld_type_of_name)); } } } @@ -588,9 +581,8 @@ void DDL_resolve_intl_type2(CompiledStatement* statement, if (field->fld_character_set || collation_name || field->fld_flags & FLD_national) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -204, - isc_arg_gds, isc_dsql_datatype_err, - isc_arg_gds, isc_collation_requires_text, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << + Arg::Gds(isc_dsql_datatype_err) << Arg::Gds(isc_collation_requires_text)); } return; } @@ -605,18 +597,16 @@ void DDL_resolve_intl_type2(CompiledStatement* statement, "RDB$FIELD_SUB_TYPE", &blob_sub_type)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -204, isc_arg_gds, - isc_dsql_datatype_err, isc_arg_gds, - isc_dsql_blob_type_unknown, isc_arg_string, - ((dsql_str*) field->fld_sub_type_name)->str_data, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << + Arg::Gds(isc_dsql_datatype_err) << + Arg::Gds(isc_dsql_blob_type_unknown) << Arg::Str(((dsql_str*)field->fld_sub_type_name)->str_data)); } field->fld_sub_type = blob_sub_type; } if (field->fld_sub_type > isc_blob_text) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -204, isc_arg_gds, - isc_dsql_datatype_err, isc_arg_gds, - isc_subtype_for_internal_use, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << Arg::Gds(isc_dsql_datatype_err) << + Arg::Gds(isc_subtype_for_internal_use)); } if (field->fld_character_set && (field->fld_sub_type == isc_blob_untyped)) { @@ -624,15 +614,13 @@ void DDL_resolve_intl_type2(CompiledStatement* statement, } if (field->fld_character_set && (field->fld_sub_type != isc_blob_text)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -204, isc_arg_gds, - isc_dsql_datatype_err, isc_arg_gds, - isc_collation_requires_text, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << Arg::Gds(isc_dsql_datatype_err) << + Arg::Gds(isc_collation_requires_text)); } if (collation_name && (field->fld_sub_type != isc_blob_text)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -204, isc_arg_gds, - isc_dsql_datatype_err, isc_arg_gds, - isc_collation_requires_text, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << Arg::Gds(isc_dsql_datatype_err) << + Arg::Gds(isc_collation_requires_text)); } if (field->fld_sub_type != isc_blob_text) { return; @@ -728,10 +716,8 @@ void DDL_resolve_intl_type2(CompiledStatement* statement, if (!resolved_charset) { // specified character set not found - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -204, - isc_arg_gds, isc_dsql_datatype_err, - isc_arg_gds, isc_charset_not_found, isc_arg_string, - charset_name, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << Arg::Gds(isc_dsql_datatype_err) << + Arg::Gds(isc_charset_not_found) << Arg::Str(charset_name)); } field->fld_character_set_id = resolved_charset->intlsym_charset_id; resolved_type = resolved_charset; @@ -744,7 +730,7 @@ void DDL_resolve_intl_type2(CompiledStatement* statement, if (!resolved_collation) { - Firebird::MetaName charSetName; + MetaName charSetName; if (charset_name) charSetName = charset_name; @@ -752,11 +738,8 @@ void DDL_resolve_intl_type2(CompiledStatement* statement, charSetName = METD_get_charset_name(statement, field->fld_character_set_id); // Specified collation not found - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -204, - isc_arg_gds, isc_dsql_datatype_err, - isc_arg_gds, isc_collation_not_found, - isc_arg_string, collation_name->str_data, - isc_arg_string, charSetName.c_str(), isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << Arg::Gds(isc_dsql_datatype_err) << + Arg::Gds(isc_collation_not_found) << Arg::Str(collation_name->str_data) << Arg::Str(charSetName)); } // If both specified, must be for same character set @@ -766,10 +749,8 @@ void DDL_resolve_intl_type2(CompiledStatement* statement, if ((field->fld_character_set_id != resolved_type->intlsym_charset_id) && (field->fld_character_set_id != ttype_dynamic)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -204, isc_arg_gds, - isc_dsql_datatype_err, isc_arg_gds, - isc_collation_not_for_charset, isc_arg_string, - collation_name->str_data, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << Arg::Gds(isc_dsql_datatype_err) << + Arg::Gds(isc_collation_not_for_charset) << Arg::Str(collation_name->str_data)); } field->fld_explicit_collation = true; @@ -814,11 +795,9 @@ static void assign_field_length ( } if (field_length > MAX_COLUMN_SIZE) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -204, - isc_arg_gds, isc_dsql_datatype_err, - isc_arg_gds, isc_imp_exc, - isc_arg_gds, isc_field_name, isc_arg_string, - field->fld_name.c_str(), isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << Arg::Gds(isc_dsql_datatype_err) << + Arg::Gds(isc_imp_exc) << + Arg::Gds(isc_field_name) << Arg::Str(field->fld_name)); } field->fld_length = (USHORT) field_length; } @@ -918,7 +897,7 @@ static bool is_array_or_blob(CompiledStatement* statement, const dsql_nod* node) { const dsql_str* name = (dsql_str*) node->nod_arg[e_sysfunc_name]; dsql_nod* nodeArgs = node->nod_arg[e_sysfunc_args]; - Firebird::Array args; + Array args; if (nodeArgs) { @@ -1047,10 +1026,8 @@ static void check_one_call (USHORT* repetition_count, **************************************/ if (++repetition_count[pos] > 1) { - ERRD_post (isc_sqlerr, isc_arg_number, (SLONG) -637, - isc_arg_gds, isc_dsql_duplicate_spec, - isc_arg_string, error_msg, - isc_arg_end); + ERRD_post (Arg::Gds(isc_sqlerr) << Arg::Num(-637) << + Arg::Gds(isc_dsql_duplicate_spec) << Arg::Str(error_msg)); } } @@ -1164,8 +1141,7 @@ static void define_computed(CompiledStatement* statement, if (is_array_or_blob(statement, input)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_no_array_computed, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << Arg::Gds(isc_dsql_no_array_computed)); } // try to calculate size of the computed field. The calculated size @@ -1726,8 +1702,7 @@ static void define_dimensions( CompiledStatement* statement, const dsql_fld* fie if (dims > MAX_ARRAY_DIMENSIONS) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -604, - isc_arg_gds, isc_dsql_max_arr_dim_exceeded, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-604) << Arg::Gds(isc_dsql_max_arr_dim_exceeded)); } statement->append_number(isc_dyn_fld_dimensions, (SSHORT) dims); @@ -1749,8 +1724,7 @@ static void define_dimensions( CompiledStatement* statement, const dsql_fld* fie statement->append_uchar(isc_dyn_end); if (lrange >= hrange) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -604, - isc_arg_gds, isc_dsql_arr_range_error, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-604) << Arg::Gds(isc_dsql_arr_range_error)); } } } @@ -1774,9 +1748,8 @@ static void define_domain(CompiledStatement* statement) if (fb_utils::implicit_domain(field->fld_name.c_str())) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -637, - isc_arg_gds, isc_dsql_implicit_domain_name, - isc_arg_string, field->fld_name.c_str(), isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-637) << + Arg::Gds(isc_dsql_implicit_domain_name) << Arg::Str(field->fld_name)); } statement->append_string(isc_dyn_def_global_fld, field->fld_name); @@ -1821,19 +1794,16 @@ static void define_domain(CompiledStatement* statement) } else { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -637, - isc_arg_gds, isc_dsql_duplicate_spec, - isc_arg_string, "NOT NULL", isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-637) << + Arg::Gds(isc_dsql_duplicate_spec) << Arg::Str("NOT NULL")); } } else if (node1->nod_type == nod_def_constraint) { if (check_flag) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -637, - isc_arg_gds, isc_dsql_duplicate_spec, - isc_arg_string, "DOMAIN CHECK CONSTRAINT", - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-637) << + Arg::Gds(isc_dsql_duplicate_spec) << Arg::Str("DOMAIN CHECK CONSTRAINT")); } check_flag = true; @@ -1971,12 +1941,10 @@ static void define_field(CompiledStatement* statement, if (!METD_get_domain(statement, field, domain_name->str_data)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_dsql_domain_not_found, - isc_arg_string, domain_name->str_data, + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_command_err) << // Specified domain or source field does not exist - isc_arg_end); + Arg::Gds(isc_dsql_domain_not_found) << Arg::Str(domain_name->str_data)); } DDL_resolve_intl_type( statement, @@ -2014,12 +1982,9 @@ static void define_field(CompiledStatement* statement, { const char* typeName = (field->fld_dtype == dtype_blob ? "BLOB" : "ARRAY"); - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_type_not_supp_ext_tab, - isc_arg_string, typeName, - isc_arg_string, relation->rel_name.c_str(), - isc_arg_string, field->fld_name.c_str(), - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_type_not_supp_ext_tab) << Arg::Str(typeName) << + Arg::Str(relation->rel_name) << Arg::Str(field->fld_name)); } if (position != -1) @@ -2066,10 +2031,9 @@ static void define_field(CompiledStatement* statement, case nod_primary: if (default_null_flag) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -204, - isc_arg_gds, isc_bad_default_value, - isc_arg_gds, isc_invalid_clause, - isc_arg_string, "default null not null", isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << + Arg::Gds(isc_bad_default_value) << + Arg::Gds(isc_invalid_clause) << Arg::Str("default null not null")); } if (!not_null_flag) { @@ -2154,7 +2118,7 @@ static void define_field(CompiledStatement* statement, } } // try - catch (const Firebird::Exception&) + catch (const Exception&) { clearPermanentField(relation, permanent); throw; @@ -2195,10 +2159,9 @@ static SSHORT getBlobFilterSubType(CompiledStatement* statement, const dsql_nod* "RDB$FIELD_SUB_TYPE", &blob_sub_type)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -204, isc_arg_gds, - isc_dsql_datatype_err, isc_arg_gds, - isc_dsql_blob_type_unknown, isc_arg_string, - ((const dsql_str*)(node->nod_arg[0]))->str_data, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << + Arg::Gds(isc_dsql_datatype_err) << + Arg::Gds(isc_dsql_blob_type_unknown) << Arg::Str(((const dsql_str*)(node->nod_arg[0]))->str_data)); } return blob_sub_type; } @@ -2260,9 +2223,8 @@ static void define_collation(CompiledStatement* statement) if (!resolved_charset) { // specified character set not found - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -504, - isc_arg_gds, isc_charset_not_found, isc_arg_string, - coll_for->str_data, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-504) << + Arg::Gds(isc_charset_not_found) << Arg::Str(coll_for->str_data)); } if (coll_specific_attributes) @@ -2282,11 +2244,9 @@ static void define_collation(CompiledStatement* statement) if (!resolved_collation) { // Specified collation not found - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -204, - isc_arg_gds, isc_collation_not_found, - isc_arg_string, ((dsql_str*)coll_from->nod_arg[0])->str_data, - isc_arg_string, resolved_charset->intlsym_name, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << + Arg::Gds(isc_collation_not_found) << Arg::Str(((dsql_str*)coll_from->nod_arg[0])->str_data) << + Arg::Str(resolved_charset->intlsym_name)); } statement->append_number(isc_dyn_coll_from, @@ -2524,10 +2484,9 @@ static void define_procedure(CompiledStatement* statement, NOD_TYPE op) } else if (defaults) { // parameter without default value after parameters with default - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -204, - isc_arg_gds, isc_bad_default_value, - isc_arg_gds, isc_invalid_clause, - isc_arg_string, "defaults must be last", isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << + Arg::Gds(isc_bad_default_value) << + Arg::Gds(isc_invalid_clause) << Arg::Str("defaults must be last")); } *ptr = MAKE_variable(field, field->fld_name.c_str(), @@ -3051,9 +3010,9 @@ static void define_shadow(CompiledStatement* statement) if (!ptr[e_shadow_number]) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_dsql_shadow_number_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_command_err) << + Arg::Gds(isc_dsql_shadow_number_err)); } statement->append_number(isc_dyn_def_shadow, (SSHORT)(IPTR) (ptr[e_shadow_number])); @@ -3082,12 +3041,10 @@ static void define_shadow(CompiledStatement* statement) if (!length && !file->fil_start) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_dsql_file_length_err, - isc_arg_number, (ISC_STATUS) file->fil_name->str_data, + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_command_err) << // Preceding file did not specify length, so %s must include starting page number - isc_arg_end); + Arg::Gds(isc_dsql_file_length_err) << Arg::Str(file->fil_name->str_data)); } const SLONG start = file->fil_start; @@ -3136,9 +3093,8 @@ static void define_trigger(CompiledStatement* statement, NOD_TYPE op) { if (type_node && (type_node->getSlong() & TRIGGER_TYPE_MASK) != TRIGGER_TYPE_DML) { - ERRD_post(isc_dsql_command_err, - isc_arg_gds, isc_dsql_incompatible_trigger_type, - isc_arg_end); + ERRD_post(Arg::Gds(isc_dsql_command_err) << + Arg::Gds(isc_dsql_incompatible_trigger_type)); } const dsql_str* relation_name = @@ -3152,9 +3108,8 @@ static void define_trigger(CompiledStatement* statement, NOD_TYPE op) { if (type_node && (type_node->getSlong() & TRIGGER_TYPE_MASK) != TRIGGER_TYPE_DB) { - ERRD_post(isc_dsql_command_err, - isc_arg_gds, isc_dsql_incompatible_trigger_type, - isc_arg_end); + ERRD_post(Arg::Gds(isc_dsql_command_err) << + Arg::Gds(isc_dsql_incompatible_trigger_type)); } } @@ -3179,9 +3134,8 @@ static void define_trigger(CompiledStatement* statement, NOD_TYPE op) { if (type_node && (type_node->getSlong() & TRIGGER_TYPE_MASK) != TRIGGER_TYPE_DML) { - ERRD_post(isc_dsql_command_err, - isc_arg_gds, isc_dsql_incompatible_trigger_type, - isc_arg_end); + ERRD_post(Arg::Gds(isc_dsql_command_err) << + Arg::Gds(isc_dsql_incompatible_trigger_type)); } relation_node = FB_NEW_RPT(*tdbb->getDefaultPool(), e_rln_count) dsql_nod; @@ -3193,9 +3147,8 @@ static void define_trigger(CompiledStatement* statement, NOD_TYPE op) } else if (found && type_node && (USHORT) type_node->getSlong() != trig_type) { - ERRD_post(isc_dsql_command_err, - isc_arg_gds, isc_dsql_db_trigger_type_cant_change, - isc_arg_end); + ERRD_post(Arg::Gds(isc_dsql_command_err) << + Arg::Gds(isc_dsql_db_trigger_type_cant_change)); } } } @@ -3352,11 +3305,10 @@ static void define_udf(CompiledStatement* statement) field->fld_dtype == dtype_blob || field->fld_dtype == dtype_timestamp)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_return_mode_err, + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-60) << + Arg::Gds(isc_dsql_command_err) << // Return mode by value not allowed for this data type - isc_arg_end); + Arg::Gds(isc_return_mode_err)); } /* For functions returning a blob, coerce return argument position to @@ -3367,12 +3319,11 @@ static void define_udf(CompiledStatement* statement) blob_position = (arguments) ? arguments->nod_count + 1 : 1; if (blob_position > MAX_UDF_ARGUMENTS) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_extern_func_err, + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_command_err) << // External functions can not have more than 10 parameters // Or 9 if the function returns a BLOB - isc_arg_end); + Arg::Gds(isc_extern_func_err)); } statement->append_number(isc_dyn_func_return_argument, blob_position); @@ -3393,15 +3344,14 @@ static void define_udf(CompiledStatement* statement) if (!arguments || position > arguments->nod_count || position < 1) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_udf_return_pos_err, //gds__extern_func_err, - isc_arg_number, (SLONG) (arguments ? arguments->nod_count : 0), + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_udf_return_pos_err) << //gds__extern_func_err, + Arg::Num(arguments ? arguments->nod_count : 0)); // CVC: We should devise new msg "position should be between 1 and #params"; // here it is: dsql_udf_return_pos_err // External functions can not have more than 10 parameters // Not strictly correct -- return position error - isc_arg_end); } // We'll verify that SCALAR_ARRAY can't be used as a return type. @@ -3412,10 +3362,8 @@ static void define_udf(CompiledStatement* statement) { const SSHORT arg_mechanism = (SSHORT) param_node[e_udf_param_type]->getSlong(); if (arg_mechanism == FUN_scalar_array) - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_random, - isc_arg_string, "BY SCALAR_ARRAY can't be used as a return parameter", - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_random) << Arg::Str("BY SCALAR_ARRAY can't be used as a return parameter")); } statement->append_number(isc_dyn_func_return_argument, position); @@ -3463,11 +3411,10 @@ static void define_udf(CompiledStatement* statement) { if (position > MAX_UDF_ARGUMENTS) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_extern_func_err, + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_command_err) << // External functions can not have more than 10 parameters - isc_arg_end); + Arg::Gds(isc_extern_func_err)); } /*field = (dsql_fld*) *ptr; */ @@ -3750,11 +3697,9 @@ static void define_view(CompiledStatement* statement, NOD_TYPE op) view_relation = METD_get_relation(statement, view_name); if (!view_relation) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_dsql_view_not_found, - isc_arg_string, view_name->str_data, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_command_err) << + Arg::Gds(isc_dsql_view_not_found) << Arg::Str(view_name->str_data)); } } @@ -3810,11 +3755,11 @@ static void define_view(CompiledStatement* statement, NOD_TYPE op) if (procedure) { // Disallow procedure-based views - ERRD_post(isc_wish_list, isc_arg_end); + ERRD_post(Arg::Gds(isc_wish_list)); } */ - const Firebird::MetaName& name = relation ? relation->rel_name : procedure->prc_name; + const MetaName& name = relation ? relation->rel_name : procedure->prc_name; statement->append_string(isc_dyn_view_relation, name); statement->append_number(isc_dyn_view_context, context->ctx_context); @@ -3846,7 +3791,7 @@ static void define_view(CompiledStatement* statement, NOD_TYPE op) dsql_nod* items = rse->nod_arg[e_rse_items]; dsql_nod** i_ptr = items->nod_arg; - Firebird::SortedArray modified_fields; + SortedArray modified_fields; for (const dsql_nod* const* const i_end = i_ptr + items->nod_count; i_ptr < i_end; i_ptr++, position++) @@ -3886,11 +3831,10 @@ static void define_view(CompiledStatement* statement, NOD_TYPE op) if (!ptr && !field_string) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_specify_field_err, + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_command_err) << // must specify field name for view select expression - isc_arg_end); + Arg::Gds(isc_specify_field_err)); } // CVC: Small modification here to catch any mismatch between number of @@ -3919,12 +3863,10 @@ static void define_view(CompiledStatement* statement, NOD_TYPE op) { if (modified_fields.exist(rel_field)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -104, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_dsql_col_more_than_once_view, - isc_arg_string, field_string, + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_command_err) << // column @1 appears more than once in ALTER VIEW - isc_arg_end); + Arg::Gds(isc_dsql_col_more_than_once_view) << Arg::Str(field_string)); } modified_fields.add(rel_field); @@ -3981,11 +3923,10 @@ static void define_view(CompiledStatement* statement, NOD_TYPE op) if (ptr != end) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_num_field_err, + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_command_err) << // number of fields does not match select list - isc_arg_end); + Arg::Gds(isc_num_field_err)); } if (view_relation) // modifying a view @@ -4009,51 +3950,46 @@ static void define_view(CompiledStatement* statement, NOD_TYPE op) { if (!updatable) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_col_name_err, + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_command_err) << // Only simple column names permitted for VIEW WITH CHECK OPTION - isc_arg_end); + Arg::Gds(isc_col_name_err)); } select_expr = select_expr->nod_arg[e_sel_query_spec]; if (select_expr->nod_type == nod_list) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_table_view_err, + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_command_err) << // Only one table allowed for VIEW WITH CHECK OPTION - isc_arg_end); + Arg::Gds(isc_table_view_err)); } if (select_expr->nod_arg[e_qry_from]->nod_count != 1) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_table_view_err, + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_command_err) << // Only one table allowed for VIEW WITH CHECK OPTION - isc_arg_end); + Arg::Gds(isc_table_view_err)); } if (!select_expr->nod_arg[e_qry_where]) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_where_err, + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_command_err) << // No where clause for VIEW WITH CHECK OPTION - isc_arg_end); + Arg::Gds(isc_where_err)); } if (select_expr->nod_arg[e_qry_distinct] || select_expr->nod_arg[e_qry_group] || select_expr->nod_arg[e_qry_having]) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_distinct_err, - // DISTINCT, GROUP or HAVING not permitted for VIEW WITH CHECK OPTION - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_command_err) << + // DISTINCT, GROUP or HAVING not permitted for VIEW WITH CHECK OPTION + Arg::Gds(isc_distinct_err)); } dsql_nod* relation_node = MAKE_node(nod_relation_name, e_rln_count); @@ -4352,22 +4288,18 @@ static void delete_relation_view (CompiledStatement* statement, if (!relation && !silent_deletion || relation && (relation->rel_flags & REL_view)) { - ERRD_post (isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_dsql_table_not_found, - isc_arg_string, string->str_data, - isc_arg_end); + ERRD_post (Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_command_err) << + Arg::Gds(isc_dsql_table_not_found) << Arg::Str(string->str_data)); } } else { /* node->nod_type == nod_del_view, nod_redef_view */ if (!relation && !silent_deletion || relation && !(relation->rel_flags & REL_view)) { - ERRD_post (isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_dsql_view_not_found, - isc_arg_string, string->str_data, - isc_arg_end); + ERRD_post (Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_command_err) << + Arg::Gds(isc_dsql_view_not_found) << Arg::Str(string->str_data)); } } if (relation) { @@ -4527,22 +4459,20 @@ static void foreign_key(CompiledStatement* statement, dsql_nod* element, const c referenced field, fail. */ if (!columns2) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_reftable_requires_pk, + ERRD_post (Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_command_err) << /* "REFERENCES table" without "(column)" requires PRIMARY KEY on referenced table */ - isc_arg_end); + Arg::Gds(isc_reftable_requires_pk)); } } if (columns2 && (columns1->nod_count != columns2->nod_count)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_key_field_count_err, + ERRD_post (Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_command_err) << // foreign key field count does not match primary key - isc_arg_end); + Arg::Gds(isc_key_field_count_err)); } /* define the foreign key index and the triggers that may be needed @@ -5338,12 +5268,10 @@ static void modify_domain( CompiledStatement* statement) correct type, length, scale, etc. */ if (!METD_get_domain(statement, &local_field, domain_name->str_data)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_dsql_domain_not_found, - isc_arg_string, domain_name->str_data, + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_command_err) << // Specified domain or source field does not exist - isc_arg_end); + Arg::Gds(isc_dsql_domain_not_found) << Arg::Str(domain_name->str_data)); } if (element->nod_arg[e_cnstr_condition]) { @@ -5663,10 +5591,10 @@ static void modify_relation(CompiledStatement* statement) TEXT linecol[64]; sprintf (linecol, "At line %d, column %d.", (int) relation_node->nod_line, (int) relation_node->nod_column); - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 204, isc_arg_gds, - isc_dsql_relation_err, isc_arg_gds, isc_random, - isc_arg_string, relation_name->str_data, isc_arg_gds, - isc_random, isc_arg_string, linecol, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << + Arg::Gds(isc_dsql_relation_err) << + Arg::Gds(isc_random) << Arg::Str(relation_name->str_data) << + Arg::Gds(isc_random) << Arg::Str(linecol)); } /* need to handle error that occur in generating dyn string. @@ -5746,9 +5674,9 @@ static void modify_relation(CompiledStatement* statement) if ((element->nod_arg[1])->nod_type == nod_cascade) { // Unsupported DSQL construct - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -901, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_dsql_construct_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) << + Arg::Gds(isc_dsql_command_err) << + Arg::Gds(isc_dsql_construct_err)); } fb_assert((element->nod_arg[1])->nod_type == nod_restrict); @@ -5773,7 +5701,7 @@ static void modify_relation(CompiledStatement* statement) statement->append_uchar(isc_dyn_end); } // try - catch (const Firebird::Exception&) + catch (const Exception&) { METD_drop_relation(statement, relation_name); statement->req_relation = 0; @@ -5794,12 +5722,11 @@ static void modify_udf(CompiledStatement* statement) const dsql_str* obj_name = (dsql_str*) node->nod_arg[e_mod_udf_name]; if (!node->nod_arg[e_mod_udf_entry_pt] && !node->nod_arg[e_mod_udf_module]) - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -104, - isc_arg_gds, isc_command_end_err2, // Unexpected end of command - isc_arg_number, (SLONG) node->nod_line, - isc_arg_number, - (SLONG) node->nod_column + obj_name->str_length, // + strlen("FUNCTION"), - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Unexpected end of command + Arg::Gds(isc_command_end_err2) << Arg::Num(node->nod_line) << + Arg::Num(node->nod_column + obj_name->str_length)); + // + strlen("FUNCTION") statement->append_cstring(isc_dyn_mod_function, obj_name->str_data); const dsql_str* entry_point_name = (dsql_str*) node->nod_arg[e_mod_udf_entry_pt]; @@ -5855,11 +5782,10 @@ static void define_user(CompiledStatement* statement, UCHAR op) { if (i == e_user_name || (i == e_user_passwd && op == isc_dyn_user_add)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -104, - isc_arg_gds, isc_command_end_err2, // Unexpected end of command - isc_arg_number, (SLONG) node->nod_line, - isc_arg_number, (SLONG) node->nod_column, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Unexpected end of command + Arg::Gds(isc_command_end_err2) << Arg::Num(node->nod_line) << + Arg::Num(node->nod_column)); } continue; @@ -5889,11 +5815,10 @@ static void define_user(CompiledStatement* statement, UCHAR op) if (argCount < 2 && op != isc_dyn_user_del) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -104, - isc_arg_gds, isc_command_end_err2, // Unexpected end of command - isc_arg_number, (SLONG) node->nod_line, - isc_arg_number, (SLONG) node->nod_column, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Unexpected end of command + Arg::Gds(isc_command_end_err2) << Arg::Num(node->nod_line) << + Arg::Num(node->nod_column)); } statement->append_uchar(isc_user_end); @@ -6322,9 +6247,8 @@ static void put_local_variables(CompiledStatement* statement, dsql_nod* paramete const dsql_fld* rest_field = (dsql_fld*) (*rest)->nod_arg[e_dfl_field]; if (field->fld_name == rest_field->fld_name) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -637, - isc_arg_gds, isc_dsql_duplicate_spec, - isc_arg_string, field->fld_name.c_str(), isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-637) << + Arg::Gds(isc_dsql_duplicate_spec) << Arg::Str(field->fld_name)); } } } @@ -6407,11 +6331,10 @@ static dsql_nod* replace_field_names(dsql_nod* input, if ((*ptr)->nod_type == nod_select_expr) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_subquery_err, + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_command_err) << // No subqueries permitted for VIEW WITH CHECK OPTION - isc_arg_end); + Arg::Gds(isc_subquery_err)); } if ((*ptr)->nod_type == nod_field_name) @@ -6770,9 +6693,8 @@ static void modify_field(CompiledStatement* statement, if (is_array_or_blob(statement, computedNod)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_no_array_computed, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_no_array_computed)); } statement->begin_blr(isc_dyn_fld_computed_blr); @@ -6811,12 +6733,10 @@ static void modify_field(CompiledStatement* statement, // Get the domain information if (!METD_get_domain(statement, field, domain_name->str_data)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_dsql_domain_not_found, + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_command_err) << // Specified domain or source field does not exist - isc_arg_string, domain_name->str_data, - isc_arg_end); + Arg::Gds(isc_dsql_domain_not_found) << Arg::Str(domain_name->str_data)); } DDL_resolve_intl_type(statement, field, NULL); } @@ -6853,7 +6773,7 @@ static void modify_field(CompiledStatement* statement, statement->append_uchar(isc_dyn_end); } // try - catch (const Firebird::Exception&) + catch (const Exception&) { clearPermanentField(relation, permanent); throw; @@ -6940,8 +6860,7 @@ void CompiledStatement::end_blr() const ULONG length = (req_blr_data.getCount() - req_base_offset) - 2; if (length > 0xFFFF) { - ERRD_post(isc_too_big_blr, isc_arg_number, (SLONG) length, - isc_arg_number, (SLONG) 0xFFFF, isc_arg_end); + ERRD_post(Arg::Gds(isc_too_big_blr) << Arg::Num(length) << Arg::Num(0xFFFF)); } *blr_base++ = (UCHAR) length; @@ -6988,7 +6907,7 @@ void CompiledStatement::append_meta_string(const char* string) thread_db* tdbb = JRD_get_thread_data(); ISC_STATUS_ARRAY status_vector = {0}; - Firebird::UCharBuffer nameBuffer; + UCharBuffer nameBuffer; CsConvert cv(INTL_charset_lookup(tdbb, CS_dynamic)->getStruct(), INTL_charset_lookup(tdbb, CS_METADATA)->getStruct()); diff --git a/src/dsql/dsql.cpp b/src/dsql/dsql.cpp index 1365f36cc1..809ad70d52 100644 --- a/src/dsql/dsql.cpp +++ b/src/dsql/dsql.cpp @@ -64,6 +64,7 @@ #ifdef SCROLLABLE_CURSORS #include "../jrd/scroll_cursors.h" #endif +#include "../common/StatusArg.h" #ifdef HAVE_CTYPE_H #include @@ -71,6 +72,7 @@ using namespace Jrd; using namespace Dsql; +using namespace Firebird; static void close_cursor(thread_db*, dsql_req*); @@ -205,9 +207,8 @@ void DSQL_execute(thread_db* tdbb, if (request->req_flags & REQ_orphan) { - ERRD_post (isc_sqlerr, isc_arg_number, (SLONG) -901, - isc_arg_gds, isc_bad_req_handle, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) << + Arg::Gds(isc_bad_req_handle)); } if ((SSHORT) in_msg_type == -1) { @@ -218,8 +219,8 @@ void DSQL_execute(thread_db* tdbb, if (!*tra_handle && request->req_type != REQ_START_TRANS) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 901, - isc_arg_gds, isc_bad_trans_handle, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) << + Arg::Gds(isc_bad_trans_handle)); } /* If the request is a SELECT or blob statement then this is an open. @@ -235,8 +236,8 @@ void DSQL_execute(thread_db* tdbb, { if (request->req_flags & REQ_cursor_open) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 502, - isc_arg_gds, isc_dsql_cursor_open_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-502) << + Arg::Gds(isc_dsql_cursor_open_err)); } } @@ -368,9 +369,9 @@ ISC_STATUS DSQL_fetch(thread_db* tdbb, request->req_type == REQ_GET_SEGMENT) { if (!(request->req_flags & REQ_cursor_open)) - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 504, - isc_arg_gds, isc_dsql_cursor_err, - isc_arg_gds, isc_dsql_cursor_not_open, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-504) << + Arg::Gds(isc_dsql_cursor_err) << + Arg::Gds(isc_dsql_cursor_not_open)); } #ifdef SCROLLABLE_CURSORS @@ -435,8 +436,8 @@ ISC_STATUS DSQL_fetch(thread_db* tdbb, break; default: - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 804, - isc_arg_gds, isc_dsql_sqlda_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-804) << + Arg::Gds(isc_dsql_sqlda_err)); } if (offset) @@ -555,8 +556,8 @@ void DSQL_free_statement(thread_db* tdbb, // Just close the cursor associated with the request if (!(request->req_flags & REQ_cursor_open)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 501, - isc_arg_gds, isc_dsql_cursor_close_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(- 501) << + Arg::Gds(isc_dsql_cursor_close_err)); } close_cursor(tdbb, request); } @@ -590,9 +591,8 @@ void DSQL_insert(thread_db* tdbb, if (request->req_flags & REQ_orphan) { - ERRD_post (isc_sqlerr, isc_arg_number, (SLONG) -901, - isc_arg_gds, isc_bad_req_handle, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) << + Arg::Gds(isc_bad_req_handle)); } // if the cursor isn't open, we've got a problem @@ -601,9 +601,9 @@ void DSQL_insert(thread_db* tdbb, { if (!(request->req_flags & REQ_cursor_open)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 504, - isc_arg_gds, isc_dsql_cursor_err, - isc_arg_gds, isc_dsql_cursor_not_open, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-504) << + Arg::Gds(isc_dsql_cursor_err) << + Arg::Gds(isc_dsql_cursor_not_open)); } } @@ -658,23 +658,21 @@ void DSQL_prepare(thread_db* tdbb, dsql_req* const old_request = *req_handle; if (!old_request) { - ERRD_post (isc_sqlerr, isc_arg_number, (SLONG) -901, - isc_arg_gds, isc_bad_req_handle, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) << + Arg::Gds(isc_bad_req_handle)); } dsql_dbb* database = old_request->req_dbb; if (!database) { - ERRD_post (isc_sqlerr, isc_arg_number, (SLONG) -901, - isc_arg_gds, isc_bad_req_handle, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) << + Arg::Gds(isc_bad_req_handle)); } // check to see if old request has an open cursor if (old_request && (old_request->req_flags & REQ_cursor_open)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 519, - isc_arg_gds, isc_dsql_open_cursor_request, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-519) << + Arg::Gds(isc_dsql_open_cursor_request)); } dsql_req* request = NULL; @@ -682,11 +680,10 @@ void DSQL_prepare(thread_db* tdbb, try { if (!string) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_command_end_err2, - // CVC: Nothing will be line 1, column 1 for the user. - isc_arg_number, (SLONG) 1, isc_arg_number, (SLONG) 1, - isc_arg_end); // Unexpected end of command + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Unexpected end of command + // CVC: Nothing will be line 1, column 1 for the user. + Arg::Gds(isc_command_end_err2) << Arg::Num(1) << Arg::Num(1)); } if (!length) { @@ -739,8 +736,8 @@ void DSQL_prepare(thread_db* tdbb, if (request->req_type == REQ_CREATE_DB) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 530, - isc_arg_gds, isc_dsql_crdb_prepare_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-530) << + Arg::Gds(isc_dsql_crdb_prepare_err)); } request->req_flags |= REQ_prepared; @@ -820,9 +817,9 @@ void DSQL_set_cursor(thread_db* tdbb, USHORT length = (USHORT) fb_utils::name_length(cursor.c_str()); if (length == 0) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 502, - isc_arg_gds, isc_dsql_decl_err, - isc_arg_gds, isc_dsql_cursor_invalid, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-502) << + Arg::Gds(isc_dsql_decl_err) << + Arg::Gds(isc_dsql_cursor_invalid)); } if (length > MAX_CURSOR_LENGTH) { length = MAX_CURSOR_LENGTH; @@ -838,10 +835,9 @@ void DSQL_set_cursor(thread_db* tdbb, if (request->req_cursor == symbol) return; - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 502, - isc_arg_gds, isc_dsql_decl_err, - isc_arg_gds, isc_dsql_cursor_redefined, - isc_arg_string, symbol->sym_string, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-502) << + Arg::Gds(isc_dsql_decl_err) << + Arg::Gds(isc_dsql_cursor_redefined) << Arg::Str(symbol->sym_string)); } // If there already is a cursor and its name isn't the same, ditto. @@ -853,10 +849,9 @@ void DSQL_set_cursor(thread_db* tdbb, } else { fb_assert(request->req_cursor != symbol); - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 502, - isc_arg_gds, isc_dsql_decl_err, - isc_arg_gds, isc_dsql_cursor_redefined, - isc_arg_string, request->req_cursor->sym_string, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-502) << + Arg::Gds(isc_dsql_decl_err) << + Arg::Gds(isc_dsql_cursor_redefined) << Arg::Str(request->req_cursor->sym_string)); } } @@ -1375,9 +1370,9 @@ static void execute_request(thread_db* tdbb, if (!request->req_updates) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 913, - isc_arg_gds, isc_deadlock, isc_arg_gds, - isc_update_conflict, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-913) << + Arg::Gds(isc_deadlock) << + Arg::Gds(isc_update_conflict)); } } else if (request->req_type == REQ_DELETE_CURSOR) @@ -1390,9 +1385,9 @@ static void execute_request(thread_db* tdbb, if (!request->req_deletes) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 913, - isc_arg_gds, isc_deadlock, isc_arg_gds, - isc_update_conflict, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-913) << + Arg::Gds(isc_deadlock) << + Arg::Gds(isc_update_conflict)); } } } @@ -2100,9 +2095,8 @@ static dsql_dbb* init(Attachment* attachment) database->dbb_ods_version = gds__vax_integer(data, l); if (database->dbb_ods_version <= 7) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 804, - isc_arg_gds, isc_dsql_too_old_ods, - isc_arg_number, (SLONG) 8, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-804) << + Arg::Gds(isc_dsql_too_old_ods) << Arg::Num(8)); } break; @@ -2234,8 +2228,8 @@ static void map_in_out( dsql_req* request, if (parameter || count) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 804, - isc_arg_gds, isc_dsql_sqlda_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-804) << + Arg::Gds(isc_dsql_sqlda_err)); } dsql_par* dbkey; @@ -2303,14 +2297,14 @@ static USHORT parse_blr( if (*blr != blr_version4 && *blr != blr_version5) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 804, - isc_arg_gds, isc_dsql_sqlda_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-804) << + Arg::Gds(isc_dsql_sqlda_err)); } blr++; // skip the blr_version if (*blr++ != blr_begin || *blr++ != blr_message) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 804, - isc_arg_gds, isc_dsql_sqlda_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-804) << + Arg::Gds(isc_dsql_sqlda_err)); } ++blr; // skip the message number @@ -2422,8 +2416,8 @@ static USHORT parse_blr( break; default: - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 804, - isc_arg_gds, isc_dsql_sqlda_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-804) << + Arg::Gds(isc_dsql_sqlda_err)); } USHORT align = type_alignments[desc.dsc_dtype]; @@ -2433,8 +2427,10 @@ static USHORT parse_blr( offset += desc.dsc_length; if (*blr++ != blr_short || *blr++ != 0) - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 804, - isc_arg_gds, isc_dsql_sqlda_err, isc_arg_end); + { + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-804) << + Arg::Gds(isc_dsql_sqlda_err)); + } align = type_alignments[dtype_short]; if (align) @@ -2459,8 +2455,8 @@ static USHORT parse_blr( if (*blr++ != (UCHAR) blr_end || offset != msg_length) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 804, - isc_arg_gds, isc_dsql_sqlda_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-804) << + Arg::Gds(isc_dsql_sqlda_err)); } return count; @@ -2492,8 +2488,8 @@ static dsql_req* prepare(thread_db* tdbb, dsql_dbb* database, jrd_tra* transacti if (client_dialect > SQL_DIALECT_CURRENT) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 901, - isc_arg_gds, isc_wish_list, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) << + Arg::Gds(isc_wish_list)); } if (!string_length) @@ -2534,9 +2530,9 @@ static dsql_req* prepare(thread_db* tdbb, dsql_dbb* database, jrd_tra* transacti // CVC: Apparently, dsql_ypparse won't return if the command is incomplete, // because yyerror() will call ERRD_post(). // This may be a special case, but we don't know about positions here. - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_command_end_err, // Unexpected end of command - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Unexpected end of command + Arg::Gds(isc_command_end_err)); } // allocate the send and receive messages @@ -2575,10 +2571,8 @@ static dsql_req* prepare(thread_db* tdbb, dsql_dbb* database, jrd_tra* transacti if (statement->req_type == REQ_DDL && parser.isStmtAmbiguous() && statement->req_dbb->dbb_db_SQL_dialect != client_dialect) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 817, - isc_arg_gds, isc_ddl_not_allowed_by_db_sql_dial, - isc_arg_number, - (SLONG) statement->req_dbb->dbb_db_SQL_dialect, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-817) << + Arg::Gds(isc_ddl_not_allowed_by_db_sql_dial) << Arg::Num(statement->req_dbb->dbb_db_SQL_dialect)); } if (statement->req_type == REQ_COMMIT || @@ -3173,8 +3167,8 @@ static UCHAR* var_info( break; default: - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 804, - isc_arg_gds, isc_dsql_datatype_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-804) << + Arg::Gds(isc_dsql_datatype_err)); } if (sql_type && (param->par_desc.dsc_flags & DSC_nullable)) diff --git a/src/dsql/errd.cpp b/src/dsql/errd.cpp index 7600442fec..beb9f612b8 100644 --- a/src/dsql/errd.cpp +++ b/src/dsql/errd.cpp @@ -148,12 +148,8 @@ void ERRD_error(const char* text) @param **/ -bool ERRD_post_warning(ISC_STATUS status, ...) +bool ERRD_post_warning(const Firebird::Arg::StatusVector& v) { - va_list args; - - va_start(args, status); - ISC_STATUS* status_vector = JRD_get_thread_data()->tdbb_status_vector; int indx = 0; @@ -177,88 +173,14 @@ bool ERRD_post_warning(ISC_STATUS status, ...) } } -// stuff the warning - if (indx + 3 >= ISC_STATUS_LENGTH) + if (indx + v.length() < ISC_STATUS_LENGTH) { - // not enough free space - // Hey, before returning, clean the varargs thing! - va_end(args); - return false; + memcpy(&status_vector[indx], v.value(), sizeof(ISC_STATUS) * (v.length() + 1)); + return true; } - status_vector[indx++] = isc_arg_warning; - status_vector[indx++] = status; - int type, len; - while ((type = va_arg(args, int)) && (indx + 3 < ISC_STATUS_LENGTH)) - { - - const char* pszTmp = NULL; - switch (status_vector[indx++] = type) - { - case isc_arg_warning: - status_vector[indx++] = (ISC_STATUS) va_arg(args, ISC_STATUS); - break; - - case isc_arg_string: - pszTmp = va_arg(args, char*); - if (strlen(pszTmp) >= (size_t) MAX_ERRSTR_LEN) { - status_vector[(indx - 1)] = isc_arg_cstring; - status_vector[indx++] = MAX_ERRSTR_LEN; - } - status_vector[indx++] = reinterpret_cast(ERR_cstring(pszTmp)); - break; - - case isc_arg_interpreted: - case isc_arg_sql_state: - pszTmp = va_arg(args, char*); - status_vector[indx++] = reinterpret_cast(ERR_cstring(pszTmp)); - break; - - case isc_arg_cstring: - len = va_arg(args, int); - status_vector[indx++] = - (ISC_STATUS) (len >= MAX_ERRSTR_LEN) ? MAX_ERRSTR_LEN : len; - pszTmp = va_arg(args, char*); - status_vector[indx++] = reinterpret_cast(ERR_cstring(pszTmp)); - break; - - case isc_arg_number: - status_vector[indx++] = (ISC_STATUS) va_arg(args, SLONG); - break; - - case isc_arg_vms: - case isc_arg_unix: - case isc_arg_win32: - default: - status_vector[indx++] = (ISC_STATUS) va_arg(args, int); - break; - } - } - va_end(args); - status_vector[indx] = isc_arg_end; - return true; -} - - -/** - - ERRD_post - - @brief Post an error, copying any potentially - transient data before we punt. - - - @param status - @param - - **/ -void ERRD_post(ISC_STATUS status, ...) -{ -// stuff the status into temp buffer - ISC_STATUS_ARRAY tmp_status; - MOVE_CLEAR(tmp_status, sizeof(tmp_status)); - STUFF_STATUS(tmp_status, status); - internal_post(tmp_status); + // not enough free space + return false; } diff --git a/src/dsql/errd_proto.h b/src/dsql/errd_proto.h index bd9c85ae84..6e9a3efb6b 100644 --- a/src/dsql/errd_proto.h +++ b/src/dsql/errd_proto.h @@ -30,9 +30,8 @@ void ERRD_assert_msg(const char*, const char*, ULONG); void ERRD_bugcheck(const char*); void ERRD_error(const char*); -void ERRD_post(ISC_STATUS, ...); -void ERRD_post(const Firebird::Arg::StatusVector&); -bool ERRD_post_warning(ISC_STATUS, ...); +void ERRD_post(const Firebird::Arg::StatusVector& v); +bool ERRD_post_warning(const Firebird::Arg::StatusVector& v); void ERRD_punt(const ISC_STATUS* = 0); #endif // DSQL_ERRD_PROTO_H diff --git a/src/dsql/gen.cpp b/src/dsql/gen.cpp index 484ae4f323..0d601c6cbb 100644 --- a/src/dsql/gen.cpp +++ b/src/dsql/gen.cpp @@ -56,9 +56,11 @@ #include "../jrd/dsc_proto.h" #include "../jrd/why_proto.h" #include "gen/iberror.h" +#include "../common/StatusArg.h" using namespace Jrd; using namespace Dsql; +using namespace Firebird; static void gen_aggregate(CompiledStatement*, const dsql_nod*); static void gen_cast(CompiledStatement*, const dsql_nod*); @@ -531,11 +533,10 @@ void GEN_expr(CompiledStatement* statement, dsql_nod* node) return; default: - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 901, - isc_arg_gds, isc_dsql_internal_err, - isc_arg_gds, isc_expression_eval_err, + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) << + Arg::Gds(isc_dsql_internal_err) << // expression evaluation not supported - isc_arg_end); + Arg::Gds(isc_expression_eval_err)); } stuff(statement, blr_operator); @@ -592,8 +593,7 @@ void GEN_expr(CompiledStatement* statement, dsql_nod* node) sprintf(message_buf, "blr %d", (int) blr_operator); s = message_buf; } - ERRD_post_warning(isc_dsql_dialect_warning_expr, - isc_arg_string, s, isc_arg_end); + ERRD_post_warning(Arg::Warning(isc_dsql_dialect_warning_expr) << Arg::Str(s)); } } @@ -679,13 +679,10 @@ void GEN_port(CompiledStatement* statement, dsql_msg* message) case dtype_sql_date: case dtype_sql_time: case dtype_int64: - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 804, - isc_arg_gds, isc_dsql_datatype_err, - isc_arg_gds, isc_sql_dialect_datatype_unsupport, - isc_arg_number, (SLONG) statement->req_client_dialect, - isc_arg_string, - DSC_dtype_tostring(parameter->par_desc.dsc_dtype), - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-804) << + Arg::Gds(isc_dsql_datatype_err) << + Arg::Gds(isc_sql_dialect_datatype_unsupport) << Arg::Num(statement->req_client_dialect) << + Arg::Str(DSC_dtype_tostring(parameter->par_desc.dsc_dtype))); break; default: // No special action for other data types @@ -701,10 +698,9 @@ void GEN_port(CompiledStatement* statement, dsql_msg* message) } if (offset > MAX_FORMAT_SIZE) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -204, - isc_arg_gds, isc_imp_exc, - isc_arg_gds, isc_blktoobig, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << + Arg::Gds(isc_imp_exc) << + Arg::Gds(isc_blktoobig)); } message->msg_length = (USHORT) offset; @@ -860,8 +856,8 @@ void GEN_start_transaction( CompiledStatement* statement, const dsql_nod* tran_n switch (ptr->nod_type) { case nod_access: if (sw_access) - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_dup_option, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_dup_option)); sw_access = true; if (ptr->nod_flags & NOD_READ_ONLY) @@ -872,8 +868,8 @@ void GEN_start_transaction( CompiledStatement* statement, const dsql_nod* tran_n case nod_wait: if (sw_wait) - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_dup_option, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_dup_option)); sw_wait = true; if (ptr->nod_flags & NOD_NO_WAIT) @@ -884,8 +880,8 @@ void GEN_start_transaction( CompiledStatement* statement, const dsql_nod* tran_n case nod_isolation: if (sw_isolation) - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_dup_option, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_dup_option)); sw_isolation = true; @@ -913,8 +909,8 @@ void GEN_start_transaction( CompiledStatement* statement, const dsql_nod* tran_n case nod_reserve: { if (sw_reserve) - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_dup_option, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_dup_option)); sw_reserve = true; const dsql_nod* reserve = ptr->nod_arg[0]; @@ -932,8 +928,8 @@ void GEN_start_transaction( CompiledStatement* statement, const dsql_nod* tran_n case nod_tra_misc: if (misc_flags & ptr->nod_flags) - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_dup_option, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_dup_option)); misc_flags |= ptr->nod_flags; if (ptr->nod_flags & NOD_NO_AUTO_UNDO) @@ -946,8 +942,8 @@ void GEN_start_transaction( CompiledStatement* statement, const dsql_nod* tran_n case nod_lock_timeout: if (sw_lock_timeout) - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_dup_option, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_dup_option)); sw_lock_timeout = true; if (ptr->nod_count == 1 && ptr->nod_arg[0]->nod_type == nod_constant) @@ -960,8 +956,8 @@ void GEN_start_transaction( CompiledStatement* statement, const dsql_nod* tran_n break; default: - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_tran_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_tran_err)); } } } @@ -1268,8 +1264,8 @@ void GEN_statement( CompiledStatement* statement, dsql_nod* node) dsql_nod* list = cursor->nod_arg[e_cur_rse]->nod_arg[e_rse_items]; if (list->nod_count != list_into->nod_count) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 313, - isc_arg_gds, isc_dsql_count_mismatch, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-313) << + Arg::Gds(isc_dsql_count_mismatch)); } stuff(statement, blr_begin); ptr = list->nod_arg; @@ -1291,10 +1287,10 @@ void GEN_statement( CompiledStatement* statement, dsql_nod* node) return; default: - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 901, - isc_arg_gds, isc_dsql_internal_err, - isc_arg_gds, isc_node_err, // gen.c: node not supported - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) << + Arg::Gds(isc_dsql_internal_err) << + // gen.c: node not supported + Arg::Gds(isc_node_err)); } } @@ -1491,11 +1487,9 @@ static void gen_constant( CompiledStatement* statement, const dsc* desc, bool ne * didn't contain an exponent so it's not a valid DOUBLE * PRECISION literal either, so we have to bounce it. */ - ERRD_post(isc_sqlerr, - isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_arith_except, - isc_arg_gds, isc_numeric_out_of_range, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(- 104) << + Arg::Gds(isc_arith_except) << + Arg::Gds(isc_numeric_out_of_range)); } /* We and the lexer both agree that this is an SINT64 constant, @@ -1548,8 +1542,8 @@ static void gen_constant( CompiledStatement* statement, const dsc* desc, bool ne default: // gen_constant: datatype not understood - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 103, - isc_arg_gds, isc_dsql_constant_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-103) << + Arg::Gds(isc_dsql_constant_err)); } } @@ -1668,8 +1662,8 @@ static void gen_descriptor( CompiledStatement* statement, const dsc* desc, bool default: // don't understand dtype - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 804, - isc_arg_gds, isc_dsql_datatype_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-804) << + Arg::Gds(isc_dsql_datatype_err)); } } @@ -1843,13 +1837,10 @@ static void gen_field( CompiledStatement* statement, const dsql_ctx* context, case dtype_sql_date: case dtype_sql_time: case dtype_int64: - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 804, - isc_arg_gds, isc_dsql_datatype_err, - isc_arg_gds, isc_sql_dialect_datatype_unsupport, - isc_arg_number, (SLONG) statement->req_client_dialect, - isc_arg_string, - DSC_dtype_tostring(static_cast(field->fld_dtype)), - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-804) << + Arg::Gds(isc_dsql_datatype_err) << + Arg::Gds(isc_sql_dialect_datatype_unsupport) << Arg::Num(statement->req_client_dialect) << + Arg::Str(DSC_dtype_tostring(static_cast(field->fld_dtype)))); break; default: // No special action for other data types @@ -1936,8 +1927,8 @@ static void gen_for_select( CompiledStatement* statement, const dsql_nod* for_se if (list_to) { if (list->nod_count != list_to->nod_count) - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 313, - isc_arg_gds, isc_dsql_count_mismatch, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-313) << + Arg::Gds(isc_dsql_count_mismatch)); dsql_nod** ptr = list->nod_arg; dsql_nod** ptr_to = list_to->nod_arg; for (const dsql_nod* const* const end = ptr + list->nod_count; ptr < end; @@ -3069,14 +3060,14 @@ static void gen_union( CompiledStatement* statement, const dsql_nod* union_node) static void stuff_context(CompiledStatement* statement, const dsql_ctx* context) { if (context->ctx_context > MAX_UCHAR) { - ERRD_post(isc_too_many_contexts, isc_arg_end); + ERRD_post(Arg::Gds(isc_too_many_contexts)); } stuff(statement, context->ctx_context); if (context->ctx_flags & CTX_recursive) { if (context->ctx_recursive > MAX_UCHAR) { - ERRD_post(isc_too_many_contexts, isc_arg_end); + ERRD_post(Arg::Gds(isc_too_many_contexts)); } stuff(statement, context->ctx_recursive); } diff --git a/src/dsql/make.cpp b/src/dsql/make.cpp index 63d9b07439..445cc4f197 100644 --- a/src/dsql/make.cpp +++ b/src/dsql/make.cpp @@ -62,9 +62,11 @@ #include "../jrd/thread_proto.h" #include "../jrd/why_proto.h" #include "../common/config/config.h" +#include "../common/StatusArg.h" using namespace Jrd; using namespace Dsql; +using namespace Firebird; /* Firebird provides transparent conversion from string to date in * contexts where it makes sense. This macro checks a descriptor to @@ -451,7 +453,7 @@ void MAKE_desc(CompiledStatement* statement, dsc* desc, dsql_nod* node, dsql_nod if (!DTYPE_IS_NUMERIC(desc->dsc_dtype) && !DTYPE_IS_TEXT(desc->dsc_dtype)) { - ERRD_post(isc_expression_eval_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_expression_eval_err)); } else if (DTYPE_IS_TEXT(desc->dsc_dtype)) { desc->dsc_dtype = dtype_double; @@ -464,7 +466,7 @@ void MAKE_desc(CompiledStatement* statement, dsc* desc, dsql_nod* node, dsql_nod desc->dsc_flags = DSC_nullable; dtype = desc->dsc_dtype; if (!DTYPE_IS_NUMERIC(dtype)) { - ERRD_post(isc_expression_eval_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_expression_eval_err)); } else if (DTYPE_IS_EXACT(dtype)) { desc->dsc_dtype = dtype_int64; @@ -482,7 +484,7 @@ void MAKE_desc(CompiledStatement* statement, dsc* desc, dsql_nod* node, dsql_nod if (!DTYPE_IS_NUMERIC(desc->dsc_dtype) && !DTYPE_IS_TEXT(desc->dsc_dtype)) { - ERRD_post(isc_expression_eval_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_expression_eval_err)); } else if (desc->dsc_dtype == dtype_short) { desc->dsc_dtype = dtype_long; @@ -503,7 +505,7 @@ void MAKE_desc(CompiledStatement* statement, dsc* desc, dsql_nod* node, dsql_nod MAKE_desc(statement, desc, node->nod_arg[0], null_replacement); dtype = desc->dsc_dtype; if (!DTYPE_IS_NUMERIC(dtype)) { - ERRD_post(isc_expression_eval_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_expression_eval_err)); } else if (DTYPE_IS_EXACT(dtype)) { desc->dsc_dtype = dtype_int64; @@ -641,8 +643,8 @@ void MAKE_desc(CompiledStatement* statement, dsc* desc, dsql_nod* node, dsql_nod dtype = MAX(dtype1, dtype2); if (DTYPE_IS_BLOB(dtype)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 607, - isc_arg_gds, isc_dsql_no_blob_array, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_no_blob_array)); } desc->dsc_flags = (desc1.dsc_flags | desc2.dsc_flags) & DSC_nullable; @@ -654,7 +656,7 @@ void MAKE_desc(CompiledStatement* statement, dsc* desc, dsql_nod* node, dsql_nod if (DTYPE_IS_TEXT(desc1.dsc_dtype) || DTYPE_IS_TEXT(desc2.dsc_dtype)) { - ERRD_post(isc_expression_eval_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_expression_eval_err)); } case dtype_timestamp: @@ -691,7 +693,7 @@ void MAKE_desc(CompiledStatement* statement, dsc* desc, dsql_nod* node, dsql_nod dtype = dtype_timestamp; } else { - ERRD_post(isc_expression_eval_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_expression_eval_err)); } if (dtype == dtype_sql_date) { @@ -721,7 +723,7 @@ void MAKE_desc(CompiledStatement* statement, dsc* desc, dsql_nod* node, dsql_nod } else { /* + */ - ERRD_post(isc_expression_eval_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_expression_eval_err)); } } else if (DTYPE_IS_DATE(desc1.dsc_dtype) || (node->nod_type == nod_add)) @@ -738,7 +740,7 @@ void MAKE_desc(CompiledStatement* statement, dsc* desc, dsql_nod* node, dsql_nod else { /* - */ fb_assert(node->nod_type == nod_subtract); - ERRD_post(isc_expression_eval_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_expression_eval_err)); } return; @@ -780,15 +782,15 @@ void MAKE_desc(CompiledStatement* statement, dsc* desc, dsql_nod* node, dsql_nod // Arrays and blobs can never partipate in addition/subtraction if (DTYPE_IS_BLOB(dtype1) || DTYPE_IS_BLOB(dtype2)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 607, - isc_arg_gds, isc_dsql_no_blob_array, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_no_blob_array)); } // In Dialect 2 or 3, strings can never partipate in addition / sub // (use a specific cast instead) if (DTYPE_IS_TEXT(dtype1) || DTYPE_IS_TEXT(dtype2)) { - ERRD_post(isc_expression_eval_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_expression_eval_err)); } /* Determine the TYPE of arithmetic to perform, store it @@ -852,7 +854,7 @@ void MAKE_desc(CompiledStatement* statement, dsc* desc, dsql_nod* node, dsql_nod dtype = dtype_timestamp; } else { - ERRD_post(isc_expression_eval_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_expression_eval_err)); } if (dtype == dtype_sql_date) { @@ -883,7 +885,7 @@ void MAKE_desc(CompiledStatement* statement, dsc* desc, dsql_nod* node, dsql_nod } else { /* + */ - ERRD_post(isc_expression_eval_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_expression_eval_err)); } } else if (DTYPE_IS_DATE(desc1.dsc_dtype) || (node->nod_type == nod_add2)) @@ -900,7 +902,7 @@ void MAKE_desc(CompiledStatement* statement, dsc* desc, dsql_nod* node, dsql_nod else { /* - */ fb_assert(node->nod_type == nod_subtract2); - ERRD_post(isc_expression_eval_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_expression_eval_err)); } return; @@ -934,7 +936,7 @@ void MAKE_desc(CompiledStatement* statement, dsc* desc, dsql_nod* node, dsql_nod default: // a type which cannot participate in an add or subtract - ERRD_post(isc_expression_eval_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_expression_eval_err)); } return; @@ -952,8 +954,8 @@ void MAKE_desc(CompiledStatement* statement, dsc* desc, dsql_nod* node, dsql_nod // Arrays and blobs can never partipate in multiplication if (DTYPE_IS_BLOB(desc1.dsc_dtype) || DTYPE_IS_BLOB(desc2.dsc_dtype)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 607, - isc_arg_gds, isc_dsql_no_blob_array, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_no_blob_array)); } dtype = DSC_multiply_blr4_result[desc1.dsc_dtype][desc2.dsc_dtype]; @@ -975,7 +977,7 @@ void MAKE_desc(CompiledStatement* statement, dsc* desc, dsql_nod* node, dsql_nod break; default: - ERRD_post(isc_expression_eval_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_expression_eval_err)); } return; @@ -995,13 +997,13 @@ void MAKE_desc(CompiledStatement* statement, dsc* desc, dsql_nod* node, dsql_nod // (use a specific cast instead) if (DTYPE_IS_TEXT(desc1.dsc_dtype) || DTYPE_IS_TEXT(desc2.dsc_dtype)) { - ERRD_post(isc_expression_eval_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_expression_eval_err)); } // Arrays and blobs can never partipate in multiplication if (DTYPE_IS_BLOB(desc1.dsc_dtype) || DTYPE_IS_BLOB(desc2.dsc_dtype)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 607, - isc_arg_gds, isc_dsql_no_blob_array, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_no_blob_array)); } dtype = DSC_multiply_result[desc1.dsc_dtype][desc2.dsc_dtype]; @@ -1024,7 +1026,7 @@ void MAKE_desc(CompiledStatement* statement, dsc* desc, dsql_nod* node, dsql_nod break; default: - ERRD_post(isc_expression_eval_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_expression_eval_err)); } return; @@ -1052,8 +1054,8 @@ void MAKE_desc(CompiledStatement* statement, dsc* desc, dsql_nod* node, dsql_nod // Arrays and blobs can never partipate in division if (DTYPE_IS_BLOB(desc1.dsc_dtype) || DTYPE_IS_BLOB(desc2.dsc_dtype)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 607, - isc_arg_gds, isc_dsql_no_blob_array, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_no_blob_array)); } dtype1 = desc1.dsc_dtype; @@ -1067,7 +1069,7 @@ void MAKE_desc(CompiledStatement* statement, dsc* desc, dsql_nod* node, dsql_nod dtype = MAX(dtype1, dtype2); if (!DTYPE_IS_NUMERIC(dtype)) { - ERRD_post(isc_expression_eval_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_expression_eval_err)); } desc->dsc_dtype = dtype_double; @@ -1092,13 +1094,13 @@ void MAKE_desc(CompiledStatement* statement, dsc* desc, dsql_nod* node, dsql_nod // (use a specific cast instead) if (DTYPE_IS_TEXT(desc1.dsc_dtype) || DTYPE_IS_TEXT(desc2.dsc_dtype)) { - ERRD_post(isc_expression_eval_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_expression_eval_err)); } // Arrays and blobs can never partipate in division if (DTYPE_IS_BLOB(desc1.dsc_dtype) || DTYPE_IS_BLOB(desc2.dsc_dtype)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 607, - isc_arg_gds, isc_dsql_no_blob_array, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_no_blob_array)); } dtype = DSC_multiply_result[desc1.dsc_dtype][desc2.dsc_dtype]; @@ -1118,7 +1120,7 @@ void MAKE_desc(CompiledStatement* statement, dsc* desc, dsql_nod* node, dsql_nod break; default: - ERRD_post(isc_expression_eval_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_expression_eval_err)); } return; @@ -1137,7 +1139,7 @@ void MAKE_desc(CompiledStatement* statement, dsc* desc, dsql_nod* node, dsql_nod // (use a specific cast instead) if (DTYPE_IS_TEXT(desc->dsc_dtype)) { if (statement->req_client_dialect >= SQL_DIALECT_V6_TRANSITION) { - ERRD_post(isc_expression_eval_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_expression_eval_err)); } desc->dsc_dtype = dtype_double; desc->dsc_length = sizeof(double); @@ -1145,12 +1147,12 @@ void MAKE_desc(CompiledStatement* statement, dsc* desc, dsql_nod* node, dsql_nod // Forbid blobs and arrays else if (DTYPE_IS_BLOB(desc->dsc_dtype)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 607, - isc_arg_gds, isc_dsql_no_blob_array, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_no_blob_array)); } // Forbid other not numeric datatypes else if (!DTYPE_IS_NUMERIC(desc->dsc_dtype)) { - ERRD_post(isc_expression_eval_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_expression_eval_err)); } return; @@ -1172,8 +1174,8 @@ void MAKE_desc(CompiledStatement* statement, dsc* desc, dsql_nod* node, dsql_nod desc->dsc_ttype() = ttype_binary; } else { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 607, - isc_arg_gds, isc_dsql_dbkey_from_non_table, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_dbkey_from_non_table)); } return; @@ -1261,8 +1263,8 @@ void MAKE_desc(CompiledStatement* statement, dsc* desc, dsql_nod* node, dsql_nod } else { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 203, - isc_arg_gds, isc_dsql_field_ref, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-203) << + Arg::Gds(isc_dsql_field_ref)); } return; @@ -1522,9 +1524,8 @@ dsql_nod* MAKE_field(dsql_ctx* context, dsql_fld* field, dsql_nod* indices) else { if (indices) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 607, - isc_arg_gds, isc_dsql_only_can_subscript_array, - isc_arg_string, field->fld_name.c_str(), isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_only_can_subscript_array) << Arg::Str(field->fld_name)); } MAKE_desc_from_field(&node->nod_desc, field); @@ -1641,8 +1642,8 @@ dsql_par* MAKE_parameter(dsql_msg* message, bool sqlda_flag, bool null_flag, USHORT sqlda_index, const dsql_nod* node) { if (!message) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 901, - isc_arg_gds, isc_badmsgnum, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) << + Arg::Gds(isc_badmsgnum)); } DEV_BLKCHK(message, dsql_type_msg); diff --git a/src/dsql/parse.y b/src/dsql/parse.y index 776a989afb..9aa962907f 100644 --- a/src/dsql/parse.y +++ b/src/dsql/parse.y @@ -95,6 +95,7 @@ #include "../jrd/gds_proto.h" #include "../jrd/err_proto.h" #include "../jrd/intlobj_new.h" +#include "../common/StatusArg.h" /* since UNIX isn't standard, we have to define stuff which is in (which isn't available @@ -143,6 +144,7 @@ const int MAX_TOKEN_LEN = 256; using namespace Jrd; using namespace Dsql; +using namespace Firebird; #ifdef NOT_USED_OR_REPLACED static bool long_int(dsql_nod*, SLONG*); @@ -2713,17 +2715,13 @@ non_charset_simple_type : national_character_type | BIGINT { if (client_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (isc_sqlerr, isc_arg_number, (SLONG) -104, - isc_arg_gds, isc_sql_dialect_datatype_unsupport, - isc_arg_number, (SLONG) client_dialect, - isc_arg_string, "BIGINT", - isc_arg_end); + ERRD_post (Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_sql_dialect_datatype_unsupport) << Arg::Num(client_dialect) << + Arg::Str("BIGINT")); if (db_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (isc_sqlerr, isc_arg_number, (SLONG) -104, - isc_arg_gds, isc_sql_db_dialect_dtype_unsupport, - isc_arg_number, (SLONG) db_dialect, - isc_arg_string, "BIGINT", - isc_arg_end); + ERRD_post (Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_sql_db_dialect_dtype_unsupport) << Arg::Num(db_dialect) << + Arg::Str("BIGINT")); lex.g_field->fld_dtype = dtype_int64; lex.g_field->fld_length = sizeof (SINT64); } @@ -2743,8 +2741,8 @@ non_charset_simple_type : national_character_type if (client_dialect <= SQL_DIALECT_V5) { /* Post warning saying that DATE is equivalent to TIMESTAMP */ - ERRD_post_warning (isc_sqlwarn, isc_arg_number, (SLONG) 301, - isc_arg_warning, isc_dtype_renamed, isc_arg_end); + ERRD_post_warning(Arg::Warning(isc_sqlwarn) << Arg::Num(301) << + Arg::Warning(isc_dtype_renamed)); lex.g_field->fld_dtype = dtype_timestamp; lex.g_field->fld_length = sizeof (GDS_TIMESTAMP); } @@ -2759,17 +2757,13 @@ non_charset_simple_type : national_character_type | TIME { if (client_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (isc_sqlerr, isc_arg_number, (SLONG) -104, - isc_arg_gds, isc_sql_dialect_datatype_unsupport, - isc_arg_number, (SLONG) client_dialect, - isc_arg_string, "TIME", - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_sql_dialect_datatype_unsupport) << Arg::Num(client_dialect) << + Arg::Str("TIME")); if (db_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (isc_sqlerr, isc_arg_number, (SLONG) -104, - isc_arg_gds, isc_sql_db_dialect_dtype_unsupport, - isc_arg_number, (SLONG) db_dialect, - isc_arg_string, "TIME", - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_sql_dialect_datatype_unsupport) << Arg::Num(db_dialect) << + Arg::Str("TIME")); lex.g_field->fld_dtype = dtype_sql_time; lex.g_field->fld_length = sizeof (SLONG); } @@ -2938,34 +2932,23 @@ prec_scale : (db_dialect > SQL_DIALECT_V5) ) || ( (client_dialect > SQL_DIALECT_V5) && (db_dialect <= SQL_DIALECT_V5) ) ) - ERRD_post (isc_sqlerr, - isc_arg_number, (SLONG) -817, - isc_arg_gds, - isc_ddl_not_allowed_by_db_sql_dial, - isc_arg_number, (SLONG) db_dialect, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-817) << + Arg::Gds(isc_ddl_not_allowed_by_db_sql_dial) << Arg::Num(db_dialect)); if (client_dialect <= SQL_DIALECT_V5) { - lex.g_field->fld_dtype = dtype_double; - lex.g_field->fld_length = sizeof (double); + lex.g_field->fld_dtype = dtype_double; + lex.g_field->fld_length = sizeof (double); } else { - if (client_dialect == SQL_DIALECT_V6_TRANSITION) - { - ERRD_post_warning ( - isc_dsql_warn_precision_ambiguous, - isc_arg_end ); - ERRD_post_warning ( - isc_dsql_warn_precision_ambiguous1, - isc_arg_end ); - ERRD_post_warning ( - isc_dsql_warn_precision_ambiguous2, - isc_arg_end ); - - } - lex.g_field->fld_dtype = dtype_int64; - lex.g_field->fld_length = sizeof (SINT64); + if (client_dialect == SQL_DIALECT_V6_TRANSITION) + { + ERRD_post_warning(Arg::Warning(isc_dsql_warn_precision_ambiguous)); + ERRD_post_warning(Arg::Warning(isc_dsql_warn_precision_ambiguous1)); + ERRD_post_warning(Arg::Warning(isc_dsql_warn_precision_ambiguous2)); + } + lex.g_field->fld_dtype = dtype_int64; + lex.g_field->fld_length = sizeof (SINT64); } } else @@ -2995,34 +2978,24 @@ prec_scale : (db_dialect > SQL_DIALECT_V5) ) || ( (client_dialect > SQL_DIALECT_V5) && (db_dialect <= SQL_DIALECT_V5) ) ) - ERRD_post (isc_sqlerr, - isc_arg_number, (SLONG) -817, - isc_arg_gds, - isc_ddl_not_allowed_by_db_sql_dial, - isc_arg_number, (SLONG) db_dialect, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-817) << + Arg::Gds(isc_ddl_not_allowed_by_db_sql_dial) << Arg::Num(db_dialect)); if (client_dialect <= SQL_DIALECT_V5) { - lex.g_field->fld_dtype = dtype_double; - lex.g_field->fld_length = sizeof (double); + lex.g_field->fld_dtype = dtype_double; + lex.g_field->fld_length = sizeof (double); } else { - if (client_dialect == SQL_DIALECT_V6_TRANSITION) - { - ERRD_post_warning ( - isc_dsql_warn_precision_ambiguous, - isc_arg_end ); - ERRD_post_warning ( - isc_dsql_warn_precision_ambiguous1, - isc_arg_end ); - ERRD_post_warning ( - isc_dsql_warn_precision_ambiguous2, - isc_arg_end ); - } - /* client_dialect >= SQL_DIALECT_V6 */ - lex.g_field->fld_dtype = dtype_int64; - lex.g_field->fld_length = sizeof (SINT64); + if (client_dialect == SQL_DIALECT_V6_TRANSITION) + { + ERRD_post_warning(Arg::Warning(isc_dsql_warn_precision_ambiguous)); + ERRD_post_warning(Arg::Warning(isc_dsql_warn_precision_ambiguous1)); + ERRD_post_warning(Arg::Warning(isc_dsql_warn_precision_ambiguous2)); + } + /* client_dialect >= SQL_DIALECT_V6 */ + lex.g_field->fld_dtype = dtype_int64; + lex.g_field->fld_length = sizeof (SINT64); } } else @@ -4278,33 +4251,25 @@ value : column_name datetime_value_expression : CURRENT_DATE { if (client_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (isc_sqlerr, isc_arg_number, (SLONG) -104, - isc_arg_gds, isc_sql_dialect_datatype_unsupport, - isc_arg_number, (SLONG) client_dialect, - isc_arg_string, "DATE", - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_sql_dialect_datatype_unsupport) << Arg::Num(client_dialect) << + Arg::Str("DATE")); if (db_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (isc_sqlerr, isc_arg_number, (SLONG) -104, - isc_arg_gds, isc_sql_db_dialect_dtype_unsupport, - isc_arg_number, (SLONG) db_dialect, - isc_arg_string, "DATE", - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_sql_dialect_datatype_unsupport) << Arg::Num(db_dialect) << + Arg::Str("DATE")); $$ = make_node (nod_current_date, 0, NULL); } | CURRENT_TIME sec_precision_opt { if (client_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (isc_sqlerr, isc_arg_number, (SLONG) -104, - isc_arg_gds, isc_sql_dialect_datatype_unsupport, - isc_arg_number, (SLONG) client_dialect, - isc_arg_string, "TIME", - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_sql_dialect_datatype_unsupport) << Arg::Num(client_dialect) << + Arg::Str("TIME")); if (db_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (isc_sqlerr, isc_arg_number, (SLONG) -104, - isc_arg_gds, isc_sql_db_dialect_dtype_unsupport, - isc_arg_number, (SLONG) db_dialect, - isc_arg_string, "TIME", - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_sql_dialect_datatype_unsupport) << Arg::Num(db_dialect) << + Arg::Str("TIME")); $$ = make_node (nod_current_time, 1, $2); } | CURRENT_TIMESTAMP sec_precision_opt @@ -4355,33 +4320,25 @@ u_constant : u_numeric_constant | DATE STRING { if (client_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (isc_sqlerr, isc_arg_number, (SLONG) -104, - isc_arg_gds, isc_sql_dialect_datatype_unsupport, - isc_arg_number, (SLONG) client_dialect, - isc_arg_string, "DATE", - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_sql_dialect_datatype_unsupport) << Arg::Num(client_dialect) << + Arg::Str("DATE")); if (db_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (isc_sqlerr, isc_arg_number, (SLONG) -104, - isc_arg_gds, isc_sql_db_dialect_dtype_unsupport, - isc_arg_number, (SLONG) db_dialect, - isc_arg_string, "DATE", - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_sql_dialect_datatype_unsupport) << Arg::Num(db_dialect) << + Arg::Str("DATE")); $$ = MAKE_constant ((dsql_str*) $2, CONSTANT_DATE); } | TIME STRING { if (client_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (isc_sqlerr, isc_arg_number, (SLONG) -104, - isc_arg_gds, isc_sql_dialect_datatype_unsupport, - isc_arg_number, (SLONG) client_dialect, - isc_arg_string, "TIME", - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_sql_dialect_datatype_unsupport) << Arg::Num(client_dialect) << + Arg::Str("TIME")); if (db_dialect < SQL_DIALECT_V6_TRANSITION) - ERRD_post (isc_sqlerr, isc_arg_number, (SLONG) -104, - isc_arg_gds, isc_sql_db_dialect_dtype_unsupport, - isc_arg_number, (SLONG) db_dialect, - isc_arg_string, "TIME", - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_sql_dialect_datatype_unsupport) << Arg::Num(db_dialect) << + Arg::Str("TIME")); $$ = MAKE_constant ((dsql_str*) $2, CONSTANT_TIME); } | TIMESTAMP STRING @@ -6064,12 +6021,9 @@ int Parser::yylexAux() * the message text exceeds the 119-character limit * of our message database. */ - ERRD_post_warning( isc_dsql_warning_number_ambiguous, - isc_arg_string, - ERR_string( lex.last_token, lex.ptr - lex.last_token ), - isc_arg_end ); - ERRD_post_warning( isc_dsql_warning_number_ambiguous1, - isc_arg_end ); + ERRD_post_warning(Arg::Warning(isc_dsql_warning_number_ambiguous) << + Arg::Str(Firebird::string(lex.last_token, lex.ptr - lex.last_token))); + ERRD_post_warning(Arg::Warning(isc_dsql_warning_number_ambiguous1)); } yylval = (dsql_nod*) MAKE_string(lex.last_token, lex.ptr - lex.last_token); @@ -6172,22 +6126,18 @@ void Parser::yyerror_detailed(const TEXT* error_string, int yychar, YYSTYPE&, YY } if (yychar < 1) - ERRD_post (isc_sqlerr, isc_arg_number, (SLONG) -104, - isc_arg_gds, isc_command_end_err2, /* Unexpected end of command */ - isc_arg_number, lines, - isc_arg_number, (SLONG) (lex.last_token - line_start + 1), - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + /* Unexpected end of command */ + Arg::Gds(isc_command_end_err2) << Arg::Num(lines) << + Arg::Num(lex.last_token - line_start + 1)); else { - ERRD_post (isc_sqlerr, isc_arg_number, (SLONG) -104, - /* Token unknown - line %d, column %d */ - isc_arg_gds, isc_dsql_token_unk_err, - isc_arg_number, (SLONG) lines, - isc_arg_number, (SLONG) (lex.last_token - line_start + 1), /*CVC: +1*/ - /* Show the token */ - isc_arg_gds, isc_random, - isc_arg_cstring, (int) (lex.ptr - lex.last_token), lex.last_token, - isc_arg_end); + ERRD_post (Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + /* Token unknown - line %d, column %d */ + Arg::Gds(isc_dsql_token_unk_err) << Arg::Num(lines) << + Arg::Num(lex.last_token - line_start + 1) << /*CVC: +1*/ + /* Show the token */ + Arg::Gds(isc_random) << Arg::Str(string(lex.last_token, lex.ptr - lex.last_token))); } } @@ -6216,6 +6166,6 @@ static void yyabandon (SLONG sql_code, * **************************************/ - ERRD_post (isc_sqlerr, isc_arg_number, sql_code, - isc_arg_gds, error_symbol, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(sql_code) << + Arg::Gds(error_symbol)); } diff --git a/src/dsql/pass1.cpp b/src/dsql/pass1.cpp index 51ea0d7a41..379159f947 100644 --- a/src/dsql/pass1.cpp +++ b/src/dsql/pass1.cpp @@ -168,9 +168,11 @@ #include "../common/classes/auto.h" #include "../common/utils_proto.h" #include "../common/config/config.h" +#include "../common/StatusArg.h" using namespace Jrd; using namespace Dsql; +using namespace Firebird; #ifdef DEV_BUILD static void DSQL_pretty(const dsql_nod*, int); @@ -363,13 +365,11 @@ dsql_ctx* PASS1_make_context(CompiledStatement* statement, const dsql_nod* relat procedure = METD_get_procedure(statement, relation_name); if (!procedure) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 204, - isc_arg_gds, isc_dsql_procedure_err, - isc_arg_gds, isc_random, isc_arg_string, relation_name->str_data, - isc_arg_gds, isc_dsql_line_col_error, - isc_arg_number, (int) relation_node->nod_line, - isc_arg_number, (int) relation_node->nod_column, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << + Arg::Gds(isc_dsql_procedure_err) << + Arg::Gds(isc_random) << Arg::Str(relation_name->str_data) << + Arg::Gds(isc_dsql_line_col_error) << Arg::Num(relation_node->nod_line) << + Arg::Num(relation_node->nod_column)); } } else if ((cte = statement->findCTE(relation_name))) @@ -385,24 +385,19 @@ dsql_ctx* PASS1_make_context(CompiledStatement* statement, const dsql_nod* relat } if (!relation && !procedure) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 204, - isc_arg_gds, isc_dsql_relation_err, - isc_arg_gds, isc_random, isc_arg_string, relation_name->str_data, - isc_arg_gds, isc_dsql_line_col_error, - isc_arg_number, (int) relation_node->nod_line, - isc_arg_number, (int) relation_node->nod_column, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << + Arg::Gds(isc_dsql_relation_err) << + Arg::Gds(isc_random) << Arg::Str(relation_name->str_data) << + Arg::Gds(isc_dsql_line_col_error) << Arg::Num(relation_node->nod_line) << + Arg::Num(relation_node->nod_column)); } } if (procedure && !procedure->prc_out_count) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 84, - isc_arg_gds, isc_dsql_procedure_use_err, - isc_arg_string, relation_name->str_data, - isc_arg_gds, isc_dsql_line_col_error, - isc_arg_number, (int) relation_node->nod_line, - isc_arg_number, (int) relation_node->nod_column, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-84) << + Arg::Gds(isc_dsql_procedure_use_err) << Arg::Str(relation_name->str_data) << + Arg::Gds(isc_dsql_line_col_error) << Arg::Num(relation_node->nod_line) << + Arg::Num(relation_node->nod_column)); } // Set up context block. @@ -489,9 +484,8 @@ dsql_ctx* PASS1_make_context(CompiledStatement* statement, const dsql_nod* relat } if (!strcmp(conflict_name, context->ctx_alias)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 204, - isc_arg_gds, error_code, - isc_arg_string, conflict_name, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << + Arg::Gds(error_code) << Arg::Str(conflict_name)); } } } @@ -511,8 +505,7 @@ dsql_ctx* PASS1_make_context(CompiledStatement* statement, const dsql_nod* relat if (count > procedure->prc_in_count || count < procedure->prc_in_count - procedure->prc_def_count) { - ERRD_post(isc_prcmismat, isc_arg_string, - relation_name->str_data, isc_arg_end); + ERRD_post(Arg::Gds(isc_prcmismat) << Arg::Str(relation_name->str_data)); } if (count) @@ -643,8 +636,8 @@ dsql_nod* PASS1_node(CompiledStatement* statement, dsql_nod* input) sub1->nod_desc.dsc_dtype != dtype_sql_date && sub1->nod_desc.dsc_dtype != dtype_timestamp) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 105, - isc_arg_gds, isc_extract_input_mismatch, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-105) << + Arg::Gds(isc_extract_input_mismatch)); } break; case blr_extract_hour: @@ -655,8 +648,8 @@ dsql_nod* PASS1_node(CompiledStatement* statement, dsql_nod* input) sub1->nod_desc.dsc_dtype != dtype_sql_time && sub1->nod_desc.dsc_dtype != dtype_timestamp) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 105, - isc_arg_gds, isc_extract_input_mismatch, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-105) << + Arg::Gds(isc_extract_input_mismatch)); } break; default: @@ -687,8 +680,8 @@ dsql_nod* PASS1_node(CompiledStatement* statement, dsql_nod* input) case nod_order: case nod_select: case nod_with: - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_command_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_command_err)); case nod_derived_table: return pass1_derived_table(statement, input, NULL); @@ -697,8 +690,8 @@ dsql_nod* PASS1_node(CompiledStatement* statement, dsql_nod* input) { if (statement->isPsql()) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 206, - isc_arg_gds, isc_dsql_subselect_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(- 206) << + Arg::Gds(isc_dsql_subselect_err)); } const DsqlContextStack::iterator base(*statement->req_context); @@ -739,8 +732,8 @@ dsql_nod* PASS1_node(CompiledStatement* statement, dsql_nod* input) case nod_array: if (statement->isPsql()) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_invalid_array, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_invalid_array)); } else return pass1_field(statement, input, false, NULL); @@ -785,20 +778,18 @@ dsql_nod* PASS1_node(CompiledStatement* statement, dsql_nod* input) statement->req_curr_ctes.hasData() && (statement->req_curr_ctes.object() == cte)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_cte_wrong_reference, // Recursive CTE member (%s) can refer itself only in FROM clause - isc_arg_string, rel_name->str_data, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Recursive CTE member (%s) can refer itself only in FROM clause + Arg::Gds(isc_dsql_cte_wrong_reference) << Arg::Str(rel_name->str_data)); } for (DsqlNodStack::const_iterator stack(statement->req_curr_ctes); stack.hasData(); ++stack) { dsql_nod* cte1 = stack.object(); if (cte1 == cte) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_cte_cycle, // CTE %s has cyclic dependencies - isc_arg_string, rel_name->str_data, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // CTE %s has cyclic dependencies + Arg::Gds(isc_dsql_cte_cycle) << Arg::Str(rel_name->str_data)); } } @@ -833,8 +824,8 @@ dsql_nod* PASS1_node(CompiledStatement* statement, dsql_nod* input) case nod_parameter: if (statement->isPsql()) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_command_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_command_err)); } node = MAKE_node(input->nod_type, e_par_count); @@ -917,11 +908,9 @@ dsql_nod* PASS1_node(CompiledStatement* statement, dsql_nod* input) } if (list_item_count >= MAX_MEMBER_LIST) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -901, - isc_arg_gds, isc_imp_exc, - isc_arg_gds, isc_dsql_too_many_values, - isc_arg_number, MAX_MEMBER_LIST, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) << + Arg::Gds(isc_imp_exc) << + Arg::Gds(isc_dsql_too_many_values) << Arg::Num(MAX_MEMBER_LIST)); } return PASS1_node(statement, node); @@ -930,8 +919,8 @@ dsql_nod* PASS1_node(CompiledStatement* statement, dsql_nod* input) { if (statement->isPsql()) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 206, - isc_arg_gds, isc_dsql_subselect_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-206) << + Arg::Gds(isc_dsql_subselect_err)); } if (sub2->nod_flags & NOD_SELECT_EXPR_SINGLETON) @@ -1001,8 +990,8 @@ dsql_nod* PASS1_node(CompiledStatement* statement, dsql_nod* input) case nod_agg_list: if (statement->isPsql()) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_command_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_command_err)); } if (!(statement->req_in_select_list || statement->req_in_where_clause || statement->req_in_group_by_clause || statement->req_in_having_clause || @@ -1010,8 +999,8 @@ dsql_nod* PASS1_node(CompiledStatement* statement, dsql_nod* input) { /* not part of a select list, where clause, group by clause, having clause, or order by clause */ - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_agg_ref_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_agg_ref_err)); } node = MAKE_node(input->nod_type, e_agg_function_count); node->nod_count = input->nod_count; // Copy count, because this must be exactly the same as input. @@ -1064,8 +1053,8 @@ dsql_nod* PASS1_node(CompiledStatement* statement, dsql_nod* input) !(ddl_node->nod_type == nod_def_domain || ddl_node->nod_type == nod_mod_domain)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 901, - isc_arg_gds, isc_dsql_domain_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) << + Arg::Gds(isc_dsql_domain_err)); } } node = MAKE_node(input->nod_type, input->nod_count); @@ -1079,9 +1068,10 @@ dsql_nod* PASS1_node(CompiledStatement* statement, dsql_nod* input) USHORT req_mask = InternalInfo::getMask(id); if (req_mask && !(statement->req_flags & req_mask)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_token_err, // Token unknown - isc_arg_gds, isc_random, isc_arg_string, InternalInfo::getAlias(id), isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Token unknown + Arg::Gds(isc_token_err) << + Arg::Gds(isc_random) << Arg::Str(InternalInfo::getAlias(id))); } } break; @@ -1095,8 +1085,7 @@ dsql_nod* PASS1_node(CompiledStatement* statement, dsql_nod* input) const int precision = const_node->getSlong(); fb_assert(precision >= 0); if (unsigned(precision) > MAX_TIME_PRECISION) { - ERRD_post(isc_invalid_time_precision, - isc_arg_number, MAX_TIME_PRECISION, isc_arg_end); + ERRD_post(Arg::Gds(isc_invalid_time_precision) << Arg::Num(MAX_TIME_PRECISION)); } } } @@ -1403,10 +1392,8 @@ dsql_nod* PASS1_statement(CompiledStatement* statement, dsql_nod* input) if (field->fld_name == field2->fld_name) { - ERRD_post(isc_sqlerr, isc_arg_number, - (SLONG) - 901, isc_arg_gds, - isc_dsql_var_conflict, isc_arg_string, - field->fld_name.c_str(), isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) << + Arg::Gds(isc_dsql_var_conflict) << Arg::Str(field->fld_name)); } } } @@ -1424,10 +1411,8 @@ dsql_nod* PASS1_statement(CompiledStatement* statement, dsql_nod* input) if (field->fld_name == field2->fld_name) { - ERRD_post(isc_sqlerr, isc_arg_number, - (SLONG) - 901, isc_arg_gds, - isc_dsql_var_conflict, isc_arg_string, - field->fld_name.c_str(), isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) << + Arg::Gds(isc_dsql_var_conflict) << Arg::Str(field->fld_name)); } } } @@ -1473,10 +1458,9 @@ dsql_nod* PASS1_statement(CompiledStatement* statement, dsql_nod* input) DEV_BLKCHK(name, dsql_type_str); dsql_prc* procedure = METD_get_procedure(statement, name); if (!procedure) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 204, - isc_arg_gds, isc_dsql_procedure_err, - isc_arg_gds, isc_random, - isc_arg_string, name->str_data, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << + Arg::Gds(isc_dsql_procedure_err) << + Arg::Gds(isc_random) << Arg::Str(name->str_data)); } if (!statement->isPsql()) @@ -1495,7 +1479,7 @@ dsql_nod* PASS1_statement(CompiledStatement* statement, dsql_nod* input) if (count > procedure->prc_in_count || count < procedure->prc_in_count - procedure->prc_def_count) { - ERRD_post(isc_prcmismat, isc_arg_string, name->str_data, isc_arg_end); + ERRD_post(Arg::Gds(isc_prcmismat) << Arg::Str(name->str_data)); } node->nod_arg[e_exe_inputs] = PASS1_node(statement, input->nod_arg[e_exe_inputs]); @@ -1524,17 +1508,17 @@ dsql_nod* PASS1_statement(CompiledStatement* statement, dsql_nod* input) const USHORT ocount = temp ? temp->nod_count : 0; if (ocount != procedure->prc_out_count) { - ERRD_post(isc_prc_out_param_mismatch, - isc_arg_string, name->str_data, isc_arg_end); + ERRD_post(Arg::Gds(isc_prc_out_param_mismatch) << Arg::Str(name->str_data)); } node->nod_arg[e_exe_outputs] = PASS1_node(statement, temp); } else { if (temp) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, isc_arg_gds, - isc_token_err, // Token unknown - isc_arg_gds, isc_random, isc_arg_string, "RETURNING_VALUES", isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Token unknown + Arg::Gds(isc_token_err) << + Arg::Gds(isc_random) << Arg::Str("RETURNING_VALUES")); } node->nod_arg[e_exe_outputs] = explode_outputs(statement, statement->req_procedure); @@ -1784,9 +1768,8 @@ dsql_nod* PASS1_statement(CompiledStatement* statement, dsql_nod* input) size_t pos; if (names.find(name->str_data, pos)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -637, - isc_arg_gds, isc_dsql_duplicate_spec, - isc_arg_string, name->str_data, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-637) << + Arg::Gds(isc_dsql_duplicate_spec) << Arg::Str(name->str_data)); } names.insert(pos, name->str_data); } @@ -1861,9 +1844,8 @@ dsql_nod* PASS1_statement(CompiledStatement* statement, dsql_nod* input) } if (dupClause) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -637, - isc_arg_gds, isc_dsql_duplicate_spec, - isc_arg_string, dupClause, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-637) << + Arg::Gds(isc_dsql_duplicate_spec) << Arg::Str(dupClause)); } } } @@ -1875,26 +1857,26 @@ dsql_nod* PASS1_statement(CompiledStatement* statement, dsql_nod* input) case nod_breakleave: if (!statement->req_loop_level) - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_token_err, // Token unknown - isc_arg_gds, isc_random, isc_arg_string, "BREAK/LEAVE", isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Token unknown + Arg::Gds(isc_token_err) << + Arg::Gds(isc_random) << Arg::Str("BREAK/LEAVE")); input->nod_arg[e_breakleave_label] = pass1_label(statement, input); return input; case nod_return: if (statement->req_flags & REQ_trigger) // triggers only { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_token_err, // Token unknown - isc_arg_gds, isc_random, isc_arg_string, "SUSPEND", isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Token unknown + Arg::Gds(isc_token_err) << + Arg::Gds(isc_random) << Arg::Str("SUSPEND")); } if (statement->req_flags & REQ_in_auto_trans_block) // autonomous transaction { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 901, - isc_arg_gds, isc_dsql_unsupported_in_auto_trans, - isc_arg_string, "SUSPEND", - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) << + Arg::Gds(isc_dsql_unsupported_in_auto_trans) << Arg::Str("SUSPEND")); } statement->req_flags |= REQ_selectable; @@ -1960,25 +1942,28 @@ dsql_nod* PASS1_statement(CompiledStatement* statement, dsql_nod* input) case nod_user_savepoint: if (statement->req_flags & REQ_block) // blocks, procedures and triggers - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_token_err, // Token unknown - isc_arg_gds, isc_random, isc_arg_string, "SAVEPOINT", isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Token unknown + Arg::Gds(isc_token_err) << + Arg::Gds(isc_random) << Arg::Str("SAVEPOINT")); statement->req_type = REQ_SAVEPOINT; return input; case nod_release_savepoint: if (statement->req_flags & REQ_block) // blocks, procedures and triggers - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_token_err, // Token unknown - isc_arg_gds, isc_random, isc_arg_string, "RELEASE", isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Token unknown + Arg::Gds(isc_token_err) << + Arg::Gds(isc_random) << Arg::Str("RELEASE")); statement->req_type = REQ_SAVEPOINT; return input; case nod_undo_savepoint: if (statement->req_flags & REQ_block) // blocks, procedures and triggers - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_token_err, // Token unknown - isc_arg_gds, isc_random, isc_arg_string, "ROLLBACK", isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Token unknown + Arg::Gds(isc_token_err) << + Arg::Gds(isc_random) << Arg::Str("ROLLBACK")); statement->req_type = REQ_SAVEPOINT; return input; @@ -2002,10 +1987,10 @@ dsql_nod* PASS1_statement(CompiledStatement* statement, dsql_nod* input) break; case nod_union: - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 901, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_union_err, // union not supported - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) << + Arg::Gds(isc_dsql_command_err) << + // union not supported + Arg::Gds(isc_union_err)); break; case nod_cursor: @@ -2050,10 +2035,8 @@ dsql_nod* PASS1_statement(CompiledStatement* statement, dsql_nod* input) break; } - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 901, - isc_arg_gds, isc_dsql_unsupported_in_auto_trans, - isc_arg_string, stmt, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) << + Arg::Gds(isc_dsql_unsupported_in_auto_trans) << Arg::Str(stmt)); } // resolve the cursor @@ -2085,10 +2068,10 @@ dsql_nod* PASS1_statement(CompiledStatement* statement, dsql_nod* input) break; default: - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 901, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_dsql_construct_err, // Unsupported DSQL construct - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) << + Arg::Gds(isc_dsql_command_err) << + // Unsupported DSQL construct + Arg::Gds(isc_dsql_construct_err)); break; } @@ -2468,23 +2451,17 @@ static dsql_nod* ambiguity_check(CompiledStatement* statement, dsql_nod* node, if (node) { delete node; } - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -204, - isc_arg_gds, isc_dsql_ambiguous_field_name, - isc_arg_string, buffer, - isc_arg_string, ++p, - isc_arg_gds, isc_random, - isc_arg_string, name->str_data, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << + Arg::Gds(isc_dsql_ambiguous_field_name) << Arg::Str(buffer) << + Arg::Str(++p) << + Arg::Gds(isc_random) << Arg::Str(name->str_data)); return NULL; } - ERRD_post_warning(isc_sqlwarn, isc_arg_number, (SLONG) 204, - isc_arg_warning, isc_dsql_ambiguous_field_name, - isc_arg_string, buffer, - isc_arg_string, ++p, - isc_arg_gds, isc_random, - isc_arg_string, name->str_data, - isc_arg_end); + ERRD_post_warning(Arg::Warning(isc_sqlwarn) << Arg::Num(204) << + Arg::Warning(isc_dsql_ambiguous_field_name) << Arg::Str(buffer) << + Arg::Str(++p) << + Arg::Gds(isc_random) << Arg::Str(name->str_data)); return node; } @@ -2575,9 +2552,8 @@ static void check_unique_fields_names(StrArray& names, const dsql_nod* fields) if (!names.find(name, pos)) names.insert(pos, name); else { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -637, - isc_arg_gds, isc_dsql_duplicate_spec, - isc_arg_string, name, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-637) << + Arg::Gds(isc_dsql_duplicate_spec) << Arg::Str(name)); } } } @@ -2762,14 +2738,11 @@ static void field_duplication(const TEXT* qualifier_name, const TEXT* field_name field_name = field_buffer; } - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -206, - isc_arg_gds, isc_dsql_no_dup_name, - isc_arg_string, field_name, - isc_arg_string, statement, - isc_arg_gds, isc_dsql_line_col_error, - isc_arg_number, (int) flawed_node->nod_line, - isc_arg_number, (int) flawed_node->nod_column, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-206) << + Arg::Gds(isc_dsql_no_dup_name) << Arg::Str(field_name) << + Arg::Str(statement) << + Arg::Gds(isc_dsql_line_col_error) << Arg::Num(flawed_node->nod_line) << + Arg::Num(flawed_node->nod_column)); } @@ -2801,40 +2774,34 @@ static void field_unknown(const TEXT* qualifier_name, const TEXT* field_name, { if (field_name) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -206, - isc_arg_gds, isc_dsql_field_err, - isc_arg_gds, isc_random, isc_arg_string, field_name, - isc_arg_gds, isc_dsql_line_col_error, - isc_arg_number, (int) flawed_node->nod_line, - isc_arg_number, (int) flawed_node->nod_column, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-206) << + Arg::Gds(isc_dsql_field_err) << + Arg::Gds(isc_random) << Arg::Str(field_name) << + Arg::Gds(isc_dsql_line_col_error) << Arg::Num(flawed_node->nod_line) << + Arg::Num(flawed_node->nod_column)); } else { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -206, - isc_arg_gds, isc_dsql_field_err, - isc_arg_gds, isc_dsql_line_col_error, - isc_arg_number, (int) flawed_node->nod_line, - isc_arg_number, (int) flawed_node->nod_column, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-206) << + Arg::Gds(isc_dsql_field_err) << + Arg::Gds(isc_dsql_line_col_error) << Arg::Num(flawed_node->nod_line) << + Arg::Num(flawed_node->nod_column)); } } else { if (field_name) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -206, - isc_arg_gds, isc_dsql_field_err, - isc_arg_gds, isc_random, isc_arg_string, field_name, - isc_arg_gds, isc_dsql_unknown_pos, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-206) << + Arg::Gds(isc_dsql_field_err) << + Arg::Gds(isc_random) << Arg::Str(field_name) << + Arg::Gds(isc_dsql_unknown_pos)); } else { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -206, - isc_arg_gds, isc_dsql_field_err, - isc_arg_gds, isc_dsql_unknown_pos, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-206) << + Arg::Gds(isc_dsql_field_err) << + Arg::Gds(isc_dsql_unknown_pos)); } } } @@ -3119,8 +3086,8 @@ static bool invalid_reference(const dsql_ctx* context, const dsql_nod* node, FIELD_MATCH_TYPE_EQUAL, true)) { // Nested aggregate functions are not allowed - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_agg_nested_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_agg_nested_err)); } } } @@ -3664,8 +3631,8 @@ static void pass1_blob( CompiledStatement* statement, dsql_nod* input) dsql_nod* field = pass1_field(statement, input->nod_arg[e_blb_field], false, NULL); if (field->nod_desc.dsc_dtype != dtype_blob) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 206, - isc_arg_gds, isc_dsql_blob_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-206) << + Arg::Gds(isc_dsql_blob_err)); } statement->req_type = (input->nod_type == nod_get_segment) ? @@ -3830,9 +3797,9 @@ static dsql_nod* pass1_collate( CompiledStatement* statement, dsql_nod* sub1, field->fld_character_length = 0; } else { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 204, - isc_arg_gds, isc_dsql_datatype_err, - isc_arg_gds, isc_collation_requires_text, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << + Arg::Gds(isc_dsql_datatype_err) << + Arg::Gds(isc_collation_requires_text)); } DDL_resolve_intl_type(statement, field, collation); MAKE_desc_from_field(&node->nod_desc, field); @@ -3881,9 +3848,8 @@ static dsql_nod* pass1_constant( CompiledStatement* statement, dsql_nod* input) if (!resolved) { // character set name is not defined - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 504, isc_arg_gds, - isc_charset_not_found, isc_arg_string, string->str_charset, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-504) << + Arg::Gds(isc_charset_not_found) << Arg::Str(string->str_charset)); } if (global_temp_collation_name) @@ -3895,11 +3861,10 @@ static dsql_nod* pass1_constant( CompiledStatement* statement, dsql_nod* input) /* ** Specified collation not found */ - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 204, isc_arg_gds, - isc_dsql_datatype_err, isc_arg_gds, - isc_collation_not_found, - isc_arg_string, global_temp_collation_name->str_data, - isc_arg_string, resolved->intlsym_name, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << + Arg::Gds(isc_dsql_datatype_err) << + Arg::Gds(isc_collation_not_found) << Arg::Str(global_temp_collation_name->str_data) << + Arg::Str(resolved->intlsym_name)); } resolved = resolved_collation; } @@ -3931,10 +3896,8 @@ static dsql_nod* pass1_constant( CompiledStatement* statement, dsql_nod* input) if (!charSet->wellFormed(string->str_length, constant->nod_desc.dsc_address, NULL)) { - ERRD_post(isc_sqlerr, - isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_malformed_string, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_malformed_string)); } else { @@ -3983,9 +3946,8 @@ static dsql_ctx* pass1_cursor_context( CompiledStatement* statement, const dsql_ if (rse->nod_arg[e_rse_reduced]) { // cursor with DISTINCT is not updatable - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 510, - isc_arg_gds, isc_dsql_cursor_update_err, - isc_arg_string, string->str_data, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-510) << + Arg::Gds(isc_dsql_cursor_update_err) << Arg::Str(string->str_data)); } const dsql_nod* temp = rse->nod_arg[e_rse_streams]; @@ -4006,11 +3968,10 @@ static dsql_ctx* pass1_cursor_context( CompiledStatement* statement, const dsql_ { if (context) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 504, - isc_arg_gds, isc_dsql_cursor_err, - isc_arg_gds, isc_dsql_cursor_rel_ambiguous, - isc_arg_string, rname->str_data, - isc_arg_string, string->str_data, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-504) << + Arg::Gds(isc_dsql_cursor_err) << + Arg::Gds(isc_dsql_cursor_rel_ambiguous) << Arg::Str(rname->str_data) << + Arg::Str(string->str_data)); } else context = candidate; @@ -4018,9 +3979,8 @@ static dsql_ctx* pass1_cursor_context( CompiledStatement* statement, const dsql_ } else if (r_node->nod_type == nod_aggregate) { // cursor with aggregation is not updatable - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 510, - isc_arg_gds, isc_dsql_cursor_update_err, - isc_arg_string, string->str_data, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-510) << + Arg::Gds(isc_dsql_cursor_update_err) << Arg::Str(string->str_data)); } // note that nod_union and nod_join will cause the error below, // as well as derived tables. Some cases deserve fixing in the future @@ -4028,11 +3988,10 @@ static dsql_ctx* pass1_cursor_context( CompiledStatement* statement, const dsql_ if (!context) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 504, - isc_arg_gds, isc_dsql_cursor_err, - isc_arg_gds, isc_dsql_cursor_rel_not_found, - isc_arg_string, rname->str_data, - isc_arg_string, string->str_data, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-504) << + Arg::Gds(isc_dsql_cursor_err) << + Arg::Gds(isc_dsql_cursor_rel_not_found) << Arg::Str(rname->str_data) << + Arg::Str(string->str_data)); } return context; @@ -4060,14 +4019,14 @@ static dsql_nod* pass1_cursor_name(CompiledStatement* statement, const dsql_str* if (!strlen(string->str_data)) { if (existence_flag) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 504, - isc_arg_gds, isc_dsql_cursor_err, - isc_arg_gds, isc_dsql_cursor_invalid, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-504) << + Arg::Gds(isc_dsql_cursor_err) << + Arg::Gds(isc_dsql_cursor_invalid)); } else { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 502, - isc_arg_gds, isc_dsql_decl_err, - isc_arg_gds, isc_dsql_cursor_invalid, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-502) << + Arg::Gds(isc_dsql_decl_err) << + Arg::Gds(isc_dsql_cursor_invalid)); } } @@ -4080,18 +4039,14 @@ static dsql_nod* pass1_cursor_name(CompiledStatement* statement, const dsql_str* } if (!cursor && existence_flag) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 504, - isc_arg_gds, isc_dsql_cursor_err, - isc_arg_gds, isc_dsql_cursor_not_found, - isc_arg_string, string->str_data, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-504) << + Arg::Gds(isc_dsql_cursor_err) << + Arg::Gds(isc_dsql_cursor_not_found) << Arg::Str(string->str_data)); } else if (cursor && !existence_flag) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 502, - isc_arg_gds, isc_dsql_decl_err, - isc_arg_gds, isc_dsql_cursor_exists, - isc_arg_string, string->str_data, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-502) << + Arg::Gds(isc_dsql_decl_err) << + Arg::Gds(isc_dsql_cursor_exists) << Arg::Str(string->str_data)); } return cursor; @@ -4125,16 +4080,13 @@ static dsql_nod* pass1_cursor_reference( CompiledStatement* statement, const dsql_sym* symbol = HSHD_lookup(statement->req_dbb, reinterpret_cast(string->str_data), - static_cast(string->str_length), SYM_cursor, - isc_arg_end); + static_cast(string->str_length), SYM_cursor, 0); if (!symbol) { // cursor is not found - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 504, - isc_arg_gds, isc_dsql_cursor_err, - isc_arg_gds, isc_dsql_cursor_not_found, - isc_arg_string, string->str_data, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-504) << + Arg::Gds(isc_dsql_cursor_err) << + Arg::Gds(isc_dsql_cursor_not_found) << Arg::Str(string->str_data)); } CompiledStatement* parent = (CompiledStatement*) symbol->sym_object; @@ -4149,9 +4101,8 @@ static dsql_nod* pass1_cursor_reference( CompiledStatement* statement, !rv_source) { // cursor is not updatable - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 510, - isc_arg_gds, isc_dsql_cursor_update_err, - isc_arg_string, string->str_data, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-510) << + Arg::Gds(isc_dsql_cursor_update_err) << Arg::Str(string->str_data)); } statement->req_parent = parent; @@ -4228,9 +4179,8 @@ static dsql_nod* pass1_dbkey( CompiledStatement* statement, dsql_nod* input) if (!context->ctx_relation) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_dbkey_from_non_table, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_dbkey_from_non_table)); } if (context->ctx_flags & CTX_null) @@ -4265,9 +4215,8 @@ static dsql_nod* pass1_dbkey( CompiledStatement* statement, dsql_nod* input) if (!context->ctx_relation) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -607, - isc_arg_gds, isc_dsql_dbkey_from_non_table, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << + Arg::Gds(isc_dsql_dbkey_from_non_table)); } if (context->ctx_flags & CTX_null) @@ -4453,9 +4402,9 @@ static dsql_nod* pass1_join_is_recursive(CompiledStatement* statement, dsql_nod* } if (leftRecursive && join_type != nod_join_inner) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_cte_outer_join, // Recursive member of CTE can''t be member of an outer join - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Recursive member of CTE can''t be member of an outer join + Arg::Gds(isc_dsql_cte_outer_join)); } bool rightRecursive = false; @@ -4475,15 +4424,15 @@ static dsql_nod* pass1_join_is_recursive(CompiledStatement* statement, dsql_nod* } if (rightRecursive && join_type != nod_join_inner) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_cte_outer_join, // Recursive member of CTE can''t be member of an outer join - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Recursive member of CTE can't be member of an outer join + Arg::Gds(isc_dsql_cte_outer_join)); } if (leftRecursive && rightRecursive) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_cte_mult_references, // Recursive member of CTE can''t reference itself more than once - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Recursive member of CTE can't reference itself more than once + Arg::Gds(isc_dsql_cte_mult_references)); } if (leftRecursive) @@ -4537,9 +4486,9 @@ static bool pass1_rse_is_recursive(CompiledStatement* statement, dsql_nod* input if (pass1_relproc_is_recursive(statement, *table)) { if (found) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_cte_mult_references, // Recursive member of CTE can''t reference itself more than once - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Recursive member of CTE can't reference itself more than once + Arg::Gds(isc_dsql_cte_mult_references)); } found = true; @@ -4554,9 +4503,9 @@ static bool pass1_rse_is_recursive(CompiledStatement* statement, dsql_nod* input if (joinBool) { if (found) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_cte_mult_references, // Recursive member of CTE can''t reference itself more than once - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Recursive member of CTE can't reference itself more than once + Arg::Gds(isc_dsql_cte_mult_references)); } found = true; @@ -4603,10 +4552,9 @@ static dsql_nod* pass1_recursive_cte(CompiledStatement* statement, dsql_nod* inp if (query->nod_type != nod_list && pass1_rse_is_recursive(statement, query)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_cte_not_a_union, // Recursive CTE (%s) must be an UNION - isc_arg_string, cte_alias->str_data, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Recursive CTE (%s) must be an UNION + Arg::Gds(isc_dsql_cte_not_a_union) << Arg::Str(cte_alias->str_data)); } // split queries list on two parts: anchor and recursive @@ -4624,40 +4572,35 @@ static dsql_nod* pass1_recursive_cte(CompiledStatement* statement, dsql_nod* inp { if (anchor_rse) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_cte_nonrecurs_after_recurs, // CTE '%s' defined non-recursive member after recursive - isc_arg_string, cte_alias->str_data, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // CTE '%s' defined non-recursive member after recursive + Arg::Gds(isc_dsql_cte_nonrecurs_after_recurs) << Arg::Str(cte_alias->str_data)); } if (rse->nod_arg[e_qry_distinct]) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_cte_wrong_clause, // Recursive member of CTE '%s' has %s clause - isc_arg_string, cte_alias->str_data, - isc_arg_string, "DISTINCT", - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Recursive member of CTE '%s' has %s clause + Arg::Gds(isc_dsql_cte_wrong_clause) << Arg::Str(cte_alias->str_data) << + Arg::Str("DISTINCT")); } if (rse->nod_arg[e_qry_group]) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_cte_wrong_clause, // Recursive member of CTE '%s' has %s clause - isc_arg_string, cte_alias->str_data, - isc_arg_string, "GROUP BY", - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Recursive member of CTE '%s' has %s clause + Arg::Gds(isc_dsql_cte_wrong_clause) << Arg::Str(cte_alias->str_data) << + Arg::Str("GROUP BY")); } if (rse->nod_arg[e_qry_having]) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_cte_wrong_clause, // Recursive member of CTE '%s' has %s clause - isc_arg_string, cte_alias->str_data, - isc_arg_string, "HAVING", - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Recursive member of CTE '%s' has %s clause + Arg::Gds(isc_dsql_cte_wrong_clause) << Arg::Str(cte_alias->str_data) << + Arg::Str("HAVING")); } // hvlad: we need also forbid any aggregate function here // but for now i have no idea how to do it simple if ((qry->nod_type == nod_list) && !(qry->nod_flags & NOD_UNION_ALL)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_cte_union_all, // Recursive members of CTE (%s) must be linked with another members via UNION ALL - isc_arg_string, cte_alias->str_data, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Recursive members of CTE (%s) must be linked with another members via UNION ALL + Arg::Gds(isc_dsql_cte_union_all) << Arg::Str(cte_alias->str_data)); } if (!recursive_rse) { recursive_rse = qry; @@ -4679,10 +4622,9 @@ static dsql_nod* pass1_recursive_cte(CompiledStatement* statement, dsql_nod* inp return input; } if (!anchor_rse) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_cte_miss_nonrecursive, // Non-recursive member is missing in CTE '%s' - isc_arg_string, cte_alias->str_data, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Non-recursive member is missing in CTE '%s' + Arg::Gds(isc_dsql_cte_miss_nonrecursive) << Arg::Str(cte_alias->str_data)); } qry = recursive_rse; @@ -4915,10 +4857,9 @@ static dsql_nod* pass1_derived_table(CompiledStatement* statement, dsql_nod* inp if (list->nod_count > rse->nod_arg[e_rse_items]->nod_count) errcode = isc_dsql_derived_table_more_columns; - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, errcode, - isc_arg_string, aliasname, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_command_err) << + Arg::Gds(errcode) << Arg::Str(aliasname)); } // Generate derived fields and assign alias-name to it. @@ -4982,11 +4923,10 @@ static dsql_nod* pass1_derived_table(CompiledStatement* statement, dsql_nod* inp { // no column name specified for column number %d in derived table %s - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_dsql_derived_field_unnamed, - isc_arg_number, SLONG(count + 1), - isc_arg_string, aliasname, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_command_err) << + Arg::Gds(isc_dsql_derived_field_unnamed) << Arg::Num(count + 1) << + Arg::Str(aliasname)); } } @@ -5002,11 +4942,10 @@ static dsql_nod* pass1_derived_table(CompiledStatement* statement, dsql_nod* inp reinterpret_cast(name2->str_data))) { // column %s was specified multiple times for derived table %s - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_dsql_derived_field_dup_name, - isc_arg_string, name1->str_data, - isc_arg_string, aliasname, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_command_err) << + Arg::Gds(isc_dsql_derived_field_dup_name) << Arg::Str(name1->str_data) << + Arg::Str(aliasname)); } } } @@ -5133,9 +5072,9 @@ static void pass1_expand_select_node(CompiledStatement* statement, dsql_nod* nod // select-item should always be a derived field! if (select_item->nod_type != nod_derived_field) { // Internal dsql error: alias type expected by pass1_expand_select_node - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_dsql_derived_alias_select, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_command_err) << + Arg::Gds(isc_dsql_derived_alias_select)); } dsql_ctx* context = (dsql_ctx*) select_item->nod_arg[e_derived_field_context]; @@ -5406,16 +5345,12 @@ static dsql_nod* pass1_field( CompiledStatement* statement, dsql_nod* input, field->fld_dtype == dtype_sql_time || field->fld_dtype == dtype_int64)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 206, - isc_arg_gds, isc_dsql_field_err, - isc_arg_gds, isc_random, - isc_arg_string, field->fld_name.c_str(), - isc_arg_gds, - isc_sql_dialect_datatype_unsupport, - isc_arg_number, (SLONG) statement->req_client_dialect, - isc_arg_string, - DSC_dtype_tostring(static_cast(field->fld_dtype)), - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-206) << + Arg::Gds(isc_dsql_field_err) << + Arg::Gds(isc_random) << Arg::Str(field->fld_name) << + Arg::Gds(isc_sql_dialect_datatype_unsupport) << + Arg::Num(statement->req_client_dialect) << + Arg::Str(DSC_dtype_tostring(static_cast(field->fld_dtype)))); return NULL; } @@ -5511,9 +5446,9 @@ static dsql_nod* pass1_field( CompiledStatement* statement, dsql_nod* input, } else { // Internal dsql error: alias type expected by pass1_field - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_dsql_derived_alias_field, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_command_err) << + Arg::Gds(isc_dsql_derived_alias_field)); } } @@ -6176,9 +6111,9 @@ static dsql_nod* pass1_group_by_list(CompiledStatement* statement, dsql_nod* inp if (input->nod_count > MAX_SORT_ITEMS) // sort and group have the same limit for now. { // cannot group on more than 255 items - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_dsql_max_group_items, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_command_err) << + Arg::Gds(isc_dsql_max_group_items)); } DsqlNodStack stack; @@ -6201,9 +6136,8 @@ static dsql_nod* pass1_group_by_list(CompiledStatement* statement, dsql_nod* inp (position > (ULONG) selectList->nod_count)) { // Invalid column position used in the GROUP BY clause - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_column_pos_err, - isc_arg_string, "GROUP BY", isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_column_pos_err) << Arg::Str("GROUP BY")); } frnode = pass1_node_psql(statement, selectList->nod_arg[position - 1], false); } @@ -6323,8 +6257,8 @@ static dsql_nod* pass1_insert( CompiledStatement* statement, dsql_nod* input, bo if (values) { if (fields->nod_count != values->nod_count) { // count of column list and value list don't match - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 804, - isc_arg_gds, isc_dsql_var_count_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-804) << + Arg::Gds(isc_dsql_var_count_err)); } dsql_nod** ptr = fields->nod_arg; @@ -6456,11 +6390,8 @@ static dsql_nod* pass1_join(CompiledStatement* statement, dsql_nod* input) { if (statement->req_client_dialect < SQL_DIALECT_V6) { - ERRD_post( - isc_sqlerr, isc_arg_number, (SLONG) -901, - isc_arg_gds, isc_dsql_unsupp_feature_dialect, - isc_arg_number, statement->req_client_dialect, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) << + Arg::Gds(isc_dsql_unsupp_feature_dialect) << Arg::Num(statement->req_client_dialect)); } DsqlNodStack leftStack, rightStack; @@ -6540,11 +6471,8 @@ static dsql_nod* pass1_join(CompiledStatement* statement, dsql_nod* input) size_t pos; if (usedColumns.find(fldName->str_data, pos)) { - ERRD_post( - isc_sqlerr, isc_arg_number, (SLONG) -104, - isc_arg_gds, isc_dsql_col_more_than_once_using, - isc_arg_string, fldName->str_data, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_col_more_than_once_using) << Arg::Str(fldName->str_data)); } else usedColumns.insert(pos, fldName->str_data); @@ -6726,11 +6654,10 @@ static dsql_nod* pass1_label(CompiledStatement* statement, dsql_nod* input) } else if (label) { // ERROR: Label %s is not found in the current scope - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_dsql_invalid_label, - isc_arg_string, string->str_data, - isc_arg_string, "is not found", isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_command_err) << + Arg::Gds(isc_dsql_invalid_label) << Arg::Str(string->str_data) << + Arg::Str("is not found")); } else { // break the current loop @@ -6740,11 +6667,10 @@ static dsql_nod* pass1_label(CompiledStatement* statement, dsql_nod* input) else { if (position > 0) { // ERROR: Label %s already exists in the current scope - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_dsql_invalid_label, - isc_arg_string, string->str_data, - isc_arg_string, "already exists", isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_command_err) << + Arg::Gds(isc_dsql_invalid_label) << Arg::Str(string->str_data) << + Arg::Str("already exists")); } else { // store label name, if specified @@ -6864,13 +6790,10 @@ static dsql_nod* pass1_lookup_alias(CompiledStatement* statement, const dsql_str } strcat(buffer2, " in the select list with name"); - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -204, - isc_arg_gds, isc_dsql_ambiguous_field_name, - isc_arg_string, buffer1, - isc_arg_string, buffer2, - isc_arg_gds, isc_random, - isc_arg_string, name->str_data, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << + Arg::Gds(isc_dsql_ambiguous_field_name) << Arg::Str(buffer1) << + Arg::Str(buffer2) << + Arg::Gds(isc_random) << Arg::Str(name->str_data)); } returnNode = matchingNode; } @@ -7500,10 +7423,9 @@ static dsql_nod* pass1_alias_list(CompiledStatement* statement, dsql_nod* alias_ if (!context) { // there is no alias or table named %s at this scope level. - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_dsql_no_relation_alias, - isc_arg_string, ((dsql_str*) *arg)->str_data, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_command_err) << + Arg::Gds(isc_dsql_no_relation_alias) << Arg::Str(((dsql_str*) *arg)->str_data)); } return (dsql_nod*) context; @@ -7571,10 +7493,9 @@ static dsql_ctx* pass1_alias(CompiledStatement* statement, DsqlContextStack& sta { if (relation_context) { /* the table %s is referenced twice; use aliases to differentiate */ - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_dsql_self_join, - isc_arg_string, alias->str_data, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_command_err) << + Arg::Gds(isc_dsql_self_join) << Arg::Str(alias->str_data)); } relation_context = context; } @@ -7683,9 +7604,10 @@ static dsql_nod* pass1_returning(CompiledStatement* statement, const dsql_nod* i if (!statement->isPsql() && target) { // RETURNING INTO is not allowed syntax for DSQL - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -104, - isc_arg_gds, isc_token_err, // Token unknown - isc_arg_gds, isc_random, isc_arg_string, "INTO", isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Token unknown + Arg::Gds(isc_token_err) << + Arg::Gds(isc_random) << Arg::Str("INTO")); } else if (statement->isPsql() && !target) { @@ -7693,11 +7615,10 @@ static dsql_nod* pass1_returning(CompiledStatement* statement, const dsql_nod* i const dsql_nod* errSrc = input->nod_arg[e_ret_source]; fb_assert(errSrc->nod_type == nod_list); // RETURNING without INTO is not allowed for PSQL - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -104, - isc_arg_gds, isc_command_end_err2, // Unexpected end of command - isc_arg_number, (SLONG) errSrc->nod_line, - isc_arg_number, (SLONG) errSrc->nod_column, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Unexpected end of command + Arg::Gds(isc_command_end_err2) << Arg::Num(errSrc->nod_line) << + Arg::Num(errSrc->nod_column)); } const int count = source->nod_count; @@ -7710,8 +7631,8 @@ static dsql_nod* pass1_returning(CompiledStatement* statement, const dsql_nod* i fb_assert(statement->isPsql()); if (count != target->nod_count) { // count of column list and value list don't match - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -804, - isc_arg_gds, isc_dsql_var_count_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-804) << + Arg::Gds(isc_dsql_var_count_err)); } dsql_nod** src = source->nod_arg; @@ -7861,9 +7782,10 @@ static dsql_nod* pass1_rse_impl( CompiledStatement* statement, dsql_nod* input, fb_assert(input->nod_count > 1); if (update_lock) - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, isc_arg_gds, - isc_token_err, // Token unknown - isc_arg_gds, isc_random, isc_arg_string, "WITH LOCK", isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Token unknown + Arg::Gds(isc_token_err) << + Arg::Gds(isc_random) << Arg::Str("WITH LOCK")); return pass1_union(statement, input, order, rows, flags); } @@ -7885,9 +7807,10 @@ static dsql_nod* pass1_rse_impl( CompiledStatement* statement, dsql_nod* input, !(relation = ((dsql_ctx*)list->nod_arg[0]->nod_arg[e_rel_context])->ctx_relation) || (relation->rel_flags & REL_view) || (relation->rel_flags & REL_external) )) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_token_err, // Token unknown - isc_arg_gds, isc_random, isc_arg_string, "WITH LOCK", isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Token unknown + Arg::Gds(isc_token_err) << + Arg::Gds(isc_random) << Arg::Str("WITH LOCK")); } } // end scope block @@ -7895,9 +7818,10 @@ static dsql_nod* pass1_rse_impl( CompiledStatement* statement, dsql_nod* input, dsql_nod* node = input->nod_arg[e_qry_limit]; if (node && rows) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_token_err, // Token unknown - isc_arg_gds, isc_random, isc_arg_string, "ROWS", isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Token unknown + Arg::Gds(isc_token_err) << + Arg::Gds(isc_random) << Arg::Str("ROWS")); } else if (node || (node = rows) ) { const int length_index = rows ? e_rows_length : e_limit_length; @@ -7928,8 +7852,8 @@ static dsql_nod* pass1_rse_impl( CompiledStatement* statement, dsql_nod* input, statement->req_scope_level, FIELD_MATCH_TYPE_EQUAL, true)) { // Cannot use an aggregate in a WHERE clause, use HAVING instead - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_agg_where_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_agg_where_err)); } } @@ -7949,9 +7873,9 @@ static dsql_nod* pass1_rse_impl( CompiledStatement* statement, dsql_nod* input, if ((flags & NOD_SELECT_EXPR_VALUE) && (!selectList || selectList->nod_count > 1)) { // More than one column (or asterisk) is specified in column_singleton - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_dsql_count_mismatch, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_command_err) << + Arg::Gds(isc_dsql_count_mismatch)); } // Pass select list @@ -7980,9 +7904,10 @@ static dsql_nod* pass1_rse_impl( CompiledStatement* statement, dsql_nod* input, // dimitr: don't allow WITH LOCK for aggregates if (update_lock) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_token_err, // Token unknown - isc_arg_gds, isc_random, isc_arg_string, "WITH LOCK", isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Token unknown + Arg::Gds(isc_token_err) << + Arg::Gds(isc_random) << Arg::Str("WITH LOCK")); } parent_context = FB_NEW(*tdbb->getDefaultPool()) @@ -8028,8 +7953,8 @@ static dsql_nod* pass1_rse_impl( CompiledStatement* statement, dsql_nod* input, statement->req_scope_level, FIELD_MATCH_TYPE_LOWER_EQUAL, true)) { // Cannot use an aggregate in a GROUP BY clause - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_agg_group_err, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_agg_group_err)); } } @@ -8040,9 +7965,10 @@ static dsql_nod* pass1_rse_impl( CompiledStatement* statement, dsql_nod* input, // sub-selects a new context number should be generated if (input->nod_arg[e_qry_distinct]) { if (update_lock) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_token_err, // Token unknown - isc_arg_gds, isc_random, isc_arg_string, "WITH LOCK", isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Token unknown + Arg::Gds(isc_token_err) << + Arg::Gds(isc_random) << Arg::Str("WITH LOCK")); } ++statement->req_in_select_list; @@ -8073,11 +7999,10 @@ static dsql_nod* pass1_rse_impl( CompiledStatement* statement, dsql_nod* input, if (invalid_reference(parent_context, *ptr, aggregate->nod_arg[e_agg_group], false, false)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_agg_column_err, - isc_arg_string, "select list", isc_arg_end); - // Invalid expression in the select list - // (not contained in either an aggregate or the GROUP BY clause) + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Invalid expression in the select list + // (not contained in either an aggregate or the GROUP BY clause) + Arg::Gds(isc_dsql_agg_column_err) << Arg::Str("select list")); } } } // end scope block @@ -8098,11 +8023,10 @@ static dsql_nod* pass1_rse_impl( CompiledStatement* statement, dsql_nod* input, if (invalid_reference(parent_context, *ptr, aggregate->nod_arg[e_agg_group], false, false)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_agg_column_err, - isc_arg_string, "ORDER BY clause", isc_arg_end); - // Invalid expression in the ORDER BY clause - // (not contained in either an aggregate or the GROUP BY clause) + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Invalid expression in the ORDER BY clause + // (not contained in either an aggregate or the GROUP BY clause) + Arg::Gds(isc_dsql_agg_column_err) << Arg::Str("ORDER BY clause")); } } } @@ -8133,11 +8057,10 @@ static dsql_nod* pass1_rse_impl( CompiledStatement* statement, dsql_nod* input, if (invalid_reference(parent_context, *ptr, aggregate->nod_arg[e_agg_group], false, false)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_agg_having_err, - isc_arg_string, "HAVING clause", isc_arg_end); - // Invalid expression in the HAVING clause - // (neither an aggregate nor contained in the GROUP BY clause) + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Invalid expression in the HAVING clause + // (neither an aggregate nor contained in the GROUP BY clause) + Arg::Gds(isc_dsql_agg_having_err) << Arg::Str("HAVING clause")); } } @@ -8147,9 +8070,9 @@ static dsql_nod* pass1_rse_impl( CompiledStatement* statement, dsql_nod* input, if (invalid_reference(parent_rse->nod_arg[e_rse_boolean], aggregate->nod_arg[e_agg_group])) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_field_ref_err, isc_arg_end); - // invalid field reference + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // invalid field reference + Arg::Gds(isc_field_ref_err)); } } #endif @@ -8387,17 +8310,19 @@ static dsql_nod* pass1_sort( CompiledStatement* statement, dsql_nod* input, dsql DEV_BLKCHK(selectList, dsql_type_nod); if (input->nod_type != nod_list) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, isc_arg_gds, - isc_dsql_command_err, isc_arg_gds, isc_order_by_err, isc_arg_end); - // invalid ORDER BY clause + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_command_err) << + // invalid ORDER BY clause + Arg::Gds(isc_order_by_err)); } if (input->nod_count > MAX_SORT_ITEMS) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, isc_arg_gds, - isc_dsql_command_err, isc_arg_gds, isc_order_by_err, - isc_arg_gds, isc_dsql_max_sort_items, isc_arg_end); - // invalid ORDER BY clause, cannot sort on more than 255 items + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_command_err) << + Arg::Gds(isc_order_by_err) << + // invalid ORDER BY clause, cannot sort on more than 255 items + Arg::Gds(isc_dsql_max_sort_items)); } // Node is simply to be rebuilt -- just recurse merrily @@ -8410,9 +8335,10 @@ static dsql_nod* pass1_sort( CompiledStatement* statement, dsql_nod* input, dsql DEV_BLKCHK(input->nod_arg[sortloop], dsql_type_nod); dsql_nod* node1 = input->nod_arg[sortloop]; if (node1->nod_type != nod_order) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, isc_arg_gds, - isc_dsql_command_err, isc_arg_gds, isc_order_by_err, isc_arg_end); - // invalid ORDER BY clause + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_command_err) << + // invalid ORDER BY clause + Arg::Gds(isc_order_by_err)); } dsql_nod* node2 = MAKE_node(nod_order, e_order_count); node2->nod_arg[e_order_flag] = node1->nod_arg[e_order_flag]; // asc/desc flag @@ -8440,10 +8366,9 @@ static dsql_nod* pass1_sort( CompiledStatement* statement, dsql_nod* input, dsql if ((position < 1) || !selectList || (position > (ULONG) selectList->nod_count)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_column_pos_err, - isc_arg_string, "ORDER BY", isc_arg_end); - // Invalid column position used in the ORDER BY clause + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // Invalid column position used in the ORDER BY clause + Arg::Gds(isc_dsql_column_pos_err) << Arg::Str("ORDER BY")); } // substitute ordinal with appropriate field node1 = pass1_node_psql(statement, selectList->nod_arg[position - 1], false); @@ -8557,10 +8482,9 @@ static dsql_nod* pass1_udf( CompiledStatement* statement, dsql_nod* input) DEV_BLKCHK(name, dsql_type_str); dsql_udf* userFunc = METD_get_function(statement, name); if (!userFunc) - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 804, - isc_arg_gds, isc_dsql_function_err, - isc_arg_gds, isc_random, - isc_arg_string, name->str_data, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-804) << + Arg::Gds(isc_dsql_function_err) << + Arg::Gds(isc_random) << Arg::Str(name->str_data)); dsql_nod* node = MAKE_node(nod_udf, input->nod_count); node->nod_arg[0] = (dsql_nod*) userFunc; @@ -8700,10 +8624,10 @@ static dsql_nod* pass1_union( CompiledStatement* statement, dsql_nod* input, for (int i = 1; i < union_node->nod_count; i++) { const dsql_nod* nod1 = union_node->nod_arg[i]->nod_arg[e_rse_items]; if (items->nod_count != nod1->nod_count) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_dsql_count_mismatch, // overload of msg - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_command_err) << + // overload of msg + Arg::Gds(isc_dsql_count_mismatch)); } } } // end scope block @@ -8796,17 +8720,17 @@ static dsql_nod* pass1_union( CompiledStatement* statement, dsql_nod* input, if (position->nod_type != nod_constant || position->nod_desc.dsc_dtype != dtype_long) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_order_by_err, // invalid ORDER BY clause. - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_command_err) << + // invalid ORDER BY clause. + Arg::Gds(isc_order_by_err)); } const SLONG number = position->getSlong(); if (number < 1 || number > union_items->nod_count) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_order_by_err, // invalid ORDER BY clause. - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_command_err) << + // invalid ORDER BY clause. + Arg::Gds(isc_order_by_err)); } // make a new order node pointing at the Nth item in the select list. @@ -8878,9 +8802,9 @@ static void pass1_union_auto_cast(dsql_nod* input, const dsc& desc, { if ((position < 0) || (position >= input->nod_count)) { // Internal dsql error: column position out of range in pass1_union_auto_cast - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_command_err, - isc_arg_gds, isc_dsql_auto_field_bad_pos, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_command_err) << + Arg::Gds(isc_dsql_auto_field_bad_pos)); } else { dsql_nod* select_item = input->nod_arg[position]; @@ -9326,7 +9250,7 @@ static dsql_nod* pass1_update_or_insert(CompiledStatement* statement, dsql_nod* if (base_rel) base_name = MAKE_cstring(base_rel->rel_name.c_str()); else - ERRD_post(isc_upd_ins_with_complex_view, isc_arg_end); + ERRD_post(Arg::Gds(isc_upd_ins_with_complex_view)); } dsql_nod* matching = input->nod_arg[e_upi_matching]; @@ -9354,9 +9278,7 @@ static dsql_nod* pass1_update_or_insert(CompiledStatement* statement, dsql_nod* if (!matching) { - ERRD_post(isc_primary_key_required, - isc_arg_string, base_name->str_data, - isc_arg_end); + ERRD_post(Arg::Gds(isc_primary_key_required) << Arg::Str(base_name->str_data)); } } @@ -9438,12 +9360,10 @@ static dsql_nod* pass1_update_or_insert(CompiledStatement* statement, dsql_nod* if (match_count != matching->nod_count) { if (input->nod_arg[e_upi_matching]) - ERRD_post(isc_upd_ins_doesnt_match_matching, isc_arg_end); + ERRD_post(Arg::Gds(isc_upd_ins_doesnt_match_matching)); else { - ERRD_post(isc_upd_ins_doesnt_match_pk, - isc_arg_string, base_name->str_data, - isc_arg_end); + ERRD_post(Arg::Gds(isc_upd_ins_doesnt_match_pk) << Arg::Str(base_name->str_data)); } } @@ -10321,12 +10241,11 @@ static bool set_parameter_type(CompiledStatement* statement, dsql_nod* in_node, // to be outsise range can be worse. if (parameter->par_desc.dsc_length > MAX_COLUMN_SIZE - sizeof(USHORT)) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) -204, - //isc_arg_gds, isc_dsql_datatype_err, - isc_arg_gds, isc_imp_exc, - //isc_arg_gds, isc_field_name, - //isc_arg_string, parameter->par_name, - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << + //Arg::Gds(isc_dsql_datatype_err) + Arg::Gds(isc_imp_exc) + //Arg::Gds(isc_field_name) << Arg::Str(parameter->par_name) + ); } parameter->par_desc.dsc_length += sizeof(USHORT); @@ -10546,9 +10465,9 @@ void CompiledStatement::addCTEs(dsql_nod* with) fb_assert(with->nod_type == nod_with); if (req_ctes.getCount()) { - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_cte_nested_with, // WITH clause can't be nested - isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + // WITH clause can't be nested + Arg::Gds(isc_dsql_cte_nested_with)); } if (with->nod_flags & NOD_UNION_RECURSIVE) @@ -10609,9 +10528,8 @@ void CompiledStatement::checkUnusedCTEs() const { const dsql_str* cte_name = (dsql_str*) cte->nod_arg[e_derived_table_alias]; - ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104, - isc_arg_gds, isc_dsql_cte_not_used, - isc_arg_string, cte_name->str_data, isc_arg_end); + ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << + Arg::Gds(isc_dsql_cte_not_used) << Arg::Str(cte_name->str_data)); } } } diff --git a/src/dsql/user_dsql.cpp b/src/dsql/user_dsql.cpp index a5b096a8dc..5334eb5992 100644 --- a/src/dsql/user_dsql.cpp +++ b/src/dsql/user_dsql.cpp @@ -45,11 +45,13 @@ #include "gen/iberror.h" #include "../common/classes/init.h" #include "../common/classes/rwlock.h" +#include "../common/StatusArg.h" #include #include #include +using namespace Firebird; enum name_type { NAME_statement = 1, @@ -99,7 +101,7 @@ static void cleanup(void*); static void cleanup_database(FB_API_HANDLE*, void*); static ISC_STATUS error(const Firebird::Exception& ex); static ISC_STATUS error(); -static void error_post(ISC_STATUS, ...); +static void error_post(const Arg::StatusVector& v); static dsql_name* lookup_name(const SCHAR*, dsql_name*); static dsql_stmt* lookup_stmt(const SCHAR*, dsql_name*, name_type); static void init(FB_API_HANDLE*); @@ -712,7 +714,7 @@ ISC_STATUS API_ROUTINE isc_embed_dsql_prepare(ISC_STATUS* user_status, statement = (dsql_stmt*) gds__alloc((SLONG) sizeof(dsql_stmt)); // FREE: by user calling isc_embed_dsql_release() if (!statement) // NOMEM: - error_post(isc_virmemexh, isc_arg_end); + error_post(Arg::Gds(isc_virmemexh)); #ifdef DEBUG_GDS_ALLOC gds_alloc_flag_unfreed((void *) statement); @@ -1267,60 +1269,12 @@ static ISC_STATUS error() // exception that it uses a different error block - one which // is local to the V3 DSQL routines... // -static void error_post(ISC_STATUS status, ...) +static void error_post(const Arg::StatusVector& v) { - va_list args; - ISC_STATUS* p; - int type; - -/* Get the addresses of the argument vector and the status vector, and do - word-wise copy. */ - - va_start(args, status); - p = UDSQL_error->dsql_status; - -// Copy first argument - - *p++ = isc_arg_gds; - *p++ = status; - -// Pick up remaining args - - while (type = va_arg(args, int)) - { - switch (*p++ = type) { - case isc_arg_gds: - *p++ = (ISC_STATUS) va_arg(args, ISC_STATUS); - break; - - case isc_arg_number: - *p++ = (ISC_STATUS) va_arg(args, SLONG); - break; - - case isc_arg_vms: - case isc_arg_unix: - case isc_arg_win32: - *p++ = va_arg(args, int); - break; - - case isc_arg_string: - case isc_arg_interpreted: - case isc_arg_sql_state: - *p++ = (ISC_STATUS)(IPTR) va_arg(args, TEXT *); - break; - - case isc_arg_cstring: - *p++ = (ISC_STATUS) va_arg(args, int); - *p++ = (ISC_STATUS)(IPTR) va_arg(args, TEXT *); - break; - } - } - - va_end(args); - *p = isc_arg_end; + // Save status vector in appropriate place + v.copyTo(UDSQL_error->dsql_status); // Give up whatever we were doing and return to the user. - Firebird::status_exception::raise(UDSQL_error->dsql_status); } @@ -1393,7 +1347,7 @@ static dsql_name* insert_name(const TEXT* symbol_name, dsql_name** list_ptr, dsq dsql_name* name = (dsql_name*) gds__alloc((SLONG) sizeof(dsql_name) + l); // FREE: by exit handler cleanup() or database_cleanup() if (!name) // NOMEM: - error_post(isc_virmemexh, isc_arg_end); + error_post(Arg::Gds(isc_virmemexh)); name->name_stmt = stmt; name->name_length = l; memcpy(name->name_symbol, symbol_name, l); @@ -1451,16 +1405,15 @@ static dsql_stmt* lookup_stmt(const TEXT* name, dsql_name* list, name_type type) return found->name_stmt; if (type == NAME_statement) { - error_post(isc_dsql_error, - isc_arg_gds, isc_sqlerr, isc_arg_number, (SLONG) - 518, - isc_arg_gds, isc_dsql_request_err, isc_arg_end); + error_post(Arg::Gds(isc_dsql_error) << + Arg::Gds(isc_sqlerr) << Arg::Num(-518) << + Arg::Gds(isc_dsql_request_err)); } else { - error_post(isc_dsql_error, - isc_arg_gds, isc_sqlerr, isc_arg_number, (SLONG) - 504, - isc_arg_gds, isc_dsql_cursor_err, - isc_arg_gds, isc_dsql_cursor_not_found, - isc_arg_string, name, isc_arg_end); + error_post(Arg::Gds(isc_dsql_error) << + Arg::Gds(isc_sqlerr) << Arg::Num(-504) << + Arg::Gds(isc_dsql_cursor_err) << + Arg::Gds(isc_dsql_cursor_not_found) << Arg::Str(name)); } return NULL; }