pg 0.12.0 → 0.16.0
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.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +2 -0
- data/BSDL +22 -0
- data/ChangeLog +1504 -11
- data/Contributors.rdoc +7 -0
- data/History.rdoc +181 -3
- data/LICENSE +12 -14
- data/Manifest.txt +29 -15
- data/{BSD → POSTGRES} +0 -0
- data/{README.OS_X.rdoc → README-OS_X.rdoc} +0 -0
- data/{README.windows.rdoc → README-Windows.rdoc} +0 -0
- data/README.ja.rdoc +10 -3
- data/README.rdoc +54 -28
- data/Rakefile +53 -26
- data/Rakefile.cross +235 -196
- data/ext/errorcodes.def +931 -0
- data/ext/errorcodes.rb +45 -0
- data/ext/errorcodes.txt +463 -0
- data/ext/extconf.rb +37 -7
- data/ext/gvl_wrappers.c +19 -0
- data/ext/gvl_wrappers.h +211 -0
- data/ext/pg.c +317 -4277
- data/ext/pg.h +124 -21
- data/ext/pg_connection.c +3642 -0
- data/ext/pg_errors.c +89 -0
- data/ext/pg_result.c +920 -0
- data/lib/pg/connection.rb +86 -0
- data/lib/pg/constants.rb +11 -0
- data/lib/pg/exceptions.rb +11 -0
- data/lib/pg/result.rb +16 -0
- data/lib/pg.rb +26 -43
- data/sample/array_insert.rb +20 -0
- data/sample/async_api.rb +21 -24
- data/sample/async_copyto.rb +2 -2
- data/sample/async_mixed.rb +56 -0
- data/sample/check_conn.rb +21 -0
- data/sample/copyfrom.rb +1 -1
- data/sample/copyto.rb +1 -1
- data/sample/cursor.rb +2 -2
- data/sample/disk_usage_report.rb +186 -0
- data/sample/issue-119.rb +94 -0
- data/sample/losample.rb +6 -6
- data/sample/minimal-testcase.rb +17 -0
- data/sample/notify_wait.rb +51 -22
- data/sample/pg_statistics.rb +294 -0
- data/sample/replication_monitor.rb +231 -0
- data/sample/test_binary_values.rb +4 -6
- data/sample/wal_shipper.rb +434 -0
- data/sample/warehouse_partitions.rb +320 -0
- data/spec/lib/helpers.rb +70 -23
- data/spec/pg/connection_spec.rb +1128 -0
- data/spec/{pgresult_spec.rb → pg/result_spec.rb} +142 -47
- data/spec/pg_spec.rb +44 -0
- data.tar.gz.sig +0 -0
- metadata +145 -100
- metadata.gz.sig +0 -0
- data/GPL +0 -340
- data/ext/compat.c +0 -541
- data/ext/compat.h +0 -184
- data/misc/openssl-pg-segfault.rb +0 -31
- data/sample/psql.rb +0 -1181
- data/sample/psqlHelp.rb +0 -158
- data/sample/test1.rb +0 -60
- data/sample/test2.rb +0 -44
- data/sample/test4.rb +0 -71
- data/spec/m17n_spec.rb +0 -151
- data/spec/pgconn_spec.rb +0 -643
data/ext/pg_errors.c
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
/*
|
2
|
+
* pg_errors.c - Definition and lookup of error classes.
|
3
|
+
*
|
4
|
+
*/
|
5
|
+
|
6
|
+
#include "pg.h"
|
7
|
+
|
8
|
+
VALUE rb_hErrors;
|
9
|
+
VALUE rb_ePGerror;
|
10
|
+
VALUE rb_eServerError;
|
11
|
+
VALUE rb_eUnableToSend;
|
12
|
+
VALUE rb_eConnectionBad;
|
13
|
+
|
14
|
+
static VALUE
|
15
|
+
define_error_class(const char *name, const char *baseclass_code)
|
16
|
+
{
|
17
|
+
VALUE baseclass = rb_eServerError;
|
18
|
+
if(baseclass_code)
|
19
|
+
{
|
20
|
+
baseclass = rb_hash_aref( rb_hErrors, rb_str_new2(baseclass_code) );
|
21
|
+
}
|
22
|
+
return rb_define_class_under( rb_mPG, name, baseclass );
|
23
|
+
}
|
24
|
+
|
25
|
+
static void
|
26
|
+
register_error_class(const char *code, VALUE klass)
|
27
|
+
{
|
28
|
+
rb_hash_aset( rb_hErrors, rb_str_new2(code), klass );
|
29
|
+
}
|
30
|
+
|
31
|
+
/* Find a proper error class for the given SQLSTATE string
|
32
|
+
*/
|
33
|
+
VALUE
|
34
|
+
lookup_error_class(const char *sqlstate)
|
35
|
+
{
|
36
|
+
VALUE klass;
|
37
|
+
|
38
|
+
if(sqlstate)
|
39
|
+
{
|
40
|
+
/* Find the proper error class by the 5-characters SQLSTATE. */
|
41
|
+
klass = rb_hash_aref( rb_hErrors, rb_str_new2(sqlstate) );
|
42
|
+
if(NIL_P(klass))
|
43
|
+
{
|
44
|
+
/* The given SQLSTATE couldn't be found. This might happen, if
|
45
|
+
* the server side uses a newer version than the client.
|
46
|
+
* Try to find a error class by using the 2-characters SQLSTATE.
|
47
|
+
*/
|
48
|
+
klass = rb_hash_aref( rb_hErrors, rb_str_new(sqlstate, 2) );
|
49
|
+
if(NIL_P(klass))
|
50
|
+
{
|
51
|
+
/* Also the 2-characters SQLSTATE is unknown.
|
52
|
+
* Use the generic server error instead.
|
53
|
+
*/
|
54
|
+
klass = rb_eServerError;
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}
|
58
|
+
else
|
59
|
+
{
|
60
|
+
/* Unable to retrieve the PG_DIAG_SQLSTATE.
|
61
|
+
* Use the generic error instead.
|
62
|
+
*/
|
63
|
+
klass = rb_eUnableToSend;
|
64
|
+
}
|
65
|
+
|
66
|
+
return klass;
|
67
|
+
}
|
68
|
+
|
69
|
+
void
|
70
|
+
init_pg_errors()
|
71
|
+
{
|
72
|
+
rb_hErrors = rb_hash_new();
|
73
|
+
rb_define_const( rb_mPG, "ERROR_CLASSES", rb_hErrors );
|
74
|
+
|
75
|
+
rb_ePGerror = rb_define_class_under( rb_mPG, "Error", rb_eStandardError );
|
76
|
+
|
77
|
+
/*************************
|
78
|
+
* PG::Error
|
79
|
+
*************************/
|
80
|
+
rb_define_alias( rb_ePGerror, "error", "message" );
|
81
|
+
rb_define_attr( rb_ePGerror, "connection", 1, 0 );
|
82
|
+
rb_define_attr( rb_ePGerror, "result", 1, 0 );
|
83
|
+
|
84
|
+
rb_eServerError = rb_define_class_under( rb_mPG, "ServerError", rb_ePGerror );
|
85
|
+
rb_eUnableToSend = rb_define_class_under( rb_mPG, "UnableToSend", rb_ePGerror );
|
86
|
+
rb_eConnectionBad = rb_define_class_under( rb_mPG, "ConnectionBad", rb_ePGerror );
|
87
|
+
|
88
|
+
#include "errorcodes.def"
|
89
|
+
}
|