From: | "Edmund Bacon" <ebacon(at)onesystem(dot)com> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | BUG #1440: ecpg seg faults |
Date: | 2005-01-24 18:50:48 |
Message-ID: | 200501241850.j0OIomme010458@developer.pgadmin.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged online:
Bug reference: 1440
Logged by: Edmund Bacon
Email address: ebacon(at)onesystem(dot)com
PostgreSQL version: 8.0.0
Operating system: Linux Redhat 9 Pentium-4
Description: ecpg seg faults
Details:
I have here a shortish source file that produces a seg-fault from ecpg.
$ ecpg --version
ecpg (PostgreSQL 8.0.0) 3.2.0
$ cat test_bad.pgc
#include <string.h>
EXEC SQL INCLUDE sqlca;
typedef
struct ideal_fc {
int upc;
char code[7];
doube usage_x;
int used;
} IDEAL_FOOD_COST;
void save_ideal_adv(char *bus_date, IDEAL_FOOD_COST *Ideal, int session_id)
{
int i, j;
EXEC SQL TYPE SQL_IDEAL IS
struct sql_ideal {
int ph_id;
double quantity;
char code[8];
};
EXEC SQL BEGIN DECLARE SECTION;
SQL_IDEAL sql_Ideal;
char *sql_date;
EXEC SQL END DECLARE SECTION;
EXEC SQL SELECT prod_hist_id, quantity, code
INTO :sql_Ideal
FROM product_history
JOIN products USING(upc)
WHERE trans_key = -2 AND date(date) = date(:sql_date)
ORDER BY code;
}
void insert_ideal(char *date, IDEAL_FOOD_COST *fc, int session_id)
{
EXEC SQL BEGIN DECLARE SECTION;
int upx;
double qty;
char *dt = date;
int sess_id = session_id;
EXEC SQL END DECLARE SECTION;
EXEC SQL
INSERT INTO product_history(date, upc, session_id, quantity,
trans_key)
VALUES(:dt, :upx, :sess_id, :qty, -2);
}
$ ecpg test_bad.pgc
Segmentation fault (core dumped)
$
Note that the following source file, which differs only in the order of the
functions passes ecpg without error.
$ cat test_good.pgc
#include <string.h>
EXEC SQL INCLUDE sqlca;
typedef
struct ideal_fc {
int upc;
char code[7];
doube usage_x;
int used;
} IDEAL_FOOD_COST;
void insert_ideal(char *date, IDEAL_FOOD_COST *fc, int session_id)
{
EXEC SQL BEGIN DECLARE SECTION;
int upx;
double qty;
char *dt = date;
int sess_id = session_id;
EXEC SQL END DECLARE SECTION;
EXEC SQL
INSERT INTO product_history(date, upc, session_id, quantity,
trans_key)
VALUES(:dt, :upx, :sess_id, :qty, -2);
}
void save_ideal_adv(char *bus_date, IDEAL_FOOD_COST *Ideal, int session_id)
{
int i, j;
EXEC SQL TYPE SQL_IDEAL IS
struct sql_ideal {
int ph_id;
double quantity;
char code[8];
};
EXEC SQL BEGIN DECLARE SECTION;
SQL_IDEAL sql_Ideal;
char *sql_date;
/*int phist_id;
double qty;
int SESSION_ID; */
EXEC SQL END DECLARE SECTION;
EXEC SQL SELECT prod_hist_id, quantity, code
INTO :sql_Ideal
FROM product_history
JOIN products USING(upc)
WHERE trans_key = -2 AND date(date) = date(:sql_date)
ORDER BY code;
}
$ ecpg test_good.pgc
$ echo $?
0
Both source files pass with ecpg v 3.1.1 (Posgtresql 7.4.2) on RedHat Linux
9 (x86), and (interstingly) withe ecpg v 3.2.0 (Postgres 8.0.) under HPUX
11i - ia64
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Fuhr | 2005-01-24 19:08:36 | Re: BUG #1440: ecpg seg faults |
Previous Message | Peter Eisentraut | 2005-01-24 16:34:04 | Re: Privilege escalation via LOAD |