HELP! ESQL program crashes

HELP! ESQL program crashes

Post by Jonathan Leffl » Fri, 08 Dec 1995 04:00:00



Questions, but they may lead to answers...

1.  Was 5.02.UC1 ported for A.09.03 or was it for a later version of the
    o/s?  If for A.09.04, then the mismatch may be the cause of the
    trouble.  And are you referring to Informix-ESQL/C?  There is no
    5.02.UC1 Informix-SQL (4.15.UC1 is the highest pre-5 release, and
    6.00.UE1 is the lowest poset-5 release, as of today).
2.  You code is not checking any error statuses -- you don't make it clear
    whether it is the DECLARE that goes wrong, though the comments imply
    that.
3.  You should not be looping on the FETCH with a for loop, unless you also
    test for SQLNOTFOUND.  If it is the DECLARE that is crashing, the OPEN
    and FETCH are redundant and should be removed from the reproduction.
4.  Your definition of main is wrong.  ANSI C says you can use either of
    two prototypes: int main(void) or "int main(int argc, char **argv)".
    The comp.lang.c FAQ (and the new book derived from it) both give
    reasons why you shouldn't abuse main().
5.  Does the program work any better if you change the name of the cursor
    from 'cursor' to something else?
6.  I can think of no reason why _iqlocate() would be calling ungetc().  Do
    you have the complete stack trace for the core dump?  Did you compile
    your code with debug enabled (-g?)?

Suggestion:

Add the following function to your test code before get_mtg_attendee():

#include <stdlib.h>

void sqlerror(void)
{
    fprintf(stderr, "SQLCODE = %d", sqlca.sqlcode);
    if (sqlca.sqlerrd[1] != 0)
        fprintf(stderr, " (ISAM = %d)", sqlca.sqlerrd[1]);
    fputc('\n', stderr);
    abort();

Quote:}

Also revise the get_mtg_attendee() function to include this whenever statement
before the $database statement.

EXEC SQL WHENEVER ERROR CALL sqlerror;

The code provided does not need sqltypes.h, sqlstype.h nor sqlda; in fact,
sqlca.h is included automatically by the generated C code, so you don't
need that header either.

Yours,


>Date: 07 Dec 1995 07:52:51 GMT
>X-Informix-List-Id: <news.19515>

>We are having trouble getting the following program to work:

>/* -*-c-*- */
>#include <stdio.h>

>$include sqltypes.h;
>$include sqlstype.h;
>$include sqlca;
>$include sqlda;

>$define DATPATH "schedule";

>void get_mtg_attendee(void) {
>  $char db_nam[9];
>  $int id;
>  int indx;

>  $database DATPATH;
>/* The following declare statement causes a bus error.  We've
>   used $PREPARE to create a query id as well.  The error seems
>   to be occurring in _ungetc which is being called by the
>   informix function _iqlocate. */
>  $DECLARE cursor CURSOR FOR
>    SELECT m_id,
>           m_user
>    INTO $id,
>         $db_nam
>    FROM meeting
>    ;

>  EXEC SQL
>    OPEN cursor;

>  for(indx = 0; indx < 10; indx++)
>    EXEC SQL
>      FETCH cursor;
>}

>void main(void)
>{

>  get_mtg_attendee();
>}

>Version INFORMIX-SQL Version 5.02.UC1 on HP-UX hp0 A.09.03 A 9000/755.

 
 
 

HELP! ESQL program crashes

Post by bertelsen christop » Fri, 08 Dec 1995 04:00:00


Hi all,

We are having trouble getting the following program to work:

/* -*-c-*- */
#include <stdio.h>

$include sqltypes.h;
$include sqlstype.h;
$include sqlca;
$include sqlda;

$define DATPATH "schedule";

void get_mtg_attendee(void) {
  $char db_nam[9];
  $int id;
  int indx;

  $database DATPATH;
/* The following declare statement causes a bus error.  We've
   used $PREPARE to create a query id as well.  The error seems
   to be occurring in _ungetc which is being called by the
   informix function _iqlocate. */
  $DECLARE cursor CURSOR FOR
    SELECT m_id,
           m_user
    INTO $id,
         $db_nam
    FROM meeting
    ;

  EXEC SQL
    OPEN cursor;

  for(indx = 0; indx < 10; indx++)
    EXEC SQL
      FETCH cursor;

Quote:}

void main(void)
{

  get_mtg_attendee();

Quote:}  

Version INFORMIX-SQL Version 5.02.UC1 on HP-UX hp0 A.09.03 A 9000/755.

Please reply (e-mail preferred) if you have any idea what might be wrong.

Many thanx in advance!



 
 
 

HELP! ESQL program crashes

Post by bertelsen christoph » Sat, 09 Dec 1995 04:00:00



>1.  Was 5.02.UC1 ported for A.09.03 or was it for a later version of the
>    o/s?  If for A.09.04, then the mismatch may be the cause of the
>    trouble.

It is extremely difficult to get any information on esql use at this university.

Quote:>    And are you referring to Informix-ESQL/C?  

Yes.

Quote:>    There is no
>    5.02.UC1 Informix-SQL (4.15.UC1 is the highest pre-5 release, and
>    6.00.UE1 is the lowest poset-5 release, as of today).

Our version INFORMIX-SQL Version 4.12.UC1

Thanks for the help.  The code I posted was extremely stripped down.  A bus error forces a
core dump at the declare line.  Here's a back trace from gdb.

Program received signal SIGBUS, Bus error.
0x7affed30 in _ungetc ()
(gdb) #1  0x7affba34 in _doscan ()
(gdb) #2  0x7afe4e20 in _sscanf ()
(gdb) #3  0x4f04 in _iqlocate_cursor ()
(gdb) #4  0x3ea8 in get_mtg_attendee () at schedule.ec:34
(gdb)

Also, it isn't a cursor problem our real cursor is named something else.

One other bit of info.  

If I compile with

        esql -Aa filename.ec -o target

then I get a cursor perfectly.  My problem is that I need either a .c or .o to link with
g++.

 
 
 

1. help needed for compiling esql/c demo programs

hi,

I just installed the esqldemo7 database that comes with SE. I can't
figure out how to compile the sample programs. I've been trying to get
the "rtoday.ec" program to work as my test.

First I do "esql rtoday.ec", which gives me the "rtoday.c" file.

But then I can't compile "rtoday.c".

I've tried stuff like:
gcc -I/informix/incl/esql -L/informix/lib/esql rtoday.c  -lsql

(tried -l at the end for every library). But every time it says
"undefined reference to 'rtoday' "
"undefined reference to 'rdatestr' "

can someone help me out?

-bob

2. Caldera Install

3. Please Help with compiling of esql/c program

4. Bug with delete stm?

5. Help on QEP on ESQL/C Programs

6. I Need different Network Paket Sizes for different Applications

7. Help: slow down of esql program.

8. Setting Up Replication Manually

9. Help With Crystal Reports: Crashes Program After Showing Second Report

10. distributed webbrowser-program crashes - help !

11. Help!...DBase IV program crashing under Windows 95

12. Database program in Delphi 2.0 crash help

13. REQ: Help with Crystal Reports (Program Crashes)