Skip to content

Commit

Permalink
Fixed CORE-4610: Add a tag name to diagnostics when trasliteration er…
Browse files Browse the repository at this point in the history
…rors in Parameter Block values occur
  • Loading branch information
AlexPeshkoff committed Dec 30, 2014
1 parent b260c1e commit c0b4e08
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 57 deletions.
140 changes: 87 additions & 53 deletions src/common/IntlParametersBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "../common/isc_f_proto.h"
#include "../common/classes/ClumpletWriter.h"
#include "../common/UtilSvc.h"
#include "../common/StatusHolder.h"

using namespace Firebird;

Expand Down Expand Up @@ -127,84 +128,114 @@ void IntlParametersBlock::fromUtf8(ClumpletWriter& pb, UCHAR utf8Tag)

void IntlParametersBlock::processParametersBlock(ProcessString* processString, ClumpletWriter& pb)
{
for (pb.rewind(); !pb.isEof(); pb.moveNext())
const char* tagName = NULL;
try
{
UCHAR tag = pb.getClumpTag();
string s;
for (pb.rewind(); !pb.isEof(); )
{
UCHAR tag = pb.getClumpTag();
string s;

switch (checkTag(tag))
tagName = NULL;
switch (checkTag(tag, &tagName))
{
case TAG_SKIP:
pb.moveNext();
break;

case TAG_STRING:
pb.getString(s);
processString(s);
pb.deleteClumplet();
pb.insertString(tag, s);
break;

case TAG_COMMAND_LINE:
pb.getString(s);
processCommandLine(processString, s);
pb.deleteClumplet();
pb.insertString(tag, s);
break;
}
}
}
catch(const Firebird::status_exception& st)
{
LocalStatus l;
st.stuffException(&l);
if ((l.getStatus() && IStatus::FB_HAS_ERRORS) && (l.getErrors()[1] == isc_bad_conn_str) && tagName)
{
case TAG_SKIP:
break;
Arg::Gds newErrors(isc_random);
string message("Bad international character in tag ");
message += tagName;
newErrors << message;

case TAG_STRING:
pb.getString(s);
processString(s);
pb.deleteClumplet();
pb.insertString(tag, s);
break;
const ISC_STATUS* errors = l.getErrors();
newErrors << Arg::StatusVector(errors + 2); // skip isc_bad_conn_str

case TAG_COMMAND_LINE:
pb.getString(s);
processCommandLine(processString, s);
pb.deleteClumplet();
pb.insertString(tag, s);
break;
l.setErrors(newErrors.value());
status_exception::raise(&l);
}

// other case leave exception as is
throw;
}
}


IntlParametersBlock::TagType IntlDpb::checkTag(UCHAR tag)
#define FB_IPB_TAG(t) case t: if (!*tagName) *tagName = #t


IntlParametersBlock::TagType IntlDpb::checkTag(UCHAR tag, const char** tagName)
{
switch (tag)
{
case isc_dpb_user_name:
case isc_dpb_password:
case isc_dpb_sql_role_name:
case isc_dpb_trusted_auth:
case isc_dpb_trusted_role:
case isc_dpb_working_directory:
case isc_dpb_set_db_charset:
case isc_dpb_process_name:
case isc_dpb_host_name:
case isc_dpb_os_user:
FB_IPB_TAG(isc_dpb_user_name);
FB_IPB_TAG(isc_dpb_password);
FB_IPB_TAG(isc_dpb_sql_role_name);
FB_IPB_TAG(isc_dpb_trusted_auth);
FB_IPB_TAG(isc_dpb_trusted_role);
FB_IPB_TAG(isc_dpb_working_directory);
FB_IPB_TAG(isc_dpb_set_db_charset);
FB_IPB_TAG(isc_dpb_process_name);
FB_IPB_TAG(isc_dpb_host_name);
FB_IPB_TAG(isc_dpb_os_user);
return TAG_STRING;
}

return TAG_SKIP;
}


IntlParametersBlock::TagType IntlSpb::checkTag(UCHAR tag)
IntlParametersBlock::TagType IntlSpb::checkTag(UCHAR tag, const char** tagName)
{
switch (tag)
{
case isc_spb_user_name:
case isc_spb_password:
case isc_spb_sql_role_name:
case isc_spb_trusted_auth:
case isc_spb_trusted_role:
case isc_spb_process_name:
case isc_spb_expected_db:
FB_IPB_TAG(isc_spb_user_name);
FB_IPB_TAG(isc_spb_password);
FB_IPB_TAG(isc_spb_sql_role_name);
FB_IPB_TAG(isc_spb_trusted_auth);
FB_IPB_TAG(isc_spb_trusted_role);
FB_IPB_TAG(isc_spb_process_name);
FB_IPB_TAG(isc_spb_expected_db);
return TAG_STRING;

case isc_spb_command_line:
FB_IPB_TAG(isc_spb_command_line);
return TAG_COMMAND_LINE;
}

return TAG_SKIP;
}


IntlParametersBlock::TagType IntlSpbStart::checkTag(UCHAR tag)
IntlParametersBlock::TagType IntlSpbStart::checkTag(UCHAR tag, const char** tagName)
{
switch (mode)
{
case 0:
switch (tag)
{
case isc_spb_dbname:
FB_IPB_TAG(isc_spb_dbname);
return TAG_STRING;

case isc_action_svc_backup:
Expand All @@ -228,16 +259,16 @@ IntlParametersBlock::TagType IntlSpbStart::checkTag(UCHAR tag)
case isc_action_svc_restore:
switch (tag)
{
case isc_spb_bkp_file:
case isc_spb_bkp_skip_data:
FB_IPB_TAG(isc_spb_bkp_file);
FB_IPB_TAG(isc_spb_bkp_skip_data);
return TAG_STRING;
}
break;

case isc_action_svc_repair:
switch (tag)
{
case isc_spb_tra_db_path:
FB_IPB_TAG(isc_spb_tra_db_path);
return TAG_STRING;
}
break;
Expand All @@ -249,12 +280,12 @@ IntlParametersBlock::TagType IntlSpbStart::checkTag(UCHAR tag)
case isc_action_svc_display_user_adm:
switch (tag)
{
case isc_spb_sec_username:
case isc_spb_sec_password:
case isc_spb_sec_groupname:
case isc_spb_sec_firstname:
case isc_spb_sec_middlename:
case isc_spb_sec_lastname:
FB_IPB_TAG(isc_spb_sec_username);
FB_IPB_TAG(isc_spb_sec_password);
FB_IPB_TAG(isc_spb_sec_groupname);
FB_IPB_TAG(isc_spb_sec_firstname);
FB_IPB_TAG(isc_spb_sec_middlename);
FB_IPB_TAG(isc_spb_sec_lastname);
return TAG_STRING;
}
break;
Expand All @@ -263,24 +294,24 @@ IntlParametersBlock::TagType IntlSpbStart::checkTag(UCHAR tag)
case isc_action_svc_nrest:
switch (tag)
{
case isc_spb_nbk_file:
FB_IPB_TAG(isc_spb_nbk_file);
return TAG_STRING;
}
break;

case isc_action_svc_trace_start:
switch (tag)
{
case isc_spb_trc_name:
case isc_spb_trc_cfg:
FB_IPB_TAG(isc_spb_trc_name);
FB_IPB_TAG(isc_spb_trc_cfg);
return TAG_STRING;
}
break;

case isc_action_svc_db_stats:
switch (tag)
{
case isc_spb_command_line:
FB_IPB_TAG(isc_spb_command_line);
return TAG_COMMAND_LINE;
}
break;
Expand All @@ -289,4 +320,7 @@ IntlParametersBlock::TagType IntlSpbStart::checkTag(UCHAR tag)
return TAG_SKIP;
}


#undef FB_IPB_TAG

}
8 changes: 4 additions & 4 deletions src/common/IntlParametersBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class IntlParametersBlock
enum TagType { TAG_SKIP, TAG_STRING, TAG_COMMAND_LINE };
typedef void ProcessString(string& s);

virtual TagType checkTag(UCHAR tag) = 0;
virtual TagType checkTag(UCHAR tag, const char** tagName) = 0;

void toUtf8(ClumpletWriter& pb, UCHAR utf8Tag);
void fromUtf8(ClumpletWriter& pb, UCHAR utf8Tag);
Expand All @@ -53,13 +53,13 @@ class IntlParametersBlock
class IntlDpb : public IntlParametersBlock
{
public:
TagType checkTag(UCHAR tag);
TagType checkTag(UCHAR tag, const char** tagName);
};

class IntlSpb : public IntlParametersBlock
{
public:
TagType checkTag(UCHAR tag);
TagType checkTag(UCHAR tag, const char** tagName);
};

class IntlSpbStart : public IntlParametersBlock
Expand All @@ -69,7 +69,7 @@ class IntlSpbStart : public IntlParametersBlock
: mode(0)
{ }

TagType checkTag(UCHAR tag);
TagType checkTag(UCHAR tag, const char** tagName);

private:
UCHAR mode;
Expand Down

0 comments on commit c0b4e08

Please sign in to comment.