Re: Extensions, this time with a patch
От | Dimitri Fontaine |
---|---|
Тема | Re: Extensions, this time with a patch |
Дата | |
Msg-id | m2bp6sy5ug.fsf@2ndQuadrant.fr обсуждение исходный текст |
Ответ на | Re: Extensions, this time with a patch (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: Extensions, this time with a patch
|
Список | pgsql-hackers |
Tom Lane <tgl@sss.pgh.pa.us> writes: > Alvaro Herrera <alvherre@commandprompt.com> writes: >> Eh, I realize now that the right way to go about this is to use SPI. > > Yeah, that would be one way to go about it. But IMO postgres.c should > be solely concerned with interactions with the client. I didn't notice it's "possible" to use SPI from within the backend core code, and now see precedent in xml.c where the user can give a query string. I've used SPI_execute() in the new (attached) version of the patch, that's not touching postgres.c at all anymore. The bulk of it is now short enough to be inlined in the mail, and if you have more comments I guess they'll be directed at this portion of the patch, so let's make it easy: /* * We abuse some internal knowledge from spi.h here. As we don't know * which queries are going to get executed, we don't know what to expect * as an OK return code from SPI_execute(). We assume that * SPI_OK_CONNECT, SPI_OK_FINISH and SPI_OK_FETCH are quite improbable, * though, and the errors are negatives. So a valid return code is * considered to be SPI_OK_UTILITY or anything from there. */ SPI_connect(); if (SPI_execute(query_string, false, 0) < SPI_OK_UTILITY) ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION), errmsg("File '%s' contains invalid query", filename))); SPI_finish(); Regards, -- Dimitri Fontaine http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support
Вложения
В списке pgsql-hackers по дате отправления: