Re: log bind parameter values on error
От | Alexey Bashtanov |
---|---|
Тема | Re: log bind parameter values on error |
Дата | |
Msg-id | 0da3d152-be04-7cfb-56b3-866f24223e69@imap.cc обсуждение исходный текст |
Ответ на | Re: log bind parameter values on error (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>) |
Ответы |
Re: log bind parameter values on error
|
Список | pgsql-hackers |
Hello and sorry for weeks of silence.
Sure. Provided you're in the postgres checkout and you've run make in src/test/examples/ this should work
CREATE SCHEMA testlibpq3;
SET search_path = testlibpq3;
CREATE TABLE test1_(i int4, t text, b bytea);
INSERT INTO test1_ VALUES(0, '', '');
CREATE VIEW test1 AS SELECT 1/i i, t, b FROM test1_;
-- will log only statement
\! ./src/test/examples/testlibpq3
ALTER SYSTEM SET log_parameters_on_error TO on;
SELECT pg_reload_conf();
-- will log statement with parameters
\! ./src/test/examples/testlibpq3
That's why the error message came without parameters.
Please find rebased patch attached.
I apologize for no reply before: I first thought my patch was really faulty and knew I wouldn't have time to fix it these days, but it seems to me it actually works.
Anyway, I don't suppose you manage to review it within the remaining few days, so I'll rebase it again in the beginning of the next CF.
Best regards,
Alexey
Hello Anders and Peter, Thanks for your messages. Please see the new patch version attached.In my testing, I couldn't get this patch to do anything. Could you please share your testing steps?
Sure. Provided you're in the postgres checkout and you've run make in src/test/examples/ this should work
CREATE SCHEMA testlibpq3;
SET search_path = testlibpq3;
CREATE TABLE test1_(i int4, t text, b bytea);
INSERT INTO test1_ VALUES(0, '', '');
CREATE VIEW test1 AS SELECT 1/i i, t, b FROM test1_;
-- will log only statement
\! ./src/test/examples/testlibpq3
ALTER SYSTEM SET log_parameters_on_error TO on;
SELECT pg_reload_conf();
-- will log statement with parameters
\! ./src/test/examples/testlibpq3
I guess this error occurred while binding, so the parameters probably weren't yet all bound by the time of error reporting.I did postgres -D data --log-parameters-on-error=on pgbench -i bench alter table pgbench_accounts alter column aid type smallint; pgbench -M extended -S -T 10 bench This will then error out on type overflows, but I don't see any parameters being logged: ERROR: value "62812" is out of range for type smallint STATEMENT: SELECT abalance FROM pgbench_accounts WHERE aid = $1; (In this case the error message contains the parameter value, so it's not a very practical case, but it should work, it seems.)
That's why the error message came without parameters.
Meanwhile, I have committed a patch that refactors the ParamListInfo initialization a bit, so you don't have to initialize hasTextValues in a bunch of places unrelated to your core code. So please rebase your patch on that.
Please find rebased patch attached.
I apologize for no reply before: I first thought my patch was really faulty and knew I wouldn't have time to fix it these days, but it seems to me it actually works.
Anyway, I don't suppose you manage to review it within the remaining few days, so I'll rebase it again in the beginning of the next CF.
Best regards,
Alexey
Вложения
В списке pgsql-hackers по дате отправления: