pgpool2.git / summary / log / commit / refs
commit 5ab4a1bd6b53259a9116a1394bfe4fb1263b745f
Author: Yugo Nagata <nagata@sraoss.co.jp>
Date: Wed Aug 19 09:53:59 2015 +0000
Fix complication error and segfault of timestamp rewrite test
src/test/timestamp/Makefile | 14 ++++++++------
src/test/timestamp/main.c | 30 +++++++++++++++++++++++++++---
2 files changed, 35 insertions(+), 9 deletions(-)
diff --git a/src/test/timestamp/Makefile b/src/test/timestamp/Makefile
index 3b409d87b..8f00c2c58 100644
--- a/src/test/timestamp/Makefile
+++ b/src/test/timestamp/Makefile
@@ -1,20 +1,22 @@
-
PROGRAM=timestamp-test
topsrc_dir=../..
-CPPFLAGS=-I$(topsrc_dir) -I$(shell pg_config --includedir)
+CPPFLAGS=-I$(topsrc_dir)/include -I$(shell pg_config --includedir)
CFLAGS=-Wall -O0 -g
+CC=gcc
OBJS=main.o \
- $(topsrc_dir)/strlcpy.o \
- $(topsrc_dir)/pool_timestamp.o \
+ $(topsrc_dir)/utils/strlcpy.o \
+ $(topsrc_dir)/utils/psprintf.o \
+ $(topsrc_dir)/rewrite/pool_timestamp.o \
$(topsrc_dir)/parser/libsql-parser.a
all: all-pre $(PROGRAM)
all-pre:
+ $(MAKE) -C $(topsrc_dir)/utils strlcpy.o
+ $(MAKE) -C $(topsrc_dir)/utils psprintf.o
+ $(MAKE) -C $(topsrc_dir)/rewrite pool_timestamp.o
$(MAKE) -C $(topsrc_dir)/parser
- $(MAKE) -C $(topsrc_dir) strlcpy.o
- $(MAKE) -C $(topsrc_dir) pool_timestamp.o
$(PROGRAM): $(OBJS)
$(CC) $(OBJS) -o $(PROGRAM)
diff --git a/src/test/timestamp/main.c b/src/test/timestamp/main.c
index 27852ab29..6dea26e46 100644
--- a/src/test/timestamp/main.c
+++ b/src/test/timestamp/main.c
@@ -3,8 +3,8 @@
#include <stdio.h>
#include "pool.h"
#include "pool_config.h"
-#include "pool_relcache.h"
-#include "pool_timestamp.h"
+#include "utils/pool_relcache.h"
+#include "rewrite/pool_timestamp.h"
#include "parser/parser.h"
/* for get_current_timestamp() (MASTER() macro) */
@@ -12,6 +12,7 @@ POOL_REQUEST_INFO _req_info;
POOL_REQUEST_INFO *Req_info = &_req_info;
POOL_CONFIG _pool_config;
POOL_CONFIG *pool_config = &_pool_config;
+ProcessType processType;
typedef struct {
char *attrname; /* attribute name */
@@ -50,12 +51,23 @@ bool pool_has_pgpool_regclass(void)
return false;
}
+bool pool_has_to_regclass(void)
+{
+ return false;
+}
+
+char *remove_quotes_and_schema_from_relname(char *table)
+{
+ return table;
+}
+
POOL_RELCACHE *
pool_create_relcache(int cachesize, char *sql, func_ptr register_func, func_ptr unregister_func, bool issessionlocal)
{
return (POOL_RELCACHE *) 1;
}
+/* dummy result of relcache (attrname, adsrc, usetimestamp)*/
void *
pool_search_relcache(POOL_RELCACHE *relcache, POOL_CONNECTION_POOL *backend, char *table)
{
@@ -65,6 +77,7 @@ pool_search_relcache(POOL_RELCACHE *relcache, POOL_CONNECTION_POOL *backend, cha
return (void *) &(rc[1]);
}
+/* dummy result of "SELECT now()" */
void do_query(POOL_CONNECTION *backend, char *query, POOL_SELECT_RESULT **result, int major) {
static POOL_SELECT_RESULT res;
static char *data[1] = {
@@ -87,9 +100,12 @@ main(int argc, char **argv)
POOL_CONNECTION_POOL backend;
POOL_CONNECTION_POOL_SLOT slot;
POOL_SENT_MESSAGE msg;
+ POOL_QUERY_CONTEXT ctx;
backend.slots[0] = &slot;
slot.sp = &sp;
+ MemoryContextInit();
+
pool_config->replication_mode = 1;
if (argc != 2)
@@ -108,6 +124,7 @@ main(int argc, char **argv)
foreach(l, tree)
{
msg.num_tsparams = 0;
+ msg.query_context = &ctx;
Node *node = (Node *) lfirst(l);
query = rewrite_timestamp(&backend, node, false, &msg);
if (query)
@@ -120,5 +137,12 @@ main(int argc, char **argv)
return 0;
}
-void pool_error(const char *fmt,...) {}
void free_select_result(POOL_SELECT_RESULT *result) {}
+POOL_SESSION_CONTEXT *pool_get_session_context(bool noerror) {return NULL;}
+int pg_frontend_exists(void) {return 0;}
+int get_frontend_protocol_version(void) {return 0;}
+int set_pg_frontend_blocking(bool blocking) {return 0;}
+int send_to_pg_frontend(char* data, int len, bool flush) {return 0;}
+void ExceptionalCondition
+ (const char *conditionName,const char *errorType,
+ const char *fileName, int lineNumber) {}
[parent: 8d6f202b2818]