0

I'm trying to analyze how postgreSQL parse a query, and after some postgreSQL source code tracing with embedding printf() here and there, I've known that the query will be parsed into raw parse tree with raw_parser, which located in file parser.c.

The strange thing is, I've already embedded a printf() dummy in the raw_parser, and after re-installing the postgreSQL and execute a query, my printf() dummy is not printed to the screen!

Can anybody please help me, where I went wrong?

Thanks in advance :D

1
  • One possibility is that the handle for stdout has been closed or changed to something you don't expect. Try opening your own file and writing to that file. Commented Oct 23, 2011 at 6:19

1 Answer 1

1

If you use fprintf(stderr, "....");, the output will appear in the server log.
Remember — you are not interacting with the server directly.

For debugging purposes, PostgreSQL provides a elog, a function that works like printf for client applications:

elog(NOTICE, "some text");

The format string follows the same conventions as printf, but keep in mind that PostgreSQL uses its own formatting system, which differs from glibc. You can display only integer or floating-point variables. String variables use a different format than the standard C null-terminated string.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.