Commit Graph

22 Commits

Author SHA1 Message Date
ede8880e72 Update copyright date 2025-01-13 09:07:30 +01:00
7b6ed0d2bc Use anonymous namespace instead of static in test code
This is recommended in C++ Core Guidelines SF.22
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rs-unnamed2
2024-08-15 22:24:35 +02:00
f07eb240ac Make a variable const (because we can) 2024-04-11 09:57:34 +02:00
6375e05087 Merge pull request #2120 from joto/add-test
Add test to make sure unset pg_result_t behaves sensibly
2024-01-27 10:28:13 +01:00
ff91d49869 Update copyright date 2024-01-26 16:45:53 +01:00
c5ea1d47da Add test to make sure unset pg_result_t behaves sensibly 2024-01-11 14:57:24 +01:00
e59440cad3 Set default schema to 'public' and use qualified names everywhere
Until now the default schema was empty and the PostgreSQL search path
was used to find tables etc.

We now set the default schema for the middle and the pgsql and flex
outputs to 'public'.

This simplifies the code, because we don't have to handle the case
without schema specially any more. More importantly it makes it easier
for the user to reason about what osm2pgsql is doing, because it does
not depend on the setting of the search path in the PostgreSQL session.

This fixes a problem where osm2pgsql could not find the
osm2pgsql_properties table it created itself, because it was created in
a different schema than expected (#2010).

The behaviour of the gazetteer output has not changed. It still uses
unqualified names.

This will be a breaking change for those users who rely on the old
behaviour.

Fixes #2010, #2011.
2023-08-07 15:56:43 +02:00
2d8f654980 Add functionality to send data to PostgreSQL in binary
Prepared statements can now send parameters in binary as well as in the
default text format. To do this, wrap the binary data in an instance of
the binary_param class, which is just a wrapper of std::string_view used
to signal to the exec_prepared() function that this parameter should be
sent in binary.

You can mix and match any number of parameters in text or binary format.

It isn't possible any more to use exec_prepared() without any
parameters, but that wasn't use (and doesn't make much sense anyway), so
no loss there.
2023-02-27 21:45:57 +01:00
0a25dda3a8 Add pgresult_t::affected_rows() function
To get the number of INSERTed, UPDATEd, or DELETEed rows.
2023-02-15 13:52:45 +01:00
399e50ef1d Use C++17 feature constexpr if to simplify pgsql code
Also adds a crucial std::decay_t<> which makes sure this works for all
sorts of types.
2023-01-17 09:45:41 +01:00
7ba523ba37 Update copyright date to 2023 2023-01-15 16:13:42 +01:00
760ee27e9f Remove pg_conn_t::query() function, use pg_conn_t::exec() instead
This removes the pg_conn_t::query() in favour of the pg_conn_t::exec()
function. They mostly did the same thing anyway and it was always
confusing when to use which one and how to set the "expect" parameter.

Now we have exec() and exec_prepared() as the only functions running a
SQL command and returning the results.
2022-12-20 09:28:57 +01:00
0f96f6f666 Replace get_value_as_string() by get() function returning string_view
This way we don't need to initialize a std::string in all cases.
2022-12-12 10:53:39 +01:00
949150219d Consolidate database capability checks
There were several places (pgsql.hpp, pgsql-capabilities.hpp,
db-check.hpp) that had code to check various capabilities, version
numbers etc. of the database we are connected to. This is now
consolidated in pgsql-capabilities.hpp. It needs to be initialized once
at program start by calling init_database_capabilities() with a database
connection object. Checking version numbers or capabilities is then much
easier, because no active database connection is needed any more.

This also adds code to get the list of supported index methods from the
database which we will need shortly. (Only works with PostgreSQL >9.5.)
2022-12-01 15:27:10 +01:00
47fc05e286 Use templates to make writing data to PostgreSQL more generic
This way we don't need to hardwire any types.

Also adds some docs and tests.
2022-03-17 17:48:23 +01:00
56d5145615 Updates copyright date to 2022 in all files 2022-01-11 14:30:34 +01:00
2b50e0604a Various small cleanups found by clang-tidy 2021-05-27 15:59:07 +02:00
cfaa0391d9 Miscellaneous const cleanups 2021-05-27 15:59:07 +02:00
d45018f88b Update copyright year to 2021 2021-01-28 09:38:17 +01:00
61bdfb4bc5 Add/update copyright notice on all C++ files
This adds a copyright notice to all C++ files and the README clarifying
the license. (There is no change of the license.) This also removes a
few names explicitly mentioned as copyright holders, instead refering to
the git log which has a full list of all osm2pgsql developers. (There is
also still the AUTHORS file which names the most important developers.)

The only exception is the sprompt.cpp file which was taken from
PostgreSQL and keeps its original license information (and, of course,
the files in contrib).
2020-12-19 11:25:07 +01:00
9e2b3b0b24 Refactor out common function to get PostGIS version 2020-06-11 18:32:45 +02:00
aa9790df5d Finish schema support in flex output
This completes the schema support for the flex output.

You have to define a schema before using it. osm2pgsql might not have
the needed permissions for creating a schema, so it will not try to
create it.
2020-05-23 19:42:41 +02:00