/usr/share/doc/ruby-pg/rdoc/index.html is in ruby-pg 0.18.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 | <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>pg: The Ruby Interface to PostgreSQL</title>
<script type="text/javascript">
var rdoc_rel_prefix = "./";
</script>
<script src="./js/jquery.js"></script>
<script src="./js/darkfish.js"></script>
<link href="./css/fonts.css" rel="stylesheet">
<link href="./css/rdoc.css" rel="stylesheet">
<body id="top" role="document" class="file">
<nav role="navigation">
<div id="project-navigation">
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
<h2>
<a href="./index.html" rel="home">Home</a>
</h2>
<div id="table-of-contents-navigation">
<a href="./table_of_contents.html#pages">Pages</a>
<a href="./table_of_contents.html#classes">Classes</a>
<a href="./table_of_contents.html#methods">Methods</a>
</div>
</div>
<div id="search-section" role="search" class="project-section initially-hidden">
<form action="#" method="get" accept-charset="utf-8">
<div id="search-field-wrapper">
<input id="search-field" role="combobox" aria-label="Search"
aria-autocomplete="list" aria-controls="search-results"
type="text" name="search" placeholder="Search" spellcheck="false"
title="Type to search, Up and Down to navigate, Enter to load">
</div>
<ul id="search-results" aria-label="Search Results"
aria-busy="false" aria-expanded="false"
aria-atomic="false" class="initially-hidden"></ul>
</form>
</div>
</div>
<div id="project-metadata">
<div id="fileindex-section" class="nav-section">
<h3>Pages</h3>
<ul class="link-list">
<li><a href="./README_rdoc.html">README</a>
</ul>
</div>
<div id="classindex-section" class="nav-section">
<h3>Class and Module Index</h3>
<ul class="link-list">
<li><a href="./Object.html">Object</a>
<li><a href="./PG/Error.html">Object::PGError</a>
<li><a href="./PG.html">PG</a>
<li><a href="./PG/BasicTypeMapBasedOnResult.html">PG::BasicTypeMapBasedOnResult</a>
<li><a href="./PG/BasicTypeMapForQueries.html">PG::BasicTypeMapForQueries</a>
<li><a href="./PG/BasicTypeMapForResults.html">PG::BasicTypeMapForResults</a>
<li><a href="./PG/BasicTypeMapForResults/WarningTypeMap.html">PG::BasicTypeMapForResults::WarningTypeMap</a>
<li><a href="./PG/BasicTypeRegistry.html">PG::BasicTypeRegistry</a>
<li><a href="./PG/BasicTypeRegistry/CoderMap.html">PG::BasicTypeRegistry::CoderMap</a>
<li><a href="./PG/BinaryDecoder.html">PG::BinaryDecoder</a>
<li><a href="./PG/BinaryDecoder/Boolean.html">PG::BinaryDecoder::Boolean</a>
<li><a href="./PG/BinaryDecoder/Bytea.html">PG::BinaryDecoder::Bytea</a>
<li><a href="./PG/BinaryDecoder/Float.html">PG::BinaryDecoder::Float</a>
<li><a href="./PG/BinaryDecoder/Integer.html">PG::BinaryDecoder::Integer</a>
<li><a href="./PG/BinaryDecoder/String.html">PG::BinaryDecoder::String</a>
<li><a href="./PG/BinaryDecoder/ToBase64.html">PG::BinaryDecoder::ToBase64</a>
<li><a href="./PG/BinaryEncoder.html">PG::BinaryEncoder</a>
<li><a href="./PG/BinaryEncoder/Boolean.html">PG::BinaryEncoder::Boolean</a>
<li><a href="./PG/BinaryEncoder/Bytea.html">PG::BinaryEncoder::Bytea</a>
<li><a href="./PG/BinaryEncoder/FromBase64.html">PG::BinaryEncoder::FromBase64</a>
<li><a href="./PG/BinaryEncoder/Int2.html">PG::BinaryEncoder::Int2</a>
<li><a href="./PG/BinaryEncoder/Int4.html">PG::BinaryEncoder::Int4</a>
<li><a href="./PG/BinaryEncoder/Int8.html">PG::BinaryEncoder::Int8</a>
<li><a href="./PG/BinaryEncoder/String.html">PG::BinaryEncoder::String</a>
<li><a href="./PG/Coder.html">PG::Coder</a>
<li><a href="./PG/Coder/BinaryFormatting.html">PG::Coder::BinaryFormatting</a>
<li><a href="./PG/CompositeCoder.html">PG::CompositeCoder</a>
<li><a href="./PG/CompositeDecoder.html">PG::CompositeDecoder</a>
<li><a href="./PG/CompositeEncoder.html">PG::CompositeEncoder</a>
<li><a href="./PG/Connection.html">PG::Connection</a>
<li><a href="./PG/ConnectionBad.html">PG::ConnectionBad</a>
<li><a href="./PG/Constants.html">PG::Constants</a>
<li><a href="./PG/CopyCoder.html">PG::CopyCoder</a>
<li><a href="./PG/CopyDecoder.html">PG::CopyDecoder</a>
<li><a href="./PG/CopyEncoder.html">PG::CopyEncoder</a>
<li><a href="./PG/Error.html">PG::Error</a>
<li><a href="./PG/InvalidChangeOfResultFields.html">PG::InvalidChangeOfResultFields</a>
<li><a href="./PG/InvalidResultStatus.html">PG::InvalidResultStatus</a>
<li><a href="./PG/NoResultError.html">PG::NoResultError</a>
<li><a href="./PG/NotAllCopyDataRetrieved.html">PG::NotAllCopyDataRetrieved</a>
<li><a href="./PG/PGError.html">PG::PGError</a>
<li><a href="./PG/Result.html">PG::Result</a>
<li><a href="./PG/ServerError.html">PG::ServerError</a>
<li><a href="./PG/SimpleCoder.html">PG::SimpleCoder</a>
<li><a href="./PG/SimpleDecoder.html">PG::SimpleDecoder</a>
<li><a href="./PG/SimpleEncoder.html">PG::SimpleEncoder</a>
<li><a href="./PG/TextDecoder.html">PG::TextDecoder</a>
<li><a href="./PG/TextDecoder/Array.html">PG::TextDecoder::Array</a>
<li><a href="./PG/TextDecoder/Boolean.html">PG::TextDecoder::Boolean</a>
<li><a href="./PG/TextDecoder/Bytea.html">PG::TextDecoder::Bytea</a>
<li><a href="./PG/TextDecoder/CopyRow.html">PG::TextDecoder::CopyRow</a>
<li><a href="./PG/TextDecoder/Date.html">PG::TextDecoder::Date</a>
<li><a href="./PG/TextDecoder/Float.html">PG::TextDecoder::Float</a>
<li><a href="./PG/TextDecoder/FromBase64.html">PG::TextDecoder::FromBase64</a>
<li><a href="./PG/TextDecoder/Identifier.html">PG::TextDecoder::Identifier</a>
<li><a href="./PG/TextDecoder/Integer.html">PG::TextDecoder::Integer</a>
<li><a href="./PG/TextDecoder/String.html">PG::TextDecoder::String</a>
<li><a href="./PG/TextDecoder/TimestampWithTimeZone.html">PG::TextDecoder::TimestampWithTimeZone</a>
<li><a href="./PG/TextDecoder/TimestampWithoutTimeZone.html">PG::TextDecoder::TimestampWithoutTimeZone</a>
<li><a href="./PG/TextEncoder.html">PG::TextEncoder</a>
<li><a href="./PG/TextEncoder/Array.html">PG::TextEncoder::Array</a>
<li><a href="./PG/TextEncoder/Boolean.html">PG::TextEncoder::Boolean</a>
<li><a href="./PG/TextEncoder/Bytea.html">PG::TextEncoder::Bytea</a>
<li><a href="./PG/TextEncoder/CopyRow.html">PG::TextEncoder::CopyRow</a>
<li><a href="./PG/TextEncoder/Date.html">PG::TextEncoder::Date</a>
<li><a href="./PG/TextEncoder/Float.html">PG::TextEncoder::Float</a>
<li><a href="./PG/TextEncoder/Identifier.html">PG::TextEncoder::Identifier</a>
<li><a href="./PG/TextEncoder/Integer.html">PG::TextEncoder::Integer</a>
<li><a href="./PG/TextEncoder/QuotedLiteral.html">PG::TextEncoder::QuotedLiteral</a>
<li><a href="./PG/TextEncoder/String.html">PG::TextEncoder::String</a>
<li><a href="./PG/TextEncoder/TimestampWithTimeZone.html">PG::TextEncoder::TimestampWithTimeZone</a>
<li><a href="./PG/TextEncoder/TimestampWithoutTimeZone.html">PG::TextEncoder::TimestampWithoutTimeZone</a>
<li><a href="./PG/TextEncoder/ToBase64.html">PG::TextEncoder::ToBase64</a>
<li><a href="./PG/TypeMap.html">PG::TypeMap</a>
<li><a href="./PG/TypeMap/DefaultTypeMappable.html">PG::TypeMap::DefaultTypeMappable</a>
<li><a href="./PG/TypeMapAllStrings.html">PG::TypeMapAllStrings</a>
<li><a href="./PG/TypeMapByClass.html">PG::TypeMapByClass</a>
<li><a href="./PG/TypeMapByColumn.html">PG::TypeMapByColumn</a>
<li><a href="./PG/TypeMapByMriType.html">PG::TypeMapByMriType</a>
<li><a href="./PG/TypeMapByOid.html">PG::TypeMapByOid</a>
<li><a href="./PG/TypeMapInRuby.html">PG::TypeMapInRuby</a>
<li><a href="./PG/UnableToSend.html">PG::UnableToSend</a>
<li><a href="./PGconn.html">PGconn</a>
<li><a href="./PGresult.html">PGresult</a>
</ul>
</div>
</div>
</nav>
<main role="main">
<h1 id="label-pg">pg<span><a href="#label-pg">¶</a> <a href="#top">↑</a></span></h1>
<dl class="rdoc-list note-list"><dt>home
<dd>
<p><a href="https://bitbucket.org/ged/ruby-pg">bitbucket.org/ged/ruby-pg</a></p>
</dd><dt>mirror
<dd>
<p><a href="https://github.com/ged/ruby-pg">github.com/ged/ruby-pg</a></p>
</dd><dt>docs
<dd>
<p><a href="http://deveiate.org/code/pg">deveiate.org/code/pg</a></p>
</dd></dl>
<p><a
href="https://gitter.im/ged/ruby-pg?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge"><img
src="https://badges.gitter.im/Join%20Chat.svg" alt="Join the chat at
https://gitter.im/ged/ruby-pg"></a></p>
<h2 id="label-Description">Description<span><a href="#label-Description">¶</a> <a href="#top">↑</a></span></h2>
<p>Pg is the Ruby interface to the <a
href="http://www.postgresql.org/">PostgreSQL RDBMS</a>.</p>
<p>It works with <a
href="http://www.postgresql.org/support/versioning/">PostgreSQL 8.4 and
later</a>.</p>
<p>A small example usage:</p>
<pre class="ruby"><span class="ruby-comment">#!/usr/bin/env ruby</span>
<span class="ruby-identifier">require</span> <span class="ruby-string">'pg'</span>
<span class="ruby-comment"># Output a table of current connections to the DB</span>
<span class="ruby-identifier">conn</span> = <span class="ruby-constant">PG</span>.<span class="ruby-identifier">connect</span>( <span class="ruby-identifier">dbname</span><span class="ruby-operator">:</span> <span class="ruby-string">'sales'</span> )
<span class="ruby-identifier">conn</span>.<span class="ruby-identifier">exec</span>( <span class="ruby-string">"SELECT * FROM pg_stat_activity"</span> ) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">result</span><span class="ruby-operator">|</span>
<span class="ruby-identifier">puts</span> <span class="ruby-string">" PID | User | Query"</span>
<span class="ruby-identifier">result</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">row</span><span class="ruby-operator">|</span>
<span class="ruby-identifier">puts</span> <span class="ruby-string">" %7d | %-16s | %s "</span> <span class="ruby-operator">%</span>
<span class="ruby-identifier">row</span>.<span class="ruby-identifier">values_at</span>(<span class="ruby-string">'procpid'</span>, <span class="ruby-string">'usename'</span>, <span class="ruby-string">'current_query'</span>)
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span>
</pre>
<h2 id="label-Build+Status">Build Status<span><a href="#label-Build+Status">¶</a> <a href="#top">↑</a></span></h2>
<p><a href="https://travis-ci.org/ged/ruby-pg"><img
src="https://travis-ci.org/ged/ruby-pg.png?branch=master" alt="Build Status
Travis-CI" /></a> <a
href="https://ci.appveyor.com/project/ged/ruby-pg"><img
src="https://ci.appveyor.com/api/projects/status/at4g4swb2cd4xji7/branch/master?svg=true"
alt="Build Status Appveyor" /></a></p>
<h2 id="label-Requirements">Requirements<span><a href="#label-Requirements">¶</a> <a href="#top">↑</a></span></h2>
<ul><li>
<p>Ruby 1.9.3-p392, or 2.0.0-p0.</p>
</li><li>
<p>PostgreSQL 8.4.x or later (with headers, -dev packages, etc).</p>
</li></ul>
<p>It may work with earlier versions of Ruby/PostgreSQL as well, but those are
not regularly tested.</p>
<h2 id="label-How+To+Install">How To Install<span><a href="#label-How+To+Install">¶</a> <a href="#top">↑</a></span></h2>
<p>Install via RubyGems:</p>
<pre class="ruby"><span class="ruby-identifier">gem</span> <span class="ruby-identifier">install</span> <span class="ruby-identifier">pg</span>
</pre>
<p>You may need to specify the path to the 'pg_config' program
installed with Postgres:</p>
<pre>gem install pg -- --with-pg-config=<path to pg_config></pre>
<p>If you're installing via Bundler, you can provide compile hints like
so:</p>
<pre>bundle config build.pg --with-pg-config=<path to pg_config></pre>
<p>See README-OS_X.rdoc for more information about installing under MacOS X,
and README-Windows.rdoc for Windows build/installation instructions.</p>
<p>There's also <a href="http://goo.gl/TFy1U">a Google+ group</a> and a <a
href="http://groups.google.com/group/ruby-pg">mailing list</a> if you get
stuck, or just want to chat about something.</p>
<h2 id="label-Type+Casts">Type Casts<span><a href="#label-Type+Casts">¶</a> <a href="#top">↑</a></span></h2>
<p>Pg can optionally type cast result values and query parameters in Ruby or
native C code. This can speed up data transfers to and from the database,
because String allocations are reduced and conversions in (slower) Ruby
code can be omitted.</p>
<p>Very basic type casting can be enabled by:</p>
<pre class="ruby"><span class="ruby-identifier">conn</span>.<span class="ruby-identifier">type_map_for_results</span> = <span class="ruby-constant">PG</span><span class="ruby-operator">::</span><span class="ruby-constant">BasicTypeMapForResults</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">conn</span>
<span class="ruby-comment"># ... this works for result value mapping:</span>
<span class="ruby-identifier">conn</span>.<span class="ruby-identifier">exec</span>(<span class="ruby-string">"select 1, now(), '{2,3}'::int[]"</span>).<span class="ruby-identifier">values</span>
<span class="ruby-comment"># => [[1, 2014-09-21 20:51:56 +0200, [2, 3]]]</span>
<span class="ruby-identifier">conn</span>.<span class="ruby-identifier">type_map_for_queries</span> = <span class="ruby-constant">PG</span><span class="ruby-operator">::</span><span class="ruby-constant">BasicTypeMapForQueries</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">conn</span>
<span class="ruby-comment"># ... and this for param value mapping:</span>
<span class="ruby-identifier">conn</span>.<span class="ruby-identifier">exec_params</span>(<span class="ruby-string">"SELECT $1::text, $2::text, $3::text"</span>, [<span class="ruby-value">1</span>, <span class="ruby-value">1.23</span>, [<span class="ruby-value">2</span>,<span class="ruby-value">3</span>]]).<span class="ruby-identifier">values</span>
<span class="ruby-comment"># => [["1", "1.2300000000000000E+00", "{2,3}"]]</span>
</pre>
<p>But Pg's type casting is highly customizable. That's why it's
divided into 2 layers:</p>
<h3 id="label-Encoders+-2F+Decoders+-28ext-2Fpg_-2Acoder.c-2C+lib-2Fpg-2F-2Acoder.rb-29">Encoders / Decoders (ext/pg_*coder.c, lib/pg/*coder.rb)<span><a href="#label-Encoders+-2F+Decoders+-28ext-2Fpg_-2Acoder.c-2C+lib-2Fpg-2F-2Acoder.rb-29">¶</a> <a href="#top">↑</a></span></h3>
<p>This is the lower layer, containing encoding classes that convert Ruby
objects for transmission to the DBMS and decoding classes to convert
received data back to Ruby objects. The classes are namespaced according to
their format and direction in <a
href="PG/TextEncoder.html">PG::TextEncoder</a>, <a
href="PG/TextDecoder.html">PG::TextDecoder</a>, <a
href="PG/BinaryEncoder.html">PG::BinaryEncoder</a> and <a
href="PG/BinaryDecoder.html">PG::BinaryDecoder</a>.</p>
<p>It is possible to assign a type OID, format code (text or binary) and
optionally a name to an encoder or decoder object. It's also possible
to build composite types by assigning an element encoder/decoder. <a
href="PG/Coder.html">PG::Coder</a> objects can be used to set up a <a
href="PG/TypeMap.html">PG::TypeMap</a> or alternatively to convert single
values to/from their string representation.</p>
<h3 id="label-PG-3A-3ATypeMap+and+derivations+-28ext-2Fpg_type_map-2A.c-2C+lib-2Fpg-2Ftype_map-2A.rb-29"><a href="PG/TypeMap.html">PG::TypeMap</a> and derivations (ext/pg_type_map*.c, lib/pg/type_map*.rb)<span><a href="#label-PG-3A-3ATypeMap+and+derivations+-28ext-2Fpg_type_map-2A.c-2C+lib-2Fpg-2Ftype_map-2A.rb-29">¶</a> <a href="#top">↑</a></span></h3>
<p>A TypeMap defines which value will be converted by which encoder/decoder.
There are different type map strategies, implemented by several derivations
of this class. They can be chosen and configured according to the
particular needs for type casting. The default type map is <a
href="PG/TypeMapAllStrings.html">PG::TypeMapAllStrings</a>.</p>
<p>A type map can be assigned per connection or per query respectively per
result set. Type maps can also be used for COPY in and out data streaming.</p>
<h2 id="label-Contributing">Contributing<span><a href="#label-Contributing">¶</a> <a href="#top">↑</a></span></h2>
<p>To report bugs, suggest features, or check out the source with Mercurial,
<a href="http://bitbucket.org/ged/ruby-pg">check out the project page</a>.
If you prefer Git, there's also a <a
href="https://github.com/ged/ruby-pg">Github mirror</a>.</p>
<p>After checking out the source, run:</p>
<pre>$ rake newb</pre>
<p>This task will install any missing dependencies, run the tests/specs, and
generate the API documentation.</p>
<p>The current maintainers are Michael Granger <ged@FaerieMUD.org> and
Lars Kanis <lars@greiz-reinsdorf.de>.</p>
<h2 id="label-Copying">Copying<span><a href="#label-Copying">¶</a> <a href="#top">↑</a></span></h2>
<p>Copyright © 1997-2015 by the authors.</p>
<ul><li>
<p>Jeff Davis <ruby-pg@j-davis.com></p>
</li><li>
<p>Guy Decoux (ts) <decoux@moulon.inra.fr></p>
</li><li>
<p>Michael Granger <ged@FaerieMUD.org></p>
</li><li>
<p>Lars Kanis <lars@greiz-reinsdorf.de></p>
</li><li>
<p>Dave Lee</p>
</li><li>
<p>Eiji Matsumoto <usagi@ruby.club.or.jp></p>
</li><li>
<p>Yukihiro Matsumoto <matz@ruby-lang.org></p>
</li><li>
<p>Noboru Saitou <noborus@netlab.jp></p>
</li></ul>
<p>You may redistribute this software under the same terms as Ruby itself; see
<a
href="http://www.ruby-lang.org/en/LICENSE.txt">www.ruby-lang.org/en/LICENSE.txt</a>
or the LICENSE file in the source for details.</p>
<p>Portions of the code are from the PostgreSQL project, and are distributed
under the terms of the PostgreSQL license, included in the file POSTGRES.</p>
<p>Portions copyright LAIKA, Inc.</p>
<h2 id="label-Acknowledgments">Acknowledgments<span><a href="#label-Acknowledgments">¶</a> <a href="#top">↑</a></span></h2>
<p>See Contributors.rdoc for the many additional fine people that have
contributed to this library over the years.</p>
<p>We are thankful to the people at the ruby-list and ruby-dev mailing lists.
And to the people who developed PostgreSQL.</p>
</main>
<footer id="validator-badges" role="contentinfo">
<p><a href="http://validator.w3.org/check/referer">Validate</a>
<p>Generated by <a href="http://docs.seattlerb.org/rdoc/">RDoc</a> 4.2.1.
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>
|