Skip to content

freebcp native format doesn't work #647

@mmcnabb-vms

Description

@mmcnabb-vms

Testing with Branch-1_5, commit 0f7966d in Windows 11 + Visual Studio 17.13.6:

Using the following command with any table (here I used the pubs2 demonstration database that comes with the SAP ASE 16.0 free trial):

freebcp pubs2.dbo.sales out sales_n.txt -Ssybase -Usa -Ppassword -n

produces error output:

 Msg 20060, Level 11
 Unknown datatype encountered

 Error in bcp_colfmt col 1

The same command with -c instead of -n works correctly for both in and out; but -n fails in both cases. I have tried various other column configurations and get the same error in all cases. The bcp utility that comes with SAP ASE SDK 16.0 works correctly in both cases.

Using the debugger, the error code is generated by the following code in freebcp.c 's function file_native() :

for (i = 1; i <= li_numcols; i++) {
	li_coltype = dbcoltype(dbproc, i);

	if (bcp_colfmt(dbproc, i, li_coltype, -1, -1, NULL, -1, i) == FAIL) {
		fprintf(stderr, "Error in bcp_colfmt col %d\n", i);

and the value of li_coltype is -1 when i is 1, which leads to a call is_tds_type_valid(-1) which gives false.
The dbcoltype function returns -1 due to the code in dblib.c:

info = tds->res_info;
if (!info)
	return NULL;

and res_info is null here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions