Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit28dc32c

Browse files
committed
Add pg_repeater and functionality for passing regression tests
1 parenta505f9b commit28dc32c

File tree

15 files changed

+342
-123
lines changed

15 files changed

+342
-123
lines changed

‎contrib/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ SUBDIRS = \
3939
pgrowlocks\
4040
pgstattuple\
4141
pg_execplan\
42+
pg_repeater\
4243
pg_visibility\
4344
postgres_fdw\
4445
seg\

‎contrib/pg_execplan/Makefile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ PGFILEDESC = "pg_execplan"
77
MODULES = pg_execplan
88
OBJS = pg_execplan.o$(WIN32RES)
99

10-
fdw_srcdir =$(top_srcdir)/contrib/postgres_fdw/
11-
12-
PG_CPPFLAGS = -I$(libpq_srcdir) -I$(fdw_srcdir) -L$(fdw_srcdir)
10+
PG_CPPFLAGS = -I$(libpq_srcdir)
1311
SHLIB_LINK_INTERNAL =$(libpq)
1412

1513
DATA_built =$(EXTENSION)--$(EXTVERSION).sql
@@ -19,12 +17,10 @@ PG_CONFIG = pg_config
1917
PGXS :=$(shell$(PG_CONFIG) --pgxs)
2018
include$(PGXS)
2119
else
22-
EXTRA_INSTALL = contrib/postgres_fdw
2320
SHLIB_PREREQS = submake-libpq
2421
subdir = contrib/pg_execplan
2522
top_builddir = ../..
2623
include$(top_builddir)/src/Makefile.global
27-
#include $(top_builddir)/contrib/postgres_fdw/Makefile
2824
include$(top_srcdir)/contrib/contrib-global.mk
2925
endif
3026

‎contrib/pg_execplan/pg_execplan.c

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,31 +117,31 @@ exec_plan(char *query_string, char *plan_string)
117117
}
118118
PG_CATCH();
119119
{
120-
elog(INFO,"BAD PLAN: %s",plan_string);
120+
elog(INFO,"BAD PLAN: %s. Query: %s",plan_string,query_string);
121121
PG_RE_THROW();
122122
}
123123
PG_END_TRY();
124124

125-
psrc=CreateCachedPlan(NULL,query_string,query_string);
126-
CompleteCachedPlan(psrc,NIL,NULL,NULL,0,NULL,NULL,
127-
CURSOR_OPT_GENERIC_PLAN, false);
128-
StorePreparedStatement(query_string,psrc, false);
129-
SetRemoteSubplan(psrc,pstmt);
130-
cplan=GetCachedPlan(psrc,paramLI, false);
131-
132125
if (EXPLAN_DEBUG_LEVEL>0)
133126
elog(INFO,"query: %s\n",query_string);
134127
if (EXPLAN_DEBUG_LEVEL>1)
135128
elog(INFO,"\nplan: %s\n",plan_string);
136129

137-
receiver=CreateDestReceiver(DestDebug);
130+
psrc=CreateCachedPlan(NULL,query_string,NULL);
131+
CompleteCachedPlan(psrc,NIL,NULL,NULL,0,NULL,NULL,
132+
CURSOR_OPT_GENERIC_PLAN, false);
133+
134+
SetRemoteSubplan(psrc,pstmt);
135+
cplan=GetCachedPlan(psrc,paramLI, false);
136+
137+
receiver=CreateDestReceiver(DestNone);
138138
portal=CreateNewPortal();
139139
portal->visible= false;
140140
PortalDefineQuery(portal,
141141
NULL,
142142
query_string,
143-
query_string,
144-
cplan->stmt_list,
143+
NULL,
144+
NULL,
145145
cplan);
146146
PG_TRY();
147147
{
@@ -156,14 +156,14 @@ exec_plan(char *query_string, char *plan_string)
156156
}
157157
PG_CATCH();
158158
{
159-
elog(INFO,"BAD QUERY: %s",query_string);
159+
elog(INFO,"BAD QUERY: '%s'.",query_string);
160+
PortalDrop(portal, false);
160161
PG_RE_THROW();
161162
}
162163
PG_END_TRY();
163164

164165
receiver->rDestroy(receiver);
165166
PortalDrop(portal, false);
166-
DropPreparedStatement(query_string, false);
167167

168168
if (EXPLAN_DEBUG_LEVEL>0)
169169
elog(INFO,"query execution finished.\n");
@@ -175,9 +175,29 @@ pg_exec_plan(PG_FUNCTION_ARGS)
175175
char*query_string=TextDatumGetCString(PG_GETARG_DATUM(0));
176176
char*plan_string=TextDatumGetCString(PG_GETARG_DATUM(1));
177177

178+
char*dec_query,
179+
*dec_plan;
180+
intdec_query_len,
181+
dec_query_len1,
182+
dec_plan_len,
183+
dec_plan_len1;
184+
178185
Assert(query_string!=NULL);
179186
Assert(plan_string!=NULL);
180-
exec_plan(query_string,plan_string);
187+
188+
dec_query_len=b64_dec_len(query_string,strlen(query_string)+1)+1;
189+
dec_query=palloc0(dec_query_len+1);
190+
dec_query_len1=b64_decode(query_string,strlen(query_string),dec_query);
191+
Assert(dec_query_len>dec_query_len1);
192+
193+
dec_plan_len=b64_dec_len(plan_string,strlen(plan_string)+1);
194+
dec_plan=palloc0(dec_plan_len+1);
195+
dec_plan_len1=b64_decode(plan_string,strlen(plan_string),dec_plan);
196+
Assert(dec_plan_len>dec_plan_len1);
197+
198+
exec_plan(dec_query,dec_plan);
199+
pfree(dec_query);
200+
pfree(dec_plan);
181201
PG_RETURN_BOOL(true);
182202
}
183203

‎contrib/pg_execplan/pg_execplan.control

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ comment = 'Execute raw query plan on remote node'
33
default_version = '0.1'
44
module_pathname = '$libdir/pg_execplan'
55
relocatable = false
6-
requires = 'postgres_fdw'

‎contrib/pg_execplan/tests/regress

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
3+
# This script performs regress tests at a master and mirrored it into the slave.
4+
U=`whoami`
5+
export LC_ALL=C
6+
export LANGUAGE="en_US:en"
7+
8+
# Paths
9+
PGINSTALL=`pwd`/tmp_install/
10+
SCRIPTS=`pwd`/contrib/pg_execplan/tests
11+
LD_LIBRARY_PATH=$PGINSTALL/lib
12+
remoteSrvName=fdwremote
13+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH
14+
export PATH=$PGINSTALL/bin:$PATH
15+
16+
pkill -9 postgres||true
17+
sleep 1
18+
rm -rf$PGINSTALL||true
19+
rm -rf PGDATA_Master||true
20+
rm -rf PGDATA_Slave||true
21+
rm -rf master.log||true
22+
rm -rf slave.log||true
23+
24+
# Building project
25+
make> /dev/null
26+
make -C contrib> /dev/null
27+
make install> /dev/null
28+
make -C contrib install> /dev/null
29+
30+
mkdir PGDATA_Master
31+
mkdir PGDATA_Slave
32+
initdb -D PGDATA_Master -E UTF8 --locale=C
33+
initdb -D PGDATA_Slave -E UTF8 --locale=C
34+
echo"shared_preload_libraries = 'postgres_fdw, pg_execplan, pg_repeater'">> PGDATA_Master/postgresql.conf
35+
echo"shared_preload_libraries = 'pg_execplan'">> PGDATA_Slave/postgresql.conf
36+
echo"repeater.fdwname = '$remoteSrvName'">> PGDATA_Master/postgresql.conf
37+
38+
pg_ctl -c -o"-p 5433" -D PGDATA_Slave -l slave.log start
39+
pg_ctl -c -o"-p 5432" -D PGDATA_Master -l master.log start
40+
createdb -p 5433$U
41+
createdb -p 5432$U
42+
43+
psql -p 5432 -c"CREATE EXTENSION postgres_fdw;"
44+
psql -p 5432 -c"CREATE SERVER$remoteSrvName FOREIGN DATA WRAPPER postgres_fdw OPTIONS (port '5433', use_remote_estimate 'on');"
45+
psql -p 5432 -c"CREATE USER MAPPING FOR PUBLIC SERVER$remoteSrvName;"
46+
47+
# Prepare plan execution
48+
psql -p 5432 -c"CREATE EXTENSION pg_execplan;"
49+
psql -p 5433 -c"CREATE EXTENSION pg_execplan;"
50+
psql -p 5432 -c"CREATE EXTENSION pg_repeater;"
51+
52+
psql -p 5433 -c"CREATE TABLE t2 (id Serial, b INT, PRIMARY KEY(id));"
53+
psql -p 5433 -c"DROP TABLE t2;"
54+
#psql -p 5433 -c "SELECT pg_exec_plan('SELECT * FROM pg_class;','sdadad');"
55+
56+
rm -rf`pwd`/src/test/regress/testtablespace
57+
mkdir`pwd`/src/test/regress/testtablespace
58+
rm -rf$PGINSTALL/lib/regress.so
59+
cp`pwd`/src/test/regress/regress.so$PGINSTALL/lib
60+
cp`pwd`/src/test/regress/regress.so$PGINSTALL/lib/postgresql/
61+
cd src/test/regress
62+
./pg_regress --schedule=$SCRIPTS/serial_schedule --load-extension=postgres_fdw --load-extension=pg_execplan --load-extension=pg_repeater --dbname=andrey --use-existing

‎contrib/pg_execplan/tests/rpl.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,3 @@ psql -p 5433 -c "SELECT oid, oprname, oprnamespace FROM pg_operator WHERE oprnam
7878
# Test
7979
psql -p 5432 -c"SELECT pg_store_query_plan('../test.txt', 'SELECT id ### 1 FROM tests.ttest1;');"
8080
psql -p 5433 -c"SELECT pg_exec_stored_plan('../test.txt');"
81-
82-
psql -p 5433 -c"SELECT pg_store_query_plan('../test.txt', 'SELECT collname, nspname
83-
FROM pg_collation JOIN pg_namespace ON (collnamespace = pg_namespace.oid)
84-
WHERE collname LIKE ''test%''
85-
ORDER BY 1;');"
86-
psql -p 5433 -c"SELECT pg_exec_stored_plan('../test.txt');"
87-
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
# src/test/regress/serial_schedule
2+
# This should probably be in an order similar to parallel_schedule.
3+
test: boolean
4+
test: char
5+
test: name
6+
test: varchar
7+
test: text
8+
test: int2
9+
test: int4
10+
test: int8
11+
test: oid
12+
test: float4
13+
test: float8
14+
test: bit
15+
test: numeric
16+
test: txid
17+
test: uuid
18+
test: enum
19+
test: money
20+
test: rangetypes
21+
test: pg_lsn
22+
test: regproc
23+
test: strings
24+
test: numerology
25+
test: point
26+
test: lseg
27+
test: line
28+
test: box
29+
test: path
30+
test: polygon
31+
test: circle
32+
test: date
33+
test: time
34+
test: timetz
35+
test: timestamp
36+
test: timestamptz
37+
test: interval
38+
test: abstime
39+
test: reltime
40+
test: tinterval
41+
test: inet
42+
test: macaddr
43+
test: tstypes
44+
test: comments
45+
test: geometry
46+
test: horology
47+
test: regex
48+
test: oidjoins
49+
test: type_sanity
50+
test: opr_sanity
51+
test: insert
52+
test: insert_conflict
53+
test: create_function_1
54+
test: create_type
55+
test: create_table
56+
test: create_function_2
57+
test: copy
58+
test: copyselect
59+
test: copydml
60+
test: create_misc
61+
test: create_operator
62+
test: create_index
63+
test: create_view
64+
test: create_aggregate
65+
test: create_function_3
66+
test: create_cast
67+
test: constraints
68+
test: triggers
69+
test: inherit
70+
test: create_table_like
71+
test: typed_table
72+
test: vacuum
73+
test: drop_if_exists
74+
test: updatable_views
75+
test: rolenames
76+
test: roleattributes
77+
test: create_am
78+
test: sanity_check
79+
test: errors
80+
test: select
81+
test: select_into
82+
test: select_distinct
83+
test: select_distinct_on
84+
test: select_implicit
85+
test: select_having
86+
test: subselect
87+
test: union
88+
test: case
89+
test: join
90+
test: aggregates
91+
test: transactions
92+
ignore: random
93+
test: random
94+
test: portals
95+
test: arrays
96+
test: btree_index
97+
test: hash_index
98+
test: update
99+
test: delete
100+
test: namespace
101+
test: prepared_xacts
102+
test: brin
103+
test: gin
104+
test: gist
105+
test: spgist
106+
test: privileges
107+
test: init_privs
108+
test: security_label
109+
test: collate
110+
test: matview
111+
test: lock
112+
test: replica_identity
113+
test: rowsecurity
114+
test: object_address
115+
test: tablesample
116+
test: groupingsets
117+
test: drop_operator
118+
test: alter_generic
119+
test: alter_operator
120+
test: misc
121+
test: psql
122+
test: async
123+
test: dbsize
124+
test: misc_functions
125+
test: tsrf
126+
test: rules
127+
test: psql_crosstab
128+
test: select_parallel
129+
test: publication
130+
test: subscription
131+
test: amutils
132+
test: select_views
133+
test: portals_p2
134+
test: foreign_key
135+
test: cluster
136+
test: dependency
137+
test: guc
138+
test: bitmapops
139+
test: combocid
140+
test: tsearch
141+
test: tsdicts
142+
test: foreign_data
143+
test: window
144+
test: xmlmap
145+
test: functional_deps
146+
test: advisory_lock
147+
test: json
148+
test: jsonb
149+
test: json_encoding
150+
test: indirect_toast
151+
test: equivclass
152+
test: plancache
153+
test: limit
154+
test: plpgsql
155+
test: copy2
156+
test: temp
157+
test: domain
158+
test: rangefuncs
159+
test: prepare
160+
test: without_oid
161+
test: conversion
162+
test: truncate
163+
test: alter_table
164+
test: sequence
165+
test: polymorphism
166+
test: rowtypes
167+
test: returning
168+
test: largeobject
169+
test: with
170+
test: xml
171+
test: event_trigger
172+
test: stats

‎contrib/pg_repeater/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ MODULE_big = pg_repeater
44
EXTENSION = pg_repeater
55
EXTVERSION = 0.1
66
PGFILEDESC = "pg_repeater"
7-
MODULES =pg_repeater1
7+
MODULES =pg_repeater
88
OBJS = pg_repeater.o$(WIN32RES)
99

1010
fdw_srcdir =$(top_srcdir)/contrib/postgres_fdw/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp