Class: Informix::Slob
- Inherits:
-
Object
- Object
- Informix::Slob
- Defined in:
- lib/informix.rb,
ext/informixc.c
Overview
class Statement
Defined Under Namespace
Classes: Stat
Constant Summary collapse
- CLOB =
INT2FIX(XID_CLOB)
- BLOB =
INT2FIX(XID_BLOB)
- RDONLY =
Access modes
INT2FIX(LO_RDONLY)
- DIRTY_READ =
INT2FIX(LO_DIRTY_READ)
- WRONLY =
INT2FIX(LO_WRONLY)
- APPEND =
INT2FIX(LO_APPEND)
- RDWR =
INT2FIX(LO_RDWR)
- BUFFER =
INT2FIX(LO_BUFFER)
- NOBUFFER =
INT2FIX(LO_NOBUFFER)
- LOCKALL =
INT2FIX(LO_LOCKALL)
- LOCKRANGE =
INT2FIX(LO_LOCKRANGE)
- SEEK_SET =
INT2FIX(LO_SEEK_SET)
- SEEK_CUR =
INT2FIX(LO_SEEK_CUR)
- SEEK_END =
INT2FIX(LO_SEEK_END)
- LOG =
Creation-time flags
INT2FIX(LO_LOG)
- NOLOG =
INT2FIX(LO_NOLOG)
- KEEP_LASTACCESS_TIME =
INT2FIX(LO_KEEP_LASTACCESS_TIME)
- NOKEEP_LASTACCESS_TIME =
INT2FIX(LO_NOKEEP_LASTACCESS_TIME)
- CURRENT_END =
Ranges
INT2FIX(LO_CURRENT_END)
- MAX_END =
INT2FIX(LO_MAX_END)
- SHARED_MODE =
Lock modes
INT2FIX(LO_SHARED_MODE)
- EXCLUSIVE_MODE =
INT2FIX(LO_EXCLUSIVE_MODE)
Class Method Summary collapse
- ._new ⇒ Object
-
.new(dbname, query, options = nil) ⇒ Object
Creates a
Slob
object.
Instance Method Summary collapse
-
#<<(data) ⇒ Object
slob << data => slob.
-
#atime ⇒ Object
slob.atime => time.
-
#close ⇒ Object
slob.close => slob.
-
#ctime ⇒ Object
stat.ctime => time.
-
#estbytes ⇒ Object
slob.estbytes => fixnum or bignum.
-
#extsz ⇒ Object
slob.extsz => fixnum.
-
#extsz=(value) ⇒ Object
slob.extsz = fixnum => fixnum.
-
#flags ⇒ Object
slob.flags => fixnum.
-
#flags=(value) ⇒ Object
slob.flags = fixnum => fixnum.
-
#initialize(*args) ⇒ Object
constructor
:nodoc:.
-
#lock(offset, whence, range, mode) ⇒ Object
slob.lock(offset, whence, range, mode) => slob.
-
#maxbytes ⇒ Object
slob.maxbytes => fixnum or bignum.
-
#mtime ⇒ Object
stat.mtime => time.
-
#open(*args) ⇒ Object
slob.open(access = Slob::RDONLY) => slob.
-
#pos=(pos) ⇒ Object
slob.pos = integer => integer.
-
#read(nbytes) ⇒ Object
slob.read(nbytes) => string.
-
#refcnt ⇒ Object
stat.refcnt => fixnum.
-
#rewind ⇒ Object
slob.rewind => fixnum.
-
#sbspace ⇒ Object
slob.sbspace => string.
-
#seek(offset, whence) ⇒ Object
slob.seek(offset, whence) => fixnum or bignum.
-
#size ⇒ Object
stat.size => fixnum or bignum.
-
#stat ⇒ Object
slob.stat => stat.
-
#tell ⇒ Object
(also: #pos)
slob.tell => integer slob.pos => integer.
-
#truncate(offset) ⇒ Object
slob.truncate(offset) => slob.
-
#unlock(offset, whence, range) ⇒ Object
slob.unlock(offset, whence, range) => slob.
-
#write(data) ⇒ Object
slob.write(data) => fixnum or bignum.
Constructor Details
#initialize(*args) ⇒ Object
:nodoc:
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 |
# File 'ext/informixc.c', line 563
static VALUE
rb_slob_initialize(int argc, VALUE *argv, VALUE self)
{
mint ret, error;
slob_t *slob;
VALUE db, type, options;
VALUE col_info, sbspace, estbytes, extsz, createflags, openflags, maxbytes;
/*
* EXEC SQL begin declare section;
*/
#line 484 "informixc.ec"
#line 485 "informixc.ec"
char *did;
/*
* EXEC SQL end declare section;
*/
#line 486 "informixc.ec"
rb_scan_args(argc, argv, "12", &db, &type, &options);
Data_Get_Struct(db, char, did);
/*
* EXEC SQL set connection :did;
*/
#line 491 "informixc.ec"
{
#line 491 "informixc.ec"
sqli_connect_set(0, did, 0);
#line 491 "informixc.ec"
}
if (SQLCODE < 0)
raise_ifx_extended();
Data_Get_Struct(self, slob_t, slob);
slob->db = db;
slob->database_id = did;
if (!NIL_P(type)) {
int t = FIX2INT(type);
if (t != XID_CLOB && t != XID_BLOB)
rb_raise(rb_eInternalError, "Invalid type %d for an SLOB", t);
slob->type = t;
}
col_info = sbspace = estbytes = extsz = createflags = openflags = maxbytes = Qnil;
if (!NIL_P(options)) {
Check_Type(options, T_HASH);
col_info = rb_hash_aref(options, sym_col_info);
sbspace = rb_hash_aref(options, sym_sbspace);
estbytes = rb_hash_aref(options, sym_estbytes);
extsz = rb_hash_aref(options, sym_extsz);
createflags = rb_hash_aref(options, sym_createflags);
openflags = rb_hash_aref(options, sym_openflags);
maxbytes = rb_hash_aref(options, sym_maxbytes);
}
ret = ifx_lo_def_create_spec(&slob->spec);
if (ret < 0)
raise_ifx_extended();
if (!NIL_P(col_info)) {
ret = ifx_lo_col_info(StringValueCStr(col_info), slob->spec);
if (ret < 0)
raise_ifx_extended();
}
if (!NIL_P(sbspace)) {
char *c_sbspace = StringValueCStr(sbspace);
ret = ifx_lo_specset_sbspace(slob->spec, c_sbspace);
if (ret == -1)
rb_raise(rb_eOperationalError, "Could not set sbspace name to %s", c_sbspace);
}
if (!NIL_P(estbytes)) {
ifx_int8_t estbytes8;
NUM2INT8(estbytes, &estbytes8);
ret = ifx_lo_specset_estbytes(slob->spec, &estbytes8);
if (ret == -1)
rb_raise(rb_eOperationalError, "Could not set estbytes");
}
if (!NIL_P(extsz)) {
ret = ifx_lo_specset_extsz(slob->spec, FIX2LONG(extsz));
if (ret == -1)
rb_raise(rb_eOperationalError, "Could not set extsz to %ld", FIX2LONG(extsz));
}
if (!NIL_P(createflags)) {
ret = ifx_lo_specset_flags(slob->spec, FIX2LONG(createflags));
if (ret == -1)
rb_raise(rb_eOperationalError, "Could not set crate-time flags to 0x%X", FIX2LONG(createflags));
}
if (!NIL_P(maxbytes)) {
ifx_int8_t maxbytes8;
NUM2INT8(maxbytes, (&maxbytes8));
ret = ifx_lo_specset_maxbytes(slob->spec, &maxbytes8);
if (ret == -1)
rb_raise(rb_eOperationalError, "Could not set maxbytes");
}
slob->fd = ifx_lo_create(slob->spec, RTEST(openflags)? FIX2LONG(openflags): LO_RDWR, &slob->lo, &error);
if (slob->fd == -1)
raise_ifx_extended();
return self;
}
|
Class Method Details
._new ⇒ Object
292 |
# File 'lib/informix.rb', line 292 alias _new new |
.new(dbname, query, options = nil) ⇒ Object
Creates a Slob
object.
The Slob
object is passed to the block if it’s given, and automatically closes it when the block terminates, returning the value of the block.
type
can be Slob::BLOB or Slob::CLOB
options
can be a Hash object with the following possible keys:
:sbspace => Sbspace name
:estbytes => Estimated size, in bytes
:extsz => Allocation extent size
:createflags => Create-time flags
:openflags => Access mode
:maxbytes => Maximum size
:col_info => Get the previous values from the column-level storage
characteristics for the specified database column
314 315 316 317 318 319 320 321 322 |
# File 'lib/informix.rb', line 314 def self.new(dbname, query, = nil) slob = _new(dbname, query, ) return slob if !block_given? begin yield slob ensure slob.close end end |
Instance Method Details
#<<(data) ⇒ Object
slob << data => slob
Writes data to the Smart Large Object. If data is not a String object it will be converted to String using to_s
.
Returns self.
912 913 914 915 916 917 |
# File 'ext/informixc.c', line 912
static VALUE
rb_slob_addstr(VALUE self, VALUE data)
{
rb_slob_write(self, data);
return self;
}
|
#atime ⇒ Object
slob.atime => time
Returns the time of last access as a Time object.
1588 1589 1590 1591 1592 |
# File 'ext/informixc.c', line 1588
static VALUE
rb_slob_atime(VALUE self)
{
return slob_stat(self, slob_atime);
}
|
#close ⇒ Object
slob.close => slob
Closes the Smart Large Object and returns __self__.
743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
# File 'ext/informixc.c', line 743
static VALUE
rb_slob_close(VALUE self)
{
slob_t *slob;
Data_Get_Struct(self, slob_t, slob);
if (slob->fd != -1) {
/*
* EXEC SQL begin declare section;
*/
#line 632 "informixc.ec"
#line 633 "informixc.ec"
char *did;
/*
* EXEC SQL end declare section;
*/
#line 634 "informixc.ec"
did = slob->database_id;
/*
* EXEC SQL set connection :did;
*/
#line 637 "informixc.ec"
{
#line 637 "informixc.ec"
sqli_connect_set(0, did, 0);
#line 637 "informixc.ec"
}
if (SQLCODE < 0)
return self;
ifx_lo_close(slob->fd);
slob->fd = -1;
}
return self;
}
|
#ctime ⇒ Object
stat.ctime => time
Returns the time of last change in status as a Time object.
1600 1601 1602 1603 1604 |
# File 'ext/informixc.c', line 1600
static VALUE
rb_slob_ctime(VALUE self)
{
return slob_stat(self, slob_ctime);
}
|
#estbytes ⇒ Object
slob.estbytes => fixnum or bignum
Returns the estimated size of the SLOB
1415 1416 1417 1418 1419 |
# File 'ext/informixc.c', line 1415
static VALUE
rb_slob_estbytes(VALUE self)
{
return slob_specget(self, slob_estbytes);
}
|
#extsz ⇒ Object
slob.extsz => fixnum
Returns the allocation extent size of the SLOB
1427 1428 1429 1430 1431 |
# File 'ext/informixc.c', line 1427
static VALUE
rb_slob_extsz(VALUE self)
{
return slob_specget(self, slob_extsz);
}
|
#extsz=(value) ⇒ Object
slob.extsz = fixnum => fixnum
Sets the allocation extent size for the SLOB
1475 1476 1477 1478 1479 |
# File 'ext/informixc.c', line 1475
static VALUE
rb_slob_set_extsz(VALUE self, VALUE value)
{
return slob_specset(self, slob_extsz, value);
}
|
#flags ⇒ Object
slob.flags => fixnum
Returns the create-time flags of the SLOB
1439 1440 1441 1442 1443 |
# File 'ext/informixc.c', line 1439
static VALUE
rb_slob_flags(VALUE self)
{
return slob_specget(self, slob_flags);
}
|
#flags=(value) ⇒ Object
slob.flags = fixnum => fixnum
Sets the create-time flags of the SLOB
1487 1488 1489 1490 1491 |
# File 'ext/informixc.c', line 1487
static VALUE
rb_slob_set_flags(VALUE self, VALUE value)
{
return slob_specset(self, slob_flags, value);
}
|
#lock(offset, whence, range, mode) ⇒ Object
slob.lock(offset, whence, range, mode) => slob
Locks range number of bytes, starting from offset bytes from whence, in mode mode.
Returns self.
Possible values:
offset => integer
whence => Slob::SEEK_SET, Slob::SEEK_CUR, Slob::SEEK_END
range => integer, Slob::CURRENT_END, Slob::MAX_END
mode => Slob::SHARED_MODE, Slob::EXCLUSIVE_MODE
1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 |
# File 'ext/informixc.c', line 1142
static VALUE
rb_slob_lock(VALUE self, VALUE offset, VALUE whence, VALUE range, VALUE mode)
{
slob_t *slob;
mint ret;
ifx_int8_t offset8, range8;
/*
* EXEC SQL begin declare section;
*/
#line 934 "informixc.ec"
#line 935 "informixc.ec"
char *did;
/*
* EXEC SQL end declare section;
*/
#line 936 "informixc.ec"
Data_Get_Struct(self, slob_t, slob);
if (slob->fd == -1)
rb_raise(rb_eProgrammingError, "Open the Slob object first");
did = slob->database_id;
/*
* EXEC SQL set connection :did;
*/
#line 944 "informixc.ec"
{
#line 944 "informixc.ec"
sqli_connect_set(0, did, 0);
#line 944 "informixc.ec"
}
if (SQLCODE < 0)
raise_ifx_extended();
NUM2INT8(offset, &offset8);
NUM2INT8(range, &range8);
ret = ifx_lo_lock(slob->fd, &offset8, FIX2INT(whence), &range8, FIX2INT(mode));
if (ret < 0)
raise_ifx_extended();
return self;
}
|
#maxbytes ⇒ Object
slob.maxbytes => fixnum or bignum
Returns the maximum size of the SLOB
1451 1452 1453 1454 1455 |
# File 'ext/informixc.c', line 1451
static VALUE
rb_slob_maxbytes(VALUE self)
{
return slob_specget(self, slob_maxbytes);
}
|
#mtime ⇒ Object
stat.mtime => time
Returns the time of last modification as a Time object.
1612 1613 1614 1615 1616 |
# File 'ext/informixc.c', line 1612
static VALUE
rb_slob_mtime(VALUE self)
{
return slob_stat(self, slob_mtime);
}
|
#open(*args) ⇒ Object
slob.open(access = Slob::RDONLY) => slob
Opens the Smart Large Object in access mode.
Access modes:
Slob::RDONLY:: Read only Slob::DIRTY_READ:: Read uncommitted data Slob::WRONLY:: Write only Slob::APPEND:: Append data to the end, if combined with RDWR or WRONLY; read only otherwise Slob::RDWR:: Read/Write Slob::BUFFER:: Use standard database server buffer pool Slob::NOBUFFER:: Use private buffer from the session pool of the database server Slob::LOCKALL:: Lock the entire Smart Large Object Slob::LOCKRANGE:: Lock a range of bytes
Returns __self__.
691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 |
# File 'ext/informixc.c', line 691
static VALUE
rb_slob_open(int argc, VALUE *argv, VALUE self)
{
VALUE access;
slob_t *slob;
mint error;
/*
* EXEC SQL begin declare section;
*/
#line 595 "informixc.ec"
#line 596 "informixc.ec"
char *did;
/*
* EXEC SQL end declare section;
*/
#line 597 "informixc.ec"
Data_Get_Struct(self, slob_t, slob);
if (slob->fd != -1) /* Already open */
return self;
did = slob->database_id;
/*
* EXEC SQL set connection :did;
*/
#line 605 "informixc.ec"
{
#line 605 "informixc.ec"
sqli_connect_set(0, did, 0);
#line 605 "informixc.ec"
}
if (SQLCODE < 0)
raise_ifx_extended();
rb_scan_args(argc, argv, "01", &access);
slob->fd = ifx_lo_open(&slob->lo, NIL_P(access)? LO_RDONLY: FIX2INT(access), &error);
if (slob->fd == -1)
raise_ifx_extended();
return self;
}
|
#pos=(pos) ⇒ Object
slob.pos = integer => integer
Seeks to the given position (in bytes) in slob.
991 992 993 994 995 |
# File 'ext/informixc.c', line 991
static VALUE
rb_slob_set_pos(VALUE self, VALUE pos)
{
return rb_slob_seek(self, pos, LO_SEEK_SET);
}
|
#read(nbytes) ⇒ Object
slob.read(nbytes) => string
Reads at most nbytes bytes from the Smart Large Object.
Returns the bytes read as a String object.
790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 |
# File 'ext/informixc.c', line 790
static VALUE
rb_slob_read(VALUE self, VALUE nbytes)
{
slob_t *slob;
mint error, ret;
char *buffer;
long c_nbytes;
VALUE str;
/*
* EXEC SQL begin declare section;
*/
#line 664 "informixc.ec"
#line 665 "informixc.ec"
char *did;
/*
* EXEC SQL end declare section;
*/
#line 666 "informixc.ec"
Data_Get_Struct(self, slob_t, slob);
if (slob->fd == -1)
rb_raise(rb_eProgrammingError, "Open the Slob object before reading");
did = slob->database_id;
/*
* EXEC SQL set connection :did;
*/
#line 675 "informixc.ec"
{
#line 675 "informixc.ec"
sqli_connect_set(0, did, 0);
#line 675 "informixc.ec"
}
if (SQLCODE < 0)
raise_ifx_extended();
c_nbytes = FIX2LONG(nbytes);
buffer = ALLOC_N(char, c_nbytes);
ret = ifx_lo_read(slob->fd, buffer, c_nbytes, &error);
if (ret == -1) {
xfree(buffer);
raise_ifx_extended();
}
str = rb_str_new(buffer, ret);
xfree(buffer);
return str;
}
|
#refcnt ⇒ Object
stat.refcnt => fixnum
Returns the number of references
1624 1625 1626 1627 1628 |
# File 'ext/informixc.c', line 1624
static VALUE
rb_slob_refcnt(VALUE self)
{
return slob_stat(self, slob_refcnt);
}
|
#rewind ⇒ Object
slob.rewind => fixnum
Moves the cursor position to the start of the Smart Large Object.
1003 1004 1005 1006 1007 |
# File 'ext/informixc.c', line 1003
static VALUE
rb_slob_rewind(VALUE self)
{
return rb_slob_seek(self, INT2FIX(0), LO_SEEK_SET);
}
|
#sbspace ⇒ Object
slob.sbspace => string
Returns the name of the sbspace where the SLOB is stored
1463 1464 1465 1466 1467 |
# File 'ext/informixc.c', line 1463
static VALUE
rb_slob_sbspace(VALUE self)
{
return slob_specget(self, slob_sbspace);
}
|
#seek(offset, whence) ⇒ Object
slob.seek(offset, whence) => fixnum or bignum
Sets the file position for the next read or write operation on the open Smart Large Object.
offset offset from the starting seek position whence identifies the starting seek position
Values for whence:
Slob::SEEK_SET:: The start of the Smart Large Object Slob::SEEK_CUR:: The current seek position in the Smart Large Object Slob::SEEK_END:: The end of the Smart Large Object
Returns the new position.
938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 |
# File 'ext/informixc.c', line 938
static VALUE
rb_slob_seek(VALUE self, VALUE offset, VALUE whence)
{
slob_t *slob;
mint ret;
VALUE seek_pos;
ifx_int8_t offset8, seek_pos8;
/*
* EXEC SQL begin declare section;
*/
#line 779 "informixc.ec"
#line 780 "informixc.ec"
char *did;
/*
* EXEC SQL end declare section;
*/
#line 781 "informixc.ec"
Data_Get_Struct(self, slob_t, slob);
if (slob->fd == -1)
rb_raise(rb_eProgrammingError, "Open the Slob object first");
did = slob->database_id;
/*
* EXEC SQL set connection :did;
*/
#line 789 "informixc.ec"
{
#line 789 "informixc.ec"
sqli_connect_set(0, did, 0);
#line 789 "informixc.ec"
}
if (SQLCODE < 0)
raise_ifx_extended();
NUM2INT8(offset, &offset8);
ret = ifx_lo_seek(slob->fd, &offset8, FIX2INT(whence), &seek_pos8);
if (ret < 0)
raise_ifx_extended();
INT82NUM(&seek_pos8, seek_pos);
return seek_pos;
}
|
#size ⇒ Object
stat.size => fixnum or bignum
Returns the size in bytes
1636 1637 1638 1639 1640 |
# File 'ext/informixc.c', line 1636
static VALUE
rb_slob_size(VALUE self)
{
return slob_stat(self, slob_size);
}
|
#stat ⇒ Object
slob.stat => stat
Creates and returns an Slob::Stat object with status information for slob.
1120 1121 1122 1123 1124 |
# File 'ext/informixc.c', line 1120
static VALUE
rb_slob_stat(VALUE self)
{
return rb_class_new_instance(1, &self, rb_cSlobStat);
}
|
#tell ⇒ Object Also known as: pos
slob.tell => integer slob.pos => integer
Returns the current file or seek position for an open Smart Large Object
1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 |
# File 'ext/informixc.c', line 1016
static VALUE
rb_slob_tell(VALUE self)
{
slob_t *slob;
mint ret;
VALUE seek_pos;
ifx_int8_t seek_pos8;
/*
* EXEC SQL begin declare section;
*/
#line 841 "informixc.ec"
#line 842 "informixc.ec"
char *did;
/*
* EXEC SQL end declare section;
*/
#line 843 "informixc.ec"
Data_Get_Struct(self, slob_t, slob);
if (slob->fd == -1)
rb_raise(rb_eProgrammingError, "Open the Slob object first");
did = slob->database_id;
/*
* EXEC SQL set connection :did;
*/
#line 851 "informixc.ec"
{
#line 851 "informixc.ec"
sqli_connect_set(0, did, 0);
#line 851 "informixc.ec"
}
if (SQLCODE < 0)
raise_ifx_extended();
ret = ifx_lo_tell(slob->fd, &seek_pos8);
if (ret < 0)
raise_ifx_extended();
INT82NUM(&seek_pos8, seek_pos);
return seek_pos;
}
|
#truncate(offset) ⇒ Object
slob.truncate(offset) => slob
Truncates a Smart Large Object at a specified byte position.
Returns __self__.
1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 |
# File 'ext/informixc.c', line 1070
static VALUE
rb_slob_truncate(VALUE self, VALUE offset)
{
slob_t *slob;
mint ret;
ifx_int8_t offset8;
/*
* EXEC SQL begin declare section;
*/
#line 878 "informixc.ec"
#line 879 "informixc.ec"
char *did;
/*
* EXEC SQL end declare section;
*/
#line 880 "informixc.ec"
Data_Get_Struct(self, slob_t, slob);
if (slob->fd == -1)
rb_raise(rb_eProgrammingError, "Open the Slob object first");
did = slob->database_id;
/*
* EXEC SQL set connection :did;
*/
#line 888 "informixc.ec"
{
#line 888 "informixc.ec"
sqli_connect_set(0, did, 0);
#line 888 "informixc.ec"
}
if (SQLCODE < 0)
raise_ifx_extended();
NUM2INT8(offset, &offset8);
ret = ifx_lo_truncate(slob->fd, &offset8);
if (ret < 0)
raise_ifx_extended();
return self;
}
|
#unlock(offset, whence, range) ⇒ Object
1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 |
# File 'ext/informixc.c', line 1202
static VALUE
rb_slob_unlock(VALUE self, VALUE offset, VALUE whence, VALUE range)
{
slob_t *slob;
mint ret;
ifx_int8_t offset8, range8;
/*
* EXEC SQL begin declare section;
*/
#line 978 "informixc.ec"
#line 979 "informixc.ec"
char *did;
/*
* EXEC SQL end declare section;
*/
#line 980 "informixc.ec"
Data_Get_Struct(self, slob_t, slob);
if (slob->fd == -1)
rb_raise(rb_eProgrammingError, "Open the Slob object first");
did = slob->database_id;
/*
* EXEC SQL set connection :did;
*/
#line 988 "informixc.ec"
{
#line 988 "informixc.ec"
sqli_connect_set(0, did, 0);
#line 988 "informixc.ec"
}
if (SQLCODE < 0)
raise_ifx_extended();
NUM2INT8(offset, &offset8);
NUM2INT8(range, &range8);
ret = ifx_lo_unlock(slob->fd, &offset8, FIX2INT(whence), &range8);
if (ret < 0)
raise_ifx_extended();
return self;
}
|
#write(data) ⇒ Object
slob.write(data) => fixnum or bignum
Writes data to the Smart Large Object. If data is not a String object it will be converted to String using to_s
.
Returns the number of bytes written.
853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 |
# File 'ext/informixc.c', line 853
static VALUE
rb_slob_write(VALUE self, VALUE data)
{
slob_t *slob;
mint error, ret;
char *buffer;
long nbytes;
VALUE str;
/*
* EXEC SQL begin declare section;
*/
#line 711 "informixc.ec"
#line 712 "informixc.ec"
char *did;
/*
* EXEC SQL end declare section;
*/
#line 713 "informixc.ec"
Data_Get_Struct(self, slob_t, slob);
if (slob->fd == -1)
rb_raise(rb_eProgrammingError, "Open the Slob object before writing");
did = slob->database_id;
/*
* EXEC SQL set connection :did;
*/
#line 721 "informixc.ec"
{
#line 721 "informixc.ec"
sqli_connect_set(0, did, 0);
#line 721 "informixc.ec"
}
if (SQLCODE < 0)
raise_ifx_extended();
str = rb_obj_as_string(data);
buffer = RSTRING_PTR(str);
nbytes = RSTRING_LEN(str);
ret = ifx_lo_write(slob->fd, buffer, nbytes, &error);
if (ret == -1)
raise_ifx_extended();
return LONG2NUM(ret);
}
|