yugabytedb-ysql 0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +7 -0
  2. data/.appveyor.yml +42 -0
  3. data/.gems +6 -0
  4. data/.gemtest +0 -0
  5. data/.github/workflows/binary-gems.yml +117 -0
  6. data/.github/workflows/source-gem.yml +143 -0
  7. data/.gitignore +24 -0
  8. data/.hgsigs +34 -0
  9. data/.hgtags +41 -0
  10. data/.irbrc +23 -0
  11. data/.pryrc +23 -0
  12. data/.tm_properties +21 -0
  13. data/.travis.yml +49 -0
  14. data/BSDL +22 -0
  15. data/Contributors.rdoc +46 -0
  16. data/Gemfile +18 -0
  17. data/History.md +901 -0
  18. data/LICENSE +56 -0
  19. data/Manifest.txt +73 -0
  20. data/POSTGRES +23 -0
  21. data/README-OS_X.rdoc +68 -0
  22. data/README-Windows.rdoc +56 -0
  23. data/README.ja.md +302 -0
  24. data/README.md +381 -0
  25. data/Rakefile +118 -0
  26. data/Rakefile.cross +299 -0
  27. data/certs/ged.pem +24 -0
  28. data/certs/kanis@comcard.de.pem +20 -0
  29. data/certs/larskanis-2022.pem +26 -0
  30. data/certs/larskanis-2023.pem +24 -0
  31. data/certs/larskanis-2024.pem +24 -0
  32. data/ext/errorcodes.def +1044 -0
  33. data/ext/errorcodes.rb +45 -0
  34. data/ext/errorcodes.txt +497 -0
  35. data/ext/extconf.rb +174 -0
  36. data/ext/gvl_wrappers.c +21 -0
  37. data/ext/gvl_wrappers.h +264 -0
  38. data/ext/pg.c +692 -0
  39. data/ext/pg.h +392 -0
  40. data/ext/pg_binary_decoder.c +308 -0
  41. data/ext/pg_binary_encoder.c +387 -0
  42. data/ext/pg_coder.c +624 -0
  43. data/ext/pg_connection.c +4681 -0
  44. data/ext/pg_copy_coder.c +917 -0
  45. data/ext/pg_errors.c +95 -0
  46. data/ext/pg_record_coder.c +522 -0
  47. data/ext/pg_result.c +1766 -0
  48. data/ext/pg_text_decoder.c +1005 -0
  49. data/ext/pg_text_encoder.c +827 -0
  50. data/ext/pg_tuple.c +572 -0
  51. data/ext/pg_type_map.c +200 -0
  52. data/ext/pg_type_map_all_strings.c +130 -0
  53. data/ext/pg_type_map_by_class.c +271 -0
  54. data/ext/pg_type_map_by_column.c +355 -0
  55. data/ext/pg_type_map_by_mri_type.c +313 -0
  56. data/ext/pg_type_map_by_oid.c +388 -0
  57. data/ext/pg_type_map_in_ruby.c +333 -0
  58. data/ext/pg_util.c +149 -0
  59. data/ext/pg_util.h +65 -0
  60. data/ext/vc/pg.sln +26 -0
  61. data/ext/vc/pg_18/pg.vcproj +216 -0
  62. data/ext/vc/pg_19/pg_19.vcproj +209 -0
  63. data/lib/pg/basic_type_map_based_on_result.rb +67 -0
  64. data/lib/pg/basic_type_map_for_queries.rb +202 -0
  65. data/lib/pg/basic_type_map_for_results.rb +104 -0
  66. data/lib/pg/basic_type_registry.rb +303 -0
  67. data/lib/pg/binary_decoder/date.rb +9 -0
  68. data/lib/pg/binary_decoder/timestamp.rb +26 -0
  69. data/lib/pg/binary_encoder/timestamp.rb +20 -0
  70. data/lib/pg/coder.rb +106 -0
  71. data/lib/pg/connection.rb +997 -0
  72. data/lib/pg/exceptions.rb +25 -0
  73. data/lib/pg/load_balance_service.rb +406 -0
  74. data/lib/pg/result.rb +43 -0
  75. data/lib/pg/text_decoder/date.rb +18 -0
  76. data/lib/pg/text_decoder/inet.rb +9 -0
  77. data/lib/pg/text_decoder/json.rb +14 -0
  78. data/lib/pg/text_decoder/numeric.rb +9 -0
  79. data/lib/pg/text_decoder/timestamp.rb +30 -0
  80. data/lib/pg/text_encoder/date.rb +12 -0
  81. data/lib/pg/text_encoder/inet.rb +28 -0
  82. data/lib/pg/text_encoder/json.rb +14 -0
  83. data/lib/pg/text_encoder/numeric.rb +9 -0
  84. data/lib/pg/text_encoder/timestamp.rb +24 -0
  85. data/lib/pg/tuple.rb +30 -0
  86. data/lib/pg/type_map_by_column.rb +16 -0
  87. data/lib/pg/version.rb +5 -0
  88. data/lib/ysql.rb +130 -0
  89. data/misc/openssl-pg-segfault.rb +31 -0
  90. data/misc/postgres/History.txt +9 -0
  91. data/misc/postgres/Manifest.txt +5 -0
  92. data/misc/postgres/README.txt +21 -0
  93. data/misc/postgres/Rakefile +21 -0
  94. data/misc/postgres/lib/postgres.rb +16 -0
  95. data/misc/ruby-pg/History.txt +9 -0
  96. data/misc/ruby-pg/Manifest.txt +5 -0
  97. data/misc/ruby-pg/README.txt +21 -0
  98. data/misc/ruby-pg/Rakefile +21 -0
  99. data/misc/ruby-pg/lib/ruby/pg.rb +16 -0
  100. data/rakelib/task_extension.rb +46 -0
  101. data/sample/array_insert.rb +20 -0
  102. data/sample/async_api.rb +102 -0
  103. data/sample/async_copyto.rb +39 -0
  104. data/sample/async_mixed.rb +56 -0
  105. data/sample/check_conn.rb +21 -0
  106. data/sample/copydata.rb +71 -0
  107. data/sample/copyfrom.rb +81 -0
  108. data/sample/copyto.rb +19 -0
  109. data/sample/cursor.rb +21 -0
  110. data/sample/disk_usage_report.rb +177 -0
  111. data/sample/issue-119.rb +94 -0
  112. data/sample/losample.rb +69 -0
  113. data/sample/minimal-testcase.rb +17 -0
  114. data/sample/notify_wait.rb +72 -0
  115. data/sample/pg_statistics.rb +285 -0
  116. data/sample/replication_monitor.rb +222 -0
  117. data/sample/test_binary_values.rb +33 -0
  118. data/sample/wal_shipper.rb +434 -0
  119. data/sample/warehouse_partitions.rb +311 -0
  120. data/yugabytedb-ysql.gemspec +33 -0
  121. metadata +232 -0
data/ext/extconf.rb ADDED
@@ -0,0 +1,174 @@
1
+ require 'pp'
2
+ require 'mkmf'
3
+
4
+
5
+ if ENV['MAINTAINER_MODE']
6
+ $stderr.puts "Maintainer mode enabled."
7
+ $CFLAGS <<
8
+ ' -Wall' <<
9
+ ' -ggdb' <<
10
+ ' -DDEBUG' <<
11
+ ' -pedantic'
12
+ end
13
+
14
+ if pgdir = with_config( 'pg' )
15
+ ENV['PATH'] = "#{pgdir}/bin" + File::PATH_SEPARATOR + ENV['PATH']
16
+ end
17
+
18
+ if enable_config("gvl-unlock", true)
19
+ $defs.push( "-DENABLE_GVL_UNLOCK" )
20
+ $stderr.puts "Calling libpq with GVL unlocked"
21
+ else
22
+ $stderr.puts "Calling libpq with GVL locked"
23
+ end
24
+
25
+ if enable_config("windows-cross")
26
+ # Avoid dependency to external libgcc.dll on x86-mingw32
27
+ $LDFLAGS << " -static-libgcc"
28
+ # Don't use pg_config for cross build, but --with-pg-* path options
29
+ dir_config 'pg'
30
+
31
+ else
32
+ # Native build
33
+
34
+ pgconfig = with_config('pg-config') ||
35
+ with_config('pg_config') ||
36
+ find_executable('pg_config')
37
+
38
+ if pgconfig && pgconfig != 'ignore'
39
+ $stderr.puts "Using config values from %s" % [ pgconfig ]
40
+ incdir = IO.popen([pgconfig, "--includedir"], &:read).chomp
41
+ libdir = IO.popen([pgconfig, "--libdir"], &:read).chomp
42
+ dir_config 'pg', incdir, libdir
43
+
44
+ # Windows traditionally stores DLLs beside executables, not in libdir
45
+ dlldir = RUBY_PLATFORM=~/mingw|mswin/ ? IO.popen([pgconfig, "--bindir"], &:read).chomp : libdir
46
+
47
+ elsif checking_for "libpq per pkg-config" do
48
+ _cflags, ldflags, _libs = pkg_config("libpq")
49
+ dlldir = ldflags && ldflags[/-L([^ ]+)/] && $1
50
+ end
51
+
52
+ else
53
+ incdir, libdir = dir_config 'pg'
54
+ dlldir = libdir
55
+ end
56
+
57
+ # Try to use runtime path linker option, even if RbConfig doesn't know about it.
58
+ # The rpath option is usually set implicit by dir_config(), but so far not
59
+ # on MacOS-X.
60
+ if dlldir && RbConfig::CONFIG["RPATHFLAG"].to_s.empty?
61
+ append_ldflags "-Wl,-rpath,#{dlldir.quote}"
62
+ end
63
+
64
+ if /mswin/ =~ RUBY_PLATFORM
65
+ $libs = append_library($libs, 'ws2_32')
66
+ end
67
+ end
68
+
69
+ $stderr.puts "Using libpq from #{dlldir}"
70
+
71
+ File.write("postgresql_lib_path.rb", <<-EOT)
72
+ module YSQL
73
+ POSTGRESQL_LIB_PATH = #{dlldir.inspect}
74
+ end
75
+ EOT
76
+ $INSTALLFILES = {
77
+ "./postgresql_lib_path.rb" => "$(RUBYLIBDIR)/pg/"
78
+ }
79
+
80
+ if RUBY_VERSION >= '2.3.0' && /solaris/ =~ RUBY_PLATFORM
81
+ append_cppflags( '-D__EXTENSIONS__' )
82
+ end
83
+
84
+ begin
85
+ find_header( 'libpq-fe.h' ) or abort "Can't find the 'libpq-fe.h header"
86
+ find_header( 'libpq/libpq-fs.h' ) or abort "Can't find the 'libpq/libpq-fs.h header"
87
+ find_header( 'pg_config_manual.h' ) or abort "Can't find the 'pg_config_manual.h' header"
88
+
89
+ abort "Can't find the PostgreSQL client library (libpq)" unless
90
+ have_library( 'pq', 'PQconnectdb', ['libpq-fe.h'] ) ||
91
+ have_library( 'libpq', 'PQconnectdb', ['libpq-fe.h'] ) ||
92
+ have_library( 'ms/libpq', 'PQconnectdb', ['libpq-fe.h'] )
93
+
94
+ rescue SystemExit
95
+ install_text = case RUBY_PLATFORM
96
+ when /linux/
97
+ <<-EOT
98
+ Please install libpq or postgresql client package like so:
99
+ sudo apt install libpq-dev
100
+ sudo yum install postgresql-devel
101
+ sudo zypper in postgresql-devel
102
+ sudo pacman -S postgresql-libs
103
+ EOT
104
+ when /darwin/
105
+ <<-EOT
106
+ Please install libpq or postgresql client package like so:
107
+ brew install libpq
108
+ EOT
109
+ when /mingw/
110
+ <<-EOT
111
+ Please install libpq or postgresql client package like so:
112
+ ridk exec sh -c "pacman -S ${MINGW_PACKAGE_PREFIX}-postgresql"
113
+ EOT
114
+ else
115
+ <<-EOT
116
+ Please install libpq or postgresql client package.
117
+ EOT
118
+ end
119
+
120
+ $stderr.puts <<-EOT
121
+ *****************************************************************************
122
+
123
+ Unable to find PostgreSQL client library.
124
+
125
+ #{install_text}
126
+ or try again with:
127
+ gem install pg -- --with-pg-config=/path/to/pg_config
128
+
129
+ or set library paths manually with:
130
+ gem install pg -- --with-pg-include=/path/to/libpq-fe.h/ --with-pg-lib=/path/to/libpq.so/
131
+
132
+ EOT
133
+ raise
134
+ end
135
+
136
+ if /mingw/ =~ RUBY_PLATFORM && RbConfig::MAKEFILE_CONFIG['CC'] =~ /gcc/
137
+ # Work around: https://sourceware.org/bugzilla/show_bug.cgi?id=22504
138
+ checking_for "workaround gcc version with link issue" do
139
+ `#{RbConfig::MAKEFILE_CONFIG['CC']} --version`.chomp =~ /\s(\d+)\.\d+\.\d+(\s|$)/ &&
140
+ $1.to_i >= 6 &&
141
+ have_library(':libpq.lib') # Prefer linking to libpq.lib over libpq.dll if available
142
+ end
143
+ end
144
+
145
+ have_func 'PQconninfo', 'libpq-fe.h' or
146
+ abort "Your PostgreSQL is too old. Either install an older version " +
147
+ "of this gem or upgrade your database to at least PostgreSQL-9.3."
148
+ # optional headers/functions
149
+ have_func 'PQsslAttribute', 'libpq-fe.h' # since PostgreSQL-9.5
150
+ have_func 'PQresultVerboseErrorMessage', 'libpq-fe.h' # since PostgreSQL-9.6
151
+ have_func 'PQencryptPasswordConn', 'libpq-fe.h' # since PostgreSQL-10
152
+ have_func 'PQresultMemorySize', 'libpq-fe.h' # since PostgreSQL-12
153
+ have_func 'PQenterPipelineMode', 'libpq-fe.h' do |src| # since PostgreSQL-14
154
+ # Ensure header files fit as well
155
+ src + " int con(){ return PGRES_PIPELINE_SYNC; }"
156
+ end
157
+ have_func 'timegm'
158
+ have_func 'rb_gc_adjust_memory_usage' # since ruby-2.4
159
+ have_func 'rb_gc_mark_movable' # since ruby-2.7
160
+ have_func 'rb_io_wait' # since ruby-3.0
161
+ have_func 'rb_io_descriptor' # since ruby-3.1
162
+
163
+ # unistd.h confilicts with ruby/win32.h when cross compiling for win32 and ruby 1.9.1
164
+ have_header 'unistd.h'
165
+ have_header 'inttypes.h'
166
+ have_header('ruby/fiber/scheduler.h') if RUBY_PLATFORM=~/mingw|mswin/
167
+
168
+ checking_for "C99 variable length arrays" do
169
+ $defs.push( "-DHAVE_VARIABLE_LENGTH_ARRAYS" ) if try_compile('void test_vla(int l){ int vla[l]; }')
170
+ end
171
+
172
+ create_header()
173
+ create_makefile( "pg_ext" )
174
+
@@ -0,0 +1,21 @@
1
+ /*
2
+ * gvl_wrappers.c - Wrapper functions for locking/unlocking the Ruby GVL
3
+ *
4
+ */
5
+
6
+ #include "pg.h"
7
+
8
+ #ifndef HAVE_PQENCRYPTPASSWORDCONN
9
+ char *PQencryptPasswordConn(PGconn *conn, const char *passwd, const char *user, const char *algorithm){return NULL;}
10
+ #endif
11
+
12
+ #ifdef ENABLE_GVL_UNLOCK
13
+ FOR_EACH_BLOCKING_FUNCTION( DEFINE_GVL_WRAPPER_STRUCT );
14
+ FOR_EACH_BLOCKING_FUNCTION( DEFINE_GVL_SKELETON );
15
+ #endif
16
+ FOR_EACH_BLOCKING_FUNCTION( DEFINE_GVL_STUB );
17
+ #ifdef ENABLE_GVL_UNLOCK
18
+ FOR_EACH_CALLBACK_FUNCTION( DEFINE_GVL_WRAPPER_STRUCT );
19
+ FOR_EACH_CALLBACK_FUNCTION( DEFINE_GVLCB_SKELETON );
20
+ #endif
21
+ FOR_EACH_CALLBACK_FUNCTION( DEFINE_GVLCB_STUB );
@@ -0,0 +1,264 @@
1
+ /*
2
+ * gvl_wrappers.h - Wrapper functions for locking/unlocking the Ruby GVL
3
+ *
4
+ * These are some obscure preprocessor directives that allow to generate
5
+ * drop-in replacement wrapper functions in a declarative manner.
6
+ * These wrapper functions ensure that ruby's GVL is released on each
7
+ * function call and reacquired at the end of the call or in callbacks.
8
+ * This way blocking functions calls don't block concurrent ruby threads.
9
+ *
10
+ * The wrapper of each function is prefixed by "gvl_".
11
+ *
12
+ * Use "gcc -E" to retrieve the generated code.
13
+ */
14
+
15
+ #ifndef __gvl_wrappers_h
16
+ #define __gvl_wrappers_h
17
+
18
+ #include <ruby/thread.h>
19
+
20
+ #ifdef RUBY_EXTCONF_H
21
+ # include RUBY_EXTCONF_H
22
+ #endif
23
+
24
+ #define DEFINE_PARAM_LIST1(type, name) \
25
+ name,
26
+
27
+ #define DEFINE_PARAM_LIST2(type, name) \
28
+ p->params.name,
29
+
30
+ #define DEFINE_PARAM_LIST3(type, name) \
31
+ type name,
32
+
33
+ #define DEFINE_PARAM_DECL(type, name) \
34
+ type name;
35
+
36
+ #define DEFINE_GVL_WRAPPER_STRUCT(name, when_non_void, rettype, lastparamtype, lastparamname) \
37
+ struct gvl_wrapper_##name##_params { \
38
+ struct { \
39
+ FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_DECL) \
40
+ lastparamtype lastparamname; \
41
+ } params; \
42
+ when_non_void( rettype retval; ) \
43
+ };
44
+
45
+ #define DEFINE_GVL_SKELETON(name, when_non_void, rettype, lastparamtype, lastparamname) \
46
+ static void * gvl_##name##_skeleton( void *data ){ \
47
+ struct gvl_wrapper_##name##_params *p = (struct gvl_wrapper_##name##_params*)data; \
48
+ when_non_void( p->retval = ) \
49
+ name( FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST2) p->params.lastparamname ); \
50
+ return NULL; \
51
+ }
52
+
53
+ #ifdef ENABLE_GVL_UNLOCK
54
+ #define DEFINE_GVL_STUB(name, when_non_void, rettype, lastparamtype, lastparamname) \
55
+ rettype gvl_##name(FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST3) lastparamtype lastparamname){ \
56
+ struct gvl_wrapper_##name##_params params = { \
57
+ {FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST1) lastparamname}, when_non_void((rettype)0) \
58
+ }; \
59
+ rb_thread_call_without_gvl(gvl_##name##_skeleton, &params, RUBY_UBF_IO, 0); \
60
+ when_non_void( return params.retval; ) \
61
+ }
62
+ #else
63
+ #define DEFINE_GVL_STUB(name, when_non_void, rettype, lastparamtype, lastparamname) \
64
+ rettype gvl_##name(FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST3) lastparamtype lastparamname){ \
65
+ when_non_void( return ) \
66
+ name( FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST1) lastparamname ); \
67
+ }
68
+ #endif
69
+
70
+ #define DEFINE_GVL_STUB_DECL(name, when_non_void, rettype, lastparamtype, lastparamname) \
71
+ rettype gvl_##name(FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST3) lastparamtype lastparamname);
72
+
73
+ #define DEFINE_GVLCB_SKELETON(name, when_non_void, rettype, lastparamtype, lastparamname) \
74
+ static void * gvl_##name##_skeleton( void *data ){ \
75
+ struct gvl_wrapper_##name##_params *p = (struct gvl_wrapper_##name##_params*)data; \
76
+ when_non_void( p->retval = ) \
77
+ name( FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST2) p->params.lastparamname ); \
78
+ return NULL; \
79
+ }
80
+
81
+ #ifdef ENABLE_GVL_UNLOCK
82
+ #define DEFINE_GVLCB_STUB(name, when_non_void, rettype, lastparamtype, lastparamname) \
83
+ rettype gvl_##name(FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST3) lastparamtype lastparamname){ \
84
+ struct gvl_wrapper_##name##_params params = { \
85
+ {FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST1) lastparamname}, when_non_void((rettype)0) \
86
+ }; \
87
+ rb_thread_call_with_gvl(gvl_##name##_skeleton, &params); \
88
+ when_non_void( return params.retval; ) \
89
+ }
90
+ #else
91
+ #define DEFINE_GVLCB_STUB(name, when_non_void, rettype, lastparamtype, lastparamname) \
92
+ rettype gvl_##name(FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST3) lastparamtype lastparamname){ \
93
+ when_non_void( return ) \
94
+ name( FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST1) lastparamname ); \
95
+ }
96
+ #endif
97
+
98
+ #define GVL_TYPE_VOID(string)
99
+ #define GVL_TYPE_NONVOID(string) string
100
+
101
+
102
+ /*
103
+ * Definitions of blocking functions and their parameters
104
+ */
105
+
106
+ #define FOR_EACH_PARAM_OF_PQconnectdb(param)
107
+
108
+ #define FOR_EACH_PARAM_OF_PQconnectStart(param)
109
+
110
+ #define FOR_EACH_PARAM_OF_PQconnectPoll(param)
111
+
112
+ #define FOR_EACH_PARAM_OF_PQreset(param)
113
+
114
+ #define FOR_EACH_PARAM_OF_PQresetStart(param)
115
+
116
+ #define FOR_EACH_PARAM_OF_PQresetPoll(param)
117
+
118
+ #define FOR_EACH_PARAM_OF_PQping(param)
119
+
120
+ #define FOR_EACH_PARAM_OF_PQexec(param) \
121
+ param(PGconn *, conn)
122
+
123
+ #define FOR_EACH_PARAM_OF_PQexecParams(param) \
124
+ param(PGconn *, conn) \
125
+ param(const char *, command) \
126
+ param(int, nParams) \
127
+ param(const Oid *, paramTypes) \
128
+ param(const char * const *, paramValues) \
129
+ param(const int *, paramLengths) \
130
+ param(const int *, paramFormats)
131
+
132
+ #define FOR_EACH_PARAM_OF_PQexecPrepared(param) \
133
+ param(PGconn *, conn) \
134
+ param(const char *, stmtName) \
135
+ param(int, nParams) \
136
+ param(const char * const *, paramValues) \
137
+ param(const int *, paramLengths) \
138
+ param(const int *, paramFormats)
139
+
140
+ #define FOR_EACH_PARAM_OF_PQprepare(param) \
141
+ param(PGconn *, conn) \
142
+ param(const char *, stmtName) \
143
+ param(const char *, query) \
144
+ param(int, nParams)
145
+
146
+ #define FOR_EACH_PARAM_OF_PQdescribePrepared(param) \
147
+ param(PGconn *, conn)
148
+
149
+ #define FOR_EACH_PARAM_OF_PQdescribePortal(param) \
150
+ param(PGconn *, conn)
151
+
152
+ #define FOR_EACH_PARAM_OF_PQgetResult(param)
153
+
154
+ #define FOR_EACH_PARAM_OF_PQputCopyData(param) \
155
+ param(PGconn *, conn) \
156
+ param(const char *, buffer)
157
+
158
+ #define FOR_EACH_PARAM_OF_PQputCopyEnd(param) \
159
+ param(PGconn *, conn)
160
+
161
+ #define FOR_EACH_PARAM_OF_PQgetCopyData(param) \
162
+ param(PGconn *, conn) \
163
+ param(char **, buffer)
164
+
165
+ #define FOR_EACH_PARAM_OF_PQnotifies(param)
166
+
167
+ #define FOR_EACH_PARAM_OF_PQsendQuery(param) \
168
+ param(PGconn *, conn)
169
+
170
+ #define FOR_EACH_PARAM_OF_PQsendQueryParams(param) \
171
+ param(PGconn *, conn) \
172
+ param(const char *, command) \
173
+ param(int, nParams) \
174
+ param(const Oid *, paramTypes) \
175
+ param(const char *const *, paramValues) \
176
+ param(const int *, paramLengths) \
177
+ param(const int *, paramFormats)
178
+
179
+ #define FOR_EACH_PARAM_OF_PQsendPrepare(param) \
180
+ param(PGconn *, conn) \
181
+ param(const char *, stmtName) \
182
+ param(const char *, query) \
183
+ param(int, nParams)
184
+
185
+ #define FOR_EACH_PARAM_OF_PQsendQueryPrepared(param) \
186
+ param(PGconn *, conn) \
187
+ param(const char *, stmtName) \
188
+ param(int, nParams) \
189
+ param(const char *const *, paramValues) \
190
+ param(const int *, paramLengths) \
191
+ param(const int *, paramFormats)
192
+
193
+ #define FOR_EACH_PARAM_OF_PQsendDescribePrepared(param) \
194
+ param(PGconn *, conn)
195
+
196
+ #define FOR_EACH_PARAM_OF_PQsendDescribePortal(param) \
197
+ param(PGconn *, conn)
198
+
199
+ #define FOR_EACH_PARAM_OF_PQsetClientEncoding(param) \
200
+ param(PGconn *, conn)
201
+
202
+ #define FOR_EACH_PARAM_OF_PQisBusy(param)
203
+
204
+ #define FOR_EACH_PARAM_OF_PQencryptPasswordConn(param) \
205
+ param(PGconn *, conn) \
206
+ param(const char *, passwd) \
207
+ param(const char *, user)
208
+
209
+ #define FOR_EACH_PARAM_OF_PQcancel(param) \
210
+ param(PGcancel *, cancel) \
211
+ param(char *, errbuf)
212
+
213
+ /* function( name, void_or_nonvoid, returntype, lastparamtype, lastparamname ) */
214
+ #define FOR_EACH_BLOCKING_FUNCTION(function) \
215
+ function(PQconnectdb, GVL_TYPE_NONVOID, PGconn *, const char *, conninfo) \
216
+ function(PQconnectStart, GVL_TYPE_NONVOID, PGconn *, const char *, conninfo) \
217
+ function(PQconnectPoll, GVL_TYPE_NONVOID, PostgresPollingStatusType, PGconn *, conn) \
218
+ function(PQreset, GVL_TYPE_VOID, void, PGconn *, conn) \
219
+ function(PQresetStart, GVL_TYPE_NONVOID, int, PGconn *, conn) \
220
+ function(PQresetPoll, GVL_TYPE_NONVOID, PostgresPollingStatusType, PGconn *, conn) \
221
+ function(PQping, GVL_TYPE_NONVOID, PGPing, const char *, conninfo) \
222
+ function(PQexec, GVL_TYPE_NONVOID, PGresult *, const char *, command) \
223
+ function(PQexecParams, GVL_TYPE_NONVOID, PGresult *, int, resultFormat) \
224
+ function(PQexecPrepared, GVL_TYPE_NONVOID, PGresult *, int, resultFormat) \
225
+ function(PQprepare, GVL_TYPE_NONVOID, PGresult *, const Oid *, paramTypes) \
226
+ function(PQdescribePrepared, GVL_TYPE_NONVOID, PGresult *, const char *, stmtName) \
227
+ function(PQdescribePortal, GVL_TYPE_NONVOID, PGresult *, const char *, portalName) \
228
+ function(PQgetResult, GVL_TYPE_NONVOID, PGresult *, PGconn *, conn) \
229
+ function(PQputCopyData, GVL_TYPE_NONVOID, int, int, nbytes) \
230
+ function(PQputCopyEnd, GVL_TYPE_NONVOID, int, const char *, errormsg) \
231
+ function(PQgetCopyData, GVL_TYPE_NONVOID, int, int, async) \
232
+ function(PQnotifies, GVL_TYPE_NONVOID, PGnotify *, PGconn *, conn) \
233
+ function(PQsendQuery, GVL_TYPE_NONVOID, int, const char *, query) \
234
+ function(PQsendQueryParams, GVL_TYPE_NONVOID, int, int, resultFormat) \
235
+ function(PQsendPrepare, GVL_TYPE_NONVOID, int, const Oid *, paramTypes) \
236
+ function(PQsendQueryPrepared, GVL_TYPE_NONVOID, int, int, resultFormat) \
237
+ function(PQsendDescribePrepared, GVL_TYPE_NONVOID, int, const char *, stmt) \
238
+ function(PQsendDescribePortal, GVL_TYPE_NONVOID, int, const char *, portal) \
239
+ function(PQsetClientEncoding, GVL_TYPE_NONVOID, int, const char *, encoding) \
240
+ function(PQisBusy, GVL_TYPE_NONVOID, int, PGconn *, conn) \
241
+ function(PQencryptPasswordConn, GVL_TYPE_NONVOID, char *, const char *, algorithm) \
242
+ function(PQcancel, GVL_TYPE_NONVOID, int, int, errbufsize);
243
+
244
+ FOR_EACH_BLOCKING_FUNCTION( DEFINE_GVL_STUB_DECL );
245
+
246
+
247
+ /*
248
+ * Definitions of callback functions and their parameters
249
+ */
250
+
251
+ #define FOR_EACH_PARAM_OF_notice_processor_proxy(param) \
252
+ param(void *, arg)
253
+
254
+ #define FOR_EACH_PARAM_OF_notice_receiver_proxy(param) \
255
+ param(void *, arg)
256
+
257
+ /* function( name, void_or_nonvoid, returntype, lastparamtype, lastparamname ) */
258
+ #define FOR_EACH_CALLBACK_FUNCTION(function) \
259
+ function(notice_processor_proxy, GVL_TYPE_VOID, void, const char *, message) \
260
+ function(notice_receiver_proxy, GVL_TYPE_VOID, void, const PGresult *, result) \
261
+
262
+ FOR_EACH_CALLBACK_FUNCTION( DEFINE_GVL_STUB_DECL );
263
+
264
+ #endif /* end __gvl_wrappers_h */