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.
277 278 279 |
# File 'lib/teradata-cli/connection.rb', line 277 def logger @logger end |
#string_extractor ⇒ Object
Returns the value of attribute string_extractor.
276 277 278 |
# File 'lib/teradata-cli/connection.rb', line 276 def string_extractor @string_extractor end |
Class Method Details
.cleanup ⇒ Object
must be called only once in process, at the finalize step.
183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'ext/teradata-cli/cli/cli.c', line 183
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
239 240 241 242 243 244 |
# File 'ext/teradata-cli/cli/cli.c', line 239
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
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
# File 'lib/teradata-cli/connection.rb', line 382 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
216 217 218 219 220 221 222 |
# File 'ext/teradata-cli/cli/cli.c', line 216
static VALUE
cli_end_request(VALUE self)
{
struct rb_cli *p = get_cli(self);
dispatch(p, DBFERQ);
return Qnil;
}
|
#fetch ⇒ Object
224 225 226 227 228 229 230 |
# File 'ext/teradata-cli/cli/cli.c', line 224
static VALUE
cli_fetch(VALUE self)
{
struct rb_cli *p = get_cli(self);
dispatch(p, DBFFET);
return Qnil;
}
|
#flavor_name ⇒ Object
292 293 294 295 296 297 |
# File 'ext/teradata-cli/cli/cli.c', line 292
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
175 176 177 178 179 180 |
# File 'ext/teradata-cli/cli/cli.c', line 175
static VALUE
cli_logging_on_p(VALUE self)
{
struct rb_cli *p = get_cli(self);
return p->logging_on;
}
|
#logoff ⇒ Object
149 150 151 152 153 154 155 156 157 158 |
# File 'ext/teradata-cli/cli/cli.c', line 149
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
232 233 234 235 236 237 |
# File 'ext/teradata-cli/cli/cli.c', line 232
static VALUE
cli_message(VALUE self)
{
struct rb_cli *p = get_cli(self);
return rb_str_new2(p->dbcarea.msg_text);
}
|
#read_metadata ⇒ Object
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
# File 'lib/teradata-cli/connection.rb', line 332 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
351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
# File 'lib/teradata-cli/connection.rb', line 351 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
322 323 324 325 326 327 328 329 330 |
# File 'lib/teradata-cli/connection.rb', line 322 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
279 280 281 282 |
# File 'lib/teradata-cli/connection.rb', line 279 def request(sql) @eor = false # EndOfRequest send_request sql end |
#send_request(sql_value) ⇒ Object
203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'ext/teradata-cli/cli/cli.c', line 203
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
196 197 198 199 200 201 |
# File 'ext/teradata-cli/cli/cli.c', line 196
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
376 377 378 379 380 |
# File 'lib/teradata-cli/connection.rb', line 376 def skip_current_request each_fet_parcel do |parcel| ; end end |
#skip_current_statement ⇒ Object
366 367 368 369 370 371 372 373 374 |
# File 'lib/teradata-cli/connection.rb', line 366 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 |