Skip to content

Commit

Permalink
fix value tracing of partial empty fetches/selects
Browse files Browse the repository at this point in the history
  • Loading branch information
gsauthof committed Jul 11, 2013
1 parent ff265b3 commit 0ff6218
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 45 deletions.
74 changes: 50 additions & 24 deletions modtest/ref/gory
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,7 @@ Iterations: 1 (of 1)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
SQL-Code: 1403, ORA-01403: no data found (select str ,n from example_tbl where n<:b0 order by n )

---------------------------------------------------------------------------
===========================================================================
stmt # 25, type CLOSE (15), line 320, #para 0 (in 0) (offset 579) (foff: 0)
---------------------------------------------------------------------------
Expand Down Expand Up @@ -942,49 +943,49 @@ SQL-Code: 1403, ORA-01403: no data found (select str ,n into :s1:s2 ,:s3:s4 fr
Iterations: 6 (of 512)
Iteration: 0
OUT paramter (a=0)
Type: STRING0 (5), Length: 32, Size: 36, Ind -1
Value: |NULL|
Type: STRING0 (5), Length: 32, Size: 36, Ind 0
Value: |a|
OUT paramter (a=1)
Type: INT (3), Length: 4, Size: 36, Ind -1
Value: |NULL|
Type: INT (3), Length: 4, Size: 36, Ind 0
Value: |0|
IN paramter (a=2)
Type: INT (3), Length: 4, Size: 4, Ind 0
Value: |6|
Iteration: 1
OUT paramter (a=0)
Type: STRING0 (5), Length: 32, Size: 36, Ind -1
Value: |NULL|
Type: STRING0 (5), Length: 32, Size: 36, Ind 0
Value: |a|
OUT paramter (a=1)
Type: INT (3), Length: 4, Size: 36, Ind -1
Value: |NULL|
Type: INT (3), Length: 4, Size: 36, Ind 0
Value: |0|
Iteration: 2
OUT paramter (a=0)
Type: STRING0 (5), Length: 32, Size: 36, Ind -1
Value: |NULL|
Type: STRING0 (5), Length: 32, Size: 36, Ind 0
Value: |a|
OUT paramter (a=1)
Type: INT (3), Length: 4, Size: 36, Ind -1
Value: |NULL|
Type: INT (3), Length: 4, Size: 36, Ind 0
Value: |0|
Iteration: 3
OUT paramter (a=0)
Type: STRING0 (5), Length: 32, Size: 36, Ind -1
Value: |NULL|
Type: STRING0 (5), Length: 32, Size: 36, Ind 0
Value: |b|
OUT paramter (a=1)
Type: INT (3), Length: 4, Size: 36, Ind -1
Value: |NULL|
Type: INT (3), Length: 4, Size: 36, Ind 0
Value: |1|
Iteration: 4
OUT paramter (a=0)
Type: STRING0 (5), Length: 32, Size: 36, Ind -1
Value: |NULL|
Type: STRING0 (5), Length: 32, Size: 36, Ind 0
Value: |b|
OUT paramter (a=1)
Type: INT (3), Length: 4, Size: 36, Ind -1
Value: |NULL|
Type: INT (3), Length: 4, Size: 36, Ind 0
Value: |1|
Iteration: 5
OUT paramter (a=0)
Type: STRING0 (5), Length: 32, Size: 36, Ind -1
Value: |NULL|
Type: STRING0 (5), Length: 32, Size: 36, Ind 0
Value: |c|
OUT paramter (a=1)
Type: INT (3), Length: 4, Size: 36, Ind -1
Value: |NULL|
Type: INT (3), Length: 4, Size: 36, Ind 0
Value: |4|
---------------------------------------------------------------------------
===========================================================================
stmt # 28, type OPEN cursor (9), line 400, #para 1 (in 1) (offset 816) (foff: 0)
Expand Down Expand Up @@ -1051,6 +1052,22 @@ Iterations: 1 (of 4)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
SQL-Code: 1403, ORA-01403: no data found (select str ,n from example_tbl where n<:b0 order by n )

Iterations: 2 (of 4)
Iteration: 0
OUT paramter (a=0)
Type: STRING0 (5), Length: 32, Size: 36, Ind 0
Value: |b|
OUT paramter (a=1)
Type: INT (3), Length: 4, Size: 36, Ind 0
Value: |1|
Iteration: 1
OUT paramter (a=0)
Type: STRING0 (5), Length: 32, Size: 36, Ind 0
Value: |c|
OUT paramter (a=1)
Type: INT (3), Length: 4, Size: 36, Ind 0
Value: |4|
---------------------------------------------------------------------------
===========================================================================
stmt # 28, type CLOSE (15), line 419, #para 0 (in 0) (offset 858) (foff: 0)
---------------------------------------------------------------------------
Expand Down Expand Up @@ -1185,6 +1202,15 @@ Iterations: 1 (of 4)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
SQL-Code: 1403, ORA-01403: no data found (SELECT str, n FROM example_tbl WHERE n < :x ORDER BY n)

Iterations: 1 (of 4)
Iteration: 0
OUT paramter (a=0)
Type: STRING0 (5), Length: 32, Size: 36, Ind 0
Value: |b|
OUT paramter (a=1)
Type: INT (3), Length: 4, Size: 36, Ind 0
Value: |1|
---------------------------------------------------------------------------
===========================================================================
stmt # 31, type CLOSE (15), line 482, #para 0 (in 0) (offset 991) (foff: 0)
---------------------------------------------------------------------------
Expand Down
19 changes: 13 additions & 6 deletions modtest/ref/sql
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,8 @@ select str ,n from example_tbl where n<5 order by n ;
-- example/main.pc:314
-- Pseudo-SQL: FETCH
-- PREFETCH=1 (# of prefetched rows)
( ;
-- ---------------------------------------------------------------------------


-- ###########################################################################
Expand Down Expand Up @@ -564,12 +566,12 @@ select str ,n into :s1:s2 ,:s3:s4 from example_tbl where n<6 order by n ;
-- ===========================================================================
-- After execution (errorcode: 1403, ORA-01403: no data found, select str ,n into :s1:s2 ,:s3:s4 from example_tbl where n<:b2 order):
-- example/main.pc:374
select str ,n into NULL ,NULL from example_tbl where n<6 order by n ;
select str ,n into NULL ,NULL from example_tbl where n<6 order by n ;
select str ,n into NULL ,NULL from example_tbl where n<6 order by n ;
select str ,n into NULL ,NULL from example_tbl where n<6 order by n ;
select str ,n into NULL ,NULL from example_tbl where n<6 order by n ;
select str ,n into NULL ,NULL from example_tbl where n<6 order by n ;
select str ,n into 'a' ,0 from example_tbl where n<6 order by n ;
select str ,n into 'a' ,0 from example_tbl where n<6 order by n ;
select str ,n into 'a' ,0 from example_tbl where n<6 order by n ;
select str ,n into 'b' ,1 from example_tbl where n<6 order by n ;
select str ,n into 'b' ,1 from example_tbl where n<6 order by n ;
select str ,n into 'c' ,4 from example_tbl where n<6 order by n ;
-- ---------------------------------------------------------------------------


Expand Down Expand Up @@ -606,6 +608,9 @@ select str ,n from example_tbl where n<6 order by n ;
-- example/main.pc:406
-- Pseudo-SQL: FETCH
-- PREFETCH=1 (# of prefetched rows)
( 'b', 1 );
( 'c', 4 );
-- ---------------------------------------------------------------------------


-- ###########################################################################
Expand Down Expand Up @@ -721,6 +726,8 @@ DELETE FROM example_tbl WHERE n = 4;
-- example/main.pc:468
-- Pseudo-SQL: FETCH
-- PREFETCH=1 (# of prefetched rows)
( 'b', 1 );
-- ---------------------------------------------------------------------------


-- ###########################################################################
Expand Down
6 changes: 2 additions & 4 deletions prettyprint.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ int pp_after_gory(const Statement *stmt,
if (!stmt->errorcode || stmt->errorcode == 1403 || stmt->errorcode == 100) {
tprintf("\n");
}
//tprintf("Fetched rows: %zu\n", stmt->acc_fetched_rows);
return 0;
}

Expand Down Expand Up @@ -212,12 +213,10 @@ int pp_sql(const Statement *stmt, void *user_ptr)
} else if (stmt->number_of_params)
sql_pseudo_tokenize(stmt->number_of_params, &s->tokens, &s->tokens_size);
}

s->tokens_pos = 0;
SQL_Token *i = s->tokens + s->tokens_pos;

// don't print (possibly) tons of NULL fetch results
if (stmt->type == FETCH && (stmt->errorcode == 1403 || stmt->errorcode == 100))
return 0;

if (s->tokens_pos < s->tokens_size && i->begin && !i->host_var) {
tprintf("%.*s", (int) (i->end - i->begin), i->begin);
Expand Down Expand Up @@ -334,7 +333,6 @@ int pp_para_sql(const Statement *stmt,

SQL_PP_State *s = user_ptr;


if (!p->pos && p->iteration && s->tokens) {
s->tokens_pos = 0;
tprintf(";\n");
Expand Down
23 changes: 12 additions & 11 deletions wrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1432,11 +1432,16 @@ static size_t determine_iterations(bool before, const Statement *stmt)
if (before)
iterations = 1;
else {
size_t mod = stmt->acc_fetched_rows % stmt->iterations;
if (mod)
iterations = mod;
else
iterations = stmt->iterations;
// for single fetches
if (stmt->iterations == 1 && stmt->errorcode) {
iterations = 0;
} else {
size_t mod = stmt->acc_fetched_rows % stmt->iterations;
if (mod)
iterations = mod;
else
iterations = stmt->iterations;
}
}
break;
default:
Expand Down Expand Up @@ -1500,8 +1505,8 @@ static int pp_para(const sqlexd *d, bool before,

// don't print OUT-parameters on errors
if (!before && p.direction == PARA_OUT
&& !(!stmt->errorcode ) //|| stmt->errorcode == 1403 || stmt->errorcode == 100)
) {
&& stmt->errorcode != 0 && stmt->errorcode != 1403
&& stmt->errorcode != 100) {
p.indicator = -1;
}

Expand Down Expand Up @@ -1649,10 +1654,6 @@ static int pp_sql_after(const sqlexd *d, Statement *stmt,
state.callbacks[callback_nr].user_ptr);
}

// don't print (possibly) tons of NULL fetch results
if (stmt->type == FETCH && (stmt->errorcode == 1403 || stmt->errorcode == 100))
return 0;

pp_para(d, false, stmt, callback_nr);

if (state.callbacks[callback_nr].after_end_fn) {
Expand Down

0 comments on commit 0ff6218

Please sign in to comment.