[GSOC] questions about idea "rewrite pg_dump as library" - Mailing list pgsql-hackers

From
Subject [GSOC] questions about idea "rewrite pg_dump as library"
Date
Msg-id 71e01949.2e16b.13df4707405.Coremail.shuai900217@126.com
Whole thread Raw
Responses Re: [GSOC] questions about idea "rewrite pg_dump as library"
Re: [GSOC] questions about idea "rewrite pg_dump as library"
List pgsql-hackers
Hi all,
    I'd like to introduce myself to the dev community. I am Shuai Fan, a student from Dalian University of Technology, DLUT , for short, China. And I am interested in working with PostgreSQL project in GSOC2013.
    I'm interested in the idea "Rewrite (add) pg_dump and pg_restore utilities as libraries (.so, .dll & .dylib)".

    These days, I had a talk with Mr. Pavel Golub by email, the author of this post. And asked some questions about this idea. He adviced me to post the question to this mail list.

    My question is:
    There are lots of functions in "pg_dump.c". If I rewrite this file as library. I should split "pg_dump.c" into two or more files(Mr. Pavel Golub's advice). However, some functions, do have return value. e.g.

    static DumpableObject *createBoundaryObjects(void);

    I thought, these functions must get return value through function argument by passing pointer to it, when using library. But, the question is: If I did so, function prototype may be changed. And Mr. Pavel Golub said "it's better to keep all functions with the same declaration", and so "we will only have one code base for both console application and library". I think he is right.
    But then, how can I deal with this situation? From my point of view, I can't malloc a variable (e.g. DumpableObject) in one library (e.g. pg_dumplib.so), and then return it's pointer to another library (or excutable program). Maybe, it's not safe(?). Or has something to do with "memory leak"(?). I'm not sure.
   
    Do you have any suggestions?


Best wishes,
    Shuai


pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: [BUGS] replication_timeout not effective
Next
From: Dang Minh Huong
Date:
Subject: Re: [BUGS] replication_timeout not effective