Opened 6 years ago

Closed 3 years ago

Last modified 3 years ago

#119 closed defect (fixed)

casting fails with user-defined types

Reported by: dmisev Owned by: vliaukevich
Priority: major Milestone: 9.0.x
Component: conversion Version: 8.3
Keywords: Cc: pbaumann, dmisev
Complexity: Medium

Description

Casting to a user-defined composite type fails, e.g. assuming a base type

struct CustomPixel { octet band1, band2, band3, band4; };

has been inserted with rasdl, the following statement fails:

insert into coll values (CustomPixel) inv_tiff($1)

Change History (18)

comment:1 Changed 5 years ago by pbaumann

  • Milestone set to 9.0

comment:2 Changed 4 years ago by pbaumann

  • Cc dmisev added
  • Complexity set to Very Hard

Dimitar, do you think his is a cast or a "TIFF with 4 bands" problem?

comment:3 Changed 4 years ago by dmisev

The casting itself is the issue, has nothing to do with the convertor function.

comment:4 Changed 3 years ago by dmisev

  • Owner changed from dmisev to vliaukevich
  • Status changed from new to assigned

comment:5 Changed 3 years ago by vliaukevich

  • Resolution set to fixed
  • Status changed from assigned to closed

comment:6 Changed 3 years ago by dmisev

  • Complexity changed from Very Hard to Medium
  • Resolution fixed deleted
  • Status changed from closed to reopened

I submitted a patch with a test in source:systemtest/testcases_mandatory/test_conversion

(TestPixel) decode($1) seems to work fine, but (TestPixel) inv_tiff($1) fails with

Error: QtConversion::evaluate() no structure type compatible found

comment:7 Changed 3 years ago by vliaukevich

Did you recompile code? Both selection and insertion with inv_tiff work for me, the test from your patch is passed.

comment:8 Changed 3 years ago by dmisev

Hmm yes I did recompile, this is the output of my test:

test.sh: ----- user-defined type conversion ------
test.sh: creating collection... ok.
rasdaman error 2002: Internal error: Entry in user defined type not found.
test.sh: user-defined base type cast inf_tiff test failed.
test.sh: user-defined base type cast decode test passed.

comment:9 Changed 3 years ago by vliaukevich

(By the way, you have a typo: "inV_tiff test passed").
That's strange:

test.sh: ----- user-defined type conversion ------
test.sh: creating collection... ok.
test.sh: user-defined base type cast inf_tiff test.
test.sh: user-defined base type cast decode test passed.

Does "select (TestPixel) inv_tiff($1)" also fail?

comment:10 Changed 3 years ago by dmisev

Strange indeed, and select fails as well

rasql: rasdaman query tool v1.0, rasdaman v9.0.1-ge5210e4 -- generated on 13.05.2014 14:27:43.
opening database RASBASE at localhost:7001...ok
fetching type information for GreyString from database, using readonly transaction...ok
reading file /home/dimitar/projects/rasdaman/community/src/systemtest/testcases_mandatory/test_conversion/testdata/multiband.tif...ok
  constant 1: GMarray
  Oid...................: 
  Type Structure........: 
  Type Schema...........: marray< char >
  Domain................: [0:691]
  Base Type Schema......: char
  Base Type Length......: 1
  Data format.......... : Array
  Data size (bytes).... : 692
Executing retrieval query...rasdaman error aborting transaction...2002: Internal error: Entry in user defined type not found.
ok
rasql done.

comment:11 Changed 3 years ago by dmisev

These are the last commits from git log

* e5210e4 (HEAD, master) ticket:119 - add conversion test
* 053b4fe (origin/master, origin/HEAD) ticket:707 - Hide debug output in StorageLayout
* 4383ed3 ticket:119 - Casting with user-defined types
* 251db02 ticket:210 - Fix null pointer dereference
...

comment:12 Changed 3 years ago by vliaukevich

I have the same commits order, and the working directory is clean.

Try just "select inv_tiff($1)", the error message seems to appear during conversion, not casting.

comment:13 Changed 3 years ago by dmisev

Yes indeed, still same error

Request: 'select inv_tiff(#MDD0#)'...parsing...checking semantics...evaluating...Error: QtConversion::evaluate() no structure type compatible found

comment:14 Changed 3 years ago by vliaukevich

I took a look at QtConversion code, it doesn't create a new temprorary type after the conversion is done, but searches for an appropriate among already existing. On my system it succeeds, on yours fails, so we need to change this behaviour. I will have a look later.

comment:15 Changed 3 years ago by dmisev

  • Resolution set to fixed
  • Status changed from reopened to closed

It seems that the inv_tiff returns a struct of chars, rather than of octets.
The TestPixel is a struct of 4 octets, which doesn't match a struct of 4 chars, so that's why it fails.
The input testdata file multiband.tif has char bands, after creating a multiband.tif with octet bands it works fine. Still puzzled how it worked for you though :)
In any case, it was an issue of the test and not the implementation, so reclosing the ticket.

comment:16 Changed 3 years ago by vliaukevich

Wait, this is what casting is about: converting one types into others. You can convert char into octet without any problem (try "select (octet) 128"), the result should be 127 because of overflow. This is how it works now for base types, so I think it should work in the same way for attributes of structures.

decode($1) also returns structure of chars, which is later converted to structure of octets (TestPixel), and this works for you as well.

Last edited 3 years ago by vliaukevich (previous) (diff)

comment:17 Changed 3 years ago by dmisev

Yes, so inv_tiff should actually create a temporary struct, if it cannot find the corresponding type in the database.

comment:18 Changed 3 years ago by vliaukevich

Yes, exactly

Note: See TracTickets for help on using tickets.