Closed Bug 469453 Opened 16 years ago Closed 16 years ago

SQL error when deleting a Status: invalid input syntax for integer

Categories

(Bugzilla :: Administration, task)

task
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 3.2

People

(Reporter: thivnor, Assigned: mkanat)

References

Details

(Whiteboard: [doesn't affect tip])

Attachments

(2 files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4
Build Identifier: Bugzilla 3.2 

I have bugzilla 3.2 running on PostgreSQL version  8.3.5. I tried to delete the "NEW" Status and got the following error:

DBD::Pg::db do failed: ERROR:  invalid input syntax for integer: "{"2"}" [for Statement "DELETE FROM status_workflow WHERE old_status = ? OR new_status = ?"] at /home/www-data/bugzilla-3.2/editvalues.cgi line 355



Reproducible: Always

Steps to Reproduce:
First you must ensure no bugs have Status=NEW. I did a search for all NEW bugs, and used Change Several bugs at once to make them ASSIGNED.

Then, I open: Administration --> Field Values --> Status.

Click "Delete" on the "New" row. Confirm when prompted. Observe error. 
2.
3.
Actual Results:  
Error message

Expected Results:  
Should have removed the NEW status
I suspect the problem is that you're running a development version of DBD::Pg or something like that. Can you attach the output of your checksetup.pl (or just find out if you're running an unstable DBD::Pg and downgrade it)?
Attached is the output from checksetup.pl. The key info is:

Checking for              DBD-Pg (v1.45)   ok: found v2.11.3
Checking for      PostgreSQL (v8.00.0000) ok: found v08.03.0500

I'm not intentionally using development versions of any Perl libraries. I used CPAN to pull that stuff down. I may have flubbed something, when doing all that CPAN stuff.
Hmmm. That doesn't look like a development version...but it still might be busted. Can you try downgrading your DBD::Pg module? (This is somewhat difficult to do, but possible.) Particularly to a stable version below 2.0.
Well, I can _try_ :)

I found an older copy of the module from here:

http://search.cpan.org/~dbdpg/DBD-Pg-1.49/

This appears to the last of the 1.x line. 

I've downloaded it, unpacked it, and built it using the instructions in the README. Specifically:

        1.   perl Makefile.PL
        2.   make
        3.   make test
        4.   make install

After installing the new Perl module, and running checksetup.pl, I'm still getting v2.11.3.  It appears that the make install step installs the module into my overall Perl library. But Bugzilla maintains its own library of Perl modules, in the lib folder.

I can't figure out how to install the DBD::Pg module into Bugzilla. The install-module.pl script appears hardwired to CPAN, it doesn't look like it will accept a local tarball. And I'm not sure what the manual install process would look like. I tried replacing the Pg.pm file, in /lib/i486-linux-gnu-thread-multi/DBD, but that made things worse. 

Do you know the process for installing a module manually, into Bugzilla's library?
Just find the DBD::Pg-related files in the lib/ directory and delete them, and then Bugzilla will use the overall-installed thing. There will be a .so, it's particularly important that you delete that.
Oh, OK, I missed the Pg.so and Pg.bs files. 

So, I've deleted all 3 of the Pg files from lib: Pg.pm, Pg.so, and Pg.bs. Running checksetup.pl now reports:

Checking for              DBD-Pg (v1.45)   ok: found v1.49
Checking for      PostgreSQL (v8.00.0000) ok: found v08.03.0500

Now, going back and trying to delete the Status, I get the following error:

Cannot bind a reference (ARRAY(0x90ab2b8)) ((null)) (1) type=3 10 4 0 at /home/www-data/bugzilla-3.2/editvalues.cgi line 355.

This is the same place (line 355 of editvalues.cgi) as before, but the message is different. 

There is almost certainly a better way to get debug info, but I added this:

 ThrowUserError($status_id);

Just before the database call. I got back:

"The user error string ARRAY(0x90ab42c) was not found."

In other words, $status_id isn't a scalar at all, it is an array. So this doesn't appear to be a database error. 

As an aside, there is a work-around, which is to just edit the workflow. So I'm not stuck or anything. That said, there is definitely something odd afoot. 

I get the same error if I try to delete a Status value which I have added. So you don't have to blow away the NEW status, to dup this bug. Just create a new Status, then try to delete it.
  I can't reproduce the bug, but it clearly exists:

        my $status_id = $dbh->selectrow_arrayref('SELECT id FROM bug_status
                                                  WHERE value = ?', undef, $value);
        $dbh->do('DELETE FROM status_workflow
                  WHERE old_status = ? OR new_status = ?',
                  undef, ($status_id, $status_id));

  That should not be selectrow_arrayref, obviously.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: blocking3.2.1+
OS: Windows XP → All
Hardware: PC → All
Target Milestone: --- → Bugzilla 3.2
Version: unspecified → 3.2
Ah, I couldn't reproduce it because I was using the tip, and it doesn't have this bug! :-) (We moved to using Bugzilla::Field::Choice in editvalues.cgi, and I fixed this bug without even noticing.)
Whiteboard: [doesn't affect tip]
Attached patch v1Splinter Review
Here, an obvious and simple fix.
Assignee: administration → mkanat
Status: NEW → ASSIGNED
Attachment #352835 - Flags: review?(LpSolit)
Depends on: bz-custstat
Attachment #352835 - Flags: review?(LpSolit) → review+
Comment on attachment 352835 [details] [diff] [review]
v1

Hum... I didn't catch this problem while writing the original code because MySQL doesn't complain and behaves correctly (just checked again right now). But I can indeed reproduce the bug on 3.2 with PostgreSQL. r=LpSolit
Flags: approval3.2+
That patch works great, thanks!
Checking in editvalues.cgi;
/cvsroot/mozilla/webtools/bugzilla/editvalues.cgi,v  <--  editvalues.cgi
new revision: 1.30.2.1; previous revision: 1.30
done
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: