Skip to content

Conversation

@mmcnabb-vms
Copy link
Contributor

@mmcnabb-vms mmcnabb-vms commented Nov 7, 2025

The commits here are:

  • First two commits: add environment variable to suppress the CRT debugging spam (there's various inconsequential memory leaks by default in freebcp) - annoying to scroll past those every time you're using freebcp
  • Issue 648: the call to bcp_init() actually performs the empty-rowset query and sets up bcp_columns() already, it's redundant for freebcp.c to go and do that again. Removing that redundant code actually fixes issue 647 as well (if -E is not used)
  • Issue 647: fix Native format if -E is used. The underlying cause is that commit 9058123 added logic to dbresults() to free tds->res_info on completion, so subsequent calls to dbcoltype() fail. I avoided the problem by performing the bcp_colfmt before making the queries for the -E switch.
  • Two refactoring commits to make the code more readable . I noticed while doing this that the BCPBATCH command was set for Character files but not for Native or Format files, not sure what the rationale was for that.

I have done various ad-hoc testing with SQL Server in different operating systems with large tables with varied column types, and not found any problems.

@mmcnabb-vms
Copy link
Contributor Author

Update: have got my ASE 16.0 SP04 evaluation working again; and using the Format file appears to work correctly, although I only did an ad-hoc test with a simple table containing an int and a datetime.

#include <freetds/replacements.h>
#include <sybfront.h>
#include <sybdb.h>
#include <dblib.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

Please not, FreeBCP should use dblib, not abuse it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, have copied what was done for bcp_getbatchsize to avoid this include. Pushed fix on top of the commit you commented on, but before my refactor.

I guess for future maintainability we may want to consider changing these two functions into something like bcp_control but for reading instead of writing.

@freddy77
Copy link
Contributor

First 2 commits merged

@mmcnabb-vms
Copy link
Contributor Author

mmcnabb-vms commented Dec 1, 2025

There's been a fair bit of progress on "master" since I opened this, I'll squash the dblib.h fix and rebase . Also fixed problem with mixed code/declarations that failed the VS2008/2010 appveyor

mmcnabb-vms and others added 4 commits December 2, 2025 10:47
    The bcp_init() already performs the zero-row SELECT to
    obtain column formats, and already calls bcp_columns().

Signed-off-by: Matt McNabb <[email protected]>
    Commit 9058123 causes dbresults(dbproc) loop to free
    the structures used by dbcoltype(), so perform the
    bcp_colfmt() loop before the -E flag processing

Signed-off-by: Matt McNabb <[email protected]>
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