Commit Graph

2553 Commits

Author SHA1 Message Date
Tom Lane be09bc9ff2 Modify nodeAgg.c so that no rows are returned for a GROUP BY
with no input rows, per pghackers discussions around 7/22/99.  Clean up
a bunch of ugly coding while at it; remove redundant re-lookup of
aggregate info at start of each new GROUP.  Arrange to pfree intermediate
values when they are pass-by-ref types, so that aggregates on pass-by-ref
types no longer eat memory.  This takes care of a couple of TODO items...
1999-09-26 21:21:15 +00:00
Tom Lane 40f6524161 Implement constant-expression simplification per Bernard
Frankpitt, plus some improvements from yours truly.  The simplifier depends
on the proiscachable field of pg_proc to tell it whether a function is
safe to pre-evaluate --- things like nextval() are not, for example.
Update pg_proc.h to contain reasonable cacheability information; as of
6.5.* hardly any functions were marked cacheable.  I may have erred too
far in the other direction; see recent mail to pghackers for more info.
This update does not force an initdb, exactly, but you won't see much
benefit from the simplifier until you do one.
1999-09-26 02:28:44 +00:00
Tom Lane e812458b27 Several changes here, not very related but touching some of the same files.
* Buffer refcount cleanup (per my "progress report" to pghackers, 9/22).
* Add links to backend PROC structs to sinval's array of per-backend info,
and use these links for routines that need to check the state of all
backends (rather than the slow, complicated search of the ShmemIndex
hashtable that was used before).  Add databaseOID to PROC structs.
* Use this to implement an interlock that prevents DESTROY DATABASE of
a database containing running backends.  (It's a little tricky to prevent
a concurrently-starting backend from getting in there, since the new
backend is not able to lock anything at the time it tries to look up
its database in pg_database.  My solution is to recheck that the DB is
OK at the end of InitPostgres.  It may not be a 100% solution, but it's
a lot better than no interlock at all...)
* In ALTER TABLE RENAME, flush buffers for the relation before doing the
rename of the physical files, to ensure we don't get failures later from
mdblindwrt().
* Update TRUNCATE patch so that it actually compiles against current
sources :-(.
You should do "make clean all" after pulling these changes.
1999-09-24 00:25:33 +00:00
Bruce Momjian dabc3f31b5 Fix for netmask('x.x.x.x/0') is 255.255.255.255 instead of 0.0.0.0
This is because (-1) << 32 is -1 (Only intel arc. has been checked)

Oleg Sharoiko
1999-09-23 17:42:23 +00:00
Bruce Momjian e7cad7b0cb Add TRUNCATE command, with psql help and sgml additions. 1999-09-23 17:03:39 +00:00
Bruce Momjian ad604ac372 values.h patch from Alex Howansky 1999-09-21 20:58:25 +00:00
Tom Lane fe2ab18ed9 Remove incorrect 'Assert(targetList != NULL)'. An
INSERT ... DEFAULT VALUES statement does indeed have a null targetlist,
at least during parse and rewrite stages.
1999-09-19 17:20:58 +00:00
Tom Lane e1a8b0f2ce Fix CASE bug identified by Keith Parks: CASE didn't reliably
treat a NULL condition result as FALSE.  Clean up some bogus comments
here and there, too.
1999-09-18 23:26:37 +00:00
Tom Lane bd272cace6 Mega-commit to make heap_open/heap_openr/heap_close take an
additional argument specifying the kind of lock to acquire/release (or
'NoLock' to do no lock processing).  Ensure that all relations are locked
with some appropriate lock level before being examined --- this ensures
that relevant shared-inval messages have been processed and should prevent
problems caused by concurrent VACUUM.  Fix several bugs having to do with
mismatched increment/decrement of relation ref count and mismatched
heap_open/close (which amounts to the same thing).  A bogus ref count on
a relation doesn't matter much *unless* a SI Inval message happens to
arrive at the wrong time, which is probably why we got away with this
sloppiness for so long.  Repair missing grab of AccessExclusiveLock in
DROP TABLE, ALTER/RENAME TABLE, etc, as noted by Hiroshi.
Recommend 'make clean all' after pulling this update; I modified the
Relation struct layout slightly.
Will post further discussion to pghackers list shortly.
1999-09-18 19:08:25 +00:00
Tatsuo Ishii 2d0eee32c4 Changes made by Hiroshi Inoue and approved by Vadim.
See attached mail for more details.

-------------------------------------------------------------------
From: "Vadim Mikheev" <vadim@krs.ru>
To: "Hiroshi Inoue" <Inoue@tpf.co.jp>
References: <000201befa94$42fe04c0$2801007e@cadzone.tpf.co.jp>
Subject: Re: elog(ERROR) in vacuum
Date: Fri, 10 Sep 1999 10:27:10 +0900
Organization: OJSC Rostelecom (Krasnoyarsk)
Message-ID: <37D85E6E.5AFA126D@krs.ru>

Hiroshi Inoue wrote:
>
> Hello Vadim,
>
> I have a question about vacuum.
>
> VACUUM has a phase like commit which calls TransactionIdCommit().
> But if elog(ERROR) occured after that,the status of transaction is
> changed from XID_COMMIT to XID_ABORT.
>
> Seems to me this causes inconsistency.
> Shoudn't AbortTransaction() be changed not to call TransacionIdAbort()
> in case of vacuum.

You're right!
As usual -:)

Vadim
1999-09-16 09:08:56 +00:00
Thomas G. Lockhart 2ee735ca21 Allow ISOLATION and LEVEL as column names. These are SQL92 reserved words
which do not need to be so for our parser. Apparently omitted earlier.
1999-09-14 06:06:31 +00:00
Thomas G. Lockhart f0f73b316d Allow CASE statement to contain *only* untyped result clauses or nulls.
Almost worked before, but forgot one place to check.
 Reported by Tatsuo Ishii.
Still does not do the right thing if inserting into a non-string target
 column. Should look for a type coersion later, but doesn't.
1999-09-13 04:14:56 +00:00
Tom Lane 43d32d3683 First cut at doing something reasonable with OR-of-ANDs WHERE
conditions.  There are some pretty bogus heuristics in prepqual.c that
try to decide whether to output CNF or DNF format; they need to be replaced,
likely.  Right now the code is probably too willing to choose DNF form,
which might hurt performance in some cases that used to work OK.
But at least we have a foundation to build on.
1999-09-13 00:17:25 +00:00
Marc G. Fournier 2b7777bfa2 cygwin doesn't have an endian.h, but defines BYTE_ORDER in sys/param.h 1999-09-12 22:27:47 +00:00
Tom Lane 2119cc0670 Further improvements in cnfify: reduce amount of self-recursion
in or_normalize, remove detection of duplicate subexpressions (since it's
highly unlikely to be worth the amount of time it takes), and introduce
a dnfify() entry point so that unintelligible backwards logic in UNION
processing can be eliminated.  This is just an intermediate step ---
next thing is to look at not forcing the qual into CNF form when it would
be better off in DNF form.
1999-09-12 18:08:17 +00:00
Tom Lane 4644fc8071 Eliminate query length limitation imposed by pg_client_to_server
and pg_server_to_client.  Eliminate copy.c's restriction on the length
of a single attribute.
1999-09-11 22:28:11 +00:00
Tom Lane b65ab31910 Eliminate token length assumption in scanstr(). 1999-09-11 22:26:47 +00:00
Tom Lane b399805e22 Eliminate elog()'s hardwired limit on length of an error message.
This change seems necessary in conjunction with long queries, and it
cleans up some bogosity in connection with long EXPLAIN texts anyway.
Note that current libpq will accept any length error message (at least
until it runs out of memory); prior versions have a limit of 8K, but
will cleanly discard excess error text, so there shouldn't be any
big compatibility problems with old clients.
1999-09-11 19:06:42 +00:00
Tom Lane 5bc0d31ae8 Repair incorrect cleanup of heap memory allocation during
transaction abort --- before it only worked if there was exactly one level
of allocation context stacked in the blank portal.  Now it does the right
thing for any depth, including zero...
1999-09-09 16:25:35 +00:00
Tom Lane 8b8db01517 Minor improvement in SI overflow logic: try to delete
expired messages before concluding that we really have buffer overflow.
1999-09-09 14:56:06 +00:00
Tom Lane 9e713ddb99 Get rid of elog(DEBUG) in snprintf emulation ... it's just
cluttering the log file...
1999-09-09 03:13:22 +00:00
Tom Lane 51db6455ea Repair error noticed by Roberto Cornacchia: selectivity code
was rejecting negative attnums as bogus, which of course they are not.
Add code to get_attdisbursion to produce a useful value for OID attribute,
since VACUUM does not store stats for system attributes.
Also, repair bug that's been in eqjoinsel for a long time: it was taking
the max of the two columns' disbursions, whereas it should use the min.
1999-09-09 02:36:04 +00:00
Tom Lane 45500964f6 StreamConnection() mustn't call elog(). 1999-09-08 22:57:12 +00:00
Tom Lane b1134e369f Cope with versions of vsnprintf() written by people who
don't read man pages...
1999-09-08 16:31:38 +00:00
Tom Lane bee7cd2a36 Repair logic error in LIKE: should not return LIKE_ABORT
when reach end of pattern before end of text.  Improve code comments.
1999-09-07 19:09:46 +00:00
Tom Lane 8759f175db Performance improvements in cnfify(): get rid of exponential
space consumption in pull_args, and avoid doing the full CNF transform on
operands of operator clauses, where it's really not particularly helpful.
This answers the TODO item about large numbers of OR clauses, at least
partially.  I was able to do a ten-thousand-OR-clause query with about
20Mb memory consumption ... it took an obscenely long time, but it worked...
1999-09-07 03:47:06 +00:00
Tom Lane 85712da90d Mike Ansley's fixes for long queries. This change just
corrects flex myinput() routine so that it doesn't assume there is only
one bufferload of data.  We still have the issue of getting rid of
YY_USES_REJECT so that the scanner can cope with tokens larger than its
initial buffer size.
1999-09-07 00:13:27 +00:00
Tom Lane 22fe3d4b04 I finally understood what sinvaladt.c is doing --- and it
offended my aesthestic sensibility that there was so much unreadable code
doing so little.  Rewritten code is about half the size, faster, and
(I hope) much more intelligible.
1999-09-06 19:37:38 +00:00
Tom Lane cc8b67a5c3 Fix relcache.c so that local relations (those created during
current transaction) are not flushed by shared-cache-inval reset message.
SI reset actually works now, for probably the first time in a long time.
I was able to run initdb and regression tests with a 16-element SI message
array, with a lot of NOTICE: cache state reset messages but no crashes.
1999-09-06 19:33:16 +00:00
Tom Lane c5092847e7 RelationCacheInvalidate thought there were 7 nailed-in-cache
system tables, but actually there are only 6 --- see RelationInitialize.
Kinda makes you wonder how long ago this code was last executed...
1999-09-06 18:13:02 +00:00
Tom Lane b9d01fe288 Per Tatsuo's recommendation, change mdopen so that it won't
automatically create the file, except during bootstrap mode where that
seems to be necessary.
1999-09-05 23:24:53 +00:00
Tom Lane 0041202b98 Disallow DROP TABLE/DROP INDEX inside a transaction block.
We can't support these properly, since once the relation's physical files
are unlinked, there's no way to roll back the transaction.  I suppose
we could postpone the unlink till transaction commit, but then what of
BEGIN; DROP TABLE foo; CREATE TABLE foo; ?
The code does allow dropping a table/index created in the current
transaction block, however, since the post-abort state would be that
the table doesn't exist anyway.
1999-09-05 17:43:47 +00:00
Tom Lane 6645a73863 IsTransactionBlock() should return true in TBLOCK_ABORT state. 1999-09-05 17:12:34 +00:00
Bruce Momjian 4fa1eeb826 remove elogs used for debugging. 1999-09-04 22:03:09 +00:00
Bruce Momjian 0e14dfe0fb Intercept temp table lookups further up to map temp names. 1999-09-04 22:00:30 +00:00
Tom Lane cb36c0f682 In RelationNameGetRelation(), replace temp table name by
real name before doing lookup.  We only want to index temp tables by their
real names in the relcache, to ensure there's not more than one relcache
entry for them.
1999-09-04 21:47:23 +00:00
Tom Lane 15dd167854 Avoid transaction overhead when there are no temp tables
to be deleted.
1999-09-04 21:45:48 +00:00
Tom Lane a24ebc3f7e Remove no-longer-needed code to update temprel's copy of
pg_class tuple during ALTER TABLE ADD COLUMN.
1999-09-04 21:19:33 +00:00
Bruce Momjian fb7548f4db Invalidate temp entries for aborted transactions. 1999-09-04 19:55:50 +00:00
Tom Lane b4a607c9e0 Modify RelationFlushRelation so that if the relcache entry
has positive refcount, it is rebuilt from pg_class data.  This ensures
that relcache entries will track changes made by other backends.  Formerly,
a shared inval report would just be ignored if it happened to arrive while
the relcache entry was in use.  Also, fix relcache to reset ref counts
to zero during transaction abort.  Finally, change LockRelation() so that
it checks for shared inval reports after obtaining the lock.  In this way,
once any kind of lock has been obtained on a rel, we can trust the relcache
entry to be up-to-date.
1999-09-04 18:42:15 +00:00
Tom Lane 8add6d71cf Modify sinval so that InvalidateSharedInvalid() does not hold
the SInval spinlock while it is calling the passed invalFunction or
resetFunction.  This is necessary to avoid deadlock with lmgr change;
InvalidateSharedInvalid can be called recursively now.  It should be
a good performance improvement anyway --- holding a spinlock for more
than a very short interval is a no-no.
1999-09-04 18:36:45 +00:00
Tom Lane 51f62ea45c Rule deparser didn't handle unary operators correctly. 1999-09-02 03:04:04 +00:00
Tom Lane 68c323483c Repair a bunch of problems in md.c. This builds on Hiroshi's
insight that RelationFlushRelation ought to invoke smgrclose, and that the
way to make that work is to ensure that mdclose doesn't fail if the relation
is already closed (or unlinked, if we are looking at a DROP TABLE).  While
I was testing that, I was able to identify several problems that we had
with multiple-segment relations.  The system is now able to do initdb and
pass the regression tests with a very small segment size (I had it set to
64Kb per segment for testing).  I don't believe that ever worked before.
File descriptor leaks seem to be gone too.
I have partially addressed the concerns we had about mdtruncate(), too.
On a Win32 or NFS filesystem it is not possible to unlink a file that
another backend is holding open, so what md.c now does is to truncate
unwanted files to zero length before trying to unlink them.  The other
backends will be forced to close their open files by relation cache
invalidation --- but I think it would take considerable work to make
that happen before vacuum truncates the relation rather than after.
Leaving zero-length files lying around seems a usable compromise.
1999-09-02 02:57:50 +00:00
Tom Lane e25e6a6dc3 Commit the bulk of Mike Ansley's long-query changes in the
backend.  Still much left to do.
1999-08-31 04:26:40 +00:00
Tom Lane 130e372b5d Minor improvements to stringinfo package to make it more
robust, since it's about to get used much more heavily.
1999-08-31 01:28:37 +00:00
Tom Lane 958600156c Fix several problems in rule deparsing: didn't handle array
references or CASE expressions, didn't parenthesize complex expressions
properly.  Also, always output variable references as fully qualified
names to eliminate ambiguity bug recently reported.  (This could be
smarter, but reliability comes first.)
1999-08-28 03:59:05 +00:00
Tom Lane 37d20eb855 Clean up some mistakes in handling of uplevel Vars in planner.
Most parts of the planner should ignore, or indeed never even see, uplevel
Vars because they will be or have been replaced by Params.  There were a
couple of places that got it wrong though, probably my fault from recent
changes...
1999-08-26 05:09:06 +00:00
Tom Lane 5adebf83b6 Clean up some bugs in oper_select_candidate(), notably the
last loop which would return the *first* surviving-to-that-point candidate
regardless of which one actually passed the test.  This was producing
such curious results as 'oid % 2' getting translated to 'int2(oid) % 2'.
1999-08-26 04:59:15 +00:00
Tom Lane 42af56e1ea Revise implementation of SubLinks so that there is a consistent,
documented intepretation of the lefthand and oper fields.  Fix a number of
obscure problems while at it --- for example, the old code failed if the parser
decided to insert a type-coercion function just below the operator of a
SubLink.
CAUTION: this will break stored rules that contain subplans.  You may
need to initdb.
1999-08-25 23:21:43 +00:00
Tatsuo Ishii edda70c0de Fix vacuum's memory consumption 1999-08-25 12:20:57 +00:00