Skip to content

Commit

Permalink
Fixed CORE-2408 - isql -ex puts default values of sp parameters befor…
Browse files Browse the repository at this point in the history
…e the NOT NULL and COLLATE flags
  • Loading branch information
asfernandes committed Apr 8, 2009
1 parent 536143d commit 8c458e4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 25 deletions.
29 changes: 16 additions & 13 deletions src/isql/extract.epp
Expand Up @@ -421,7 +421,7 @@ int EXTRACT_list_table(const SCHAR* relation_name,
char_sets[0] = '\0';
collation = RFR.RDB$COLLATION_ID;
char_set_id = FLD.RDB$CHARACTER_SET_ID;
ISQL_get_character_sets (FLD.RDB$CHARACTER_SET_ID, 0, true, char_sets);
ISQL_get_character_sets (FLD.RDB$CHARACTER_SET_ID, 0, true, false, char_sets);
if (char_sets[0])
isqlGlob.prints(char_sets);
}
Expand Down Expand Up @@ -539,7 +539,7 @@ int EXTRACT_list_table(const SCHAR* relation_name,
if (!FLD.RDB$CHARACTER_SET_ID.NULL)
char_set_id = FLD.RDB$CHARACTER_SET_ID;
if ((char_set_id != default_char_set_id) || collation)
ISQL_get_character_sets (char_set_id, 0, false, char_sets);
ISQL_get_character_sets (char_set_id, 0, false, false, char_sets);
if (char_sets[0])
isqlGlob.prints(char_sets);
// CVC: Someone deleted the code that checks intchar when handling collations
Expand Down Expand Up @@ -598,7 +598,7 @@ int EXTRACT_list_table(const SCHAR* relation_name,
if (collation)
{
char_sets[0] = '\0';
ISQL_get_character_sets (char_set_id, collation, true, char_sets);
ISQL_get_character_sets (char_set_id, collation, true, false, char_sets);
if (char_sets[0])
isqlGlob.prints(char_sets);
}
Expand Down Expand Up @@ -722,7 +722,7 @@ static void get_procedure_args(const char* proc_name)
* extract file
*
**************************************/
SCHAR char_sets[86];
SCHAR char_sets[95];

// query to retrieve the parameters.

Expand Down Expand Up @@ -862,10 +862,13 @@ static void get_procedure_args(const char* proc_name)
!prm_collation_id_null && prm_collation_id)
{
char_sets[0] = '\0';
ISQL_get_character_sets(FLD.RDB$CHARACTER_SET_ID, prm_collation_id, true, char_sets);
ISQL_get_character_sets(FLD.RDB$CHARACTER_SET_ID, prm_collation_id, true,
!prm_null_flag_null && prm_null_flag, char_sets);
if (char_sets[0])
isqlGlob.prints(char_sets);
}
else if (!prm_null_flag_null && prm_null_flag)
isqlGlob.printf(" NOT NULL");

if (ptype == 0) // input, try to extract default and make Vlad happy.
{
Expand Down Expand Up @@ -973,10 +976,13 @@ static void get_procedure_args(const char* proc_name)
if (FLD.RDB$CHARACTER_SET_ID.NULL)
FLD.RDB$CHARACTER_SET_ID = 0;

ISQL_get_character_sets (FLD.RDB$CHARACTER_SET_ID, collation, false, char_sets);
ISQL_get_character_sets (FLD.RDB$CHARACTER_SET_ID, collation, false,
!prm_null_flag_null && prm_null_flag, char_sets);
if (char_sets[0])
isqlGlob.prints(char_sets);
}
else if (!prm_null_flag_null && prm_null_flag)
isqlGlob.printf(" NOT NULL");

if (ptype == 0) // input, try to extract default and make Vlad happy.
{
Expand All @@ -992,9 +998,6 @@ static void get_procedure_args(const char* proc_name)
}
}
}

if (!prm_null_flag_null && prm_null_flag)
isqlGlob.printf(" NOT NULL");
END_FOR
ON_ERROR
ISQL_errmsg(gds_status);
Expand Down Expand Up @@ -1991,7 +1994,7 @@ static void list_domain_table(const SCHAR* table_name, SSHORT default_char_set_i
if ((FLD.RDB$CHARACTER_SET_ID != default_char_set_id) ||
(!FLD.RDB$COLLATION_ID.NULL && FLD.RDB$COLLATION_ID != 0))
{
ISQL_get_character_sets (FLD.RDB$CHARACTER_SET_ID, 0, false, char_sets);
ISQL_get_character_sets (FLD.RDB$CHARACTER_SET_ID, 0, false, false, char_sets);
}
if (char_sets[0])
isqlGlob.prints(char_sets);
Expand Down Expand Up @@ -2024,7 +2027,7 @@ static void list_domain_table(const SCHAR* table_name, SSHORT default_char_set_i
if (!FLD.RDB$COLLATION_ID.NULL && FLD.RDB$COLLATION_ID != 0)
{
char_sets[0] = 0;
ISQL_get_character_sets (FLD.RDB$CHARACTER_SET_ID, FLD.RDB$COLLATION_ID, true, char_sets);
ISQL_get_character_sets (FLD.RDB$CHARACTER_SET_ID, FLD.RDB$COLLATION_ID, true, false, char_sets);
if (char_sets[0])
isqlGlob.prints(char_sets);
}
Expand Down Expand Up @@ -2172,7 +2175,7 @@ static void list_domains(SSHORT default_char_set_id)
if ((FLD.RDB$CHARACTER_SET_ID != default_char_set_id) ||
(!FLD.RDB$COLLATION_ID.NULL && FLD.RDB$COLLATION_ID != 0))
{
ISQL_get_character_sets (FLD.RDB$CHARACTER_SET_ID, 0, false, char_sets);
ISQL_get_character_sets (FLD.RDB$CHARACTER_SET_ID, 0, false, false, char_sets);
}
if (char_sets[0])
isqlGlob.prints(char_sets);
Expand Down Expand Up @@ -2205,7 +2208,7 @@ static void list_domains(SSHORT default_char_set_id)
if (!FLD.RDB$COLLATION_ID.NULL && FLD.RDB$COLLATION_ID != 0)
{
char_sets[0] = 0;
ISQL_get_character_sets (FLD.RDB$CHARACTER_SET_ID, FLD.RDB$COLLATION_ID, true, char_sets);
ISQL_get_character_sets (FLD.RDB$CHARACTER_SET_ID, FLD.RDB$COLLATION_ID, true, false, char_sets);
if (char_sets[0])
isqlGlob.prints(char_sets);
}
Expand Down
12 changes: 7 additions & 5 deletions src/isql/isql.epp
Expand Up @@ -1190,6 +1190,7 @@ void ISQL_get_character_sets(
SSHORT char_set_id,
SSHORT collation,
bool collate_only,
bool not_null,
TEXT* string)
{
/**************************************
Expand All @@ -1205,6 +1206,7 @@ void ISQL_get_character_sets(
bool found = false;
#endif

const char* notNullStr = not_null ? " NOT NULL" : "";
string[0] = 0;

// Transaction for all frontend commands
Expand Down Expand Up @@ -1233,13 +1235,13 @@ void ISQL_get_character_sets(
// Is specified collation the default collation for character set?
if (strcmp (CST.RDB$DEFAULT_COLLATE_NAME, COL.RDB$COLLATION_NAME) == 0) {
if (!collate_only)
sprintf (string, " CHARACTER SET %s", CST.RDB$CHARACTER_SET_NAME);
sprintf (string, " CHARACTER SET%s %s", CST.RDB$CHARACTER_SET_NAME, notNullStr);
}
else if (collate_only)
sprintf (string, " COLLATE %s", COL.RDB$COLLATION_NAME);
sprintf (string, "%s COLLATE %s", notNullStr, COL.RDB$COLLATION_NAME);
else
sprintf (string, " CHARACTER SET %s COLLATE %s",
CST.RDB$CHARACTER_SET_NAME, COL.RDB$COLLATION_NAME);
sprintf (string, " CHARACTER SET %s%s COLLATE %s",
CST.RDB$CHARACTER_SET_NAME, notNullStr, COL.RDB$COLLATION_NAME);
END_FOR
ON_ERROR
ISQL_errmsg(isc_status);
Expand All @@ -1264,7 +1266,7 @@ void ISQL_get_character_sets(
#endif
fb_utils::exact_name(CST.RDB$CHARACTER_SET_NAME);

sprintf (string, " CHARACTER SET %s", CST.RDB$CHARACTER_SET_NAME);
sprintf (string, " CHARACTER SET %s%s", CST.RDB$CHARACTER_SET_NAME, notNullStr);
END_FOR
ON_ERROR
ISQL_errmsg(isc_status);
Expand Down
2 changes: 1 addition & 1 deletion src/isql/isql_proto.h
Expand Up @@ -46,7 +46,7 @@ void ISQL_exit_db();
//int ISQL_extract(TEXT*, int, FILE*, FILE*, FILE*);
int ISQL_frontend_command(TEXT*, FILE*, FILE*, FILE*);
bool ISQL_get_base_column_null_flag(const TEXT*, const SSHORT, const TEXT*);
void ISQL_get_character_sets(SSHORT, SSHORT, bool, TEXT*);
void ISQL_get_character_sets(SSHORT, SSHORT, bool, bool, TEXT*);
SSHORT ISQL_get_default_char_set_id();
void ISQL_get_default_source(const TEXT*, TEXT*, ISC_QUAD*);
SSHORT ISQL_get_field_length(const TEXT*);
Expand Down
12 changes: 6 additions & 6 deletions src/isql/show.epp
Expand Up @@ -1841,11 +1841,11 @@ static void show_charsets(
char_sets[0] = 0;
if ((char_set_id != default_char_set_id) || collation) {
if (show_charset && !show_collation)
ISQL_get_character_sets(char_set_id, 0, false, char_sets);
ISQL_get_character_sets(char_set_id, 0, false, false, char_sets);
else if (!show_charset && show_collation)
ISQL_get_character_sets(char_set_id, collation, true, char_sets);
ISQL_get_character_sets(char_set_id, collation, true, false, char_sets);
else
ISQL_get_character_sets(char_set_id, collation, false, char_sets);
ISQL_get_character_sets(char_set_id, collation, false, false, char_sets);
}
if (char_sets[0]) {
if (doIndent)
Expand Down Expand Up @@ -1947,11 +1947,11 @@ static void show_proc_charsets(
if ((char_set_id != default_char_set_id) || collation)
{
if (show_charset && !show_collation)
ISQL_get_character_sets(char_set_id, 0, false, char_sets);
ISQL_get_character_sets(char_set_id, 0, false, false, char_sets);
else if (!show_charset && show_collation)
ISQL_get_character_sets(char_set_id, collation, true, char_sets);
ISQL_get_character_sets(char_set_id, collation, true, false, char_sets);
else
ISQL_get_character_sets(char_set_id, collation, false, char_sets);
ISQL_get_character_sets(char_set_id, collation, false, false, char_sets);
}

if (char_sets[0])
Expand Down

0 comments on commit 8c458e4

Please sign in to comment.