Class: DuckDB::ExtractedStatementsImpl
- Inherits:
-
Object
- Object
- DuckDB::ExtractedStatementsImpl
- Defined in:
- ext/duckdb/extracted_statements.c
Direct Known Subclasses
Instance Method Summary collapse
- #destroy ⇒ Object
- #initialize(con, query) ⇒ Object constructor
- #prepared_statement(con, index) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(con, query) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'ext/duckdb/extracted_statements.c', line 42 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 ? error : "Failed to extract statements(Database connection closed?)."); } return self; } |
Instance Method Details
#destroy ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'ext/duckdb/extracted_statements.c', line 66 static VALUE duckdb_extracted_statements_destroy(VALUE self) { rubyDuckDBExtractedStatements *ctx; TypedData_Get_Struct(self, rubyDuckDBExtractedStatements, &extract_statements_data_type, ctx); duckdb_destroy_extracted(&(ctx->extracted_statements)); return Qnil; } |
#prepared_statement(con, index) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'ext/duckdb/extracted_statements.c', line 84 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)); } |
#size ⇒ Object
76 77 78 79 80 81 82 |
# File 'ext/duckdb/extracted_statements.c', line 76 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); } |