Advertisement
AntonyZhilin

Untitled

Oct 22nd, 2024
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 5.43 KB | None | 0 0
  1. Subject: [PATCH] Fix
  2. ---
  3. Index: taxi/uservices/userver/postgresql/CMakeLists.txt
  4. IDEA additional info:
  5. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  6. <+>UTF-8
  7. ===================================================================
  8. diff --git a/taxi/uservices/userver/postgresql/CMakeLists.txt b/taxi/uservices/userver/postgresql/CMakeLists.txt
  9. --- a/taxi/uservices/userver/postgresql/CMakeLists.txt  (revision 7c1f5b52dd11d9b210f926f53a69b38f49ee7c28)
  10. +++ b/taxi/uservices/userver/postgresql/CMakeLists.txt  (date 1729615441863)
  11. @@ -18,6 +18,20 @@
  12.    target_link_libraries(userver-libpq INTERFACE PostgreSQL::PostgreSQL)
  13.  endif()
  14.  
  15. +add_executable(userver-impl-libpq-version-generator
  16. +    "${CMAKE_CURRENT_SOURCE_DIR}/libpq-version-generator/main.cpp"
  17. +)
  18. +target_link_libraries(userver-impl-libpq-version-generator PRIVATE userver-libpq)
  19. +
  20. +set(LIBPQ_VERSION_DIR "${CMAKE_CURRENT_BINARY_DIR}/libpq_version")
  21. +add_custom_command(
  22. +    OUTPUT "${LIBPQ_VERSION_DIR}/userver_libpq_version.hpp"
  23. +    COMMAND "${CMAKE_COMMAND}" -E make_directory "${LIBPQ_VERSION_DIR}"
  24. +    COMMAND $<TARGET_FILE:userver-impl-libpq-version-generator>
  25. +    WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
  26. +    COMMENT "Running gRPC C++ protocol buffer compiler for ${root_path}"
  27. +)
  28. +
  29.  file(GLOB_RECURSE SOURCES
  30.    ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
  31.    ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp)
  32. @@ -45,12 +59,16 @@
  33.  
  34.  add_library(${PROJECT_NAME} STATIC ${SOURCES})
  35.  
  36. +target_sources(${PROJECT_NAME} PRIVATE "${LIBPQ_VERSION_DIR}/userver_libpq_version.hpp")
  37. +
  38.  set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX)
  39.  
  40. -target_include_directories(${PROJECT_NAME} PUBLIC
  41. -   $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  42. -  PRIVATE
  43. -  ${CMAKE_CURRENT_SOURCE_DIR}/src
  44. +target_include_directories(${PROJECT_NAME}
  45. +    PUBLIC
  46. +    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  47. +    PRIVATE
  48. +    "${CMAKE_CURRENT_SOURCE_DIR}/src"
  49. +    "${LIBPQ_VERSION_DIR}"
  50.  )
  51.  
  52.  target_link_libraries(${PROJECT_NAME}
  53. Index: taxi/uservices/userver/postgresql/libpq-version-generator/main.cpp
  54. IDEA additional info:
  55. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  56. <+>UTF-8
  57. ===================================================================
  58. diff --git a/taxi/uservices/userver/postgresql/libpq-version-generator/main.cpp b/taxi/uservices/userver/postgresql/libpq-version-generator/main.cpp
  59. new file mode 100644
  60. --- /dev/null   (date 1729614771483)
  61. +++ b/taxi/uservices/userver/postgresql/libpq-version-generator/main.cpp    (date 1729614771483)
  62. @@ -0,0 +1,10 @@
  63. +#include <fstream>
  64. +
  65. +#include <libpq-fe.h>
  66. +
  67. +int main() {
  68. +    const int version = PQlibVersion();
  69. +    std::ofstream out("libpq_version/userver_libpq_version.hpp", std::ios::out | std::ios::trunc);
  70. +    out << "#pragma once\n" << "\n" << "#define USERVER_LIBPQ_VERSION " << version << "\n";
  71. +    return 0;
  72. +}
  73. Index: taxi/uservices/userver/postgresql/src/storages/postgres/detail/pg_connection_wrapper.cpp
  74. IDEA additional info:
  75. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  76. <+>UTF-8
  77. ===================================================================
  78. diff --git a/taxi/uservices/userver/postgresql/src/storages/postgres/detail/pg_connection_wrapper.cpp b/taxi/uservices/userver/postgresql/src/storages/postgres/detail/pg_connection_wrapper.cpp
  79. --- a/taxi/uservices/userver/postgresql/src/storages/postgres/detail/pg_connection_wrapper.cpp  (revision 7c1f5b52dd11d9b210f926f53a69b38f49ee7c28)
  80. +++ b/taxi/uservices/userver/postgresql/src/storages/postgres/detail/pg_connection_wrapper.cpp  (date 1729615521379)
  81. @@ -14,6 +14,11 @@
  82.  }
  83.  #endif
  84.  
  85. +// Generated header with
  86. +// #define USERVER_LIBPQ_VERSION AABBCC
  87. +// (two decimal digits per major, minor, patch versions)
  88. +#include <userver_libpq_version.hpp>
  89. +
  90.  #include <userver/concurrent/background_task_storage.hpp>
  91.  #include <userver/crypto/openssl.hpp>
  92.  #include <userver/engine/task/cancel.hpp>
  93. @@ -84,15 +89,15 @@
  94.              return "PQstatus: Consuming remaining response messages on connection";
  95.          case CONNECTION_GSS_STARTUP:
  96.              return "PQstatus: Negotiating GSSAPI";
  97. -#if PG_VERSION_NUM >= 130000
  98. +#if USERVER_LIBPQ_VERSION >= 130000
  99.          case CONNECTION_CHECK_TARGET:
  100.              return "PQstatus: Checking target server properties";
  101.  #endif
  102. -#if PG_VERSION_NUM >= 140000
  103. +#if USERVER_LIBPQ_VERSION >= 140000
  104.          case CONNECTION_CHECK_STANDBY:
  105.              return "PQstatus: Checking if server is in standby mode";
  106.  #endif
  107. -#if PG_VERSION_NUM >= 170000
  108. +#if USERVER_LIBPQ_VERSION >= 170000
  109.          case CONNECTION_ALLOCATED:
  110.              return "PQstatus: Waiting for connection attempt to be started";
  111.  #endif
  112. @@ -704,7 +709,7 @@
  113.              msg.ThrowException();
  114.              break;
  115.          }
  116. -#if PG_VERSION_NUM >= 140000
  117. +#if USERVER_LIBPQ_VERSION >= 140000
  118.          case PGRES_PIPELINE_ABORTED:
  119.              PGCW_LOG_LIMITED_WARNING() << "Command failure in a pipeline";
  120.              CloseWithError(ConnectionError{"Command failure in a pipeline"});
  121. @@ -713,7 +718,7 @@
  122.              PGCW_LOG_TRACE() << "Successful completion of all commands in a pipeline";
  123.              break;
  124.  #endif
  125. -#if PG_VERSION_NUM >= 170000
  126. +#if USERVER_LIBPQ_VERSION >= 170000
  127.          case PGRES_TUPLES_CHUNK:
  128.              PGCW_LOG_LIMITED_WARNING() << "Got a chunk of tuples from the larger resultset";
  129.              CloseWithError(ConnectionError{"Got a chunk of tuples from the larger resultset"});
  130.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement