View Issue Details

IDProjectCategoryView StatusLast Update
0014375mantisbtdb postgresqlpublic2014-05-16 15:02
Reporterdhaun Assigned Todregad  
PrioritynormalSeveritycrashReproducibilityalways
Status closedResolutionduplicate 
Product Version1.2.11 
Summary0014375: Postgres SQL error: smallint vs. boolean
Description

After logging in to a freshly upgraded MantisBT 1.2.11, I am confronted with this error message:

--- snip ---
APPLICATION ERROR 0000401

Database query failed. Error received from database was #-1: ERROR: operator does not exist: smallint = boolean
LINE 5: AND (is_public = true
^
HINT: No operator matches the given name and argument type(s). You may need to add explicit type casts. for the query: SELECT * FROM mantis_filters_table
WHERE (project_id=?
OR project_id=0)
AND name!=''
AND (is_public = true
OR user_id = ?)
ORDER BY is_public DESC, name ASC.
--- snip ---

This is MantisBT running on PostgreSQL (8.2.6 if that matters). It seems the field is_public isn't really a boolean but a smallint.

Additional Information

I've tracked the error down to the SQL query in function filter_db_get_available_queries() in core/filter_api.php

Replacing

AND (is_public = " . db_prepare_bool(true) . "

with

AND (is_public = " . ((int) true) . "

fixes the issue for now.

Note: The same SQL query is also in function mci_filter_db_get_available_queries() in api/soap/mc_api.php and can be fixed in the same way.

TagsNo tags attached.
Attached Files
mantisbt-schema.png (26,535 bytes)   
mantisbt-schema.png (26,535 bytes)   

Relationships

duplicate of 0015440 closeddregad schema not updated - error assuming smallint is boolean 
related to 0014385 closeddregad Impossible to create a new project with fresh install on PostgreSQL 
related to 0014288 closeddregad Manage User not reachable due to error in PostgreSQL 

Activities

dregad

dregad

2012-06-09 08:42

developer   ~0032050

This was introduced by commit c8a0c592.

However, I'm surprised by your statement "It seems the field is_public isn't really a boolean but a smallint." - as per schema definition (admin/schema.php), the field's type is "L" which should translate to bool.

dhaun

dhaun

2012-06-09 09:00

reporter   ~0032051

is_public is a smallint in our database. Maybe something went wrong during the update (from MantisBT 1.2.10)? I didn't see any error messages during the update, though.

So would you suggest I'd change is_public to a boolean manually and revert the changes I mentioned above?

dregad

dregad

2012-06-11 12:15

developer   ~0032069

Last edited: 2012-06-11 12:16

I just did a fresh install of mantisbt 1.2.11 on Postgres (9.1, but I don't think that should not make any difference), and the mantis_filters_table.is_public column is of type bool


Column | Type | Modifiers
--------------+-----------------------+-------------------------------------------------------------------
id | integer | not null default nextval('mantis_filters_table_id_seq'::regclass)
user_id | integer | not null default 0
project_id | integer | not null default 0
is_public | boolean |
name | character varying(64) | not null default ''::character varying
filter_string | text | not null

I did find other issues with int/bool type mismatches in the code though, e.g.
mantis_project_table.inherit_global is defined as unsigned int in the DB, but handled as bool in the code.

grangeway

grangeway

2012-06-11 13:52

reporter   ~0032070

dhaun,

You are probably best to run mysql if you can for a bit - the postgres/oracle/mssql support is fairly broken in 1.2 atm (IMO at least)

For the next major version of mantis, we are looking at replacing the db layer to try to fix these sorts of issues.

Paul

dregad

dregad

2012-06-12 09:17

developer   ~0032082

In relation to my earlier note 0014375:0032069, please refer to issue 0014385.

There is a good chance that the issue you experience was also introduced by the same commit b8d4b503; can you please try to revert it and report here if that fixes the problem.

It may also be useful if you could provide step-by-step instructions to reproduce your problem.

dregad

dregad

2012-06-13 13:08

developer   ~0032091

I thought some more about it, and since this column was never defined as anything other than "L" in the schema definition (which translates to boolean in postgres) since the installation code creation back in 2005, I can only conclude that you having it as smallint is the result of a manual update or a very old (pre 1.0.0) upgrade that was not properly executed.

Therefore I suggest that you alter the column definition to boolean, and disregard my previous suggestion to revert b8d4b503.

dregad

dregad

2013-02-01 04:51

developer   ~0035006

Based on analysis in 0015440, this is due to changes in ADOdb data dictionary for postgres. Due to this, MantisBT versions < 1.1.0 created all "L" type columns as SMALLINT, whereas later releases used the BOOLEAN type.

grangeway

grangeway

2014-05-16 15:02

reporter   ~0040522

MantisBT currently supports Mysql and has support for other database engines.

The support for other databases is known to be problematic.

Having implemented the current database layer into Mantis 10 years ago, I'm currently working on replacing the current layer.

If you are interested in using Mantis with non-mysql databases - for example, Oracle, PGSQL or MSSQL, and would be willing to help out testing the new database layer, please drop me an email at paul@mantisforge.org

In the meantime, I'd advise running Mantis with Mysql Only to avoid issues.

Thanks
Paul