ruby-postgres 0.7.1.2006.04.05-mswin32 → 0.7.1.2006.04.06-mswin32
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/extconf.rb +1 -1
- data/mkmf.log +0 -56
- data/postgres.c +61 -19
- data/postgres.o +0 -0
- data/postgres.so +0 -0
- data/ruby-postgres.gemspec +1 -1
- data/tests/tc_postgres.rb +4 -4
- metadata +6 -3
data/extconf.rb
CHANGED
@@ -19,7 +19,7 @@ end
|
|
19
19
|
|
20
20
|
dir_config('pgsql', config_value('include'), config_value('lib'))
|
21
21
|
|
22
|
-
required_libraries =
|
22
|
+
required_libraries = []
|
23
23
|
desired_functions = %w(PQsetClientEncoding pg_encoding_to_char PQfreemem)
|
24
24
|
compat_functions = %w(PQescapeString PQexecParams)
|
25
25
|
|
data/mkmf.log
CHANGED
@@ -31,62 +31,6 @@ checked program was:
|
|
31
31
|
|
32
32
|
--------------------
|
33
33
|
|
34
|
-
have_library: checking for main() in -lcrypto... -------------------- no
|
35
|
-
|
36
|
-
"gcc -o conftest -I. -Ic:/mingw/ruby/lib/ruby/1.8/i386-mingw32 -Ic:/apps/POSTGR~1/8.1/include -O2 -pipe conftest.c -L"c:/apps/POSTGR~1/8.1/lib" -L"c:/mingw/ruby/lib" -lpq -lmsvcrt-ruby18-static -lcrypto -lpq -lwsock32 "
|
37
|
-
c:\mingw\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: cannot find -lcrypto
|
38
|
-
collect2: ld returned 1 exit status
|
39
|
-
checked program was:
|
40
|
-
/* begin */
|
41
|
-
|
42
|
-
/*top*/
|
43
|
-
int main() { return 0; }
|
44
|
-
int t() { main(); return 0; }
|
45
|
-
/* end */
|
46
|
-
|
47
|
-
"gcc -o conftest -I. -Ic:/mingw/ruby/lib/ruby/1.8/i386-mingw32 -Ic:/apps/POSTGR~1/8.1/include -O2 -pipe conftest.c -L"c:/apps/POSTGR~1/8.1/lib" -L"c:/mingw/ruby/lib" -lpq -lmsvcrt-ruby18-static -lcrypto -lpq -lwsock32 "
|
48
|
-
c:\mingw\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: cannot find -lcrypto
|
49
|
-
collect2: ld returned 1 exit status
|
50
|
-
checked program was:
|
51
|
-
/* begin */
|
52
|
-
#include <windows.h>
|
53
|
-
#include <winsock.h>
|
54
|
-
|
55
|
-
/*top*/
|
56
|
-
int main() { return 0; }
|
57
|
-
int t() { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
|
58
|
-
/* end */
|
59
|
-
|
60
|
-
--------------------
|
61
|
-
|
62
|
-
have_library: checking for main() in -lssl... -------------------- no
|
63
|
-
|
64
|
-
"gcc -o conftest -I. -Ic:/mingw/ruby/lib/ruby/1.8/i386-mingw32 -Ic:/apps/POSTGR~1/8.1/include -O2 -pipe conftest.c -L"c:/apps/POSTGR~1/8.1/lib" -L"c:/mingw/ruby/lib" -lpq -lmsvcrt-ruby18-static -lssl -lpq -lwsock32 "
|
65
|
-
c:\mingw\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: cannot find -lssl
|
66
|
-
collect2: ld returned 1 exit status
|
67
|
-
checked program was:
|
68
|
-
/* begin */
|
69
|
-
|
70
|
-
/*top*/
|
71
|
-
int main() { return 0; }
|
72
|
-
int t() { main(); return 0; }
|
73
|
-
/* end */
|
74
|
-
|
75
|
-
"gcc -o conftest -I. -Ic:/mingw/ruby/lib/ruby/1.8/i386-mingw32 -Ic:/apps/POSTGR~1/8.1/include -O2 -pipe conftest.c -L"c:/apps/POSTGR~1/8.1/lib" -L"c:/mingw/ruby/lib" -lpq -lmsvcrt-ruby18-static -lssl -lpq -lwsock32 "
|
76
|
-
c:\mingw\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: cannot find -lssl
|
77
|
-
collect2: ld returned 1 exit status
|
78
|
-
checked program was:
|
79
|
-
/* begin */
|
80
|
-
#include <windows.h>
|
81
|
-
#include <winsock.h>
|
82
|
-
|
83
|
-
/*top*/
|
84
|
-
int main() { return 0; }
|
85
|
-
int t() { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
|
86
|
-
/* end */
|
87
|
-
|
88
|
-
--------------------
|
89
|
-
|
90
34
|
have_func: checking for PQsetClientEncoding()... -------------------- yes
|
91
35
|
|
92
36
|
"gcc -o conftest -I. -Ic:/mingw/ruby/lib/ruby/1.8/i386-mingw32 -Ic:/apps/POSTGR~1/8.1/include -O2 -pipe conftest.c -L"c:/apps/POSTGR~1/8.1/lib" -L"c:/mingw/ruby/lib" -lpq -lmsvcrt-ruby18-static -lpq -lwsock32 "
|
data/postgres.c
CHANGED
@@ -78,6 +78,7 @@ static VALUE rb_cPGlarge;
|
|
78
78
|
static VALUE rb_cPGrow;
|
79
79
|
|
80
80
|
static VALUE pgconn_lastval _((VALUE));
|
81
|
+
static VALUE pgconn_close _((VALUE));
|
81
82
|
static VALUE pgresult_fields _((VALUE));
|
82
83
|
static VALUE pgresult_clear _((VALUE));
|
83
84
|
static VALUE pgresult_result_with_clear _((VALUE));
|
@@ -307,7 +308,7 @@ build_key_value_string_i(key, value, result)
|
|
307
308
|
{
|
308
309
|
VALUE key_value;
|
309
310
|
if (key == Qundef) return ST_CONTINUE;
|
310
|
-
key_value = rb_str_dup(key);
|
311
|
+
key_value = (TYPE(key) == T_STRING ? rb_str_dup(key) : rb_obj_as_string(key));
|
311
312
|
rb_str_cat(key_value, "=", 1);
|
312
313
|
rb_str_concat(key_value, pgconn_s_quote(rb_cPGconn, value));
|
313
314
|
rb_ary_push(result, key_value);
|
@@ -443,7 +444,11 @@ pgconn_init(argc, argv, self)
|
|
443
444
|
VALUE *argv;
|
444
445
|
VALUE self;
|
445
446
|
{
|
446
|
-
|
447
|
+
pgconn_connect(argc, argv, self);
|
448
|
+
if (rb_block_given_p()) {
|
449
|
+
return rb_ensure(rb_yield, self, pgconn_close, self);
|
450
|
+
}
|
451
|
+
return self;
|
447
452
|
}
|
448
453
|
|
449
454
|
static PGconn*
|
@@ -464,11 +469,11 @@ get_pgconn(obj)
|
|
464
469
|
* Closes the backend connection.
|
465
470
|
*/
|
466
471
|
static VALUE
|
467
|
-
pgconn_close(
|
468
|
-
VALUE
|
472
|
+
pgconn_close(self)
|
473
|
+
VALUE self;
|
469
474
|
{
|
470
|
-
PQfinish(get_pgconn(
|
471
|
-
DATA_PTR(
|
475
|
+
PQfinish(get_pgconn(self));
|
476
|
+
DATA_PTR(self) = NULL;
|
472
477
|
return Qnil;
|
473
478
|
}
|
474
479
|
|
@@ -500,6 +505,42 @@ get_pgresult(obj)
|
|
500
505
|
PGresult *PQexecParams_compat(PGconn *conn, VALUE command, VALUE values);
|
501
506
|
#endif
|
502
507
|
|
508
|
+
#define TEXT_FORMAT 0
|
509
|
+
#define BINARY_FORMAT 1
|
510
|
+
|
511
|
+
void
|
512
|
+
translate_to_pg(VALUE value, char const** result, int* length, int* format)
|
513
|
+
{
|
514
|
+
switch (TYPE(value)) {
|
515
|
+
case T_NIL:
|
516
|
+
*result = NULL;
|
517
|
+
*length = 0;
|
518
|
+
*format = BINARY_FORMAT;
|
519
|
+
return;
|
520
|
+
case T_TRUE:
|
521
|
+
*result = "\1";
|
522
|
+
*length = 1;
|
523
|
+
*format = BINARY_FORMAT;
|
524
|
+
return;
|
525
|
+
case T_FALSE:
|
526
|
+
*result = "\0";
|
527
|
+
*length = 1;
|
528
|
+
*format = BINARY_FORMAT;
|
529
|
+
return;
|
530
|
+
case T_STRING:
|
531
|
+
*result = StringValuePtr(value);
|
532
|
+
*length = RSTRING(value)->len;
|
533
|
+
*format = BINARY_FORMAT;
|
534
|
+
return;
|
535
|
+
default: {
|
536
|
+
VALUE formatted = pgconn_s_format(rb_cPGconn, value);
|
537
|
+
*result = StringValuePtr(formatted);
|
538
|
+
*length = RSTRING(formatted)->len;
|
539
|
+
*format = TEXT_FORMAT;
|
540
|
+
}
|
541
|
+
}
|
542
|
+
}
|
543
|
+
|
503
544
|
/*
|
504
545
|
* call-seq:
|
505
546
|
* conn.exec(sql, *bind_values)
|
@@ -533,18 +574,13 @@ pgconn_exec(argc, argv, obj)
|
|
533
574
|
int i;
|
534
575
|
#ifdef HAVE_PQEXECPARAMS
|
535
576
|
VALUE* ptr = RARRAY(params)->ptr;
|
536
|
-
|
537
|
-
|
577
|
+
char const** values = ALLOCA_N(char const*, len);
|
578
|
+
int* lengths = ALLOCA_N(int, len);
|
579
|
+
int* formats = ALLOCA_N(int, len);
|
538
580
|
for (i = 0; i < len; i++, ptr++) {
|
539
|
-
|
540
|
-
values[i] = NULL;
|
541
|
-
}
|
542
|
-
else {
|
543
|
-
formatted = pgconn_s_format(rb_cPGconn, *ptr);
|
544
|
-
values[i] = StringValuePtr(formatted);
|
545
|
-
}
|
581
|
+
translate_to_pg(*ptr, values+i, lengths+i, formats+i);
|
546
582
|
}
|
547
|
-
result = PQexecParams(conn, StringValuePtr(command), len, NULL, values,
|
583
|
+
result = PQexecParams(conn, StringValuePtr(command), len, NULL, values, lengths, formats, 0);
|
548
584
|
#else
|
549
585
|
for (i = 0; i < len; i++) {
|
550
586
|
rb_ary_store(params, i, pgconn_s_quote(rb_cPGconn, rb_ary_entry(params, i)));
|
@@ -562,8 +598,15 @@ pgconn_exec(argc, argv, obj)
|
|
562
598
|
case PGRES_COPY_OUT:
|
563
599
|
case PGRES_COPY_IN:
|
564
600
|
case PGRES_EMPTY_QUERY:
|
565
|
-
case PGRES_COMMAND_OK:
|
566
|
-
|
601
|
+
case PGRES_COMMAND_OK: {
|
602
|
+
VALUE pg_result = pgresult_new(result);
|
603
|
+
if (rb_block_given_p()) {
|
604
|
+
return rb_ensure(rb_yield, pg_result, pgresult_clear, pg_result);
|
605
|
+
}
|
606
|
+
else {
|
607
|
+
return pg_result;
|
608
|
+
}
|
609
|
+
}
|
567
610
|
|
568
611
|
case PGRES_BAD_RESPONSE:
|
569
612
|
case PGRES_FATAL_ERROR:
|
@@ -2509,7 +2552,6 @@ Init_postgres()
|
|
2509
2552
|
rb_define_singleton_alias(rb_cPGconn, "open", "connect");
|
2510
2553
|
rb_define_singleton_alias(rb_cPGconn, "setdb", "connect");
|
2511
2554
|
rb_define_singleton_alias(rb_cPGconn, "setdblogin", "connect");
|
2512
|
-
rb_define_singleton_alias(rb_cPGconn, "open", "connect");
|
2513
2555
|
rb_define_singleton_method(rb_cPGconn, "escape", pgconn_s_escape, 1);
|
2514
2556
|
rb_define_singleton_method(rb_cPGconn, "quote", pgconn_s_quote, 1);
|
2515
2557
|
rb_define_singleton_alias(rb_cPGconn, "format", "quote");
|
data/postgres.o
CHANGED
Binary file
|
data/postgres.so
CHANGED
Binary file
|
data/ruby-postgres.gemspec
CHANGED
@@ -6,7 +6,7 @@ SPEC = Gem::Specification.new do |s|
|
|
6
6
|
s.rubyforge_project = 'ruby-postgres'
|
7
7
|
s.version = "0.7.1.#{Date.today}".tr('-', '.')
|
8
8
|
s.summary = 'Ruby extension library providing an API to PostgreSQL'
|
9
|
-
s.
|
9
|
+
s.authors = ['Yukihiro Matsumoto', 'Eiji Matsumoto', 'Noboru Saitou', 'Dave Lee']
|
10
10
|
s.email = 'davelee.com@gmail.com'
|
11
11
|
s.homepage = 'http://ruby.scripting.ca/postgres/'
|
12
12
|
s.requirements = 'PostgreSQL libpq library and headers'
|
data/tests/tc_postgres.rb
CHANGED
@@ -24,13 +24,13 @@ select true as true_value,
|
|
24
24
|
1234.56::numeric(10) as numeric_10_value,
|
25
25
|
12345.12345::numeric(10,5) as numeric_10_5_value
|
26
26
|
EOT
|
27
|
-
res = @conn.exec(query,
|
28
|
-
assert_equal(res.num_tuples, 1)
|
29
|
-
assert_equal(res.num_fields, 10)
|
27
|
+
res = @conn.exec(query, "12345\0TEST")
|
28
|
+
assert_equal(1, res.num_tuples, 1)
|
29
|
+
assert_equal(10, res.num_fields, 10)
|
30
30
|
tuple = res.result.first
|
31
31
|
assert_equal(true, tuple['true_value'])
|
32
32
|
assert_equal(false, tuple['false_value'])
|
33
|
-
assert_equal("
|
33
|
+
assert_equal("12345\0TEST", tuple['bytea_value'])
|
34
34
|
assert_equal(Date.parse('2005-11-30'), tuple['date_value'])
|
35
35
|
assert_equal(Time.parse('12:00:00'), tuple['time_value'])
|
36
36
|
assert_equal(Time.parse('2005-11-30 12:00:00'), tuple['date_time_value'])
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: ruby-postgres
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.7.1.2006.04.
|
7
|
-
date: 2006-04-
|
6
|
+
version: 0.7.1.2006.04.06
|
7
|
+
date: 2006-04-06 00:00:00 -06:00
|
8
8
|
summary: Ruby extension library providing an API to PostgreSQL
|
9
9
|
require_paths:
|
10
10
|
- .
|
@@ -26,7 +26,10 @@ platform: mswin32
|
|
26
26
|
signing_key:
|
27
27
|
cert_chain:
|
28
28
|
authors:
|
29
|
-
- Yukihiro Matsumoto
|
29
|
+
- Yukihiro Matsumoto
|
30
|
+
- Eiji Matsumoto
|
31
|
+
- Noboru Saitou
|
32
|
+
- Dave Lee
|
30
33
|
files:
|
31
34
|
- ChangeLog
|
32
35
|
- Contributors
|