Thread: Adding a field in Path Structure and Plan Structure

Adding a field in Path Structure and Plan Structure

From
Zichen Xu
Date:
Here is my problem and also the question. I'd like adding a field in
Path structure and Plan structure as follows:

typedef struct Path{
....bla bla bla

Cost energy_cost;

....bla bla bla


}


typedef struct Plan{
....bla bla bla

Cost energy_cost;

....bla bla bla


}


Also, I have modified the funscopy.c and every related place where the
other field total_cost appears. Right now, the compile is fine and
build is fine. However, everytime the server is running and I send a
query to the server, it crashed. as

psql:1.sql:23: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
psql:1.sql:23: connection to server was lost


Is there anyone who can help me with it?

Thanks very much~!


-- 
Zichen Xu - X.Z.C.
University of South Florida
Computer Science and Engineering
33620, Flower Ave
Tampa, FL
徐子晨


Re: Adding a field in Path Structure and Plan Structure

From
Robert Haas
Date:
On Mon, Feb 23, 2009 at 4:14 PM, Zichen Xu <xzckiller@gmail.com> wrote:
> Here is my problem and also the question. I'd like adding a field in
> Path structure and Plan structure as follows:
>
> typedef struct Path{
> ....bla bla bla
>
> Cost energy_cost;
>
> ....bla bla bla
>
>
> }
>
>
> typedef struct Plan{
> ....bla bla bla
>
> Cost energy_cost;
>
> ....bla bla bla
>
>
> }
>
>
> Also, I have modified the funscopy.c and every related place where the
> other field total_cost appears. Right now, the compile is fine and
> build is fine. However, everytime the server is running and I send a
> query to the server, it crashed. as
>
> psql:1.sql:23: server closed the connection unexpectedly
> This probably means the server terminated abnormally
> before or while processing the request.
> psql:1.sql:23: connection to server was lost
>
>
> Is there anyone who can help me with it?

Attach to the backend with gdb.  Then you can get a backtrace, esp. if
you've built with --enable-debug.

It may be helpful to use lsof to figure out which backend your psql
session is connected to.

...Robert


Re: Adding a field in Path Structure and Plan Structure

From
Tom Lane
Date:
Zichen Xu <xzckiller@gmail.com> writes:
> Also, I have modified the funscopy.c and every related place where the
> other field total_cost appears.

Sounds like it should work.  Did you recompile everything?

> Right now, the compile is fine and
> build is fine. However, everytime the server is running and I send a
> query to the server, it crashed. as

Crashed where?  If you're not reasonably handy with gdb or some other
favorite debugger, stop what you're doing and go learn one.  The
investment of time will be repaid very quickly if you're doing any
nontrivial C programming.
        regards, tom lane


Re: Adding a field in Path Structure and Plan Structure

From
Gregory Stark
Date:
Robert Haas <robertmhaas@gmail.com> writes:

> Attach to the backend with gdb.  Then you can get a backtrace, esp. if
> you've built with --enable-debug.
>
> It may be helpful to use lsof to figure out which backend your psql
> session is connected to.

select backend_pid();

is pretty handy for this. Though if you have the backend crashing on every
plan it may not help...
--  Gregory Stark EnterpriseDB          http://www.enterprisedb.com Ask me about EnterpriseDB's Slony Replication
support!


Re: Adding a field in Path Structure and Plan Structure

From
Robert Haas
Date:
On Mon, Feb 23, 2009 at 4:49 PM, Gregory Stark <stark@enterprisedb.com> wrote:
> Robert Haas <robertmhaas@gmail.com> writes:
>
>> Attach to the backend with gdb.  Then you can get a backtrace, esp. if
>> you've built with --enable-debug.
>>
>> It may be helpful to use lsof to figure out which backend your psql
>> session is connected to.
>
> select backend_pid();
>
> is pretty handy for this. Though if you have the backend crashing on every
> plan it may not help...

pg_backend_pid()

...Robert


Re: Adding a field in Path Structure and Plan Structure

From
Andrew Dunstan
Date:

Tom Lane wrote:
>> Right now, the compile is fine and
>> build is fine. However, everytime the server is running and I send a
>> query to the server, it crashed. as
>>     
>
> Crashed where?  If you're not reasonably handy with gdb or some other
> favorite debugger, stop what you're doing and go learn one.  The
> investment of time will be repaid very quickly if you're doing any
> nontrivial C programming.
>
>   

In particular, learn to build postgres with debugging enabled 
(--enable-debug), start postgres with core file generation enabled 
(pg_ctl -c ... start) and get a backtrace from a core file (gdb -ex bt 
--batch /path/to/postgres /path/to/corefile)

cheers

andrew


Re: Adding a field in Path Structure and Plan Structure

From
Euler Taveira de Oliveira
Date:
Zichen Xu escreveu:
> Also, I have modified the funscopy.c and every related place where the                     ^^^^^^^^^
This file doesn't exist on PostgreSQL source code.

Out of curiosity, what another cost metric is for?


--  Euler Taveira de Oliveira http://www.timbira.com/