postgresql-interfaces/psqlodbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
From: omeuid (@omeuid) <[email protected]>
To: postgresql-interfaces/psqlodbc <[email protected]>
Subject: [postgresql-interfaces/psqlodbc] issue #54: Escape sequence for the INSERT function fails.
Date: Fri, 27 Sep 2024 16:53:20 +0000
Message-ID: <[email protected]> (raw)

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.





view thread (2+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: github://postgresql-interfaces/psqlodbc
  Cc: [email protected], [email protected]
  Subject: Re: [postgresql-interfaces/psqlodbc] issue #54: Escape sequence for the INSERT function fails.
  In-Reply-To: <<[email protected]>>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox