Add schema support to PG driver in ogr2ogr
|Reported by:||Owned by:||Mateusz Łoskot|
|Cc:||Markus Neteler, horst.duester@…|
Description (last modified by )
Schemas in PostgreSQL are seperate namespaces with permissions per namespace (create or usage) and there's a 'search_path' variable that lists out the schemas to be searched for when no specific schema is given.
It's a lot like Oracle accounts except you don't actually have to have an account to have a schema, which is *very* nice. Generally each real user has his/her own schema though, except for role accounts which just use other schemas.
Schemas are tracked in Postgres via the pg_namespace system table.
Login as user sfrost; default search_path is '$user,public'. Now, there exists a 'sfrost' schema, so that's what I'm looking at when I first log in and do \d. I only see things in the 'sfrost' schema and the 'public' schema though. Now, say there's another schema called 'lerg', I can reference that schema directly by saying:
select * from lerg.table;
Assuming I have 'usage' rights on the schema 'lerg' and select rights on the table 'lerg.table'.
Now, what happened when I ran ogr2ogr was that it dumped the new tables into 'sfrost', my default schema. What I'd like to have happen is for the tables to be loaded into their own schema. I wouldn't expect ogr2ogr to actually create the schema, that's generally an operation reserved for the database superuser.
What I'd like is the ability to tell ogr2ogr what schema to use. Having support directly in ogr2ogr would mean that you could then specify a list of schemas to search for layers, instead of tables, which would make things easier both from an ogr2ogr point of view and from a user's point of view, I'd think.
Additionally, it doesn't appear possible to specify a schema to use in the PGconnectdb string.
From what I can tell ogr2ogr just needs to issue a 'set schema_path to %s' command where the %s is provided on the command-line to get basic schema support.