Commit Graph

4119 Commits

Author SHA1 Message Date
Tom Lane e74ce0a566 As long as we're fixing this space calculation, let's actually do it
right.  We should MAXALIGN the individual items because we'll
allocate them individually, not as an array.
2001-02-23 20:12:37 +00:00
Bruce Momjian 81b48493aa Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Is there one LOCKMETHODCTL for every backend?  I thought there was only
> one of them.
>>
>> You're right, that line is erroneous; it should read
>>
>> size += MAX_LOCK_METHODS * MAXALIGN(sizeof(LOCKMETHODCTL));
>>
>> Not a significant error but it should be changed for clarity ...
2001-02-23 18:28:46 +00:00
Hiroshi Inoue 94b61fbc58 Resolve a compile error. 2001-02-23 09:31:52 +00:00
Hiroshi Inoue 34822e517a Reindex of shared system indexes must be overwrite mode. 2001-02-23 09:26:14 +00:00
Tatsuo Ishii 5735c4cf3d Enhanced UTF-8/SJIS mapping generator, contributed by
Eiji Tokuya" <e-tokuya@Mail.Sankyo-Unyu.co.jp>
2001-02-23 08:44:33 +00:00
Bruce Momjian a95ac415f7 More comment cleanups. 2001-02-22 23:20:06 +00:00
Bruce Momjian 82fc51e0b3 More comment improvements. 2001-02-22 23:02:33 +00:00
Bruce Momjian 4f6c49fef0 Clean up index/btree comments/macros, as approved. 2001-02-22 21:48:49 +00:00
Bruce Momjian 660ca3e01c Change /*---- commants to /* where appropriate. pgindent will tighten
up the comments later.
2001-02-22 18:39:20 +00:00
Hiroshi Inoue 50e3c60b95 Avoid 'FATAL: out of free buffers: time to abort !" error
during WAL recovery.  Recovery failure is always serious.
2001-02-22 08:59:40 +00:00
Tom Lane 4dba6814a3 Correct bogus output formatting of timeofday() function. A number of
microseconds < 100000 should be displayed as, eg, 13.000126, not 13.126.
2001-02-21 22:03:00 +00:00
Tom Lane be92ad49e0 Change case-folding of keywords to conform to SQL99 and fix misbehavior
in Turkish locale.  Keywords are now checked under pure ASCII case-folding
rules ('A'-'Z'->'a'-'z' and nothing else).  However, once a word is
determined not to be a keyword, it will be case-folded under the current
locale, same as before.  See pghackers discussion 20-Feb-01.
2001-02-21 18:53:47 +00:00
Tatsuo Ishii fa877ed8ee Safe guard in case of imporper data is provided to elog()
in multi-byte build.
2001-02-21 06:05:23 +00:00
Peter Eisentraut cb6edf9d56 Make sure -L and -I's for our source tree are always before system include
or library directories on the command line.
2001-02-20 19:20:30 +00:00
Tom Lane d18c1d1f51 Truncate incoming username and database name to NAMEDATALEN-1 characters
so that we don't reject overlength names unnecessarily.
2001-02-20 01:34:40 +00:00
Tom Lane 414f94f262 Change plpgsql's GET DIAGNOSTICS statement to use SQL99-compatible
syntax.  Fix the RESULT_OID case, which never worked.  Add documentation.
2001-02-19 19:49:53 +00:00
Peter Eisentraut 215b90d3d7 Allow extract() to accept the same field selectors as date_part(), not just
the ones specified by SQL.
2001-02-18 18:06:10 +00:00
Tom Lane 57e0847180 Change default commit_delay to zero, update documentation. 2001-02-18 04:50:43 +00:00
Tom Lane 33cc5d8a4d Change s_lock to not use any zero-delay select() calls; these are just a
waste of cycles on single-CPU machines, and of dubious utility on multi-CPU
machines too.
Tweak s_lock_stuck so that caller can specify timeout interval, and
increase interval before declaring stuck spinlock for buffer locks and XLOG
locks.
On systems that have fdatasync(), use that rather than fsync() to sync WAL
log writes.  Ensure that WAL file is entirely allocated during XLogFileInit.
2001-02-18 04:39:42 +00:00
Tom Lane 58c4ab9d62 Remove bogus set_ps_display call --- changing displayed status here is
either wrong or unnecessary in most cases, and on systems where setting
status takes a kernel call, the overhead of setting status three times
per command rather than two is annoying.
2001-02-18 04:28:31 +00:00
Tom Lane b634118af9 Add current seek position to FDDEBUG output for FileRead,
FileWrite, FileSeek.
2001-02-17 01:00:04 +00:00
Tom Lane 1ad93b7e45 Defend against starting a non-MULTIBYTE-enabled backend in a database
with encoding other than SQL_ASCII.  Per recent discussion in pghackers.
2001-02-16 18:50:40 +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 b29f68f611 Take OUTER JOIN semantics into account when estimating the size of join
relations.  It's not very bright, but at least it now knows that
A LEFT JOIN B must produce at least as many rows as are in A ...
2001-02-16 00:03:08 +00:00
Tom Lane 6da3b76a94 Add some notes about memory management of RI plans. 2001-02-15 21:57:43 +00:00
Tom Lane db3ac67d8f Update comments about memory management. 2001-02-15 21:47:08 +00:00
Tom Lane 5c2abb960d Update notes about memory context scheme. 2001-02-15 21:38:26 +00:00
Tom Lane 059e361481 Although we can't support out-of-line TOAST storage in indexes (yet),
compressed storage works perfectly well.  Might as well have a coherent
strategy for applying it, rather than the haphazard store-what-you-get
approach that was in the code before.  The strategy I've set up here is
to attempt compression of any compressible index value exceeding
BLCKSZ/16, or about 500 bytes by default.
2001-02-15 20:57:01 +00:00
Tom Lane 39b9c9f221 Reduce default selectivity estimates for geometric operators; it seems
the old ones were not small enough to ensure r-tree and gist indexes would
get picked when available.  These numbers are totally bogus anyway, but
in the absence of any real estimation technique, we'd like to select
indexes when available ...
2001-02-15 17:55:17 +00:00
Tom Lane 83b4ab53ad Update a couple of obsolete comments. 2001-02-15 17:46:40 +00:00
Tatsuo Ishii 5c90733558 Unicode <-> SJIS new mapping tables (based on CP932.TXT) contributed by
Eiji Tokuya" <e-tokuya@Mail.Sankyo-Unyu.co.jp>
2001-02-15 01:56:29 +00:00
Tom Lane de434c2d5f Arrange for ORDER BY an expression on a UNION/INTERSECT/EXCEPT result,
such as
    SELECT f1 FROM foo UNION SELECT ... ORDER BY upper(f1)
to draw
'ORDER BY on a UNION/INTERSECT/EXCEPT result must be on one of the result columns'
rather than the uninformative 'f1 not found' we were producing before.
Eventually this should actually work, but that looks much too hard to try
to implement in late beta...
2001-02-15 01:10:28 +00:00
Tom Lane c7d2ce7bc6 Repair problems with duplicate index names generated when CREATE TABLE
specifies redundant UNIQUE conditions.
2001-02-14 23:32:38 +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
Vadim B. Mikheev 7e04843ba7 Comments about GetFreeXLBuffer().
GetFreeXLBuffer(): use Insert->LgwrResult instead of private LgwrResult
copy if it's more fresh (attempt to avoid acquiring info_lck/lgwr_lck).
2001-02-13 20:40:25 +00:00
Bruce Momjian 7582bd91cb Please apply the following patch to fix AIX and IRIX timestamp behavior
as previously discussed.

It makes AIX and IRIX not use DST for dates before 1970.

The following expected files need to be removed from the regression tests,
they contain wrong results and are not needed any more.

src/test/regress/expected/horology-1947-PDT.out
src/test/regress/expected/tinterval-1947-PDT.out
src/test/regress/expected/abstime-1947-PDT.out

Zeugswetter Andreas
2001-02-13 14:32:52 +00:00
Vadim B. Mikheev 35273825dc Removed abort() in XLogFileOpen. 2001-02-13 08:44:09 +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 f7a839bc2b Clean up portability problems in regexp package: change all routine
definitions from K&R to ANSI C style, and fix broken assumption that
int and long are the same datatype.  This repairs problems observed
on Alpha with regexps having between 32 and 63 states.
2001-02-13 00:02:36 +00:00
Tom Lane dd580f188e Suppress compiler warning on Alpha. 2001-02-12 21:03:03 +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
Bruce Momjian d8c4cb740c Cleanup 2001-02-12 18:46:40 +00:00
Bruce Momjian 281b7d84fc Add // -> /* */ mapping to pgindent. 2001-02-12 18:30:53 +00:00
Bruce Momjian 00f4fd2689 poit -> point. 2001-02-12 12:52:02 +00:00
Tom Lane 68590993ea Improve error message when startup or shutdown proc fails. 2001-02-11 23:12:28 +00:00
Tatsuo Ishii 8f17e53f0e Move pg_encoding_mblen() from common.c to wchar.c. 2001-02-11 01:59:22 +00:00
Tatsuo Ishii f54c02d2eb conv.c did not compile anymore. Fix wrong header file inclusion. 2001-02-11 01:56:58 +00:00
Peter Eisentraut 2660803697 Only look for bison as YACC; other yaccs need to be selected explicitly.
When no suitable YACC is configured, supply useful informational messages
to users.  (Same way flex has been handled for a while.)
2001-02-10 22:31:42 +00:00
Tom Lane d08741eab5 Restructure the key include files per recent pghackers discussion: there
are now separate files "postgres.h" and "postgres_fe.h", which are meant
to be the primary include files for backend .c files and frontend .c files
respectively.  By default, only include files meant for frontend use are
installed into the installation include directory.  There is a new make
target 'make install-all-headers' that adds the whole content of the
src/include tree to the installed fileset, for use by people who want to
develop server-side code without keeping the complete source tree on hand.
Cleaned up a whole lot of crufty and inconsistent header inclusions.
2001-02-10 02:31:31 +00:00
Tom Lane b1e4cfa5f6 This hasn't been used for anything for a long time... 2001-02-09 19:26:45 +00:00
Tom Lane 7fdca53711 When updating a tuple containing compressed-in-line fields, do not
decompress the existing fields unnecessarily.
2001-02-09 17:30:03 +00:00
Tom Lane dfbd5d6532 plpgsql's private copy of xlateSqlType was out of sync. Again. This
is clearly not maintainable, so dike it out in favor of calling the real
version in the backend's gram.y.
2001-02-09 03:26:28 +00:00
Tom Lane 897a895d32 When launching a child backend, take care to close file descriptors for
any other client connections that may exist (which would only happen if
another client is currently in the authentication cycle).  This avoids
wastage of open descriptors in a child.  It might also explain peculiar
behaviors like not closing connections when expected, since the kernel
will probably not signal EOF as long as some other backend is randomly
holding open a reference to the connection, even if the client went away
long since ...
2001-02-08 00:35:10 +00:00
Vadim B. Mikheev 608ddb7503 FixBTree flag still exists and may be used to turn
runtime recovery OFF.
2001-02-07 23:36:22 +00:00
Vadim B. Mikheev c19dadbf08 Runtime btree recovery is now ON by default. 2001-02-07 23:35:33 +00:00
Tom Lane 6b52dc7491 Repair postmaster memory leakage during password authentication. 2001-02-07 23:31:38 +00:00
Tom Lane 080af3db80 Need to specify DYNAMIC_PATH flag to shl_load, else HPUX's dld will not
honor library search path that we so carefully installed into the
executable ...
2001-02-07 17:59:58 +00:00
Peter Eisentraut c86c379787 If the first argument is --version or --help, skip the root check. 2001-02-06 17:00:01 +00:00
Vadim B. Mikheev 21d08bc1f6 PageAddItem in overwrite mode: must *NOT* check itemid' flag if
OffsetNumber == MaxOffsetNumber + 1 - there may be garbage there!
2001-02-06 06:24:00 +00:00
Tom Lane 85c17dbff8 Out-of-bounds memory allocation request sizes should be treated as just
elog(ERROR) not an Assert trap, since we've downgraded out-of-memory to
elog(ERROR) not a fatal error.  Also, change the hard boundary from 256Mb
to 1Gb, just so that anyone who's actually got that much memory to spare
can play with TOAST objects approaching a gigabyte.
2001-02-06 01:53:53 +00:00
Peter Eisentraut 0d3c767bb5 Dump/display 'timestamp' as 'timestamp with time zone', to make room for a
future 'timestamp without time zone', which SQL claims is equivalent to
plain 'timestamp'.
2001-02-05 17:35:04 +00:00
Tom Lane 503f042cd7 Fix inappropriate attempt to push down qual clauses into a view that
has UNION/INTERSECT/EXCEPT operations.  Per bug report from Ferrier.
2001-02-03 21:17:52 +00:00
Peter Eisentraut 67849c84d6 Use elog() instead of exit() for fatal scanner errors. 2001-02-03 20:13:05 +00:00
Vadim B. Mikheev b18c09ee3a Runtime tree recovery is implemented, just testing is left -:) 2001-02-02 19:49:15 +00:00
Bruce Momjian b60c57da2d Apply patches for QNX from Maurizio 2001-02-02 18:21:59 +00:00
Vadim B. Mikheev dca0762efc Couple additional functions to fix tree at runtime.
Need in one more function to handle "my bits moved..."
case. FixBTree is still FALSE.
2001-01-31 01:08:36 +00:00
Vadim B. Mikheev 598a12722a Call _bt_fixroot() from _bt_insertonpg. 2001-01-29 07:28:17 +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
Peter Eisentraut dc7a0009f0 Add permission check for CHECKPOINT. 2001-01-27 10:19:52 +00:00
Tom Lane 80caa741ab Fix failure to create sequences for more than one SERIAL column in a
table.
2001-01-27 07:23:48 +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 f44639e1bf Don't crash if subquery appears multiple times in jointree. This should
not happen anyway, but let's try not to get completely confused if it does
(due to rewriter bugs or whatever).
2001-01-27 04:42:32 +00:00
Tom Lane 352871ac93 Repair bug reported by Huxton, 1/24/01. We need to include a rule's
original table ('OLD' table) in its join tree if OLD is referenced by
either the rule action, the rule qual, or the original query qual that
will be added to the rule action.  However, we only want one instance
of the original table to be included; so beware of the possibility that
the rule action already has a jointree entry for OLD.
2001-01-27 04:40:59 +00:00
Tom Lane c9c8d53d80 Refuse to try to attach a condition to a NOTIFY or other utility statement,
rather than coredumping (as prior 7.1 code did) or silently dropping the
condition (as 7.0 did).  This is annoying but there doesn't seem to be
any good way to fix it, short of a major querytree restructuring.
2001-01-27 01:44:20 +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
Tom Lane 1dc3051088 Re-read Unix-socket lock file every so often (every CheckPoint interval,
actually) to ensure that its file access time doesn't get old enough to
tempt a /tmp directory cleaner to remove it.  Still another reason we
should never have put the sockets in /tmp in the first place ...
2001-01-27 00:05:31 +00:00
Tom Lane b78d1bed07 Change float8-to-int8 conversion to round to nearest, rather than
truncating to integer.  Remove regress test that checks whether
4567890123456789 can be converted to float without loss; since that's
52 bits, it's on the hairy edge of failing with IEEE float8s, and indeed
rint seems to give platform-dependent results for it.
2001-01-26 22:50:26 +00:00
Tom Lane f433d0d3cd Special case in ProcSleep() wasn't sufficiently general: must check to
see if we shouldn't block whenever we insert ourselves anywhere before
the end of the queue, not only at the front.
2001-01-26 18:23:12 +00:00
Vadim B. Mikheev c6e6d292bc First step in attempt to fix tree at runtime: create upper levels
and new root page if old root one was splitted but new root page
wasn't created.
New code is protected by FixBTree bool flag setted to FALSE, so
nothing should be affected by this untested approach.
2001-01-26 01:24:31 +00:00
Tom Lane 211f5afd40 Whoops, forgot to do ProcLockWakeup() after deadlock checker
rearranges wait queues.
2001-01-25 03:45:50 +00:00
Tom Lane a05eae029a Re-implement deadlock detection and resolution, per design notes posted
to pghackers on 18-Jan-01.
2001-01-25 03:31:16 +00:00
Bruce Momjian 623bf843d2 Change Copyright from PostgreSQL, Inc to PostgreSQL Global Development Group. 2001-01-24 19:43:33 +00:00
Peter Eisentraut 718fc7e0d1 Fix bogus pattern for STRING. 2001-01-24 19:01:31 +00:00
Bruce Momjian 7df3bb50f0 Add all possible config file options. 2001-01-24 18:37:31 +00:00
Bruce Momjian 3347fbad79 Put back old config contents until I am finished. 2001-01-24 15:57:49 +00:00
Bruce Momjian 0843ec088c Add "idle in transaction" status message 2001-01-24 15:53:59 +00:00
Bruce Momjian ab37224426 Fix formatting of db crash. 2001-01-24 14:32:32 +00:00
Bruce Momjian 3f0f30d1a1 Add comment for getpwid() safety. 2001-01-24 05:24:43 +00:00
Bruce Momjian 843657b066 attached is take-2 of a patch which fixes a bug related
to the use of getpwuid when running in standalone mode.
this patch allocates some persistent storage (using
strdup) to store the username obtained with getpwuid
in src/backend/main/main.c.  this is necessary because
later on, getpwuid is called again (in ValidateBinary).

the man pages for getpwuid on SCO OpenServer, FreeBSD,
and Darwin all have words to this effect (this is from
the SCO OpenServer man page):

  Note
  ====
  All information is contained in a static area, so it must
  be copied if it is to be saved. Otherwise, it may be
  overwritten on subsequent calls to these routines.

in particular, on my platform, the storage used to hold
the pw_name from the first call is overwritten such that
it looks like an empty username.  this causes a problem
later on in SetSessionUserIdFromUserName.

i'd assume this isn't a problem on most platforms because
getpwuid is called with the same UID both times, and the
same thing ends up happening to that static storage each
time.  however, that's not guaranteed, and is _not_ what
happens on my platform (at least :).

this is for the version of 7.1 available via anon cvs as
of Tue Jan 23 15:14:00 2001 PST:
  .../src/backend/main/main.c,v 1.37 2000/12/31 18:04:35 tgl Exp

-michael thornburgh, zenomt@armory.com
2001-01-24 03:50:06 +00:00
Hiroshi Inoue a8b275e76d Removed a dangerours DropRelationBuffers() call. 2001-01-24 00:36:17 +00:00
Tom Lane 997ee51631 Make functional index copy attstorage from the column data type, rather
than forcing 'plain'.  This probably does not matter right now, but I
think it needs to be consistent with the regular (not-functional) index
case, where attstorage is copied from the underlying table.  Clean up
some other dead and infelicitous code too.
2001-01-24 00:06:07 +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 4e27b308e2 Do _bt_wrtbuf() outside critical section, per discussion with Vadim 1/19. 2001-01-23 23:29:22 +00:00
Tom Lane f69ff0c4bd Give 'a_expr ::= a_expr Op' production a slightly lower precedence than
Op, so that the sequence 'a_expr Op Op a_expr' will be parsed as
a_expr Op (Op a_expr) not (a_expr Op) Op a_expr as formerly.  In other
words, prefer treating user-defined operators as prefix operators to
treating them as postfix operators, when there is an ambiguity.
Also clean up a couple of other infelicities in production priority
assignment --- for example, BETWEEN wasn't being given the intended
priority, but that of AND.
2001-01-23 22:39:08 +00:00
Peter Eisentraut 3de8407ea7 Remove useless leftover global variable Ps_status_buffer. 2001-01-23 20:33:29 +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
Tom Lane b686fb5bf1 Remove no-longer-needed restriction against referencing system
attributes in a FieldSelect node --- all the places that manipulate
these work just fine with system attribute numbers.  OK, it's a new
feature, so shoot me ...
2001-01-23 02:32:26 +00:00
Bruce Momjian 7e533da492 Rename int4 to int32 in a few places. 2001-01-23 01:48:17 +00:00
Tom Lane 728b0aa290 Improve realloc() per idea from Karel Zak --- if chunk to be enlarged is
at end of its block, maybe we can enlarge it in-place.
2001-01-23 01:01:36 +00:00
Tom Lane e9c936ff38 Remove rangechecks on errno; just call strerror unconditionally. This
eliminates a raft of portability issues, including whether sys_nerr
exists, whether the platform has any valid negative errnos, etc.  The
downside is minimal: errno shouldn't ever contain an invalid value anyway,
and if it does, reasonably modern versions of strerror will not choke.
This rangecheck idea seemed good at the time, but it's clearly a net loss,
and I apologize to all concerned for having ever put it in.
2001-01-22 23:28:52 +00:00
Tom Lane e84c429062 Clean up lockmanager data structures some more, in preparation for planned
rewrite of deadlock checking.  Lock holder objects are now reachable from
the associated LOCK as well as from the owning PROC.  This makes it
practical to find all the processes holding a lock, as well as all those
waiting on the lock.  Also, clean up some of the grottier aspects of the
SHMQueue API, and cause the waitProcs list to be stored in the intuitive
direction instead of the nonintuitive one.  (Bet you didn't know that
the code followed the 'prev' link to get to the next waiting process,
instead of the 'next' link.  It doesn't do that anymore.)
2001-01-22 22:30:06 +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
Bruce Momjian b8f23aff82 Back out patch for BLOB operations until approval. 2001-01-21 03:50:25 +00:00
Bruce Momjian c655935217 Hello,
here is the patch attached which do check in each BLOB operation, if we are
in transaction, and raise an error otherwise. This will prevent such mistakes.

--
Sincerely Yours,
Denis Perchine
2001-01-21 03:49:14 +00:00
Tom Lane 023a48b811 Deal with C++ incompatibility of sys_nerr declaration by taking it out
of c.h altogether, and putting it into the only places that use it
(elog.c and exc.c), instead.  Modify these routines to check for a
NULL or empty-string return from strerror, too, since some platforms
define strerror to return empty string for unknown errors (what a useless
definition that is ...).  Clean up some cruft in ExcPrint while at it.
2001-01-21 00:59:26 +00:00
Tom Lane 1a02edae60 Give a good error message for what's likely to be a common syntax error,
namely omitting the alias clause for a sub-SELECT in FROM.
2001-01-20 17:37:52 +00:00
Peter Eisentraut 19cba0cc1b Add missing piece of BitString support to node output functions. Expand
and remove IsA_Value macro.
2001-01-20 00:15:59 +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
Bruce Momjian 75815c3100 cleanup. 2001-01-19 21:09:57 +00:00
Bruce Momjian 27aaf9df7e Remove ; and add \n to ASM code. 2001-01-19 20:39:16 +00:00
Tom Lane 86a2c2595b Suppress compiler warning in MULTIBYTE code. 2001-01-19 06:57:25 +00:00
Tom Lane bdb72d8765 Suppress compiler warning in MULTIBYTE case. 2001-01-19 06:54:57 +00:00
Tom Lane c78e19544e Suppress unused-variable warning in non-Assert compilations. 2001-01-19 06:50:23 +00:00
Vadim B. Mikheev 0a12767004 Comment out xlrec in xact_redo - no support for file unlinking on
commit yet.
2001-01-18 18:33:45 +00:00
Hiroshi Inoue 89ac643964 Fix some leaks(was my fault). 2001-01-18 07:29:04 +00:00
Thomas G. Lockhart 6acdebbd3a Fix up "Postgres-style" time interval representation when fields have
mixed-signs. Previous effort left way too many minus signs, and was at
 least as broken as the one before that :(
Clean up "ISO-style" time interval representation to omit zero fields if
 there is at least one non-zero field. Supress some leading plus signs
 when not necessary for clarity.
Replace every #ifdef __CYGWIN__ block with a cleaner TIMEZONE_GLOBAL macro
 defined in datetime.h.
2001-01-18 07:22:43 +00:00
Tom Lane b06fbc7ad2 Fix performance issue with qualifications on VIEWs: outer query should
try to push restrictions on the view down into the view subquery,
so that they can become indexscan quals or what-have-you rather than
being applied at the top level of the subquery.  7.0 and before were
able to do this, though in a much klugier way, and I'd hate to have
anyone complaining that 7.1 is stupider than 7.0 ...
2001-01-18 07:12:37 +00:00
Hiroshi Inoue 53ebb2286d Change LockClassinfoForUpdate() to retry mark4update() in case
the tuple is already uodated. (If LockClassinfoForUpdate() is
thought to be useful).
2001-01-18 04:01:42 +00:00
Bruce Momjian 978c03f9cf attached is a patch that makes SysV semaphore emulation
using POSIX semaphores more robust on Darwin 1.2/Mac OS X
Public Beta.  this is for the version of 7.1 available
via anon cvs as of Jan 14 2001 14:00 PST.

since the semaphores and shared memory created by this
emulator are shared with the backends via fork(), their
persistent names are not necessary.  removing their
names with shm_unlink() and sem_unlink() after creation
obviates the need for any "ipcclean" function.  further,
without these changes, the shared memory (and, therefore,
the semaphores) will not be re-initialized/re-created after
the first execution of the postmaster, until reboot
or until some (non-existent) ipcclean function is executed.

this patch does the following:

   1) if the shared memory segment "SysV_Sem_Info" already
      existed, it is cleaned up.  it shouldn't be there anyways.

   2) the real indicator for whether the shared memory/semaphore
      emulator has been initialized is if "SemInfo" has been
      initialized.  the shared memory and semaphores must be
      initialized regardless of whether there was a garbage shared
      memory segment lying around.

   3) the shared memory segment "SysV_Sem_Info" is created with "O_EXCL"
      to catch the case where two postmasters might be starting
      simultaneously, so they don't both end up with the same shared
      memory (one will fail).  note that this can't be done with the
      semaphores because Darwin 1.2 has a bug where attempting to
      open an existing semaphore with "O_EXCL" set will ruin the
      semaphore until the next reboot.

   4) the shared memory segment "SysV_Sem_Info" is unlinked after
      it is created.  it will then exist without a name until the
      postmaster and all backend children exit.
   5) all semaphores are unlinked after they are created.  they'll
      then exist without names until the postmaster and all backend
      children exit.

-michael thornburgh, zenomt@armory.com
2001-01-17 22:11:19 +00:00
Bruce Momjian 5088f0748a Change lcons(x, NIL) to makeList(x) where appropriate. 2001-01-17 17:26:45 +00:00
Thomas G. Lockhart 8e9840383c Change comparisons of tm->tm_isdst from "nonzero" to "greater than zero".
Not sure why some were this way, and others were already correct, but it
 seems to have been like this for several years.
This caused problems on a few damaged platforms like AIX and IRIX which do
 not support DST calculations for years before 1970.
Thanks to Andreas Zeugswetter <ZeugswetterA@wien.spardat.at> for finding
 the problem.
2001-01-17 16:46:56 +00:00
Bruce Momjian 26e0321191 Move structure comments from the top block down to the line entries for
this file to match all the other files, and to be clearer.
2001-01-17 06:41:31 +00:00
Tom Lane 4c4f305b15 Remove bogus backslashes in sed command. 2001-01-16 22:48:34 +00:00
Tom Lane dae52bf3ec Oops, I had managed to break query-cancel-while-waiting-for-lock. 2001-01-16 20:59:34 +00:00
Tom Lane 64e6c60897 Rename fields of lock and lockholder structures to something a tad less
confusing, and clean up documentation.
2001-01-16 06:11:34 +00:00
Tom Lane 3db4056e22 Fix problems with parentheses around sub-SELECT --- for the last time,
I hope.  I finally realized that we were going at it backwards: when
there are excess parentheses, they need to be treated as part of the
sub-SELECT, not as part of the surrounding expression.  Although either
choice yields an unambiguous grammar, only this way produces a grammar
that is LALR(1).  With the old approach we were guaranteed to fail on
either 'SELECT (((SELECT 2)) + 3)' or
'SELECT (((SELECT 2)) UNION SELECT 2)' depending on which way we
resolve the initial shift/reduce conflict.  With the new way, the same
reduction track can be followed in both cases until we have advanced
far enough to know whether we are done with the sub-SELECT or not.
2001-01-15 20:36:36 +00:00
Tom Lane efd6cade83 Tweak heap_update/delete so that we do not hold the buffer context lock
on the old tuple's page while we are doing TOAST pushups.
2001-01-15 05:29:19 +00:00
Tom Lane 0b5d194aaa Minor coding cleanups. 2001-01-14 22:21:54 +00:00
Tom Lane a904181a46 Another go-round on making GetRawDatabaseInfo behave as well as it can,
given the fundamental restriction of not looking at transaction commit
data in pg_log.  Use code that is actually based on tqual.c rather than
ad-hoc tests.  Also write the tuple fetch loop using standard access
macros rather than ad-hoc code.
2001-01-14 22:21:05 +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 c0f069944f Make aclcontains() do something that's at least vaguely reasonable:
it now returns true if the aclitem argument exactly matches any one of
the elements of the aclitem[] argument.  Per complaint from Wolff 1/10/01.
2001-01-14 19:23:27 +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 160675ecee Relax test on typmod matching between a table and its proposed ON SELECT
rule.  Needed to avoid failure when reloading a 7.0 pg_dump of a view
that has a NUMERIC column.
2001-01-13 03:58:28 +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
Marc G. Fournier 0ad7db4be4 New feature:
1. Support of variable size keys - new algorithm of insertion to tree
      (GLI - gist layrered insertion). Previous algorithm was implemented
      as described in paper by Joseph M. Hellerstein et.al
      "Generalized Search Trees for Database Systems".  This (old)
      algorithm was not suitable for variable size keys and could be
      not effective ( walking up-down ) in case of multiple levels split
Bug fixed:
   1. fixed bug in gistPageAddItem - key values were written to disk
      uncompressed. This caused failure if decompression function
      does real job.
   2. NULLs handling - we keep NULLs in tree. Right way is to remove them,
      but we don't know how to inform vacuum about index statistics. This is
      just cosmetic warning message (like in case with R-Tree),
      but I'm not sure how to recognize real problem if we remove NULLs
      and suppress this warning as Tom suggested.
   3. various memory leaks

This work was done by Teodor Sigaev (teodor@stack.net) and
Oleg Bartunov (oleg@sai.msu.su).
2001-01-12 00:12:58 +00:00
Peter Eisentraut c340c21865 Remove useless DLLIMPORT (only needed in header files). 2001-01-11 23:27:05 +00:00
Hiroshi Inoue 09a160d579 Removed a no longer needed SetWaitingForLock() call in
DeadLockCheck().
2001-01-10 01:24:19 +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
Peter Eisentraut c3f9371956 Add configure check for sys_nerr, to end all discussions. 2001-01-09 18:40:15 +00:00
Hiroshi Inoue 7edff1618e Disable query cancel during HandleDeadLock(). 2001-01-09 09:38:57 +00:00
Vadim B. Mikheev 4b59366e57 1. Checkpoint.undo may be after checkpoint itself:
- no more elog(STOP) in StartupXLOG();
   - both checkpoint' undo & redo are used to define
     oldest on-line log file.
2. Ability to pre-allocate a few log files at checkpoint time
   (wal_files option). Off by default.
2001-01-09 06:24:33 +00:00
Tom Lane 07c741e61c Fix oversight in planning of GROUP queries: when an expression is used
as both a GROUP BY item and an output expression, the top-level Group
node should just copy up the evaluated expression value from its input,
rather than re-evaluating the expression.  Aside from any performance
benefit this might offer, this avoids a crash when there is a sub-SELECT
in said expression.
2001-01-09 03:48:51 +00:00
Bruce Momjian 745f0c21e5 Remove compiler warning about uninitialized warnings. 2001-01-08 20:54:24 +00:00
Tom Lane b95f81a54a Add some debugging support code (ifdef'd out in normal use). 2001-01-08 18:34:44 +00:00
Tom Lane e2586c3c62 LockBuffer should not elog while holding buffer's cntx_lock. 2001-01-08 18:31:49 +00:00
Hiroshi Inoue 6adc255f8a Keep relations open until they are no longer needed. 2001-01-08 03:14:58 +00:00
Tom Lane 1112a2a084 Make outfuncs/readfuncs treat OIDs properly as unsigned values. Clean up
inconsistent coding practices for handling Index values and booleans,
too.
2001-01-08 00:31:43 +00:00
Tom Lane a4ddbbd1a4 Correct nasty error in heap_update: it was releasing the buffer refcount
before calling RelationInvalidateHeapTuple(), which is bad because the
latter needs to look at the tuple data, which is in the shared disk
buffer.  If another backend manages to recycle the buffer while this
is going on, we will compute the wrong hashindex for the tuple or
maybe even crash outright.  Must hold buffer refcount until afterwards.
(This bug is not in 7.0.*; seems to be have introduced during WAL changes.)
2001-01-07 22:14:31 +00:00
Tom Lane 542b7c6445 Clear QueryCancel and ProcDiePending at start of proc_exit, to ensure
that leftover cancel/die requests cannot interfere with exit activities.
2001-01-07 04:30:41 +00:00
Tom Lane cb7ce7d0e3 Fix recent breakage of query-cancel logic, see my pghackers message
of 6 Jan 2001 21:55.
2001-01-07 04:17:29 +00:00
Tom Lane 4057b64f32 Modify readfuncs so that recursive use of stringToNode will not crash
and burn.  Just for added luck, change reading of CONST nodes so that
we do not need to consult pg_type rows while reading them; this means
that no database access occurs during stringToNode.  This requires
changing the order in which const-node fields are written, which means
an initdb is forced.
2001-01-07 01:08:48 +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
Tom Lane deb21f0f80 Log memory context stats to stderr when reporting a 'Memory exhausted'
error, so as to provide a starting point for debugging.
2001-01-06 21:59:39 +00:00
Tom Lane e69b8d4655 Fix memory leak in relcache handling of rules: allocate rule parsetrees
in per-entry sub-memory-context, where they were supposed to go, rather
than in CacheMemoryContext where the code was putting them.  Must've
suffered a severe brain fade when I wrote this :-(
2001-01-06 21:53:18 +00:00
Peter Eisentraut 3ff76734f6 Simplify the rules that explicitly allowed TYPE as a type name (which is
no longer the case).  Add AND and TRAILING to ColLabel.  All key words
except AS are now at least ColLabel's.
2001-01-06 10:50:02 +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
Hiroshi Inoue 4451ed3dfe init_irels() is changed to be called in RelationCacheInitializePhase2()
so that transactional control could guarantee the consistency.
2001-01-06 01:48:59 +00:00
Tom Lane 81d08fcffe Rename and document some invalidation routines to make it clearer that
they don't themselves flush any cache entries, only add to to-do lists
that will be processed later.
2001-01-05 22:54:37 +00:00
Tom Lane 2fb6cc9045 Remove not-really-standard implementation of CREATE TABLE's UNDER clause,
and revert documentation to describe the existing INHERITS clause
instead, per recent discussion in pghackers.  Also fix implementation
of SQL_inheritance SET variable: it is not cool to look at this var
during the initial parsing phase, only during parse_analyze().  See
recent bug report concerning misinterpretation of date constants just
after a SET TIMEZONE command.  gram.y really has to be an invariant
transformation of the query string to a raw parsetree; anything that
can vary with time must be done during parse analysis.
2001-01-05 06:34:23 +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 f9d6ffc5c4 Repair guaranteed core dump in SPI_exec(). Guess this routine wasn't
used before ...
2001-01-04 02:36:52 +00:00
Hiroshi Inoue 3052a421d5 I neglected to remove a debug message,sorry. 2001-01-04 02:24:22 +00:00
Tom Lane 60500d58bc Fix breakage of rules using NOTIFY actions, per bug report and patch
from sergiop@sinectis.com.ar.
2001-01-03 22:01:05 +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
Thomas G. Lockhart a8aa2f95b4 Repair always-broken date_part('quarter',timestamp).
Previous result did not have correct month boundaries so anything near edge
 cases was suspect (e.g. April was in Q1 and July, August were lumped into
 Q2).
Thanks to Denis Osadchy <osadchy@turbo.nsk.su> for the report.
2001-01-03 16:48:02 +00:00
Tom Lane 1b8a219eef Clean up non-reentrant interface for hash_seq/HashTableWalk, so that
starting a new hashtable search no longer clobbers any other search
active anywhere in the system.  Fix RelationCacheInvalidate() so that
it will not crash or go into an infinite loop if invoked recursively,
as for example by a second SI Reset message arriving while we are still
processing a prior one.
2001-01-02 04:33:24 +00:00
Tom Lane ad0169b1b7 CLUSTER forgot to create a TOAST table for the clustered relation. 2001-01-01 21:35:00 +00:00
Tom Lane 9315ff5549 Ensure attcacheoff is written out as -1 when writing pg_attribute
tuples for a relation.  Needed to prevent Assert failure in CLUSTER.
2001-01-01 21:33:31 +00:00
Tom Lane 473763e676 Update comment. 2001-01-01 21:22:54 +00:00
Tom Lane ff6012e275 Reverse #if test to be defined(__osf__) rather than not-any-of-a-lot-
of-others.
2000-12-31 18:04:35 +00:00
Tom Lane fada8ee41f NetBSD/Alpha porting fixes from tom@minnesota.com. 2000-12-31 03:34:01 +00:00
Tom Lane 4723b2b99b Be more careful about the difference between signed and unsigned ints.
Bug is revealed by OID regress test on 64-bit platforms.
2000-12-30 19:17:47 +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 c193f19a39 Fixed misprint in heap update WALoging. 2000-12-30 06:52:34 +00:00
Tom Lane c23851bbe0 Paranoia about possible values of errno after a shmget/semget failure.
In theory we should always get EEXIST if there's a key collision, but
if the kernel code tests error conditions in a weird order, perhaps
EACCES or EIDRM could occur too.
2000-12-30 01:20:55 +00:00
Tom Lane 7f60b81e1a Fix failure in CreateCheckPoint on some Alpha boxes --- it's not OK to
assume that TAS() will always succeed the first time, even if the lock
is known to be free.  Also, make sure that code will eventually time out
and report a stuck spinlock, rather than looping forever.  Small cleanups
in s_lock.h, too.
2000-12-29 21:31:21 +00:00
Vadim B. Mikheev 7d363c4c33 MUST update (in-memory) data page BEFORE XLogInsert to log
NEW page content if WAL will decide to backup page.
2000-12-29 20:47:17 +00:00
Vadim B. Mikheev b3c4f03c9c nbtree_xlog_newroot: set meta flag in meta page opaque. 2000-12-29 08:08:59 +00:00
Vadim B. Mikheev 7ceeeb662f New WAL version - CRC and data blocks backup. 2000-12-28 13:00:29 +00:00
Tom Lane c996c7f573 Let's try this again on accepting the correct range of Oid input values
for 64-bit platforms ...
2000-12-28 01:51:15 +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 7df721af0e Compute reasonable cost and output-row-count estimates for LIMIT plan
nodes.
2000-12-23 18:49:41 +00:00
Tom Lane a412749812 Replace overly-cute coding with code that (a) has defined behavior
according to the ANSI C spec, (b) gets the boundary conditions right,
and (c) is about a third as long and three times more intelligible.
2000-12-23 04:05:31 +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 0db1a951d5 Repair not-too-well-thought-out code to do rangechecking of OIDs on
64-bit machines.  Also, make oidvectorin use the same code as oidin.
2000-12-22 21:36:09 +00:00
Vadim B. Mikheev 369aace5f3 Avoid XLogFlush for clean buffers in BufferSync. 2000-12-22 20:04:43 +00:00
Tom Lane 046848c272 Improve error message for case where DROP TABLE is rejected because
table has a child table.
2000-12-22 19:21:37 +00:00
Tom Lane 04b31609b6 Add 'ONLY' to queries generated by RI triggers, so as to preserve pre-7.1
semantics of RI operations.  Eventually we ought to look at making RI
work properly across inheritance trees, but not for 7.1 ...
2000-12-22 18:35:09 +00:00
Tom Lane 61784c54b5 Change default output formatting for CIDR to be unabbreviated, per
recommendation from Paul Vixie.  Add a new abbrev() function to produce
abbreviated format as text.  No forced initdb, but new function is not
available unless you do an initdb or add the pg_proc row manually.
2000-12-22 18:00:24 +00:00
Tom Lane 317215fc55 Clean up CREATE TYPE/OPERATOR/AGGREGATE productions, so that parser
will not accept types named with operator names or vice versa.
2000-12-22 07:07:58 +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 e6e9e18e9e Remove multi.c and single.c, which have been dead code for
over two years.
2000-12-20 22:54:02 +00:00
Tom Lane 39b547f430 Prevent freshly-started backend from ignoring SIGUSR1, per race condition
observed by Inoue.  Also, don't call ProcRemove() from postmaster if we
have detected a backend crash --- too risky if shared memory is corrupted.
It's not needed anyway, considering we are going to reinitialize shared
memory and semaphores as soon as the last child is dead.
2000-12-20 21:51:52 +00:00
Bruce Momjian 1f159e562b >> Here is a patch for the beos port (All regression tests are OK).
>>     xlog.c : special case for beos to avoid 'link' which does not work yet
>>     beos/sem.c : implementation of new sem_ctl call (GETPID) and a new
>sem_op
>> flag (IPCNOWAIT)
>>     dynloader/beos.c : add a verification of symbol validity (seem that
the
>> loader sometime return OK with an invalid symbol)
>>     postmaster.c :  add beos forking support for the new checkpoint
process
>>     postgres.c : remove beos special case for getrusage
>>     beos.h : Correction of a bas definition of AF_UNIX, misc defnitions
>>
>>
>>     thanks
>>
>>
>>             cyril

Cyril VELTER
2000-12-18 18:45:05 +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 97cfb9d606 Make sure make_rels_by_clause_joins doesn't return multiple references
to same joinrel.  Although make_rels_by_joins doesn't mind, GEQO has
an Assert that doesn't like this.
2000-12-18 06:50:51 +00:00
Tom Lane 42d5e34e77 Repair mishandling of PRIMARY KEY declaration that references an
inherited column, per bug report from Elphick 12/15/00.
2000-12-18 01:37:56 +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 cfa4d4d040 Tweak select_common_type() to deal with possibility of multiple preferred
types in a category --- it was taking the last preferred type among the
inputs, rather than the first one as intended.
2000-12-17 04:32:29 +00:00
Bruce Momjian 85934d1bdb Remove current->old mapping. 2000-12-15 23:36:20 +00:00
Tom Lane 7d6af50f43 Make algorithm for resolving UNKNOWN function/operator inputs be
insensitive to the order of arguments.  Per pghackers discussion 12/10/00.
2000-12-15 19:22:03 +00:00
Bruce Momjian ff783fbae0 here is a patch fixing today's bug report:
> Date: Thu, 14 Dec 2000 12:44:47 +0100 (CET)
> From: Kovacs Zoltan Sandor <tip@pc10.radnoti-szeged.sulinet.hu>
> To: pgsql-bugs@postgresql.org
> Subject: [BUGS] to_char() causes backend to close connection
>
> Hi, this query gives different strange results:
>
> select to_char(now()::abstime,'YYMMDDHH24MI');
>
> I get e.g. a "backend closed the channel unexpectedly..." error with
> successful or failed resetting attempt (indeterministic)

 Again thanks Kovacs, you found really designing bug, that appear
if anyone write bad format template to "number" version of to_char()
(as you with 'DD').

                                        Karel
2000-12-15 19:15:09 +00:00
Tom Lane b260c18cbc Remove obsolete comment. 2000-12-15 18:02:47 +00:00
Tom Lane 352cd1f1c5 Remove a few remaining vestiges of elog(WARN). 2000-12-15 04:08:15 +00:00
Jan Wieck 4ea746a84f Bugfix
Trying to connect to template0 left a global referenced buffer
because the scan of pg_database wasn't ended properly before
elog(FATAL).

Jan
2000-12-14 23:51:35 +00:00
Tom Lane ea166f1146 Planner speedup hacking. Avoid saving useless pathkeys, so that path
comparison does not consider paths different when they differ only in
uninteresting aspects of sort order.  (We had a special case of this
consideration for indexscans already, but generalize it to apply to
ordered join paths too.)  Be stricter about what is a canonical pathkey
to allow faster pathkey comparison.  Cache canonical pathkeys and
dispersion stats for left and right sides of a RestrictInfo's clause,
to avoid repeated computation.  Total speedup will depend on number of
tables in a query, but I see about 4x speedup of planning phase for
a sample seven-table query.
2000-12-14 22:30:45 +00:00
Hiroshi Inoue db11f4382a Make sure to not handle deactivated system indexes 2000-12-14 07:02:42 +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 780992316f Fix thinko for case of outer join where inner table is empty: should
output first outer tuple before advancing...
2000-12-13 23:45:46 +00:00
Tom Lane 17b843d677 Cache eval cost of qualification expressions in RestrictInfo nodes to
avoid repeated evaluations in cost_qual_eval().  This turns out to save
a useful fraction of planning time.  No change to external representation
of RestrictInfo --- although that node type doesn't appear in stored
rules anyway.
2000-12-12 23:33:34 +00:00
Vadim B. Mikheev 5bb4f723d2 Remove elog for online log files. 2000-12-11 19:27:42 +00:00
Vadim B. Mikheev dae369d390 elog(LOG)-->elog(DEBUG) for skipped logs. 2000-12-11 18:02:25 +00:00
Tom Lane 2cf8064af8 Tweak Darwin patch to get right include order. 2000-12-11 16:35:59 +00:00
Hiroshi Inoue 6ef0219c34 Resolve complie error(was my fault). 2000-12-11 09:14:03 +00:00
Hiroshi Inoue a8824ff257 *redo: Heap move* neglects to set t_cmin for MOVED_IN tuples. 2000-12-11 05:25:23 +00:00
Tatsuo Ishii d81fd94d40 Fix ILIKE bug (only in multi-byte case) 2000-12-11 05:00:18 +00:00
Tom Lane 41fe2a2a03 Darwin porting patches from Peter Bierman <bierman@apple.com> 2000-12-11 00:49:54 +00:00
Tom Lane 8fdd794d97 Portability fix from Ryan Kirkpatrick's Alpha patches. I believe this
is the only diff not accounted for by fmgr rewrite...
2000-12-09 20:40:57 +00:00
Tom Lane 228c1e74a7 Suppress compiler warnings. 2000-12-09 20:32:44 +00:00
Tatsuo Ishii cfe26c0fb1 Fix a bug in conversion from big5 to EUC_TW (CNS 11643-1992 Plane 3)
Thanks Chih-Chang Hsieh <cch@cc.kmu.edu.tw> for finding the bug.
2000-12-09 04:27:36 +00:00
Tom Lane 376784cf8a Repair erroneous use of hashvarlena() for MACADDR, which is not a
varlena type.  (I did not force initdb, but you won't see the fix
unless you do one.)  Also, make sure all index support operators and
functions are careful not to leak memory for toasted inputs; I had
missed some hash and rtree support ops on this point before.
2000-12-08 23:57:03 +00:00
Tom Lane fb47385fc8 Resurrect -F switch: it controls fsyncs again, though the fsyncs are
mostly just on the WAL logfile nowadays.  But if people want to disable
fsync for performance, why should we say no?
2000-12-08 22:21:33 +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 2a7a75ee7e Change lpad() and rpad() to behave more Oracle-compatibly when target
length is less than original string length.
2000-12-07 23:22:56 +00:00
Tom Lane cbc5f4f127 checkretval() failed to cope with an empty SQL function body. 2000-12-07 19:40:56 +00:00
Tom Lane 821f4673ff Make OVERLAPS operators conform to SQL92 spec regarding NULL handling.
As I read it, the spec requires a non-null result in some cases where
one of the inputs is NULL: specifically, if the other endpoint of that
interval is between the endpoints of the other interval, then the result
is known TRUE despite the missing endpoint.  The spec could've been a
lot simpler if they did not intend this behavior.
I did not force an initdb for this change, but if you don't do one you'll
still see the old strict-function behavior.
2000-12-07 18:38:59 +00:00
Hiroshi Inoue 8bb4dab94d RecordTransactionAbort() shouldn't log XLOG_XACT_ABORT
if the transaction has already been committed ?
2000-12-07 10:03:46 +00:00
Tom Lane 5cf81b3c06 Silence compiler warning. 2000-12-07 02:52:27 +00:00
Tom Lane 06dde51ef0 Silence compiler warning. 2000-12-07 02:04:30 +00:00
Tom Lane 7711e40b9f Make application of FOR UPDATE to a view work exactly like the parser's
transformForUpdate does: it should recurse into subqueries.
2000-12-07 01:22:25 +00:00
Tom Lane 0a844e84a1 transformForUpdate() mustn't assume rowMarks list is initially empty.
It could be recursing into a sub-query where there was already a FOR
UPDATE clause.
2000-12-07 01:12:08 +00:00
Tom Lane 73d2a3595a Clean up handling of FOR UPDATE inside views and subselects ... make it
work where we can (given that the executor only handles it at top level)
and generate an error where we can't.  Note that while the parser has
been allowing views to say SELECT FOR UPDATE for a few weeks now, that
hasn't actually worked until just now.
2000-12-06 23:55:19 +00:00
Tom Lane 5fb1022212 Don't include miscadmin.h in elog.h, since the former is not part of
the installed header file set.
2000-12-06 17:25:46 +00:00
Tom Lane a0f863637f I've just seen what happens when the MEMORY_CONTEXT_CHECKING code fires
an error at end of transaction ... and I did *not* like it.  Reduce ERROR
to NOTICE so that this situation doesn't cause an infinite loop.
2000-12-05 23:40:36 +00:00
Tom Lane 614d951a54 In SELECT FOR UPDATE, silently ignore null CTIDs, rather than generating
an error as we used to.  In an OUTER JOIN scenario, retrieving a null
CTID from one of the input relations is entirely expected.  We still
want to lock the input rows from the other relations, so just ignore
the null and keep going.
2000-12-05 22:03:57 +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 a51f004d29 Repair breakage of rules containing INSERT ... SELECT actions, per bug
report from Joel Burton.  Turns out that my simple idea of turning the
SELECT into a subquery does not interact well *at all* with the way the
rule rewriter works.  Really what we need to make INSERT ... SELECT work
cleanly is to decouple targetlists from rangetables: an INSERT ... SELECT
wants to have two levels of targetlist but only one rangetable.  No time
for that for 7.1, however, so I've inserted some ugly hacks to make the
rewriter know explicitly about the structure of INSERT ... SELECT queries.
Ugh :-(
2000-12-05 19:15:10 +00:00
Peter Eisentraut 3d0e49623b corrections 2000-12-03 21:12:19 +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
Tom Lane 68ed296301 Don't use 'private' as a parameter name in visible headers ... makes C++
very unhappy ...
2000-12-03 17:18:10 +00:00
Thomas G. Lockhart 6969b8fa11 Repair usage of the OVERLAPS operator.
Allow some operator-like tokens to be used as function names.
Flesh out support for time, timetz, and interval operators
 and interactions.
Regression tests pass, but non-reference-platform horology test results
 will need to be updated.
2000-12-03 14:51:12 +00:00
Peter Eisentraut 13dbd0276a Final(?) GUC clean-up. Update psql tab completion. 2000-12-03 14:36:47 +00:00
Vadim B. Mikheev 65b362fae1 Disable elog(ERROR|FATAL) in signal handlers in
critical sections of code.
2000-12-03 10:27:29 +00:00
Tom Lane 5e3bc5ebcd Avoid memory leakage during regular COPY when outputting toasted values.
COPY BINARY is still broken for toasted data, however.
2000-12-02 20:49:24 +00:00