Commit Graph

1018 Commits

Author SHA1 Message Date
Tom Lane 6a7273e14c Fix permissions-checking bugs and namespace-search-path bugs in
CONVERSION code.  Still need to figure out what to do about inappropriate
coding in parsing.
2002-11-02 02:33:03 +00:00
Tom Lane 8d43947886 Reduce messages associated with shell-type function arguments/results
from WARNING to NOTICE, since they are expected messages in common cases.
2002-11-01 19:19:58 +00:00
Tom Lane 8a45a2e9b6 Fix miscalculation of remaining free space during tuple chain moving.
Only affects machines where MAXALIGN > 4, and is a boundary-condition
case even there, but still surprising that it's not been identified
before.  Also reduce tuple chain move give-up messages from WARNING
to DEBUG1, since they are not unexpected conditions.
2002-10-31 19:25:29 +00:00
Tom Lane 200b151615 Fix places that were using IsTransactionBlock() as an (inadequate) check
that they'd get to commit immediately on finishing.  There's now a
centralized routine PreventTransactionChain() that implements the
necessary tests.
2002-10-21 22:06:20 +00:00
Bruce Momjian e49c1a9234 Fix ALTER TABLE ... ADD COLUMN for inheritance cases.
Alvaro Herrera
2002-10-21 20:31:52 +00:00
Tom Lane a20e49bea8 Avoid using IsTransactionBlock() in DeferredTriggerSetState(); no real
need for this optimization, and it's too easily fooled anyway.
2002-10-21 19:55:49 +00:00
Tom Lane e16f04cf72 Make CREATE/ALTER/DROP USER/GROUP transaction-safe, or at least pretty
nearly so, by postponing write of flat password file until transaction
commit.
2002-10-21 19:46:45 +00:00
Tom Lane 60992456ed Invert logic in pg_exec_query_string() so that we set a snapshot for
all utility statement types *except* a short list, per discussion a few
days ago.  Add missing SetQuerySnapshot calls in VACUUM and REINDEX,
and guard against calling REINDEX DATABASE from a function (has same
problem as VACUUM).
2002-10-19 20:15:09 +00:00
Bruce Momjian 757b98fda8 Back out Alvaro's patch until regression tests pass. 2002-10-19 03:01:09 +00:00
Bruce Momjian 1a63cc5e90 Fix compile failure caused by new patch. 2002-10-19 02:25:51 +00:00
Bruce Momjian cabad378fc > Huh, I don't know where I got the idea you were (or someone else was?)
> in the position that attislocal should be reset.  I'll clean everything
> up and submit the patch I had originally made.

All right, this is it.  This patch merely checks if child tables have
the column.  If atttypid and atttypmod are the same, the attributes'
attinhcount is incremented; else the operation is aborted.  If child
tables don't have the column, recursively add it.

attislocal is not touched in any case.

Alvaro Herrera
2002-10-19 02:09:45 +00:00
Tom Lane 5a0a79d694 Add missing #include <errno.h>. 2002-10-19 00:25:36 +00:00
Tom Lane 8f2a289d78 Arrange to copy relcache's trigdesc structure at the start of any
query that uses it.  This ensures that triggers will be applied consistently
throughout a query even if someone commits changes to the relation's
pg_class.reltriggers field meanwhile.  Per crash report from Laurette Cisneros.
While at it, simplify memory management in relcache.c, which no longer
needs the old hack to try to keep trigger info in the same place over
a relcache entry rebuild.  (Should try to fix rd_att and rewrite-rule
access similarly, someday.)  And make RelationBuildTriggers simpler and
more robust by making it build the trigdesc in working memory and then
CopyTriggerDesc() into cache memory.
2002-10-14 16:51:30 +00:00
Bruce Momjian ac376a3eb9 As Niel so nicely pointed out this morning, the output of EXPLAIN
ANALYZE is not quite clear when branches of the query are never
executed. So this tiny patch fixes that.

The patch is attached and can also be found at:
http://svana.org/kleptog/pgsql/pgsql-explain.patch

Martijn van Oosterhout
2002-10-14 04:26:54 +00:00
Bruce Momjian 8a7cfa3756 Lock on the rule relation wasn't removed after adding the comment.
Added Tom's patch fix for heap_close.

Rod Taylor
2002-10-09 16:26:46 +00:00
Tom Lane 916d8164df Restrict CREATE OPERATOR CLASS to superusers, per discussion some weeks
ago.
2002-10-04 22:19:29 +00:00
Tom Lane d2db166c75 Require superuser privilege to create a binary-compatible cast, per
discussion some weeks ago.  Also, add a check that two types to be
binary-equivalenced match as to typlen, typbyval, and typalign; if
they don't then it's surely a mistake to equivalence them.
2002-10-04 22:08:44 +00:00
Tom Lane aab47baf6c Hack to make it possible to load CREATE CONSTRAINT TRIGGER commands that
are missing the FROM clause (due to a long-ago pg_dump bug).  Patch by
Stephan Szabo, minor tweaking by Tom Lane.
2002-10-03 21:06:23 +00:00
Tom Lane 6d0d15c451 Make the world at least somewhat safe for zero-column tables, and
remove the special case in ALTER DROP COLUMN to prohibit dropping a
table's last column.
2002-09-28 20:00:19 +00:00
Tom Lane 23616b47d5 ARGH!
Vacuum must not advance pg_database.datvacuumxid nor truncate CLOG
unless it's processed *all* tables in the database.  Vacuums run by
unprivileged users don't count.

(Beats head against nearest convenient wall...)
2002-09-27 20:57:08 +00:00
Tom Lane 233ecca7c9 Further thinking about heap_mark4update: in HeapTupleSelfUpdated case,
executor should not return the tuple as successfully marked, because in
fact it's been deleted.  Not clear that this case has ever been seen
in practice (I think you'd have to write a SELECT FOR UPDATE that calls
a function that deletes some row the SELECT will visit later...) but we
should be consistent.  Also add comments to several other places that
got it right but didn't explain what they were doing.
2002-09-23 22:57:44 +00:00
Tom Lane 5fa3418304 Disallow VACUUM, ANALYZE, TRUNCATE on temp tables belonging to other
backends.  Given that temp tables now store data locally in the local
buffer manager, these things are not going to work safely.
2002-09-23 20:43:41 +00:00
Tom Lane bc1088c28a Get rid of bogus use of heap_mark4update in reindex operations (cf.
recent bug report).  Fix processing of nailed-in-cache indexes;
it appears that REINDEX DATABASE has been broken for months :-(.
2002-09-23 00:42:48 +00:00
Tom Lane c328b6dd8b Replace pg_attribute.attisinherited with attislocal and attinhcount
columns, to allow more correct behavior in multiple-inheritance cases.
Patch by Alvaro Herrera, review by Tom Lane.
2002-09-22 19:42:52 +00:00
Tom Lane ac355d558e Move most of the error checking for foreign-key constraints out of
parse analysis and into the execution code (in tablecmds.c).  This
eliminates a lot of unreasonably complex code that needed to have two
or more execution paths in case it was dealing with a not-yet-created
table column vs. an already-existing one.  The execution code is always
dealing with already-created tables and so needs only one case.  This
also eliminates some potential race conditions (the table wasn't locked
between parse analysis and execution), makes it easy to fix the gripe
about wrong referenced-column names generating a misleading error message,
and lets us easily add a dependency from the foreign-key constraint to
the unique index that it requires the referenced table to have.  (Cf.
complaint from Kris Jurka 12-Sep-2002 on pgsql-bugs.)

Also, third try at building a deletion mechanism that is not sensitive
to the order in which pg_depend entries are visited.  Adding the above-
mentioned dependency exposed the folly of what dependency.c had been
doing: it failed for cases where B depends on C while both auto-depend
on A.  Dropping A should succeed in this case, but was failing if C
happened to be visited before B.  It appears the only solution is two
separate walks over the dependency tree.
2002-09-22 00:37:09 +00:00
Tom Lane eb3adab568 Provide an upgrade strategy for dump files containing functions declared
with OPAQUE.  CREATE LANGUAGE, CREATE TRIGGER, and CREATE TYPE will all
accept references to functions declared with OPAQUE --- but they will
issue a NOTICE, and will modify the function entries in pg_proc to have
the preferred type-safe argument or result types instead of OPAQUE.
Per recent pghackers discussions.
2002-09-21 18:39:26 +00:00
Tom Lane b2735fcd52 Performance improvement for MultiRecordFreeSpace on large relations ---
avoid O(N^2) behavior.  Problem noted and fixed by Stephen Marshall <smarshall@wsicorp.com>,
with some help from Tom Lane.
2002-09-20 19:56:01 +00:00
Tom Lane 316d4e29b2 Code review for check-domain-constraints-in-COPY patch. Do correct thing
when default expression for a domain is being used.  Avoid repetitive
catalog lookups.
2002-09-20 16:56:02 +00:00
Bruce Momjian 5d115bb548 Change domain patch to COERCE_IMPLICIT_CAST, per Tom. 2002-09-20 15:43:03 +00:00
Bruce Momjian a1199e0c4c Fix compile error from Rod's patch. 2002-09-20 15:29:44 +00:00
Bruce Momjian 07a6fa9df1 Fixed this problem and added regression tests in domain.sql.
Also:
- Changed header file order (alphabetical)
- Changed to m = attnum - 1 in binary copy code for consistency

Rod Taylor
2002-09-20 03:52:50 +00:00
Bruce Momjian a834cbe1e9 > I'm not sure why NDirectFileRead/NDirectFileWrite are unused at the
> moment, but they used to be used; I think the correct response is to
> put back the missing counter increments, not rip out the counters.

Ok, fair enough. It's worth noting that they've been broken for a
while -- for example, the HashJoin counter increments were broken when
you comitted r1.20 of executor/nodeHashJoin.c in May of '99.

I've attached a revised patch that doesn't remove the counters (but
doesn't increment them either: I'm not sure of all the places where
the counter should be incremented).

Neil Conway
2002-09-20 03:45:08 +00:00
Tom Lane da395b56cd Tweak heap.c to refuse attempts to create table columns of standalone
composite types.  Add a couple more lsyscache.c routines to support this,
and make use of them in some other places that were doing lookups the
hard way.
2002-09-19 23:40:56 +00:00
Tom Lane 4a0c3a6142 Department of second thoughts: suppressing implicit casts everywhere in
ruleutils display is not such a great idea.  For arguments of functions
and operators I think we'd better keep the historical behavior of showing
such casts explicitly, to ensure that the function/operator is reparsed
the same way when the rule is reloaded.  This also makes the output of
EXPLAIN less obscurantist about exactly what's happening.
2002-09-19 22:48:34 +00:00
Tom Lane b26dfb9522 Extend pg_cast castimplicit column to a three-way value; this allows us
to be flexible about assignment casts without introducing ambiguity in
operator/function resolution.  Introduce a well-defined promotion hierarchy
for numeric datatypes (int2->int4->int8->numeric->float4->float8).
Change make_const to initially label numeric literals as int4, int8, or
numeric (never float8 anymore).
Explicitly mark Func and RelabelType nodes to indicate whether they came
from a function call, explicit cast, or implicit cast; use this to do
reverse-listing more accurately and without so many heuristics.
Explicit casts to char, varchar, bit, varbit will truncate or pad without
raising an error (the pre-7.2 behavior), while assigning to a column without
any explicit cast will still raise an error for wrong-length data like 7.3.
This more nearly follows the SQL spec than 7.2 behavior (we should be
reporting a 'completion condition' in the explicit-cast cases, but we have
no mechanism for that, so just do silent truncation).
Fix some problems with enforcement of typmod for array elements;
it didn't work at all in 'UPDATE ... SET array[n] = foo', for example.
Provide a generalized array_length_coerce() function to replace the
specialized per-array-type functions that used to be needed (and were
missing for NUMERIC as well as all the datetime types).
Add missing conversions int8<->float4, text<->numeric, oid<->int8.
initdb forced.
2002-09-18 21:35:25 +00:00
Tom Lane 53e95eee84 Fix for rare race-condition-like failure: if a backend receives SIGUSR2
(notify/SI-overrun interrupt) while it is in process of doing proc_exit,
it is possible for Async_NotifyHandler() to try to start a transaction
when one is already running.  This leads to Asserts() or worse.  I think
it may only be possible to occur when frontend synchronization is lost
(ie, the elog(FATAL) in SocketBackend() fires), but that is a standard
occurrence after error during COPY.  In any case, I have seen this
failure occur during regression tests, so it is definitely possible.
2002-09-16 01:24:41 +00:00
Peter Eisentraut 5ea9322872 Cast functions can be immutable or stable. 2002-09-15 13:04:16 +00:00
Tom Lane c91b8bc537 Cosmetic fixes from Neil Conway. 2002-09-14 19:59:20 +00:00
Peter Eisentraut d73f8137d2 Translation updates 2002-09-14 13:46:24 +00:00
Tom Lane feb202193d Fix likely cause of rare ALTER TABLE ADD FOREIGN KEY failures ---
don't assume relname field of a relcache entry will stay valid across
lots of operations.
2002-09-12 21:16:42 +00:00
Tom Lane 9a9825f96a Remove heap_mark4update from AlterTableCreateToastTable. This has
never been the correct procedure for locking a relation, and the
recently-found ALTER TABLE bug with adding a constraint and a toast
table in the same command shows why it's a bad idea.
2002-09-06 00:01:53 +00:00
Bruce Momjian e50f52a074 pgindent run. 2002-09-04 20:31:48 +00:00
Tom Lane d61de58906 Arrange for the default permissions on a database to allow temp table
creation to world, but disallow temp table creation in template1.  Per
latest round of pghackers discussion.
I did not force initdb, but the permissions lockdown on template1 will
not take effect unless you do one (or manually REVOKE TEMP ON DATABASE template1 FROM public).
2002-09-03 22:17:35 +00:00
Peter Eisentraut 77f7763b55 Remove all traces of multibyte and locale options. Clean up comments
referring to "multibyte" where it really means character encoding.
2002-09-03 21:45:44 +00:00
Peter Eisentraut c917660a11 Workaround for format strings that are concatenated from macros
(INT64_FORMAT), which gettext cannot handle.
2002-09-03 18:50:54 +00:00
Tom Lane ab82bde7e0 Code review and documentation updates for indisclustered patch. 2002-09-03 01:04:41 +00:00
Tom Lane 8f60f43f2e Department of second thoughts: make checks for replacing a view slightly
more flexible, and improve the error reporting.  Also, add documentation
for REPLACE RULE/VIEW.
2002-09-02 20:04:40 +00:00
Bruce Momjian 97ac103289 Remove sys/types.h in files that include postgres.h, and hence c.h,
because c.h has sys/types.h.
2002-09-02 02:47:07 +00:00
Tom Lane 248c67d7ed CREATE OR REPLACE VIEW, CREATE OR REPLACE RULE.
Gavin Sherry, Neil Conway, and Tom Lane all got their hands dirty
on this one ...
2002-09-02 02:13:02 +00:00
Tom Lane c7a165adc6 Code review for HeapTupleHeader changes. Add version number to page headers
(overlaying low byte of page size) and add HEAP_HASOID bit to t_infomask,
per earlier discussion.  Simplify scheme for overlaying fields in tuple
header (no need for cmax to live in more than one place).  Don't try to
clear infomask status bits in tqual.c --- not safe to do it there.  Don't
try to force output table of a SELECT INTO to have OIDs, either.  Get rid
of unnecessarily complex three-state scheme for TupleDesc.tdhasoids, which
has already caused one recent failure.  Improve documentation.
2002-09-02 01:05:06 +00:00