Skip to content
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

Escape sequence for the INSERT function fails. #54

Open
omeuid opened this issue Sep 27, 2024 · 1 comment
Open

Escape sequence for the INSERT function fails. #54

omeuid opened this issue Sep 27, 2024 · 1 comment

Comments

@omeuid
Copy link
Contributor

omeuid commented Sep 27, 2024

The SQLGetInfo function for the SQL_STRING_FUNCTIONS param returns the following information:
SQL_FN_STR_CONCAT | SQL_FN_STR_INSERT | SQL_FN_STR_LEFT | SQL_FN_STR_LTRIM | SQL_FN_STR_LENGTH | SQL_FN_STR_LOCATE | SQL_FN_STR_LCASE | SQL_FN_STR_REPEAT | SQL_FN_STR_RIGHT | SQL_FN_STR_RTRIM | SQL_FN_STR_SUBSTRING | SQL_FN_STR_UCASE | SQL_FN_STR_ASCII | SQL_FN_STR_CHAR | SQL_FN_STR_LOCATE_2 | SQL_FN_STR_SPACE

Notice that INSERT function is returned (SQL_FN_STR_INSERT ).

But when you execute the following escape sequence an error is returned:

  • SELECT {fn INSERT('aabcda', 2, 3 'zzz')}

The following errors are shown in the driver log:

[37872-19.426] execute.c[Exec_with_parameters_resolved]445: copying statement params: trans_status=1, len=40, stmt='SELECT {fn INSERT('aabcda', 2, 3 'zzz')}'
[37872-19.426] convert.c[inner_process_tokens]3912: token_len=6 status=1 token=SELECT
[37872-19.426] convert.c[inner_process_tokens]3912: token_len=1 status=0 token=(
[37872-19.426] convert.c[inner_process_tokens]3912: token_len=1 status=0 token=,
[37872-19.426] convert.c[inner_process_tokens]3912: token_len=1 status=1 token=2
[37872-19.426] convert.c[inner_process_tokens]3912: token_len=1 status=0 token=,
[37872-19.426] convert.c[inner_process_tokens]3912: token_len=1 status=1 token=3
[37872-19.426] convert.c[convert_escape]5861: 4th param not found for the expression substring($1 from 1 for $2 - 1) || $4 || substring($1 from $2 + $3)
[37872-19.426] convert.c[inner_process_tokens]3692: convert_escape error
[37872-19.426]statement.[SC_log_error]2488: STATEMENT ERROR: func=copy_statement_with_parameters, desc='', errnum=1, errmsg='param not found'

It seems that the problem could be located in the inner_process_tokens or prepareParametersNoDesc methods from convert.c file.

  • Notice that the insert function should be delegated as (substring($1 from 1 for $2 - 1) || $4 || substring($1 from $2 + $3)) (just like is indicated in convert.c), so the 4th param is included in the expression.
@omeuid
Copy link
Contributor Author

omeuid commented Sep 30, 2024

Closing issue as escape sequence was incorrect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant