Skip to content

Commit

Permalink
add linked list support in hastable entries
Browse files Browse the repository at this point in the history
  • Loading branch information
Franck Boudehen committed Oct 4, 2023
1 parent 12e3693 commit 7310200
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions pg_query_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ static char * pgqs_queryString = NULL;
/* Name of our config table */
static const char* pgqs_config = "pgqs_config";

/*
Max length of a param name or a param value string
*/
#define PGQS_MAXPARAMNAMELENGTH 39
#define PGQS_MAXPARAMVALUELENGTH 10

Expand Down Expand Up @@ -111,14 +114,15 @@ typedef struct pgqsHashKey
} pgqsHashKey;

/*
Define our settings
Define our settings : for each queryid we have a linked list
of params, value.
*/

typedef struct pgqsSettings
{
/* FIXME*/
char name[PGQS_MAXPARAMNAMELENGTH];
char value[PGQS_MAXPARAMVALUELENGTH];
struct pgqsSettings * next_param;
} pgqsSettings;

/*
Expand All @@ -136,7 +140,7 @@ Shared State
*/
typedef struct pgqsSharedState
{
LWLock *lock; /* protects hashtable search/modificartion */
LWLock *lock; /* protects hashtable search/modification */
/* do we need more ? */
} pgqsSharedState;

Expand Down Expand Up @@ -166,7 +170,8 @@ void pgqs_shmem_startup_hook(void){


/*
* Estimate shared memory space needed.
* Estimate shared memory space needed by pgqs
* SharedState + Hashtable.
*/
static Size
pgqs_memsize(void)
Expand All @@ -175,10 +180,10 @@ pgqs_memsize(void)

size = MAXALIGN(sizeof(pgqsSharedState));

/* FIXME : 1000 == max number of queryid stored */
size = add_size(size, hash_estimate_size(1000, sizeof(pgqsEntry)));


/* FIXME : 100 == max number of queryid stored */
size = add_size(size, hash_estimate_size(100, sizeof(pgqsEntry)));
/* FIXME : how to evaluate when we use a linked list ? */
/* size = add_size(size, hash_estimate_size(...)) */
return size;
}

Expand Down Expand Up @@ -597,6 +602,13 @@ Datum
pg_query_settings_reload(PG_FUNCTION_ARGS)
{
if (debug) elog (DEBUG1,"Reload");

/* FIXME:
Here we must reload the table pgqs_config and store it into the shmem
*/



PG_RETURN_VOID();
}

Expand Down

0 comments on commit 7310200

Please sign in to comment.