~ubuntu-branches/ubuntu/oneiric/pgpool2/oneiric

« back to all changes in this revision

Viewing changes to pool_relcache.h

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Berg
  • Date: 2011-06-10 10:18:29 UTC
  • mfrom: (1.1.6 upstream) (4.2.2 sid)
  • Revision ID: james.westby@ubuntu.com-20110610101829-m1aig6u0p74qpif3
Tags: 3.0.4-1
* New upstream release
* Use format 3.0 (quilt).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*-pgsql-c-*- */
 
2
/*
 
3
 *
 
4
 * $Header: /cvsroot/pgpool/pgpool-II/pool_relcache.h,v 1.3 2010/08/19 09:25:40 t-ishii Exp $
 
5
 *
 
6
 * pgpool: a language independent connection pool server for PostgreSQL 
 
7
 * written by Tatsuo Ishii
 
8
 *
 
9
 * Copyright (c) 2003-2010      PgPool Global Development Group
 
10
 *
 
11
 * Permission to use, copy, modify, and distribute this software and
 
12
 * its documentation for any purpose and without fee is hereby
 
13
 * granted, provided that the above copyright notice appear in all
 
14
 * copies and that both that copyright notice and this permission
 
15
 * notice appear in supporting documentation, and that the name of the
 
16
 * author not be used in advertising or publicity pertaining to
 
17
 * distribution of the software without specific, written prior
 
18
 * permission. The author makes no representations about the
 
19
 * suitability of this software for any purpose.  It is provided "as
 
20
 * is" without express or implied warranty.
 
21
 *
 
22
 * pool_relcache.h.: pool_relcache.c related header file
 
23
 *
 
24
 */
 
25
 
 
26
#ifndef POOL_RELCACHE_H
 
27
#define POOL_RELCACHE_H
 
28
 
 
29
/* ------------------------
 
30
 * Relation cache structure
 
31
 *-------------------------
 
32
*/
 
33
#define MAX_ITEM_LENGTH 1024
 
34
 
 
35
/* Relation lookup cache structure */
 
36
 
 
37
typedef void *(*func_ptr) ();
 
38
 
 
39
typedef struct {
 
40
        char dbname[MAX_ITEM_LENGTH];   /* database name */
 
41
        char relname[MAX_ITEM_LENGTH];  /* table name */
 
42
        void *data;     /* user data */
 
43
        int refcnt;             /* reference count */
 
44
        int session_id;         /* LocalSessionId */
 
45
} PoolRelCache;
 
46
 
 
47
typedef struct {
 
48
        int num;                /* number of cache items */
 
49
        char sql[MAX_ITEM_LENGTH];      /* Query to relation */
 
50
        /*
 
51
         * User defined function to be called at data register.
 
52
         * Argument is POOL_SELECT_RESULT *.
 
53
         * This function must return a pointer to be
 
54
         * saved in cache->data.
 
55
         */
 
56
        func_ptr        register_func;
 
57
        /*
 
58
         * User defined function to be called at data unregister.
 
59
         * Argument cache->data.
 
60
         */
 
61
        func_ptr        unregister_func;
 
62
        bool cache_is_session_local;            /* True if cache life time is session local */
 
63
        PoolRelCache *cache;    /* cache data */
 
64
} POOL_RELCACHE;
 
65
 
 
66
extern POOL_RELCACHE *pool_create_relcache(int cachesize, char *sql,
 
67
                                                                        func_ptr register_func, func_ptr unregister_func,
 
68
                                                                        bool issessionlocal);
 
69
extern void pool_discard_relcache(POOL_RELCACHE *relcache);
 
70
extern void *pool_search_relcache(POOL_RELCACHE *relcache, POOL_CONNECTION_POOL *backend, char *table);
 
71
extern void *int_register_func(POOL_SELECT_RESULT *res);
 
72
extern void *int_unregister_func(void *data);
 
73
extern void *string_register_func(POOL_SELECT_RESULT *res);
 
74
extern void *string_unregister_func(void *data);
 
75
 
 
76
#endif /* POOL_RELCACHE_H */