Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using connection string schema when working with metadata. #1156

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
83a46f8
Adding possiblity for database backends to register the schema to use…
cstiborg Jul 22, 2024
62224ad
Following coding standard
cstiborg Jul 23, 2024
e50e135
MySQL uses the word "int" for integer types
cstiborg Aug 2, 2024
bca17c1
Adding functionality for MySQL and PostgreSQL to use schemas in the m…
cstiborg Aug 6, 2024
e0efa58
Updating tests for metadata
cstiborg Aug 6, 2024
3d8a719
Adding a bit of debug info to figure out how the postgresql version w…
cstiborg Aug 6, 2024
5f42362
Always collect schema from DB for metadata
cstiborg Aug 11, 2024
09955e6
Ignore schema for tests
cstiborg Aug 11, 2024
97e9cbe
Handling memory leak
cstiborg Aug 11, 2024
dce77e3
Merge branch 'master' into master
cstiborg Aug 11, 2024
82e317e
Handling both cases in prepare_column_descriptions: With and without …
cstiborg Aug 12, 2024
f5e0cc7
Merge branch 'master' of github.com:cstiborg/soci
cstiborg Aug 12, 2024
5075c50
Remove unused header
cstiborg Aug 12, 2024
9ff2fc0
Adding support for bigint and double types
cstiborg Aug 12, 2024
bd9e7ce
Using predefined BOOST definition to handle compilation on multiple p…
cstiborg Aug 16, 2024
01e1ce5
Handling memory leak
cstiborg Aug 16, 2024
cbd81a4
Using correct type
cstiborg Aug 16, 2024
7af75a4
Implementing SOCI_FALLTHROUGH for multiple platforms
cstiborg Aug 18, 2024
3d0265a
Merge pull request #2 from SOCI/master
cstiborg Aug 20, 2024
a991b16
Update src/backends/postgresql/session.cpp
cstiborg Aug 24, 2024
a868fa9
Resolving comments
cstiborg Aug 25, 2024
02cd976
Resolve conflict
cstiborg Aug 25, 2024
2df0434
Adding MSVC support for fallthrough
cstiborg Aug 25, 2024
bb1b16f
Update src/backends/postgresql/session.cpp
cstiborg Aug 25, 2024
fca8d97
Update src/backends/postgresql/session.cpp
cstiborg Aug 25, 2024
04300dc
Update include/soci/session.h
cstiborg Aug 25, 2024
23a70d0
Update src/backends/postgresql/session.cpp
cstiborg Aug 25, 2024
90afe84
Update include/private/soci-compiler.h
cstiborg Aug 25, 2024
6606faa
Merge branch 'master' into master
cstiborg Aug 25, 2024
ac5ee7b
Removing usage of heap operations, new and delete
cstiborg Aug 26, 2024
c60f4f2
Adding paragraph on how to use schema with table
cstiborg Aug 26, 2024
10cd4ab
Adding new tests for metadata
cstiborg Aug 26, 2024
c568656
Removing nullable test, which is irrelevant (and apparently gives dif…
cstiborg Aug 26, 2024
6e3b5e6
Debug for test on Windows
cstiborg Aug 27, 2024
aa2526a
Using case insensitive checks for table and column names in metadata …
cstiborg Aug 27, 2024
afcd127
Redesigning test for MySQL to discover information_schema.tables first
cstiborg Aug 27, 2024
34b194a
Printing more debug info
cstiborg Aug 27, 2024
03705a5
Attemting more debug output
cstiborg Aug 27, 2024
f8fd4bd
Only table names output may be upper- or lowercase
cstiborg Aug 27, 2024
e3f6dfd
Ignoring case on MySQL metadata column info query
cstiborg Aug 27, 2024
895f20e
Update src/backends/postgresql/session.cpp
cstiborg Sep 1, 2024
400c716
Remove duplicate code
cstiborg Sep 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions include/soci/soci-backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ class blob_backend
class session_backend
{
public:
session_backend() : failoverCallback_(NULL), session_(NULL) {}
session_backend() : failoverCallback_(NULL), session_(NULL), schema_name_("public") {}
virtual ~session_backend() {}

virtual bool is_connected() = 0;
Expand Down Expand Up @@ -366,7 +366,7 @@ class session_backend
{
return "select table_name as \"TABLE_NAME\""
" from information_schema.tables"
" where table_schema = 'public'";
" where table_schema = '" + schema_name_ + "'";
cstiborg marked this conversation as resolved.
Show resolved Hide resolved
}

// Returns a query with a single parameter (table name) for the list
Expand All @@ -380,7 +380,7 @@ class session_backend
" numeric_scale as \"NUMERIC_SCALE\","
" is_nullable as \"IS_NULLABLE\""
" from information_schema.columns"
" where table_schema = 'public' and table_name = :t";
" where table_schema = '" + schema_name_ + "' and table_name = :t";
}

virtual std::string create_table(const std::string & tableName)
Expand Down Expand Up @@ -565,6 +565,7 @@ class session_backend

failover_callback * failoverCallback_;
session * session_;
std::string schema_name_;

private:
SOCI_NOT_COPYABLE(session_backend)
Expand Down
1 change: 1 addition & 0 deletions src/backends/mysql/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ mysql_session_backend::mysql_session_backend(
clean_up();
throw mysql_soci_error(errMsg, errNum);
}
schema_name_ = db;
}

#if defined(__GNUC__) && ( __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ > 6)))
Expand Down
10 changes: 10 additions & 0 deletions src/backends/postgresql/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ void postgresql_session_backend::connect(
: "SET extra_float_digits = 2",
"Cannot set extra_float_digits parameter");

PGresult* res = PQexec(conn, "SHOW search_path");
if (PQresultStatus(res) == PGRES_TUPLES_OK)
{
if (PQntuples(res) > 0)
{
schema_name_ = PQgetvalue(res, 0, 0);
cstiborg marked this conversation as resolved.
Show resolved Hide resolved
}
}
PQclear(res);

conn_ = conn;
connectionParameters_ = parameters;
}
Expand Down
Loading