1212
1313
1414HTAB * relations = NULL ;
15- HTAB * hash_restrictions = NULL ;
1615HTAB * range_restrictions = NULL ;
1716bool initialization_needed = true;
1817
@@ -26,7 +25,7 @@ static int cmp_range_entries(const void *p1, const void *p2);
2625 * Initialize hashtables
2726 */
2827void
29- init (void )
28+ load_config (void )
3029{
3130bool new_segment_created ;
3231
@@ -127,7 +126,6 @@ load_part_relations_hashtable(bool reinitialize)
127126prel -> children_count = 0 ;
128127}
129128load_check_constraints (oid );
130- // load_hash_restrictions(oid);
131129break ;
132130}
133131}
@@ -153,93 +151,8 @@ create_part_relations_hashtable()
153151// &ctl, HASH_ELEM | HASH_BLOBS);
154152}
155153
156- void
157- load_hash_restrictions (Oid parent_oid )
158- {
159- bool found ;
160- PartRelationInfo * prel ;
161- HashRelation * hashrel ;
162- HashRelationKey key ;
163- int ret ;
164- int i ;
165- int proc ;
166- bool isnull ;
167-
168- Datum vals [1 ];
169- Oid oids [1 ]= {INT4OID };
170- bool nulls [1 ]= {false};
171- vals [0 ]= Int32GetDatum (parent_oid );
172-
173- prel = (PartRelationInfo * )
174- hash_search (relations , (const void * )& 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- TupleDesc tupdesc = 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- HeapTuple tuple = tuptable -> vals [i ];
201- int child_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- HASHCTL ctl ;
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 */
244157void
245158load_check_constraints (Oid parent_oid )
@@ -340,10 +253,6 @@ load_check_constraints(Oid parent_oid)
340253if (!validate_hash_constraint (expr ,prel ,& hash ))
341254/* TODO: elog() */
342255continue ;
343-
344- hashrel = (HashRelation * )
345- hash_search (hash_restrictions , (void * )& hash ,HASH_ENTER ,& found );
346- hashrel -> child_oid = con -> conrelid ;
347256children [hash ]= con -> conrelid ;
348257}
349258}
@@ -521,7 +430,6 @@ remove_relation_info(Oid relid)
521430{
522431key .parent_oid = relid ;
523432key .hash = i ;
524- hash_search (hash_restrictions , (const void * )& key ,HASH_REMOVE ,0 );
525433}
526434free_dsm_array (& prel -> children );
527435break ;