Skip to content

Fix plain COPY crash and restore copy_test to test suite - #22

Merged
SandeepDave2 merged 4 commits into
mainfrom
fix/plain-copy-empty-vidx
Jul 16, 2026
Merged

SandeepDave2 merged 4 commits into
mainfrom
fix/plain-copy-empty-vidx

Conversation

@SandeepDave2

@SandeepDave2 SandeepDave2 commented Jul 14, 2026 •

Copy link
Copy Markdown
Collaborator

Issue-
Running a plain COPY with the ODBC loader was failing with ERROR 3399: InvokeSetupUDL(): UDx side process has exited abnormally. The external table path worked fine, only plain COPY crashed.

Root Cause-
I traced it back to commit eae4c95 (#19), which added column pruning. That change made the code use vidx.at(i) to map columns, and vidx only gets filled when the hidden column-filter params (query_col_name / query_col_idx) are sent.
On a plain COPY those params are sent but empty. Two things went wrong because of that:

  1. The code still entered the column-filter block and built a broken query like SELECT FROM (...) (empty column list), which the remote DB rejected.
  2. vidx stayed empty, so vidx.at(i) later threw an out-of-range and killed the process.

Fix-

  • Only do column filtering when the column-name param is actually non-empty. If it's empty (plain COPY), build SELECT * FROM (...) and load all columns.
  • If vidx is empty when we bind columns, default it to a straight 0..numcols-1 mapping, and set colInTable so the pre-null loop covers all columns. This keeps the plain COPY path behaving like it did before the change, so all columns line up correctly.

Testing-

  • Tested a plain COPY against our source and it now loads all rows correctly (verified row count and data).
  • Also restored copy_test in the Makefile test target.
image

Comment thread ODBCLoader.cpp Outdated
Comment thread ODBCLoader.cpp
@mkottakota1

Copy link
Copy Markdown
Collaborator

Apart from that changes are looking good

@SandeepDave2
SandeepDave2 requested a review from mkottakota1 July 16, 2026 05:56
@mkottakota1

Copy link
Copy Markdown
Collaborator

I have reviewed the changes and analyzed the impact on adding " // Plain COPY: column-filter param present but empty -> load all columns.
query = "SELECT * FROM ( " + query + " ) sq" ;"

As requested in Teams, please run a sample program to load the specified columns.

@mkottakota1 mkottakota1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The changes are looking good and Fix is covering all the scenerios

@SandeepDave2

Copy link
Copy Markdown
Collaborator Author

I have reviewed the changes and analyzed the impact on adding " // Plain COPY: column-filter param present but empty -> load all columns. query = "SELECT * FROM ( " + query + " ) sq" ;"

As requested in Teams, please run a sample program to load the specified columns.

image

It's working as expected.

@SandeepDave2
SandeepDave2 merged commit 65cd599 into main Jul 16, 2026
2 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