@@ -48,7 +48,7 @@ static std::string build_sql(options_t const &options, char const *templ)
4848 templ, fmt::arg (" prefix" , options.prefix ),
4949 fmt::arg (" schema" , options.middle_dbschema .empty ()
5050 ? " "
51- : (options.middle_dbschema + " ." )),
51+ : (" \" " + options.middle_dbschema + " \ " ." )),
5252 fmt::arg (" unlogged" , options.droptemp ? " UNLOGGED" : " " ),
5353 fmt::arg (" using_tablespace" , using_tablespace),
5454 fmt::arg (" data_tablespace" , tablespace_clause (options.tblsslim_data )),
@@ -654,15 +654,17 @@ static table_sql sql_for_nodes(bool create_table) noexcept
654654 sql.name = " {prefix}_nodes" ;
655655
656656 if (create_table) {
657- sql.create_table = " CREATE {unlogged} TABLE {schema}{prefix}_nodes ("
658- " id int8 PRIMARY KEY {using_tablespace},"
659- " lat int4 NOT NULL,"
660- " lon int4 NOT NULL"
661- " ) {data_tablespace};\n " ;
657+ sql.create_table =
658+ " CREATE {unlogged} TABLE {schema}\" {prefix}_nodes\" ("
659+ " id int8 PRIMARY KEY {using_tablespace},"
660+ " lat int4 NOT NULL,"
661+ " lon int4 NOT NULL"
662+ " ) {data_tablespace};\n " ;
662663
663- sql.prepare_query = " PREPARE get_node_list(int8[]) AS"
664- " SELECT id, lon, lat FROM {schema}{prefix}_nodes"
665- " WHERE id = ANY($1::int8[]);\n " ;
664+ sql.prepare_query =
665+ " PREPARE get_node_list(int8[]) AS"
666+ " SELECT id, lon, lat FROM {schema}\" {prefix}_nodes\" "
667+ " WHERE id = ANY($1::int8[]);\n " ;
666668 }
667669
668670 return sql;
@@ -675,48 +677,49 @@ static table_sql sql_for_ways(bool has_bucket_index,
675677
676678 sql.name = " {prefix}_ways" ;
677679
678- sql.create_table = " CREATE {unlogged} TABLE {schema}{prefix}_ways ("
680+ sql.create_table = " CREATE {unlogged} TABLE {schema}\" {prefix}_ways\" ("
679681 " id int8 PRIMARY KEY {using_tablespace},"
680682 " nodes int8[] NOT NULL,"
681683 " tags text[]"
682684 " ) {data_tablespace};\n " ;
683685
684686 sql.prepare_query = " PREPARE get_way(int8) AS"
685687 " SELECT nodes, tags"
686- " FROM {schema}{prefix}_ways WHERE id = $1;\n "
688+ " FROM {schema}\" {prefix}_ways\" WHERE id = $1;\n "
687689 " PREPARE get_way_list(int8[]) AS"
688690 " SELECT id, nodes, tags"
689- " FROM {schema}{prefix}_ways"
691+ " FROM {schema}\" {prefix}_ways\" "
690692 " WHERE id = ANY($1::int8[]);\n " ;
691693
692694 if (has_bucket_index) {
693695 sql.prepare_fw_dep_lookups =
694696 " PREPARE mark_ways_by_node(int8) AS"
695- " SELECT id FROM {schema}{prefix}_ways w"
697+ " SELECT id FROM {schema}\" {prefix}_ways\" w"
696698 " WHERE $1 = ANY(nodes)"
697- " AND {schema}{prefix}_index_bucket(w.nodes)"
698- " && {schema}{prefix}_index_bucket(ARRAY[$1]);\n " ;
699+ " AND {schema}\" {prefix}_index_bucket\" (w.nodes)"
700+ " && {schema}\" {prefix}_index_bucket\" (ARRAY[$1]);\n " ;
699701 } else {
700- sql.prepare_fw_dep_lookups = " PREPARE mark_ways_by_node(int8) AS"
701- " SELECT id FROM {schema}{prefix}_ways"
702- " WHERE nodes && ARRAY[$1];\n " ;
702+ sql.prepare_fw_dep_lookups =
703+ " PREPARE mark_ways_by_node(int8) AS"
704+ " SELECT id FROM {schema}\" {prefix}_ways\" "
705+ " WHERE nodes && ARRAY[$1];\n " ;
703706 }
704707
705708 if (way_node_index_id_shift == 0 ) {
706709 sql.create_fw_dep_indexes =
707- " CREATE INDEX ON {schema}{prefix}_ways USING GIN (nodes)"
710+ " CREATE INDEX ON {schema}\" {prefix}_ways\" USING GIN (nodes)"
708711 " WITH (fastupdate = off) {index_tablespace};\n " ;
709712 } else {
710713 sql.create_fw_dep_indexes =
711714 " CREATE OR REPLACE FUNCTION"
712- " {schema}{prefix}_index_bucket(int8[])"
715+ " {schema}\" {prefix}_index_bucket\" (int8[])"
713716 " RETURNS int8[] AS $$\n "
714717 " SELECT ARRAY(SELECT DISTINCT"
715718 " unnest($1) >> {way_node_index_id_shift})\n "
716719 " $$ LANGUAGE SQL IMMUTABLE;\n "
717- " CREATE INDEX {schema}{prefix}_ways_nodes_bucket_idx"
718- " ON {schema}{prefix}_ways"
719- " USING GIN ({schema}{prefix}_index_bucket(nodes))"
720+ " CREATE INDEX {schema}\" {prefix}_ways_nodes_bucket_idx\" "
721+ " ON {schema}\" {prefix}_ways\" "
722+ " USING GIN ({schema}\" {prefix}_index_bucket\" (nodes))"
720723 " WITH (fastupdate = off) {index_tablespace};\n " ;
721724 }
722725
@@ -729,7 +732,7 @@ static table_sql sql_for_relations() noexcept
729732
730733 sql.name = " {prefix}_rels" ;
731734
732- sql.create_table = " CREATE {unlogged} TABLE {schema}{prefix}_rels ("
735+ sql.create_table = " CREATE {unlogged} TABLE {schema}\" {prefix}_rels\" ("
733736 " id int8 PRIMARY KEY {using_tablespace},"
734737 " way_off int2,"
735738 " rel_off int2,"
@@ -740,20 +743,20 @@ static table_sql sql_for_relations() noexcept
740743
741744 sql.prepare_query = " PREPARE get_rel(int8) AS"
742745 " SELECT members, tags"
743- " FROM {schema}{prefix}_rels WHERE id = $1;\n " ;
746+ " FROM {schema}\" {prefix}_rels\" WHERE id = $1;\n " ;
744747
745748 sql.prepare_fw_dep_lookups =
746749 " PREPARE mark_rels_by_node(int8) AS"
747- " SELECT id FROM {schema}{prefix}_rels"
750+ " SELECT id FROM {schema}\" {prefix}_rels\" "
748751 " WHERE parts && ARRAY[$1]"
749752 " AND parts[1:way_off] && ARRAY[$1];\n "
750753 " PREPARE mark_rels_by_way(int8) AS"
751- " SELECT id FROM {schema}{prefix}_rels"
754+ " SELECT id FROM {schema}\" {prefix}_rels\" "
752755 " WHERE parts && ARRAY[$1]"
753756 " AND parts[way_off+1:rel_off] && ARRAY[$1];\n " ;
754757
755758 sql.create_fw_dep_indexes =
756- " CREATE INDEX ON {schema}{prefix}_rels USING GIN (parts)"
759+ " CREATE INDEX ON {schema}\" {prefix}_rels\" USING GIN (parts)"
757760 " WITH (fastupdate = off) {index_tablespace};\n " ;
758761
759762 return sql;
0 commit comments