我在 postgresql 9.1(http://doxygen.postgresql.org/postgres_8c_source.html#l00829第 1094 行)的 postgres.c(在 exexc_simple_query 内部)工作。我需要在一个表中插入一些查询信息,稍后我将检查该表。我正在尝试使用这三行通过 SPI 来实现:
SPI_connect();
SPI_exec("INSERT INTO testvalues (11,6)", 5);
SPI_finish();
但是当我启动服务器并发送查询时,出现分段错误:
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
你知道我该如何解决吗?有没有更好的方法从 postgres.c 插入数据?