Skip to content

Commit

Permalink
Merge pull request #272 from yitam/convert_string
Browse files Browse the repository at this point in the history
removed inconsistent code calling convert_string_from_utf16
  • Loading branch information
v-kigos authored Feb 2, 2017
2 parents c9b92b1 + e7f4165 commit 67f7d31
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion source/shared/core_stmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ field_meta_data* core_sqlsrv_field_metadata( sqlsrv_stmt* stmt, SQLSMALLINT coln
field_name_temp = static_cast<SQLWCHAR*>( sqlsrv_malloc( ( SS_MAXCOLNAMELEN + 1 ) * sizeof( SQLWCHAR ) ));
SQLSRV_ENCODING encoding = ( (stmt->encoding() == SQLSRV_ENCODING_DEFAULT ) ? stmt->conn->encoding() : stmt->encoding());
try{
core::SQLDescribeColW( stmt, colno + 1, field_name_temp, SS_MAXCOLNAMELEN, &field_len_temp,
core::SQLDescribeColW( stmt, colno + 1, field_name_temp, SS_MAXCOLNAMELEN + 1, &field_len_temp,
&( meta_data->field_type ), & ( meta_data->field_size ), & ( meta_data->field_scale ),
&( meta_data->field_is_nullable ) TSRMLS_CC );
}
Expand Down
7 changes: 1 addition & 6 deletions source/shared/core_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,8 @@ bool core_sqlsrv_get_odbc_error( sqlsrv_context& ctx, int record_number, sqlsrv_
return false;
}

#ifndef _WIN32
// In linux we need to calculate number of characters
// We need to calculate number of characters
SQLLEN wsqlstate_len = sizeof( wsqlstate ) / sizeof( SQLWCHAR );
#else
// In Windows we need the size in bytes
SQLLEN wsqlstate_len = sizeof( wsqlstate );
#endif // !_WIN32
SQLLEN sqlstate_len = 0;
convert_string_from_utf16(enc, wsqlstate, wsqlstate_len, (char**)&error->sqlstate, sqlstate_len);

Expand Down
5 changes: 2 additions & 3 deletions source/sqlsrv/stmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1825,10 +1825,9 @@ void fetch_fields_common( _Inout_ ss_sqlsrv_stmt* stmt, zend_long fetch_type, _O
for( int i = 0; i < num_cols; ++i ) {

core::SQLColAttributeW ( stmt, i + 1, SQL_DESC_NAME, field_name_w, ( SS_MAXCOLNAMELEN + 1 ) * 2, &field_name_len_w, NULL TSRMLS_CC );
#ifndef _WIN32
//Conversion function in Linux expects size in characters.

//Conversion function expects size in characters
field_name_len_w = field_name_len_w / sizeof ( SQLWCHAR );
#endif // !_WIN32
bool converted = convert_string_from_utf16( encoding, field_name_w,
field_name_len_w, ( char** ) &field_name, field_name_len );

Expand Down

0 comments on commit 67f7d31

Please sign in to comment.