Commit Graph

431 Commits

Author SHA1 Message Date
Tom Lane fdc60bd9d9 Tweak pg_exec_query_string so that we close down transaction command
before reporting command-complete message for the final command of a
query string.  This way, any errors detected during finish_xact_command
(such as RI violations) will appear to be part of the final command,
rather than coming out after the command is reported complete.  This
avoids confusing PQendcopy and other not-overly-bright clients.
Per Lee Harr's bug report of 25-Feb-02.
2002-02-27 23:16:07 +00:00
Tom Lane 04cb9a6a16 Paranoia about data structure lifetime ... 2002-02-27 19:52:41 +00:00
Tom Lane 6779c55c22 Clean up BeginCommand and related routines. BeginCommand and EndCommand
are now both invoked once per received SQL command (raw parsetree) from
pg_exec_query_string.  BeginCommand is actually just an empty routine
at the moment --- all its former operations have been pushed into tuple
receiver setup routines in printtup.c.  This makes for a clean distinction
between BeginCommand/EndCommand (once per command) and the tuple receiver
setup/teardown routines (once per ExecutorRun call), whereas the old code
was quite ad hoc.  Along the way, clean up the calling conventions for
ExecutorRun a little bit.
2002-02-27 19:36:13 +00:00
Tom Lane 56ee2ecba9 Restructure command-completion-report code so that there is just one
report for each received SQL command, regardless of rewriting activity.
Also ensure that this report comes from the 'original' command, not the
last command generated by rewrite; this fixes 7.2 breakage for INSERT
commands that have actions added by rules.  Fernando Nasser and Tom Lane.
2002-02-26 22:47:12 +00:00
Tom Lane a833c441fd Add OWNER option to CREATE DATABASE, so superusers can create databases
on behalf of unprivileged users.  Also, make '=' optional in CREATE
DATABASE syntax.  From Gavin Sherry, with kibitzing and docs by Tom Lane.
2002-02-24 20:20:21 +00:00
Peter Eisentraut 51f195580f Save source of GUC settings, allowing different sources to be processed in
any order without affecting results.
2002-02-23 01:31:37 +00:00
Tom Lane 8e2998d8a6 Remove some unnecessary pqsignal() calls to shave a few cycles off
backend startup.
2002-02-19 19:54:43 +00:00
Hiroshi Inoue e206ff5946 Removed a check for REINDEX TABLE. 2002-02-07 00:27:30 +00:00
Tom Lane 92a2598f97 The result of getopt() should be compared to -1, not EOF, per
pgsql-hackers discussion of this date.
2002-01-10 01:11:45 +00:00
Tom Lane dc6b4deb97 Require ownership permission for CREATE INDEX, per bug report.
Disallow CREATE INDEX on system catalogs, non-tables (views, sequences, etc).
Disallow CREATE/DROP TRIGGER on system catalogs, non-tables.
Disallow ALTER TABLE ADD/DROP CONSTRAINT on system catalogs.
Disallow FOREIGN KEY reference to non-table.
None of these things can actually work in the present system structure,
but the code was letting them pass without complaint.
2002-01-03 23:21:32 +00:00
Tom Lane 4764ae823b Do not accept interrupts in RESUME_INTERRUPTS() and END_CRIT_SECTION()
macros, but only at explicit CHECK_FOR_INTERRUPTS() calls.  Not clear
whether overenthusiastic acceptance of interrupts accounts for any real
bugs, but it definitely seems risky and unnecessary.
2002-01-01 23:16:22 +00:00
Tom Lane f4bd04bb67 Replace pq_getbytes(&ch, 1) calls with pq_getbyte(), which is easier
to use and significantly faster.  This tweak saves 25% (!) of the runtime
of COPY IN in a test with 8000-character lines.  I wouldn't normally
commit a performance improvement this late in the cycle, but 25% got
my attention...
2001-12-04 19:40:17 +00:00
Tom Lane 604f54cd27 Some minor tweaks of REINDEX processing: grab exclusive lock a little
earlier, make error checks more uniform.
2001-11-20 02:46:13 +00:00
Tom Lane f6ee99a062 Clean up usage-statistics display code (ShowUsage and friends). StatFp
is gone, usage messages now go through elog(DEBUG).
2001-11-10 23:51:14 +00:00
Bruce Momjian ea08e6cd55 New pgindent run with fixes suggested by Tom. Patch manually reviewed,
initdb/regression tests pass.
2001-11-05 17:46:40 +00:00
Bruce Momjian 6783b2372e Another pgindent run. Fixes enum indenting, and improves #endif
spacing.  Also adds space for one-line comments.
2001-10-28 06:26:15 +00:00
Bruce Momjian b81844b173 pgindent run on all C files. Java run to follow. initdb/regression
tests pass.
2001-10-25 05:50:21 +00:00
Tom Lane b2e92a712e Fix getopt-vs-init_ps_display problem by copying original argv[] info,
per suggestion from Peter.  Simplify several APIs by transmitting the
original argv location directly from main.c to ps_status.c, instead of
passing it down through several levels of subroutines.
2001-10-21 03:25:36 +00:00
Tom Lane 861a679fc1 Set optreset on platforms that have it before launching postmaster
subprocesses; perhaps this will fix portability problem just noted by
Lockhart.  Also, move test for bad permissions of DataDir to a more
logical place.
2001-10-19 18:19:41 +00:00
Tom Lane 6430e6e283 Ensure that all startup paths (postmaster, standalone postgres, or
bootstrap) check for a valid PG_VERSION file before looking at anything
else in the data directory.  This fixes confusing error report when
trying to start current sources in a pre-7.1 data directory.
Per trouble report from Rich Shepard 10/18/01.
2001-10-19 17:03:08 +00:00
Tom Lane eb133197b6 Move init_ps_display from postgres.c to postmaster.c, putting it
just after receipt of the startup packet.  Now, postmaster children
that are waiting for client authentication response will show as
'postgres: user database host authentication'.  Also, do an
init_ps_display for startup/shutdown/checkpoint subprocesses,
so that they are readily identifiable as well.  Fix an obscure race
condition that could lead to Assert failure in the postmaster ---
attempting to start a checkpoint process before any connections have
been received led to calling PostmasterRandom before setting random_seed.
2001-10-19 00:44:08 +00:00
Thomas G. Lockhart 9310075a13 Accept an INTERVAL argument for SET TIME ZONE per SQL99.
Modified the parser and the SET handlers to use full Node structures
 rather than simply a character string argument.
Implement INTERVAL() YEAR TO MONTH (etc) syntax per SQL99.
 Does not yet accept the goofy string format that goes along with, but
 this should be fairly straight forward to fix now as a bug or later
 as a feature.
Implement precision for the INTERVAL() type.
 Use the typmod mechanism for both of INTERVAL features.
Fix the INTERVAL syntax in the parser:
 opt_interval was in the wrong place.
INTERVAL is now a reserved word, otherwise we get reduce/reduce errors.
Implement an explicit date_part() function for TIMETZ.
 Should fix coersion problem with INTERVAL reported by Peter E.
Fix up some error messages for date/time types.
 Use all caps for type names within message.
Fix recently introduced side-effect bug disabling 'epoch' as a recognized
 field for date_part() etc. Reported by Peter E. (??)
Bump catalog version number.
Rename "microseconds" current transaction time field
 from ...Msec to ...Usec. Duh!
date/time regression tests updated for reference platform, but a few
 changes will be necessary for others.
2001-10-18 17:30:21 +00:00
Tom Lane f9e6e27c87 Break transformCreateStmt() into multiple routines and make
transformAlterStmt() use these routines, instead of having lots of
duplicate (not to mention should-have-been-duplicate) code.
Adding a column with a CHECK constraint actually works now,
and the tests to reject unsupported DEFAULT and NOT NULL clauses
actually fire now.  ALTER TABLE ADD PRIMARY KEY works, modulo
having to have created the column(s) NOT NULL already.
2001-10-12 00:07:15 +00:00
Tom Lane c781600618 Fix typo in error message. Noted by laser@zhengmai.com.cn. 2001-10-09 14:00:22 +00:00
Tom Lane 8a52b893b3 Further cleanup of dynahash.c API, in pursuit of portability and
readability.  Bizarre '(long *) TRUE' return convention is gone,
in favor of just raising an error internally in dynahash.c when
we detect hashtable corruption.  HashTableWalk is gone, in favor
of using hash_seq_search directly, since it had no hope of working
with non-LONGALIGNable datatypes.  Simplify some other code that was
made undesirably grotty by promixity to HashTableWalk.
2001-10-05 17:28:13 +00:00
Tom Lane 3d59ad00e8 Remove useless LockDisable() function and associated overhead, per my
proposal of 26-Aug.
2001-09-27 16:29:13 +00:00
Tom Lane 35b7601b04 Add an overall timeout on the client authentication cycle, so that
a hung client or lost connection can't indefinitely block a postmaster
child (not to mention the possibility of deliberate DoS attacks).
Timeout is controlled by new authentication_timeout GUC variable,
which I set to 60 seconds by default ... does that seem reasonable?
2001-09-21 17:06:12 +00:00
Tom Lane 89fa551808 EXPLAIN ANALYZE feature to measure and show actual runtimes and tuple
counts alongside the planner's estimates.  By Martijn van Oosterhout,
with some further work by Tom Lane.
2001-09-18 01:59:07 +00:00
Tom Lane 02b1a7fd51 Clean up some confusion about where and how to set whereToSendOutput.
We will no longer try to send elog messages to the client before we have
initialized backend libpq (oops); however, reporting bogus commandline
switches via elog does work now (not irrelevant, because of PGOPTIONS).
Fix problem with inappropriate sending of checkpoint-process messages
to stderr.
2001-09-08 01:10:21 +00:00
Jan Wieck 7e26a8241d Enable SIGTERM and SIGQUIT during client authentication so
the postmaster can kill the forked off processes when shutdown
is requested.

Jan
2001-09-07 16:12:49 +00:00
Tom Lane f933766ba7 Restructure pg_opclass, pg_amop, and pg_amproc per previous discussions in
pgsql-hackers.  pg_opclass now has a row for each opclass supported by each
index AM, not a row for each opclass name.  This allows pg_opclass to show
directly whether an AM supports an opclass, and furthermore makes it possible
to store additional information about an opclass that might be AM-dependent.
pg_opclass and pg_amop now store "lossy" and "haskeytype" information that we
previously expected the user to remember to provide in CREATE INDEX commands.
Lossiness is no longer an index-level property, but is associated with the
use of a particular operator in a particular index opclass.

Along the way, IndexSupportInitialize now uses the syscaches to retrieve
pg_amop and pg_amproc entries.  I find this reduces backend launch time by
about ten percent, at the cost of a couple more special cases in catcache.c's
IndexScanOK.

Initial work by Oleg Bartunov and Teodor Sigaev, further hacking by Tom Lane.

initdb forced.
2001-08-21 16:36:06 +00:00
Tom Lane dad8e410d0 Fix handling of SIGCHLD, per recent pghackers discussion: on some
platforms system(2) gets confused unless the signal handler is set to
SIG_DFL, not SIG_IGN.  pgstats.c now uses pqsignal() as it should,
not signal().  Also, arrange for the stats collector process to show
a reasonable ID in 'ps', rather than looking like a postmaster.
2001-08-04 00:14:43 +00:00
Tom Lane 77896d1fc9 Cleanup code for preparsing pg_hba.conf and pg_ident.conf. Store line
number in the data structure so that we can give at least a minimally
useful idea of where the mistake is when we issue syntax error messages.
Move the ClientAuthentication() call to where it should have been in
the first place, so that postmaster memory releasing can happen in a
reasonable place also.  Update obsolete comments, correct one real bug
(auth_argument was not picked up correctly).
2001-07-31 22:55:45 +00:00
Bruce Momjian 462b7d46d1 Load pg_hba.conf and pg_ident.conf on startup and SIGHUP into List of
Lists, and use that for user validation.

Bruce Momjian
2001-07-30 14:50:24 +00:00
Tom Lane f31dc0ada7 Partial indexes work again, courtesy of Martijn van Oosterhout.
Note: I didn't force an initdb, figuring that one today was enough.
However, there is a new function in pg_proc.h, and pg_dump won't be
able to dump partial indexes until you add that function.
2001-07-16 05:07:00 +00:00
Tom Lane f889b12be9 Fix erroneous GUC variable references from commandline-GUC patch. 2001-06-29 16:05:57 +00:00
Tom Lane 2e67a67715 Fix a couple remaining places where GUC variables were assigned to
directly, rather than through SetConfigOption().
2001-06-25 22:56:05 +00:00
Bruce Momjian 6a7f23c213 > Marko Kreen <marko@l-t.ee> writes:
> > secure_ctx changes too.  it will be PGC_BACKEND after '-p'.
>
> Oh, okay, I missed that part.  Could we see the total state of the
> patch --- ie, a diff against current CVS, not a bunch of deltas?
> I've gotten confused about what's in and what's out.

Ok, here it is.  Cleared the ctx comment too - after -p
it will be PGC_BACKEND in any case.

Marko Kreen
2001-06-23 22:23:49 +00:00
Jan Wieck 8d80b0d980 Statistical system views (yet without the config stuff, but
it's hard to keep such massive changes in sync with the tree
so I need to get it in and work from there now).

Jan
2001-06-22 19:16:24 +00:00
Peter Eisentraut 9b4bfbdc2c Handle reading of startup packet and authentication exchange after forking
a new postmaster child process.  This should eliminate problems with
authentication blocking (e.g., ident, SSL init) and also reduce problems
with the accept queue filling up under heavy load.

The option to send elog output to a different file per backend (postgres -o)
has been disabled for now because the initialization would have to happen
in a different order and it's not clear we want to keep this anyway.
2001-06-20 18:07:56 +00:00
Bruce Momjian 2e81f3d204 Back out SET ALL patch because it is breaking things. 2001-06-19 23:40:10 +00:00
Bruce Momjian 3709a5ada7 RESET ALL secondary patch:
Here is Tomified version of my 2 pending patches.
Dropped the set_.._real change as it is not needed.
Desc would be:

* use GUC for settings from cmdline

Marko Kreen
2001-06-18 23:42:32 +00:00
Bruce Momjian 49ce6fff1d Allow removal of system-named pg_* temp tables. Rename temp file/dir as
pgsql_tmp.
2001-06-18 16:13:21 +00:00
Tom Lane 2938eec7fe Extend GUC concepts of parse_hook and assign_hook to all four supported
datatypes, not only strings.  parse_hook is useless for bool, I suppose,
but it seems possibly useful for int and double to apply variable-specific
constraints that are more complex than simple range limits.  assign_hook
is definitely useful for all datatypes --- we need it right now for bool
to support date cache reset when changing Australian timezone rule setting.
Also, clean up some residual problems with the reset all/show all patch,
including memory leaks and mistaken reset of PostPortNumber.  It seems
best that RESET ALL not touch variables that don't have SUSET or
USERSET context.
2001-06-12 22:54:06 +00:00
Peter Eisentraut 7ceed2a9b5 Allow GRANT/REVOKE to/from more than one user per invocation. Command tag
for GRANT/REVOKE is now just that, not "CHANGE".

On the way, migrate some of the aclitem internal representation away from
the parser and build a real parse tree instead.  Also add some 'const'
qualifiers.
2001-06-09 23:21:55 +00:00
Bruce Momjian 4ee76ad884 reset all: command line and .conf options change defaults
on RESET ALL those are restored.

show all: GUC + non-GUC.

SHOW ALL, RESET ALL

Marko Kreen
2001-06-07 04:50:57 +00:00
Tom Lane a51ec450ff Remove fastpath.c's lame attempt at caching function lookup info across
calls.  This has never actually cached anything, because postgres.c does
each fastpath call as a separate transaction command, and so fastpath.c
would always decide that its cache was outdated.  If it had worked, it
would now be failing for calls of oldstyle functions due to dangling
pointers in the FmgrInfo struct.  Rip it out for simplicity and bug-
proofing.
2001-06-01 15:45:42 +00:00
Bruce Momjian 53020d0fbe Remove OLD_FILE_NAMING code. No longer used. 2001-05-30 20:52:34 +00:00
Peter Eisentraut 96147a6d1c Make UPDATE and DELETE privileges distinct. Add REFERENCES and TRIGGER
privileges.  INSERT and COPY FROM now require INSERT (only).  Add
privileges regression test.
2001-05-27 09:59:30 +00:00
Tom Lane f905d65ee3 Rewrite of planner statistics-gathering code. ANALYZE is now available as
a separate statement (though it can still be invoked as part of VACUUM, too).
pg_statistic redesigned to be more flexible about what statistics are
stored.  ANALYZE now collects a list of several of the most common values,
not just one, plus a histogram (not just the min and max values).  Random
sampling is used to make the process reasonably fast even on very large
tables.  The number of values and histogram bins collected is now
user-settable via an ALTER TABLE command.

There is more still to do; the new stats are not being used everywhere
they could be in the planner.  But the remaining changes for this project
should be localized, and the behavior is already better than before.

A not-very-related change is that sorting now makes use of btree comparison
routines if it can find one, rather than invoking '<' twice.
2001-05-07 00:43:27 +00:00