Commit Graph

448 Commits

Author SHA1 Message Date
Peter Eisentraut 8a3cbc84ef Repair parallel make in backend tree (and make it really parallel).
Make Gen_fmgrtab.sh reasonably robust against concurrent invocation.
2000-07-13 16:07:14 +00:00
Tom Lane 9191d684a7 Planner did the wrong thing with index-scan-backward plans: generated
them, but forgot to attach relevant restriction clauses, so that the
plan represented a scan over the whole table with restrictions applied
as qpquals not indexquals.  Another day, another bug...
2000-07-13 05:47:29 +00:00
Peter Eisentraut cb292206c5 Remove a bunch of unused configure tests, in particular cases where
* the result is not recorded anywhere
* the result is not used anywhere
* the result is only used in some places, whereas others have been getting away with it
* the result is used improperly

Also make command line options handling a little better (e.g., --disable-locale,
while redundant, should really still *dis*able).
2000-07-12 22:59:15 +00:00
Tom Lane badce86a2c First stage of reclaiming memory in executor by resetting short-term
memory contexts.  Currently, only leaks in expressions executed as
quals or projections are handled.  Clean up some old dead cruft in
executor while at it --- unused fields in state nodes, that sort of thing.
2000-07-12 02:37:39 +00:00
Tom Lane 40f64064ff Update textin() and textout() to new fmgr style. This is just phase
one of updating the whole text datatype, but there are so dang many
calls of these two routines that it seems worth a separate commit.
2000-07-05 23:12:09 +00:00
Tom Lane 1aebc3618a First phase of memory management rewrite (see backend/utils/mmgr/README
for details).  It doesn't really do that much yet, since there are no
short-term memory contexts in the executor, but the infrastructure is
in place and long-term contexts are handled reasonably.  A few long-
standing bugs have been fixed, such as 'VACUUM; anything' in a single
query string crashing.  Also, out-of-memory is now considered a
recoverable ERROR, not FATAL.
Eliminate a large amount of crufty, now-dead code in and around
memory management.
Fix problem with holding off SIGTRAP, SIGSEGV, etc in postmaster and
backend startup.
2000-06-28 03:33:33 +00:00
Tom Lane 38db5fab29 Make inheritance planning logic a little simpler and clearer,
hopefully even a little faster.
2000-06-20 04:22:21 +00:00
Tom Lane 1ee26b7764 Reimplement nodeMaterial to use a temporary BufFile (or even memory, if the
materialized tupleset is small enough) instead of a temporary relation.
This was something I was thinking of doing anyway for performance, and Jan
says he needs it for TOAST because he doesn't want to cope with toasting
noname relations.  With this change, the 'noname table' support in heap.c
is dead code, and I have accordingly removed it.  Also clean up 'noname'
plan handling in planner --- nonames are either sort or materialize plans,
and it seems less confusing to handle them separately under those names.
2000-06-18 22:44:35 +00:00
Tom Lane d03a933ec5 Fix performance problems with pg_index lookups (see, for example,
discussion of 5/19/00).  pg_index is now searched for indexes of a
relation using an indexscan.  Moreover, this is done once and cached
in the relcache entry for the relation, in the form of a list of OIDs
for the indexes.  This list is used by the parser and executor to drive
lookups in the pg_index syscache when they want to know the properties
of the indexes.  Net result: index information will be fully cached
for repetitive operations such as inserts.
2000-06-17 21:49:04 +00:00
Bruce Momjian df43800fc8 Clean up #include's. 2000-06-15 03:33:12 +00:00
Tom Lane ce7746201b Cause inheritance patch to meet minimum coding standards (no gcc
warnings).
2000-06-09 03:17:13 +00:00
Bruce Momjian 8c1d09d591 Inheritance overhaul by Chris Bitmead <chris@bitmead.com> 2000-06-09 01:44:34 +00:00
Bruce Momjian 20ad43b576 Mark functions as static and ifdef NOT_USED as appropriate. 2000-06-08 22:38:00 +00:00
Tom Lane 2190cf2926 Repair bug reported by ldm@apartia.com: Append nodes, which don't
actually use their targetlist, are given a targetlist that is just a
pointer to the first appended plan's targetlist.  This is OK, but what
is not OK is that any sub-select expressions in said tlist were being
entered in the subPlan lists of both the Append and the first appended
plan.  That led to two startup and two shutdown calls for the same
plan node at exec time, which led to crashes.  Fix is to not generate
a list of subPlans for an Append node.  Same problem and fix apply
to other node types that don't have a real, functioning targetlist:
Material, Sort, Unique, Hash.
2000-06-04 20:50:50 +00:00
Tom Lane cbf503180f Tweak recognition of range-clause pairs so that 'var > $1 AND var < $2'
(ie, parameters instead of consts) will be treated as a range query.
We do not know the actual selectivities involved, but it seems like
a good idea to use a smaller estimate than we would use for two unrelated
inequalities.
2000-05-31 15:38:53 +00:00
Peter Eisentraut 6a68f42648 The heralded `Grand Unified Configuration scheme' (GUC)
That means you can now set your options in either or all of $PGDATA/configuration,
some postmaster option (--enable-fsync=off), or set a SET command. The list of
options is in backend/utils/misc/guc.c, documentation will be written post haste.

pg_options is gone, so is that pq_geqo config file. Also removed were backend -K,
-Q, and -T options (no longer applicable, although -d0 does the same as -Q).

Added to configure an --enable-syslog option.

changed all callers from TPRINTF to elog(DEBUG)
2000-05-31 00:28:42 +00:00
Tom Lane 0f1e39643d Third round of fmgr updates: eliminate calls using fmgr() and
fmgr_faddr() in favor of new-style calls.  Lots of cleanup of
sloppy casts to use XXXGetDatum and DatumGetXXX ...
2000-05-30 04:25:00 +00:00
Bruce Momjian a12a23f0d0 Remove unused include files. Do not touch /port or includes used by defines. 2000-05-30 00:49:57 +00:00
Tom Lane 091126fa28 Generated header files parse.h and fmgroids.h are now copied into
the src/include tree, so that -I backend is no longer necessary anywhere.
Also, clean up some bit rot in contrib tree.
2000-05-29 05:45:56 +00:00
Tom Lane ab843085f1 Constant-expression simplifier now knows how to simplify strict functions
that have at least one constant-NULL input, even if other inputs are
not constants.
2000-05-28 20:33:28 +00:00
Tom Lane 0a7fb4e918 First round of changes for new fmgr interface. fmgr itself and the
key call sites are changed, but most called functions are still oldstyle.
An exception is that the PL managers are updated (so, for example, NULL
handling now behaves as expected in plperl and plpgsql functions).
NOTE initdb is forced due to added column in pg_proc.
2000-05-28 17:56:29 +00:00
Tom Lane 1c5b902018 Fix problem in which sloppily-coded test in ExecInitIndexScan would
think that both sides of indexqual look like index keys.  An example is
create table inside (f1 float8 primary key);
create table outside (g1 float8, g2 float8);
select * from inside,outside where f1 = atan2(g1+1, g2);
ERROR:  ExecInitIndexScan: both left and right ops are rel-vars
(note that failure is potentially platform-dependent).  Solution is a
cleanup I had had in mind to make anyway: functional index keys should
be represented as Var nodes in the fixed indexqual, just like regular
index keys.
2000-05-23 16:56:37 +00:00
Tom Lane d6eac08f11 Repair problem noted by Elphick: make_rels_by_joins failed to handle
cases where joinclauses were present but some joins have to be made
by cartesian-product join anyway.  An example is
SELECT * FROM a,b,c WHERE (a.f1 + b.f2 + c.f3) = 0;
Even though all the rels have joinclauses, we must join two of them
in cartesian style before we can use the join clause...
2000-04-27 18:35:04 +00:00
Tom Lane 32e192d712 Repair coredump seen when a view refers to an inheritance group
(SELECT FROM table*).  Cause was reference to 'eref' field of an RTE,
which is null in an RTE loaded from a stored rule parsetree.  There
wasn't any good reason to be touching the refname anyway...
2000-04-18 05:52:35 +00:00
Tom Lane 25442d8d2f Correct oversight in hashjoin cost estimation: nodeHash sizes its hash
table for an average of NTUP_PER_BUCKET tuples/bucket, but cost_hashjoin
was assuming a target load of one tuple/bucket.  This was causing a
noticeable underestimate of hashjoin costs.
2000-04-18 05:43:02 +00:00
Tom Lane 82849df6c6 Add new selectivity estimation functions for pattern-matching operators
(LIKE and regexp matches).  These are not yet referenced in pg_operator,
so by default the system will continue to use eqsel/neqsel.
Also, tweak convert_to_scalar() logic so that common prefixes of strings
are stripped off, allowing better accuracy when all strings in a table
share a common prefix.
2000-04-16 04:41:03 +00:00
Tom Lane 8064a49f6f get_relattval() should treat a NULL constant as a non-constant expression,
since it has no way to indicate to its caller that the constant is
actually NULL.  This prevents coredump in cases like
  WHERE textfield < null::text;
2000-04-16 01:55:45 +00:00
Tom Lane 9d91db4fde Repair bug reported by Wickstrom: backend would crash if WHERE clause
contained a sub-SELECT nested within an AND/OR tree that cnfify()
thought it should rearrange.  Same physical sub-SELECT node could
end up linked into multiple places in resulting expression tree.
This is harmless for most node types, but not for SubLink.
Repair bug by making physical copies of subexpressions that get
logically duplicated by cnfify().  Also, tweak the heuristic that
decides whether it's a good idea to do cnfify() --- we don't really
want that to happen when it would cause multiple copies of a subselect
to be generated, I think.
2000-04-14 00:19:17 +00:00
Bruce Momjian 52f77df613 Ye-old pgindent run. Same 4-space tabs. 2000-04-12 17:17:23 +00:00
Tom Lane 9c38a8d296 Further tweaking of indexscan cost estimates. 2000-04-09 04:31:37 +00:00
Tom Lane 1c72a8a37a Fix extremely nasty little bug observed when a sub-SELECT appears in
WHERE in a place where it can be part of a nestloop inner indexqual.
As the code stood, it put the same physical sub-Plan node into both
indxqual and indxqualorig of the IndexScan plan node.  That confused
later processing in the optimizer (which expected that tracing the
subPlan list would visit each subplan node exactly once), and would
probably have blown up in the executor if the planner hadn't choked first.
Fix by making the 'fixed' indexqual be a complete deep copy of the
original indexqual, rather than trying to share nodes below the topmost
operator node.  This had further ramifications though, because we were
making the aforesaid list of sub-Plan nodes during SS_process_sublinks
which is run before construction of the 'fixed' indexqual, meaning that
the copy of the sub-Plan didn't show up in that list.  Fix by rearranging
logic so that the sub-Plan list is built by the final set_plan_references
pass, not in SS_process_sublinks.  This may sound like a mess, but it's
actually a good deal cleaner now than it was before, because we are no
longer dependent on the assumption that planning will never make a copy
of a sub-Plan node.
2000-04-04 01:21:48 +00:00
Tom Lane e55985d3be Tweak indexscan cost estimation: round estimated # of tuples visited up
to next integer.  Previously, if selectivity was small, we could compute
very tiny scan cost on the basis of estimating that only 0.001 tuple
would be fetched, which is silly.  This naturally led to some rather
silly plans...
2000-03-30 00:53:30 +00:00
Tom Lane 8cbeb5f131 Save a few cycles in simple cases: no need to call cost_sort() when there
is no presorted path to compare with.
2000-03-24 21:40:43 +00:00
Tom Lane 7177bbac29 A little further tweaking of the range-query selectivity logic:
to avoid undue sensitivity to roundoff error, believe that a zero
or slightly negative range estimate should represent a small
positive selectivity, rather than falling back on a generic default
estimate.
2000-03-23 23:35:47 +00:00
Tom Lane 1afaa2557a If we cannot get a real estimate for the selectivity of a range query,
use a default value that's fairly small.  We were generating a result
of about 0.1, but I think 0.01 is probably better --- want to encourage
use of an indexscan in this situation.
2000-03-23 00:58:36 +00:00
Tom Lane 1d5e7a6f46 Repair logic flaw in cost estimator: cost_nestloop() was estimating CPU
costs using the inner path's parent->rows count as the number of tuples
processed per inner scan iteration.  This is wrong when we are using an
inner indexscan with indexquals based on join clauses, because the rows
count in a Relation node reflects the selectivity of the restriction
clauses for that rel only.  Upshot was that if join clause was very
selective, we'd drastically overestimate the true cost of the join.
Fix is to calculate correct output-rows estimate for an inner indexscan
when the IndexPath node is created and save it in the path node.
Change of path node doesn't require initdb, since path nodes don't
appear in saved rules.
2000-03-22 22:08:35 +00:00
Tom Lane 3ee8f7e207 Restructure planning code so that preprocessing of targetlist and quals
to simplify constant expressions and expand SubLink nodes into SubPlans
is done in a separate routine subquery_planner() that calls union_planner().
We formerly did most of this work in query_planner(), but that's the
wrong place because it may never see the real targetlist.  Splitting
union_planner into two routines also allows us to avoid redundant work
when union_planner is invoked recursively for UNION and inheritance
cases.  Upshot is that it is now possible to do something like
select float8(count(*)) / (select count(*) from int4_tbl)  from int4_tbl
group by f1;
which has never worked before.
2000-03-21 05:12:12 +00:00
Tom Lane d6429e552d Minor code rearrangement & doc improvement in eval_const_expressions(). 2000-03-19 18:20:38 +00:00
Tom Lane 341b328b18 Fix a bunch of minor portability problems and maybe-bugs revealed by
running gcc and HP's cc with warnings cranked way up.  Signed vs unsigned
comparisons, routines declared static and then defined not-static,
that kind of thing.  Tedious, but perhaps useful...
2000-03-17 02:36:41 +00:00
Thomas G. Lockhart 6456810078 Implement column aliases on views "CREATE VIEW name (collist)".
Implement TIME WITH TIME ZONE type (timetz internal type).
Remap length() for character strings to CHAR_LENGTH() for SQL92
 and to remove the ambiguity with geometric length() functions.
Keep length() for character strings for backward compatibility.
Shrink stored views by removing internal column name list from visible rte.
Implement min(), max() for time and timetz data types.
Implement conversion of TIME to INTERVAL.
Implement abs(), mod(), fac() for the int8 data type.
Rename some math functions to generic names:
 round(), sqrt(), cbrt(), pow(), etc.
Rename NUMERIC power() function to pow().
Fix int2 factorial to calculate result in int4.
Enhance the Oracle compatibility function translate() to work with string
 arguments (from Edwin Ramirez).
Modify pg_proc system table to remove OID holes.
2000-03-14 23:06:59 +00:00
Tom Lane 6217a8c7ba Fix some bogosities in the code that deals with estimating the fraction
of tuples we are going to retrieve from a sub-SELECT.  Must have been
half asleep when I did this code the first time :-(
2000-03-14 02:23:15 +00:00
Tom Lane 1879175b18 Fix performance bug in constant-expression simplifier. After finding
that the inputs to a given operator can be recursively simplified to
constants, it was evaluating the operator using the op's *original*
(unsimplified) arg list, so that any subexpressions had to be evaluated
again.  A constant subexpression at depth N got evaluated N times.
Probably not very important in practical situations, but it made us look
real slow in MySQL's 'crashme' test...
2000-03-12 19:32:06 +00:00
Tom Lane e8be8ffaf0 Further tweaking of logic that decides when to materialize an uncorrelated
subplan: do it if subplan has subplans itself, and always do it if the
subplan is an indexscan.  (I originally set it to materialize an indexscan
only if the indexqual is fairly selective, but I dunno what I was
thinking ... an unselective indexscan is still expensive ...)
2000-03-11 23:53:41 +00:00
Hiroshi Inoue fd9ff86bd9 Trial implementation of ALTER DROP COLUMN.
They are #ifdef'd.
Add -D_DROP_COLUMN_HACK__ compile option
to evaluate it.
2000-03-09 05:00:26 +00:00
Tom Lane 0eb5ab8250 Apply a MATERIAL node to the result of an uncorrelated subplan, if it
looks like it will save computation to do so.
2000-03-02 04:08:16 +00:00
Tom Lane 84ccfdf087 Avoid a little bit of unnecessary computation in canonicalize_qual. 2000-02-27 19:45:44 +00:00
Tom Lane be05edd812 Tweak planner to use OFFSET+LIMIT, not just LIMIT, as estimate of the
portion of the query result that will be retrieved.  As far as I could
tell, the consensus was that we should let the planner do the best it
can with a LIMIT query, and require the user to add ORDER BY if he
wants consistent results from different LIMIT values.
2000-02-21 01:13:04 +00:00
Tom Lane 57b30e8e22 Create a new expression node type RelabelType, which exists solely to
represent the result of a binary-compatible type coercion.  At runtime
it just evaluates its argument --- but during type resolution, exprType
will pick up the output type of the RelabelType node instead of the type
of the argument.  This solves some longstanding problems with dropped
type coercions, an example being 'select now()::abstime::int4' which
used to produce date-formatted output, not an integer, because the
coercion to int4 was dropped on the floor.
2000-02-20 21:32:16 +00:00
Tom Lane 3cbcb78a3d Plug some more memory leaks in the planner. It still leaks like a sieve,
but this is as good as it'll get for this release...
2000-02-18 23:47:31 +00:00
Hiroshi Inoue e3a97b370c Implement reindex command 2000-02-18 09:30:20 +00:00