I'm working inside postgres.c (inside exexc_simple_query) of postgresql 9.1 (line 1094 of http://doxygen.postgresql.org/postgres_8c_source.html#l00829 ). I need to insert some query information in a table that I will check in a second moment. I'm trying to do it with SPI using these three lines:
SPI_connect(); SPI_exec("INSERT INTO testvalues (11,6)", 5); SPI_finish();
but when I start the server and I send a query I get segmentation fault:
LOG: server process (PID 13856) was terminated by signal 11: Segmentation fault LOG: terminating any other active server processes WARNING: terminating connection because of crash of another server process DETAIL: The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory. HINT: In a moment you should be able to reconnect to the database and repeat your command. FATAL: the database system is in recovery mode LOG: all server processes terminated; reinitializing LOG: database system was interrupted; last known up at 2013-07-14 00:40:22 CEST LOG: database system was not properly shut down; automatic recovery in progress LOG: record with zero length at 0/17D7368 LOG: redo is not required LOG: autovacuum launcher started LOG: database system is ready to accept connections
Do you have any idea how I can fix it? Is there a better way to insert data from the postgres.c?