Home > Archive > IQ Server > March 2005 > Query with CAST and CASE in subquery fails









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Query with CAST and CASE in subquery fails
Alexander Sinitsin

2005-03-30, 7:08 pm

Hi All!

IQ 12.5 ESD 11. Reproduced on Windows and SUN. Seems this is a bug, so be warned.

Query example:

SELECT
t2.f1 ,
t2.f2 ,
t2.f3 ,
CAST(
CASE WHEN t2.f3 = 'A' THEN '1'
WHEN t2.f3 = 'B' THEN '2'
WHEN t2.f3 = 'K' THEN '3'
WHEN t2.f3 = 'J' THEN '4'
WHEN t2.f3 = 'D' THEN '5'
WHEN t2.f3 = 'E' THEN '6'
WHEN t2.f3 = 'F' THEN '7'
WHEN t2.f3 = 'G' THEN '8'
WHEN t2.f3 = 'H' THEN '9'
WHEN t2.f3 = 'Z' THEN '99'
ELSE NULL
END
AS VARCHAR(30)) AS f4,
t2.f5
FROM
( SELECT
CAST(
CASE
WHEN t1.f2 BETWEEN '01' AND '04' THEN '01-04'
WHEN t1.f2 BETWEEN '05' AND '08' THEN '05-08'
WHEN t1.f2 BETWEEN '10' AND '15' THEN '10-15'
WHEN t1.f2 BETWEEN '18' AND '20' THEN '18-20'
WHEN t1.f2 BETWEEN '210' AND '230' THEN '210-230'
ELSE 'unmatched'
END
AS varchar(20) ) AS f1 ,
t1.f2 ,
t1.f3 ,
CAST(COUNT(*) AS INT) AS f5
FROM MainTable t1
WHERE
t1.f2 = 1
GROUP BY f1, f2, f3
) AS t2

When I omit CAST in subquery, query is OK:

( SELECT
CASE
WHEN t1.f2 BETWEEN '01' AND '04' THEN '01-04'
. . .
END AS f1 ,

Server log contains these rows:

2005-03-02 10:58:38 0000000128 ********************
********************
****************
2005-03-02 10:58:38 0000000128 **
2005-03-02 10:58:38 0000000128 ** Non-Fatal IQ Internal Error Detected
2005-03-02 10:58:38 0000000128 ** at dfo.cxx:5159 on thread 84
2005-03-02 10:58:38 0000000128 **
2005-03-02 10:58:38 0000000128 ** Please report this to Sybase IQ support
2005-03-02 10:58:38 0000000128 ** with the following diagnostic information,
2005-03-02 10:58:38 0000000128 ** and, if possible, with the user's command.
2005-03-02 10:58:38 0000000128 **
2005-03-02 10:58:38 0000000128 ** IQconnectID: 2
2005-03-02 10:58:38 0000000128 ** Adaptive Server IQ/12.5.0/030305/P/GA
2005-03-02 10:58:38 0000000128 ** 2005-03-02 10:58:38
2005-03-02 10:58:38 0000000128
IQ built on: MS/Windows NT 4.0, Executed on: Windows/SERVERNAME/WinNT/5.2/Build 3790//x86 Family/level 6/Model 8/Stepping 10/1 CPU(s)
2005-03-02 10:58:38 0000000128 ** while executing this command from user: DBA
COMMAND: <actual query>
CURSOR ACTIVE

2005-03-02 10:58:38 0000000128 ***************** This is the STACKTRACE ***************
2005-03-02 10:58:38 0000000128
===== Thread Number 1940 =====
2005-03-02 10:58:38 0000000128 pc: 0xd56958 ()
2005-03-02 10:58:38 0000000128 pc: 0x127d961c void near StackTraceForThisThr
ead( char const near *, int, char const near *, char const near * ) +0xbdc(0x4e670000, 0x4e6b3294, 0x12c43fdc, 0x130a0e00, 0x184ea244)
2005-03-02 10:58:38 0000000128 pc: 0x12386137 near df_Exception::df_Exc
eption( char const near *, int, int, char const near *, char const near *, dfo const near *, df_Evaluable const near * ) +0x1b7(0x4e6bdcfc, 0x0, 0x0, 0x0, 0x1)
2005-03-02 10:58:38 0000000128 pc: 0x1247ef8c void near dfo::ValidateOutputV
ectors() +0xd0c(0x1, 0x54, 0x0, 0x1, 0x12d03c94)
2005-03-02 10:58:38 0000000128 pc: 0x1247e3fc void near dfo::ValidateOutputV
ectors() +0x17c(0x1, 0x54, 0x0, 0x1, 0x12d03c94)
2005-03-02 10:58:38 0000000128 pc: 0x1247e3fc void near dfo::ValidateOutputV
ectors() +0x17c(0x1, 0x54, 0x0, 0x1, 0x12d03c94)
2005-03-02 10:58:38 0000000128 pc: 0x1247e3fc void near dfo::ValidateOutputV
ectors() +0x17c(0x184edb7c, 0x12cfc4a4, 0x0, 0x123b54a0, 0x444)
2005-03-02 10:58:38 0000000128 pc: 0x124a1803 void near dfo_Root::Prepare() +0x3e3(0x12c43fdc, 0xcc0900, 0x184ee32c, 0x127b0000, 0xcc0038)
2005-03-02 10:58:38 0000000128 pc: 0x12a3437b void near st_cursorIQtoSA::Pre
pare() +0x5bb(0x124d56a1, 0x130807e0, 0x130807e0, 0x12775b5e, 0x13)
2005-03-02 10:58:38 0000000128 pc: 0x124dfcb9 void near df_OpenCursor::Prepa
re() +0x6b(0xffffffff, 0xffffe3e0, 0x12c46f2e, 0x64, 0x184eea48)
2005-03-02 10:58:38 0000000128 pc: 0x12a3087a void near st_command::DoCmdThr
oughResourceGate() +0x2ea(0x3, 0x54, 0x0, 0x1, 0x12d00fb4)
2005-03-02 10:58:38 0000000128 pc: 0x12a4921b int near st_iqdml::OpenCursor
( a_statement near *, UIConnection near *, UICursor near *, int unsigned, __anonymous_enum ) +0x2b(0x2, 0x1, 0xcc1a30, 0x10ecfbb0, 0x10ecfbb0)
2005-03-02 10:58:38 0000000128 pc: 0x12a64bd1 UIQDML_OpenCursor_ +0x21(0x184ef1e8, 0x13080970, 0x184ef1e8, 0xcc1a30, 0xcc1a48)
2005-03-02 10:58:38 0000000128 pc: 0x12a5f7d6 void near st_thrInterfaceInfo:
:callFunction() +0x16(0x0, 0x0, 0x0, 0x0, 0x0)
2005-03-02 10:58:38 0000000128 pc: 0x12a61345 void near st_threadInterface::
IQwaitForFunc() +0x265(0x0, 0x0, 0x0, 0x0, 0x0)
2005-03-02 10:58:38 0000000128 pc: 0x12a61b21 IQLeaderThread_ +0x31(0x175e5260, 0x0, 0x0, 0x0, 0x0)
2005-03-02 10:58:38 0000000128 pc: 0x127dd3ec int near hos_thread::Main() +0x1fc(0x0, 0x0, 0x0, 0x0, 0x0)
2005-03-02 10:58:38 0000000128 pc: 0x127752f5 int near hos_lwtask::Start( hos_lwtask near * ) +0x205(0x175e5260, 0x184effdc, 0x12c4ba80, 0x175e5260, 0x184effec)
2005-03-02 10:58:38 0000000128 pc: 0x12c4cb1c void near vpe_HostVar::Constru
ctKey() +0xb85c(0x0, 0x130c5e50, 0x77e4a990, 0x130c5e50, 0x0)
2005-03-02 10:58:38 0000000128 ******************* End of STACKTRACE ******************
2005-03-02 10:58:38 0000000128 **
2005-03-02 10:58:38 0000000128 ** End of Non-Fatal stack trace from dfo.cxx:5159
2005-03-02 10:58:38 0000000128 **
2005-03-02 10:58:38 0000000128 ********************
********************
****************

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com