From 56c202127c1eb66029c461c946a36ba1a0158474 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Fri, 28 Jan 2011 21:06:49 -0500 Subject: [PATCH 1/3] [ticket/10016] Fixed varchar to decimal cast on postgresql 7.x. PHPBB3-10016 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 9a8cc5d6b3..7632d8790d 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -176,7 +176,7 @@ function set_config_count($config_name, $increment, $is_dynamic = false) { case 'firebird': case 'postgres': - $sql_update = 'CAST(CAST(config_value as DECIMAL(255, 0)) + ' . (int) $increment . ' as VARCHAR(255))'; + $sql_update = 'CAST(CAST(config_value::text as DECIMAL(255, 0)) + ' . (int) $increment . ' as VARCHAR(255))'; break; // MySQL, SQlite, mssql, mssql_odbc, oracle From 841061426ded7100624496a915e8669d81d197c9 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 5 Mar 2011 22:48:24 +0100 Subject: [PATCH 2/3] [ticket/10016] Leave Firebird unchanged. PHPBB3-10016 --- phpBB/includes/functions.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 7632d8790d..ef71a4e7fd 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -175,6 +175,9 @@ function set_config_count($config_name, $increment, $is_dynamic = false) switch ($db->sql_layer) { case 'firebird': + $sql_update = 'CAST(CAST(config_value as DECIMAL(255, 0)) + ' . (int) $increment . ' as VARCHAR(255))'; + break; + case 'postgres': $sql_update = 'CAST(CAST(config_value::text as DECIMAL(255, 0)) + ' . (int) $increment . ' as VARCHAR(255))'; break; From 9cdeb51a5287844be1cd8671284d625d41e9b2fa Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 5 Mar 2011 22:55:58 +0100 Subject: [PATCH 3/3] [ticket/10016] Add comment for text casting (for PostgreSQL 7.x) PHPBB3-10016 --- phpBB/includes/functions.php | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index ef71a4e7fd..fb90ee5f50 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -179,6 +179,7 @@ function set_config_count($config_name, $increment, $is_dynamic = false) break; case 'postgres': + // Need to cast to text first for PostgreSQL 7.x $sql_update = 'CAST(CAST(config_value::text as DECIMAL(255, 0)) + ' . (int) $increment . ' as VARCHAR(255))'; break;