12
12
13
13
14
14
HTAB * relations = NULL ;
15
- HTAB * hash_restrictions = NULL ;
16
15
HTAB * range_restrictions = NULL ;
17
16
bool initialization_needed = true;
18
17
@@ -26,7 +25,7 @@ static int cmp_range_entries(const void *p1, const void *p2);
26
25
* Initialize hashtables
27
26
*/
28
27
void
29
- init (void )
28
+ load_config (void )
30
29
{
31
30
bool new_segment_created ;
32
31
@@ -127,7 +126,6 @@ load_part_relations_hashtable(bool reinitialize)
127
126
prel -> children_count = 0 ;
128
127
}
129
128
load_check_constraints (oid );
130
- // load_hash_restrictions(oid);
131
129
break ;
132
130
}
133
131
}
@@ -153,93 +151,8 @@ create_part_relations_hashtable()
153
151
// &ctl, HASH_ELEM | HASH_BLOBS);
154
152
}
155
153
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
-
240
154
/*
241
155
* Load and validate constraints
242
- * TODO: make it work for HASH partitioning
243
156
*/
244
157
void
245
158
load_check_constraints (Oid parent_oid )
@@ -340,10 +253,6 @@ load_check_constraints(Oid parent_oid)
340
253
if (!validate_hash_constraint (expr ,prel ,& hash ))
341
254
/* TODO: elog() */
342
255
continue ;
343
-
344
- hashrel = (HashRelation * )
345
- hash_search (hash_restrictions , (void * )& hash ,HASH_ENTER ,& found );
346
- hashrel -> child_oid = con -> conrelid ;
347
256
children [hash ]= con -> conrelid ;
348
257
}
349
258
}
@@ -521,7 +430,6 @@ remove_relation_info(Oid relid)
521
430
{
522
431
key .parent_oid = relid ;
523
432
key .hash = i ;
524
- hash_search (hash_restrictions , (const void * )& key ,HASH_REMOVE ,0 );
525
433
}
526
434
free_dsm_array (& prel -> children );
527
435
break ;