keithf4/pg_partman — pull request #2 by terrorobe (2013-03-20 10:57:41+00:00)
Title: Bandaid schema-qualified table names in time extraction logic

drop_time_partition apparently misbehaves when the tables you want to drop are in your schema searchpath.

I noticed that it wanted to drop all my child tables despite being put on a 3 month retention.

While debugging I got the following output:

```
NOTICE: Dropping partition download_log_p2013w12, 3 mons smaller than 2013-03-20 11:12:56.292812+01 - 0001-01-01 00:00:00 BC + 7 days
```

Digging down this was caused by the following:

```
uldllog=# SELECT inhrelid::regclass FROM pg_catalog.pg_inherits WHERE inhparent::regclass = 'public.download_log'::regclass ORDER BY inhrelid::regclass limit 2;
inhrelid
-----------------------
download_log_p2013w12
download_log_p2013w11
(2 rows)

uldllog=# select 'public.download_log'::regclass;
regclass
--------------
download_log
(1 row)

uldllog=#

uldllog=# select to_timestamp(substring('download_log_p2013w12' from char_length('public.download_log'||'_p')+1), 'IYYY"w"IW');
to_timestamp
---------------------------------
0001-01-01 00:00:00+00:19:32 BC
(1 row)

uldllog=# select to_timestamp(substring('download_log_p2013w12' from char_length('download_log'||'_p')+1), 'IYYY"w"IW');
to_timestamp
------------------------
2013-03-18 00:00:00+01
(1 row)
```

Explicitly selecting the regclass of the supplied parent_table and using that one in the uninherit/drop loop is a bandaid, but I think more robust logic wouldn't hurt in that area.

Plus debug logging as well as a way to explicitly specify child tables (ignoring retention logic) would be great - I can open separate issues for those if need be.