Login | Register
My pages Projects Community openCollabNet

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Catacomb] Pool and result abstraction



Hello,

Several more comments on dbms implementation.

Probably it is good idea get pool in dbms_prepare not dbms_create. Also dbms_query needs pool instead of dbms_db.

dav_repos_dbms_query *dbms_prepare(const dbms *db, const char *query, apr_pool_t *pool);

Since dbms_create is called when httpd starts, the httpd may serve more than 100000 requests. I don't think apr_pool has a garbage collection function.

Also, I'd like to recommend to use dav_buffer. It is very handy. :-)

/* set the cur_len to the given size and ensure space is available */
DAV_DECLARE(void) dav_set_bufsize(apr_pool_t *p, dav_buffer *pbuf,
                                  apr_size_t size);

/* initialize a buffer and copy the specified (null-term'd) string into it */
DAV_DECLARE(void) dav_buffer_init(apr_pool_t *p, dav_buffer *pbuf,
                                  const char *str);

/* check that the buffer can accomodate <extra_needed> more bytes */
DAV_DECLARE(void) dav_check_bufsize(apr_pool_t *p, dav_buffer *pbuf,
                                    apr_size_t extra_needed);

/* append a string to the end of the buffer, adjust length */
DAV_DECLARE(void) dav_buffer_append(apr_pool_t *p, dav_buffer *pbuf,
                                    const char *str);

Sorry to make this mail very long.
We need to have abstract result struct too.

This is my skeleton abstract result struct:

struct dav_repos_dbms_result {
	apr_hash_t *one_res; /* Hold one records */
	struct dav_repos_dbms_result *next; /* Of course we can man records */
	apr_pool_t *pool;
};

We can hide MYSQL_RES in dbms_mysql.c and free MYSQL_RES in dbms_execute.

--
Sung Kim <hunkim@cse.ucsc.edu>
http://www.cse.ucsc.edu/~hunkim

 "Dreams become reality!"