Thread: LIBPQ: program crashed during executing query

LIBPQ: program crashed during executing query

From
"Alex Glikson"
Date:
Hi!

My C program executes a pretty complex query (of length about 600 chars,
with subqueries, etc.).
When I run it (on Linux), it crashes with "Segmentation fault (core
dumped)".
I'm sure that the program crashes on this specific PQexec command.

Is there a length limit for queries in PQexec, or is there any other reason
for it?
The query is attached.

Thanks in advance,

    Alex

 P.S. The query is:
SELECT s1.GivingCode FROM Scored s1, Scored s2
  WHERE s1.Score >= 8 AND s2.Score >= 8 AND s1.Year = s2.Year AND
   s1.GivingCode = s2.ReceivingCode AND s1.ReceivingCode = s2.GivingCode AND
   s1.GivingCode NOT IN (SELECT Code FROM Friends) AND
   s1.ReceivingCode IN (SELECT Code FROM Friends) AND
   NOT EXISTS (SELECT * FROM Represented re1, Represented re2, Scored sc
WHERE
    re1.Year = re2.Year AND re1.Year = sc.Year AND re1.Code = s1.GivingCode
AND
    re2.Code = s1.ReceivingCode AND
    ((sc.GivingCode = s1.ReceivingCode AND sc.ReceivingCode = s1.GivingCode
AND sc.Score < 8) OR
     (sc.GivingCode = s1.GivingCode AND sc.ReceivingCode = s1.ReceivingCode
AND sc.Score < 8)))

Re: LIBPQ: program crashed during executing query

From
"Alex Glikson"
Date:
Please, ignore my question. The problem was that I did PQclear(res) before
calling to PQgetvalue(res,...)
Anyway, it should not crush (IMHO).

Alex

"Alex Glikson" <agliks@technion.ac.il> wrote in message
news:a1jjj5$tas$1@news.huji.ac.il...
> Hi!
>
> My C program executes a pretty complex query (of length about 600 chars,
> with subqueries, etc.).
> When I run it (on Linux), it crashes with "Segmentation fault (core
> dumped)".
> I'm sure that the program crashes on this specific PQexec command.
>
> Is there a length limit for queries in PQexec, or is there any other
reason
> for it?
> The query is attached.
>
> Thanks in advance,
>
>     Alex
>
>  P.S. The query is:
> SELECT s1.GivingCode FROM Scored s1, Scored s2
>   WHERE s1.Score >= 8 AND s2.Score >= 8 AND s1.Year = s2.Year AND
>    s1.GivingCode = s2.ReceivingCode AND s1.ReceivingCode = s2.GivingCode
AND
>    s1.GivingCode NOT IN (SELECT Code FROM Friends) AND
>    s1.ReceivingCode IN (SELECT Code FROM Friends) AND
>    NOT EXISTS (SELECT * FROM Represented re1, Represented re2, Scored sc
> WHERE
>     re1.Year = re2.Year AND re1.Year = sc.Year AND re1.Code =
s1.GivingCode
> AND
>     re2.Code = s1.ReceivingCode AND
>     ((sc.GivingCode = s1.ReceivingCode AND sc.ReceivingCode =
s1.GivingCode
> AND sc.Score < 8) OR
>      (sc.GivingCode = s1.GivingCode AND sc.ReceivingCode =
s1.ReceivingCode
> AND sc.Score < 8)))
>
>
>