Closed SurendarRajavel closed 1 year ago
OK - so it's been a long time since this issue was posted - sorry about that. I just tried the repro you attached above, and I see no issues. The script runs fine whether I use prepare() or prepare_cached(). Maybe I'm missing something? Thanks.
Fixed in 1.22
Hi Michael, We are having issue with prepared_cahced and fetchall_arrayref() statement while we pass the array data where we have two instance resultant set. As a workaround, we have used prepare statement to avoid the error instead prepare_cached. Please refer the test case examples below: I am able to recreate the prepare_cached issue/failures using a simple test cases “temp.t” as attached. Able to make it working for few cases. While we pass the id from main DB connection(Id 1 to 5) – “id()” to sub “tagGrps”, if the resultant is more than one records Eg for Id – 3, it give two rows then the prepare_cached is not able to handle and raising exception. If the resultant is one row then it is working fine.
<- fetch= ( [ 3 'Test3' ] ) [1 items] row1 at DBI.pm line 2096 via at temp.t line 96 !! ERROR: 36 'OpenClient message: LAYER = (4) ORIGIN = (2) SEVERITY = (6) NUMBER = (36) Server CD_CENTRAL, database Message String: ct_fetch(): protocol specific layer: internal Client Library error: There is a tds state machine error. An illegal tds token sequence was received. ' (err#0)
“my $sth = $self->dbh()->prepare_cached(<<'END_SQL'); select id, def from #tag where id= ? END_SQL $sth->execute($self->id()); $$self{tagGrps} = $sth->fetchall_arrayref({}); $sth->finish();”
However in prepare statement, if the resultant is more that than one records then the connection is getting reset(like below logs) and avoiding the error. If we use prepare_cached statement then the sub $sth has to return single row for each instance/call in latest version. This might be reason for few cases prepare_cached statement working and exception for other cases. Also I have tried $sth->finish(); for each statement. st_next_result() -> ct_results(4046) == 1 ct_results(4046) final retcode = -205 st_next_result() -> lasterr = 0, lastsev = 0 st_next_result() -> got CS_CMD_DONE: resetting ACTIVE, moreResults, dyn_execed, exec_done clear_sth_flags() -> resetting ACTIVE, moreResults, dyn_execed, exec_done clear_sth_flags() -> reset inUse flag syb_st_fetch() -> st_next_results() == 4046
With Prepare_cached statement we are seeing below behavior: fetchall_arrayref is not able to handle multiple values resultant but handling the null/undef values for passed parameter. DBD::Sybase::st fetchall_arrayref failed: OpenClient message: LAYER = (4) ORIGIN = (2) SEVERITY = (6) NUMBER = (36) fetchrow_arrayref is able to handle multiple values resultant but not able to handle null/undef values for passed parameter. Failed test 'Has_Tag_Groups died (Can't use an undefined value as an ARRAY reference at t/tag_new.t line 96.)'
DB_trace_logs.txt temp.t.txt