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

sql server: fix writing to tmp tables with FreeTDS #886

Merged
merged 4 commits into from
Jan 27, 2025

Conversation

detule
Copy link
Collaborator

@detule detule commented Jan 26, 2025

Hi:

This fixes an issue seen when writing to temp tables in SQL Server when using FreeTDS:

val <- paste(rep(paste(LETTERS, collapse = ""), 100), collapse = "")
> nchar(val)
[1] 2600
dbWriteTable(conn, "#test_freetds_tmp_write", data.frame(col = val))
res <- DBI::dbReadTable(conn, "#test_freetds_tmp_write")
> nchar(res[[1]])
[1] 255
---------------------------
> conn@info$drivername
[1] "libtdsodbc.so"
> conn@info$driver.version
[1] "01.01.9999"

It introduces an additional query or two when writing ( to temp tables ), but I think the cost is sufficiently low that I am not too concerned about it yet. Besides, without this patch, odbcConnectionColumns is genuinly broken for temp tables / doesn't work for any driver; it's just that the OEM driver can manage the write despite us not being able to discern the parameter types.

@detule detule requested review from hadley and simonpcouch January 26, 2025 02:05
Copy link
Collaborator

@simonpcouch simonpcouch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm with it!

@detule detule merged commit 1e81ed2 into r-dbi:main Jan 27, 2025
16 of 17 checks passed
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

Successfully merging this pull request may close these issues.

2 participants