Skip to content
This repository has been archived by the owner on Jul 24, 2021. It is now read-only.

Add option wich specify a schema name for pg tables #4144

Closed
openstreetmap-trac opened this issue Jul 23, 2021 · 9 comments
Closed

Add option wich specify a schema name for pg tables #4144

openstreetmap-trac opened this issue Jul 23, 2021 · 9 comments

Comments

@openstreetmap-trac
Copy link

Reporter: rodolphe[at]quiedeville.org
[Submitted to the original trac issue database at 10.41am, Monday, 12th December 2011]

Hi please found here a patch that add a new option '-g' (better letter wan be choosen) to specify the schema name where to create table instead of 'public'. It's a useful feature in postgres.

@openstreetmap-trac
Copy link
Author

Author: jburgess777[at]googlemail.com
[Added to the original trac issue at 9.58pm, Wednesday, 14th December 2011]

I am not particularly familiar with schemas but I wonder if the same effect could be achieved more easily by just setting search path on each connection:

"SET search_path TO %s,public;", Options->schema

@openstreetmap-trac
Copy link
Author

Author: rodolphe[at]quiedeville.org
[Added to the original trac issue at 10.48pm, Wednesday, 14th December 2011]

Yes it is possible to this way too, you're right.

@openstreetmap-trac
Copy link
Author

Author: rodolphe[at]quiedeville.org
[Added to the original trac issue at 9.17am, Thursday, 15th December 2011]

I look to the code and IMHO it's not really simpliest to set the search_path on each db connection, but if you definitely prefer this solution I can write a new patch in that way. Please let me know.

@openstreetmap-trac
Copy link
Author

Author: rodolphe[at]quiedeville.org
[Added to the original trac issue at 9.52am, Thursday, 15th December 2011]

I found a problem with using search_path, as we use postgis we need to access postgis tables in 'public' schema, so we need to set the searchpath as 'wanted_schema,public'. But if the user is not allowed in 'wanted_schema' all the actions will occurs in 'public' schema. If we use the qualified table name 'wanted_schema.tablename' an error will occurs. I think it's better to have an error than action in non wanted schema.

@openstreetmap-trac
Copy link
Author

Author: Ptigrouick
[Added to the original trac issue at 7.30pm, Wednesday, 1st February 2012]

Hello. Thank you Rodolphe for this new enhancement I need.
I tried to apply this patch on current osm2pgsql subversion revision (27678). I got some errors. I think it's because your patch was developped for a previous revision. After some fixes in "output-pgsql.c", I tested an import in my database, but I saw that 3 tables was not imported in the specified schema, but always in the public one (nodes, ways and rels). 4 other tables was correctly imported.
So I made some changes in file "middle-pgsql.c". As I'm not really a C developer it was a little difficult for me, but I think I succeed. I tested my revised version and it seems to be OK : all 7 tables are imported in the specified schema. Here is my patch. Please test and tell me if it's alright for you.

@openstreetmap-trac
Copy link
Author

Author: Ptigrouick
[Added to the original trac issue at 7.35pm, Wednesday, 1st February 2012]

I think it would be great if this enhancement could be inserted into osm2pgsql svn trunk. Do you know who is the one to ask for this ?

@openstreetmap-trac
Copy link
Author

Author: rodolphe[at]quiedeville.org
[Added to the original trac issue at 9.34pm, Wednesday, 1st February 2012]

I'll test your patch as soon as possible.
Our patch will be inserted if osm2pgsql'dev think it usefull.

@openstreetmap-trac
Copy link
Author

Author: loki2000[at]inbox.ru
[Added to the original trac issue at 1.31pm, Friday, 28th June 2013]

Hello! Could you plz include this patch in some build next time?

@openstreetmap-trac
Copy link
Author

Author: pnorman
[Added to the original trac issue at 10.39am, Tuesday, 3rd January 2017]

Closing in favour of GH issues osm2pgsql-dev/osm2pgsql#173 osm2pgsql-dev/osm2pgsql#279 osm2pgsql-dev/osm2pgsql#619.

Doing this right is harder than expected, see GH issues for details.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant