Skip to content

Commit 639b2b4

Browse files
committed
add input tuple length check in function put, minor modification in
format
1 parent f6f7ac2 commit 639b2b4

4 files changed

Lines changed: 268 additions & 210 deletions

File tree

src/kv_fdw.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ PG_FUNCTION_INFO_V1(kv_fdw_validator);
2626

2727
static SharedMem *ptr = NULL; // in client process
2828

29+
2930
static void GetForeignRelSize(PlannerInfo *root,
3031
RelOptInfo *baserel,
3132
Oid foreignTableId) {

src/kv_fdw.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "access/attnum.h"
1313
#include "utils/relcache.h"
1414

15+
1516
/* Defines */
1617
#define KVKEYJUNK "__key_junk"
1718

@@ -23,31 +24,31 @@
2324

2425
#define PATHMAXLENGTH 4096
2526

26-
#define BUFSIZE 65536
27+
#define BUFSIZE 65536 * sizeof(char)
2728

2829
#define FILENAMELENGTH 20
2930

3031
#define RESPONSEFILE "/KVSharedResponse"
3132

3233
#define RESPONSEQUEUELENGTH 2
3334

34-
#define DATAAREASIZE sizeof(char)*BUFSIZE
35-
3635

3736
/* Shared memory for function requests:
38-
* mutex is used for the mutual exclusion of the request buffer;
39-
* full is used to tell whether the request buffer is full;
40-
* agent[2] are used to synchronize the creation of the worker process;
41-
* worker is used to notify the worker process after a request is submitted;
42-
* responseMutexes[RESPONSEQUEUELENGTH] are used for the mutual exclusion of the response buffer;
43-
* responseSync[RESPONSEQUEUELENGTH] are used to notify child processes after the response is ready.
37+
* mutex: mutual exclusion of the request buffer;
38+
* full: tell whether the request buffer is full;
39+
* agent[2]: synchronize the creation of the worker process;
40+
* worker: notify the worker process after a request is submitted;
41+
* responseMutexes[RESPONSEQUEUELENGTH]:
42+
* mutual exclusion of the response buffer;
43+
* responseSync[RESPONSEQUEUELENGTH]:
44+
* notify child processes after the response is ready.
4445
*/
4546
typedef struct SharedMem {
4647
sem_t mutex;
4748
sem_t full;
4849
sem_t agent[2];
4950
sem_t worker;
50-
sem_t responseMutexes[RESPONSEQUEUELENGTH];
51+
sem_t responseMutex[RESPONSEQUEUELENGTH];
5152
sem_t responseSync[RESPONSEQUEUELENGTH];
5253
bool workerProcessCreated;
5354
char area[BUFSIZE]; // assume ~64K for a tuple is enough

0 commit comments

Comments
 (0)