From: ts Date: 2003-02-12T19:59:51+09:00 Subject: Re: PostgreSQL and embedded Ruby >>>>> "S" == Szymon Drejewicz writes: S> -e:1: method call on terminated object (NotImplementedError) S> -e:1: [BUG] Segmentation fault pigeon% cat a.c #include #include #include int main(int argc, char** argv) { PGresult *result; PGconn *conn; int nFields; int i; int j; VALUE rb_cPGconn; conn = PQconnectdb(""); if(PQstatus(conn) == CONNECTION_OK) { printf("connection made\n"); result = PQexec(conn, "SELECT COUNT(*) FROM studenci"); nFields = PQnfields(result); for (i = 0; i < nFields; i++) printf("%-15s", PQfname(result, i)); printf("\n\n"); for (i = 0; i < PQntuples(result); i++) { for (j = 0; j < nFields; j++) printf("%-15s", PQgetvalue(result, i, j)); printf("\n"); } ruby_init(); // ruby_options(argc,argv); ruby_init_loadpath(); rb_require("postgres"); rb_cPGconn = rb_const_get(rb_cObject, rb_intern("PGconn")); //-----------------PROBLEM BEGIN { VALUE DBconn = Data_Wrap_Struct(rb_cPGconn, 0, 0, conn); // rb_obj_call_init(DBconn,0,0); VALUE connection = conn; rb_define_variable("$conn",&DBconn); rb_eval_string("puts '\nTEST\n'"); rb_eval_string("a = $conn.query('select count(*) from studenci')[0][0] \n puts a"); } //-----------------PROBLEM END } else printf("connection failed: %s\n", PQerrorMessage(conn)); PQfinish(conn); return EXIT_SUCCESS; } pigeon% pigeon% ./a.out connection made count 1 TEST 1 pigeon% Guy Decoux