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

Commit057683c

Browse files
committed
Add RELOID and TYPEOID portbility.
1 parentc3ec548 commit057683c

File tree

4 files changed

+92
-3
lines changed

4 files changed

+92
-3
lines changed

‎init.sql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
-- query - query string which will be parsed and planned.
55
-- filename - path to the file on a disk.
66
CREATEOR REPLACE FUNCTION @extschema@.pg_store_query_plan(
7-
queryTEXT,
8-
filenameTEXT)
7+
filenameTEXT,
8+
queryTEXT
9+
)
910
RETURNS VOIDAS'pg_execplan'
1011
LANGUAGE C;
1112

‎pg_execplan.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ pg_store_query_plan(PG_FUNCTION_ARGS)
8383
fwrite(&string_len,sizeof(size_t),1,fout);
8484
fwrite(query_string,sizeof(char),string_len,fout);
8585

86+
set_portable_output(true);
8687
plan_string=nodeToString(queryDesc->plannedstmt);
88+
set_portable_output(false);
8789
string_len=strlen(plan_string);
8890
fwrite(&string_len,sizeof(size_t),1,fout);
8991
fwrite(plan_string,sizeof(char),string_len,fout);
@@ -135,7 +137,19 @@ pg_exec_query_plan(PG_FUNCTION_ARGS)
135137
inteflags=0;
136138

137139
LoadPlanFromFile(filename,&query_string,&plan_string);
138-
pstmt= (PlannedStmt*)stringToNode(plan_string);
140+
141+
PG_TRY();
142+
{
143+
set_portable_input(true);
144+
pstmt= (PlannedStmt*)stringToNode(plan_string);
145+
set_portable_input(false);
146+
}
147+
PG_CATCH();
148+
{
149+
elog(INFO,"!!!BAD PLAN: %s",plan_string);
150+
PG_RE_THROW();
151+
}
152+
PG_END_TRY();
139153

140154
psrc=CreateCachedPlan(NULL,query_string,query_string);
141155
CompleteCachedPlan(psrc,NIL,NULL,NULL,0,NULL,NULL,

‎tests/create_objects.sql

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
-- Make dummy I/O routines using the existing internal support for int4, text
2+
CREATEFUNCTIONint42_in(cstring)
3+
RETURNS int42
4+
AS'int4in'
5+
LANGUAGE internal STRICT IMMUTABLE;
6+
CREATEFUNCTIONint42_out(int42)
7+
RETURNS cstring
8+
AS'int4out'
9+
LANGUAGE internal STRICT IMMUTABLE;
10+
11+
CREATETYPEint42 (
12+
internallength=4,
13+
input= int42_in,
14+
output= int42_out,
15+
alignment= int4,
16+
default=42,
17+
passedbyvalue
18+
);
19+
20+
CREATETABLEt1 (id int42);

‎tests/rpl.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
3+
# Script for the plan passing between separate instances
4+
U=`whoami`
5+
6+
# Paths
7+
PGINSTALL=`pwd`/tmp_install/
8+
LD_LIBRARY_PATH=$PGINSTALL/lib
9+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH
10+
export PATH=$PGINSTALL/bin:$PATH
11+
12+
pkill -9 postgres||true
13+
sleep 1
14+
rm -rf$PGINSTALL||true
15+
rm -rf PGDATA_Master||true
16+
rm -rf PGDATA_Slave||true
17+
rm -rf master.log||true
18+
rm -rf slave.log||true
19+
20+
# Building project
21+
make> /dev/null
22+
make -C contrib> /dev/null
23+
make install> /dev/null
24+
make -C contrib install> /dev/null
25+
26+
mkdir PGDATA_Master
27+
mkdir PGDATA_Slave
28+
initdb -D PGDATA_Master
29+
initdb -D PGDATA_Slave
30+
echo"shared_preload_libraries = 'postgres_fdw, pg_execplan'">> PGDATA_Master/postgresql.conf
31+
echo"shared_preload_libraries = 'postgres_fdw, pg_execplan'">> PGDATA_Slave/postgresql.conf
32+
33+
pg_ctl -w -D PGDATA_Master -o"-p 5432" -l master.log start
34+
pg_ctl -w -D PGDATA_Slave -o"-p 5433" -l slave.log start
35+
createdb$U -p 5432
36+
createdb$U -p 5433
37+
38+
psql -p 5432 -c"CREATE EXTENSION postgres_fdw;"
39+
psql -p 5433 -c"CREATE EXTENSION postgres_fdw;"
40+
psql -p 5432 -c"CREATE EXTENSION pg_execplan;"
41+
psql -p 5433 -c"CREATE EXTENSION pg_execplan;"
42+
43+
# shift oids
44+
psql -p 5433 -c"CREATE TABLE t0 (id int);"
45+
psql -p 5433 -c"DROP TABLE t0;"
46+
47+
#create database objects for check of oid switching
48+
psql -p 5432 -f contrib/pg_execplan/tests/create_objects.sql
49+
psql -p 5433 -f contrib/pg_execplan/tests/create_objects.sql
50+
51+
# TEST ON RELOID and TYPEOID objects.
52+
psql -p 5432 -c"SELECT pg_store_query_plan('../test.txt', 'SELECT * FROM t1;');"
53+
psql -p 5433 -c"SELECT pg_exec_query_plan('../test.txt');"
54+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp