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:
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 670 671 672 673 674 675 676 |
# File 'ext/informixc.c', line 570
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 491 "informixc.ec"
#line 492 "informixc.ec"
char *did;
/*
* EXEC SQL end declare section;
*/
#line 493 "informixc.ec"
rb_scan_args(argc, argv, "12", &db, &type, &options);
Data_Get_Struct(db, char, did);
/*
* EXEC SQL set connection :did;
*/
#line 498 "informixc.ec"
{
#line 498 "informixc.ec"
sqli_connect_set(0, did, 0);
#line 498 "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.
919 920 921 922 923 924 |
# File 'ext/informixc.c', line 919
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.
1595 1596 1597 1598 1599 |
# File 'ext/informixc.c', line 1595
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__.
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 781 782 783 784 785 786 787 |
# File 'ext/informixc.c', line 750
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 639 "informixc.ec"
#line 640 "informixc.ec"
char *did;
/*
* EXEC SQL end declare section;
*/
#line 641 "informixc.ec"
did = slob->database_id;
/*
* EXEC SQL set connection :did;
*/
#line 644 "informixc.ec"
{
#line 644 "informixc.ec"
sqli_connect_set(0, did, 0);
#line 644 "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.
1607 1608 1609 1610 1611 |
# File 'ext/informixc.c', line 1607
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
1422 1423 1424 1425 1426 |
# File 'ext/informixc.c', line 1422
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
1434 1435 1436 1437 1438 |
# File 'ext/informixc.c', line 1434
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
1482 1483 1484 1485 1486 |
# File 'ext/informixc.c', line 1482
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
1446 1447 1448 1449 1450 |
# File 'ext/informixc.c', line 1446
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
1494 1495 1496 1497 1498 |
# File 'ext/informixc.c', line 1494
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
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 1186 1187 1188 1189 1190 1191 1192 |
# File 'ext/informixc.c', line 1149
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 941 "informixc.ec"
#line 942 "informixc.ec"
char *did;
/*
* EXEC SQL end declare section;
*/
#line 943 "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 951 "informixc.ec"
{
#line 951 "informixc.ec"
sqli_connect_set(0, did, 0);
#line 951 "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
1458 1459 1460 1461 1462 |
# File 'ext/informixc.c', line 1458
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.
1619 1620 1621 1622 1623 |
# File 'ext/informixc.c', line 1619
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__.
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 736 737 738 739 740 741 742 |
# File 'ext/informixc.c', line 698
static VALUE
rb_slob_open(int argc, VALUE *argv, VALUE self)
{
VALUE access;
slob_t *slob;
mint error;
/*
* EXEC SQL begin declare section;
*/
#line 602 "informixc.ec"
#line 603 "informixc.ec"
char *did;
/*
* EXEC SQL end declare section;
*/
#line 604 "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 612 "informixc.ec"
{
#line 612 "informixc.ec"
sqli_connect_set(0, did, 0);
#line 612 "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.
998 999 1000 1001 1002 |
# File 'ext/informixc.c', line 998
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.
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 843 844 845 846 847 848 849 |
# File 'ext/informixc.c', line 797
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 671 "informixc.ec"
#line 672 "informixc.ec"
char *did;
/*
* EXEC SQL end declare section;
*/
#line 673 "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 682 "informixc.ec"
{
#line 682 "informixc.ec"
sqli_connect_set(0, did, 0);
#line 682 "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
1631 1632 1633 1634 1635 |
# File 'ext/informixc.c', line 1631
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.
1010 1011 1012 1013 1014 |
# File 'ext/informixc.c', line 1010
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
1470 1471 1472 1473 1474 |
# File 'ext/informixc.c', line 1470
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.
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 984 985 986 987 988 989 990 |
# File 'ext/informixc.c', line 945
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 786 "informixc.ec"
#line 787 "informixc.ec"
char *did;
/*
* EXEC SQL end declare section;
*/
#line 788 "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 796 "informixc.ec"
{
#line 796 "informixc.ec"
sqli_connect_set(0, did, 0);
#line 796 "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
1643 1644 1645 1646 1647 |
# File 'ext/informixc.c', line 1643
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.
1127 1128 1129 1130 1131 |
# File 'ext/informixc.c', line 1127
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
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 1061 1062 1063 1064 1065 1066 1067 |
# File 'ext/informixc.c', line 1023
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 848 "informixc.ec"
#line 849 "informixc.ec"
char *did;
/*
* EXEC SQL end declare section;
*/
#line 850 "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 858 "informixc.ec"
{
#line 858 "informixc.ec"
sqli_connect_set(0, did, 0);
#line 858 "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__.
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 1113 1114 1115 1116 1117 1118 1119 |
# File 'ext/informixc.c', line 1077
static VALUE
rb_slob_truncate(VALUE self, VALUE offset)
{
slob_t *slob;
mint ret;
ifx_int8_t offset8;
/*
* EXEC SQL begin declare section;
*/
#line 885 "informixc.ec"
#line 886 "informixc.ec"
char *did;
/*
* EXEC SQL end declare section;
*/
#line 887 "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 895 "informixc.ec"
{
#line 895 "informixc.ec"
sqli_connect_set(0, did, 0);
#line 895 "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
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 1246 1247 1248 1249 1250 1251 1252 |
# File 'ext/informixc.c', line 1209
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 985 "informixc.ec"
#line 986 "informixc.ec"
char *did;
/*
* EXEC SQL end declare section;
*/
#line 987 "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 995 "informixc.ec"
{
#line 995 "informixc.ec"
sqli_connect_set(0, did, 0);
#line 995 "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.
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 902 903 904 905 906 907 908 |
# File 'ext/informixc.c', line 860
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 718 "informixc.ec"
#line 719 "informixc.ec"
char *did;
/*
* EXEC SQL end declare section;
*/
#line 720 "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 728 "informixc.ec"
{
#line 728 "informixc.ec"
sqli_connect_set(0, did, 0);
#line 728 "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);
}
|