Advertisement:

Author Topic: [SMF 2.0 RC2] The database value you're trying to insert does not exist: value  (Read 2337 times)

Offline TheStupidOne

  • Semi-Newbie
  • *
  • Posts: 20
    • Maidens of the Kaleidoscope
Confirmed on both new install and upgrade installs of SMF 2.0 RC2 using PostgreSQL as the database backend.  I am hosting it on a stock Debian Stable distro using LigHTTPd and PHP5 in FastCGI, software versions are as follows:

LigHTTPd 1.4.19
PHP 5.2.6-1+lenny3
PostgreSQL 8.3.8
XCache 1.2.2

The problem is with the handling code in Sources/Subs-Db-postgresql.php, specifically the routine for setting up an UPDATE template for a "replace" query.  By replacing the file with the RC1 version the forum is usable, further debugging determined it to be the following routine change between RC1 and RC2.

Code: [Select]
*** 579,600 ****
  // Setup an UPDATE template.
  $updateData = '';
  $where = '';
- $count = 0;
  foreach ($columns as $columnName => $type)
  {
  // Are we restricting the length?
  if (strpos($type, 'string-') !== false)
! $actualType = sprintf($columnName . ' = SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $count);
  else
! $actualType = sprintf($columnName . ' = {%1$s:%2$s}, ', $type, $count);
 
  // Has it got a key?
  if (in_array($columnName, $keys))
  $where .= (empty($where) ? '' : ' AND ') . substr($actualType,0, -2);
  else
  $updateData .= $actualType;
-
- $count++;
  }
  $updateData = substr($updateData, 0, -2);
 
--- 613,631 ----
  // Setup an UPDATE template.
  $updateData = '';
  $where = '';
  foreach ($columns as $columnName => $type)
  {
  // Are we restricting the length?
  if (strpos($type, 'string-') !== false)
! $actualType = sprintf($columnName . ' = SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName);
  else
! $actualType = sprintf($columnName . ' = {%1$s:%2$s}, ', $type, $columnName);
 
  // Has it got a key?
  if (in_array($columnName, $keys))
  $where .= (empty($where) ? '' : ' AND ') . substr($actualType,0, -2);
  else
  $updateData .= $actualType;
  }
  $updateData = substr($updateData, 0, -2);

That removal of $count and changing the sprintfs to have $columnName rather than $count as the last argument breaks any operation that results in an SQL update.  By reverting it back to the RC1 changes, it works perfectly.  Attached is a diff for the exact patch to be made.  Apply with "patch -p1 < /path/to/diff" while in your SMF install location.
« Last Edit: November 18, 2009, 12:50:49 PM by TheStupidOne »

Offline habakuk

  • Semi-Newbie
  • *
  • Posts: 85
I asked about a similar (or identical) problem in the suport forum. So, I guess it's worth adding my voice here:

I cannot install RC2 freshly on the following setup:

MacOSX 10.5.8
Apache  2.2.13
PHP 5.2.11
postgres 8.3.5

Failes on step 5 and leaves me with a bord with just the plain text error as stated in the subject of this thread.
My detailed report can be found here.

thanks

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,035
    • Arantor on GitHub
Seems to be PostgreSQL that's the common factor.

There are some issues still in it though :(
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Offline TheStupidOne

  • Semi-Newbie
  • *
  • Posts: 20
    • Maidens of the Kaleidoscope
Well I understand it's still very much a beta candidate and I don't mind making a few tweaks and code fixes to get it working properly.  It's nice that PostgreSQL support is being attempted at all.  I can't stand MySQL and noone else seems to want to give PostgreSQL some love :\

I'm still testing everything out on RC2 before I move my production forum to it from RC1, will report if I find anything else broken.

Offline Norv

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 18,313
  • Blue Wolf
The problem is with the handling code in Sources/Subs-Db-postgresql.php, specifically the routine for setting up an UPDATE template for a "replace" query.  By replacing the file with the RC1 version the forum is usable, further debugging determined it to be the following routine change between RC1 and RC2.

Code: [Select]
*** 579,600 ****
  // Setup an UPDATE template.
  $updateData = '';
  $where = '';
- $count = 0;
  foreach ($columns as $columnName => $type)
  {
  // Are we restricting the length?
  if (strpos($type, 'string-') !== false)
! $actualType = sprintf($columnName . ' = SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $count);
  else
! $actualType = sprintf($columnName . ' = {%1$s:%2$s}, ', $type, $count);
 
  // Has it got a key?
  if (in_array($columnName, $keys))
  $where .= (empty($where) ? '' : ' AND ') . substr($actualType,0, -2);
  else
  $updateData .= $actualType;
-
- $count++;
  }
  $updateData = substr($updateData, 0, -2);
 
--- 613,631 ----
  // Setup an UPDATE template.
  $updateData = '';
  $where = '';
  foreach ($columns as $columnName => $type)
  {
  // Are we restricting the length?
  if (strpos($type, 'string-') !== false)
! $actualType = sprintf($columnName . ' = SUBSTRING({string:%1$s}, 1, ' . substr($type, 7) . '), ', $columnName);
  else
! $actualType = sprintf($columnName . ' = {%1$s:%2$s}, ', $type, $columnName);
 
  // Has it got a key?
  if (in_array($columnName, $keys))
  $where .= (empty($where) ? '' : ' AND ') . substr($actualType,0, -2);
  else
  $updateData .= $actualType;
  }
  $updateData = substr($updateData, 0, -2);

That removal of $count and changing the sprintfs to have $columnName rather than $count as the last argument breaks any operation that results in an SQL update.  By reverting it back to the RC1 changes, it works perfectly.  Attached is a diff for the exact patch to be made.  Apply with "patch -p1 < /path/to/diff" while in your SMF install location.

Confirmed, and it's already fixed at this point in svn. Thank you for your report.
To-do lists are for deferral. The more things you write down the later they're doneā€¦ until you have 100s of lists of things you don't do.
File a security report | Developers' Blog | Bug Tracker

Also known as Norv on D* | Norv N. on G+ | Norv on Github