Class: DuckDB::ExtractedStatements

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

Instance Method Summary collapse

Constructor Details

#initialize(con, query) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'ext/duckdb/extracted_statements.c', line 41

static VALUE duckdb_extracted_statements_initialize(VALUE self, VALUE con, VALUE query) {
    rubyDuckDBConnection *pcon;
    rubyDuckDBExtractedStatements *ctx;
    char *pquery;
    const char *error;

    if (rb_obj_is_kind_of(con, cDuckDBConnection) != Qtrue) {
        rb_raise(rb_eTypeError, "1st argument must be DuckDB::Connection");
    }

    pquery = StringValuePtr(query);
    pcon = get_struct_connection(con);
    TypedData_Get_Struct(self, rubyDuckDBExtractedStatements, &extract_statements_data_type, ctx);

    ctx->num_statements = duckdb_extract_statements(pcon->con, pquery, &(ctx->extracted_statements));

    if (ctx->num_statements == 0) {
        error = duckdb_extract_statements_error(ctx->extracted_statements);
        rb_raise(eDuckDBError, "%s", error);
    }

    return self;
}

Instance Method Details

#prepared_statement(con, index) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
# File 'ext/duckdb/extracted_statements.c', line 74

static VALUE duckdb_extracted_statements_prepared_statement(VALUE self, VALUE con, VALUE index) {
    rubyDuckDBConnection *pcon;
    rubyDuckDBExtractedStatements *ctx;

    if (rb_obj_is_kind_of(con, cDuckDBConnection) != Qtrue) {
        rb_raise(rb_eTypeError, "1st argument must be DuckDB::Connection");
    }
    pcon = get_struct_connection(con);
    TypedData_Get_Struct(self, rubyDuckDBExtractedStatements, &extract_statements_data_type, ctx);

    return rbduckdb_prepared_statement_new(pcon->con, ctx->extracted_statements, NUM2ULL(index));
}

#sizeObject



65
66
67
68
69
70
71
# File 'ext/duckdb/extracted_statements.c', line 65

static VALUE duckdb_extracted_statements_size(VALUE self) {
    rubyDuckDBExtractedStatements *ctx;

    TypedData_Get_Struct(self, rubyDuckDBExtractedStatements, &extract_statements_data_type, ctx);

    return ULL2NUM(ctx->num_statements);
}