Class: ODPI::Dpi::Pool

Inherits:
Object
  • Object
show all
Defined in:
ext/odpi_ext/rbdpi-pool.c

Instance Method Summary collapse

Constructor Details

#initialize(username, password, database, params) ⇒ Object


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
# File 'ext/odpi_ext/rbdpi-pool.c', line 56

static VALUE pool_initialize(VALUE self, VALUE username, VALUE password, VALUE database, VALUE params)
{
    pool_t *pool = (pool_t *)rb_check_typeddata(self, &pool_data_type);
    dpiCommonCreateParams common_params;
    dpiPoolCreateParams create_params;
    VALUE gc_guard1;
    VALUE gc_guard2;

    if (pool->handle != NULL) {
        rb_raise(rb_eRuntimeError, "Try to initialize an initialized connection");
    }
    pool->enc = rbdpi_get_encodings(params);
    CHK_NSTR_ENC(username, pool->enc.enc);
    CHK_NSTR_ENC(password, pool->enc.enc);
    CHK_NSTR_ENC(database, pool->enc.enc);
    gc_guard1 = rbdpi_fill_dpiCommonCreateParams(&common_params, params, pool->enc.enc);
    gc_guard2 = rbdpi_fill_dpiPoolCreateParams(&create_params, params, pool->enc.enc);
    if (NIL_P(username) && NIL_P(password)) {
        create_params.externalAuth = 1;
    }
    CHK(dpiPool_create_without_gvl(rbdpi_g_context,
                                   NSTR_PTR(username), NSTR_LEN(username),
                                   NSTR_PTR(password), NSTR_LEN(password),
                                   NSTR_PTR(database), NSTR_LEN(database),
                                   &common_params, &create_params, &pool->handle));
    RB_GC_GUARD(username);
    RB_GC_GUARD(password);
    RB_GC_GUARD(database);
    RB_GC_GUARD(gc_guard1);
    RB_GC_GUARD(gc_guard2);
    return self;
}

Instance Method Details

#busy_countObject


120
121
122
123
124
125
126
127
# File 'ext/odpi_ext/rbdpi-pool.c', line 120

static VALUE pool_get_busy_count(VALUE self)
{
    pool_t *pool = rbdpi_to_pool(self);
    uint32_t val;

    CHK(dpiPool_getBusyCount(pool->handle, &val));
    return UINT2NUM(val);
}

#close(mode) ⇒ Object


112
113
114
115
116
117
118
# File 'ext/odpi_ext/rbdpi-pool.c', line 112

static VALUE pool_close(VALUE self, VALUE mode)
{
    pool_t *pool = rbdpi_to_pool(self);

    CHK(dpiPool_close_without_gvl(pool->handle, rbdpi_to_dpiPoolCloseMode(mode)));
    return self;
}

#connection(username, password, auth_mode, params) ⇒ Object


89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'ext/odpi_ext/rbdpi-pool.c', line 89

static VALUE pool_get_connection(VALUE self, VALUE username, VALUE password, VALUE auth_mode, VALUE params)
{
    pool_t *pool = rbdpi_to_pool(self);
    dpiConn *conn;
    dpiConnCreateParams create_params;
    VALUE gc_guard;

    CHK_NSTR_ENC(username, pool->enc.enc);
    CHK_NSTR_ENC(password, pool->enc.enc);
    gc_guard = rbdpi_fill_dpiConnCreateParams(&create_params, params, auth_mode, pool->enc.enc);
    if (NIL_P(username) && NIL_P(password)) {
        create_params.externalAuth = 1;
    }
    CHK(dpiPool_acquireConnection_without_gvl(pool->handle,
                                              NSTR_PTR(username), NSTR_LEN(username),
                                              NSTR_PTR(password), NSTR_LEN(password),
                                              &create_params, &conn));
    RB_GC_GUARD(username);
    RB_GC_GUARD(password);
    RB_GC_GUARD(gc_guard);
    return rbdpi_from_conn(conn, &create_params, &pool->enc);
}

#encoding_infoObject


129
130
131
132
133
134
135
136
# File 'ext/odpi_ext/rbdpi-pool.c', line 129

static VALUE pool_get_encoding_info(VALUE self)
{
    pool_t *pool = rbdpi_to_pool(self);
    dpiEncodingInfo info;

    CHK(dpiPool_getEncodingInfo(pool->handle, &info));
    return rbdpi_from_dpiEncodingInfo(&info);
}

#get_modeObject


138
139
140
141
142
143
144
145
# File 'ext/odpi_ext/rbdpi-pool.c', line 138

static VALUE pool_get_get_mode(VALUE self)
{
    pool_t *pool = rbdpi_to_pool(self);
    dpiPoolGetMode mode;

    CHK(dpiPool_getGetMode(pool->handle, &mode));
    return rbdpi_from_dpiPoolGetMode(mode);
}

#get_mode=(val) ⇒ Object


183
184
185
186
187
188
189
# File 'ext/odpi_ext/rbdpi-pool.c', line 183

static VALUE pool_set_get_mode(VALUE self, VALUE val)
{
    pool_t *pool = rbdpi_to_pool(self);

    CHK(dpiPool_setGetMode(pool->handle, rbdpi_to_dpiPoolGetMode(val)));
    return val;
}

#max_lifetime_sessionObject


147
148
149
150
151
152
153
154
# File 'ext/odpi_ext/rbdpi-pool.c', line 147

static VALUE pool_get_max_lifetime_session(VALUE self)
{
    pool_t *pool = rbdpi_to_pool(self);
    uint32_t val;

    CHK(dpiPool_getMaxLifetimeSession(pool->handle, &val));
    return UINT2NUM(val);
}

#max_lifetime_session=(val) ⇒ Object


191
192
193
194
195
196
197
# File 'ext/odpi_ext/rbdpi-pool.c', line 191

static VALUE pool_set_max_lifetime_session(VALUE self, VALUE val)
{
    pool_t *pool = rbdpi_to_pool(self);

    CHK(dpiPool_setMaxLifetimeSession(pool->handle, NUM2UINT(val)));
    return val;
}

#open_countObject


156
157
158
159
160
161
162
163
# File 'ext/odpi_ext/rbdpi-pool.c', line 156

static VALUE pool_get_open_count(VALUE self)
{
    pool_t *pool = rbdpi_to_pool(self);
    uint32_t val;

    CHK(dpiPool_getOpenCount(pool->handle, &val));
    return UINT2NUM(val);
}

#stmt_cache_sizeObject


165
166
167
168
169
170
171
172
# File 'ext/odpi_ext/rbdpi-pool.c', line 165

static VALUE pool_get_stmt_cache_size(VALUE self)
{
    pool_t *pool = rbdpi_to_pool(self);
    uint32_t val;

    CHK(dpiPool_getStmtCacheSize(pool->handle, &val));
    return UINT2NUM(val);
}

#stmt_cache_size=(val) ⇒ Object


199
200
201
202
203
204
205
# File 'ext/odpi_ext/rbdpi-pool.c', line 199

static VALUE pool_set_stmt_cache_size(VALUE self, VALUE val)
{
    pool_t *pool = rbdpi_to_pool(self);

    CHK(dpiPool_setStmtCacheSize(pool->handle, NUM2UINT(val)));
    return val;
}

#timeoutObject


174
175
176
177
178
179
180
181
# File 'ext/odpi_ext/rbdpi-pool.c', line 174

static VALUE pool_get_timeout(VALUE self)
{
    pool_t *pool = rbdpi_to_pool(self);
    uint32_t val;

    CHK(dpiPool_getTimeout(pool->handle, &val));
    return UINT2NUM(val);
}

#timeout=(val) ⇒ Object


207
208
209
210
211
212
213
# File 'ext/odpi_ext/rbdpi-pool.c', line 207

static VALUE pool_set_timeout(VALUE self, VALUE val)
{
    pool_t *pool = rbdpi_to_pool(self);

    CHK(dpiPool_setTimeout(pool->handle, NUM2UINT(val)));
    return val;
}