hook_install: pgsql: check version number
Hi, I am not very familiar with Postgresql. I wrote taxonomy_access.install file, but for POSTGRESQL priot to 8.0, I need to make a BIT_OR aggregate function. Do you think this will work OK for pg? if (version_compare(pg_version(), '8.0', '<')) { // PRIOR TO POSTGRESQL 8.0: making a BIT_OR aggregate function } Many thanks, Keve.
also do an if $GLOBALS['db_type'] == 'pgsql' { } On 06 Mar 2006, at 12:23 PM, Keve wrote:
Hi,
I am not very familiar with Postgresql. I wrote taxonomy_access.install file, but for POSTGRESQL priot to 8.0, I need to make a BIT_OR aggregate function. Do you think this will work OK for pg?
if (version_compare(pg_version(), '8.0', '<')) { // PRIOR TO POSTGRESQL 8.0: making a BIT_OR aggregate function }
Many thanks, Keve.
-- Adrian Rossouw Drupal developer and Bryght Guy http://drupal.org | http://bryght.com
Of course, i just did not mention it. Thanks anyway. Keve. Adrian Rossouw wrote:
also do an
if $GLOBALS['db_type'] == 'pgsql' {
} On 06 Mar 2006, at 12:23 PM, Keve wrote:
Hi,
I am not very familiar with Postgresql. I wrote taxonomy_access.install file, but for POSTGRESQL priot to 8.0, I need to make a BIT_OR aggregate function. Do you think this will work OK for pg?
if (version_compare(pg_version(), '8.0', '<')) { // PRIOR TO POSTGRESQL 8.0: making a BIT_OR aggregate function }
Many thanks, Keve.
-- Adrian Rossouw Drupal developer and Bryght Guy http://drupal.org | http://bryght.com
<!-- Adverticum zone: 28057 (js) --> <script type="text/javascript"> // <![CDATA[ var ord=Math.round(Math.random()*100000000); document.write('<sc'+'ript type="text/javascript" src="http://ad.adverticum.net/js.prm?zona=28057&ord='+ord+'"><\/scr'+'ipt>');
// ]]> </script> <noscript><a href="http://ad.adverticum.net/click.prm?zona=28057&nah=!ie" target="_top" title="Hirdetés"><img border="0" src="http://ad.adverticum.net/img.prm?zona=28057&nah=!ie" alt="Kattintson a hirdetésre!" /></a></noscript>
On Mon, Mar 06, 2006 at 11:23:27AM +0100, Keve wrote:
Hi,
I am not very familiar with Postgresql. I wrote taxonomy_access.install file, but for POSTGRESQL priot to 8.0, I need to make a BIT_OR aggregate function. Do you think this will work OK for pg?
if (version_compare(pg_version(), '8.0', '<')) { // PRIOR TO POSTGRESQL 8.0: making a BIT_OR aggregate function }
That has problems. Here's something that I've put together for the update process, though it has not been incorporated yet. Then there's similar thinking for the install process. Considering the need to know server version numbers in several places, I hope code along the following lines gets incorporated into database.inc: function get_db_server_version() { static $version; if (isset($version)) { return $version; } switch ($GLOBALS['db_type']) { case 'mysql': case 'mysqli': if (function_exists('mysql_get_server_info')) { // Since: MySQL library: 4.0.1-alpha, PHP: 4.0.5. $version = mysql_get_server_info($GLOBALS['active_db']); } else { $row = db_fetch_object(db_query('SELECT version() AS version')); $version = $row->version; } $version = str_replace(array('-debug','-max','-nt','-opt'), '', $version); break; case 'pgsql': /* * Not using pg_version() because it is only available in PHP 5 and with * PostgreSQL library: 7.4. More importantly, the 'server_version' * is missing, at least in PHP 5.1.2. */ $row = db_fetch_object(db_query('SELECT version() AS version')); $version = preg_replace('/^[^0-9]+([^ ]+).*/i', '\\1', $row->version); break; default: $version = 0; } return $version; } --Dan -- T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y data intensive web and database programming http://www.AnalysisAndSolutions.com/ 4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409
On Mon, Mar 06, 2006 at 09:44:57AM -0500, Daniel Convissor wrote:
function get_db_server_version() { static $version;
if (isset($version)) { return $version; }
Hmm... Upon further thought, that line will need tweaking because in testing and edge cases, the database connection may get changed. So, perhaps something like this: function get_db_server_version() { static $version, $prior_active_db; if (isset($version) && isset($prior_active_db) && $prior_active_db == $GLOBALS['active_db']) { return $version; } $prior_active_db = $GLOBALS['active_db']; --Dan -- T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y data intensive web and database programming http://www.AnalysisAndSolutions.com/ 4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409
participants (3)
-
Adrian Rossouw -
Daniel Convissor -
Keve