Opened 8 years ago

Closed 3 years ago

#4144 closed enhancement (duplicate)

Add option wich specify a schema name for pg tables

Reported by: Rodolphe Quiédeville Owned by: jburgess777@…
Priority: minor Milestone:
Component: osm2pgsql Version:
Keywords: Cc:

Description

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.

Attachments (2)

schema.patch (12.1 KB) - added by Rodolphe Quiédeville 8 years ago.
patch made with svn diff
schema.2.patch (31.4 KB) - added by Ptigrouick 7 years ago.
patch made with svn diff

Download all attachments as: .zip

Change History (11)

Changed 8 years ago by Rodolphe Quiédeville

Attachment: schema.patch added

patch made with svn diff

comment:1 Changed 8 years ago by jburgess777@…

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

comment:2 Changed 8 years ago by Rodolphe Quiédeville

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

comment:3 Changed 8 years ago by Rodolphe Quiédeville

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.

comment:4 Changed 8 years ago by Rodolphe Quiédeville

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.

Changed 7 years ago by Ptigrouick

Attachment: schema.2.patch added

patch made with svn diff

comment:5 Changed 7 years ago by Ptigrouick

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.

comment:6 Changed 7 years ago by Ptigrouick

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 ?

comment:7 Changed 7 years ago by Rodolphe Quiédeville

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

comment:8 Changed 6 years ago by loki2000@…

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

comment:9 Changed 3 years ago by pnorman

Resolution: duplicate
Status: newclosed
Note: See TracTickets for help on using tickets.