Select literal causes the next select empty string to return junk
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Trafodion |
Fix Released
|
Critical
|
Howard Qin |
Bug Description
As shown in the following example. The 1st query selects a literal with 10 characters. It causes the 2nd query, which selects '', to return rows with junk. It only happens when the 2 queries are executed together. The problem seems to go away if the 1st query is commented out.
This is seen on the v0105_0830 build installed on a cluster. As the nature of junk result often is, it can’t be reproduced 100%, but it does occur often enough. It is likely to be a regression introduced sometime between the v1218_0830 daily build and the v0105_0830 daily build.
-------
Here is the entire script to reproduce it:
create schema mytest;
set schema mytest;
create table t (a int);
insert into t values (1),(2);
select '0123456789' from t;
select '' from t;
drop schema mytest cascade;
-------
Here is the execution output:
[trafodion@n009 bin]$ sqlci
Trafodion Conversational Interface 0.9.1
(c) Copyright 2014 Hewlett-Packard Development Company, LP.
>>obey mytest.sql;
>>create schema mytest;
--- SQL operation complete.
>>set schema mytest;
--- SQL operation complete.
>>create table t (a int);
--- SQL operation complete.
>>insert into t values (1),(2);
--- 2 row(s) inserted.
>>select '0123456789' from t;
(EXPR)
----------
0123456789
0123456789
--- 2 row(s) selected.
>>select '' from t;
(EXPR)
----------
23456789
23456789
--- 2 row(s) selected.
>>drop schema mytest cascade;
--- SQL operation complete.
-------
Here is the execution output showing that if the 1st query is commented out, the 2nd query returns correct empty strings.
[trafodion@n009 bin]$ sqlci
Trafodion Conversational Interface 0.9.1
(c) Copyright 2014 Hewlett-Packard Development Company, LP.
>>obey mytest.sql;
>>create schema mytest;
--- SQL operation complete.
>>set schema mytest;
--- SQL operation complete.
>>create table t (a int);
--- SQL operation complete.
>>insert into t values (1),(2);
--- 2 row(s) inserted.
>>-- select '0123456789' from t;
>>select '' from t;
(EXPR)
------
--- 2 row(s) selected.
>>drop schema mytest cascade;
--- SQL operation complete.
Changed in trafodion: | |
assignee: | QF Chen (qifan-chen) → Howard Qin (hao-qin) |
Changed in trafodion: | |
status: | In Progress → Fix Committed |
Looks like something related to query cache. Maybe the hybrid cache changes are causing it.
Turning off query_cache does not show this issue.
This may be related to how varchar literals are being handled during query cache.
The literal in second select is a string of length zero which is represented as a varchar.
If that literal is changed to one blank, then this issue does not show up since one blank
is treated as a fixed char of length 1.
The output also doesn't contain the first 2 bytes which is being treated as the length
bytes of a varchar.
Forwarding to compiler group to take the first look.
/opt/home/ ansharma/ ansharma_ lp_fixes/ core/sqf/ rundir/ seabase: sqlci
Trafodion Conversational Interface 0.9.1
(c) Copyright 2014 Hewlett-Packard Development Company, LP.
>>select '0123456789' from t;
(EXPR)
----------
0123456789
0123456789
--- 2 row(s) selected.
>>select '' from t;
(EXPR)
----------
23456789
23456789
--- 2 row(s) selected.
>>cqd query_cache '0';
--- SQL operation complete.
>>select '' from t;
(EXPR)
------
--- 2 row(s) selected.
>>
****Run with one blank in the second select which works*****
/opt/home/ ansharma/ ansharma_ lp_fixes/ core/sqf/ rundir/ seabase: sqlci
Trafodion Conversational Interface 0.9.1
(c) Copyright 2014 Hewlett-Packard Development Company, LP.
>>select '1234' from t;
(EXPR)
------
1234
1234
--- 2 row(s) selected.
>>select ' ' from t;
(EXPR)
------
--- 2 row(s) selected.
>>