@@ -31,7 +31,7 @@ load_part_relations_hashtable()
3131ListCell * lc ;
3232
3333SPI_connect ();
34- ret = SPI_exec ("SELECT pg_class.relfilenode, pg_attribute.attnum, pg_pathman_rels.parttype "
34+ ret = SPI_exec ("SELECT pg_class.relfilenode, pg_attribute.attnum, pg_pathman_rels.parttype, pg_attribute.atttypid "
3535"FROM pg_pathman_rels "
3636"JOIN pg_class ON pg_class.relname = pg_pathman_rels.relname "
3737"JOIN pg_attribute ON pg_attribute.attname = pg_pathman_rels.attname "
@@ -48,10 +48,12 @@ load_part_relations_hashtable()
4848HeapTuple tuple = tuptable -> vals [i ];
4949
5050int oid = DatumGetObjectId (SPI_getbinval (tuple ,tupdesc ,1 ,& isnull ));
51- prinfo = (PartRelationInfo * )hash_search (relations , (const void * )& oid ,HASH_ENTER ,NULL );
51+ prinfo = (PartRelationInfo * )
52+ hash_search (relations , (const void * )& oid ,HASH_ENTER ,NULL );
5253prinfo -> oid = oid ;
5354prinfo -> attnum = DatumGetInt32 (SPI_getbinval (tuple ,tupdesc ,2 ,& isnull ));
5455prinfo -> parttype = DatumGetInt32 (SPI_getbinval (tuple ,tupdesc ,3 ,& isnull ));
56+ prinfo -> atttype = DatumGetObjectId (SPI_getbinval (tuple ,tupdesc ,4 ,& isnull ));
5557
5658part_oids = lappend_int (part_oids ,oid );
5759
@@ -204,14 +206,16 @@ load_range_restrictions(Oid parent_oid)
204206
205207// SPI_connect();
206208ret = SPI_execute_with_args ("SELECT p.relfilenode, c.relfilenode, "
207- "rr.min_int, rr.max_int, "
208- "rr.min_dt - '1 microsecond'::INTERVAL, "
209- "rr.max_dt - '1 microsecond'::INTERVAL "
209+ "rr.min_num, rr.max_num, "
210+ "rr.min_dt, "
211+ "rr.max_dt - '1 microsecond'::INTERVAL, "
212+ "rr.min_dt::DATE, "
213+ "(rr.max_dt - '1 day'::INTERVAL)::DATE "
210214"FROM pg_pathman_range_rels rr "
211215"JOIN pg_class p ON p.relname = rr.parent "
212216"JOIN pg_class c ON c.relname = rr.child "
213217"WHERE p.relfilenode = $1 "
214- "ORDER BY rr.parent, rr.min_int , rr.min_dt" ,
218+ "ORDER BY rr.parent, rr.min_num , rr.min_dt" ,
2152191 ,oids ,vals ,nulls , true,0 );
216220proc = SPI_processed ;
217221
@@ -250,19 +254,35 @@ load_range_restrictions(Oid parent_oid)
250254// break;
251255// }
252256
253- re .min = SPI_getbinval (tuple ,tupdesc ,3 ,& arg1_isnull );
254- re .max = SPI_getbinval (tuple ,tupdesc ,4 ,& arg2_isnull );
255- prel -> atttype = AT_INT ;
256-
257- if (arg1_isnull || arg2_isnull )
257+ switch (prel -> atttype )
258258{
259- re .min = SPI_getbinval (tuple ,tupdesc ,5 ,& arg1_isnull );
260- re .max = SPI_getbinval (tuple ,tupdesc ,6 ,& arg2_isnull );
261- prel -> atttype = AT_DATE ;
262-
263- if (arg1_isnull || arg2_isnull )
264- ereport (ERROR , (errmsg ("Range relation should be of type either INTEGER or DATE" )));
259+ case DATEOID :
260+ re .min = SPI_getbinval (tuple ,tupdesc ,7 ,& arg1_isnull );
261+ re .max = SPI_getbinval (tuple ,tupdesc ,8 ,& arg2_isnull );
262+ break ;
263+ case TIMESTAMPOID :
264+ re .min = SPI_getbinval (tuple ,tupdesc ,5 ,& arg1_isnull );
265+ re .max = SPI_getbinval (tuple ,tupdesc ,6 ,& arg2_isnull );
266+ break ;
267+ default :
268+ re .min = SPI_getbinval (tuple ,tupdesc ,3 ,& arg1_isnull );
269+ re .max = SPI_getbinval (tuple ,tupdesc ,4 ,& arg2_isnull );
270+ break ;
265271}
272+
273+ // re.min = SPI_getbinval(tuple, tupdesc, 3, &arg1_isnull);
274+ // re.max = SPI_getbinval(tuple, tupdesc, 4, &arg2_isnull);
275+ // // prel->atttype = AT_INT;
276+
277+ // if (arg1_isnull || arg2_isnull)
278+ // {
279+ // re.min = SPI_getbinval(tuple, tupdesc, 5, &arg1_isnull);
280+ // re.max = SPI_getbinval(tuple, tupdesc, 6, &arg2_isnull);
281+ // // prel->atttype = AT_DATE;
282+
283+ // if (arg1_isnull || arg2_isnull)
284+ // ereport(ERROR, (errmsg("Range relation should be of type either INTEGER or DATE")));
285+ // }
266286rangerel -> ranges [rangerel -> nranges ++ ]= re ;
267287
268288prel -> children [prel -> children_count ++ ]= re .child_oid ;