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

Commitaf586f4

Browse files
committed
pathman:
* some cleanup
1 parent8c34e54 commitaf586f4

File tree

4 files changed

+242
-102
lines changed

4 files changed

+242
-102
lines changed

‎contrib/pathman/init.c

Lines changed: 1 addition & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313

1414
HTAB*relations=NULL;
15-
HTAB*hash_restrictions=NULL;
1615
HTAB*range_restrictions=NULL;
1716
boolinitialization_needed= true;
1817

@@ -26,7 +25,7 @@ static int cmp_range_entries(const void *p1, const void *p2);
2625
* Initialize hashtables
2726
*/
2827
void
29-
init(void)
28+
load_config(void)
3029
{
3130
boolnew_segment_created;
3231

@@ -127,7 +126,6 @@ load_part_relations_hashtable(bool reinitialize)
127126
prel->children_count=0;
128127
}
129128
load_check_constraints(oid);
130-
// load_hash_restrictions(oid);
131129
break;
132130
}
133131
}
@@ -153,93 +151,8 @@ create_part_relations_hashtable()
153151
// &ctl, HASH_ELEM | HASH_BLOBS);
154152
}
155153

156-
void
157-
load_hash_restrictions(Oidparent_oid)
158-
{
159-
boolfound;
160-
PartRelationInfo*prel;
161-
HashRelation*hashrel;
162-
HashRelationKeykey;
163-
intret;
164-
inti;
165-
intproc;
166-
boolisnull;
167-
168-
Datumvals[1];
169-
Oidoids[1]= {INT4OID};
170-
boolnulls[1]= {false};
171-
vals[0]=Int32GetDatum(parent_oid);
172-
173-
prel= (PartRelationInfo*)
174-
hash_search(relations, (constvoid*)&parent_oid,HASH_FIND,&found);
175-
176-
/* if already loaded then quit */
177-
if (prel->children_count>0)
178-
return;
179-
180-
ret=SPI_execute_with_args("SELECT p.relfilenode, hr.hash, c.relfilenode "
181-
"FROM pg_pathman_hash_rels hr "
182-
"JOIN pg_class p ON p.relname = hr.parent "
183-
"JOIN pg_class c ON c.relname = hr.child "
184-
"WHERE p.relfilenode = $1",
185-
1,oids,vals,nulls, true,0);
186-
proc=SPI_processed;
187-
188-
if (ret>0&&SPI_tuptable!=NULL)
189-
{
190-
TupleDesctupdesc=SPI_tuptable->tupdesc;
191-
SPITupleTable*tuptable=SPI_tuptable;
192-
Oid*children;
193-
194-
/* allocate an array of children Oids */
195-
alloc_dsm_array(&prel->children,sizeof(Oid),proc);
196-
children= (Oid*)dsm_array_get_pointer(&prel->children);
197-
198-
for (i=0;i<proc;i++)
199-
{
200-
HeapTupletuple=tuptable->vals[i];
201-
intchild_oid=DatumGetObjectId(SPI_getbinval(tuple,tupdesc,3,&isnull));
202-
203-
key.parent_oid=DatumGetObjectId(SPI_getbinval(tuple,tupdesc,1,&isnull));
204-
key.hash=DatumGetInt32(SPI_getbinval(tuple,tupdesc,2,&isnull));
205-
206-
hashrel= (HashRelation*)
207-
hash_search(hash_restrictions, (void*)&key,HASH_ENTER,&found);
208-
hashrel->child_oid=child_oid;
209-
210-
/* appending children to PartRelationInfo */
211-
// prel->children[prel->children_count++] = child_oid;
212-
children[prel->children_count++]=child_oid;
213-
}
214-
}
215-
216-
// SPI_finish();
217-
}
218-
219-
/*
220-
* Create hash restrictions table
221-
*/
222-
void
223-
create_hash_restrictions_hashtable()
224-
{
225-
HASHCTLctl;
226-
227-
memset(&ctl,0,sizeof(ctl));
228-
ctl.keysize=sizeof(HashRelationKey);
229-
ctl.entrysize=sizeof(HashRelation);
230-
231-
/* already exists, recreate */
232-
if (hash_restrictions!=NULL)
233-
hash_destroy(hash_restrictions);
234-
235-
hash_restrictions=ShmemInitHash("pg_pathman hash restrictions",
236-
1024,1024,
237-
&ctl,HASH_ELEM |HASH_BLOBS);
238-
}
239-
240154
/*
241155
* Load and validate constraints
242-
* TODO: make it work for HASH partitioning
243156
*/
244157
void
245158
load_check_constraints(Oidparent_oid)
@@ -340,10 +253,6 @@ load_check_constraints(Oid parent_oid)
340253
if (!validate_hash_constraint(expr,prel,&hash))
341254
/* TODO: elog() */
342255
continue;
343-
344-
hashrel= (HashRelation*)
345-
hash_search(hash_restrictions, (void*)&hash,HASH_ENTER,&found);
346-
hashrel->child_oid=con->conrelid;
347256
children[hash]=con->conrelid;
348257
}
349258
}
@@ -521,7 +430,6 @@ remove_relation_info(Oid relid)
521430
{
522431
key.parent_oid=relid;
523432
key.hash=i;
524-
hash_search(hash_restrictions, (constvoid*)&key,HASH_REMOVE,0);
525433
}
526434
free_dsm_array(&prel->children);
527435
break;

‎contrib/pathman/pathman.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,13 @@ _PG_init(void)
108108
shmem_startup_hook=my_shmem_startup;
109109

110110
planner_hook=my_planner_hook;
111-
/* TEMP */
112-
// get_relation_info_hook = my_get_relation_info;
113111
}
114112

115113
void
116114
_PG_fini(void)
117115
{
118116
set_rel_pathlist_hook=set_rel_pathlist_hook_original;
119117
shmem_startup_hook=shmem_startup_hook_original;
120-
// hash_destroy(relations);
121-
// hash_destroy(hash_restrictions);
122118
}
123119

124120
PlannedStmt*
@@ -127,7 +123,7 @@ my_planner_hook(Query *parse, int cursorOptions, ParamListInfo boundParams)
127123
PlannedStmt*result;
128124

129125
if (initialization_needed)
130-
init();
126+
load_config();
131127

132128
inheritance_disabled= false;
133129
disable_inheritance(parse);
@@ -195,7 +191,6 @@ my_shmem_startup(void)
195191
/* allocate shared memory objects */
196192
alloc_dsm_table();
197193
create_part_relations_hashtable();
198-
create_hash_restrictions_hashtable();
199194
create_range_restrictions_hashtable();
200195

201196
LWLockRelease(AddinShmemInitLock);

‎contrib/pathman/pathman.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,11 @@ HTAB *range_restrictions;
191191
boolinitialization_needed;
192192

193193
/* initialization functions */
194-
voidinit(void);
194+
voidload_config(void);
195195
voidcreate_part_relations_hashtable(void);
196196
voidcreate_hash_restrictions_hashtable(void);
197197
voidcreate_range_restrictions_hashtable(void);
198198
voidload_part_relations_hashtable(boolreinitialize);
199-
voidload_hash_restrictions(Oidrelid);
200-
// void load_range_restrictions(Oid relid);
201199
voidload_check_constraints(Oidparent_oid);
202200
voidremove_relation_info(Oidrelid);
203201

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp