Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@ test:
@echo "Running ODBCLoader Test Suite"
@echo "========================================="
@echo ""
@echo "[*] Running Copy Test..."
@echo ""
@$(VSQL) -f tests/copy_test.sql 2>&1 | tee $(TMPDIR)/copy_test.out | perl -pe 's/^vsql:[\/_:\w\.]* /vsql: /; \
s/\[ODBC[^\]]*\]/[...]/g; \
s/\[mysql[^\]]*\]/[...]/g; \
s/(Error parsing .* )\(.*\)$$/$$1(...)/; \
s/mariadb/MySQL/ig; '
@echo ""
@echo "[*] Validating copy test output..."
@diff -u tests/expected/copy_test.out <(perl -pe 's/^vsql:[\/_:\w\.]* /vsql: /; \
s/\[ODBC[^\]]*\]/[...]/g; \
s/\[mysql[^\]]*\]/[...]/g; \
s/(Error parsing .* )\(.*\)$$/$$1(...)/; \
s/mariadb/MySQL/ig; ' $(TMPDIR)/copy_test.out) && echo "[✓] Copy test validation passed" || (echo "[✗] Copy test validation failed" && exit 1)
@echo ""
@echo "[*] Running Federated Queries Test..."
@echo ""
@$(VSQL) -f tests/federated_queries.sql 2>&1 | tee $(TMPDIR)/federated_queries.out | perl -pe 's/^vsql:[\/_:\w\.]* /vsql: /; \
Expand Down
20 changes: 17 additions & 3 deletions ODBCLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,9 +574,11 @@ class ODBCLoader : public UDParser {

// Check "hidden" parameters __query_col_name__ and __query_col_idx__ to filter out columns
if ( src_cfilter ) {
if (srvInterface.getParamReader().containsParameter("__query_col_name__")) {
if (srvInterface.getParamReader().containsParameter("__query_col_idx__")) {
colInTable = (int)colInfo.getColumnCount() ;
// Only column-filter when the param is actually non-empty, a plain COPY sends it empty.
if (srvInterface.getParamReader().containsParameter("__query_col_name__") &&
!srvInterface.getParamReader().getStringRef("__query_col_name__").str().empty()) {
if (srvInterface.getParamReader().containsParameter("__query_col_idx__")) {
colInTable = (int)colInfo.getColumnCount() ;
#if LOADER_DEBUG
srvInterface.log("DEBUG __query_col_name__=<%s>",srvInterface.getParamReader().getStringRef("__query_col_name__").str().c_str());
srvInterface.log("DEBUG __query_col_idx__=<%s>",srvInterface.getParamReader().getStringRef("__query_col_idx__").str().c_str());
Expand All @@ -603,6 +605,9 @@ srvInterface.log("-----> External Table Columns, colInTable=<%d>", colInTable);
query +
" ) sq" ;
}
} else {
Comment thread
SandeepDave2 marked this conversation as resolved.
// Plain COPY: column-filter param present but empty -> load all columns.
query = "SELECT * FROM ( " + query + " ) sq" ;
}

} else {
Expand Down Expand Up @@ -665,6 +670,15 @@ srvInterface.log("-----> External Table Columns, colInTable=<%d>", colInTable);
vtype = (BaseDataOID *)srvInterface.allocator->alloc(numcols * sizeof(BaseDataOID)) ;
stype = (uint32 *)srvInterface.allocator->alloc(numcols * sizeof(uint32)) ;

// Plain COPY leaves vidx empty. Default to identity mapping and set
// colInTable so the pre-null loop covers all columns.
if (vidx.empty()) {
for (SQLSMALLINT i = 0; i < numcols; i++) {
vidx.push_back(i);
}
colInTable = numcols;
}

// Set up column-data buffers
// Bind to the columns in question
for (SQLSMALLINT i = 0; i < numcols; i++) {
Expand Down
2 changes: 0 additions & 2 deletions tests/expected/copy_test.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Timing is on.
Pager usage is off.
Timing is off.
SET
CREATE TABLE
Expand Down
Loading