Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to GitHub issues 574 and 580 #592

Merged
merged 3 commits into from
Nov 15, 2017
Merged

Fix to GitHub issues 574 and 580 #592

merged 3 commits into from
Nov 15, 2017

Conversation

yitam
Copy link
Contributor

@yitam yitam commented Nov 9, 2017

This change is Reviewable

@yitam yitam changed the title Fix to GitHub issue 574 Fix to GitHub issue #574 Nov 9, 2017
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.07%) to 73.061% when pulling 52b612e on yitam:nextResult into 07ac237 on Microsoft:dev.

@yitam yitam requested a review from yukiwongky November 10, 2017 00:24
@@ -45,7 +45,7 @@ namespace {

// *** internal constants ***

const int INITIAL_FIELD_STRING_LEN = 256; // base allocation size when retrieving a string field
const int INITIAL_FIELD_STRING_LEN = 1024; // base allocation size when retrieving a string field
Copy link
Contributor

Choose a reason for hiding this comment

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

can you only increase the initial buffer size when column encryption is enabled? Also, if column encryption is enabled, I would love to blast the initial buffer size to 8000 (max size for varchar(n))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's reasonable to simply use 8000 regardless of AE setting. We use this buffer size for varchar / char parameters with unknown size.

// fetch from $tableName
$row = $stmt->fetch(PDO::FETCH_NUM);
if ($row) {
echo(substr($row[0], 0, 15)) . PHP_EOL;
Copy link
Contributor

Choose a reason for hiding this comment

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

this only echoes the first 10 characters, what if something has gone wrong in between? Would be great of you can compare it with $phrase instead

createTable($conn, $tableName1, $columns);

// insert one row to each table
$phrase = str_repeat('This is a test ', 250);
Copy link
Contributor

Choose a reason for hiding this comment

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

if you're going to change the initial buffer size, this number will have to change as well

@@ -0,0 +1,186 @@
--TEST--
GitHub issue 574 - Fetch Next Result Test
Copy link
Contributor

Choose a reason for hiding this comment

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

please change this test as well according to the comments in the PDO_SQLSRV equivalent test

@codecov-io
Copy link

codecov-io commented Nov 10, 2017

Codecov Report

Merging #592 into dev will decrease coverage by 0.49%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##              dev     #592     +/-   ##
=========================================
- Coverage   74.96%   74.47%   -0.5%     
=========================================
  Files          50       50             
  Lines       14933    14949     +16     
=========================================
- Hits        11195    11133     -62     
- Misses       3738     3816     +78
Impacted Files Coverage Δ
...-7.1.11-src/ext/pdo_sqlsrv/shared/core_results.cpp 59.31% <0%> (-4.53%) ⬇️
...-7.0.25-src/ext/pdo_sqlsrv/shared/core_results.cpp 57.14% <0%> (-4.36%) ⬇️
.../php-7.1.11-src/ext/sqlsrv/shared/core_results.cpp 73.41% <0%> (-2.17%) ⬇️
.../php-7.0.25-src/ext/sqlsrv/shared/core_results.cpp 70.73% <0%> (-2.1%) ⬇️
...php-7.1.11-src/ext/pdo_sqlsrv/shared/core_stmt.cpp 67.86% <0%> (-0.05%) ⬇️
...php-7.0.25-src/ext/pdo_sqlsrv/shared/core_stmt.cpp 66.29% <0%> (-0.04%) ⬇️
...php-7.0.25-src/ext/pdo_sqlsrv/shared/core_sqlsrv.h 42.33% <0%> (ø) ⬆️
...php-7.1.11-src/ext/pdo_sqlsrv/shared/core_sqlsrv.h 76.56% <0%> (ø) ⬆️
...x86/php-7.1.11-src/ext/sqlsrv/shared/core_sqlsrv.h 79.52% <0%> (ø) ⬆️
...x86/php-7.0.25-src/ext/sqlsrv/shared/core_sqlsrv.h 43.72% <0%> (ø) ⬆️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 07ac237...1a24596. Read the comment docs.

@yitam
Copy link
Contributor Author

yitam commented Nov 10, 2017

#574 and #580

@yitam yitam changed the title Fix to GitHub issue #574 Fix to GitHub issues 574 and 580 Nov 10, 2017
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 72.958% when pulling d633691 on yitam:nextResult into 07ac237 on Microsoft:dev.

@@ -45,7 +45,7 @@ namespace {

// *** internal constants ***

const int INITIAL_FIELD_STRING_LEN = 1024; // base allocation size when retrieving a string field
const int INITIAL_FIELD_STRING_LEN = 8000; // base allocation size when retrieving a string field
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that I think about it, changing this value for non-AE may cause a breaking change. Say a user is trying to fetch a string that is 5000 bytes long. Before this change, the user needs to call sqlsrv_next_result + sqlsrv_get_field many times to retrieve the complete string. With this change however, the user only needs to call sqlsrv_get_field once the retrieve the entire string. This seems like a good thing. But if the user has multiple sqlsrv_next_result + sqlsrv_get_field in their code, error will be thrown telling the user there's no more result left. Therefore, I think it's best to only change the buffer size for if column encryption is enabled. It's impossible to change the constant here though, you may have to go through the code, check where INITIAL_FIELD_STRING_LEN is used and change it there.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 72.691% when pulling 1a24596 on yitam:nextResult into 07ac237 on Microsoft:dev.

@yitam yitam merged commit 04f5034 into microsoft:dev Nov 15, 2017
@yitam yitam deleted the nextResult branch November 15, 2017 23:36
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.

4 participants