autocompl 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/lib/autocompl/repository.rb +11 -1
  3. data/lib/autocompl/version.rb +1 -1
  4. data/test/dummy/log/development.log +467 -0
  5. data/test/dummy/log/test.log +3 -0
  6. data/test/dummy/vendor/bundle/ruby/2.3.0/bin/console +23 -0
  7. data/test/dummy/vendor/bundle/ruby/2.3.0/cache/pg-0.19.0.gem +0 -0
  8. data/test/dummy/vendor/bundle/ruby/2.3.0/cache/pq-0.0.1.gem +0 -0
  9. data/test/dummy/vendor/bundle/ruby/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/pg-0.19.0/gem.build_complete +0 -0
  10. data/test/dummy/vendor/bundle/ruby/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/pg-0.19.0/gem_make.out +78 -0
  11. data/test/dummy/vendor/bundle/ruby/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/pg-0.19.0/mkmf.log +1346 -0
  12. data/test/dummy/vendor/bundle/ruby/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/pg-0.19.0/pg_ext.bundle +0 -0
  13. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/BSDL +22 -0
  14. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ChangeLog +6378 -0
  15. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/Contributors.rdoc +46 -0
  16. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/History.rdoc +363 -0
  17. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/LICENSE +56 -0
  18. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/Manifest.txt +85 -0
  19. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/POSTGRES +23 -0
  20. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/README-OS_X.rdoc +68 -0
  21. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/README-Windows.rdoc +56 -0
  22. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/README.ja.rdoc +14 -0
  23. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/README.rdoc +168 -0
  24. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/Rakefile +216 -0
  25. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/Rakefile.cross +301 -0
  26. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/Makefile +261 -0
  27. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/errorcodes.def +947 -0
  28. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/errorcodes.rb +45 -0
  29. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/errorcodes.txt +467 -0
  30. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/extconf.h +38 -0
  31. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/extconf.rb +112 -0
  32. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/gvl_wrappers.c +13 -0
  33. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/gvl_wrappers.h +257 -0
  34. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/gvl_wrappers.o +0 -0
  35. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg.c +667 -0
  36. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg.h +395 -0
  37. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg.o +0 -0
  38. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_binary_decoder.c +162 -0
  39. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_binary_decoder.o +0 -0
  40. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_binary_encoder.c +162 -0
  41. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_binary_encoder.o +0 -0
  42. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_coder.c +500 -0
  43. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_coder.o +0 -0
  44. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_connection.c +4102 -0
  45. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_connection.o +0 -0
  46. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_copy_coder.c +591 -0
  47. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_copy_coder.o +0 -0
  48. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_errors.c +95 -0
  49. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_errors.o +0 -0
  50. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_ext.bundle +0 -0
  51. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_result.c +1271 -0
  52. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_result.o +0 -0
  53. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_text_decoder.c +421 -0
  54. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_text_decoder.o +0 -0
  55. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_text_encoder.c +683 -0
  56. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_text_encoder.o +0 -0
  57. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map.c +159 -0
  58. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map.o +0 -0
  59. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map_all_strings.c +116 -0
  60. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map_all_strings.o +0 -0
  61. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map_by_class.c +239 -0
  62. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map_by_class.o +0 -0
  63. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map_by_column.c +312 -0
  64. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map_by_column.o +0 -0
  65. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map_by_mri_type.c +284 -0
  66. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map_by_mri_type.o +0 -0
  67. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map_by_oid.c +355 -0
  68. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map_by_oid.o +0 -0
  69. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map_in_ruby.c +299 -0
  70. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/pg_type_map_in_ruby.o +0 -0
  71. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/util.c +149 -0
  72. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/util.h +65 -0
  73. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/util.o +0 -0
  74. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/vc/pg.sln +26 -0
  75. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/vc/pg_18/pg.vcproj +216 -0
  76. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/ext/vc/pg_19/pg_19.vcproj +209 -0
  77. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/lib/pg.rb +64 -0
  78. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/lib/pg/basic_type_mapping.rb +426 -0
  79. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/lib/pg/coder.rb +83 -0
  80. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/lib/pg/connection.rb +271 -0
  81. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/lib/pg/constants.rb +11 -0
  82. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/lib/pg/exceptions.rb +11 -0
  83. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/lib/pg/result.rb +30 -0
  84. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/lib/pg/text_decoder.rb +51 -0
  85. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/lib/pg/text_encoder.rb +35 -0
  86. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/lib/pg/type_map_by_column.rb +15 -0
  87. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/lib/pg_ext.bundle +0 -0
  88. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/array_insert.rb +20 -0
  89. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/async_api.rb +106 -0
  90. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/async_copyto.rb +39 -0
  91. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/async_mixed.rb +56 -0
  92. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/check_conn.rb +21 -0
  93. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/copyfrom.rb +81 -0
  94. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/copyto.rb +19 -0
  95. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/cursor.rb +21 -0
  96. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/disk_usage_report.rb +186 -0
  97. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/issue-119.rb +94 -0
  98. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/losample.rb +69 -0
  99. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/minimal-testcase.rb +17 -0
  100. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/notify_wait.rb +72 -0
  101. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/pg_statistics.rb +294 -0
  102. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/replication_monitor.rb +231 -0
  103. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/test_binary_values.rb +33 -0
  104. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/wal_shipper.rb +434 -0
  105. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/warehouse_partitions.rb +320 -0
  106. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/data/expected_trace.out +26 -0
  107. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/data/random_binary_data +0 -0
  108. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/helpers.rb +352 -0
  109. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/pg/basic_type_mapping_spec.rb +305 -0
  110. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/pg/connection_spec.rb +1676 -0
  111. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/pg/result_spec.rb +449 -0
  112. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/pg/type_map_by_class_spec.rb +138 -0
  113. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/pg/type_map_by_column_spec.rb +222 -0
  114. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/pg/type_map_by_mri_type_spec.rb +136 -0
  115. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/pg/type_map_by_oid_spec.rb +149 -0
  116. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/pg/type_map_in_ruby_spec.rb +164 -0
  117. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/pg/type_map_spec.rb +22 -0
  118. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/pg/type_spec.rb +777 -0
  119. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/spec/pg_spec.rb +50 -0
  120. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pq-0.0.1/Gemfile +4 -0
  121. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pq-0.0.1/LICENSE.txt +22 -0
  122. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pq-0.0.1/README.md +76 -0
  123. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pq-0.0.1/Rakefile +1 -0
  124. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pq-0.0.1/bin/console +7 -0
  125. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pq-0.0.1/lib/pq.rb +99 -0
  126. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pq-0.0.1/pq.gemspec +29 -0
  127. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pq-0.0.1/spec/helpers.rb +10 -0
  128. data/test/dummy/vendor/bundle/ruby/2.3.0/gems/pq-0.0.1/spec/queue_spec.rb +84 -0
  129. data/test/dummy/vendor/bundle/ruby/2.3.0/specifications/pg-0.19.0.gemspec +63 -0
  130. data/test/dummy/vendor/bundle/ruby/2.3.0/specifications/pq-0.0.1.gemspec +49 -0
  131. metadata +253 -1
@@ -0,0 +1,38 @@
1
+ #ifndef EXTCONF_H
2
+ #define EXTCONF_H
3
+ #define HAVE_PQCONNECTIONUSEDPASSWORD 1
4
+ #define HAVE_PQISTHREADSAFE 1
5
+ #define HAVE_PQPREPARE 1
6
+ #define HAVE_PQEXECPARAMS 1
7
+ #define HAVE_PQESCAPESTRING 1
8
+ #define HAVE_PQESCAPESTRINGCONN 1
9
+ #define HAVE_PQESCAPELITERAL 1
10
+ #define HAVE_PQESCAPEIDENTIFIER 1
11
+ #define HAVE_PQGETCANCEL 1
12
+ #define HAVE_LO_CREATE 1
13
+ #define HAVE_PG_ENCODING_TO_CHAR 1
14
+ #define HAVE_PG_CHAR_TO_ENCODING 1
15
+ #define HAVE_PQSETCLIENTENCODING 1
16
+ #define HAVE_PQLIBVERSION 1
17
+ #define HAVE_PQPING 1
18
+ #define HAVE_PQSETSINGLEROWMODE 1
19
+ #define HAVE_PQCONNINFO 1
20
+ #define HAVE_PQSSLATTRIBUTE 1
21
+ #define HAVE_RB_ENCDB_ALIAS 1
22
+ #define HAVE_RB_ENC_ALIAS 1
23
+ #define HAVE_RB_THREAD_CALL_WITHOUT_GVL 1
24
+ #define HAVE_RB_THREAD_CALL_WITH_GVL 1
25
+ #define HAVE_RB_THREAD_FD_SELECT 1
26
+ #define HAVE_RB_STR_MODIFY_EXPAND 1
27
+ #define HAVE_RB_HASH_DUP 1
28
+ #define HAVE_CONST_PGRES_COPY_BOTH 1
29
+ #define HAVE_CONST_PGRES_SINGLE_TUPLE 1
30
+ #define HAVE_CONST_PG_DIAG_TABLE_NAME 1
31
+ #define HAVE_STRUCT_PGNOTIFY_EXTRA 1
32
+ #define HAVE_ST_EXTRA 1
33
+ #define HAVE_ST_NOTIFY_EXTRA 1
34
+ #define HAVE_UNISTD_H 1
35
+ #define HAVE_INTTYPES_H 1
36
+ #define HAVE_RUBY_ST_H 1
37
+ #define HAVE_VARIABLE_LENGTH_ARRAYS 1
38
+ #endif
@@ -0,0 +1,112 @@
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("windows-cross")
19
+ # Avoid dependency to external libgcc.dll on x86-mingw32
20
+ $LDFLAGS << " -static-libgcc"
21
+ # Don't use pg_config for cross build, but --with-pg-* path options
22
+ dir_config 'pg'
23
+
24
+ else
25
+ # Native build
26
+
27
+ pgconfig = with_config('pg-config') ||
28
+ with_config('pg_config') ||
29
+ find_executable('pg_config')
30
+
31
+ if pgconfig && pgconfig != 'ignore'
32
+ $stderr.puts "Using config values from %s" % [ pgconfig ]
33
+ incdir = `"#{pgconfig}" --includedir`.chomp
34
+ libdir = `"#{pgconfig}" --libdir`.chomp
35
+ dir_config 'pg', incdir, libdir
36
+
37
+ # Try to use runtime path linker option, even if RbConfig doesn't know about it.
38
+ # The rpath option is usually set implicit by dir_config(), but so far not
39
+ # on MacOS-X.
40
+ if RbConfig::CONFIG["RPATHFLAG"].to_s.empty? && try_link('int main() {return 0;}', " -Wl,-rpath,#{libdir}")
41
+ $LDFLAGS << " -Wl,-rpath,#{libdir}"
42
+ end
43
+ else
44
+ $stderr.puts "No pg_config... trying anyway. If building fails, please try again with",
45
+ " --with-pg-config=/path/to/pg_config"
46
+ dir_config 'pg'
47
+ end
48
+ end
49
+
50
+ if RUBY_VERSION >= '2.3.0' && /solaris/ =~ RUBY_PLATFORM
51
+ append_cppflags( '-D__EXTENSIONS__' )
52
+ end
53
+
54
+ find_header( 'libpq-fe.h' ) or abort "Can't find the 'libpq-fe.h header"
55
+ find_header( 'libpq/libpq-fs.h' ) or abort "Can't find the 'libpq/libpq-fs.h header"
56
+ find_header( 'pg_config_manual.h' ) or abort "Can't find the 'pg_config_manual.h' header"
57
+
58
+ abort "Can't find the PostgreSQL client library (libpq)" unless
59
+ have_library( 'pq', 'PQconnectdb', ['libpq-fe.h'] ) ||
60
+ have_library( 'libpq', 'PQconnectdb', ['libpq-fe.h'] ) ||
61
+ have_library( 'ms/libpq', 'PQconnectdb', ['libpq-fe.h'] )
62
+
63
+ # optional headers/functions
64
+ have_func 'PQconnectionUsedPassword' or
65
+ abort "Your PostgreSQL is too old. Either install an older version " +
66
+ "of this gem or upgrade your database."
67
+ have_func 'PQisthreadsafe'
68
+ have_func 'PQprepare'
69
+ have_func 'PQexecParams'
70
+ have_func 'PQescapeString'
71
+ have_func 'PQescapeStringConn'
72
+ have_func 'PQescapeLiteral'
73
+ have_func 'PQescapeIdentifier'
74
+ have_func 'PQgetCancel'
75
+ have_func 'lo_create'
76
+ have_func 'pg_encoding_to_char'
77
+ have_func 'pg_char_to_encoding'
78
+ have_func 'PQsetClientEncoding'
79
+ have_func 'PQlibVersion'
80
+ have_func 'PQping'
81
+ have_func 'PQsetSingleRowMode'
82
+ have_func 'PQconninfo'
83
+ have_func 'PQsslAttribute'
84
+
85
+ have_func 'rb_encdb_alias'
86
+ have_func 'rb_enc_alias'
87
+ have_func 'rb_thread_call_without_gvl'
88
+ have_func 'rb_thread_call_with_gvl'
89
+ have_func 'rb_thread_fd_select'
90
+ have_func 'rb_w32_wrap_io_handle'
91
+ have_func 'rb_str_modify_expand'
92
+ have_func 'rb_hash_dup'
93
+
94
+ have_const 'PGRES_COPY_BOTH', 'libpq-fe.h'
95
+ have_const 'PGRES_SINGLE_TUPLE', 'libpq-fe.h'
96
+ have_const 'PG_DIAG_TABLE_NAME', 'libpq-fe.h'
97
+
98
+ $defs.push( "-DHAVE_ST_NOTIFY_EXTRA" ) if
99
+ have_struct_member 'struct pgNotify', 'extra', 'libpq-fe.h'
100
+
101
+ # unistd.h confilicts with ruby/win32.h when cross compiling for win32 and ruby 1.9.1
102
+ have_header 'unistd.h'
103
+ have_header 'inttypes.h'
104
+ have_header 'ruby/st.h' or have_header 'st.h' or abort "pg currently requires the ruby/st.h header"
105
+
106
+ checking_for "C99 variable length arrays" do
107
+ $defs.push( "-DHAVE_VARIABLE_LENGTH_ARRAYS" ) if try_compile('void test_vla(int l){ int vla[l]; }')
108
+ end
109
+
110
+ create_header()
111
+ create_makefile( "pg_ext" )
112
+
@@ -0,0 +1,13 @@
1
+ /*
2
+ * gvl_wrappers.c - Wrapper functions for locking/unlocking the Ruby GVL
3
+ *
4
+ */
5
+
6
+ #include "pg.h"
7
+
8
+ FOR_EACH_BLOCKING_FUNCTION( DEFINE_GVL_WRAPPER_STRUCT );
9
+ FOR_EACH_BLOCKING_FUNCTION( DEFINE_GVL_SKELETON );
10
+ FOR_EACH_BLOCKING_FUNCTION( DEFINE_GVL_STUB );
11
+ FOR_EACH_CALLBACK_FUNCTION( DEFINE_GVL_WRAPPER_STRUCT );
12
+ FOR_EACH_CALLBACK_FUNCTION( DEFINE_GVLCB_SKELETON );
13
+ FOR_EACH_CALLBACK_FUNCTION( DEFINE_GVLCB_STUB );
@@ -0,0 +1,257 @@
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
+ #if defined(HAVE_RB_THREAD_CALL_WITH_GVL)
19
+ extern void *rb_thread_call_with_gvl(void *(*func)(void *), void *data1);
20
+ #endif
21
+
22
+ #if defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL)
23
+ extern void *rb_thread_call_without_gvl(void *(*func)(void *), void *data1,
24
+ rb_unblock_function_t *ubf, void *data2);
25
+ #endif
26
+
27
+ #define DEFINE_PARAM_LIST1(type, name) \
28
+ name,
29
+
30
+ #define DEFINE_PARAM_LIST2(type, name) \
31
+ p->params.name,
32
+
33
+ #define DEFINE_PARAM_LIST3(type, name) \
34
+ type name,
35
+
36
+ #define DEFINE_PARAM_DECL(type, name) \
37
+ type name;
38
+
39
+ #define DEFINE_GVL_WRAPPER_STRUCT(name, when_non_void, rettype, lastparamtype, lastparamname) \
40
+ struct gvl_wrapper_##name##_params { \
41
+ struct { \
42
+ FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_DECL) \
43
+ lastparamtype lastparamname; \
44
+ } params; \
45
+ when_non_void( rettype retval; ) \
46
+ };
47
+
48
+ #define DEFINE_GVL_SKELETON(name, when_non_void, rettype, lastparamtype, lastparamname) \
49
+ static void * gvl_##name##_skeleton( void *data ){ \
50
+ struct gvl_wrapper_##name##_params *p = (struct gvl_wrapper_##name##_params*)data; \
51
+ when_non_void( p->retval = ) \
52
+ name( FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST2) p->params.lastparamname ); \
53
+ return NULL; \
54
+ }
55
+
56
+ #if defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL)
57
+ #define DEFINE_GVL_STUB(name, when_non_void, rettype, lastparamtype, lastparamname) \
58
+ rettype gvl_##name(FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST3) lastparamtype lastparamname){ \
59
+ struct gvl_wrapper_##name##_params params = { \
60
+ {FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST1) lastparamname}, when_non_void((rettype)0) \
61
+ }; \
62
+ rb_thread_call_without_gvl(gvl_##name##_skeleton, &params, RUBY_UBF_IO, 0); \
63
+ when_non_void( return params.retval; ) \
64
+ }
65
+ #else
66
+ #define DEFINE_GVL_STUB(name, when_non_void, rettype, lastparamtype, lastparamname) \
67
+ rettype gvl_##name(FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST3) lastparamtype lastparamname){ \
68
+ return name( FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST1) lastparamname ); \
69
+ }
70
+ #endif
71
+
72
+ #define DEFINE_GVL_STUB_DECL(name, when_non_void, rettype, lastparamtype, lastparamname) \
73
+ rettype gvl_##name(FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST3) lastparamtype lastparamname);
74
+
75
+ #define DEFINE_GVLCB_SKELETON(name, when_non_void, rettype, lastparamtype, lastparamname) \
76
+ static void * gvl_##name##_skeleton( void *data ){ \
77
+ struct gvl_wrapper_##name##_params *p = (struct gvl_wrapper_##name##_params*)data; \
78
+ when_non_void( p->retval = ) \
79
+ name( FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST2) p->params.lastparamname ); \
80
+ return NULL; \
81
+ }
82
+
83
+ #if defined(HAVE_RB_THREAD_CALL_WITH_GVL)
84
+ #define DEFINE_GVLCB_STUB(name, when_non_void, rettype, lastparamtype, lastparamname) \
85
+ rettype gvl_##name(FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST3) lastparamtype lastparamname){ \
86
+ struct gvl_wrapper_##name##_params params = { \
87
+ {FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST1) lastparamname}, when_non_void((rettype)0) \
88
+ }; \
89
+ rb_thread_call_with_gvl(gvl_##name##_skeleton, &params); \
90
+ when_non_void( return params.retval; ) \
91
+ }
92
+ #else
93
+ #define DEFINE_GVLCB_STUB(name, when_non_void, rettype, lastparamtype, lastparamname) \
94
+ rettype gvl_##name(FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST3) lastparamtype lastparamname){ \
95
+ return name( FOR_EACH_PARAM_OF_##name(DEFINE_PARAM_LIST1) lastparamname ); \
96
+ }
97
+ #endif
98
+
99
+ #define GVL_TYPE_VOID(string)
100
+ #define GVL_TYPE_NONVOID(string) string
101
+
102
+
103
+ /*
104
+ * Definitions of blocking functions and their parameters
105
+ */
106
+
107
+ #define FOR_EACH_PARAM_OF_PQconnectdb(param)
108
+
109
+ #define FOR_EACH_PARAM_OF_PQconnectStart(param)
110
+
111
+ #define FOR_EACH_PARAM_OF_PQconnectPoll(param)
112
+
113
+ #define FOR_EACH_PARAM_OF_PQreset(param)
114
+
115
+ #define FOR_EACH_PARAM_OF_PQresetStart(param)
116
+
117
+ #define FOR_EACH_PARAM_OF_PQresetPoll(param)
118
+
119
+ #define FOR_EACH_PARAM_OF_PQexec(param) \
120
+ param(PGconn *, conn)
121
+
122
+ #define FOR_EACH_PARAM_OF_PQexecParams(param) \
123
+ param(PGconn *, conn) \
124
+ param(const char *, command) \
125
+ param(int, nParams) \
126
+ param(const Oid *, paramTypes) \
127
+ param(const char * const *, paramValues) \
128
+ param(const int *, paramLengths) \
129
+ param(const int *, paramFormats)
130
+
131
+ #define FOR_EACH_PARAM_OF_PQexecPrepared(param) \
132
+ param(PGconn *, conn) \
133
+ param(const char *, stmtName) \
134
+ param(int, nParams) \
135
+ param(const char * const *, paramValues) \
136
+ param(const int *, paramLengths) \
137
+ param(const int *, paramFormats)
138
+
139
+ #define FOR_EACH_PARAM_OF_PQprepare(param) \
140
+ param(PGconn *, conn) \
141
+ param(const char *, stmtName) \
142
+ param(const char *, query) \
143
+ param(int, nParams)
144
+
145
+ #define FOR_EACH_PARAM_OF_PQdescribePrepared(param) \
146
+ param(PGconn *, conn)
147
+
148
+ #define FOR_EACH_PARAM_OF_PQdescribePortal(param) \
149
+ param(PGconn *, conn)
150
+
151
+ #define FOR_EACH_PARAM_OF_PQgetResult(param)
152
+
153
+ #define FOR_EACH_PARAM_OF_PQputCopyData(param) \
154
+ param(PGconn *, conn) \
155
+ param(const char *, buffer)
156
+
157
+ #define FOR_EACH_PARAM_OF_PQputCopyEnd(param) \
158
+ param(PGconn *, conn)
159
+
160
+ #define FOR_EACH_PARAM_OF_PQgetCopyData(param) \
161
+ param(PGconn *, conn) \
162
+ param(char **, buffer)
163
+
164
+ #define FOR_EACH_PARAM_OF_PQnotifies(param)
165
+
166
+ #define FOR_EACH_PARAM_OF_PQsendQuery(param) \
167
+ param(PGconn *, conn)
168
+
169
+ #define FOR_EACH_PARAM_OF_PQsendQueryParams(param) \
170
+ param(PGconn *, conn) \
171
+ param(const char *, command) \
172
+ param(int, nParams) \
173
+ param(const Oid *, paramTypes) \
174
+ param(const char *const *, paramValues) \
175
+ param(const int *, paramLengths) \
176
+ param(const int *, paramFormats)
177
+
178
+ #define FOR_EACH_PARAM_OF_PQsendPrepare(param) \
179
+ param(PGconn *, conn) \
180
+ param(const char *, stmtName) \
181
+ param(const char *, query) \
182
+ param(int, nParams)
183
+
184
+ #define FOR_EACH_PARAM_OF_PQsendQueryPrepared(param) \
185
+ param(PGconn *, conn) \
186
+ param(const char *, stmtName) \
187
+ param(int, nParams) \
188
+ param(const char *const *, paramValues) \
189
+ param(const int *, paramLengths) \
190
+ param(const int *, paramFormats)
191
+
192
+ #define FOR_EACH_PARAM_OF_PQsendDescribePrepared(param) \
193
+ param(PGconn *, conn)
194
+
195
+ #define FOR_EACH_PARAM_OF_PQsendDescribePortal(param) \
196
+ param(PGconn *, conn)
197
+
198
+ #define FOR_EACH_PARAM_OF_PQsetClientEncoding(param) \
199
+ param(PGconn *, conn)
200
+
201
+ #define FOR_EACH_PARAM_OF_PQisBusy(param)
202
+
203
+ #define FOR_EACH_PARAM_OF_PQcancel(param) \
204
+ param(PGcancel *, cancel) \
205
+ param(char *, errbuf)
206
+
207
+ /* function( name, void_or_nonvoid, returntype, lastparamtype, lastparamname ) */
208
+ #define FOR_EACH_BLOCKING_FUNCTION(function) \
209
+ function(PQconnectdb, GVL_TYPE_NONVOID, PGconn *, const char *, conninfo) \
210
+ function(PQconnectStart, GVL_TYPE_NONVOID, PGconn *, const char *, conninfo) \
211
+ function(PQconnectPoll, GVL_TYPE_NONVOID, PostgresPollingStatusType, PGconn *, conn) \
212
+ function(PQreset, GVL_TYPE_VOID, void, PGconn *, conn) \
213
+ function(PQresetStart, GVL_TYPE_NONVOID, int, PGconn *, conn) \
214
+ function(PQresetPoll, GVL_TYPE_NONVOID, PostgresPollingStatusType, PGconn *, conn) \
215
+ function(PQexec, GVL_TYPE_NONVOID, PGresult *, const char *, command) \
216
+ function(PQexecParams, GVL_TYPE_NONVOID, PGresult *, int, resultFormat) \
217
+ function(PQexecPrepared, GVL_TYPE_NONVOID, PGresult *, int, resultFormat) \
218
+ function(PQprepare, GVL_TYPE_NONVOID, PGresult *, const Oid *, paramTypes) \
219
+ function(PQdescribePrepared, GVL_TYPE_NONVOID, PGresult *, const char *, stmtName) \
220
+ function(PQdescribePortal, GVL_TYPE_NONVOID, PGresult *, const char *, portalName) \
221
+ function(PQgetResult, GVL_TYPE_NONVOID, PGresult *, PGconn *, conn) \
222
+ function(PQputCopyData, GVL_TYPE_NONVOID, int, int, nbytes) \
223
+ function(PQputCopyEnd, GVL_TYPE_NONVOID, int, const char *, errormsg) \
224
+ function(PQgetCopyData, GVL_TYPE_NONVOID, int, int, async) \
225
+ function(PQnotifies, GVL_TYPE_NONVOID, PGnotify *, PGconn *, conn) \
226
+ function(PQsendQuery, GVL_TYPE_NONVOID, int, const char *, query) \
227
+ function(PQsendQueryParams, GVL_TYPE_NONVOID, int, int, resultFormat) \
228
+ function(PQsendPrepare, GVL_TYPE_NONVOID, int, const Oid *, paramTypes) \
229
+ function(PQsendQueryPrepared, GVL_TYPE_NONVOID, int, int, resultFormat) \
230
+ function(PQsendDescribePrepared, GVL_TYPE_NONVOID, int, const char *, stmt) \
231
+ function(PQsendDescribePortal, GVL_TYPE_NONVOID, int, const char *, portal) \
232
+ function(PQsetClientEncoding, GVL_TYPE_NONVOID, int, const char *, encoding) \
233
+ function(PQisBusy, GVL_TYPE_NONVOID, int, PGconn *, conn) \
234
+ function(PQcancel, GVL_TYPE_NONVOID, int, int, errbufsize);
235
+
236
+
237
+ FOR_EACH_BLOCKING_FUNCTION( DEFINE_GVL_STUB_DECL );
238
+
239
+
240
+ /*
241
+ * Definitions of callback functions and their parameters
242
+ */
243
+
244
+ #define FOR_EACH_PARAM_OF_notice_processor_proxy(param) \
245
+ param(void *, arg)
246
+
247
+ #define FOR_EACH_PARAM_OF_notice_receiver_proxy(param) \
248
+ param(void *, arg)
249
+
250
+ /* function( name, void_or_nonvoid, returntype, lastparamtype, lastparamname ) */
251
+ #define FOR_EACH_CALLBACK_FUNCTION(function) \
252
+ function(notice_processor_proxy, GVL_TYPE_VOID, void, const char *, message) \
253
+ function(notice_receiver_proxy, GVL_TYPE_VOID, void, const PGresult *, result) \
254
+
255
+ FOR_EACH_CALLBACK_FUNCTION( DEFINE_GVL_STUB_DECL );
256
+
257
+ #endif /* end __gvl_wrappers_h */
@@ -0,0 +1,667 @@
1
+ /*
2
+ * pg.c - Toplevel extension
3
+ * $Id: pg.c,v c77d0997b4e4 2016/08/20 17:30:03 ged $
4
+ *
5
+ * Author/s:
6
+ *
7
+ * - Jeff Davis <ruby-pg@j-davis.com>
8
+ * - Guy Decoux (ts) <decoux@moulon.inra.fr>
9
+ * - Michael Granger <ged@FaerieMUD.org>
10
+ * - Lars Kanis <lars@greiz-reinsdorf.de>
11
+ * - Dave Lee
12
+ * - Eiji Matsumoto <usagi@ruby.club.or.jp>
13
+ * - Yukihiro Matsumoto <matz@ruby-lang.org>
14
+ * - Noboru Saitou <noborus@netlab.jp>
15
+ *
16
+ * See Contributors.rdoc for the many additional fine people that have contributed
17
+ * to this library over the years.
18
+ *
19
+ * Copyright (c) 1997-2016 by the authors.
20
+ *
21
+ * You may redistribute this software under the same terms as Ruby itself; see
22
+ * https://www.ruby-lang.org/en/about/license.txt or the BSDL file in the source
23
+ * for details.
24
+ *
25
+ * Portions of the code are from the PostgreSQL project, and are distributed
26
+ * under the terms of the PostgreSQL license, included in the file "POSTGRES".
27
+ *
28
+ * Portions copyright LAIKA, Inc.
29
+ *
30
+ *
31
+ * The following functions are part of libpq, but not available from ruby-pg,
32
+ * because they are deprecated, obsolete, or generally not useful:
33
+ *
34
+ * - PQfreemem -- unnecessary: copied to ruby object, then freed. Ruby object's
35
+ * memory is freed when it is garbage collected.
36
+ * - PQbinaryTuples -- better to use PQfformat
37
+ * - PQprint -- not very useful
38
+ * - PQsetdb -- not very useful
39
+ * - PQoidStatus -- deprecated, use PQoidValue
40
+ * - PQrequestCancel -- deprecated, use PQcancel
41
+ * - PQfn -- use a prepared statement instead
42
+ * - PQgetline -- deprecated, use PQgetCopyData
43
+ * - PQgetlineAsync -- deprecated, use PQgetCopyData
44
+ * - PQputline -- deprecated, use PQputCopyData
45
+ * - PQputnbytes -- deprecated, use PQputCopyData
46
+ * - PQendcopy -- deprecated, use PQputCopyEnd
47
+ */
48
+
49
+ #include "pg.h"
50
+
51
+ VALUE rb_mPG;
52
+ VALUE rb_mPGconstants;
53
+
54
+
55
+ /*
56
+ * Document-class: PG::Error
57
+ *
58
+ * This is the exception class raised when an error is returned from
59
+ * a libpq API call.
60
+ *
61
+ * The attributes +connection+ and +result+ are set to the connection
62
+ * object and result set object, respectively.
63
+ *
64
+ * If the connection object or result set object is not available from
65
+ * the context in which the error was encountered, it is +nil+.
66
+ */
67
+
68
+ /*
69
+ * M17n functions
70
+ */
71
+
72
+ #ifdef M17N_SUPPORTED
73
+ /**
74
+ * The mapping from canonical encoding names in PostgreSQL to ones in Ruby.
75
+ */
76
+ const char * const (pg_enc_pg2ruby_mapping[][2]) = {
77
+ {"BIG5", "Big5" },
78
+ {"EUC_CN", "GB2312" },
79
+ {"EUC_JP", "EUC-JP" },
80
+ {"EUC_JIS_2004", "EUC-JP" },
81
+ {"EUC_KR", "EUC-KR" },
82
+ {"EUC_TW", "EUC-TW" },
83
+ {"GB18030", "GB18030" },
84
+ {"GBK", "GBK" },
85
+ {"ISO_8859_5", "ISO-8859-5" },
86
+ {"ISO_8859_6", "ISO-8859-6" },
87
+ {"ISO_8859_7", "ISO-8859-7" },
88
+ {"ISO_8859_8", "ISO-8859-8" },
89
+ /* {"JOHAB", "JOHAB" }, dummy */
90
+ {"KOI8", "KOI8-R" },
91
+ {"KOI8R", "KOI8-R" },
92
+ {"KOI8U", "KOI8-U" },
93
+ {"LATIN1", "ISO-8859-1" },
94
+ {"LATIN2", "ISO-8859-2" },
95
+ {"LATIN3", "ISO-8859-3" },
96
+ {"LATIN4", "ISO-8859-4" },
97
+ {"LATIN5", "ISO-8859-9" },
98
+ {"LATIN6", "ISO-8859-10" },
99
+ {"LATIN7", "ISO-8859-13" },
100
+ {"LATIN8", "ISO-8859-14" },
101
+ {"LATIN9", "ISO-8859-15" },
102
+ {"LATIN10", "ISO-8859-16" },
103
+ {"MULE_INTERNAL", "Emacs-Mule" },
104
+ {"SJIS", "Windows-31J" },
105
+ {"SHIFT_JIS_2004","Windows-31J" },
106
+ /* {"SQL_ASCII", NULL }, special case*/
107
+ {"UHC", "CP949" },
108
+ {"UTF8", "UTF-8" },
109
+ {"WIN866", "IBM866" },
110
+ {"WIN874", "Windows-874" },
111
+ {"WIN1250", "Windows-1250"},
112
+ {"WIN1251", "Windows-1251"},
113
+ {"WIN1252", "Windows-1252"},
114
+ {"WIN1253", "Windows-1253"},
115
+ {"WIN1254", "Windows-1254"},
116
+ {"WIN1255", "Windows-1255"},
117
+ {"WIN1256", "Windows-1256"},
118
+ {"WIN1257", "Windows-1257"},
119
+ {"WIN1258", "Windows-1258"}
120
+ };
121
+
122
+
123
+ /*
124
+ * A cache of mapping from PostgreSQL's encoding indices to Ruby's rb_encoding*s.
125
+ */
126
+ static struct st_table *enc_pg2ruby;
127
+
128
+
129
+ /*
130
+ * Look up the JOHAB encoding, creating it as a dummy encoding if it's not
131
+ * already defined.
132
+ */
133
+ static rb_encoding *
134
+ pg_find_or_create_johab(void)
135
+ {
136
+ static const char * const aliases[] = { "JOHAB", "Windows-1361", "CP1361" };
137
+ int enc_index;
138
+ size_t i;
139
+
140
+ for (i = 0; i < sizeof(aliases)/sizeof(aliases[0]); ++i) {
141
+ enc_index = rb_enc_find_index(aliases[i]);
142
+ if (enc_index > 0) return rb_enc_from_index(enc_index);
143
+ }
144
+
145
+ enc_index = rb_define_dummy_encoding(aliases[0]);
146
+ for (i = 1; i < sizeof(aliases)/sizeof(aliases[0]); ++i) {
147
+ ENC_ALIAS(aliases[i], aliases[0]);
148
+ }
149
+ return rb_enc_from_index(enc_index);
150
+ }
151
+
152
+ /*
153
+ * Return the given PostgreSQL encoding ID as an rb_encoding.
154
+ *
155
+ * - returns NULL if the client encoding is 'SQL_ASCII'.
156
+ * - returns ASCII-8BIT if the client encoding is unknown.
157
+ */
158
+ rb_encoding *
159
+ pg_get_pg_encoding_as_rb_encoding( int enc_id )
160
+ {
161
+ rb_encoding *enc;
162
+
163
+ /* Use the cached value if it exists */
164
+ if ( st_lookup(enc_pg2ruby, (st_data_t)enc_id, (st_data_t*)&enc) ) {
165
+ return enc;
166
+ }
167
+ else {
168
+ const char *name = pg_encoding_to_char( enc_id );
169
+
170
+ enc = pg_get_pg_encname_as_rb_encoding( name );
171
+ st_insert( enc_pg2ruby, (st_data_t)enc_id, (st_data_t)enc );
172
+
173
+ return enc;
174
+ }
175
+
176
+ }
177
+
178
+ /*
179
+ * Return the given PostgreSQL encoding name as an rb_encoding.
180
+ */
181
+ rb_encoding *
182
+ pg_get_pg_encname_as_rb_encoding( const char *pg_encname )
183
+ {
184
+ size_t i;
185
+
186
+ /* Trying looking it up in the conversion table */
187
+ for ( i = 0; i < sizeof(pg_enc_pg2ruby_mapping)/sizeof(pg_enc_pg2ruby_mapping[0]); ++i ) {
188
+ if ( strcmp(pg_encname, pg_enc_pg2ruby_mapping[i][0]) == 0 )
189
+ return rb_enc_find( pg_enc_pg2ruby_mapping[i][1] );
190
+ }
191
+
192
+ /* JOHAB isn't a builtin encoding, so make up a dummy encoding if it's seen */
193
+ if ( strncmp(pg_encname, "JOHAB", 5) == 0 )
194
+ return pg_find_or_create_johab();
195
+
196
+ /* Fallthrough to ASCII-8BIT */
197
+ return rb_ascii8bit_encoding();
198
+ }
199
+
200
+ /*
201
+ * Get the client encoding of the specified connection handle and return it as a rb_encoding.
202
+ */
203
+ rb_encoding *
204
+ pg_conn_enc_get( PGconn *conn )
205
+ {
206
+ int enc_id = PQclientEncoding( conn );
207
+ return pg_get_pg_encoding_as_rb_encoding( enc_id );
208
+ }
209
+
210
+
211
+ /*
212
+ * Returns the given rb_encoding as the equivalent PostgreSQL encoding string.
213
+ */
214
+ const char *
215
+ pg_get_rb_encoding_as_pg_encoding( rb_encoding *enc )
216
+ {
217
+ const char *rb_encname = rb_enc_name( enc );
218
+ const char *encname = NULL;
219
+ size_t i;
220
+
221
+ for (i = 0; i < sizeof(pg_enc_pg2ruby_mapping)/sizeof(pg_enc_pg2ruby_mapping[0]); ++i) {
222
+ if (strcmp(rb_encname, pg_enc_pg2ruby_mapping[i][1]) == 0) {
223
+ encname = pg_enc_pg2ruby_mapping[i][0];
224
+ }
225
+ }
226
+
227
+ if ( !encname ) encname = "SQL_ASCII";
228
+
229
+ return encname;
230
+ }
231
+
232
+ #endif /* M17N_SUPPORTED */
233
+
234
+
235
+ /*
236
+ * Ensures that the given string has enough capacity to take expand_len
237
+ * more data bytes. The new data part of the String is not initialized.
238
+ *
239
+ * current_out must be a pointer within the data part of the String object.
240
+ * This pointer is returned and possibly adjusted, because the location of the data
241
+ * part of the String can change through this function.
242
+ *
243
+ * PG_RB_STR_ENSURE_CAPA can be used to do fast inline checks of the remaining capacity.
244
+ * end_capa it is then set to the first byte after the currently reserved memory,
245
+ * if not NULL.
246
+ *
247
+ * Before the String can be used with other string functions or returned to Ruby space,
248
+ * the string length has to be set with rb_str_set_len().
249
+ *
250
+ * Usage example:
251
+ *
252
+ * VALUE string;
253
+ * char *current_out, *end_capa;
254
+ * PG_RB_STR_NEW( string, current_out, end_capa );
255
+ * while( data_is_going_to_be_processed ){
256
+ * PG_RB_STR_ENSURE_CAPA( string, 2, current_out, end_capa );
257
+ * *current_out++ = databyte1;
258
+ * *current_out++ = databyte2;
259
+ * }
260
+ * rb_str_set_len( string, current_out - RSTRING_PTR(string) );
261
+ *
262
+ */
263
+ #ifdef HAVE_RB_STR_MODIFY_EXPAND
264
+ /* Use somewhat faster version with access to string capacity on MRI */
265
+ char *
266
+ pg_rb_str_ensure_capa( VALUE str, long expand_len, char *curr_ptr, char **end_ptr )
267
+ {
268
+ long curr_len = curr_ptr - RSTRING_PTR(str);
269
+ long curr_capa = rb_str_capacity( str );
270
+ if( curr_capa < curr_len + expand_len ){
271
+ rb_str_set_len( str, curr_len );
272
+ rb_str_modify_expand( str, (curr_len + expand_len) * 2 - curr_capa );
273
+ curr_ptr = RSTRING_PTR(str) + curr_len;
274
+ }
275
+ if( end_ptr )
276
+ *end_ptr = RSTRING_PTR(str) + rb_str_capacity( str );
277
+ return curr_ptr;
278
+ }
279
+ #else
280
+ /* Use the more portable version */
281
+ char *
282
+ pg_rb_str_ensure_capa( VALUE str, long expand_len, char *curr_ptr, char **end_ptr )
283
+ {
284
+ long curr_len = curr_ptr - RSTRING_PTR(str);
285
+ long curr_capa = RSTRING_LEN( str );
286
+ if( curr_capa < curr_len + expand_len ){
287
+ rb_str_resize( str, (curr_len + expand_len) * 2 - curr_capa );
288
+ curr_ptr = RSTRING_PTR(str) + curr_len;
289
+ }
290
+ if( end_ptr )
291
+ *end_ptr = RSTRING_PTR(str) + RSTRING_LEN(str);
292
+ return curr_ptr;
293
+ }
294
+ #endif
295
+
296
+
297
+ /**************************************************************************
298
+ * Module Methods
299
+ **************************************************************************/
300
+
301
+ #ifdef HAVE_PQLIBVERSION
302
+ /*
303
+ * call-seq:
304
+ * PG.library_version -> Integer
305
+ *
306
+ * Get the version of the libpq library in use. The number is formed by
307
+ * converting the major, minor, and revision numbers into two-decimal-
308
+ * digit numbers and appending them together.
309
+ * For example, version 7.4.2 will be returned as 70402, and version
310
+ * 8.1 will be returned as 80100 (leading zeroes are not shown). Zero
311
+ * is returned if the connection is bad.
312
+ */
313
+ static VALUE
314
+ pg_s_library_version(VALUE self)
315
+ {
316
+ UNUSED( self );
317
+ return INT2NUM(PQlibVersion());
318
+ }
319
+ #endif
320
+
321
+
322
+ /*
323
+ * call-seq:
324
+ * PG.isthreadsafe -> Boolean
325
+ * PG.is_threadsafe? -> Boolean
326
+ * PG.threadsafe? -> Boolean
327
+ *
328
+ * Returns +true+ if libpq is thread-safe, +false+ otherwise.
329
+ */
330
+ static VALUE
331
+ pg_s_threadsafe_p(VALUE self)
332
+ {
333
+ UNUSED( self );
334
+ return PQisthreadsafe() ? Qtrue : Qfalse;
335
+ }
336
+
337
+ static int
338
+ pg_to_bool_int(VALUE value)
339
+ {
340
+ switch( TYPE(value) ){
341
+ case T_FALSE:
342
+ return 0;
343
+ case T_TRUE:
344
+ return 1;
345
+ default:
346
+ return NUM2INT(value);
347
+ }
348
+ }
349
+
350
+ /*
351
+ * call-seq:
352
+ * PG.init_openssl(do_ssl, do_crypto) -> nil
353
+ *
354
+ * Allows applications to select which security libraries to initialize.
355
+ *
356
+ * If your application initializes libssl and/or libcrypto libraries and libpq is
357
+ * built with SSL support, you should call PG.init_openssl() to tell libpq that the
358
+ * libssl and/or libcrypto libraries have been initialized by your application,
359
+ * so that libpq will not also initialize those libraries. See
360
+ * http://h71000.www7.hp.com/doc/83final/BA554_90007/ch04.html for details on the SSL API.
361
+ *
362
+ * When do_ssl is +true+, libpq will initialize the OpenSSL library before first
363
+ * opening a database connection. When do_crypto is +true+, the libcrypto library
364
+ * will be initialized. By default (if PG.init_openssl() is not called), both libraries
365
+ * are initialized. When SSL support is not compiled in, this function is present but does nothing.
366
+ *
367
+ * If your application uses and initializes either OpenSSL or its underlying libcrypto library,
368
+ * you must call this function with +false+ for the appropriate parameter(s) before first opening
369
+ * a database connection. Also be sure that you have done that initialization before opening a
370
+ * database connection.
371
+ *
372
+ */
373
+ static VALUE
374
+ pg_s_init_openssl(VALUE self, VALUE do_ssl, VALUE do_crypto)
375
+ {
376
+ UNUSED( self );
377
+ PQinitOpenSSL(pg_to_bool_int(do_ssl), pg_to_bool_int(do_crypto));
378
+ return Qnil;
379
+ }
380
+
381
+
382
+ /*
383
+ * call-seq:
384
+ * PG.init_ssl(do_ssl) -> nil
385
+ *
386
+ * Allows applications to select which security libraries to initialize.
387
+ *
388
+ * This function is equivalent to <tt>PG.init_openssl(do_ssl, do_ssl)</tt> . It is sufficient for
389
+ * applications that initialize both or neither of OpenSSL and libcrypto.
390
+ */
391
+ static VALUE
392
+ pg_s_init_ssl(VALUE self, VALUE do_ssl)
393
+ {
394
+ UNUSED( self );
395
+ PQinitSSL(pg_to_bool_int(do_ssl));
396
+ return Qnil;
397
+ }
398
+
399
+
400
+ /**************************************************************************
401
+ * Initializer
402
+ **************************************************************************/
403
+
404
+ void
405
+ Init_pg_ext()
406
+ {
407
+ rb_mPG = rb_define_module( "PG" );
408
+ rb_mPGconstants = rb_define_module_under( rb_mPG, "Constants" );
409
+
410
+ /*************************
411
+ * PG module methods
412
+ *************************/
413
+ #ifdef HAVE_PQLIBVERSION
414
+ rb_define_singleton_method( rb_mPG, "library_version", pg_s_library_version, 0 );
415
+ #endif
416
+ rb_define_singleton_method( rb_mPG, "isthreadsafe", pg_s_threadsafe_p, 0 );
417
+ SINGLETON_ALIAS( rb_mPG, "is_threadsafe?", "isthreadsafe" );
418
+ SINGLETON_ALIAS( rb_mPG, "threadsafe?", "isthreadsafe" );
419
+
420
+ rb_define_singleton_method( rb_mPG, "init_openssl", pg_s_init_openssl, 2 );
421
+ rb_define_singleton_method( rb_mPG, "init_ssl", pg_s_init_ssl, 1 );
422
+
423
+
424
+ /****** PG::Connection CLASS CONSTANTS: Connection Status ******/
425
+
426
+ /* Connection succeeded */
427
+ rb_define_const(rb_mPGconstants, "CONNECTION_OK", INT2FIX(CONNECTION_OK));
428
+ /* Connection failed */
429
+ rb_define_const(rb_mPGconstants, "CONNECTION_BAD", INT2FIX(CONNECTION_BAD));
430
+
431
+ /****** PG::Connection CLASS CONSTANTS: Nonblocking connection status ******/
432
+
433
+ /* Waiting for connection to be made. */
434
+ rb_define_const(rb_mPGconstants, "CONNECTION_STARTED", INT2FIX(CONNECTION_STARTED));
435
+ /* Connection OK; waiting to send. */
436
+ rb_define_const(rb_mPGconstants, "CONNECTION_MADE", INT2FIX(CONNECTION_MADE));
437
+ /* Waiting for a response from the server. */
438
+ rb_define_const(rb_mPGconstants, "CONNECTION_AWAITING_RESPONSE", INT2FIX(CONNECTION_AWAITING_RESPONSE));
439
+ /* Received authentication; waiting for backend start-up to finish. */
440
+ rb_define_const(rb_mPGconstants, "CONNECTION_AUTH_OK", INT2FIX(CONNECTION_AUTH_OK));
441
+ /* Negotiating SSL encryption. */
442
+ rb_define_const(rb_mPGconstants, "CONNECTION_SSL_STARTUP", INT2FIX(CONNECTION_SSL_STARTUP));
443
+ /* Negotiating environment-driven parameter settings. */
444
+ rb_define_const(rb_mPGconstants, "CONNECTION_SETENV", INT2FIX(CONNECTION_SETENV));
445
+ /* Internal state: connect() needed. */
446
+ rb_define_const(rb_mPGconstants, "CONNECTION_NEEDED", INT2FIX(CONNECTION_NEEDED));
447
+
448
+ /****** PG::Connection CLASS CONSTANTS: Nonblocking connection polling status ******/
449
+
450
+ /* Async connection is waiting to read */
451
+ rb_define_const(rb_mPGconstants, "PGRES_POLLING_READING", INT2FIX(PGRES_POLLING_READING));
452
+ /* Async connection is waiting to write */
453
+ rb_define_const(rb_mPGconstants, "PGRES_POLLING_WRITING", INT2FIX(PGRES_POLLING_WRITING));
454
+ /* Async connection failed or was reset */
455
+ rb_define_const(rb_mPGconstants, "PGRES_POLLING_FAILED", INT2FIX(PGRES_POLLING_FAILED));
456
+ /* Async connection succeeded */
457
+ rb_define_const(rb_mPGconstants, "PGRES_POLLING_OK", INT2FIX(PGRES_POLLING_OK));
458
+
459
+ /****** PG::Connection CLASS CONSTANTS: Transaction Status ******/
460
+
461
+ /* Transaction is currently idle (#transaction_status) */
462
+ rb_define_const(rb_mPGconstants, "PQTRANS_IDLE", INT2FIX(PQTRANS_IDLE));
463
+ /* Transaction is currently active; query has been sent to the server, but not yet completed. (#transaction_status) */
464
+ rb_define_const(rb_mPGconstants, "PQTRANS_ACTIVE", INT2FIX(PQTRANS_ACTIVE));
465
+ /* Transaction is currently idle, in a valid transaction block (#transaction_status) */
466
+ rb_define_const(rb_mPGconstants, "PQTRANS_INTRANS", INT2FIX(PQTRANS_INTRANS));
467
+ /* Transaction is currently idle, in a failed transaction block (#transaction_status) */
468
+ rb_define_const(rb_mPGconstants, "PQTRANS_INERROR", INT2FIX(PQTRANS_INERROR));
469
+ /* Transaction's connection is bad (#transaction_status) */
470
+ rb_define_const(rb_mPGconstants, "PQTRANS_UNKNOWN", INT2FIX(PQTRANS_UNKNOWN));
471
+
472
+ /****** PG::Connection CLASS CONSTANTS: Error Verbosity ******/
473
+
474
+ /* Terse error verbosity level (#set_error_verbosity) */
475
+ rb_define_const(rb_mPGconstants, "PQERRORS_TERSE", INT2FIX(PQERRORS_TERSE));
476
+ /* Default error verbosity level (#set_error_verbosity) */
477
+ rb_define_const(rb_mPGconstants, "PQERRORS_DEFAULT", INT2FIX(PQERRORS_DEFAULT));
478
+ /* Verbose error verbosity level (#set_error_verbosity) */
479
+ rb_define_const(rb_mPGconstants, "PQERRORS_VERBOSE", INT2FIX(PQERRORS_VERBOSE));
480
+
481
+ #ifdef HAVE_PQPING
482
+ /****** PG::Connection CLASS CONSTANTS: Check Server Status ******/
483
+
484
+ /* Server is accepting connections. */
485
+ rb_define_const(rb_mPGconstants, "PQPING_OK", INT2FIX(PQPING_OK));
486
+ /* Server is alive but rejecting connections. */
487
+ rb_define_const(rb_mPGconstants, "PQPING_REJECT", INT2FIX(PQPING_REJECT));
488
+ /* Could not establish connection. */
489
+ rb_define_const(rb_mPGconstants, "PQPING_NO_RESPONSE", INT2FIX(PQPING_NO_RESPONSE));
490
+ /* Connection not attempted (bad params). */
491
+ rb_define_const(rb_mPGconstants, "PQPING_NO_ATTEMPT", INT2FIX(PQPING_NO_ATTEMPT));
492
+ #endif
493
+
494
+ /****** PG::Connection CLASS CONSTANTS: Large Objects ******/
495
+
496
+ /* Flag for #lo_creat, #lo_open -- open for writing */
497
+ rb_define_const(rb_mPGconstants, "INV_WRITE", INT2FIX(INV_WRITE));
498
+ /* Flag for #lo_creat, #lo_open -- open for reading */
499
+ rb_define_const(rb_mPGconstants, "INV_READ", INT2FIX(INV_READ));
500
+ /* Flag for #lo_lseek -- seek from object start */
501
+ rb_define_const(rb_mPGconstants, "SEEK_SET", INT2FIX(SEEK_SET));
502
+ /* Flag for #lo_lseek -- seek from current position */
503
+ rb_define_const(rb_mPGconstants, "SEEK_CUR", INT2FIX(SEEK_CUR));
504
+ /* Flag for #lo_lseek -- seek from object end */
505
+ rb_define_const(rb_mPGconstants, "SEEK_END", INT2FIX(SEEK_END));
506
+
507
+ /****** PG::Result CONSTANTS: result status ******/
508
+
509
+ /* #result_status constant: The string sent to the server was empty. */
510
+ rb_define_const(rb_mPGconstants, "PGRES_EMPTY_QUERY", INT2FIX(PGRES_EMPTY_QUERY));
511
+ /* #result_status constant: Successful completion of a command returning no data. */
512
+ rb_define_const(rb_mPGconstants, "PGRES_COMMAND_OK", INT2FIX(PGRES_COMMAND_OK));
513
+ /* #result_status constant: Successful completion of a command returning data
514
+ (such as a SELECT or SHOW). */
515
+ rb_define_const(rb_mPGconstants, "PGRES_TUPLES_OK", INT2FIX(PGRES_TUPLES_OK));
516
+ /* #result_status constant: Copy Out (from server) data transfer started. */
517
+ rb_define_const(rb_mPGconstants, "PGRES_COPY_OUT", INT2FIX(PGRES_COPY_OUT));
518
+ /* #result_status constant: Copy In (to server) data transfer started. */
519
+ rb_define_const(rb_mPGconstants, "PGRES_COPY_IN", INT2FIX(PGRES_COPY_IN));
520
+ /* #result_status constant: The server’s response was not understood. */
521
+ rb_define_const(rb_mPGconstants, "PGRES_BAD_RESPONSE", INT2FIX(PGRES_BAD_RESPONSE));
522
+ /* #result_status constant: A nonfatal error (a notice or warning) occurred. */
523
+ rb_define_const(rb_mPGconstants, "PGRES_NONFATAL_ERROR",INT2FIX(PGRES_NONFATAL_ERROR));
524
+ /* #result_status constant: A fatal error occurred. */
525
+ rb_define_const(rb_mPGconstants, "PGRES_FATAL_ERROR", INT2FIX(PGRES_FATAL_ERROR));
526
+ /* #result_status constant: Copy In/Out data transfer in progress. */
527
+ #ifdef HAVE_CONST_PGRES_COPY_BOTH
528
+ rb_define_const(rb_mPGconstants, "PGRES_COPY_BOTH", INT2FIX(PGRES_COPY_BOTH));
529
+ #endif
530
+ /* #result_status constant: Single tuple from larger resultset. */
531
+ #ifdef HAVE_CONST_PGRES_SINGLE_TUPLE
532
+ rb_define_const(rb_mPGconstants, "PGRES_SINGLE_TUPLE", INT2FIX(PGRES_SINGLE_TUPLE));
533
+ #endif
534
+
535
+ /****** Result CONSTANTS: result error field codes ******/
536
+
537
+ /* #result_error_field argument constant: The severity; the field contents
538
+ * are ERROR, FATAL, or PANIC (in an error message), or WARNING, NOTICE,
539
+ * DEBUG, INFO, or LOG (in a notice message), or a localized translation
540
+ * of one of these. Always present.
541
+ */
542
+ rb_define_const(rb_mPGconstants, "PG_DIAG_SEVERITY", INT2FIX(PG_DIAG_SEVERITY));
543
+
544
+ /* #result_error_field argument constant: The SQLSTATE code for the
545
+ * error. The SQLSTATE code identies the type of error that has occurred;
546
+ * it can be used by front-end applications to perform specic operations
547
+ * (such as er- ror handling) in response to a particular database
548
+ * error. For a list of the possible SQLSTATE codes, see Appendix A.
549
+ * This eld is not localizable, and is always present.
550
+ */
551
+ rb_define_const(rb_mPGconstants, "PG_DIAG_SQLSTATE", INT2FIX(PG_DIAG_SQLSTATE));
552
+
553
+ /* #result_error_field argument constant: The primary human-readable
554
+ * error message (typically one line). Always present. */
555
+ rb_define_const(rb_mPGconstants, "PG_DIAG_MESSAGE_PRIMARY", INT2FIX(PG_DIAG_MESSAGE_PRIMARY));
556
+
557
+ /* #result_error_field argument constant: Detail: an optional secondary
558
+ * error message carrying more detail about the problem. Might run to
559
+ * multiple lines.
560
+ */
561
+ rb_define_const(rb_mPGconstants, "PG_DIAG_MESSAGE_DETAIL", INT2FIX(PG_DIAG_MESSAGE_DETAIL));
562
+
563
+ /* #result_error_field argument constant: Hint: an optional suggestion
564
+ * what to do about the problem. This is intended to differ from detail
565
+ * in that it offers advice (potentially inappropriate) rather than
566
+ * hard facts. Might run to multiple lines.
567
+ */
568
+
569
+ rb_define_const(rb_mPGconstants, "PG_DIAG_MESSAGE_HINT", INT2FIX(PG_DIAG_MESSAGE_HINT));
570
+ /* #result_error_field argument constant: A string containing a decimal
571
+ * integer indicating an error cursor position as an index into the
572
+ * original statement string. The rst character has index 1, and
573
+ * positions are measured in characters not bytes.
574
+ */
575
+
576
+ rb_define_const(rb_mPGconstants, "PG_DIAG_STATEMENT_POSITION", INT2FIX(PG_DIAG_STATEMENT_POSITION));
577
+ /* #result_error_field argument constant: This is dened the same as
578
+ * the PG_DIAG_STATEMENT_POSITION eld, but it is used when the cursor
579
+ * position refers to an internally generated command rather than the
580
+ * one submitted by the client. The PG_DIAG_INTERNAL_QUERY eld will
581
+ * always appear when this eld appears.
582
+ */
583
+
584
+ rb_define_const(rb_mPGconstants, "PG_DIAG_INTERNAL_POSITION", INT2FIX(PG_DIAG_INTERNAL_POSITION));
585
+ /* #result_error_field argument constant: The text of a failed
586
+ * internally-generated command. This could be, for example, a SQL
587
+ * query issued by a PL/pgSQL function.
588
+ */
589
+
590
+ rb_define_const(rb_mPGconstants, "PG_DIAG_INTERNAL_QUERY", INT2FIX(PG_DIAG_INTERNAL_QUERY));
591
+ /* #result_error_field argument constant: An indication of the context
592
+ * in which the error occurred. Presently this includes a call stack
593
+ * traceback of active procedural language functions and internally-generated
594
+ * queries. The trace is one entry per line, most recent rst.
595
+ */
596
+
597
+ rb_define_const(rb_mPGconstants, "PG_DIAG_CONTEXT", INT2FIX(PG_DIAG_CONTEXT));
598
+ /* #result_error_field argument constant: The le name of the source-code
599
+ * location where the error was reported. */
600
+ rb_define_const(rb_mPGconstants, "PG_DIAG_SOURCE_FILE", INT2FIX(PG_DIAG_SOURCE_FILE));
601
+
602
+ /* #result_error_field argument constant: The line number of the
603
+ * source-code location where the error was reported. */
604
+ rb_define_const(rb_mPGconstants, "PG_DIAG_SOURCE_LINE", INT2FIX(PG_DIAG_SOURCE_LINE));
605
+
606
+ /* #result_error_field argument constant: The name of the source-code
607
+ * function reporting the error. */
608
+ rb_define_const(rb_mPGconstants, "PG_DIAG_SOURCE_FUNCTION", INT2FIX(PG_DIAG_SOURCE_FUNCTION));
609
+
610
+ #ifdef HAVE_CONST_PG_DIAG_TABLE_NAME
611
+ /* #result_error_field argument constant: If the error was associated with a
612
+ * specific database object, the name of the schema containing that object, if any. */
613
+ rb_define_const(rb_mPGconstants, "PG_DIAG_SCHEMA_NAME", INT2FIX(PG_DIAG_SCHEMA_NAME));
614
+
615
+ /* #result_error_field argument constant: If the error was associated with a
616
+ *specific table, the name of the table. (When this field is present, the schema name
617
+ * field provides the name of the table's schema.) */
618
+ rb_define_const(rb_mPGconstants, "PG_DIAG_TABLE_NAME", INT2FIX(PG_DIAG_TABLE_NAME));
619
+
620
+ /* #result_error_field argument constant: If the error was associated with a
621
+ * specific table column, the name of the column. (When this field is present, the
622
+ * schema and table name fields identify the table.) */
623
+ rb_define_const(rb_mPGconstants, "PG_DIAG_COLUMN_NAME", INT2FIX(PG_DIAG_COLUMN_NAME));
624
+
625
+ /* #result_error_field argument constant: If the error was associated with a
626
+ * specific datatype, the name of the datatype. (When this field is present, the
627
+ * schema name field provides the name of the datatype's schema.) */
628
+ rb_define_const(rb_mPGconstants, "PG_DIAG_DATATYPE_NAME", INT2FIX(PG_DIAG_DATATYPE_NAME));
629
+
630
+ /* #result_error_field argument constant: If the error was associated with a
631
+ * specific constraint, the name of the constraint. The table or domain that the
632
+ * constraint belongs to is reported using the fields listed above. (For this
633
+ * purpose, indexes are treated as constraints, even if they weren't created with
634
+ * constraint syntax.) */
635
+ rb_define_const(rb_mPGconstants, "PG_DIAG_CONSTRAINT_NAME", INT2FIX(PG_DIAG_CONSTRAINT_NAME));
636
+ #endif
637
+
638
+ /* Invalid OID constant */
639
+ rb_define_const(rb_mPGconstants, "INVALID_OID", INT2FIX(InvalidOid));
640
+ rb_define_const(rb_mPGconstants, "InvalidOid", INT2FIX(InvalidOid));
641
+
642
+ /* Add the constants to the toplevel namespace */
643
+ rb_include_module( rb_mPG, rb_mPGconstants );
644
+
645
+ #ifdef M17N_SUPPORTED
646
+ enc_pg2ruby = st_init_numtable();
647
+ #endif
648
+
649
+ /* Initialize the main extension classes */
650
+ init_pg_connection();
651
+ init_pg_result();
652
+ init_pg_errors();
653
+ init_pg_type_map();
654
+ init_pg_type_map_all_strings();
655
+ init_pg_type_map_by_class();
656
+ init_pg_type_map_by_column();
657
+ init_pg_type_map_by_mri_type();
658
+ init_pg_type_map_by_oid();
659
+ init_pg_type_map_in_ruby();
660
+ init_pg_coder();
661
+ init_pg_text_encoder();
662
+ init_pg_text_decoder();
663
+ init_pg_binary_encoder();
664
+ init_pg_binary_decoder();
665
+ init_pg_copycoder();
666
+ }
667
+