WillAyd commented on code in PR #2219:
URL: https://github.com/apache/arrow-adbc/pull/2219#discussion_r1822860652


##########
c/driver/postgresql/connection.cc:
##########
@@ -478,19 +479,35 @@ AdbcStatusCode PostgresConnection::GetInfo(struct 
AdbcConnection* connection,
   for (size_t i = 0; i < info_codes_length; i++) {
     switch (info_codes[i]) {
       case ADBC_INFO_VENDOR_NAME:
-        infos.push_back({info_codes[i], "PostgreSQL"});
+        if (RedshiftVersion()[0] > 0) {
+          infos.emplace_back(info_codes[i], "Redshift");
+        } else {
+          infos.push_back({info_codes[i], "PostgreSQL"});
+        }
+
         break;
       case ADBC_INFO_VENDOR_VERSION: {
-        const char* stmt = "SHOW server_version_num";
-        auto result_helper = PqResultHelper{conn_, std::string(stmt)};
-        RAISE_STATUS(error, result_helper.Execute());
-        auto it = result_helper.begin();
-        if (it == result_helper.end()) {
-          SetError(error, "[libpq] PostgreSQL returned no rows for '%s'", 
stmt);
-          return ADBC_STATUS_INTERNAL;
+        if (RedshiftVersion()[0] > 0) {
+          std::array<int, 3> version = RedshiftVersion();
+          std::string version_string = std::to_string(version[0]) + "." +
+                                       std::to_string(version[1]) + "." +
+                                       std::to_string(version[2]);
+          infos.emplace_back(info_codes[i], std::move(version_string));
+
+        } else {
+          // Gives a version in the form 140000 instead of 14.0.0
+          const char* stmt = "SHOW server_version_num";
+          auto result_helper = PqResultHelper{conn_, std::string(stmt)};
+          RAISE_STATUS(error, result_helper.Execute());
+          auto it = result_helper.begin();
+          if (it == result_helper.end()) {
+            SetError(error, "[libpq] PostgreSQL returned no rows for '%s'", 
stmt);
+            return ADBC_STATUS_INTERNAL;
+          }
+          const char* server_version_num = (*it)[0].data;
+          infos.push_back({info_codes[i], server_version_num});

Review Comment:
   Here's another spot



##########
c/driver/postgresql/connection.cc:
##########
@@ -478,19 +479,35 @@ AdbcStatusCode PostgresConnection::GetInfo(struct 
AdbcConnection* connection,
   for (size_t i = 0; i < info_codes_length; i++) {
     switch (info_codes[i]) {
       case ADBC_INFO_VENDOR_NAME:
-        infos.push_back({info_codes[i], "PostgreSQL"});
+        if (RedshiftVersion()[0] > 0) {
+          infos.emplace_back(info_codes[i], "Redshift");
+        } else {
+          infos.push_back({info_codes[i], "PostgreSQL"});

Review Comment:
   I should have been clearer but all of the push_back's here I think are 
better with emplace_back



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to