-
Notifications
You must be signed in to change notification settings - Fork 134
[CBRD-26429] support to change csql prompt using enviornment variable #6703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
http://jira.cubrid.org/browse/CBRD-26429 The CSQL (CUBRID SQL Interpreter) prompt display can be modified using the user environment variable CUBRID_CSQL_PROMPT. This environment variable supports special user-defined characters (escape sequences) that the CSQL interpreter will replace with specific runtime values to build the customized prompt string. The user-defined characters (escape sequences) are the follows. - /u or /U : replaced with the user name (currently logged in) - /d or /D : replaced with the database name (currently connected) - /h or /H : replaced with the host name (currently connected)
|
/run all |
|
이건 미리 질문 드려보는 것인데 |
|
프롬프트에 한글을 사용하는 경우, 어떻게 될까요? 경우에 따라서는 한글이 잘려서 깨질 수 있을 것 같습니다. |
만약 csql에서 multi-connection을 지원하게 된다면, 아마도 ;switch 와 같은 command가 추가되어야 할 것 같습니다. |
|
- apply reviewer's opinion
|
다음 사항을 추가 반영했습니다.
|
|
/run all |
|
/run all |
|
LC_ALL 과 LANG 설정 없이 CUBRID_CSQL_PROMPT에 한글 utf8 사용시 csql의 readline() 함수에 segfault를 발생하는데, |
ascii만 지원하자는 것에 찬성합니다. |
- modify to add "> " to prompt string
- fix segfault when trying to login with non-existent user using ;connect
|
/run all |
|
/run all |
한글로 만들어진 유저가 있다면 어떻게 처리가 될까요? |
대체되는 문자열에 대해서는 ignore code가 없어서, LC_ALL 과 LANG 설정이 없으면 segfault가 발생합니다. |
LC_ALL과 LANG 설정이 없으면, 설정을 ko_KR.utf8로 해주면 어떨까요? 그럼, 한글 문제도 해결이 될 것 같습니다. |
|
PR 설명 부분에 환경 변수 옵션을 "/"로 표시하고 있는데, "\"로 수정되어야 합니다. |
PR 살명은 수정했습니다. |
LC_ALL과 LANG에 설정할 수 있는 내용을 iso88591, utf8, euckr로 한정하고 나머지는 모두 에러 처리하면 어떨지요? |
현재 사용중인 libedit에서 core 나는 부분은 수정할 예정입니다. |
… do not match, a warning message is output and the prompt is changed to use "csql>".
| set(WITH_LIBEXPAT_URL "https://github.com/CUBRID/3rdparty/raw/develop/expat/expat-2.6.4.tar.gz") # expat library sources URL | ||
| set(WITH_LIBJANSSON_URL "https://github.com/CUBRID/3rdparty/raw/develop/jansson/jansson-2.10.tar.gz") # jansson library sources URL | ||
| set(WITH_LIBEDIT_URL "https://github.com/CUBRID/libedit/archive/refs/tags/csql_v1.1.tar.gz") # editline library sources URL | ||
| set(WITH_LIBEDIT_URL "https://github.com/CUBRID/libedit/archive/refs/tags/csql_v1.2.tar.gz") # editline library sources URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LANG 설정이 안되어 있고, prompt에 멀티바이트 사용하여 readline 호출시 core 발생하는 것을 수정해서 머지해두었습니다.
| } | ||
|
|
||
| #if !defined (WINDOW) | ||
| /* check if the prompt contains multi-byte characters */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prompt에 multi-byte 문자가 있는지 확인 후 있는 경우 db codeset를 얻어서 OS에서 설정한 locale과 확인하는 코드 추가하였음. (db codeset가 iso88591 인경우에는 무조건 경고)
만약 OS의 locale이 다를 경우 경고 메세지를 출력후, "csql>"로 프롬프트 변경하게 수정함.
|
/run all |
| } | ||
|
|
||
| /* veify if match LANG and DB codeset */ | ||
| if (strcasestr (locale, find1) || strcasestr (locale, find2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (strcasestr (locale, find1) == 0 || strcasestr (locale, find2) == 0)
이렇게 체크해야 하지 않을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strcasestr() 은 찾는 경우에는 포인터를 넘겨주고, 찾는 못하는 경우에는 NULL을 반환하게 되어 있습니다.
find1 또는 find2가 locale에 있으면 정상적인 경우로 판단하고 있습니다.
아래처럼 명시적으로 변경해야 할까요 ?
if ((strcasestr (locale, find1) != NULL || strcasestr (locale, find2) != NULL)
|
/run sql |
|
/run all |
http://jira.cubrid.org/browse/CBRD-26429
Purpose
The CSQL (CUBRID SQL Interpreter) prompt display can be modified using the user environment variable CUBRID_CSQL_PROMPT. This environment variable supports special user-defined characters (escape sequences) that the CSQL interpreter will replace with specific runtime values to build the customized prompt string.
The user-defined characters (escape sequences) are the follows.
if the prompt contains multi-byte character and LANG and db codeset do not match, a warning message is output and the prompt is used "csql>".