Class: Mysql::Stmt

Inherits:
Object
  • Object
show all
Defined in:
ext/mysql.c

Constant Summary collapse

ATTR_UPDATE_MAX_LENGTH =
INT2NUM(STMT_ATTR_UPDATE_MAX_LENGTH)

Instance Method Summary collapse

Instance Method Details

#affected_rowsObject

affected_rows()



1772
1773
1774
1775
1776
1777
1778
1779
# File 'ext/mysql.c', line 1772

static VALUE stmt_affected_rows(VALUE obj)
{
    struct mysql_stmt* s = DATA_PTR(obj);
    my_ulonglong n;
    check_stmt_closed(obj);
    n = mysql_stmt_affected_rows(s->stmt);
    return INT2NUM(n);
}

#attr_get(opt) ⇒ Object

attr_get(option)



1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
# File 'ext/mysql.c', line 1783

static VALUE stmt_attr_get(VALUE obj, VALUE opt)
{
    struct mysql_stmt* s = DATA_PTR(obj);
    check_stmt_closed(obj);
    if (NUM2INT(opt) == STMT_ATTR_UPDATE_MAX_LENGTH) {
	my_bool arg;
	mysql_stmt_attr_get(s->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &arg);
	return arg == 1 ? Qtrue : Qfalse;
    }
    rb_raise(eMysql, "unknown option: %d", NUM2INT(opt));
}

#attr_set(opt, val) ⇒ Object

attr_set(option, arg)



1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
# File 'ext/mysql.c', line 1796

static VALUE stmt_attr_set(VALUE obj, VALUE opt, VALUE val)
{
    struct mysql_stmt* s = DATA_PTR(obj);
    check_stmt_closed(obj);
    if (NUM2INT(opt) == STMT_ATTR_UPDATE_MAX_LENGTH) {
	my_bool arg;
	arg = (val == Qnil || val == Qfalse) ? 0 : 1;
	mysql_stmt_attr_set(s->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &arg);
	return obj;
    }
    rb_raise(eMysql, "unknown option: %d", NUM2INT(opt));
}

#bind_result(*args) ⇒ Object

bind_result(bind,…)



1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
# File 'ext/mysql.c', line 1811

static VALUE stmt_bind_result(int argc, VALUE *argv, VALUE obj)
{
    struct mysql_stmt* s = DATA_PTR(obj);
    int i;
    MYSQL_FIELD *field;

    check_stmt_closed(obj);
    if (argc != s->result.n)
	rb_raise(eMysql, "bind_result: result value count(%d) != number of argument(%d)", s->result.n, argc);
    for (i = 0; i < argc; i++) {
	if (argv[i] == Qnil || argv[i] == rb_cNilClass) {
	    field = mysql_fetch_fields(s->res);
            s->result.bind[i].buffer_type = field[i].type;
	}
	else if (argv[i] == rb_cString)
	    s->result.bind[i].buffer_type = MYSQL_TYPE_STRING;
	else if (argv[i] == rb_cNumeric || argv[i] == rb_cInteger || argv[i] == rb_cFixnum)
	    s->result.bind[i].buffer_type = MYSQL_TYPE_LONGLONG;
	else if (argv[i] == rb_cFloat)
	    s->result.bind[i].buffer_type = MYSQL_TYPE_DOUBLE;
	else if (argv[i] == cMysqlTime)
	    s->result.bind[i].buffer_type = MYSQL_TYPE_DATETIME;
	else
	    rb_raise(rb_eTypeError, "unrecognized class: %s", RSTRING_PTR(rb_inspect(argv[i])));
	if (mysql_stmt_bind_result(s->stmt, s->result.bind))
	    mysql_stmt_raise(s->stmt);
    }
    return obj;
}

#closeObject

close()



1842
1843
1844
1845
1846
1847
1848
1849
# File 'ext/mysql.c', line 1842

static VALUE stmt_close(VALUE obj)
{
    struct mysql_stmt* s = DATA_PTR(obj);
    check_stmt_closed(obj);
    mysql_stmt_close(s->stmt);
    s->closed = Qtrue;
    return Qnil;
}

#data_seek(offset) ⇒ Object

data_seek(offset)



1852
1853
1854
1855
1856
1857
1858
# File 'ext/mysql.c', line 1852

static VALUE stmt_data_seek(VALUE obj, VALUE offset)
{
    struct mysql_stmt* s = DATA_PTR(obj);
    check_stmt_closed(obj);
    mysql_stmt_data_seek(s->stmt, NUM2INT(offset));
    return obj;
}

#eachObject

each …



2093
2094
2095
2096
2097
2098
2099
2100
# File 'ext/mysql.c', line 2093

static VALUE stmt_each(VALUE obj)
{
    VALUE row;
    check_stmt_closed(obj);
    while ((row = stmt_fetch(obj)) != Qnil)
	rb_yield(row);
    return obj;
}

#execute(*args) ⇒ Object

execute(arg,…)



1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
# File 'ext/mysql.c', line 1861

static VALUE stmt_execute(int argc, VALUE *argv, VALUE obj)
{
    struct mysql_stmt *s = DATA_PTR(obj);
    MYSQL_STMT *stmt = s->stmt;
    int i;

    check_stmt_closed(obj);
    free_execute_memory(s);
    if (s->param.n != argc)
	rb_raise(eMysql, "execute: param_count(%d) != number of argument(%d)", s->param.n, argc);
    if (argc > 0) {
        memset(s->param.bind, 0, sizeof(*(s->param.bind))*argc);
        for (i = 0; i < argc; i++) {
            switch (TYPE(argv[i])) {
            case T_NIL:
                s->param.bind[i].buffer_type = MYSQL_TYPE_NULL;
                break;
            case T_FIXNUM:
#if SIZEOF_INT < SIZEOF_LONG
                s->param.bind[i].buffer_type = MYSQL_TYPE_LONGLONG;
                s->param.bind[i].buffer = &(s->param.buffer[i]);
                *(LONG_LONG*)(s->param.bind[i].buffer) = FIX2LONG(argv[i]);
#else
                s->param.bind[i].buffer_type = MYSQL_TYPE_LONG;
                s->param.bind[i].buffer = &(s->param.buffer[i]);
                *(int*)(s->param.bind[i].buffer) = FIX2INT(argv[i]);
#endif
                break;
            case T_BIGNUM:
                s->param.bind[i].buffer_type = MYSQL_TYPE_LONGLONG;
                s->param.bind[i].buffer = &(s->param.buffer[i]);
                *(LONG_LONG*)(s->param.bind[i].buffer) = rb_big2ll(argv[i]);
                break;
            case T_FLOAT:
                s->param.bind[i].buffer_type = MYSQL_TYPE_DOUBLE;
                s->param.bind[i].buffer = &(s->param.buffer[i]);
                *(double*)(s->param.bind[i].buffer) = NUM2DBL(argv[i]);
                break;
            case T_STRING:
                s->param.bind[i].buffer_type = MYSQL_TYPE_STRING;
                s->param.bind[i].buffer = RSTRING_PTR(argv[i]);
                s->param.bind[i].buffer_length = RSTRING_LEN(argv[i]);
                s->param.length[i] = RSTRING_LEN(argv[i]);
                s->param.bind[i].length = &(s->param.length[i]);
                break;
            default:
                if (CLASS_OF(argv[i]) == rb_cTime) {
                    MYSQL_TIME t;
                    VALUE a = rb_funcall(argv[i], rb_intern("to_a"), 0);
                    s->param.bind[i].buffer_type = MYSQL_TYPE_DATETIME;
                    s->param.bind[i].buffer = &(s->param.buffer[i]);
                    t.second_part = 0;
                    t.neg = 0;
                    t.second = FIX2INT(rb_ary_entry(a, 0));
                    t.minute = FIX2INT(rb_ary_entry(a, 1));
                    t.hour = FIX2INT(rb_ary_entry(a, 2));
                    t.day = FIX2INT(rb_ary_entry(a, 3));
                    t.month = FIX2INT(rb_ary_entry(a, 4));
                    t.year = FIX2INT(rb_ary_entry(a, 5));
                    *(MYSQL_TIME*)&(s->param.buffer[i]) = t;
                } else if (CLASS_OF(argv[i]) == cMysqlTime) {
                    MYSQL_TIME t;
                    s->param.bind[i].buffer_type = MYSQL_TYPE_DATETIME;
                    s->param.bind[i].buffer = &(s->param.buffer[i]);
                    t.second_part = 0;
                    t.neg = 0;
                    t.second = NUM2INT(rb_iv_get(argv[i], "second"));
                    t.minute = NUM2INT(rb_iv_get(argv[i], "minute"));
                    t.hour = NUM2INT(rb_iv_get(argv[i], "hour"));
                    t.day = NUM2INT(rb_iv_get(argv[i], "day"));
                    t.month = NUM2INT(rb_iv_get(argv[i], "month"));
                    t.year = NUM2INT(rb_iv_get(argv[i], "year"));
                    *(MYSQL_TIME*)&(s->param.buffer[i]) = t;
                } else
                    rb_raise(rb_eTypeError, "unsupported type: %d", TYPE(argv[i]));
            }
        }
        if (mysql_stmt_bind_param(stmt, s->param.bind))
            mysql_stmt_raise(stmt);
    }

    if (mysql_stmt_execute(stmt))
	mysql_stmt_raise(stmt);
    if (s->res) {
	MYSQL_FIELD *field;
	if (mysql_stmt_store_result(stmt))
	    mysql_stmt_raise(stmt);
	field = mysql_fetch_fields(s->res);
	for (i = 0; i < s->result.n; i++) {
            switch(s->result.bind[i].buffer_type) {
            case MYSQL_TYPE_NULL:
                break;
            case MYSQL_TYPE_TINY:
            case MYSQL_TYPE_SHORT:
            case MYSQL_TYPE_YEAR:
            case MYSQL_TYPE_INT24:
            case MYSQL_TYPE_LONG:
            case MYSQL_TYPE_LONGLONG:
            case MYSQL_TYPE_FLOAT:
            case MYSQL_TYPE_DOUBLE:
                s->result.bind[i].buffer = xmalloc(8);
                s->result.bind[i].buffer_length = 8;
                memset(s->result.bind[i].buffer, 0, 8);
                break;
            case MYSQL_TYPE_DECIMAL:
            case MYSQL_TYPE_STRING:
            case MYSQL_TYPE_VAR_STRING:
            case MYSQL_TYPE_TINY_BLOB:
            case MYSQL_TYPE_BLOB:
            case MYSQL_TYPE_MEDIUM_BLOB:
            case MYSQL_TYPE_LONG_BLOB:
#if MYSQL_VERSION_ID >= 50003
            case MYSQL_TYPE_NEWDECIMAL:
            case MYSQL_TYPE_BIT:
#endif
                s->result.bind[i].buffer = xmalloc(field[i].max_length);
                memset(s->result.bind[i].buffer, 0, field[i].max_length);
                s->result.bind[i].buffer_length = field[i].max_length;
                break;
            case MYSQL_TYPE_TIME:
            case MYSQL_TYPE_DATE:
            case MYSQL_TYPE_DATETIME:
            case MYSQL_TYPE_TIMESTAMP:
                s->result.bind[i].buffer = xmalloc(sizeof(MYSQL_TIME));
                s->result.bind[i].buffer_length = sizeof(MYSQL_TIME);
                memset(s->result.bind[i].buffer, 0, sizeof(MYSQL_TIME));
                break;
            default:
                rb_raise(rb_eTypeError, "unknown buffer_type: %d", s->result.bind[i].buffer_type);
            }
	}
	if (mysql_stmt_bind_result(s->stmt, s->result.bind))
	    mysql_stmt_raise(s->stmt);
    }
    return obj;
}

#fetchObject

fetch()



1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
# File 'ext/mysql.c', line 1999

static VALUE stmt_fetch(VALUE obj)
{
    struct mysql_stmt* s = DATA_PTR(obj);
    VALUE ret;
    int i;
    int r;

    check_stmt_closed(obj);
    r = mysql_stmt_fetch(s->stmt);
    if (r == MYSQL_NO_DATA)
	return Qnil;
#ifdef MYSQL_DATA_TRUNCATED
    if (r == MYSQL_DATA_TRUNCATED)
        rb_raise(rb_eRuntimeError, "unexpectedly data truncated");
#endif
    if (r == 1)
	mysql_stmt_raise(s->stmt);

    ret = rb_ary_new2(s->result.n);
    for (i = 0; i < s->result.n; i++) {
	if (s->result.is_null[i])
	    rb_ary_push(ret, Qnil);
	else {
	    VALUE v;
	    MYSQL_TIME *t;
	    switch (s->result.bind[i].buffer_type) {
            case MYSQL_TYPE_TINY:
                if (s->result.bind[i].is_unsigned)
                    v = UINT2NUM(*(unsigned char *)s->result.bind[i].buffer);
                else
                    v = INT2NUM(*(signed char *)s->result.bind[i].buffer);
                break;
            case MYSQL_TYPE_SHORT:
            case MYSQL_TYPE_YEAR:
                if (s->result.bind[i].is_unsigned)
                    v = UINT2NUM(*(unsigned short *)s->result.bind[i].buffer);
                else
                    v = INT2NUM(*(short *)s->result.bind[i].buffer);
                break;
            case MYSQL_TYPE_INT24:
            case MYSQL_TYPE_LONG:
                if (s->result.bind[i].is_unsigned)
                    v = UINT2NUM(*(unsigned int *)s->result.bind[i].buffer);
                else
                    v = INT2NUM(*(int *)s->result.bind[i].buffer);
                break;
            case MYSQL_TYPE_LONGLONG:
                if (s->result.bind[i].is_unsigned)
                    v = ULL2NUM(*(unsigned long long *)s->result.bind[i].buffer);
                else
                    v = LL2NUM(*(long long *)s->result.bind[i].buffer);
                break;
            case MYSQL_TYPE_FLOAT:
                v = rb_float_new((double)(*(float *)s->result.bind[i].buffer));
                break;
            case MYSQL_TYPE_DOUBLE:
                v = rb_float_new(*(double *)s->result.bind[i].buffer);
                break;
            case MYSQL_TYPE_TIME:
            case MYSQL_TYPE_DATE:
            case MYSQL_TYPE_DATETIME:
            case MYSQL_TYPE_TIMESTAMP:
                t = (MYSQL_TIME *)s->result.bind[i].buffer;
                v = rb_obj_alloc(cMysqlTime);
                rb_funcall(v, rb_intern("initialize"), 8,
                           INT2FIX(t->year), INT2FIX(t->month),
                           INT2FIX(t->day), INT2FIX(t->hour),
                           INT2FIX(t->minute), INT2FIX(t->second),
                           (t->neg ? Qtrue : Qfalse),
                           INT2FIX(t->second_part));
                break;
            case MYSQL_TYPE_DECIMAL:
            case MYSQL_TYPE_STRING:
            case MYSQL_TYPE_VAR_STRING:
            case MYSQL_TYPE_TINY_BLOB:
            case MYSQL_TYPE_BLOB:
            case MYSQL_TYPE_MEDIUM_BLOB:
            case MYSQL_TYPE_LONG_BLOB:
#if MYSQL_VERSION_ID >= 50003
            case MYSQL_TYPE_NEWDECIMAL:
            case MYSQL_TYPE_BIT:
#endif
                v = rb_tainted_str_new(s->result.bind[i].buffer, s->result.length[i]);
                break;
            default:
                rb_raise(rb_eTypeError, "unknown buffer_type: %d", s->result.bind[i].buffer_type);
	    }
	    rb_ary_push(ret, v);
	}
    }
    return ret;
}

#field_countObject

field_count()



2103
2104
2105
2106
2107
2108
2109
2110
# File 'ext/mysql.c', line 2103

static VALUE stmt_field_count(VALUE obj)
{
    struct mysql_stmt* s = DATA_PTR(obj);
    unsigned int n;
    check_stmt_closed(obj);
    n = mysql_stmt_field_count(s->stmt);
    return INT2NUM(n);
}

#free_resultObject

free_result()



2113
2114
2115
2116
2117
2118
2119
2120
# File 'ext/mysql.c', line 2113

static VALUE stmt_free_result(VALUE obj)
{
    struct mysql_stmt* s = DATA_PTR(obj);
    check_stmt_closed(obj);
    if (mysql_stmt_free_result(s->stmt))
	mysql_stmt_raise(s->stmt);
    return obj;
}

#insert_idObject

insert_id()



2123
2124
2125
2126
2127
2128
2129
2130
# File 'ext/mysql.c', line 2123

static VALUE stmt_insert_id(VALUE obj)
{
    struct mysql_stmt* s = DATA_PTR(obj);
    my_ulonglong n;
    check_stmt_closed(obj);
    n = mysql_stmt_insert_id(s->stmt);
    return INT2NUM(n);
}

#num_rowsObject

num_rows()



2133
2134
2135
2136
2137
2138
2139
2140
# File 'ext/mysql.c', line 2133

static VALUE stmt_num_rows(VALUE obj)
{
    struct mysql_stmt* s = DATA_PTR(obj);
    my_ulonglong n;
    check_stmt_closed(obj);
    n = mysql_stmt_num_rows(s->stmt);
    return INT2NUM(n);
}

#param_countObject

param_count()



2143
2144
2145
2146
2147
2148
2149
2150
# File 'ext/mysql.c', line 2143

static VALUE stmt_param_count(VALUE obj)
{
    struct mysql_stmt* s = DATA_PTR(obj);
    unsigned long n;
    check_stmt_closed(obj);
    n = mysql_stmt_param_count(s->stmt);
    return INT2NUM(n);
}

#prepare(query) ⇒ Object

prepare(query)



2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
# File 'ext/mysql.c', line 2153

static VALUE stmt_prepare(VALUE obj, VALUE query)
{
    struct mysql_stmt* s = DATA_PTR(obj);
    int n;
    int i;
    MYSQL_FIELD *field;

    free_mysqlstmt_memory(s);
    check_stmt_closed(obj);
    Check_Type(query, T_STRING);
    if (mysql_stmt_prepare(s->stmt, RSTRING_PTR(query), RSTRING_LEN(query)))
	mysql_stmt_raise(s->stmt);

    n = mysql_stmt_param_count(s->stmt);
    s->param.n = n;
    s->param.bind = xmalloc(sizeof(s->param.bind[0]) * n);
    s->param.length = xmalloc(sizeof(s->param.length[0]) * n);
    s->param.buffer = xmalloc(sizeof(s->param.buffer[0]) * n);

    s->res = mysql_stmt_result_metadata(s->stmt);
    if (s->res) {
	n = s->result.n = mysql_num_fields(s->res);
	s->result.bind = xmalloc(sizeof(s->result.bind[0]) * n);
	s->result.is_null = xmalloc(sizeof(s->result.is_null[0]) * n);
	s->result.length = xmalloc(sizeof(s->result.length[0]) * n);
	field = mysql_fetch_fields(s->res);
	memset(s->result.bind, 0, sizeof(s->result.bind[0]) * n);
	for (i = 0; i < n; i++) {
            s->result.bind[i].buffer_type = field[i].type;
#if MYSQL_VERSION_ID < 50003
            if (field[i].type == MYSQL_TYPE_DECIMAL)
                s->result.bind[i].buffer_type = MYSQL_TYPE_STRING;
#endif
	    s->result.bind[i].is_null = &(s->result.is_null[i]);
	    s->result.bind[i].length = &(s->result.length[i]);
            s->result.bind[i].is_unsigned = ((field[i].flags & UNSIGNED_FLAG) != 0);
	}
    } else {
	if (mysql_stmt_errno(s->stmt))
	    mysql_stmt_raise(s->stmt);
    }

    return obj;
}

#resetObject

reset()



2200
2201
2202
2203
2204
2205
2206
2207
# File 'ext/mysql.c', line 2200

static VALUE stmt_reset(VALUE obj)
{
    struct mysql_stmt* s = DATA_PTR(obj);
    check_stmt_closed(obj);
    if (mysql_stmt_reset(s->stmt))
	mysql_stmt_raise(s->stmt);
    return obj;
}

#result_metadataObject

result_metadata()



2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
# File 'ext/mysql.c', line 2211

static VALUE stmt_result_metadata(VALUE obj)
{
    struct mysql_stmt* s = DATA_PTR(obj);
    MYSQL_RES *res;
    check_stmt_closed(obj);
    res = mysql_stmt_result_metadata(s->stmt);
    if (res == NULL) {
      if (mysql_stmt_errno(s->stmt) != 0)
	mysql_stmt_raise(s->stmt);
      return Qnil;
    }
    return mysqlres2obj(res, Qfalse);
}

#row_seek(offset) ⇒ Object

row_seek(offset)



2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
# File 'ext/mysql.c', line 2226

static VALUE stmt_row_seek(VALUE obj, VALUE offset)
{
    struct mysql_stmt* s = DATA_PTR(obj);
    MYSQL_ROW_OFFSET prev_offset;
    if (CLASS_OF(offset) != cMysqlRowOffset)
	rb_raise(rb_eTypeError, "wrong argument type %s (expected Mysql::RowOffset)", rb_obj_classname(offset));
    check_stmt_closed(obj);
    prev_offset = mysql_stmt_row_seek(s->stmt, DATA_PTR(offset));
    return Data_Wrap_Struct(cMysqlRowOffset, 0, NULL, prev_offset);
}

#row_tellObject

row_tell()



2238
2239
2240
2241
2242
2243
2244
2245
# File 'ext/mysql.c', line 2238

static VALUE stmt_row_tell(VALUE obj)
{
    struct mysql_stmt* s = DATA_PTR(obj);
    MYSQL_ROW_OFFSET offset;
    check_stmt_closed(obj);
    offset = mysql_stmt_row_tell(s->stmt);
    return Data_Wrap_Struct(cMysqlRowOffset, 0, NULL, offset);
}

#send_long_data(col, data) ⇒ Object

send_long_data(col, data)



2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
# File 'ext/mysql.c', line 2249

static VALUE stmt_send_long_data(VALUE obj, VALUE col, VALUE data)
{
    struct mysql_stmt* s = DATA_PTR(obj);
    int c;
    check_stmt_closed(obj);
    c = NUM2INT(col);
    if (0 <= c && c < s->param.n) {
	s->param.bind[c].buffer_type = MYSQL_TYPE_STRING;
	if (mysql_stmt_bind_param(s->stmt, s->param.bind))
	    mysql_stmt_raise(s->stmt);
    }
    if (mysql_stmt_send_long_data(s->stmt, c, RSTRING_PTR(data), RSTRING_LEN(data)))
	mysql_stmt_raise(s->stmt);
    return obj;
}

#sqlstateObject

sqlstate()



2267
2268
2269
2270
2271
# File 'ext/mysql.c', line 2267

static VALUE stmt_sqlstate(VALUE obj)
{
    struct mysql_stmt* s = DATA_PTR(obj);
    return rb_tainted_str_new2(mysql_stmt_sqlstate(s->stmt));
}