Class: TeradataCli::CLI
- Inherits:
-
Object
- Object
- TeradataCli::CLI
- Defined in:
- lib/teradata-cli/connection.rb,
ext/teradata-cli/cli/cli.c
Overview
reopen
Constant Summary collapse
- Id =
rb_str_new2("$Id: cli.c 629 2010-02-17 01:46:11Z aamine $")
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#string_extractor ⇒ Object
Returns the value of attribute string_extractor.
Class Method Summary collapse
-
.cleanup ⇒ Object
must be called only once in process, at the finalize step.
Instance Method Summary collapse
- #data ⇒ Object
- #each_fet_parcel ⇒ Object
- #end_request ⇒ Object
- #fetch ⇒ Object
- #flavor_name ⇒ Object
- #logging_on? ⇒ Boolean
- #logoff ⇒ Object
- #message ⇒ Object
- #read_metadata ⇒ Object
- #read_record ⇒ Object
-
#read_result_set ⇒ Object
Non-Valued Result CLI Response Sequence.
- #request(sql) ⇒ Object
- #send_request(sql_value) ⇒ Object
- #session_charset ⇒ Object
- #skip_current_request ⇒ Object
- #skip_current_statement ⇒ Object
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
279 280 281 |
# File 'lib/teradata-cli/connection.rb', line 279 def logger @logger end |
#string_extractor ⇒ Object
Returns the value of attribute string_extractor.
278 279 280 |
# File 'lib/teradata-cli/connection.rb', line 278 def string_extractor @string_extractor end |
Class Method Details
.cleanup ⇒ Object
must be called only once in process, at the finalize step.
188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'ext/teradata-cli/cli/cli.c', line 188
static VALUE
cli_cleanup(VALUE mod)
{
Int32 status;
char dummy[4];
DBCHCLN(&status, dummy);
if (status != EM_OK) {
rb_raise(CLIError, "CLI cleanup failed");
}
return Qnil;
}
|
Instance Method Details
#data ⇒ Object
244 245 246 247 248 249 |
# File 'ext/teradata-cli/cli/cli.c', line 244
static VALUE
cli_data(VALUE self)
{
struct rb_cli *p = get_cli(self);
return rb_str_new(p->dbcarea.fet_data_ptr, p->dbcarea.fet_ret_data_len);
}
|
#each_fet_parcel ⇒ Object
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
# File 'lib/teradata-cli/connection.rb', line 384 def each_fet_parcel return if @eor while true debug { "CLI.fetch" } fetch flavor = flavor_name() debug { "fetched: #{flavor}" } case flavor when 'PclENDREQUEST' debug { "=== End Request ===" } @eor = true return when 'PclFAILURE', 'PclERROR' @eor = true end yield FetchedParcel.new(flavor, self) end end |
#end_request ⇒ Object
221 222 223 224 225 226 227 |
# File 'ext/teradata-cli/cli/cli.c', line 221
static VALUE
cli_end_request(VALUE self)
{
struct rb_cli *p = get_cli(self);
dispatch(p, DBFERQ);
return Qnil;
}
|
#fetch ⇒ Object
229 230 231 232 233 234 235 |
# File 'ext/teradata-cli/cli/cli.c', line 229
static VALUE
cli_fetch(VALUE self)
{
struct rb_cli *p = get_cli(self);
dispatch(p, DBFFET);
return Qnil;
}
|
#flavor_name ⇒ Object
297 298 299 300 301 302 |
# File 'ext/teradata-cli/cli/cli.c', line 297
static VALUE
cli_flavor_name(VALUE self)
{
struct rb_cli *p = get_cli(self);
return rb_str_new2(flavor_name(p->dbcarea.fet_parcel_flavor));
}
|
#logging_on? ⇒ Boolean
180 181 182 183 184 185 |
# File 'ext/teradata-cli/cli/cli.c', line 180
static VALUE
cli_logging_on_p(VALUE self)
{
struct rb_cli *p = get_cli(self);
return p->logging_on;
}
|
#logoff ⇒ Object
154 155 156 157 158 159 160 161 162 163 |
# File 'ext/teradata-cli/cli/cli.c', line 154
static VALUE
cli_logoff(VALUE self)
{
struct rb_cli *p = get_cli(self);
if (! p->logging_on) {
rb_raise(CLIError, "is already logged off");
}
logoff(p, Qfalse);
return Qnil;
}
|
#message ⇒ Object
237 238 239 240 241 242 |
# File 'ext/teradata-cli/cli/cli.c', line 237
static VALUE
cli_message(VALUE self)
{
struct rb_cli *p = get_cli(self);
return rb_str_new2(p->dbcarea.msg_text);
}
|
#read_metadata ⇒ Object
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
# File 'lib/teradata-cli/connection.rb', line 334 def each_fet_parcel do |parcel| case parcel.flavor_name when 'PclPREPINFO' = MetaData.parse_prepinfo(parcel.data, string_extractor()) debug { "metadata = #{.inspect}" } return when 'PclDATAINFO' when 'PclENDSTATEMENT' # null request returns no metadata. return nil else ; end end warn { "read_metadata: each_fet_parcel returned before PclENDSTATEMENT?" } nil #FIXME: should raise? end |
#read_record ⇒ Object
353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
# File 'lib/teradata-cli/connection.rb', line 353 def read_record each_fet_parcel do |parcel| case parcel.flavor_name when 'PclRECORD' return parcel.data when 'PclENDSTATEMENT' return nil else ; end end warn { "read_record: each_fet_parcel returned before PclENDSTATEMENT?" } nil #FIXME: should raise? end |
#read_result_set ⇒ Object
Non-Valued Result CLI Response Sequence
PclSUCCESS PclENDSTATEMENT PclSUCCESS PclENDSTATEMENT … PclENDREQUEST
Valued Result CLI Response Sequence
On Success
PclSUCCESS PclPREPINFO PclDATAINFO PclRECORD PclRECORD … PclENDSTATEMENT
PclSUCCESS PclPREPINFO PclDATAINFO PclRECORD PclRECORD … PclENDSTATEMENT
PclENDREQUEST
CLI Response Sequence on Failure
PclSUCCESS PclENDSTATEMENT … PclFAILURE
324 325 326 327 328 329 330 331 332 |
# File 'lib/teradata-cli/connection.rb', line 324 def read_result_set each_fet_parcel do |parcel| case parcel.flavor_name when 'PclSUCCESS', 'PclFAILURE', 'PclERROR' return ResultSet.new(parcel.sql_status, self) end end nil end |
#request(sql) ⇒ Object
281 282 283 284 |
# File 'lib/teradata-cli/connection.rb', line 281 def request(sql) @eor = false # EndOfRequest send_request sql end |
#send_request(sql_value) ⇒ Object
208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'ext/teradata-cli/cli/cli.c', line 208
static VALUE
cli_send_request(VALUE self, VALUE sql_value)
{
struct rb_cli *p = get_cli(self);
StringValue(sql_value);
p->dbcarea.req_ptr = RSTRING_PTR(sql_value);
p->dbcarea.req_len = RSTRING_LEN(sql_value);
dispatch(p, DBFIRQ);
p->dbcarea.i_sess_id = p->dbcarea.o_sess_id;
p->dbcarea.i_req_id = p->dbcarea.o_req_id;
return Qnil;
}
|
#session_charset ⇒ Object
201 202 203 204 205 206 |
# File 'ext/teradata-cli/cli/cli.c', line 201
static VALUE
cli_session_charset(VALUE self)
{
struct rb_cli *p = get_cli(self);
return rb_str_new2(p->session_charset);
}
|
#skip_current_request ⇒ Object
378 379 380 381 382 |
# File 'lib/teradata-cli/connection.rb', line 378 def skip_current_request each_fet_parcel do |parcel| ; end end |
#skip_current_statement ⇒ Object
368 369 370 371 372 373 374 375 376 |
# File 'lib/teradata-cli/connection.rb', line 368 def skip_current_statement each_fet_parcel do |parcel| case parcel.flavor_name when 'PclENDSTATEMENT' return end end # each_fet_parcel returns before PclENDSTATEMENT when error occured end |