-
Notifications
You must be signed in to change notification settings - Fork 7.9k
pgsqlSetNoticeCallback #4823
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
Closed
Closed
pgsqlSetNoticeCallback #4823
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
1e1a060
pgsqlSetNoticeCallback
outtersg d859e13
pgsqlSetNoticeCallback: test case
outtersg fb326d1
pgsqlSetNoticeCallback: test case for closure callback
outtersg 5917890
pgsqlSetNoticeCallback: code cleanup
outtersg 6bdac76
pgsqlSetNoticeCallback: tests: ensure where are "multiple calls"-proof
outtersg 6414d18
pgsqlSetNoticeCallback: accept closure callbacks
outtersg 33a3ac1
pgsqlSetNoticeCallback: cleanup on pgsql_handle_closer
outtersg 994ac07
pgsqlSetNoticeCallback: test case for method callback
outtersg f8a7e5d
pgsqlSetNoticeCallback: tests: set client_min_messages
outtersg 7492232
fix: pgsqlSetNoticeCallback: memory leak
outtersg 44f5d81
fix: pgsqlSetNoticeCallback: potential memory leak
outtersg 12fc060
fix: pgsqlSetNoticeCallback: ADDREF on non ref counted
outtersg dd97c3c
pgsqlSetNoticeCallback: get rid of TSRMLS
outtersg b3d6dd5
pgsqlSetNoticeCallback: unused variable
outtersg 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
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,22 @@ | ||
<?php | ||
require_once dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc'; | ||
require_once dirname(__FILE__) . '/config.inc'; | ||
$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt'); | ||
|
||
attach($db); | ||
|
||
$db->beginTransaction(); | ||
$db->exec("set client_min_messages to notice"); | ||
$db->exec("create temporary table t (a varchar(3))"); | ||
$db->exec("create function hey() returns trigger as \$\$ begin new.a := 'oh'; raise notice 'I tampered your data, did you know?'; return new; end; \$\$ language plpgsql"); | ||
$db->exec("create trigger hop before insert on t for each row execute procedure hey()"); | ||
$db->exec("insert into t values ('ah')"); | ||
attach($db, 'Re'); | ||
$db->exec("delete from t"); | ||
$db->exec("insert into t values ('ah')"); | ||
$db->pgsqlSetNoticeCallback(null); | ||
$db->exec("delete from t"); | ||
$db->exec("insert into t values ('ah')"); | ||
var_dump($db->query("select * from t")->fetchAll(PDO::FETCH_ASSOC)); | ||
echo "Done\n"; | ||
?> |
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,30 @@ | ||
--TEST-- | ||
pgsqlSetNoticeCallback catches Postgres "raise notice". | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded'); | ||
require_once dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc'; | ||
require_once dirname(__FILE__) . '/config.inc'; | ||
PDOTest::skip(); | ||
?> | ||
--FILE-- | ||
<?php | ||
function disp($message) { echo trim($message)."\n"; } | ||
function dispRe($message) { echo "Re".trim($message)."\n"; } | ||
function attach($db, $prefix = '') | ||
{ | ||
$db->pgsqlSetNoticeCallback('disp'.$prefix); | ||
} | ||
require dirname(__FILE__) . '/issue78621.inc'; | ||
?> | ||
--EXPECT-- | ||
NOTICE: I tampered your data, did you know? | ||
ReNOTICE: I tampered your data, did you know? | ||
array(1) { | ||
[0]=> | ||
array(1) { | ||
["a"]=> | ||
string(2) "oh" | ||
} | ||
} | ||
Done |
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,31 @@ | ||
--TEST-- | ||
pgsqlSetNoticeCallback catches Postgres "raise notice". | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded'); | ||
require_once dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc'; | ||
require_once dirname(__FILE__) . '/config.inc'; | ||
PDOTest::skip(); | ||
?> | ||
--FILE-- | ||
<?php | ||
function disp($message) { echo trim($message)."\n"; } | ||
function attach($db, $prefix = '') | ||
{ | ||
$db->pgsqlSetNoticeCallback(function($message) use($prefix) { echo $prefix.trim($message)."\n"; }); | ||
// https://github.com/php/php-src/pull/4823#pullrequestreview-335623806 | ||
$eraseCallbackMemoryHere = (object)[1]; | ||
} | ||
require dirname(__FILE__) . '/issue78621.inc'; | ||
?> | ||
--EXPECT-- | ||
NOTICE: I tampered your data, did you know? | ||
ReNOTICE: I tampered your data, did you know? | ||
array(1) { | ||
[0]=> | ||
array(1) { | ||
["a"]=> | ||
string(2) "oh" | ||
} | ||
} | ||
Done |
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,35 @@ | ||
--TEST-- | ||
pgsqlSetNoticeCallback catches Postgres "raise notice". | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded'); | ||
require_once dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc'; | ||
require_once dirname(__FILE__) . '/config.inc'; | ||
PDOTest::skip(); | ||
?> | ||
--FILE-- | ||
<?php | ||
class Logger | ||
{ | ||
public function disp($message) { echo trim($message)."\n"; } | ||
public function dispRe($message) { echo "Re".trim($message)."\n"; } | ||
} | ||
$logger = new Logger(); | ||
function attach($db, $prefix = '') | ||
{ | ||
global $logger; | ||
$db->pgsqlSetNoticeCallback(array($logger, 'disp'.$prefix)); | ||
} | ||
require dirname(__FILE__) . '/issue78621.inc'; | ||
?> | ||
--EXPECT-- | ||
NOTICE: I tampered your data, did you know? | ||
ReNOTICE: I tampered your data, did you know? | ||
array(1) { | ||
[0]=> | ||
array(1) { | ||
["a"]=> | ||
string(2) "oh" | ||
} | ||
} | ||
Done |
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.