Skip to content

Commit

Permalink
Applied review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yitam committed Apr 30, 2019
1 parent cff17bc commit 30e1348
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
3 changes: 1 addition & 2 deletions source/shared/core_sqlsrv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1464,8 +1464,7 @@ namespace data_classification {
}
};

struct column_sensitivity
{
struct column_sensitivity {
USHORT num_pairs;
std::vector<label_infotype_pair> label_info_pairs;

Expand Down
2 changes: 1 addition & 1 deletion source/shared/core_stmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ void core_sqlsrv_sensitivity_metadata( _Inout_ sqlsrv_stmt* stmt TSRMLS_DC )

// First call to get dclen
r = ::SQLGetDescFieldW(ird, 0, SQL_CA_SS_DATA_CLASSIFICATION, dcbuf, 0, &dclen);
if (r != SQL_SUCCESS) {
if (r != SQL_SUCCESS || dclen == 0) {
// log the error first
LOG(SEV_ERROR, "core_sqlsrv_sensitivity_metadata: failed in calling SQLGetDescFieldW first time." );

Expand Down
13 changes: 8 additions & 5 deletions source/shared/core_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,13 +497,14 @@ namespace data_classification {
unsigned short ncols;

// Get number of columns
meta->num_columns = ncols = *(unsigned short*)ptr;
meta->num_columns = ncols = *(reinterpret_cast<unsigned short*>(ptr));

// Move forward
ptr += sizeof(unsigned short);

while (ncols--) {
unsigned short npairs = *(unsigned short*)ptr;
unsigned short npairs = *(reinterpret_cast<unsigned short*>(ptr));

ptr += sizeof(unsigned short);

column_sensitivity column;
Expand All @@ -513,8 +514,10 @@ namespace data_classification {
label_infotype_pair pair;

unsigned short labelidx, typeidx;
labelidx = *(unsigned short*)ptr; ptr += sizeof(unsigned short);
typeidx = *(unsigned short*)ptr; ptr += sizeof(unsigned short);
labelidx = *(reinterpret_cast<unsigned short*>(ptr));
ptr += sizeof(unsigned short);
typeidx = *(reinterpret_cast<unsigned short*>(ptr));
ptr += sizeof(unsigned short);

pair.label_idx = labelidx;
pair.infotype_idx = typeidx;
Expand All @@ -535,7 +538,7 @@ namespace data_classification {
return 0;
}

SQLSRV_ASSERT(colno >= 0 && colno < meta->num_columns, "fill_column_sensitivity_array: column number out of bound");
SQLSRV_ASSERT(colno >= 0 && colno < meta->num_columns, "fill_column_sensitivity_array: column number out of bounds");

zval data_classification;
ZVAL_UNDEF(&data_classification);
Expand Down
2 changes: 1 addition & 1 deletion test/functional/sqlsrv/sqlsrv_data_classification.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function getRegularMetadata($conn, $tsql)
fatalError("getRegularMetadata (2): failed in sqlsrv_query.\n");
}

// The metadata for all columns should be identical
// The metadata for each statement, column by column, should be identical
$numCol = sqlsrv_num_fields($stmt1);
$metadata1 = sqlsrv_field_metadata($stmt1);
$metadata2 = sqlsrv_field_metadata($stmt2);
Expand Down

0 comments on commit 30e1348

Please sign in to comment.