-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(agent): don't skip arguments when calling
mysqli::real_connect
(#…
…976) Co-authored-by: Konstantin Kovshenin <[email protected]> Co-authored-by: Amber Sistla <[email protected]>
- Loading branch information
1 parent
597bad6
commit dc162a4
Showing
4 changed files
with
342 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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 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 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.