Fix timestamp test so that it works.
authorToshihiro Kitagawa <kitagawa at sraoss.co.jp>
Mon, 5 Sep 2011 09:05:50 +0000 (09:05 +0000)
committerToshihiro Kitagawa <kitagawa at sraoss.co.jp>
Mon, 5 Sep 2011 09:05:50 +0000 (09:05 +0000)
test/timestamp/Makefile
test/timestamp/expected/insert.out
test/timestamp/expected/misc.out
test/timestamp/expected/update.out
test/timestamp/main.c

index 9a241a024c0bf424619b01a415d4e276cddd8858..3b409d87b04e3e81a303778457e78ddcc42a68f1 100644 (file)
@@ -5,6 +5,7 @@ CPPFLAGS=-I$(topsrc_dir) -I$(shell pg_config --includedir)
 CFLAGS=-Wall -O0 -g
 
 OBJS=main.o \
+        $(topsrc_dir)/strlcpy.o \
         $(topsrc_dir)/pool_timestamp.o \
         $(topsrc_dir)/parser/libsql-parser.a
 
@@ -12,6 +13,7 @@ all: all-pre $(PROGRAM)
 
 all-pre:
        $(MAKE) -C $(topsrc_dir)/parser
+       $(MAKE) -C $(topsrc_dir) strlcpy.o
        $(MAKE) -C $(topsrc_dir) pool_timestamp.o
 
 $(PROGRAM): $(OBJS)
index 89e15bc7e64efd9a92243519e0d889901f7ae05e..f666a5f307c14ffe501120a05f983792f7b0321c 100644 (file)
@@ -1,8 +1,8 @@
 INSERT INTO "rel1" VALUES (DEFAULT,'2009-01-01 23:59:59.123456+09',DEFAULT,'2009-01-01 23:59:59.123456+09')
 INSERT INTO rel2 DEFAULT VALUES
 INSERT INTO rel2(c1) VALUES(1)
-INSERT INTO "rel1" VALUES (1,"timestamptz"('2009-01-01 23:59:59.123456+09'::text),2,'2009-01-01 23:59:59.123456+09'::text::date)
-INSERT INTO "rel1" VALUES (3,"timestamptz"('2009-01-01 23:59:59.123456+09'::text),4,'2009-01-01 23:59:59.123456+09'::text::timetz)
+INSERT INTO "rel1" VALUES (1,"pg_catalog"."timestamptz"('2009-01-01 23:59:59.123456+09'::text),2,'2009-01-01 23:59:59.123456+09'::text::date)
+INSERT INTO "rel1" VALUES (3,"pg_catalog"."timestamptz"('2009-01-01 23:59:59.123456+09'::text),4,'2009-01-01 23:59:59.123456+09'::text::timetz)
 INSERT INTO "rel1" VALUES (5,'2009-01-01 23:59:59.123456+09'::text::timestamptz(0),6,'2009-01-01 23:59:59.123456+09'::text::timetz(0))
 INSERT INTO "rel1" VALUES (7,'2009-01-01 23:59:59.123456+09'::text::timestamp,8,'2009-01-01 23:59:59.123456+09'::text::time)
 INSERT INTO "rel1" VALUES (9,'2009-01-01 23:59:59.123456+09'::text::timestamp(0),10,'2009-01-01 23:59:59.123456+09'::text::time(0))
index e1f9bf82b0f71bcbcf0a1a00863a8b79c193b1cf..66376eae5513f75e979cf9b21cadd33364ff3d86 100644 (file)
@@ -1,3 +1,3 @@
 DELETE FROM "rel1" WHERE  ("c1"='2009-01-01 23:59:59.123456+09'::text::date )
 PREPARE "q" ("date",timestamptz) AS DELETE FROM "rel1" WHERE  ( ("c1"=$1 ) AND  ("c3"=$2::text::date ))
-EXECUTE "q" ("timestamptz"('2009-01-01 23:59:59.123456+09'::text))
+EXECUTE "q" ("pg_catalog"."timestamptz"('2009-01-01 23:59:59.123456+09'::text))
index 4d0011d59ad452e2b9eedd368785b655317aadde..d14c8cef94929addd95c9a6daaa38af0ad4834d7 100644 (file)
@@ -1,6 +1,6 @@
 UPDATE "rel1" SET "c1" = DEFAULT, "c2" = '2009-01-01 23:59:59.123456+09'
 UPDATE rel2 SET c1 = DEFAULT, c2 = DEFAULT
-UPDATE "rel1" SET "c1" = "timestamptz"('2009-01-01 23:59:59.123456+09'::text), "c2" = '2009-01-01 23:59:59.123456+09'::text::date
-UPDATE "rel1" SET "c3" = "timestamptz"('2009-01-01 23:59:59.123456+09'::text), "c4" = '2009-01-01 23:59:59.123456+09'::text::timetz
+UPDATE "rel1" SET "c1" = "pg_catalog"."timestamptz"('2009-01-01 23:59:59.123456+09'::text), "c2" = '2009-01-01 23:59:59.123456+09'::text::date
+UPDATE "rel1" SET "c3" = "pg_catalog"."timestamptz"('2009-01-01 23:59:59.123456+09'::text), "c4" = '2009-01-01 23:59:59.123456+09'::text::timetz
 UPDATE "rel1" SET "c1" = '2009-01-01 23:59:59.123456+09'::text::timestamp, "c2" = '2009-01-01 23:59:59.123456+09'::text::time
 PREPARE "q" (int4,timestamptz) AS UPDATE "rel1" SET "c1" = $1, "c2" = $2::text::date
index 1862fd88fa1ceabe8213c49f408efffc375c4538..c821ccd86936ed314c00787d1f867af761bd2ff4 100644 (file)
@@ -2,20 +2,20 @@
 #include <string.h>
 #include <stdio.h>
 #include "pool.h"
-#include "pool_proto_modules.h"
+#include "pool_config.h"
+#include "pool_relcache.h"
 #include "pool_timestamp.h"
 #include "parser/parser.h"
 
 /* for get_current_timestamp() (MASTER() macro) */
 POOL_REQUEST_INFO              _req_info;
 POOL_REQUEST_INFO *Req_info = &_req_info;
-int selected_slot = 0;         /* selected DB node */
-int in_load_balance = 1;       /* non 0 if in load balance mode */
 POOL_CONFIG _pool_config;
 POOL_CONFIG *pool_config = &_pool_config;
 
 typedef struct {
-       char    *attrname;
+       char    *attrname;      /* attribute name */
+       char    *adsrc;         /* default value expression */
        int              use_timestamp;
 } TSAttr;
 
@@ -27,19 +27,29 @@ typedef struct {
 
 TSRel   rc[2] = {
        { 4, {
-               { "c1", 0 },
-               { "c2", 1 },
-               { "c3", 0 },
-               { "c4", 1 }
+               { "c1", "", 0 },
+               { "c2", "", 1 },
+               { "c3", "", 0 },
+               { "c4", "", 1 }
        } },
        { 4, {
-               { "c1", 0 },
-               { "c2", 0 },
-               { "c3", 0 },
-               { "c4", 0 }
+               { "c1", "", 0 },
+               { "c2", "", 0 },
+               { "c3", "", 0 },
+               { "c4", "", 0 }
        } }
 };
 
+int pool_virtual_master_db_node_id(void)
+{
+       return 0;
+}
+
+bool pool_has_pgpool_regclass(void)
+{
+       return false;
+}
+
 POOL_RELCACHE *
 pool_create_relcache(int cachesize, char *sql, func_ptr register_func, func_ptr unregister_func, bool issessionlocal)
 {
@@ -75,10 +85,12 @@ main(int argc, char **argv)
        char            *query;
        List            *tree;
        ListCell        *l;
-       Portal           portal;
+       StartupPacket    sp;
        POOL_CONNECTION_POOL    backend;
        POOL_CONNECTION_POOL_SLOT slot;
+       POOL_SENT_MESSAGE       msg;
        backend.slots[0] = &slot;
+       slot.sp = &sp;
 
        pool_config->replication_mode = 1;
 
@@ -97,9 +109,9 @@ main(int argc, char **argv)
        {
                foreach(l, tree)
                {
-                       portal.num_tsparams = 0;
+                       msg.num_tsparams = 0;
                        Node *node = (Node *) lfirst(l);
-                       query = rewrite_timestamp(&backend, node, false, &portal);
+                       query = rewrite_timestamp(&backend, node, false, &msg);
                        if (query)
                                printf("%s\n", query);
                        else