Skip to content

Commit

Permalink
[CBRD-24573] Among the SERVER information, dbname and user can be inp…
Browse files Browse the repository at this point in the history
…ut as a string type (#3989) (#4047)

http://jira.cubrid.org/browse/CBRD-24573

backport #3989
  • Loading branch information
ctshim authored Jan 17, 2023
1 parent b476890 commit bf3319c
Show file tree
Hide file tree
Showing 18 changed files with 84 additions and 9 deletions.
2 changes: 2 additions & 0 deletions msg/de_DE.utf8/cubrid.msg
Original file line number Diff line number Diff line change
Expand Up @@ -1598,6 +1598,8 @@ $set 7 MSGCAT_SET_PARSER_SYNTAX
133 Ungültige Verwendung von DROP SYNONYM.\n DROP [PRIVATE] SYNONYM [IF EXISTS] [<schema_name>.]<synonym_name>
134 Ungültige Verwendung von RENAME SYNONYM.\n RENAME [PRIVATE] SYNONYM [<schema_name>.]<old_synonym_name> {AS|TO} [<schema_name>.]<new_synonym_name>
135 Keine Optionen für ALTER SYNONYM angegeben.
136 Maximum length of a server dbname is %1$d bytes.
137 Maximum length of a server user is %1$d bytes.

$set 8 MSGCAT_SET_PARSER_SEMANTIC
1 Außer Speicher.
Expand Down
2 changes: 2 additions & 0 deletions msg/en_US.utf8/cubrid.msg
Original file line number Diff line number Diff line change
Expand Up @@ -1596,6 +1596,8 @@ $set 7 MSGCAT_SET_PARSER_SYNTAX
133 Invalid use of DROP SYNONYM.\n DROP [PRIVATE] SYNONYM [IF EXISTS] [<schema_name>.]<synonym_name>
134 Invalid use of RENAME SYNONYM.\n RENAME [PRIVATE] SYNONYM [<schema_name>.]<old_synonym_name> {AS|TO} [<schema_name>.]<new_synonym_name>
135 No options specified for ALTER SYNONYM.
136 Maximum length of a server dbname is %1$d bytes.
137 Maximum length of a server user is %1$d bytes.

$set 8 MSGCAT_SET_PARSER_SEMANTIC
1 Out of memory.
Expand Down
2 changes: 2 additions & 0 deletions msg/en_US/cubrid.msg
Original file line number Diff line number Diff line change
Expand Up @@ -1599,6 +1599,8 @@ $set 7 MSGCAT_SET_PARSER_SYNTAX
133 Invalid use of DROP SYNONYM.\n DROP [PRIVATE] SYNONYM [IF EXISTS] [<schema_name>.]<synonym_name>
134 Invalid use of RENAME SYNONYM.\n RENAME [PRIVATE] SYNONYM [<schema_name>.]<old_synonym_name> {AS|TO} [<schema_name>.]<new_synonym_name>
135 No options specified for ALTER SYNONYM.
136 Maximum length of a server dbname is %1$d bytes.
137 Maximum length of a server user is %1$d bytes.

$set 8 MSGCAT_SET_PARSER_SEMANTIC
1 Out of memory.
Expand Down
2 changes: 2 additions & 0 deletions msg/es_ES.utf8/cubrid.msg
Original file line number Diff line number Diff line change
Expand Up @@ -1598,6 +1598,8 @@ $set 7 MSGCAT_SET_PARSER_SYNTAX
133 Uso invalido de DROP SYNONYM.\n DROP [PRIVATE] SYNONYM [IF EXISTS] [<schema_name>.]<synonym_name>
134 Uso invalido de RENAME SYNONYM.\n RENAME [PRIVATE] SYNONYM [<schema_name>.]<old_synonym_name> {AS|TO} [<schema_name>.]<new_synonym_name>
135 No se han especificado opciones para ALTER SYNONYM.
136 Maximum length of a server dbname is %1$d bytes.
137 Maximum length of a server user is %1$d bytes.

$set 8 MSGCAT_SET_PARSER_SEMANTIC
1 Sin memoria.
Expand Down
2 changes: 2 additions & 0 deletions msg/fr_FR.utf8/cubrid.msg
Original file line number Diff line number Diff line change
Expand Up @@ -1598,6 +1598,8 @@ $set 7 MSGCAT_SET_PARSER_SYNTAX
133 Utilisation non valide de DROP SYNONYM.\n DROP [PRIVATE] SYNONYM [IF EXISTS] [<schema_name>.]<synonym_name>
134 Utilisation non valide de RENAME SYNONYM.\n RENAME [PRIVATE] SYNONYM [<schema_name>.]<old_synonym_name> {AS|TO} [<schema_name>.]<new_synonym_name>
135 Aucune option spécifiée pour ALTER SYNONYM.
136 Maximum length of a server dbname is %1$d bytes.
137 Maximum length of a server user is %1$d bytes.

$set 8 MSGCAT_SET_PARSER_SEMANTIC
1 Mémoire épuisée.
Expand Down
2 changes: 2 additions & 0 deletions msg/it_IT.utf8/cubrid.msg
Original file line number Diff line number Diff line change
Expand Up @@ -1598,6 +1598,8 @@ $set 7 MSGCAT_SET_PARSER_SYNTAX
133 Uso non valido di DROP SYNONYM.\n DROP [PRIVATE] SYNONYM [IF EXISTS] [<schema_name>.]<synonym_name>
134 Uso non valido di RENAME SYNONYM.\n RENAME [PRIVATE] SYNONYM [<schema_name>.]<old_synonym_name> {AS|TO} [<schema_name>.]<new_synonym_name>
135 Nessuna opzione specificata per ALTER SYNONYM.
136 Maximum length of a server dbname is %1$d bytes.
137 Maximum length of a server user is %1$d bytes.

$set 8 MSGCAT_SET_PARSER_SEMANTIC
1 Memoria esaurita.
Expand Down
2 changes: 2 additions & 0 deletions msg/ja_JP.utf8/cubrid.msg
Original file line number Diff line number Diff line change
Expand Up @@ -1598,6 +1598,8 @@ $set 7 MSGCAT_SET_PARSER_SYNTAX
133 「DROP SYNONYM」の使用が無効です。\n DROP [PRIVATE] SYNONYM [IF EXISTS] [<schema_name>.]<synonym_name>
134 「RENAME SYNONYM」の使用が無効です。\n RENAME [PRIVATE] SYNONYM [<schema_name>.]<old_synonym_name> {AS|TO} [<schema_name>.]<new_synonym_name>
135 「ALTER SYNONYM」にオプションが指定されていません。
136 Maximum length of a server dbname is %1$d bytes.
137 Maximum length of a server user is %1$d bytes.

$set 8 MSGCAT_SET_PARSER_SEMANTIC
1 メモリーが足りません。
Expand Down
2 changes: 2 additions & 0 deletions msg/km_KH.utf8/cubrid.msg
Original file line number Diff line number Diff line change
Expand Up @@ -1598,6 +1598,8 @@ $set 7 MSGCAT_SET_PARSER_SYNTAX
133 Invalid use of DROP SYNONYM.\n DROP [PRIVATE] SYNONYM [IF EXISTS] [<schema_name>.]<synonym_name>
134 Invalid use of RENAME SYNONYM.\n RENAME [PRIVATE] SYNONYM [<schema_name>.]<old_synonym_name> {AS|TO} [<schema_name>.]<new_synonym_name>
135 No options specified for ALTER SYNONYM.
136 Maximum length of a server dbname is %1$d bytes.
137 Maximum length of a server user is %1$d bytes.

$set 8 MSGCAT_SET_PARSER_SEMANTIC
1 Out of memory.
Expand Down
2 changes: 2 additions & 0 deletions msg/ko_KR.euckr/cubrid.msg
Original file line number Diff line number Diff line change
Expand Up @@ -1598,6 +1598,8 @@ $set 7 MSGCAT_SET_PARSER_SYNTAX
133 �߸��� ������ drop synonym �����Դϴ�.\n DROP [PRIVATE] SYNONYM [IF EXISTS] [<schema_name>.]<synonym_name>
134 �߸��� ������ rename synonym �����Դϴ�.\n RENAME [PRIVATE] SYNONYM [<schema_name>.]<old_synonym_name> {AS|TO} [<schema_name>.]<new_synonym_name>
135 ALTER SYNONYM�� ���� ������ �ɼ��� �����ϴ�.
136 Server�� DBNAME �ִ� ���̴� %1$d ����Ʈ�Դϴ�.
137 Server�� USER �ִ� ���̴� %1$d ����Ʈ�Դϴ�.

$set 8 MSGCAT_SET_PARSER_SEMANTIC
1 �޸𸮰� �����մϴ�
Expand Down
2 changes: 2 additions & 0 deletions msg/ko_KR.utf8/cubrid.msg
Original file line number Diff line number Diff line change
Expand Up @@ -1598,6 +1598,8 @@ $set 7 MSGCAT_SET_PARSER_SYNTAX
133 잘못된 형식의 drop synonym 구문입니다.\n DROP [PRIVATE] SYNONYM [IF EXISTS] [<schema_name>.]<synonym_name>
134 잘못된 형식의 rename synonym 구문입니다.\n RENAME [PRIVATE] SYNONYM [<schema_name>.]<old_synonym_name> {AS|TO} [<schema_name>.]<new_synonym_name>
135 ALTER SYNONYM에 대해 지정된 옵션이 없습니다.
136 Server의 DBNAME 최대 길이는 %1$d 바이트입니다.
137 Server의 USER 최대 길이는 %1$d 바이트입니다.

$set 8 MSGCAT_SET_PARSER_SEMANTIC
1 메모리가 부족합니다
Expand Down
2 changes: 2 additions & 0 deletions msg/ro_RO.utf8/cubrid.msg
Original file line number Diff line number Diff line change
Expand Up @@ -1598,6 +1598,8 @@ $set 7 MSGCAT_SET_PARSER_SYNTAX
133 Utilizare invalidă a DROP SYNONYM.\n DROP [PRIVATE] SYNONYM [IF EXISTS] [<schema_name>.]<synonym_name>
134 Utilizare invalidă a RENAME SYNONYM.\n RENAME [PRIVATE] SYNONYM [<schema_name>.]<old_synonym_name> {AS|TO} [<schema_name>.]<new_synonym_name>
135 Nu au fost specificate opțiuni pentru ALTER SYNONYM.
136 Maximum length of a server dbname is %1$d bytes.
137 Maximum length of a server user is %1$d bytes.

$set 8 MSGCAT_SET_PARSER_SEMANTIC
1 Memorie epuizată.
Expand Down
2 changes: 2 additions & 0 deletions msg/tr_TR.utf8/cubrid.msg
Original file line number Diff line number Diff line change
Expand Up @@ -1598,6 +1598,8 @@ $set 7 MSGCAT_SET_PARSER_SYNTAX
133 DROP SYNONYM geçersiz kullanımı.\n DROP [PRIVATE] SYNONYM [IF EXISTS] [<schema_name>.]<synonym_name>
134 RENAME SYNONYM geçersiz kullanımı.\n RENAME [PRIVATE] SYNONYM [<schema_name>.]<old_synonym_name> {AS|TO} [<schema_name>.]<new_synonym_name>
135 ALTER SYNONYM için herhangi bir seçenek belirtilmedi.
136 Maximum length of a server dbname is %1$d bytes.
137 Maximum length of a server user is %1$d bytes.

$set 8 MSGCAT_SET_PARSER_SEMANTIC
1 Bellek yetersiz.
Expand Down
2 changes: 2 additions & 0 deletions msg/vi_VN.utf8/cubrid.msg
Original file line number Diff line number Diff line change
Expand Up @@ -1598,6 +1598,8 @@ $set 7 MSGCAT_SET_PARSER_SYNTAX
133 Invalid use of DROP SYNONYM.\n DROP [PRIVATE] SYNONYM [IF EXISTS] [<schema_name>.]<synonym_name>
134 Invalid use of RENAME SYNONYM.\n RENAME [PRIVATE] SYNONYM [<schema_name>.]<old_synonym_name> {AS|TO} [<schema_name>.]<new_synonym_name>
135 No options specified for ALTER SYNONYM.
136 Maximum length of a server dbname is %1$d bytes.
137 Maximum length of a server user is %1$d bytes.

$set 8 MSGCAT_SET_PARSER_SEMANTIC
1 Out of memory.
Expand Down
2 changes: 2 additions & 0 deletions msg/zh_CN.utf8/cubrid.msg
Original file line number Diff line number Diff line change
Expand Up @@ -1599,6 +1599,8 @@ $set 7 MSGCAT_SET_PARSER_SYNTAX
133 DROP SYNONYM 的使用无效.\n DROP [PRIVATE] SYNONYM [IF EXISTS] [<schema_name>.]<synonym_name>
134 RENAME SYNONYM 的使用无效.\n RENAME [PRIVATE] SYNONYM [<schema_name>.]<old_synonym_name> {AS|TO} [<schema_name>.]<new_synonym_name>
135 没有为 ALTER SYNONYM 指定选项。
136 Maximum length of a server dbname is %1$d bytes.
137 Maximum length of a server user is %1$d bytes.

$set 8 MSGCAT_SET_PARSER_SEMANTIC
1 内存耗尽.
Expand Down
12 changes: 9 additions & 3 deletions src/executables/unload_schema.c
Original file line number Diff line number Diff line change
Expand Up @@ -3832,8 +3832,13 @@ export_server (print_output & output_ctx)
output_ctx ("CREATE SERVER [%s].[%s] (", owner_name, srv_name);
output_ctx ("\n\t HOST= '%s'", (char *) db_get_string (values + 1));
output_ctx (",\n\t PORT= %d", db_get_int (values + 2));
output_ctx (",\n\t DBNAME= %s", (char *) db_get_string (values + 3));
output_ctx (",\n\t USER= %s", (char *) db_get_string (values + 4));

output_ctx (",\n\t DBNAME= ");
desc_value_print (output_ctx, values + 3);

output_ctx (",\n\t USER= ");
desc_value_print (output_ctx, values + 4);

output_ctx (",\n\t PASSWORD= '%s'", (char *) db_get_string (&passwd_val));

str = (char *) db_get_string (values + 6);
Expand All @@ -3845,7 +3850,8 @@ export_server (print_output & output_ctx)
str = (char *) db_get_string (values + 7);
if (str)
{
output_ctx (",\n\t COMMENT= '%s'", str);
output_ctx (",\n\t COMMENT= ");
desc_value_print (output_ctx, values + 7);
}
output_ctx (" );\n");
}
Expand Down
37 changes: 35 additions & 2 deletions src/parser/csql_grammar.y
Original file line number Diff line number Diff line change
Expand Up @@ -23801,12 +23801,38 @@ connect_item
SET_CONTAINER_2(ctn, FROM_NUMBER(CONN_INFO_PORT), val);
$$ = ctn;
DBG_PRINT}}
| DBNAME '=' char_string_literal
{{ DBG_TRACE_GRAMMAR(connect_item, | DBNAME '=' char_string_literal );
container_2 ctn;
PT_NODE *val = $3;
val->type_enum = PT_TYPE_VARCHAR;
if (val->info.value.data_value.str->length > 254)
{
PT_ERRORmf (this_parser, val, MSGCAT_SET_PARSER_SYNTAX, MSGCAT_SYNTAX_MAX_SERVER_DBNAME_LEN, 254);
}
PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, val);
SET_CONTAINER_2(ctn, FROM_NUMBER(CONN_INFO_DBNAME), val);
$$ = ctn;
DBG_PRINT}}
| DBNAME '=' identifier
{{ DBG_TRACE_GRAMMAR(connect_item, | DBNAME '=' identifier );
container_2 ctn;
SET_CONTAINER_2(ctn, FROM_NUMBER(CONN_INFO_DBNAME), $3);
$$ = ctn;
DBG_PRINT}}
| USER '=' char_string_literal
{{ DBG_TRACE_GRAMMAR(connect_item, | USER '=' char_string_literal);
container_2 ctn;
PT_NODE *val = $3;
val->type_enum = PT_TYPE_VARCHAR;
if (val->info.value.data_value.str->length > 254)
{
PT_ERRORmf (this_parser, val, MSGCAT_SET_PARSER_SYNTAX, MSGCAT_SYNTAX_MAX_SERVER_USER_LEN, 254);
}
PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, val);
SET_CONTAINER_2(ctn, FROM_NUMBER(CONN_INFO_USER), val);
$$ = ctn;
DBG_PRINT}}
| USER '=' identifier
{{ DBG_TRACE_GRAMMAR(connect_item, | USER '=' identifier);
container_2 ctn;
Expand Down Expand Up @@ -23890,10 +23916,17 @@ connect_item
SET_CONTAINER_2(ctn, FROM_NUMBER(CONN_INFO_COMMENT), NULL);
$$ = ctn;
DBG_PRINT }}
| COMMENT '=' char_string
| COMMENT '=' char_string_literal
{{ DBG_TRACE_GRAMMAR(connect_item, | COMMENT '=' char_string );
container_2 ctn;
SET_CONTAINER_2(ctn, FROM_NUMBER(CONN_INFO_COMMENT), $3);
PT_NODE *val = $3;
$3->type_enum = PT_TYPE_VARCHAR;
if (val->info.value.data_value.str->length > SM_MAX_COMMENT_LENGTH)
{
PT_ERRORmf (this_parser, val, MSGCAT_SET_PARSER_SYNTAX, MSGCAT_SYNTAX_MAX_COMMENT_LEN, SM_MAX_COMMENT_LENGTH);
}
PT_NODE_PRINT_VALUE_TO_TEXT (this_parser, val);
SET_CONTAINER_2(ctn, FROM_NUMBER(CONN_INFO_COMMENT), val);
$$ = ctn;
DBG_PRINT}}
;
Expand Down
2 changes: 2 additions & 0 deletions src/parser/parser_message.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@
#define MSGCAT_SYNTAX_SYNONYM_INVALID_DROP MSGCAT_SYNTAX_NO(133)
#define MSGCAT_SYNTAX_SYNONYM_INVALID_RENAME MSGCAT_SYNTAX_NO(134)
#define MSGCAT_SYNTAX_SYNONYM_ALTER_NO_OPTION MSGCAT_SYNTAX_NO(135)
#define MSGCAT_SYNTAX_MAX_SERVER_DBNAME_LEN MSGCAT_SYNTAX_NO(136)
#define MSGCAT_SYNTAX_MAX_SERVER_USER_LEN MSGCAT_SYNTAX_NO(137)

/* Message id in the set MSGCAT_SET_PARSER_SEMANTIC */
#define MSGCAT_SEMANTIC_NO(n) n
Expand Down
14 changes: 10 additions & 4 deletions src/query/execute_statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -20142,17 +20142,23 @@ do_create_server (PARSER_CONTEXT * parser, PT_NODE * statement)
pval = NULL;

/* DBNAME */
assert (create_server->dbname->node_type == PT_NAME);
attr_val[2] = (char *) create_server->dbname->info.name.original;
assert (create_server->dbname->node_type == PT_NAME || create_server->dbname->node_type == PT_VALUE);
// *INDENT-OFF*
attr_val[2] = (create_server->dbname->node_type == PT_NAME) ? (char *) create_server->dbname->info.name.original
: (char *) PT_VALUE_GET_BYTES (create_server->dbname);
// *INDENT-ON*
if (attr_val[2] == NULL)
{
error = ER_FAILED;
goto end;
}

/* USER */
assert (create_server->user->node_type == PT_NAME);
attr_val[3] = (char *) create_server->user->info.name.original;
assert (create_server->user->node_type == PT_NAME || create_server->user->node_type == PT_VALUE);
// *INDENT-OFF*
attr_val[3] = (create_server->user->node_type == PT_NAME) ? (char *) create_server->user->info.name.original
: (char *) PT_VALUE_GET_BYTES (create_server->user);
// *INDENT-ON*
if (attr_val[3] == NULL)
{
error = ER_FAILED;
Expand Down

0 comments on commit bf3319c

Please sign in to comment.