connectivity/source/commontools/TTableHelper.cxx | 26 +++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-)
New commits: commit 64da0afacf13bc5b1a294f90d5c1cc305d43d28f Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sat Jul 27 19:35:06 2024 +0500 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sat Jul 27 18:17:59 2024 +0200 tdf#162227: use strict order of evaluations accessing columns ODBC SQLGetData requires that data must be retrieved in increasing column number order, unless the driver supports SQL_GD_ANY_ORDER extension (see https://learn.microsoft.com/en-us/sql/odbc/reference/syntax/sqlgetdata-function). We can't emplace_back(getString(4), getInt(5), ..., getString(12), getInt(17)), because MSVC would reorder calls into getInt(17) -> getString(12) -> ..., and then MS SQL Server ODBC driver will give error on access of column 12 after column 17. This partially reverts commit e8248b5e4b19df8ba469d1ca3a762960c1a053b5 "cid#1545222 COPY_INSTEAD_OF_MOVE", 2023-12-19. Change-Id: I9bf53086e526c886c4794af51a60e61d4cce89ef Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171097 Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Tested-by: Jenkins diff --git a/connectivity/source/commontools/TTableHelper.cxx b/connectivity/source/commontools/TTableHelper.cxx index f69333253102..0eb0c1e70260 100644 --- a/connectivity/source/commontools/TTableHelper.cxx +++ b/connectivity/source/commontools/TTableHelper.cxx @@ -202,15 +202,23 @@ namespace Reference< XRow > xRow( _rxResult, UNO_QUERY_THROW ); while ( _rxResult->next() ) { - _out_rColumns.emplace_back(xRow->getString(4), // COLUMN_NAME, - xRow->getInt(5), - xRow->getString(6), - xRow->getInt(7), - xRow->getInt(9), - xRow->getInt(11), - xRow->getString(12), - xRow->getString(13), - xRow->getInt(17)); // ORDINAL_POSITION + // tdf#162227: ODBC SQLGetData requires that data must be retrieved in increasing + // column number order, unless the driver supports SQL_GD_ANY_ORDER extension (see + // https://learn.microsoft.com/en-us/sql/odbc/reference/syntax/sqlgetdata-function). + // We can't emplace_back(getString(4), getInt(5), ..., getString(12), getInt(17)), + // because MSVC would reorder calls into getInt(17) -> getString(12) -> ..., and then + // MS SQL Server ODBC driver will give error on access of column 12 after column 17. + OUString sName = xRow->getString(4); // COLUMN_NAME + sal_Int32 nField5 = xRow->getInt(5); + OUString aField6 = xRow->getString(6); + sal_Int32 nField7 = xRow->getInt(7); + sal_Int32 nField9 = xRow->getInt(9); + sal_Int32 nField11 = xRow->getInt(11); + OUString sField12 = xRow->getString(12); + OUString sField13 = xRow->getString(13); + OrdinalPosition nOrdinalPosition = xRow->getInt(17); // ORDINAL_POSITION + _out_rColumns.emplace_back(sName, nField5, aField6, nField7, nField9, nField11, + sField12, sField13, nOrdinalPosition); } }