Skip to content

Commit

Permalink
FIX: Conditional revert of 06f80d3 as the original code is necessary …
Browse files Browse the repository at this point in the history
…in some configurations.

Now we have the magic of an if block to guide us.
  • Loading branch information
Sam Minnee committed Sep 19, 2012
1 parent c46e45f commit 3fe7671
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions code/PostgreSQLDatabase.php
Expand Up @@ -1117,9 +1117,26 @@ protected function extractTriggerColumns($triggerName)
"SELECT tgargs FROM pg_catalog.pg_trigger WHERE tgname='%s'", $this->addslashes($triggerName)
))->first();

$argList = explode('\000', $trigger['tgargs']);
array_pop($argList);

// Option 1: output as a string
if(strpos($trigger['tgargs'],'\000') !== false) {
$argList = explode('\000', $trigger['tgargs']);
array_pop($argList);

// Option 2: hex-encoded (not sure why this happens, depends on PGSQL config)
} else {
$bytes = str_split($trigger['tgargs'],2);
$argList = array();
$nextArg = "";
foreach($bytes as $byte) {
if($byte == "00") {
$argList[] = $nextArg;
$nextArg = "";
} else {
$nextArg .= chr(hexdec($byte));
}
}
}

// Drop first two arguments (trigger name and config name) and implode into nice list
return array_slice($argList, 2);
}
Expand Down

0 comments on commit 3fe7671

Please sign in to comment.