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

Commit0c2f5df

Browse files
committed
Intermediate commit for many efforts saving: exchange node (without transport) + planner base rules
1 parent678ac3d commit0c2f5df

29 files changed

+2533
-2
lines changed

‎.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,5 @@ lib*.pc
4444
/tmp_install/
4545
/.cproject
4646
/.project
47+
/.gdb_history
4748
/.settings/

‎contrib/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ SUBDIRS = \
3030
pageinspect\
3131
passwordcheck\
3232
pg_buffercache\
33+
pg_exchange\
3334
pg_execplan\
3435
pg_freespacemap\
3536
pg_prewarm\

‎contrib/pg_exchange/LICENSE

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
ParGRES is released under the PostgreSQL License, a liberal Open Source license, similar to the BSD or MIT licenses.
2+
3+
Copyright (c) 2018-2019, Postgres Professional
4+
Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group
5+
Portions Copyright (c) 1994, The Regents of the University of California
6+
7+
Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies.
8+
9+
IN NO EVENT SHALL POSTGRES PROFESSIONAL BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF POSTGRES PROFESSIONAL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10+
11+
POSTGRES PROFESSIONAL SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND POSTGRES PROFESSIONAL HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

‎contrib/pg_exchange/Makefile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# contrib/pg_exchange/Makefile
2+
3+
MODULE_big = pg_exchange
4+
EXTENSION = pg_exchange
5+
EXTVERSION = 0.1
6+
PGFILEDESC = "pg_exchange - an exchange custom node and rules for the planner"
7+
MODULES = pg_exchange
8+
OBJS = pg_exchange.o exchange.o connection.o hooks.o common.o nodeDummyscan.o nodeDistPlanExec.o$(WIN32RES)
9+
10+
fdw_srcdir =$(top_srcdir)/contrib/postgres_fdw/
11+
12+
PG_CPPFLAGS = -I$(libpq_srcdir) -I$(fdw_srcdir) -L$(fdw_srcdir)
13+
SHLIB_LINK_INTERNAL =$(libpq)
14+
15+
DATA_built =$(EXTENSION)--$(EXTVERSION).sql
16+
17+
ifdefUSE_PGXS
18+
PG_CONFIG = pg_config
19+
PGXS :=$(shell$(PG_CONFIG) --pgxs)
20+
include$(PGXS)
21+
else
22+
EXTRA_INSTALL = contrib/postgres_fdw
23+
SHLIB_PREREQS = submake-libpq
24+
subdir = contrib/pg_exchange
25+
top_builddir = ../..
26+
include$(top_builddir)/src/Makefile.global
27+
include$(top_srcdir)/contrib/contrib-global.mk
28+
endif
29+
30+
$(EXTENSION)--$(EXTVERSION).sql: init.sql
31+
cat$^>$@

‎contrib/pg_exchange/common.c

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/* ------------------------------------------------------------------------
2+
*
3+
* common.c
4+
*Common code for ParGRES extension
5+
*
6+
* Copyright (c) 2018, Postgres Professional
7+
*
8+
* ------------------------------------------------------------------------
9+
*/
10+
11+
#include"postgres.h"
12+
13+
#include"access/heapam.h"
14+
#include"access/htup_details.h"
15+
#include"access/genam.h"
16+
#include"access/sysattr.h"
17+
#include"access/xact.h"
18+
#include"catalog/indexing.h"
19+
#include"catalog/pg_extension.h"
20+
#include"commands/extension.h"
21+
#include"utils/fmgroids.h"
22+
23+
#include"common.h"
24+
25+
26+
/* GUC variables */
27+
intnode_number;
28+
intnodes_at_cluster;
29+
char*pargres_hosts_string=NULL;
30+
char*pargres_ports_string=NULL;
31+
inteports_pool_size=100;
32+
33+
intCoordNode=-1;
34+
boolPargresInitialized= false;
35+
PortStack*PORTS;
36+
37+
38+
Oid
39+
get_pargres_schema(void)
40+
{
41+
Oidresult;
42+
Relationrel;
43+
SysScanDescscandesc;
44+
HeapTupletuple;
45+
ScanKeyDataentry[1];
46+
Oidext_oid;
47+
48+
/* It's impossible to fetch pg_pathman's schema now */
49+
if (!IsTransactionState())
50+
returnInvalidOid;
51+
52+
ext_oid=get_extension_oid("pargres", true);
53+
if (ext_oid==InvalidOid)
54+
returnInvalidOid;/* exit if pg_pathman does not exist */
55+
56+
ScanKeyInit(&entry[0],
57+
ObjectIdAttributeNumber,
58+
BTEqualStrategyNumber,F_OIDEQ,
59+
ObjectIdGetDatum(ext_oid));
60+
61+
rel=heap_open(ExtensionRelationId,AccessShareLock);
62+
scandesc=systable_beginscan(rel,ExtensionOidIndexId, true,
63+
NULL,1,entry);
64+
65+
tuple=systable_getnext(scandesc);
66+
67+
/* We assume that there can be at most one matching tuple */
68+
if (HeapTupleIsValid(tuple))
69+
result= ((Form_pg_extension)GETSTRUCT(tuple))->extnamespace;
70+
else
71+
result=InvalidOid;
72+
73+
systable_endscan(scandesc);
74+
75+
heap_close(rel,AccessShareLock);
76+
77+
returnresult;
78+
}
79+
80+
void
81+
STACK_Init(PortStack*stack,intrange_min,intsize)
82+
{
83+
inti;
84+
85+
LWLockAcquire(&stack->lock,LW_EXCLUSIVE);
86+
87+
stack->size=size;
88+
stack->index=0;
89+
for (i=0;i<stack->size;i++)
90+
stack->values[i]=range_min+i;
91+
92+
LWLockRelease(&stack->lock);
93+
}
94+
95+
int
96+
STACK_Pop(PortStack*stack)
97+
{
98+
intvalue;
99+
100+
LWLockAcquire(&stack->lock,LW_EXCLUSIVE);
101+
102+
Assert(stack->index<stack->size);
103+
value=stack->values[stack->index++];
104+
105+
LWLockRelease(&stack->lock);
106+
returnvalue;
107+
}
108+
109+
void
110+
STACK_Push(PortStack*stack,intvalue)
111+
{
112+
LWLockAcquire(&stack->lock,LW_EXCLUSIVE);
113+
114+
Assert(stack->index>0);
115+
stack->values[--stack->index]=value;
116+
117+
LWLockRelease(&stack->lock);
118+
}

‎contrib/pg_exchange/common.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* common.h
4+
*Common code for ParGRES extension
5+
*
6+
* Copyright (c) 2018, PostgreSQL Global Development Group
7+
* Author: Andrey Lepikhov <a.lepikhov@postgrespro.ru>
8+
*
9+
* IDENTIFICATION
10+
*contrib/pargres/common.h
11+
*
12+
*-------------------------------------------------------------------------
13+
*/
14+
15+
#ifndefCOMMON_H_
16+
#defineCOMMON_H_
17+
18+
#include"nodes/pg_list.h"
19+
#include"storage/lock.h"
20+
21+
22+
typedefstruct
23+
{
24+
LWLocklock;
25+
intsize;
26+
intindex;
27+
intvalues[FLEXIBLE_ARRAY_MEMBER];
28+
}PortStack;
29+
30+
31+
/* GUC variables */
32+
externintnode_number;
33+
externintnodes_at_cluster;
34+
externchar*pargres_hosts_string;
35+
externchar*pargres_ports_string;
36+
externinteports_pool_size;
37+
38+
externPortStack*PORTS;
39+
externintCoordNode;
40+
externboolPargresInitialized;
41+
42+
43+
externOidget_pargres_schema(void);
44+
externvoidSTACK_Init(PortStack*stack,intrange_min,intsize);
45+
intSTACK_Pop(PortStack*stack);
46+
voidSTACK_Push(PortStack*stack,intvalue);
47+
48+
#endif/* COMMON_H_ */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp