On 8 July 2013 12:46, Bernd Helmle <mailings@oopsware.de> wrote:
> Recently i got annoyed that psql doesn't tab complete to updatable foreign
> tables.
>
> Attached is a patch to address this. I'm using the new
> pg_relation_is_updatable() function to accomplish this. The function could
> also be used for the trigger based stuff in the query, but i haven't touched
> this part of the query. The patch ist against HEAD, but maybe it's worth to
> apply this to REL9_3_STABLE, too, but not sure what our policy is at this
> state...
>
+1
A couple of points though:
* pg_relation_is_updatable is only available in 9.3, whereas psql may
connect to older servers, so it needs to guard against that.
* If we're doing this, I think we should do it for auto-updatable
views at the same time.
There was concern that pg_relation_is_updatable() would end up opening
every relation in the database, hammering performance. I now realise
that these tab-complete queries have a limit (1000 by default) so I
don't think this is such an issue. I tested it by creating 10,000
randomly named auto-updatable views on top of a table, and didn't see
any performance problems.
Here's an updated patch based on the above points.
Regards,
Dean