Re: Using host variables -- segmentation fault - Mailing list pgsql-novice
From | Yadnyesh Joshi |
---|---|
Subject | Re: Using host variables -- segmentation fault |
Date | |
Msg-id | 20061016170212.18722.qmail@web53204.mail.yahoo.com Whole thread Raw |
In response to | Using host variables -- segmentation fault (Yadnyesh Joshi <yadnyesh_joshi@yahoo.com>) |
Responses |
Re: Using host variables -- segmentation fault
|
List | pgsql-novice |
Hi,
I found out what was the problem.
I had not set LD_LIBRARY_PATH environment variable.
But I didn't see anything in documentation which says that if I don't set the environment variable, I won't be able to use host variables in C.
Morevoer, the usual insert statement (without using host variables) was working fine; so it created more trouble..
Regards,
Yadnyesh.
I found out what was the problem.
I had not set LD_LIBRARY_PATH environment variable.
But I didn't see anything in documentation which says that if I don't set the environment variable, I won't be able to use host variables in C.
Morevoer, the usual insert statement (without using host variables) was working fine; so it created more trouble..
Regards,
Yadnyesh.
----- Original Message ----
From: Yadnyesh Joshi <yadnyesh_joshi@yahoo.com>
To: pgsql-novice@postgresql.org
Sent: Monday, 16 October, 2006 9:15:59 PM
Subject: Re: [NOVICE] Using host variables -- segmentation fault
Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download Now! http://messenger.yahoo.com/download.php
From: Yadnyesh Joshi <yadnyesh_joshi@yahoo.com>
To: pgsql-novice@postgresql.org
Sent: Monday, 16 October, 2006 9:15:59 PM
Subject: Re: [NOVICE] Using host variables -- segmentation fault
----- Original Message ----
From: Michael Fuhr <mike@fuhr.org>
To: Yadnyesh Joshi <yadnyesh_joshi@yahoo.com>
Cc: pgsql-novice@postgresql.org
Sent: Monday, 16 October, 2006 7:11:24 PM
Subject: Re: [NOVICE] Using host variables -- segmentation fault
From: Michael Fuhr <mike@fuhr.org>
To: Yadnyesh Joshi <yadnyesh_joshi@yahoo.com>
Cc: pgsql-novice@postgresql.org
Sent: Monday, 16 October, 2006 7:11:24 PM
Subject: Re: [NOVICE] Using host variables -- segmentation fault
On Mon, Oct 16, 2006 at 05:16:06AM -0700, Yadnyesh Joshi wrote:
> The first EXEC SQL INSERT INTO simple values (6); executes fine. The
> value is added in the database as I am doing a COMMIT.
>
> However, segmentation fault occurs at EXEC SQL INSERT INTO simple values (:i);
> What can be the problem?
The program you posted doesn't initialize i but I'd expect that to
result in a garbage value being inserted instead of a segmentation
fault. Do you still get a segmentation fault if you initialize i?
What about if you comment out the line that inserts i?
Initializing i doesn't make any difference. I still get a segmentation fault.
If I comment the line that inserts i, program executes fine. It runs to the comepletion.
Your program doesn't return a value from main(). I haven't worked
on any platforms where that would cause a segmentation fault but it
should be fixed in any case.
Return value is not a problem. If I add return 1; at the end, the problem persists.
What platform are you on? What version of PostgreSQL?
PostgreSQL version - 8.1.5
I am working on Fedora Core 4 - 64 bit version.
Did you get a core dump? If so, what does a stack trace show?
I didn't get core dump.
What do you see if you add "ECPGdebug(1, stderr);" at the beginning of the program?
[12328]: ECPGdebug: set to 1
[12328]: ECPGconnect: opening database mydb on localhost port <DEFAULT>
[12328]: got TSD connection
[12328]: ECPGexecute line 16: QUERY: insert into simple values( 6 ) on connection mydb
[12328]: ECPGexecute line 16 Ok: INSERT 0 1
[12328]: got TSD connection
[12328]: ECPGtrans line 17 action = commit connection = mydb
Before inserting i
[12328]: got TSD connection
Segmentation fault
I added a printf statement just before inserting into i.
For your refernce, here is first.pgc file again..
#include<stdio.h>
int main()
{
EXEC SQL BEGIN DECLARE SECTION;
char *target="mydb@localhost";
int i;
char msg[10];
EXEC SQL END DECLARE SECTION;
ECPGdebug(1, stderr);
//strcpy(msg,"\'AAAA\'");
i=9;
EXEC SQL CONNECT TO :target;
EXEC SQL INSERT INTO simple values (6);
EXEC SQL COMMIT;
printf("Before inserting i\n");
EXEC SQL INSERT INTO simple values (:i);
EXEC SQL COMMIT;
//EXEC SQL INSERT INTO fromprg values (:i,:msg);
//EXEC SQL COMMIT;
EXEC SQL DISCONNECT;
return 1;
}
Thanks,
Yadnyesh.
--
Michael Fuhr
> The first EXEC SQL INSERT INTO simple values (6); executes fine. The
> value is added in the database as I am doing a COMMIT.
>
> However, segmentation fault occurs at EXEC SQL INSERT INTO simple values (:i);
> What can be the problem?
The program you posted doesn't initialize i but I'd expect that to
result in a garbage value being inserted instead of a segmentation
fault. Do you still get a segmentation fault if you initialize i?
What about if you comment out the line that inserts i?
Initializing i doesn't make any difference. I still get a segmentation fault.
If I comment the line that inserts i, program executes fine. It runs to the comepletion.
Your program doesn't return a value from main(). I haven't worked
on any platforms where that would cause a segmentation fault but it
should be fixed in any case.
Return value is not a problem. If I add return 1; at the end, the problem persists.
What platform are you on? What version of PostgreSQL?
PostgreSQL version - 8.1.5
I am working on Fedora Core 4 - 64 bit version.
Did you get a core dump? If so, what does a stack trace show?
I didn't get core dump.
What do you see if you add "ECPGdebug(1, stderr);" at the beginning of the program?
[12328]: ECPGdebug: set to 1
[12328]: ECPGconnect: opening database mydb on localhost port <DEFAULT>
[12328]: got TSD connection
[12328]: ECPGexecute line 16: QUERY: insert into simple values( 6 ) on connection mydb
[12328]: ECPGexecute line 16 Ok: INSERT 0 1
[12328]: got TSD connection
[12328]: ECPGtrans line 17 action = commit connection = mydb
Before inserting i
[12328]: got TSD connection
Segmentation fault
I added a printf statement just before inserting into i.
For your refernce, here is first.pgc file again..
#include<stdio.h>
int main()
{
EXEC SQL BEGIN DECLARE SECTION;
char *target="mydb@localhost";
int i;
char msg[10];
EXEC SQL END DECLARE SECTION;
ECPGdebug(1, stderr);
//strcpy(msg,"\'AAAA\'");
i=9;
EXEC SQL CONNECT TO :target;
EXEC SQL INSERT INTO simple values (6);
EXEC SQL COMMIT;
printf("Before inserting i\n");
EXEC SQL INSERT INTO simple values (:i);
EXEC SQL COMMIT;
//EXEC SQL INSERT INTO fromprg values (:i,:msg);
//EXEC SQL COMMIT;
EXEC SQL DISCONNECT;
return 1;
}
Thanks,
Yadnyesh.
--
Michael Fuhr
Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download Now! http://messenger.yahoo.com/download.php
Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download Now! http://messenger.yahoo.com/download.php
pgsql-novice by date: