Обсуждение: Core dump when I run a program that uses embedded sql

Поиск
Список
Период
Сортировка

Core dump when I run a program that uses embedded sql

От
"Ligia Pimentel"
Дата:
Hello.
I'm using postgres 7.1, and I'm on my first try to use embedded sql. Here's
my problem.

I'm trying to use an example I copied from the web:

/**************************************************  Example program  for embedded SQL:
tryit.pgc**************************************************/

#include <stdio.h>

EXEC SQL INCLUDE sqlca;

main () {   EXEC SQL BEGIN DECLARE SECTION;   int sup_id;   int sales;   int total;   float price;   VARCHAR
cof_name[33];  EXEC SQL END DECLARE SECTION;
 
   EXEC SQL CONNECT 'TarjetaDebito' ;   if(sqlca.sqlcode) {      printf("Error al connectar a la base de datos.\n");
exit(0);   }
 
   printf("Solicitud: ");   scanf("%d", &sup_id);
   EXEC SQL SELECT nombreenplastico, correlativo INTO :cof_name, :price                 FROM tarjeta WHERE correlativo
=:sup_id ;   if (sqlca.sqlcode==0) {      printf("Result: %s tarjeta con solicitud  $%5.2f\n", cof_name.arr,
 
price);   }   else {      printf("Error #%d: %s\n", sqlca.sqlerrm.sqlerrml,
sqlca.sqlerrm.sqlerrmc);   }
}

Nothing fancy as you can see... (of course I changed the names of the tables
and the fields to be able to find them on my server).

Then I precompile it (ecpg ...) successfully, and after that I compile it
with gcc (also everything OK aparently), and when I try to run my program, I
get
SEGMENTATION FAULT (core dumped).

I don't know where to start. Could you help me?

Thank you.

Ligia Pimentel





Re: Core dump when I run a program that uses embedded sql

От
Michael Meskes
Дата:
On Wed, Aug 29, 2001 at 11:08:24AM -0500, Ligia Pimentel wrote:
> Then I precompile it (ecpg ...) successfully, and after that I compile it
> with gcc (also everything OK aparently), and when I try to run my program, I
> get
> SEGMENTATION FAULT (core dumped).

Where does it segfault? I need more info to help you. Could you please run
the program in gdb and tell me where exactly it segfaults?

If you need to learn more about the executed statementy you can add the
following code:

FILE *dbgs;

<at start of main()>
if ((dbgs = fopen("log", "w")) != NULL)ECPGdebug(1, dbgs);
...

<before exit>
if (dbgs != NULL)fclose(dbgs);

This will log all actions by libecpg in file "log". However, this will give
you an empty file if the program segfaults before closing the file. 

Michael
-- 
Michael Meskes
Michael@Fam-Meskes.De
Go SF 49ers! Go Rhein Fire!
Use Debian GNU/Linux! Use PostgreSQL!