summaryrefslogtreecommitdiff
path: root/src/backend/tcop/postgres.c
AgeCommit message (Collapse)Author
2007-08-02Move session_start out of MyProcPort stucture and make it a global called ↵Andrew Dunstan
MyStartTime, so that we will be able to create a cookie for all processes for CSVlogs. It is set wherever MyProcPid is set. Take the opportunity to remove the now unnecessary session-only restriction on the %s and %c escapes in log_line_prefix.
2007-07-09Fix single-user mode so that interrupts (particularly SIGTERM andTom Lane
SIGQUIT) will be recognized and processed while waiting for input, rather than only after something has been typed. Also make SIGQUIT do the same thing as SIGTERM in single-user mode, ie, do a normal shutdown and exit. Since it's relatively easy to provoke SIGQUIT from the keyboard, people may try that instead of control-D, and we'd rather this leads to orderly shutdown. Per report from Leon Mergen and subsequent discussion.
2007-06-29Arrange for SIGINT in autovacuum workers to cancel the current table andAlvaro Herrera
continue with the schedule. Change current uses of SIGINT to abort a worker into SIGTERM, which keeps the old behaviour of terminating the process. Patch from ITAGAKI Takahiro, with some editorializing of my own.
2007-06-23Separate parse-analysis for utility commands out of parser/analyze.cTom Lane
(which now deals only in optimizable statements), and put that code into a new file parser/parse_utilcmd.c. This helps clarify and enforce the design rule that utility statements shouldn't be processed during the regular parse analysis phase; all interpretation of their meaning should happen after they are given to ProcessUtility to execute. (We need this because we don't retain any locks for a utility statement that's in a plan cache, nor have any way to detect that it's stale.) We are also able to simplify the API for parse_analyze() and related routines, because they will now always return exactly one Query structure. In passing, fix bug #3403 concerning trying to add a serial column to an existing temp table (this is largely Heikki's work, but we needed all that restructuring to make it safe).
2007-04-30Fix oversight in my patch of yesterday: forgot to ensure that stats wouldTom Lane
still be forced out at backend exit.
2007-04-16Make plancache store cursor options so it can pass them to planner duringTom Lane
a replan. I had originally thought this was not necessary, but the new SPI facilities create a path whereby queries planned with non-default options can get into the cache, so it is necessary.
2007-04-16Expose more cursor-related functionality in SPI: specifically, allowTom Lane
access to the planner's cursor-related planning options, and provide new FETCH/MOVE routines that allow access to the full power of those commands. Small refactoring of planner(), pg_plan_query(), and pg_plan_queries() APIs to make it convenient to pass the planning options down from SPI. This is the core-code portion of Pavel Stehule's patch for scrollable cursor support in plpgsql; I'll review and apply the plpgsql changes separately.
2007-03-29exec_parse_message neglected to copy parameter type array into theTom Lane
required memory context when handling client-specified parameter types for an unnamed statement. Per report from Kris Jurka.
2007-03-22Arrange for PreventTransactionChain to reject commands submitted as partTom Lane
of a multi-statement simple-Query message. This bug goes all the way back, but unfortunately is not nearly so easy to fix in existing releases; it is only the recent ProcessUtility API change that makes it fixable in HEAD. Per report from William Garrison.
2007-03-13First phase of plan-invalidation project: create a plan cache managementTom Lane
module and teach PREPARE and protocol-level prepared statements to use it. In service of this, rearrange utility-statement processing so that parse analysis does not assume table schemas can't change before execution for utility statements (necessary because we don't attempt to re-acquire locks for utility statements when reusing a stored plan). This requires some refactoring of the ProcessUtility API, but it ends up cleaner anyway, for instance we can get rid of the QueryContext global. Still to do: fix up SPI and related code to use the plan cache; I'm tempted to try to make SQL functions use it too. Also, there are at least some aspects of system state that we want to ensure remain the same during a replan as in the original processing; search_path certainly ought to behave that way for instance, and perhaps there are others.
2007-03-03Add resetStringInfo(), which clears the content of a StringInfo, andNeil Conway
fixup various places in the tree that were clearing a StringInfo by hand. Making this function a part of the API simplifies client code slightly, and avoids needlessly peeking inside the StringInfo interface.
2007-03-02Make log_min_error_statement put LOG level at the same priority asTom Lane
log_min_messages does; and arrange to suppress the duplicative output that would otherwise result from log_statement and log_duration messages. Bruce Momjian and Tom Lane.
2007-02-20Remove the Query structure from the executor's API. This allows us to stopTom Lane
storing mostly-redundant Query trees in prepared statements, portals, etc. To replace Query, a new node type called PlannedStmt is inserted by the planner at the top of a completed plan tree; this carries just the fields of Query that are still needed at runtime. The statement lists kept in portals etc. now consist of intermixed PlannedStmt and bare utility-statement nodes --- no Query. This incidentally allows us to remove some fields from Query and Plan nodes that shouldn't have been there in the first place. Still to do: simplify the execution-time range table; at the moment the range table passed to the executor still contains Query trees for subqueries. initdb forced due to change of stored rules.
2007-02-17Add code so that when COPY_PARSE_PLAN_TREES is defined, the copy andTom Lane
equal functions are checked for raw parse trees as well as post-analysis trees. This was never very important before, but the upcoming plan cache control module will need to be able to do copyObject() on raw parse trees.
2007-02-15Restructure autovacuum in two processes: a dummy process, which runsAlvaro Herrera
continuously, and requests vacuum runs of "autovacuum workers" to postmaster. The workers do the actual vacuum work. This allows for future improvements, like allowing multiple autovacuum jobs running in parallel. For now, the code keeps the original behavior of having a single autovac process at any time by sleeping until the previous worker has finished.
2007-02-10StrNCpy -> strlcpy (not complete)Peter Eisentraut
2007-01-05Update CVS HEAD for 2007 copyright. Back branches are typically notBruce Momjian
back-stamped for this.
2007-01-04Fix erroneous implementation of -s in postmaster.c (the switch doesn't takeTom Lane
an optarg). Add some comments noting that code in three different files has to be kept in sync. Fix erroneous description of -S switch (it sets work_mem not silent_mode), and do some light copy-editing elsewhere in postgres-ref.
2006-12-08Fix the build for when SHOW_MEMORY_STATS is defined. The reference toNeil Conway
the nonexistent ShowStats variable is simply removed, per Gavin Sherry.
2006-11-21On systems that have setsid(2) (which should be just about everything exceptTom Lane
Windows), arrange for each postmaster child process to be its own process group leader, and deliver signals SIGINT, SIGTERM, SIGQUIT to the whole process group not only the direct child process. This provides saner behavior for archive and recovery scripts; in particular, it's possible to shut down a warm-standby recovery server using "pg_ctl stop -m immediate", since delivery of SIGQUIT to the startup subprocess will result in killing the waiting recovery_command. Also, this makes Query Cancel and statement_timeout apply to scripts being run from backends via system(). (There is no support in the core backend for that, but it's widely done using untrusted PLs.) Per gripe from Stephen Harris and subsequent discussion.
2006-11-21Adjust elog.c so that elog(FATAL) exits (including cases where ERROR isTom Lane
promoted to FATAL) end in exit(1) not exit(0). Then change the postmaster to allow exit(1) without a system-wide panic, but not for the startup subprocess or the bgwriter. There were a couple of places that were using exit(1) to deliberately force a system-wide panic; adjust these to be exit(2) instead. This fixes the problem noted back in July that if the startup process exits with elog(ERROR), the postmaster would think everything is hunky-dory and proceed to start up. Alternative solutions such as trying to run the entire startup process as a critical section seem less clean, primarily because of the fact that a fair amount of startup code is shared by all postmaster children in the EXEC_BACKEND case. We'd need an ugly special case somewhere near the head of main.c to make it work if it's the child process's responsibility to determine what happens; and what's the point when the postmaster already treats different children differently?
2006-10-19Make sure that debug_query_string contains the original query text,Tom Lane
if available (which it usually should be), during processing of Bind and Execute protocol messages. This improves usefulness of log_min_error_statement logging for extended query protocol.
2006-10-08Add include needed for new getrusage() call.Bruce Momjian
2006-10-08On Windows, we know the backend stack size limit because we have toTom Lane
specify it explicitly in backend/Makefile. Arrange for this value to be known by get_stack_depth_rlimit() too. Per suggestion from Magnus.
2006-10-07When planning a query at Bind time, be careful to pass the correctTom Lane
query_list into the Portal, ie, the one seen and possibly modified by the planner. My fault :-( Per report from Sergey Koposov.
2006-10-07On platforms that have getrlimit(RLIMIT_STACK), use it to ensure thatTom Lane
max_stack_depth is not set to an unsafe value. This commit also provides configure-time checking for <sys/resource.h>, and cleans up some perhaps-unportable code associated with use of that include file and getrlimit().
2006-10-07Adjust HINT for stack depth limit to mention checking the underlyingTom Lane
platform limit, rather than just blindly raising max_stack_depth. Also, tweak the code to work properly if someone sets max_stack_depth to more than 2Gb, which guc.c will allow on a 64-bit machine.
2006-10-04pgindent run for 8.2.Bruce Momjian
2006-09-13Make logging of extended-protocol commands a bit more consistent, perTom Lane
discussion with Guillaume Smet.
2006-09-08Tweak the behavior of log_duration as proposed by Guillaume Smet: ratherTom Lane
than being equivalent to setting log_min_duration_statement to zero, this option now forces logging of all query durations, but doesn't force logging of query text. Also, add duration logging coverage for fastpath function calls.
2006-09-07Clean up logging for extended-query-protocol operations, as per my recentTom Lane
proposal. Parameter logging works even for binary-format parameters, and logging overhead is avoided when disabled. log_statement = all output for the src/test/examples/testlibpq3.c example now looks like LOG: statement: execute <unnamed>: SELECT * FROM test1 WHERE t = $1 DETAIL: parameters: $1 = 'joe''s place' LOG: statement: execute <unnamed>: SELECT * FROM test1 WHERE i = $1::int4 DETAIL: parameters: $1 = '2' and log_min_duration_statement = 0 results in LOG: duration: 2.431 ms parse <unnamed>: SELECT * FROM test1 WHERE t = $1 LOG: duration: 2.335 ms bind <unnamed> to <unnamed>: SELECT * FROM test1 WHERE t = $1 DETAIL: parameters: $1 = 'joe''s place' LOG: duration: 0.394 ms execute <unnamed>: SELECT * FROM test1 WHERE t = $1 DETAIL: parameters: $1 = 'joe''s place' LOG: duration: 1.251 ms parse <unnamed>: SELECT * FROM test1 WHERE i = $1::int4 LOG: duration: 0.566 ms bind <unnamed> to <unnamed>: SELECT * FROM test1 WHERE i = $1::int4 DETAIL: parameters: $1 = '2' LOG: duration: 0.173 ms execute <unnamed>: SELECT * FROM test1 WHERE i = $1::int4 DETAIL: parameters: $1 = '2' (This example demonstrates the folly of ignoring parse/bind steps for duration logging purposes, BTW.) Along the way, create a less ad-hoc mechanism for determining which commands are logged by log_statement = mod and log_statement = ddl. The former coding was actually missing quite a few things that look like ddl to me, and it did not handle EXECUTE or extended query protocol correctly at all. This commit does not do anything about the question of whether log_duration should be removed or made less redundant with log_min_duration_statement.
2006-09-06Change processing of extended-Query mode so that an unnamed statementTom Lane
that has parameters is always planned afresh for each Bind command, treating the parameter values as constants in the planner. This removes the performance penalty formerly often paid for using out-of-line parameters --- with this definition, the planner can do constant folding, LIKE optimization, etc. After a suggestion by Andrew@supernews.
2006-09-03Revert FETCH/MOVE int64 patch. Was using incorrect checks forBruce Momjian
fetch/move in scan.l.
2006-09-02Change FETCH/MOVE to use int8.Bruce Momjian
Dhanaraj M
2006-08-30Update logging of prepare/execute syntax, per comments from Guillaume Smet.Bruce Momjian
2006-08-29Separate prepared statement and bind parameters with comma.Bruce Momjian
Fix printing of NULL bind parameters, use "NULL".
2006-08-29Only call log_after_parse() if necessary.Bruce Momjian
2006-08-29Now bind displays prepare as detail, and execute displays prepare andBruce Momjian
optionally bind. I re-added the "statement:" label so people will understand why the line is being printed (it is log_*statement behavior). Use single quotes for bind values, instead of double quotes, and double literal single quotes in bind values (and document that). I also made use of the DETAIL line to have much cleaner output.
2006-08-15Add server support for "plugin" libraries that can be used for add-on tasksTom Lane
such as debugging and performance measurement. This consists of two features: a table of "rendezvous variables" that allows separately-loaded shared libraries to communicate, and a new GUC setting "local_preload_libraries" that allows libraries to be loaded into specific sessions without explicit cooperation from the client application. To make local_preload_libraries as flexible as possible, we do not restrict its use to superusers; instead, it is restricted to load only libraries stored in $libdir/plugins/. The existing LOAD command has also been modified to allow non-superusers to LOAD libraries stored in this directory. This patch also renames the existing GUC variable preload_libraries to shared_preload_libraries (after a suggestion by Simon Riggs) and does some code refactoring in dfmgr.c to improve clarity. Korry Douglas, with a little help from Tom Lane.
2006-08-13Fix core dump in duration logging for a V3-protocol Execute messageTom Lane
when what's being executed is a COMMIT or ROLLBACK. Per report from Sergey Koposov. Backpatch to 8.1; 8.0 and before don't have the bug due to lack of any logging at all here.
2006-08-10Fix display of log duration so it is milliseconds.microseconds "ms".Bruce Momjian
Greg Sabino Mullane
2006-08-08For protocol-level prepare/bind/execute:Bruce Momjian
o print user name for all o print portal name if defined for all o print query for all o reduce log_statement header to single keyword o print bind parameters as DETAIL if text mode
2006-08-06Use better named loop variable for large loop, rather than 'i'.Bruce Momjian
2006-08-04Improve logging of protocol-level prepared statements.Bruce Momjian
2006-07-29Adjust initialization sequence for timezone_abbreviations so thatTom Lane
it's handled just about like timezone; in particular, don't try to read anything during InitializeGUCOptions. Should solve current startup failure on Windows, and avoid wasted cycles if a nondefault setting is specified in postgresql.conf too. Possibly we need to think about a more general solution for handling 'expensive to set' GUC options.
2006-07-14Remove 576 references of include files that were not needed.Bruce Momjian
2006-07-13Allow include files to compile own their own.Bruce Momjian
Strip unused include files out unused include files, and add needed includes to C files. The next step is to remove unused include files in C files.
2006-06-27Add GUC update_process_title to control whether 'ps' display is updatedBruce Momjian
for every command, default to on.
2006-06-20Remove redundant gettimeofday() calls to the extent practical withoutTom Lane
changing semantics too much. statement_timestamp is now set immediately upon receipt of a client command message, and the various places that used to do their own gettimeofday() calls to mark command startup are referenced to that instead. I have also made stats_command_string use that same value for pg_stat_activity.query_start for both the command itself and its eventual replacement by <IDLE> or <idle in transaction>. There was some debate about that, but no argument that seemed convincing enough to justify an extra gettimeofday() call.
2006-06-18Merge postmaster and postgres command into just postgres. postmasterPeter Eisentraut
symlink is kept for now for compatibility. To call single-user mode, use postgres --single.