qoobaa-pg 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +10 -0
- data/.gitignore +5 -0
- data/BSD +23 -0
- data/ChangeLog +266 -0
- data/Contributors +29 -0
- data/GPL +340 -0
- data/LICENSE +58 -0
- data/README +125 -0
- data/Rakefile +50 -0
- data/VERSION +1 -0
- data/doc/postgres.html +278 -0
- data/doc/postgres.jp.html +256 -0
- data/ext/compat.c +541 -0
- data/ext/compat.h +180 -0
- data/ext/extconf.rb +87 -0
- data/ext/mingw/Rakefile +24 -0
- data/ext/mingw/build.rake +40 -0
- data/ext/mkmf.log +316 -0
- data/ext/mkrf_config.rb +138 -0
- data/ext/pg.c +3569 -0
- data/ext/pg.h +60 -0
- data/ext/vc/pg.sln +26 -0
- data/ext/vc/pg_18/pg.vcproj +216 -0
- data/ext/vc/pg_19/pg_19.vcproj +209 -0
- data/pg.gemspec +73 -0
- data/sample/losample.rb +47 -0
- data/sample/psql.rb +1181 -0
- data/sample/psqlHelp.rb +158 -0
- data/sample/test1.rb +63 -0
- data/sample/test2.rb +44 -0
- data/sample/test4.rb +71 -0
- data/spec/data/expected_trace.out +26 -0
- data/spec/data/random_binary_data +0 -0
- data/spec/pgconn_spec.rb +130 -0
- data/spec/pgresult_spec.rb +112 -0
- metadata +90 -0
data/LICENSE
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.co.jp>.
|
2
|
+
You can redistribute it and/or modify it under either the terms of the GPL
|
3
|
+
(see COPYING.txt file), or the conditions below:
|
4
|
+
|
5
|
+
1. You may make and give away verbatim copies of the source form of the
|
6
|
+
software without restriction, provided that you duplicate all of the
|
7
|
+
original copyright notices and associated disclaimers.
|
8
|
+
|
9
|
+
2. You may modify your copy of the software in any way, provided that
|
10
|
+
you do at least ONE of the following:
|
11
|
+
|
12
|
+
a) place your modifications in the Public Domain or otherwise
|
13
|
+
make them Freely Available, such as by posting said
|
14
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
15
|
+
the author to include your modifications in the software.
|
16
|
+
|
17
|
+
b) use the modified software only within your corporation or
|
18
|
+
organization.
|
19
|
+
|
20
|
+
c) rename any non-standard executables so the names do not conflict
|
21
|
+
with standard executables, which must also be provided.
|
22
|
+
|
23
|
+
d) make other distribution arrangements with the author.
|
24
|
+
|
25
|
+
3. You may distribute the software in object code or executable
|
26
|
+
form, provided that you do at least ONE of the following:
|
27
|
+
|
28
|
+
a) distribute the executables and library files of the software,
|
29
|
+
together with instructions (in the manual page or equivalent)
|
30
|
+
on where to get the original distribution.
|
31
|
+
|
32
|
+
b) accompany the distribution with the machine-readable source of
|
33
|
+
the software.
|
34
|
+
|
35
|
+
c) give non-standard executables non-standard names, with
|
36
|
+
instructions on where to get the original software distribution.
|
37
|
+
|
38
|
+
d) make other distribution arrangements with the author.
|
39
|
+
|
40
|
+
4. You may modify and include the part of the software into any other
|
41
|
+
software (possibly commercial). But some files in the distribution
|
42
|
+
are not written by the author, so that they are not under this terms.
|
43
|
+
|
44
|
+
They are gc.c(partly), utils.c(partly), regex.[ch], st.[ch] and some
|
45
|
+
files under the ./missing directory. See each file for the copying
|
46
|
+
condition.
|
47
|
+
|
48
|
+
5. The scripts and library files supplied as input to or produced as
|
49
|
+
output from the software do not automatically fall under the
|
50
|
+
copyright of the software, but belong to whomever generated them,
|
51
|
+
and may be sold commercially, and may be aggregated with this
|
52
|
+
software.
|
53
|
+
|
54
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
55
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
56
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
57
|
+
PURPOSE.
|
58
|
+
|
data/README
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
================================================================================
|
2
|
+
ruby-pg: Ruby interface to PostgreSQL RDBMS
|
3
|
+
================================================================================
|
4
|
+
|
5
|
+
This library is copyrighted by the authors.
|
6
|
+
|
7
|
+
Authors:
|
8
|
+
* Yukihiro Matsumoto <matz@ruby-lang.org>
|
9
|
+
Author of Ruby.
|
10
|
+
* Eiji Matsumoto <usagi@ruby.club.or.jp>
|
11
|
+
One of users who loves Ruby.
|
12
|
+
* Jeff Davis <ruby-pg@j-davis.com>
|
13
|
+
|
14
|
+
Thanks to:
|
15
|
+
* Noboru Saitou <noborus@netlab.jp>
|
16
|
+
Past maintainer.
|
17
|
+
* Dave Lee
|
18
|
+
Past maintainer.
|
19
|
+
* Guy Decoux ts <decoux@moulon.inra.fr>
|
20
|
+
|
21
|
+
Maintainer:
|
22
|
+
Jeff Davis <ruby-pg@j-davis.com>
|
23
|
+
|
24
|
+
Copying:
|
25
|
+
You may redistribute this software under the terms of the Ruby license,
|
26
|
+
included in the file "LICENSE". The Ruby license also allows distribution
|
27
|
+
under the terms of the GPL, included in the file "COPYING.txt" and the
|
28
|
+
file "GPL".
|
29
|
+
|
30
|
+
Portions of the code are from the PostgreSQL project, and are distributed
|
31
|
+
under the terms of the BSD license, included in the file "BSD".
|
32
|
+
|
33
|
+
- Summary
|
34
|
+
|
35
|
+
This is the extension library to access a PostgreSQL database from Ruby.
|
36
|
+
This library works with PostgreSQL 7.4 and later.
|
37
|
+
|
38
|
+
- Requirements
|
39
|
+
|
40
|
+
Ruby 1.8 or later.
|
41
|
+
PostgreSQL 7.3 or later installed.
|
42
|
+
|
43
|
+
It may work with earlier versions as well, but those are
|
44
|
+
not regularly tested.
|
45
|
+
|
46
|
+
- How to install ?
|
47
|
+
|
48
|
+
Follow the instructions below to compile and install:
|
49
|
+
|
50
|
+
ruby extconf.rb
|
51
|
+
make
|
52
|
+
su (if necessary)
|
53
|
+
make install
|
54
|
+
|
55
|
+
You may need to specify the directory name for the include files and the
|
56
|
+
-lpq library by using
|
57
|
+
|
58
|
+
--with-pgsql-include=<include file directory>
|
59
|
+
--with-pgsql-lib=<library directory>
|
60
|
+
|
61
|
+
For example:
|
62
|
+
|
63
|
+
ruby extconf.rb --with-pgsql-include=/usr/local/pgsql/include \
|
64
|
+
--with-pgsql-lib=/usr/local/pgsql/lib
|
65
|
+
|
66
|
+
- Modules
|
67
|
+
|
68
|
+
'pg': The 'pg' module is the newer module, that has been greatly improved, and
|
69
|
+
is almost a complete rewrite. It is not backwards compatible. Use this module
|
70
|
+
for newly written code. It should be more stable, less buggy, and has more
|
71
|
+
features.
|
72
|
+
|
73
|
+
'postgres': Older module, maintained for backwards compatibility. It
|
74
|
+
has known flaws that aren't reasonably fixable without breaking backwards
|
75
|
+
compatibility. Use this module if you have code that already works, and
|
76
|
+
you just want the fixes that I've committed to this module (for instance,
|
77
|
+
this module is compatible with PostgreSQL 8.3).
|
78
|
+
|
79
|
+
- How to use ?
|
80
|
+
|
81
|
+
This gem builds and installs two PostgreSQL database adapters, 'postgres'
|
82
|
+
and 'pg'.
|
83
|
+
|
84
|
+
The standard way to download and install the most current stable
|
85
|
+
version of the postgres gem (from http://gems.rubyforge.org) is to use
|
86
|
+
the RubyGem package manager. You may need to supply RubyGem with the
|
87
|
+
location of the libpq library and the libpq.h and libpq/libpq-fs.h
|
88
|
+
files, and may need to run as root.
|
89
|
+
If you installed from source on a Unix system you can locate these
|
90
|
+
libpq files with:
|
91
|
+
find <path to install directory> -name "libpq-fe.h" -print
|
92
|
+
With binary distributions, you may need to install additional
|
93
|
+
PostgreSQL development libraries to get these files.
|
94
|
+
|
95
|
+
Then run:
|
96
|
+
sudo gem install postgres -- --with-pgsql-include-dir=<location of
|
97
|
+
Postgresql>/include --with-pgsql-lib-dir=<location of Postgresql/lib
|
98
|
+
|
99
|
+
Example:
|
100
|
+
on Mac OS X with PostgreSQL in /Library/PostgreSQL8 use
|
101
|
+
--with-pgsql-include-dir=/Library/PostgreSQL8/include --with-pgsql-lib-
|
102
|
+
dir=/Library/PostgreSQL8/lib
|
103
|
+
|
104
|
+
To use the module with Rails:
|
105
|
+
refer to it as
|
106
|
+
adapter: postgresql
|
107
|
+
in your database:yaml file
|
108
|
+
|
109
|
+
To use these modules in Ruby directly (not Rails), refer to the RDoc
|
110
|
+
documentation.
|
111
|
+
|
112
|
+
- Acknowledgments
|
113
|
+
|
114
|
+
We are thankful to the people at the ruby-list and ruby-dev mailing lists.
|
115
|
+
And to the people who developed PostgreSQL.
|
116
|
+
|
117
|
+
- Copying
|
118
|
+
|
119
|
+
This library is copyrighted by its authors; Yukihiro Matsumoto, and Eiji
|
120
|
+
Matsumoto.
|
121
|
+
|
122
|
+
Portions copyright Laika, Inc.
|
123
|
+
|
124
|
+
|
125
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rake'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'jeweler'
|
7
|
+
Jeweler::Tasks.new do |gem|
|
8
|
+
gem.name = "pg"
|
9
|
+
gem.summary = %Q{provides the module "pg", a Ruby interface to the PostgreSQL}
|
10
|
+
gem.email = "qoobaa@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/qoobaa/pg"
|
12
|
+
gem.authors = ["Jakub Kuźma"]
|
13
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
14
|
+
gem.extensions << 'ext/extconf.rb'
|
15
|
+
end
|
16
|
+
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'spec/rake/spectask'
|
22
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
23
|
+
spec.libs << 'lib' << 'spec'
|
24
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
25
|
+
end
|
26
|
+
|
27
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
28
|
+
spec.libs << 'lib' << 'spec'
|
29
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
30
|
+
spec.rcov = true
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
task :default => :spec
|
35
|
+
|
36
|
+
require 'rake/rdoctask'
|
37
|
+
Rake::RDocTask.new do |rdoc|
|
38
|
+
if File.exist?('VERSION.yml')
|
39
|
+
config = YAML.load(File.read('VERSION.yml'))
|
40
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
41
|
+
else
|
42
|
+
version = ""
|
43
|
+
end
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "ruby-pg #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
50
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.8.1
|
data/doc/postgres.html
ADDED
@@ -0,0 +1,278 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
2
|
+
"http://www.w3.org/TR/html4/strict.dtd">
|
3
|
+
<html lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
6
|
+
<meta http-equiv="Content-Style-Type" content="text/css">
|
7
|
+
<meta name="Keywords" lang="en" content="Ruby PostgreSQL">
|
8
|
+
<link rev="made" href="mailto:noborus@netlab.jp">
|
9
|
+
<style type="text/css">
|
10
|
+
<!--
|
11
|
+
body {
|
12
|
+
background-color: white;
|
13
|
+
color: black;
|
14
|
+
}
|
15
|
+
address { text-align: right }
|
16
|
+
div.lastmodifed { text-align: right }
|
17
|
+
div.language { text-align: right }
|
18
|
+
pre {
|
19
|
+
white-space: pre;
|
20
|
+
background-color: antiquewhite;
|
21
|
+
border: inset thin;
|
22
|
+
}
|
23
|
+
-->
|
24
|
+
</style>
|
25
|
+
<title>Postgres reference</title>
|
26
|
+
</head>
|
27
|
+
<body>
|
28
|
+
<div class = "language">
|
29
|
+
[English | <a href="postgres.jp.html">Japanese</a>]
|
30
|
+
</div>
|
31
|
+
<h1><a name="reference">Postgres reference</a></h1>
|
32
|
+
<div class = "lastmodifed">
|
33
|
+
Last update: Sun, 4 Mar 2001 15:40:08 +0000
|
34
|
+
</div>
|
35
|
+
<hr>
|
36
|
+
<div>
|
37
|
+
<h2><a name="PGconn">PGconn</a></h2>
|
38
|
+
<p>
|
39
|
+
The class to access PostgreSQL database. All other functionality of libpq
|
40
|
+
save the large object to a file.
|
41
|
+
</p>
|
42
|
+
<p>
|
43
|
+
For example, to send query to the database on the localhost.
|
44
|
+
</p>
|
45
|
+
<pre>
|
46
|
+
require "postgres"
|
47
|
+
conn = PGconn.connect("localhost", 5432, "", "", "test1")
|
48
|
+
# or: conn = PGconn.open('dbname=test1')
|
49
|
+
res = conn.exec("select * from a;")
|
50
|
+
</pre>
|
51
|
+
<h3>super class:</h3>
|
52
|
+
<code>Object</code>
|
53
|
+
<h3>class methods:</h3>
|
54
|
+
<p>
|
55
|
+
<a name="PGconn.connect"><code>connect(<var>pghost</var>,
|
56
|
+
<var>pgport</var>, <var>pgoptions</var>,
|
57
|
+
<var>pgtty</var>, <var>dbname</var>, <var>login</var>,
|
58
|
+
<var>passwd</var>)</code></a>
|
59
|
+
<a name="PGconn.new"><code>new(<var>pghost</var>,
|
60
|
+
<var>pgport</var>, <var>pgoptions</var>,
|
61
|
+
<var>pgtty</var>, <var>dbname</var>, <var>login</var>,
|
62
|
+
<var>passwd</var>)</code></a>
|
63
|
+
<a name="PGconn.open"><code>open(<var>string</var>)</code></a>
|
64
|
+
</p>
|
65
|
+
<dl>
|
66
|
+
<dt>Connect to the PostgreSQL server. Options are:</dt>
|
67
|
+
<dd><var>pghost</var> : Server hostname(string)
|
68
|
+
<dd><var>pgport</var> : Server port number(integer)
|
69
|
+
<dd><var>pgoptions</var> : backend options(string)
|
70
|
+
<dd><var>pgtty</var> : tty to print backend debug message(string)
|
71
|
+
<dd><var>dbname</var> : connecting database name(string)
|
72
|
+
<dd><var>login</var> : login user name(string)
|
73
|
+
<dd><var>passwd</var> : login password(string)
|
74
|
+
<dt>Options in string format (separated by whitespace) are:</dt>
|
75
|
+
<dd><var>host=name</var> : Server hostname(string) (defaults to localhost)
|
76
|
+
<dd><var>hostaddr=addr</var> : Server host IP address(string)
|
77
|
+
<dd><var>port=number</var> : Server port number(integer) (default: 5432)
|
78
|
+
<dd><var>options=string</var> : backend options(string) (sent to server, not well explained)
|
79
|
+
<dd><var>tty=anything</var> : ignored, used to be debug TTY(string)
|
80
|
+
<dd><var>dbname=name</var> : connecting database name(string) (default: your username)
|
81
|
+
<dd><var>user=username</var> : login user name(string) (default: your username)
|
82
|
+
<dd><var>password=censored</var> : login password(string)
|
83
|
+
<dd><var>sslmode=mode</var> : how to treat SSL(string) (one of disable, allow, prefer, require)
|
84
|
+
<dd><var>service=name</var> : service name in pg_service.conf(string)
|
85
|
+
<dd><var>connect_timeout=seconds</var> : how long to wait for a connection(integer) (0 means forever)
|
86
|
+
</dl>
|
87
|
+
<p>On failure, it raises <code>PGError</code> exception.</p>
|
88
|
+
<h3>methods:</h3>
|
89
|
+
<dl>
|
90
|
+
<dt><a name="db"><code>db</code></a>
|
91
|
+
<dd>Returns the connected database name.
|
92
|
+
<dt><a name="host"><code>host</code></a>
|
93
|
+
<dd>Returns the connected server name.
|
94
|
+
<dt><a name="user"><code>user</code></a>
|
95
|
+
<dd>Returns the authenticated user name.
|
96
|
+
<dt><a name="options"><code>options</code></a>
|
97
|
+
<dd>Returns backend option string.
|
98
|
+
<dt><a name="port"><code>port</code></a>
|
99
|
+
<dd>Returns the connected server port number.
|
100
|
+
<dt><a name="tty"><code>tty</code></a>
|
101
|
+
<dd>Returns the connected pgtty.
|
102
|
+
<dt><a name="error"><code>error</code></a>
|
103
|
+
<dd>Returns the error message about connection.
|
104
|
+
<dt> <a name="finish"><code>finish</code></a>
|
105
|
+
<dt> <a name="close"><code>close</code></a>
|
106
|
+
<dd>Closes the backend connection.
|
107
|
+
<dt><a name="reset"><code>reset</code></a>
|
108
|
+
<dd>Resets the backend connection. This method closes the backend
|
109
|
+
connection and tries to re-connect.
|
110
|
+
<dt><a name="trace"><code>trace(<var>port</var>)</code></a>
|
111
|
+
<dd>Enables tracing message passing between backend. The trace
|
112
|
+
message will be written to the port object, which is the
|
113
|
+
instance of the class File.
|
114
|
+
<dt><a name="untrace"><code>untrace</code></a>
|
115
|
+
<dd>Disables the message tracing.
|
116
|
+
<dt><a name="exec"><code>exec(<var>sql</var>)</code></a>
|
117
|
+
<dd>Sends SQL query request specified by <var>sql</var> to the
|
118
|
+
PostgreSQL. Returns the <a href="#PGresult">PGresult</a>
|
119
|
+
instance on success. On failure, it raises <code>PGError</code>
|
120
|
+
exception.
|
121
|
+
<dt><a name="query"><code>query(<var>sql</var>)</code></a>
|
122
|
+
<dd>Sends SQL query request specified by <var>sql</var> to the
|
123
|
+
PostgreSQL.Returns an Array as the resulting tuple on success.
|
124
|
+
On failure, it returns nil, and error detail can be obtained
|
125
|
+
by error.
|
126
|
+
<dt><a name="async_exec"><code>async_exec(<var>sql</var>)</code></a>
|
127
|
+
<dd>Sends SQL asynchronous query request specified by <var>sql</var>
|
128
|
+
to the PostgreSQL. Returns the <a href="#PGresult">PGresult</a>
|
129
|
+
instance on success. On failure, it raises <code>PGError</code>
|
130
|
+
exception.
|
131
|
+
<dt><a name="async_query"><code>async_query(<var>sql</var>)</code></a>
|
132
|
+
<dd>Sends SQL asynchronous query request specified by <var>sql</var>
|
133
|
+
to the PostgreSQL.Returns an Array as the resulting tuple on
|
134
|
+
success. On failure, it returns nil, and error detail can be
|
135
|
+
obtained by error.
|
136
|
+
<dt><a name="get_notify"><code>get_notify</code></a>
|
137
|
+
<dd>Returns the array of the unprocessed notifiers.
|
138
|
+
If there is no unprocessed notifier, it returns nil.
|
139
|
+
<dt><a name="insert_table"><code>insert_table(<var>table</var>,
|
140
|
+
<var>array</var>)</code></a>
|
141
|
+
<dd>Inserts contents of the <var>array</var> into the
|
142
|
+
<var>table</var>.
|
143
|
+
<dt><a name="getline"><code>getline</code></a>
|
144
|
+
<dd>Reads a line from the backend server into internal buffer.
|
145
|
+
Returns nil for EOF, 0 for success, 1 for buffer overflowed.
|
146
|
+
You need to ensure single "." from backend to confirm
|
147
|
+
transmission completion. The sample program <a href="../sample/psql.rb">psql.rb</a>
|
148
|
+
treats this copy protocol right.
|
149
|
+
<dt><a name="putline"><code>putline(<var>string</var>)</code></a>
|
150
|
+
<dd>Sends the <var>string</var> to the backend server.
|
151
|
+
Users must send a single "." to denote the end of data transmission.
|
152
|
+
<dt><a name="endcopy"><code>endcopy</code></a>
|
153
|
+
<dd>Waits until the backend completes the copying. You should call
|
154
|
+
this method after putline, or getline.Returns nil on success,
|
155
|
+
raises an exception otherwise.
|
156
|
+
<dt><a name="set_client_encoding"><code>set_client_encoding</code></a>
|
157
|
+
<dd>Set client encoding(String).
|
158
|
+
<dt><a name="client_encoding"><code>client_encoding</code></a>
|
159
|
+
<dd>Returns client encoding(String).
|
160
|
+
<dt><a name="set_notice_processor"><code>set_notice_processor(proc)</code></a>
|
161
|
+
<dd>Control reporting of notice and warning messages generated by the
|
162
|
+
backend server (with Proc or anything else responding to :call).
|
163
|
+
Pass nil to disable processing of the messages.
|
164
|
+
|
165
|
+
<dt><a name="lo_import"><code>lo_import(<var>file</var>)</code></a>
|
166
|
+
<dd>Import a <var>file</var> to a large object. Return the <a href="#PGlarge">PGlarge</a> instance on success. On failure, it raises <code>PGError</code> exception.
|
167
|
+
<dt><a name="lo_export"><code>lo_export(<var>oid</var>, <var>file</var>)</code></a>
|
168
|
+
<dd>Save a large object of oid to a <var>file</var>.
|
169
|
+
<dt><a name="lo_create"><code>lo_create([<var>mode</var>])</code></a>
|
170
|
+
<dd>Return the <a href="#PGlarge">PGlarge</a> instance on success. On failure, it raises <code>PGError</code> exception.
|
171
|
+
<dt><a name="lo_open"><code>lo_open(<var>oid</var>, [<var>mode</var>])</code></a>
|
172
|
+
<dd>Open a large object of oid. Return the <a href="#PGlarge">PGlarge</a> instance on success. The mode argument specifies the mode for the opened large object, which is either <var>"INV_READ"</var>, or <var>"INV_WRITE"</var>. If mode On failure, it raises <code>PGError</code> exception. If mode omitted, the default is <var>"INV_READ"</var>
|
173
|
+
<dt><a name="lo_unlink"><code>lo_unlink(<var>oid</var>)</code></a>
|
174
|
+
<dd>Unlink (deletes) the postgres large object of oid.
|
175
|
+
</dl>
|
176
|
+
</div>
|
177
|
+
<hr>
|
178
|
+
<div>
|
179
|
+
<h2><a name="PGresult">PGresult</a></h2>
|
180
|
+
<P>
|
181
|
+
The class to represent the query result tuples. The object of this
|
182
|
+
class is created as the result of every query. You may need to invoke
|
183
|
+
clear method for the finished object for better memory performance.
|
184
|
+
</P>
|
185
|
+
<h3>super class:</h3>
|
186
|
+
<p>
|
187
|
+
<code>Object</code>
|
188
|
+
</p>
|
189
|
+
<h2>methods:</h2>
|
190
|
+
<dl>
|
191
|
+
<dt><a name="status"><code>status</code></a>
|
192
|
+
<dd><dl>
|
193
|
+
<dt>Returns the status of the query. The status value is
|
194
|
+
either:
|
195
|
+
<dd>EMPTY_QUERY
|
196
|
+
<dd>COMMAND_OK
|
197
|
+
<dd>TUPLES_OK
|
198
|
+
<dd>COPY_OUT
|
199
|
+
<dd>COPY_IN
|
200
|
+
</dl>
|
201
|
+
<dt><a name="result"><code>result</code></a>
|
202
|
+
<dd>Returns the query result tuple in the array.
|
203
|
+
<dt><a name="fields"><code>fields</code></a>
|
204
|
+
<dd>Returns the array of the fields of the query result.
|
205
|
+
<dt><a name="num_tuples"><code>num_tuples</code></a>
|
206
|
+
<dd>Returns the number of tuples of the query result.
|
207
|
+
<dt><a name="num_fields"><code>num_fields</code></a>
|
208
|
+
<dd>Returns the number of fields of the query result.
|
209
|
+
<dt><a name="fieldname"><code>fieldname(<var>index</var>)</code></a>
|
210
|
+
<dd>Returns the field name corresponding field index.
|
211
|
+
<dt><a name="fieldnum"><code>fieldnum(<var>name</var>)</code></a>
|
212
|
+
<dd>Returns the index of the <var>name</var>ed field.
|
213
|
+
<dt><a name="type"><code>type(<var>index</var>)</code></a>
|
214
|
+
<dd>Returns the integer corresponding the type of the field.
|
215
|
+
The field indicator starts from zero.
|
216
|
+
<dt><a name="size"><code>size(<var>index</var>)</code></a>
|
217
|
+
<dd>Returns the size of the field in bytes.
|
218
|
+
Returns <code>-1</code> if the field is variable sized.
|
219
|
+
<dt><a name="getvalue"><code>getvalue(<var>tup_num, field_num</var>)
|
220
|
+
</code></a>
|
221
|
+
<dd>Returns the field value.
|
222
|
+
<dt><a name="getlength"><code>getlength(<var>tup_num, field_num</var>)
|
223
|
+
</code></a>
|
224
|
+
<dd>Returns the length of the field in bytes.
|
225
|
+
<dt><a name="cmdstatus"><code>cmdtuples</code></a>
|
226
|
+
<dd>the number of tuples (rows) affected by the SQL command.
|
227
|
+
<dt><a name="cmdstatus"><code>cmdstatus</code></a>
|
228
|
+
<dd>Returns the status string of the last query command.
|
229
|
+
<dt><a name="oid"><code>oid</code></a>
|
230
|
+
<dd>Returns the oid of the inserted row, or <code>nil</code> if
|
231
|
+
the last statement was not an <code>INSERT</code>
|
232
|
+
<dt><a name="clear"><code>clear</code></a>
|
233
|
+
<dd>Clears the <a href="#PGresult">PGresult</a> object as the result
|
234
|
+
of the query.
|
235
|
+
</dl>
|
236
|
+
</div>
|
237
|
+
<hr>
|
238
|
+
<div>
|
239
|
+
<h2><a name="PGlarge">PGlarge</a></h2>
|
240
|
+
<P>
|
241
|
+
The class to access large objects. The object of this class is created as the
|
242
|
+
result of <a href="#lo_import">lo_import</a>, <a href="#lo_create">lo_create</a>, and <a href="#lo_open">lo_open</a>.
|
243
|
+
</P>
|
244
|
+
<h3>super class:</h3>
|
245
|
+
<p>
|
246
|
+
<code>Object</code>
|
247
|
+
</p>
|
248
|
+
<h2>methods:</h2>
|
249
|
+
<dl>
|
250
|
+
<dt><a name="open"><code>open([<var>mode</var>])</code></a>
|
251
|
+
<dd>Open a large object. The mode argument specifies the mode for the opened large object, which is either <var>"INV_READ"</var>,<var>"INV_READ"</var>.
|
252
|
+
<dt><a name="close"><code>close</code></a>
|
253
|
+
<dd>Close a large object. Closed when they are garbage-collected.
|
254
|
+
<dt><a name="read"><code>read([<var>length</var>])</code></a>
|
255
|
+
<dd>Attempts to read <var>length</var> bytes from large object. If no <var>length</var> given, reads all data.
|
256
|
+
<dt><a name="write"><code>write(<var>str</var>)</code></a>
|
257
|
+
<dd>Write the string to the large object. Return the number of bytes written.
|
258
|
+
<dt><a name="seek"><code>seek(<var>offset</var>, <var>whence</var>)</code></a>
|
259
|
+
<dd>Move the large object pointer to the <var>offset</var>. The value for <var>whence</var> are SEEK_SET, SEEK_CUR, and SEEK_END.Or it is 0,1,2.
|
260
|
+
<dt><a name="tell"><code>tell</code></a>
|
261
|
+
<dd>Return the current position of the large object pointer.
|
262
|
+
<dt><a name="unlink"><code>unlink</code></a>
|
263
|
+
<dd>Delete large object.
|
264
|
+
<dt><a name="oid"><code>oid</code></a>
|
265
|
+
<dd>Return the large object oid.
|
266
|
+
<dt><a name="size"><code>size</code></a>
|
267
|
+
<dd>Return the size of large object.
|
268
|
+
<dt><a name="export"><code>export(<var>file</var>)</code></a>
|
269
|
+
<dd>Save a large object of oid to a <var>file</var>.
|
270
|
+
</dl>
|
271
|
+
</div>
|
272
|
+
<hr>
|
273
|
+
<address>
|
274
|
+
mailto:
|
275
|
+
<a href="mailto:noborus@netlab.jp">Noboru Saitou</a>
|
276
|
+
</address>
|
277
|
+
</body>
|
278
|
+
</html>
|