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

MSSQL Server dbWriteTable fails without batch_row = nrow(value) #814

Closed
meztez opened this issue Jun 6, 2024 · 6 comments · Fixed by #816
Closed

MSSQL Server dbWriteTable fails without batch_row = nrow(value) #814

meztez opened this issue Jun 6, 2024 · 6 comments · Fixed by #816

Comments

@meztez
Copy link
Contributor

meztez commented Jun 6, 2024

MSSQL Server dbWriteTable fails without batch_row = nrow(value)

# Something to create a connexion
con <- ...
tb <- mtcars[rep(seq_len(nrow(mtcars)), 200),]
odbc::dbWriteTable(con, name = "#TMP_CARS", value = mtcars, overwrite = TRUE, immediate = TRUE)
odbc::dbWriteTable(con, name = "#TMP_XCARS", value = tb, overwrite = TRUE, immediate = TRUE)
#> Error in eval(expr, envir, enclos): nanodbc/nanodbc.cpp:1783: 00000
#> The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 2 (""): The supplied length is not valid for data type nvarchar(max). Check the source data for invalid lengths. An example of an invalid length is data of nchar type with an odd length in bytes.,
odbc::dbWriteTable(con, name = "#TMP_XCARS", value = tb, overwrite = TRUE, immediate = TRUE, batch_rows = nrow(tb))

Created on 2024-06-06 with reprex v2.1.0

Database
> DBI::dbGetInfo(con)

$dbms.name
[1] "Microsoft SQL Server"

$db.version
[1] "14.00.3465"

$host
[1] ""

$port
[1] ""

$sourcename
[1] ""

$drivername
[1] "RStudio SQL Server ODBC Driver"

$odbc.version
[1] "03.52"

$driver.version
[1] "1.5.23.1024"

$odbcdriver.version
[1] "03.80"

$supports.transactions
[1] TRUE

$supports.catalogs
[1] TRUE

$supports.schema
[1] TRUE

$getdata.extensions.any_column
[1] TRUE

$getdata.extensions.any_order
[1] TRUE
Session Info
> devtools::session_info() ─ Session info ─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.4.0 (2024-04-24)
 os       Ubuntu 22.04.4 LTS
 system   x86_64, linux-gnu
 ui       RStudio
 language (EN)
 collate  C.UTF-8
 ctype    C.UTF-8
 tz       America/Montreal
 date     2024-06-06
 rstudio  2024.04.0+735.pro3 Chocolate Cosmos (server)
 pandoc   3.1.12.3 @ /usr/bin/ (via rmarkdown)

─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────
 package     * version date (UTC) lib source
 askpass       1.2.0   2023-09-03 [2] CRAN (R 4.4.0)
 assertthat    0.2.1   2019-03-21 [2] CRAN (R 4.4.0)
 base64enc     0.1-3   2015-07-28 [2] CRAN (R 4.4.0)
 bigrquery     1.5.1   2024-03-14 [2] CRAN (R 4.4.0)
 bit           4.0.5   2022-11-15 [2] CRAN (R 4.4.0)
 bit64         4.0.5   2020-08-30 [2] CRAN (R 4.4.0)
 blob          1.2.4   2023-03-17 [2] CRAN (R 4.4.0)
 cachem        1.1.0   2024-05-16 [2] CRAN (R 4.4.0)
 callr         3.7.6   2024-03-25 [2] CRAN (R 4.4.0)
 cellranger    1.1.0   2016-07-27 [2] CRAN (R 4.4.0)
 cli           3.6.2   2023-12-11 [2] CRAN (R 4.4.0)
 cloud.cap     0.6.13  2024-05-01 [2] Custom
 connect.cap   0.4.14  2024-05-01 [2] Custom
 crayon        1.5.2   2022-09-29 [2] CRAN (R 4.4.0)
 curl          5.2.1   2024-03-01 [2] CRAN (R 4.4.0)
 data.table    1.15.4  2024-03-30 [2] CRAN (R 4.4.0)
 DBI           1.2.3   2024-06-02 [2] CRAN (R 4.4.0)
 devtools      2.4.5   2022-10-11 [2] CRAN (R 4.4.0)
 digest        0.6.35  2024-03-11 [2] CRAN (R 4.4.0)
 ellipsis      0.3.2   2021-04-29 [2] CRAN (R 4.4.0)
 evaluate      0.23    2023-11-01 [2] CRAN (R 4.4.0)
 extraw        1.15.25 2024-06-06 [2] local
 fansi         1.0.6   2023-12-08 [2] CRAN (R 4.4.0)
 fastmap       1.2.0   2024-05-15 [2] CRAN (R 4.4.0)
 fs            1.6.4   2024-04-25 [2] CRAN (R 4.4.0)
 gargle        1.5.2   2023-07-20 [2] CRAN (R 4.4.0)
 getPass       0.2-4   2023-12-10 [2] CRAN (R 4.4.0)
 glue          1.7.0   2024-01-09 [2] CRAN (R 4.4.0)
 hms           1.1.3   2023-03-21 [2] CRAN (R 4.4.0)
 htmltools     0.5.8.1 2024-04-04 [2] CRAN (R 4.4.0)
 htmlwidgets   1.6.4   2023-12-06 [2] CRAN (R 4.4.0)
 httpuv        1.6.15  2024-03-26 [2] CRAN (R 4.4.0)
 httr          1.4.7   2023-08-15 [2] CRAN (R 4.4.0)
 jsonlite      1.8.8   2023-12-04 [2] CRAN (R 4.4.0)
 keyring       1.3.2   2023-12-11 [2] CRAN (R 4.4.0)
 knitr         1.47    2024-05-29 [2] CRAN (R 4.4.0)
 later         1.3.2   2023-12-06 [2] CRAN (R 4.4.0)
 lifecycle     1.0.4   2023-11-07 [2] CRAN (R 4.4.0)
 magrittr      2.0.3   2022-03-30 [2] CRAN (R 4.4.0)
 memoise       2.0.1   2021-11-26 [2] CRAN (R 4.4.0)
 mime          0.12    2021-09-28 [2] CRAN (R 4.4.0)
 miniUI        0.1.1.1 2018-05-18 [2] CRAN (R 4.4.0)
 odbc          1.5.0   2024-06-05 [2] CRAN (R 4.4.0)
 openssl       2.2.0   2024-05-16 [2] CRAN (R 4.4.0)
 pillar        1.9.0   2023-03-22 [2] CRAN (R 4.4.0)
 pkgbuild      1.4.4   2024-03-17 [2] CRAN (R 4.4.0)
 pkgconfig     2.0.3   2019-09-22 [2] CRAN (R 4.4.0)
 pkgload       1.3.4   2024-01-16 [2] CRAN (R 4.4.0)
 processx      3.8.4   2024-03-16 [2] CRAN (R 4.4.0)
 profvis       0.3.8   2023-05-02 [2] CRAN (R 4.4.0)
 promises      1.3.0   2024-04-05 [2] CRAN (R 4.4.0)
 ps            1.7.6   2024-01-18 [2] CRAN (R 4.4.0)
 purrr         1.0.2   2023-08-10 [2] CRAN (R 4.4.0)
 R.cache       0.16.0  2022-07-21 [2] CRAN (R 4.4.0)
 R.methodsS3   1.8.2   2022-06-13 [2] CRAN (R 4.4.0)
 R.oo          1.26.0  2024-01-24 [2] CRAN (R 4.4.0)
 R.utils       2.12.3  2023-11-18 [2] CRAN (R 4.4.0)
 R6            2.5.1   2021-08-19 [2] CRAN (R 4.4.0)
 rappdirs      0.3.3   2021-01-31 [2] CRAN (R 4.4.0)
 Rcpp          1.0.12  2024-01-09 [2] CRAN (R 4.4.0)
 readxl        1.4.3   2023-07-06 [2] CRAN (R 4.4.0)
 remotes       2.5.0   2024-03-17 [2] CRAN (R 4.4.0)
 reprex        2.1.0   2024-01-11 [2] CRAN (R 4.4.0)
 rlang         1.1.4   2024-06-04 [2] CRAN (R 4.4.0)
 rmarkdown     2.27    2024-05-17 [2] CRAN (R 4.4.0)
 rstudioapi    0.16.0  2024-03-24 [2] CRAN (R 4.4.0)
 sessioninfo   1.2.2   2021-12-06 [2] CRAN (R 4.4.0)
 shiny         1.8.1.1 2024-04-02 [2] CRAN (R 4.4.0)
 stringi       1.8.4   2024-05-06 [2] CRAN (R 4.4.0)
 stringr       1.5.1   2023-11-14 [2] CRAN (R 4.4.0)
 styler        1.10.3  2024-04-07 [2] CRAN (R 4.4.0)
 tibble        3.2.1   2023-03-20 [2] CRAN (R 4.4.0)
 urlchecker    1.0.1   2021-11-30 [2] CRAN (R 4.4.0)
 usethis       2.2.3   2024-02-19 [2] CRAN (R 4.4.0)
 utf8          1.2.4   2023-10-22 [2] CRAN (R 4.4.0)
 utils.cap     1.4.46  2024-05-01 [2] Custom
 vctrs         0.6.5   2023-12-01 [2] CRAN (R 4.4.0)
 withr         3.0.0   2024-01-16 [2] CRAN (R 4.4.0)
 xfun          0.44    2024-05-15 [2] CRAN (R 4.4.0)
 xml2          1.3.6   2023-12-04 [2] CRAN (R 4.4.0)
 xtable        1.8-4   2019-04-21 [2] CRAN (R 4.4.0)
 yaml          2.3.8   2023-12-11 [2] CRAN (R 4.4.0)
@meztez
Copy link
Contributor Author

meztez commented Jun 6, 2024

odbc::dbWriteTable(con, name = "#TEST", value = data.frame(A = 1:2), overwrite = TRUE, immediate = TRUE, batch_rows = 1)
EDIT from Simon: drop output into collapsible
> odbc::dbWriteTable(con, name = "#TEST", value = data.frame(A = 1:2), batch_rows = 1, overwrite = TRUE)
nanodbc/nanodbc.cpp:1472 SQLAllocHandle(SQL_HANDLE_STMT, conn.native_dbc_handle(), &stmt_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1707 SQLSetStmtAttr(stmt_, SQL_ATTR_PARAMSET_SIZE, (SQLPOINTER)(std::intptr_t)batch_operations, 0)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1550 SQLSetStmtAttr(stmt_, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER)(std::intptr_t)timeout, 0)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1719 SQLExecDirect(stmt_, (NANODBC_SQLCHAR*)query.c_str(), SQL_NTS)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2361 SQLSetStmtAttr(stmt_.native_statement_handle(), SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER)(std::intptr_t)rowset_size_, 0)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2371 SQLSetStmtAttr(stmt_.native_statement_handle(), SQL_ATTR_ROWS_FETCHED_PTR, &row_count_, 0)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1842 SQLNumResultCols(stmt_, &cols)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1842 SQLNumResultCols(stmt_, &cols)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1249 SQLGetInfo(dbc_, info_type, value, sizeof(value) / sizeof(NANODBC_SQLCHAR), &length)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1249 SQLGetInfo(dbc_, info_type, value, sizeof(value) / sizeof(NANODBC_SQLCHAR), &length)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2812 SQLFetchScroll(stmt_.native_statement_handle(), orientation, rows)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2812 SQLFetchScroll(stmt_.native_statement_handle(), orientation, rows)
nanodbc/nanodbc.cpp:2629 SQLMoreResults(stmt_.native_statement_handle())
nanodbc/nanodbc.cpp:1509 SQLCancel(stmt_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1462 SQLCancel(stmt_)
nanodbc/nanodbc.cpp:1851 SQLFreeStmt(stmt_, SQL_RESET_PARAMS)
nanodbc/nanodbc.cpp:746 SQLFreeHandle(handle_type, handle)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1472 SQLAllocHandle(SQL_HANDLE_STMT, conn.native_dbc_handle(), &stmt_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1707 SQLSetStmtAttr(stmt_, SQL_ATTR_PARAMSET_SIZE, (SQLPOINTER)(std::intptr_t)batch_operations, 0)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1550 SQLSetStmtAttr(stmt_, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER)(std::intptr_t)timeout, 0)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1719 SQLExecDirect(stmt_, (NANODBC_SQLCHAR*)query.c_str(), SQL_NTS)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2361 SQLSetStmtAttr(stmt_.native_statement_handle(), SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER)(std::intptr_t)rowset_size_, 0)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2371 SQLSetStmtAttr(stmt_.native_statement_handle(), SQL_ATTR_ROWS_FETCHED_PTR, &row_count_, 0)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1842 SQLNumResultCols(stmt_, &cols)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1842 SQLNumResultCols(stmt_, &cols)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1826 SQLRowCount(stmt_, &rows)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1509 SQLCancel(stmt_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1462 SQLCancel(stmt_)
nanodbc/nanodbc.cpp:1851 SQLFreeStmt(stmt_, SQL_RESET_PARAMS)
nanodbc/nanodbc.cpp:746 SQLFreeHandle(handle_type, handle)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1472 SQLAllocHandle(SQL_HANDLE_STMT, conn.native_dbc_handle(), &stmt_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1707 SQLSetStmtAttr(stmt_, SQL_ATTR_PARAMSET_SIZE, (SQLPOINTER)(std::intptr_t)batch_operations, 0)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1550 SQLSetStmtAttr(stmt_, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER)(std::intptr_t)timeout, 0)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1719 SQLExecDirect(stmt_, (NANODBC_SQLCHAR*)query.c_str(), SQL_NTS)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2361 SQLSetStmtAttr(stmt_.native_statement_handle(), SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER)(std::intptr_t)rowset_size_, 0)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2371 SQLSetStmtAttr(stmt_.native_statement_handle(), SQL_ATTR_ROWS_FETCHED_PTR, &row_count_, 0)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1842 SQLNumResultCols(stmt_, &cols)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1842 SQLNumResultCols(stmt_, &cols)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1826 SQLRowCount(stmt_, &rows)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1509 SQLCancel(stmt_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1462 SQLCancel(stmt_)
nanodbc/nanodbc.cpp:1851 SQLFreeStmt(stmt_, SQL_RESET_PARAMS)
nanodbc/nanodbc.cpp:746 SQLFreeHandle(handle_type, handle)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1472 SQLAllocHandle(SQL_HANDLE_STMT, conn.native_dbc_handle(), &stmt_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:4674 SQLColumns(stmt.native_statement_handle(), (NANODBC_SQLCHAR*)(catalog), (catalog == nullptr ? 0 : SQL_NTS), (NANODBC_SQLCHAR*)(schema), (schema == nullptr ? 0 : SQL_NTS), (NANODBC_SQLCHAR*)(table), (table == nullptr ? 0 : SQL_NTS), (NANODBC_SQLCHAR*)(column), (column == nullptr ? 0 : SQL_NTS))
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2361 SQLSetStmtAttr(stmt_.native_statement_handle(), SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER)(std::intptr_t)rowset_size_, 0)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2371 SQLSetStmtAttr(stmt_.native_statement_handle(), SQL_ATTR_ROWS_FETCHED_PTR, &row_count_, 0)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1842 SQLNumResultCols(stmt_, &cols)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2812 SQLFetchScroll(stmt_.native_statement_handle(), orientation, rows)
nanodbc/nanodbc.cpp:1462 SQLCancel(stmt_)
nanodbc/nanodbc.cpp:1851 SQLFreeStmt(stmt_, SQL_RESET_PARAMS)
nanodbc/nanodbc.cpp:746 SQLFreeHandle(handle_type, handle)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1472 SQLAllocHandle(SQL_HANDLE_STMT, conn.native_dbc_handle(), &stmt_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1533 SQLPrepare(stmt_, (NANODBC_SQLCHAR*)query.c_str(), (SQLINTEGER)query.size())
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1550 SQLSetStmtAttr(stmt_, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER)(std::intptr_t)timeout, 0)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1863 SQLNumParams(stmt_, &params)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1863 SQLNumParams(stmt_, &params)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1863 SQLNumParams(stmt_, &params)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1237 SQLGetInfo(dbc_, info_type, &value, 0, nullptr)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1319 SQLSetConnectAttr(conn_.native_dbc_handle(), SQL_ATTR_AUTOCOMMIT, (SQLPOINTER)SQL_AUTOCOMMIT_OFF, SQL_IS_UINTEGER)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1935 SQLDescribeParam(stmt_, param_index + 1, &param.type_, &param.size_, &param.scale_, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1985 SQLBindParameter(stmt_, param.index_ + 1, param.iotype_, sql_ctype<T>::value, param.type_, param.size_, param.scale_, (SQLPOINTER)buffer.values_, buffer_size, bind_len_or_null_[param.index_].data())
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1757 SQLFreeStmt(stmt_, SQL_CLOSE)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1769 SQLSetStmtAttr(stmt_, SQL_ATTR_PARAMSET_SIZE, (SQLPOINTER)(std::intptr_t)batch_operations, 0)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1550 SQLSetStmtAttr(stmt_, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER)(std::intptr_t)timeout, 0)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1781 SQLExecute(stmt_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2361 SQLSetStmtAttr(stmt_.native_statement_handle(), SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER)(std::intptr_t)rowset_size_, 0)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2371 SQLSetStmtAttr(stmt_.native_statement_handle(), SQL_ATTR_ROWS_FETCHED_PTR, &row_count_, 0)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1842 SQLNumResultCols(stmt_, &cols)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1842 SQLNumResultCols(stmt_, &cols)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1935 SQLDescribeParam(stmt_, param_index + 1, &param.type_, &param.size_, &param.scale_, &nullable)
<-- rc: SQL_ERROR | 
nanodbc/nanodbc.cpp:1985 SQLBindParameter(stmt_, param.index_ + 1, param.iotype_, sql_ctype<T>::value, param.type_, param.size_, param.scale_, (SQLPOINTER)buffer.values_, buffer_size, bind_len_or_null_[param.index_].data())
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1757 SQLFreeStmt(stmt_, SQL_CLOSE)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1769 SQLSetStmtAttr(stmt_, SQL_ATTR_PARAMSET_SIZE, (SQLPOINTER)(std::intptr_t)batch_operations, 0)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1550 SQLSetStmtAttr(stmt_, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER)(std::intptr_t)timeout, 0)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1781 SQLExecute(stmt_)
<-- rc: SQL_ERROR | 
nanodbc/nanodbc.cpp:381 SQLGetDiagRec(handle_type, handle, (SQLSMALLINT)i, sql_state, &native_error, 0, 0, &total_bytes)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:399 SQLGetDiagRec(handle_type, handle, (SQLSMALLINT)i, sql_state, &native_error, sql_message.data(), (SQLSMALLINT)sql_message.size(), &total_bytes)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:381 SQLGetDiagRec(handle_type, handle, (SQLSMALLINT)i, sql_state, &native_error, 0, 0, &total_bytes)
<-- rc: SQL_NO_DATA | 
nanodbc/nanodbc.cpp:1344 SQLEndTran(SQL_HANDLE_DBC, conn_.native_dbc_handle(), SQL_ROLLBACK)
nanodbc/nanodbc.cpp:1348 SQLSetConnectAttr(conn_.native_dbc_handle(), SQL_ATTR_AUTOCOMMIT, (SQLPOINTER)SQL_AUTOCOMMIT_ON, SQL_IS_UINTEGER)
Error:
! nanodbc/nanodbc.cpp:1783: 00000
The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Parameter 1 (""): The supplied length is not valid for data type nvarchar(max). Check the source data for invalid lengths. An example of an invalid length is data of nchar type with an odd length in bytes.,  
Run `rlang::last_trace()` to see where the error occurred.
Called from: signal_abort(cnd)
nanodbc/nanodbc.cpp:1472 SQLAllocHandle(SQL_HANDLE_STMT, conn.native_dbc_handle(), &stmt_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:4725 SQLTables(stmt.native_statement_handle(), (NANODBC_SQLCHAR*)SQL_ALL_CATALOGS, 1, (NANODBC_SQLCHAR*)NANODBC_TEXT(""), 0, (NANODBC_SQLCHAR*)NANODBC_TEXT(""), 0, (NANODBC_SQLCHAR*)NANODBC_TEXT(""), 0)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2361 SQLSetStmtAttr(stmt_.native_statement_handle(), SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER)(std::intptr_t)rowset_size_, 0)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2371 SQLSetStmtAttr(stmt_.native_statement_handle(), SQL_ATTR_ROWS_FETCHED_PTR, &row_count_, 0)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1842 SQLNumResultCols(stmt_, &cols)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2851 SQLDescribeCol(stmt_.native_statement_handle(), i + 1, (NANODBC_SQLCHAR*)column_name, sizeof(column_name) / sizeof(NANODBC_SQLCHAR), &len, &sqltype, &sqlsize, &scale, &nullable)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2979 SQLBindCol(stmt_.native_statement_handle(), i + 1, col.ctype_, col.pdata_, col.clen_, col.cbdata_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2812 SQLFetchScroll(stmt_.native_statement_handle(), orientation, rows)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2812 SQLFetchScroll(stmt_.native_statement_handle(), orientation, rows)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2812 SQLFetchScroll(stmt_.native_statement_handle(), orientation, rows)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2812 SQLFetchScroll(stmt_.native_statement_handle(), orientation, rows)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2812 SQLFetchScroll(stmt_.native_statement_handle(), orientation, rows)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2812 SQLFetchScroll(stmt_.native_statement_handle(), orientation, rows)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2812 SQLFetchScroll(stmt_.native_statement_handle(), orientation, rows)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2812 SQLFetchScroll(stmt_.native_statement_handle(), orientation, rows)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2812 SQLFetchScroll(stmt_.native_statement_handle(), orientation, rows)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2812 SQLFetchScroll(stmt_.native_statement_handle(), orientation, rows)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2812 SQLFetchScroll(stmt_.native_statement_handle(), orientation, rows)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2812 SQLFetchScroll(stmt_.native_statement_handle(), orientation, rows)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:2812 SQLFetchScroll(stmt_.native_statement_handle(), orientation, rows)
nanodbc/nanodbc.cpp:1462 SQLCancel(stmt_)
nanodbc/nanodbc.cpp:1851 SQLFreeStmt(stmt_, SQL_RESET_PARAMS)
nanodbc/nanodbc.cpp:746 SQLFreeHandle(handle_type, handle)
<-- rc: SQL_SUCCESS | 
Browse[1]> c
nanodbc/nanodbc.cpp:1509 SQLCancel(stmt_)
<-- rc: SQL_SUCCESS | 
nanodbc/nanodbc.cpp:1462 SQLCancel(stmt_)
nanodbc/nanodbc.cpp:1851 SQLFreeStmt(stmt_, SQL_RESET_PARAMS)
nanodbc/nanodbc.cpp:746 SQLFreeHandle(handle_type, handle)
<-- rc: SQL_SUCCESS | 

Will update as I find out more about the issue.

@simonpcouch
Copy link
Collaborator

simonpcouch commented Jun 6, 2024

Possibly related to #813, both of which I'd hypothesize are an outcome of #774.

Hypothesized issue, tested and does not resolve One thing I observe when I look through [the diff there](https://github.com//pull/774/files#diff-af2d02b6a9ed515dc1d95e050d0a6415f52350bd36dff64245f83f1b7b7413c8R153-R159)... in:

odbc/R/dbi-table.R

Lines 153 to 159 in 559718b

values <- sqlData(conn, row.names = row.names, value[, , drop = FALSE])
if (is.na(batch_rows)) {
batch_rows <- NROW(value)
if (batch_rows == 0) {
batch_rows <- 1
}
batch_rows <- min(1024, batch_rows)

#691 set batch_rows based on value rather than values, the variable created just before then—should that read NROW(values) instead?

The changes from #691 had made it to CRAN before 1.5.0, so if NROW(values) is the needed change, it hadn't been an issue by itself.

@simonpcouch
Copy link
Collaborator

I can't replicate with Microsoft's driver, but can do so with the Pro driver.

@simonpcouch
Copy link
Collaborator

In the above, 1024 is indeed the value passed for batch_rows in:

result_insert_dataframe(rs@ptr, values, batch_rows),

Sounds like some drivers don't support batch_rows values other than the size of the data. It had been my sense that some drivers just didn't support batch_rows values greater than the size of the data. This didn't come up in related issue threads, but I see this commit message does call that out.

@detule
Copy link
Collaborator

detule commented Jun 11, 2024

@meztez Thanks for the report and the good investigation.

Can you test #816 to see if it helps with the issue?

Thanks again

@meztez
Copy link
Contributor Author

meztez commented Jun 11, 2024

It goes through without any errors, of course, you fixed it!

Thanks

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