Commit Graph

663 Commits

Author SHA1 Message Date
Tom Lane 7fdaf78ed0 Reduce amount of memory used per tuple for after-event triggers. This
is still a memory leak, but a little less bad than it was.
2001-03-14 21:50:32 +00:00
Tom Lane c9f26d7af6 COPY should handle after-insert triggers the same as execMain.c does.
I'm not sure that it's really necessary to save insert events when there
are only after update or delete triggers, but certainly it's wrong for
COPY to behave differently from an INSERT query.
2001-03-14 21:47:50 +00:00
Hiroshi Inoue ebffbb42ac ifdef out reindex stuff in VACUUM for safety. 2001-03-14 08:40:57 +00:00
Tom Lane b246510ccc Avoid O(N^2) behavior in deferredTriggerAddEvent() for large numbers of
tuples inserted/deleted/updated in a single transaction.  On my machine,
this reduced the time to delete 80000 tuples in a foreign-key-referencing
table from ~15min to ~8sec.
2001-03-12 23:02:00 +00:00
Tom Lane b109b03fea Repair a number of places that didn't bother to check whether PageAddItem
succeeds or not.  Revise rtree page split algorithm to take care about
making a feasible split --- ie, will the incoming tuple actually fit?
Failure to make a feasible split, combined with failure to notice the
failure, account for Jim Stone's recent bug report.  I suspect that
hash and gist indices may have the same type of bug, but at least now
we'll get error messages rather than silent failures if so.  Also clean
up rtree code to use Datum rather than char* where appropriate.
2001-03-07 21:20:26 +00:00
Tom Lane 778a21ca94 Tweak portal (cursor) code so that it will not call the executor again
when user does another FETCH after reaching end of data, or another
FETCH backwards after reaching start.  This is needed because some plan
nodes are not very robust about being called again after they've already
returned NULL; for example, MergeJoin will crash in some states but not
others.  While the ideal approach would be for them all to handle this
correctly, it seems foolish to assume that no such bugs would creep in
again once cleaned up.  Therefore, the most robust answer is to prevent
the situation from arising at all.
2001-02-27 22:07:34 +00:00
Hiroshi Inoue 34822e517a Reindex of shared system indexes must be overwrite mode. 2001-02-23 09:26:14 +00:00
Tom Lane 13cc7eb3e2 Clean up two rather nasty bugs in operator selection code.
1. If there is exactly one pg_operator entry of the right name and oprkind,
oper() and related routines would return that entry whether its input type
had anything to do with the request or not.  This is just premature
optimization: we shouldn't return the single candidate until after we verify
that it really is a valid candidate, ie, is at least coercion-compatible
with the given types.

2. oper() and related routines only promise a coercion-compatible result.
Unfortunately, there were quite a few callers that assumed the returned
operator is binary-compatible with the given datatype; they would proceed
to call it without making any datatype coercions.  These callers include
sorting, grouping, aggregation, and VACUUM ANALYZE.  In general I think
it is appropriate for these callers to require an exact or binary-compatible
match, so I've added a new routine compatible_oper() that only succeeds if
it can find an operator that doesn't require any run-time conversions.
Callers now call oper() or compatible_oper() depending on whether they are
prepared to deal with type conversion or not.

The upshot of these bugs is revealed by the following silliness in PL/Tcl's
selftest: it creates an operator @< on int4, and then tries to use it to
sort a char(N) column.  The system would let it do that :-( (and evidently
has done so since 6.3 :-( :-().  The result in this case was just a silly
sort order, but the reverse combination would've provoked coredump from
trying to dereference integers.  With this fix you get more reasonable
behavior:
pltcl_test=# select * from T_pkey1 order by key1, key2 using @<;
ERROR:  Unable to identify an operator '@<' for types 'bpchar' and 'bpchar'
        You will have to retype this query using an explicit cast
2001-02-16 03:16:58 +00:00
Tom Lane 4a66f9dd54 Change scoping of table and join refnames to conform to SQL92: a JOIN
clause with an alias is a <subquery> and therefore hides table references
appearing within it, according to the spec.  This is the same as the
preliminary patch I posted to pgsql-patches yesterday, plus some really
grotty code in ruleutils.c to reverse-list a query tree with the correct
alias name depending on context.  I'd rather not have done that, but unless
we want to force another initdb for 7.1, there's no other way for now.
2001-02-14 21:35:07 +00:00
Philip Warner 0e39c8ac78 Added some comments to setval, setval_is_called and do_setval 2001-02-13 01:57:12 +00:00
Tom Lane aa88e59ade Rearrange order of operations in heap_create_with_catalog so that if
two transactions create the same table name concurrently, the one that
fails will complain about unique index pg_class_relname_index, rather than
about pg_type_typname_index which'll confuse most people.  Free side
benefit: pg_class.reltype is correctly linked to the pg_type entry now.
It's been zero in all but the preloaded pg_class entries since who knows
when.
2001-02-12 20:07:21 +00:00
Tom Lane 0d54d6ac44 Clean up handling of tuple descriptors so that result-tuple descriptors
allocated by plan nodes are not leaked at end of query.  This doesn't
really matter for normal queries, but it sure does for queries invoked
repetitively inside SQL functions.  Clean up some other grotty code
associated with tupdescs, and fix a few other memory leaks exposed by
tests with simple SQL functions.
2001-01-29 00:39:20 +00:00
Tom Lane a6f0adbe38 Looks like I broke cases involving combinations of deferred update/delete
triggers ... oops ... but the regress tests should have covered this ...
2001-01-27 05:16:58 +00:00
Tom Lane c1a63c944d Suppress coredump when EXPLAINing query that is rewritten to include
a NOTIFY.
2001-01-27 01:41:19 +00:00
Bruce Momjian 623bf843d2 Change Copyright from PostgreSQL, Inc to PostgreSQL Global Development Group. 2001-01-24 19:43:33 +00:00
Tom Lane c654c69c05 Narrow scope of critical section, per discussion 1/19/01. 2001-01-23 23:32:45 +00:00
Tom Lane 786f1a59cd Fix all the places that called heap_update() and heap_delete() without
bothering to check the return value --- which meant that in case the
update or delete failed because of a concurrent update, you'd not find
out about it, except by observing later that the transaction produced
the wrong outcome.  There are now subroutines simple_heap_update and
simple_heap_delete that should be used anyplace that you're not prepared
to do the full nine yards of coping with concurrent updates.  In
practice, that seems to mean absolutely everywhere but the executor,
because *noplace* else was checking.
2001-01-23 04:32:23 +00:00
Bruce Momjian 7e533da492 Rename int4 to int32 in a few places. 2001-01-23 01:48:17 +00:00
Tom Lane c9fe128316 Clean up per-tuple memory leaks in trigger firing and plpgsql
expression evaluation.
2001-01-22 00:50:07 +00:00
Tom Lane 6ce0ed2813 Make critical sections (elog->crash) and interrupt holdoff sections
into distinct concepts, per recent discussion on pghackers.
2001-01-19 22:08:47 +00:00
Tom Lane bdb72d8765 Suppress compiler warning in MULTIBYTE case. 2001-01-19 06:54:57 +00:00
Bruce Momjian 5088f0748a Change lcons(x, NIL) to makeList(x) where appropriate. 2001-01-17 17:26:45 +00:00
Tom Lane a3cac3a03b Need to do BufferSync at end of DROP DATABASE as well as CREATE DATABASE.
Otherwise, newly connecting backends will still think the deleted DB is
valid, and will generate unexpected error messages.
2001-01-14 22:14:10 +00:00
Tom Lane 36839c1927 Restructure backend SIGINT/SIGTERM handling so that 'die' interrupts
are treated more like 'cancel' interrupts: the signal handler sets a
flag that is examined at well-defined spots, rather than trying to cope
with an interrupt that might happen anywhere.  See pghackers discussion
of 1/12/01.
2001-01-14 05:08:17 +00:00
Tom Lane 6162432de9 Add more critical-section calls: all code sections that hold spinlocks
are now critical sections, so as to ensure die() won't interrupt us while
we are munging shared-memory data structures.  Avoid insecure intermediate
states in some code that proc_exit will call, like palloc/pfree.  Rename
START/END_CRIT_CODE to START/END_CRIT_SECTION, since that seems to be
what people tend to call them anyway, and make them be called with () like
a function call, in hopes of not confusing pg_indent.
I doubt that this is sufficient to make SIGTERM safe anywhere; there's
just too much code that could get invoked during proc_exit().
2001-01-12 21:54:01 +00:00
Tom Lane 565639cde0 Preserve constraints and column defaults during CLUSTER.
Wish they were all this easy ...
2001-01-12 01:22:21 +00:00
Tom Lane 412cb388b3 Do The Right Thing (tm) if asked to cluster a temp table. Previous
code would cluster, but table would magically lose its tempness.
2001-01-10 01:12:28 +00:00
Hiroshi Inoue 6adc255f8a Keep relations open until they are no longer needed. 2001-01-08 03:14:58 +00:00
Tom Lane 1402201463 Clean up checking of relkind for ALTER TABLE and LOCK TABLE commands.
Disallow cases like adding constraints to sequences :-(, and eliminate
now-unnecessary search of pg_rewrite to decide if a relation is a view.
2001-01-07 00:05:22 +00:00
Tatsuo Ishii a6944611e2 Fix copy to make it more robust against unexpected character
sequences. This is done by disabling multi-byte awareness when it's
not necessary. This is kind of a workaround, not a perfect solution.
However, there is no ideal way to parse broken multi-byte character
sequences. So I guess this is the best way what we could do right
now...
2001-01-06 03:33:17 +00:00
Tom Lane e62c38d0fc Disallow creation of a child table by a user who does not own the parent
table, per pghackers discussion around 22-Dec-00.
2001-01-05 02:58:16 +00:00
Tom Lane 676cf18c5b New file format for COPY BINARY, in accordance with pghackers discussions
of early December 2000.  COPY BINARY is now TOAST-safe.
2001-01-03 20:04:10 +00:00
Tom Lane 8fd2e269f7 MakeRetrieveViewRuleName was scribbling on memory that didn't belong
to it.  Bad dog.
2001-01-03 18:43:09 +00:00
Tom Lane ad0169b1b7 CLUSTER forgot to create a TOAST table for the clustered relation. 2001-01-01 21:35:00 +00:00
Vadim B. Mikheev 3e059b3802 1. WAL needs in zero-ed content of newly initialized page.
2. Log record for PageRepaireFragmentation now keeps array
   of !LP_USED offnums to redo cleanup properly.
2000-12-30 15:19:57 +00:00
Vadim B. Mikheev 7ceeeb662f New WAL version - CRC and data blocks backup. 2000-12-28 13:00:29 +00:00
Tom Lane 8609d4abf2 Fix portability problems recently exposed by regression tests on Alphas.
1. Distinguish cases where a Datum representing a tuple datatype is an OID
from cases where it is a pointer to TupleTableSlot, and make sure we use
the right typlen in each case.
2. Make fetchatt() and related code support 8-byte by-value datatypes on
machines where Datum is 8 bytes.  Centralize knowledge of the available
by-value datatype sizes in two macros in tupmacs.h, so that this will be
easier if we ever have to do it again.
2000-12-27 23:59:14 +00:00
Tom Lane 90f42847b5 Small cleanup of temp-table handling. Disallow creation of a non-temp
table that inherits from a temp table.  Make sure the right things happen
if one creates a temp table, creates another temp that inherits from it,
then renames the first one.  (Previously, system would end up trying to
delete the temp tables in the wrong order.)
2000-12-22 23:12:07 +00:00
Tom Lane 6cc842abd3 Revise lock manager to support "session level" locks as well as "transaction
level" locks.  A session lock is not released at transaction commit (but it
is released on transaction abort, to ensure recovery after an elog(ERROR)).
In VACUUM, use a session lock to protect the master table while vacuuming a
TOAST table, so that the TOAST table can be done in an independent
transaction.

I also took this opportunity to do some cleanup and renaming in the lock
code.  The previously noted bug in ProcLockWakeup, that it couldn't wake up
any waiters beyond the first non-wakeable waiter, is now fixed.  Also found
a previously unknown bug of the same kind (failure to scan all members of
a lock queue in some cases) in DeadLockCheck.  This might have led to failure
to detect a deadlock condition, resulting in indefinite waits, but it's
difficult to characterize the conditions required to trigger a failure.
2000-12-22 00:51:54 +00:00
Tom Lane 0e952cdb90 Fix longstanding bug with VIEW using BETWEEN: OffsetVarNodes would get
applied to the duplicated subtree twice.  Probably someday we should
fix the parser not to generate multiple links to the same subtree,
but for now a quick copyObject() is the path of least resistance.
2000-12-21 17:36:15 +00:00
Tom Lane 5491233f52 Ensure that 'errno' is saved and restored by all signal handlers that
might change it.  Experimentation shows that the signal handler call
mechanism does not save/restore errno for you, at least not on Linux
or HPUX, so this is definitely a real risk.
2000-12-18 17:33:42 +00:00
Tom Lane a626b78c89 Clean up backend-exit-time cleanup behavior. Use on_shmem_exit callbacks
to ensure that we have released buffer refcounts and so forth, rather than
putting ad-hoc operations before (some of the calls to) proc_exit.  Add
commentary to discourage future hackers from repeating that mistake.
2000-12-18 00:44:50 +00:00
Tom Lane 352cd1f1c5 Remove a few remaining vestiges of elog(WARN). 2000-12-15 04:08:15 +00:00
Tom Lane 468a970409 Change StoreCatalogInheritance() to work from a list of parent relation
OIDs rather than names.  Aside from being simpler and faster, this way
doesn't blow up in the face of 'create temp table foo () inherits (foo)'.
Which is a rather odd thing to do, but it seems some people want to.
2000-12-14 00:41:09 +00:00
Tom Lane 90bdb64be8 Add missing copyright and RCS identification header. 2000-12-08 20:10:19 +00:00
Tom Lane b44e46cfce Remove error check that disallowed setval() on a sequence with cache
value greater than one.  The behavior this sought to disallow doesn't
seem any less confusing than the other behaviors of cached sequences.
Improve wording of some error messages, too.
Update documentation accordingly.  Also add an explanation that
aborted transactions do not roll back their nextval() calls; this
seems to be a FAQ, so it ought to be mentioned here...
2000-12-08 20:06:58 +00:00
Hiroshi Inoue ce1748406b Cache invalidation for vacuum of system tables. 2000-12-08 06:43:44 +00:00
Hiroshi Inoue d7892e0263 REINDEX under WAL. 2000-12-08 06:17:58 +00:00
Tom Lane 981a7d32d1 From Stephan Szabo:
I believe this should fix the issue that Philip Warner
noticed about the check for unique constraints meeting the
referenced keys of a foreign key constraint allowing the
specification of a subset of a foreign key instead of
rejecting it.  I also added tests for a base case of
this to the foreign key and alter table tests and patches
for expected output.
2000-12-05 19:57:56 +00:00
Tom Lane a27b691e29 Ensure that all uses of <ctype.h> functions are applied to unsigned-char
values, whether the local char type is signed or not.  This is necessary
for portability.  Per discussion on pghackers around 9/16/00.
2000-12-03 20:45:40 +00:00