Bug 1225428 - Searching in templates return database error
Summary: Searching in templates return database error
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Virtualization Manager
Classification: Red Hat
Component: ovirt-engine
Version: 3.6.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ovirt-3.6.0-rc
: 3.6.0
Assignee: Shmuel Melamud
QA Contact: sefi litmanovich
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-05-27 11:00 UTC by Karolína Hajná
Modified: 2016-05-20 01:24 UTC (History)
13 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-04-20 01:38:29 UTC
oVirt Team: Virt
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
oVirt gerrit 41884 0 master MERGED core: Search templates by version name only Never

Description Karolína Hajná 2015-05-27 11:00:00 UTC
Description of problem:
When using search for templates, it results in

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<fault>
    <reason>Operation Failed</reason>
    <detail>statementcallback; bad sql grammar [select * from (select * from vm templates view where ( vmt guid in (select distinct vm templates storage domain.vmt guid from  vm templates storage domain   where  (  vm templates storage domain.description like '%%%' or  vm templates storage domain.free text comment like '%%%' or  vm templates storage domain.name like '%%%' or  vm templates storage domain.quota name like '%%%' or  vm templates storage domain.storage pool name like '%%%' or  vm templates storage domain.template version name, template version number like '%%%' or  vm templates storage domain.vds group name like '%%%' ) ))  order by name asc ) as t1 offset (1 -1) limit 2147483647]; nested exception is org.postgresql.util.psqlexception: error: argument of or must be type boolean, not type character varying
  position: 447</detail>
</fault>


Version-Release number of selected component (if applicable):
3.6.0-0.0.master.20150519172222.git9a2e2b3.el7

How reproducible:
100%

Steps to Reproduce:
1. Use
curl -k -u admin@internal -i -H "Accept: application/xml" https://{engine_ip}/api/templates\;from\=\?search\=*


Actual results:
database error

Expected results:
listed templates

Comment 1 Omer Frenkel 2015-05-28 08:58:41 UTC
this part looks wrong:

...
templates storage domain.template version name, template version number like '%%%' or  
...

template_version_name is not compared to any value, and template_version_number is not a string at all, i dont think it should be queried here at all

not sure if infra or virt, Eli, please let me know what you find/decide

as a workaround i recommend not to use this kind of "search all fields for string"
you can search for string in specific fields, like:

curl -k -u admin@internal -i -H "Accept: application/xml" https://{engine_ip}/api/templates\;from\=\?search\=name\=*

Comment 2 Eli Mesika 2015-05-28 09:22:48 UTC
(In reply to Omer Frenkel from comment #1)
> this part looks wrong:
> 
> ...
> templates storage domain.template version name, template version number like
> '%%%' or  
> ...
> 
> template_version_name is not compared to any value, and
> template_version_number is not a string at all, i dont think it should be
> queried here at all
> 
> not sure if infra or virt, Eli, please let me know what you find/decide
> 

I think its virt 

origin : backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/VmTemplateConditionFieldAutoCompleter.java

code : columnNameDict.put(VERSION_NAME_AND_NUMBER, "template_version_name, template_version_number");

AFAIK, the search engine does not support here multiple columns, especially when one is varchar and the other is int so the "like" operation will fail.

If both version name and number are needed here, maybe add a computed column to the view that is varchar and concat both and then use this column here

Comment 3 Omer Frenkel 2015-05-28 10:17:43 UTC
ok, thanks.
i dont think we need a computed column, currently it doesnt look like the sorting for the version column in the ui works well..
i think it should be on version name only, should fix both search and sorting issues.

moving to virt

Comment 4 Max Kovgan 2015-06-28 14:12:43 UTC
ovirt-3.6.0-3 release

Comment 5 sefi litmanovich 2015-07-13 15:42:17 UTC
Verified with ovirt-engine-3.6.0-0.0.master.20150627185750.git6f063c1.el6.noarch
according the description:

curl -k -u admin@internal -i -H "Accept: application/xml" https://{engine_ip}/api/templates\;from\=\?search\=name\=*

returned all the templates as expected.

Comment 6 Bimal Chollera 2015-10-20 18:14:31 UTC
Problem seen on RHEV 3.5.3. as well.

Comment 7 sefi litmanovich 2015-10-25 12:24:17 UTC
did not re produce on rhevm-3.5.5-0.1.el6ev.noarch so need to open z-stream bz.


Note You need to log in before you can comment on or make changes to this bug.