pgpool2.git / summary / log / commit / refs

commit    e2a050ba8f45610fa22cd0b91c38eee4ed81d092
Author:   Bo Peng <pengbo@sraoss.co.jp>
Date:     Mon Aug 20 08:04:45 2018 +0000

    Move pgproto header files to "include/pgproto".


src/include/Makefile.am | 2 +- src/include/Makefile.in | 2 +- src/tools/pgproto/buffer.c | 8 ++-- src/tools/pgproto/buffer.h | 26 ----------- src/tools/pgproto/extended_query.c | 12 ++--- src/tools/pgproto/extended_query.h | 27 ----------- src/tools/pgproto/fe_memutils.c | 2 +- src/tools/pgproto/fe_memutils.h | 93 -------------------------------------- src/tools/pgproto/main.c | 12 ++--- src/tools/pgproto/pgproto.h | 40 ---------------- src/tools/pgproto/read.c | 6 +-- src/tools/pgproto/read.h | 20 -------- src/tools/pgproto/send.c | 8 ++-- src/tools/pgproto/send.h | 25 ---------- 14 files changed, 26 insertions(+), 257 deletions(-) diff --git a/src/include/Makefile.am b/src/include/Makefile.am index a140e4178..c2e47e41c 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am @@ -5,4 +5,4 @@ DEFS = @DEFS@ \ EXTRA_DIST = auth \ context query_cache\ - parser pool.h pcp pool_type.h pool_config.h protocol rewrite version.h utils watchdog config.h config.h.in pool_config_variables.h + parser pool.h pcp pool_type.h pool_config.h protocol rewrite version.h utils watchdog config.h config.h.in pool_config_variables.h pgproto diff --git a/src/include/Makefile.in b/src/include/Makefile.in index 6c22d56fe..e2e1b646c 100644 --- a/src/include/Makefile.in +++ b/src/include/Makefile.in @@ -279,7 +279,7 @@ top_srcdir = @top_srcdir@ ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = auth \ context query_cache\ - parser pool.h pcp pool_type.h pool_config.h protocol rewrite version.h utils watchdog config.h config.h.in pool_config_variables.h + parser pool.h pcp pool_type.h pool_config.h protocol rewrite version.h utils watchdog config.h config.h.in pool_config_variables.h pgproto all: config.h $(MAKE) $(AM_MAKEFLAGS) all-am diff --git a/src/tools/pgproto/buffer.c b/src/tools/pgproto/buffer.c index 173bfec10..f9163cfb6 100644 --- a/src/tools/pgproto/buffer.c +++ b/src/tools/pgproto/buffer.c @@ -14,7 +14,7 @@ */ #include "../../include/config.h" -#include "pgproto.h" +#include "pgproto/pgproto.h" #include <unistd.h> #include <stdlib.h> #include <stdio.h> @@ -22,10 +22,10 @@ #include <string.h> #include <errno.h> #include <fcntl.h> -#include "fe_memutils.h" +#include "pgproto/fe_memutils.h" #include <libpq-fe.h> -#include "read.h" -#include "buffer.h" +#include "pgproto/read.h" +#include "pgproto/buffer.h" /* * Read integer field and returns it. The pointer in the buffer afer reading diff --git a/src/tools/pgproto/buffer.h b/src/tools/pgproto/buffer.h deleted file mode 100644 index 087798c23..000000000 --- a/src/tools/pgproto/buffer.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2017 Tatsuo Ishii - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby - * granted, provided that the above copyright notice appear in all - * copies and that both that copyright notice and this permission - * notice appear in supporting documentation, and that the name of the - * author not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. The author makes no representations about the - * suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - */ - -#ifndef BUFFER_H - -#define BUFFER_H - -#define SKIP_TABS(p) while (*p == '\t') {p++;} - -extern int buffer_read_int(char *buf, char **bufp); -extern char *buffer_read_string(char *buf, char **bufp); -extern char buffer_read_char(char *buf, char **bufp); - -#endif diff --git a/src/tools/pgproto/extended_query.c b/src/tools/pgproto/extended_query.c index 753df958d..4fc01557a 100644 --- a/src/tools/pgproto/extended_query.c +++ b/src/tools/pgproto/extended_query.c @@ -16,7 +16,7 @@ */ #include "../../include/config.h" -#include "pgproto.h" +#include "pgproto/pgproto.h" #include <unistd.h> #include <stdlib.h> #include <stdio.h> @@ -24,12 +24,12 @@ #include <string.h> #include <errno.h> #include <fcntl.h> -#include "fe_memutils.h" +#include "pgproto/fe_memutils.h" #include <libpq-fe.h> -#include "read.h" -#include "send.h" -#include "extended_query.h" -#include "buffer.h" +#include "pgproto/read.h" +#include "pgproto/send.h" +#include "pgproto/extended_query.h" +#include "pgproto/buffer.h" /* * Send parse messae. "conn" should at the point right after the message kind diff --git a/src/tools/pgproto/extended_query.h b/src/tools/pgproto/extended_query.h deleted file mode 100644 index 02301d87e..000000000 --- a/src/tools/pgproto/extended_query.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2017 Tatsuo Ishii - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby - * granted, provided that the above copyright notice appear in all - * copies and that both that copyright notice and this permission - * notice appear in supporting documentation, and that the name of the - * author not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. The author makes no representations about the - * suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - * - * Process Parse, Bind, Execute message. - */ - -#ifndef EXTENDED_QUERY_H -#define EXTENDED_QUERY_H - -extern void process_parse(char *buf, PGconn *conn); -extern void process_bind(char *buf, PGconn *conn); -extern void process_execute(char *buf, PGconn *conn); -extern void process_describe(char *buf, PGconn *conn); -extern void process_close(char *buf, PGconn *conn); - -#endif diff --git a/src/tools/pgproto/fe_memutils.c b/src/tools/pgproto/fe_memutils.c index 704fb25b4..059476057 100644 --- a/src/tools/pgproto/fe_memutils.c +++ b/src/tools/pgproto/fe_memutils.c @@ -27,7 +27,7 @@ #include <stdint.h> #include <string.h> -#include "fe_memutils.h" +#include "pgproto/fe_memutils.h" static inline void * pg_malloc_internal(size_t size, int flags) diff --git a/src/tools/pgproto/fe_memutils.h b/src/tools/pgproto/fe_memutils.h deleted file mode 100644 index 0167b968d..000000000 --- a/src/tools/pgproto/fe_memutils.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * fe_memutils.h - * memory management support for frontend code - * - * Copyright (c) 2003-2017, PostgreSQL Global Development Group - * - * src/include/common/fe_memutils.h - */ -#ifndef FE_MEMUTILS_H -#define FE_MEMUTILS_H - -typedef size_t Size; - -/* - * Flags for pg_malloc_extended and palloc_extended, deliberately named - * the same as the backend flags. - */ -#define MCXT_ALLOC_HUGE 0x01 /* allow huge allocation (> 1 GB) not - * actually used for frontends */ -#define MCXT_ALLOC_NO_OOM 0x02 /* no failure if out-of-memory */ -#define MCXT_ALLOC_ZERO 0x04 /* zero allocated memory */ - -/* - * "Safe" memory allocation functions --- these exit(1) on failure - * (except pg_malloc_extended with MCXT_ALLOC_NO_OOM) - */ -extern char *pg_strdup(const char *in); -extern void *pg_malloc(size_t size); -extern void *pg_malloc0(size_t size); -extern void *pg_malloc_extended(size_t size, int flags); -extern void *pg_realloc(void *pointer, size_t size); -extern void pg_free(void *pointer); - -/* Equivalent functions, deliberately named the same as backend functions */ -extern char *pstrdup(const char *in); -extern void *palloc(Size size); -extern void *palloc0(Size size); -extern void *palloc_extended(Size size, int flags); -extern void *repalloc(void *pointer, Size size); -extern void pfree(void *pointer); - -#ifdef NOT_USED -/* sprintf into a palloc'd buffer --- these are in psprintf.c */ -extern char *psprintf(const char *fmt,...) pg_attribute_printf(1, 2); -extern size_t pvsnprintf(char *buf, size_t len, const char *fmt, va_list args) pg_attribute_printf(3, 0); -#endif - -#define MEMSET_LOOP_LIMIT 1024 - -/* - * MemSet - * Exactly the same as standard library function memset(), but considerably - * faster for zeroing small word-aligned structures (such as parsetree nodes). - * This has to be a macro because the main point is to avoid function-call - * overhead. However, we have also found that the loop is faster than - * native libc memset() on some platforms, even those with assembler - * memset() functions. More research needs to be done, perhaps with - * MEMSET_LOOP_LIMIT tests in configure. - */ -#define MemSet(start, val, len) \ - do \ - { \ - /* must be void* because we don't know if it is integer aligned yet */ \ - void *_vstart = (void *) (start); \ - int _val = (val); \ - Size _len = (len); \ -\ - if ((((uintptr_t) _vstart) & LONG_ALIGN_MASK) == 0 && \ - (_len & LONG_ALIGN_MASK) == 0 && \ - _val == 0 && \ - _len <= MEMSET_LOOP_LIMIT && \ - /* \ - * If MEMSET_LOOP_LIMIT == 0, optimizer should find \ - * the whole "if" false at compile time. \ - */ \ - MEMSET_LOOP_LIMIT != 0) \ - { \ - long *_start = (long *) _vstart; \ - long *_stop = (long *) ((char *) _start + _len); \ - while (_start < _stop) \ - *_start++ = 0; \ - } \ - else \ - memset(_vstart, _val, _len); \ - } while (0) - -/* originaly gettext staff */ -#define _(x) x - -/* Get a bit mask of the bits set in non-long aligned addresses */ -#define LONG_ALIGN_MASK (sizeof(long) - 1) - -#endif /* FE_MEMUTILS_H */ diff --git a/src/tools/pgproto/main.c b/src/tools/pgproto/main.c index 5e6284522..31d119c50 100644 --- a/src/tools/pgproto/main.c +++ b/src/tools/pgproto/main.c @@ -14,7 +14,7 @@ */ #include "../../include/config.h" -#include "pgproto.h" +#include "pgproto/pgproto.h" #include <unistd.h> #include <stdlib.h> #include <stdio.h> @@ -22,12 +22,12 @@ #include <string.h> #include <errno.h> #include <fcntl.h> -#include "fe_memutils.h" +#include "pgproto/fe_memutils.h" #include <libpq-fe.h> -#include "read.h" -#include "send.h" -#include "buffer.h" -#include "extended_query.h" +#include "pgproto/read.h" +#include "pgproto/send.h" +#include "pgproto/buffer.h" +#include "pgproto/extended_query.h" #undef DEBUG diff --git a/src/tools/pgproto/pgproto.h b/src/tools/pgproto/pgproto.h deleted file mode 100644 index 9be981572..000000000 --- a/src/tools/pgproto/pgproto.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2017-2018 Tatsuo Ishii - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby - * granted, provided that the above copyright notice appear in all - * copies and that both that copyright notice and this permission - * notice appear in supporting documentation, and that the name of the - * author not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. The author makes no representations about the - * suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - */ - -#ifndef PGPROTO_H -#define PGPROTO_H - -/* - * The default file name for protocol data to be sent from frontend to backend - */ -#define PGPROTODATA "pgproto.data" - -#define MAXENTRIES 128 - -/* - * Protocol data representation read from the data file. - * We assume that the protocol version is V3. - */ -typedef struct -{ - char type; /* message type */ - int size; /* message length excluding this (in host - * order) */ - char message[1]; /* actual message (variable length) */ -} PROTO_DATA; - -extern int read_nap; - -#endif /* PGPROTO_H */ diff --git a/src/tools/pgproto/read.c b/src/tools/pgproto/read.c index 1d8dd4d5c..11c5a8f98 100644 --- a/src/tools/pgproto/read.c +++ b/src/tools/pgproto/read.c @@ -16,16 +16,16 @@ */ #include "../../include/config.h" -#include "pgproto.h" +#include "pgproto/pgproto.h" #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <errno.h> #include <arpa/inet.h> -#include "fe_memutils.h" +#include "pgproto/fe_memutils.h" #include <libpq-fe.h> -#include "read.h" +#include "pgproto/read.h" static char read_char(PGconn *conn); static int read_int32(PGconn *conn); diff --git a/src/tools/pgproto/read.h b/src/tools/pgproto/read.h deleted file mode 100644 index b60f1a90c..000000000 --- a/src/tools/pgproto/read.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2017 Tatsuo Ishii - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby - * granted, provided that the above copyright notice appear in all - * copies and that both that copyright notice and this permission - * notice appear in supporting documentation, and that the name of the - * author not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. The author makes no representations about the - * suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - */ - -#ifndef READ_H -#define READ_H - -extern void read_until_ready_for_query(PGconn *conn, int check_input); -#endif diff --git a/src/tools/pgproto/send.c b/src/tools/pgproto/send.c index c31b224fe..77faad7b6 100644 --- a/src/tools/pgproto/send.c +++ b/src/tools/pgproto/send.c @@ -14,7 +14,7 @@ */ #include "../../include/config.h" -#include "pgproto.h" +#include "pgproto/pgproto.h" #include <unistd.h> #include <stdlib.h> #include <stdio.h> @@ -23,10 +23,10 @@ #include <errno.h> #include <fcntl.h> #include <arpa/inet.h> -#include "fe_memutils.h" +#include "pgproto/fe_memutils.h" #include <libpq-fe.h> -#include "read.h" -#include "send.h" +#include "pgproto/read.h" +#include "pgproto/send.h" /* * Send a character to the connection. diff --git a/src/tools/pgproto/send.h b/src/tools/pgproto/send.h deleted file mode 100644 index 9ce8d9dcc..000000000 --- a/src/tools/pgproto/send.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2017 Tatsuo Ishii - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby - * granted, provided that the above copyright notice appear in all - * copies and that both that copyright notice and this permission - * notice appear in supporting documentation, and that the name of the - * author not be used in advertising or publicity pertaining to - * distribution of the software without specific, written prior - * permission. The author makes no representations about the - * suitability of this software for any purpose. It is provided "as - * is" without express or implied warranty. - */ - -#ifndef SEND_H -#define SEND_H - -extern void send_char(char c, PGconn *conn); -extern void send_int(int intval, PGconn *conn); -extern void send_int16(short shortval, PGconn *conn); -extern void send_string(char *buf, PGconn *conn); -extern void send_byte(char *buf, int len, PGconn *conn); - -#endif [parent: ac01bec935bd]