Skip to content

Commit b63ef4b

Browse files
authored
Merge pull request #382 from Mytherin/redshift
Automatically turn on text protocol when connecting to redshift
2 parents 50531bf + f36221a commit b63ef4b

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

src/include/postgres_version.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace duckdb {
1414

15-
enum class PostgresInstanceType { UNKNOWN, POSTGRES, AURORA };
15+
enum class PostgresInstanceType { UNKNOWN, POSTGRES, AURORA, REDSHIFT };
1616

1717
struct PostgresVersion {
1818
PostgresVersion() {

src/postgres_connection.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,14 @@ PostgresVersion PostgresConnection::GetPostgresVersion() {
128128
version.type_v = PostgresInstanceType::UNKNOWN;
129129
return version;
130130
}
131-
auto version = PostgresUtils::ExtractPostgresVersion(result->GetString(0, 0));
131+
auto pg_version_string = result->GetString(0, 0);
132+
auto version = PostgresUtils::ExtractPostgresVersion(pg_version_string);
132133
if (result->GetInt64(0, 1) > 0) {
133134
version.type_v = PostgresInstanceType::AURORA;
134135
}
136+
if (StringUtil::Contains(pg_version_string, "Redshift")) {
137+
version.type_v = PostgresInstanceType::REDSHIFT;
138+
}
135139
return version;
136140
}
137141

src/postgres_scanner.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ void PostgresScanFunction::PrepareBind(PostgresVersion version, ClientContext &c
130130
}
131131
bind_data.SetTablePages(approx_num_pages);
132132
bind_data.version = version;
133+
if (version.type_v == PostgresInstanceType::REDSHIFT) {
134+
bind_data.use_text_protocol = true;
135+
}
133136
}
134137

135138
PostgresBindData::PostgresBindData(ClientContext &context) {

0 commit comments

Comments
 (0)