-
Notifications
You must be signed in to change notification settings - Fork 107
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
Error in result_fetch(res@ptr, n) : wstring_convert::to_bytes with odbc 1.2.3 + #427
Comments
Additional note on this. While longer text columns are returned with odbc 1.2.2 they are truncated to 255 characters. |
|
Thanks for the quick response @detule!
|
Thanks - I don't have access to those drivers but looks like there are some config options ( |
We have tried MaxVarchar both in the connection directly and through the ini file without any luck thus far. I'll loop RStudio support in on this, since their professional drivers are in the mix here, and see if there is anything they might suggest. |
Hi, What version of R you have with RStudio? I had this issue with most recent version R 4.0.5 (with latest R studio) and connecting to SQL Server via odbc. It was failing for a row where query (in dbGetQuery()) returns a column value Unicode (NVARCHAR(MAX) with special character (<U+FFFD>) stored in a SQL server table. I had to revert back to older version of R (3.6.3) and reinstall odbc package (latest version 1.3.2) for it to work. I still have to test it with R 4.0.4 though. I hope this helps. The error I had: Error in result_fetch(res@ptr, n) : wstring_convert::to_bytes |
I am also getting this and I've isolated it to a column that contains non-ANSI characters. I am collecting the data from a Microsoft SQL Server Database.
Matrix products: default locale: attached base packages: other attached packages: loaded via a namespace (and not attached): |
I am faced with a similar error issue that only occurs on shinyapps.io, but not locally.
I am using a Postgres (version 11.11) database that has a text column with entry values over 255 characters. We don’t have a column with non-ANSI characters or anything else out of the ordinary. The issue occurs after succesfully connecting to the database and when reading in the SQL views. Strangely, it's not fully reproducible. At times the shiny app on shinyapps.io works perfectly normal, at others it fails to start up (failing to read in the views) and yield this error. The data being pulled is always the same. Locally the same odbc R code/shiny app never fails. I believe it might be a combination of the odbc R package version and the Postgres driver version.
(as returned by I did more some testing to resolve my issue:
Hence I now locked in the odbc package to version at 1.2.2. With this setup the text fields are being returned in full length locally, but truncated at 255 characters on shinyapps.io. |
We received the traceback below from a ticket submitted to Posit Support for what we thought might have been a Professional Drivers issue. Does the following help? Or is there any other output that may help from the user: Traceback output:
|
I’ve found the following resources which seem related to the issue here (perhaps). I noticed in the nanodbc.cpp file that it contains 4 different calls to std::wstring_convert. There is a comment in the file that this function is provided as a workaround to the following documented bug: This is the same function call which is failing. Is there a connection here? |
I get this result sometimes as well. However, I have found that if I immediately resubmit the query, it can work. Or sometimes it takes 3 resubmissions. We had a theory that the Postgres server we were querying was being updated during the query. For us, the fact that the exact same query with the same connection arguments and drivers will both work and not work makes us think it isn't related to |
Issue Description and Expected Result
When querying tables with long text entries I get the error
Error in result_fetch(res@ptr, n) : wstring_convert::to_bytes
when querying the table with select *, using odbc version 1.2.3 or above. Omitting such columns from the query returns results as expected. Switching back to odbc 1.2.2 also returns results as expected on such tables using select *.Database
PostgreSQL Version: 11.0.8
Session Info
setting value
version R version 4.0.2 (2020-06-22)
os Ubuntu 18.04.5 LTS
system x86_64, linux-gnu
ui RStudio
language (EN)
collate C.UTF-8
ctype C.UTF-8
tz Etc/UTC
date 2020-12-29
─ Packages ────────────────────────────────────────────────────────────────────────────────
package * version date lib source
assertthat 0.2.1 2019-03-21 [1] RSPM (R 4.0.2)
backports 1.1.8 2020-06-17 [1] RSPM (R 4.0.2)
bit 4.0.4 2020-08-04 [1] RSPM (R 4.0.2)
bit64 4.0.2 2020-07-30 [1] RSPM (R 4.0.2)
blob 1.2.1 2020-01-20 [1] RSPM (R 4.0.2)
callr 3.4.3 2020-03-28 [1] RSPM (R 4.0.2)
cli 2.0.2 2020-02-28 [1] RSPM (R 4.0.2)
config 0.3 2018-03-27 [1] RSPM (R 4.0.2)
crayon 1.3.4 2017-09-16 [1] RSPM (R 4.0.2)
curl 4.3 2019-12-02 [1] RSPM (R 4.0.2)
data.table 1.13.0 2020-07-24 [1] RSPM (R 4.0.2)
DBI * 1.1.0 2019-12-15 [1] RSPM (R 4.0.2)
desc 1.2.0 2018-05-01 [1] RSPM (R 4.0.2)
devtools 2.3.1 2020-07-21 [1] RSPM (R 4.0.2)
digest 0.6.25 2020-02-23 [1] RSPM (R 4.0.2)
ellipsis 0.3.1 2020-05-15 [1] RSPM (R 4.0.2)
fansi 0.4.1 2020-01-08 [1] RSPM (R 4.0.2)
fs 1.5.0 2020-07-31 [1] RSPM (R 4.0.2)
glue 1.4.1 2020-05-13 [1] RSPM (R 4.0.2)
hms 0.5.3 2020-01-08 [1] RSPM (R 4.0.2)
httr 1.4.2 2020-07-20 [1] RSPM (R 4.0.2)
jsonlite 1.7.0 2020-06-25 [1] RSPM (R 4.0.2)
magrittr 1.5 2014-11-22 [1] RSPM (R 4.0.2)
memoise 1.1.0 2017-04-21 [1] RSPM (R 4.0.2)
odbc * 1.2.3 2020-06-18 [1] RSPM (R 4.0.2)
paws 0.1.9 2020-08-04 [1] RSPM (R 4.0.2)
paws.common 0.3.3 2020-07-19 [1] RSPM (R 4.0.2)
paws.security.identity 0.1.9 2020-08-03 [1] RSPM (R 4.0.2)
pkgbuild 1.1.0 2020-07-13 [1] RSPM (R 4.0.2)
pkgconfig 2.0.3 2019-09-22 [1] RSPM (R 4.0.2)
pkgload 1.1.0 2020-05-29 [1] RSPM (R 4.0.2)
prettyunits 1.1.1 2020-01-24 [1] RSPM (R 4.0.2)
processx 3.4.3 2020-07-05 [1] RSPM (R 4.0.2)
ps 1.3.4 2020-08-11 [1] RSPM (R 4.0.2)
R6 2.4.1 2019-11-12 [1] RSPM (R 4.0.2)
Rcpp 1.0.5 2020-07-06 [1] RSPM (R 4.0.2)
remotes 2.2.0 2020-07-21 [1] RSPM (R 4.0.2)
rlang 0.4.7 2020-07-09 [1] RSPM (R 4.0.2)
rprojroot 1.3-2 2018-01-03 [1] RSPM (R 4.0.2)
rstudioapi 0.11 2020-02-07 [1] RSPM (R 4.0.2)
sessioninfo 1.1.1 2018-11-05 [1] RSPM (R 4.0.2)
testthat 2.3.2 2020-03-02 [1] RSPM (R 4.0.2)
usethis 1.6.1 2020-04-29 [1] RSPM (R 4.0.2)
vctrs 0.3.2 2020-07-15 [1] RSPM (R 4.0.2)
vibrantR * 0.1.2.0.0.0.1600885364 2020-11-03 [1] RSPM (R 4.0.2)
withr 2.2.0 2020-04-20 [1] RSPM (R 4.0.2)
yaml 2.2.1 2020-02-01 [1] RSPM (R 4.0.2)
The text was updated successfully, but these errors were encountered: