-
Notifications
You must be signed in to change notification settings - Fork 69
fix(agent): don't skip arguments when calling mysqli::real_connect
#976
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c563658
enhance test services
lavarou 16b2e92
enhance mysqli tests
lavarou a1e0693
fix(agent): Don't skip arguments when calling mysqli::real_connect
kovshenin e9099ac
Avoid defaulting the final $flags argument to null
kovshenin bf7ae8b
fix(agent): only non-null for first three params
zsistla 312228d
fix(agent): typo
zsistla b1c7ab5
fix(agent): variable naming, remove redundant check.
zsistla File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
148 changes: 148 additions & 0 deletions
148
tests/integration/mysqli/test_explain_connect_socket.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
<?php | ||
/* | ||
* Copyright 2020 New Relic Corporation. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/*DESCRIPTION | ||
The agent should generate explain plans when connections are made with | ||
mysqli_connect() when connecting to the database via socket. | ||
*/ | ||
|
||
/*SKIPIF | ||
<?php require("skipif.inc"); | ||
*/ | ||
|
||
/*INI | ||
error_reporting = E_ALL & ~E_DEPRECATED | ||
newrelic.transaction_tracer.explain_enabled = true | ||
newrelic.transaction_tracer.explain_threshold = 0 | ||
newrelic.transaction_tracer.record_sql = obfuscated | ||
*/ | ||
|
||
/*EXPECT | ||
STATISTICS | ||
*/ | ||
|
||
/*EXPECT_METRICS | ||
[ | ||
"?? agent run id", | ||
"?? start time", | ||
"?? stop time", | ||
[ | ||
[{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/all"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name":"DurationByCaller/Unknown/Unknown/Unknown/Unknown/allOther"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name":"Datastore/all"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name":"Datastore/allOther"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name":"Datastore/MySQL/all"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name":"Datastore/MySQL/allOther"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name":"Datastore/statement/MySQL/tables/select"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name":"Datastore/statement/MySQL/tables/select", | ||
"scope":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name":"Datastore/operation/MySQL/select"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name":"OtherTransaction/all"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name":"OtherTransaction/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name":"OtherTransactionTotalTime"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name":"OtherTransactionTotalTime/php__FILE__"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name":"Supportability/Logging/Forwarding/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name":"Supportability/Logging/Metrics/PHP/enabled"}, [1, "??", "??", "??", "??", "??"]], | ||
[{"name":"Supportability/Logging/LocalDecorating/PHP/disabled"}, [1, "??", "??", "??", "??", "??"]] | ||
] | ||
] | ||
*/ | ||
|
||
|
||
|
||
/*EXPECT_SLOW_SQLS | ||
[ | ||
[ | ||
[ | ||
"OtherTransaction/php__FILE__", | ||
"<unknown>", | ||
"?? SQL ID", | ||
"SELECT TABLE_NAME FROM information_schema.tables WHERE table_name=?", | ||
"Datastore/statement/MySQL/tables/select", | ||
1, | ||
"?? total time", | ||
"?? min time", | ||
"?? max time", | ||
{ | ||
"explain_plan": [ | ||
[ | ||
"id", | ||
"select_type", | ||
"table", | ||
"type", | ||
"possible_keys", | ||
"key", | ||
"key_len", | ||
"ref", | ||
"rows", | ||
"Extra" | ||
], | ||
[ | ||
[ | ||
1, | ||
"SIMPLE", | ||
"tables", | ||
"ALL", | ||
null, | ||
"TABLE_NAME", | ||
null, | ||
null, | ||
null, | ||
"Using where; Skip_open_table; Scanned 1 database" | ||
] | ||
] | ||
], | ||
"backtrace": [ | ||
" in mysqli_stmt_execute called at __FILE__ (??)", | ||
" in test_prepare called at __FILE__ (??)" | ||
] | ||
} | ||
] | ||
] | ||
] | ||
*/ | ||
|
||
/*EXPECT_TRACED_ERRORS | ||
null | ||
*/ | ||
|
||
require_once(realpath (dirname ( __FILE__ )) . '/../../include/config.php'); | ||
|
||
function test_prepare($link) | ||
{ | ||
$query = "SELECT TABLE_NAME FROM information_schema.tables WHERE table_name='STATISTICS'"; | ||
|
||
$stmt = mysqli_prepare($link, $query); | ||
if (FALSE === $stmt) { | ||
echo mysqli_error($link) . "\n"; | ||
return; | ||
} | ||
|
||
if (FALSE === mysqli_stmt_execute($stmt)) { | ||
echo mysqli_stmt_error($stmt) . "\n"; | ||
return; | ||
} | ||
|
||
if (FALSE === mysqli_stmt_bind_result($stmt, $value)) { | ||
echo mysqli_stmt_error($stmt) . "\n"; | ||
return; | ||
} | ||
|
||
while (mysqli_stmt_fetch($stmt)) { | ||
echo $value . "\n"; | ||
} | ||
|
||
mysqli_stmt_close($stmt); | ||
} | ||
|
||
$link = mysqli_connect('localhost', $MYSQL_USER, $MYSQL_PASSWD, $MYSQL_DB, null, $MYSQL_SOCKET); | ||
if (mysqli_connect_errno()) { | ||
echo mysqli_connect_error() . "\n"; | ||
exit(1); | ||
} | ||
|
||
test_prepare($link); | ||
mysqli_close($link); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.