Commit Graph

395 Commits

Author SHA1 Message Date
Bruce Momjian 82682ff31f optimizer rename 1999-02-15 03:59:28 +00:00
Bruce Momjian ba2883b264 Remove duplicate geqo functions, and more optimizer cleanup 1999-02-15 03:22:37 +00:00
Tom Lane 944d3c395e Replace non-idiomatic nconc(x, lcons(y, NIL)) with lappend(x, y). 1999-02-15 02:04:58 +00:00
Tom Lane dec354ca97 Fix a number of places that made faulty assumptions about
what is_opclause will accept.
1999-02-15 01:06:59 +00:00
Tom Lane 5500039843 Fix optimizer coredump with unary-operator WHERE clauses.
A test case is:
create table linetab (x line);
select * from linetab where ?| x;
which coredumps in 6.4.2 and current sources.
1999-02-14 22:24:25 +00:00
Bruce Momjian d8b482be7c optimizer cleanup. 1999-02-14 05:27:12 +00:00
Bruce Momjian 808a6df065 optimizer rename. 1999-02-14 05:14:15 +00:00
Bruce Momjian 61aa825876 Optimizer rename. 1999-02-14 04:57:02 +00:00
Bruce Momjian 6724a50787 Change my-function-name-- to my_function_name, and optimizer renames. 1999-02-13 23:22:53 +00:00
Bruce Momjian ad4b27ac3f Optimizer cleanup. 1999-02-12 17:25:05 +00:00
Bruce Momjian c0d17c7aee JoinPath -> NestPath for nested loop. 1999-02-12 06:43:53 +00:00
Bruce Momjian 3fdb9bb9c7 Fix optimizer and make faster. 1999-02-12 05:57:08 +00:00
Bruce Momjian 55d0465009 optimizer update 1999-02-12 02:37:52 +00:00
Bruce Momjian 34ecb9d850 Optimizer cleanups. 1999-02-11 21:05:28 +00:00
Bruce Momjian c873fcdaf4 Optimizer cleanup. 1999-02-11 17:21:51 +00:00
Bruce Momjian 8dc2209f71 optimizer cleanup 1999-02-11 17:03:17 +00:00
Bruce Momjian 6de25f09b1 Optimizer cleanup. 1999-02-11 17:00:49 +00:00
Bruce Momjian 4ea3f728e9 More optimization. 1999-02-11 16:09:41 +00:00
Bruce Momjian d244df95db More optimizer speedups. 1999-02-11 14:59:09 +00:00
Bruce Momjian 129543e22d optimizer cleanup 1999-02-11 05:29:08 +00:00
Bruce Momjian dbd80c97f4 Optimizer fix for samekeys() and cost fixes for longer optimizer keys. 1999-02-11 04:08:44 +00:00
Bruce Momjian 9dbb0efb0b Optmizer cleanup 1999-02-10 21:02:50 +00:00
Bruce Momjian d5a785cd5a Update find_typedefs for bsdi 4.0. 1999-02-10 17:14:32 +00:00
Bruce Momjian f859c81c18 Rename Path.keys to Path.pathkeys. Too many 'keys' used for other things. 1999-02-10 03:52:54 +00:00
Bruce Momjian 318e593f03 Rename Temp to Noname for noname tables. 1999-02-09 17:03:14 +00:00
Bruce Momjian 78511d8fe9 Optimizer fix for samekeys. 1999-02-09 06:30:45 +00:00
Bruce Momjian fe35ffe7e0 Major optimizer improvement for joining a large number of tables. 1999-02-09 03:51:42 +00:00
Bruce Momjian 54e5d25666 Optimizer cleanup. 1999-02-08 04:29:25 +00:00
Tom Lane 65d320e7e4 Fix bracketing error in CaseExpr code 1999-02-07 03:02:21 +00:00
Bruce Momjian a553760845 Optimizer cleanup. 1999-02-06 17:29:30 +00:00
Bruce Momjian 7d2b3874aa optimizer cleanup 1999-02-05 20:34:11 +00:00
Bruce Momjian 6e2edaf4b8 Optimizer cleanup. 1999-02-05 19:59:31 +00:00
Tom Lane d3a85108c2 Fix silly typo in prune_joinrel 1999-02-05 03:43:05 +00:00
Bruce Momjian c45e4925ab Optimizer cleanups. 1999-02-04 23:19:53 +00:00
Bruce Momjian ae12e25263 Update optimizer comments. 1999-02-04 19:20:12 +00:00
Bruce Momjian ce3afccf7f More optimizer cleanups. 1999-02-04 03:19:11 +00:00
Bruce Momjian 18fbe4142f More optimizer renaming HInfo -> HashInfo. 1999-02-04 01:47:02 +00:00
Bruce Momjian 9322950aa4 Cleanup of source files where 'return' or 'var =' is alone on a line. 1999-02-03 21:18:02 +00:00
Bruce Momjian 8d9237d485 Optimizer rename ClauseInfo -> RestrictInfo. Update optimizer README. 1999-02-03 20:15:53 +00:00
Jan Wieck f3a6b38e32 Sort node for ORDER BY is suppressed if choosen index scan will
allways present tuples in the requested order.

Jan
1999-02-03 19:31:24 +00:00
Bruce Momjian 4090d17fee SET_ARGS cleanup 1999-02-02 23:53:26 +00:00
Bruce Momjian f1b7823471 Make GEQO use dependent on table and index count. 1999-02-02 20:30:18 +00:00
Bruce Momjian 8e958b8a38 Fix create_rule is->as. 1999-02-02 17:46:17 +00:00
Tom Lane 757f403451 Tighten coding in samekeys(). Pretty braindead change,
but it saves almost 10% of the runtime in Charles Hornberger's optimizer
example, so what the heck ...
1999-02-01 04:20:50 +00:00
Bruce Momjian 692a65e6ff pgindent file. 1999-01-26 05:57:14 +00:00
Bruce Momjian 1401f63dd1 Agg/Aggreg cleanup and datetime.sql patch. 1999-01-25 18:02:28 +00:00
Vadim B. Mikheev 247b3f9054 SELECT FOR UPDATE is implemented... 1999-01-25 12:01:19 +00:00
Bruce Momjian 17467bb7fb Rename Aggreg to Aggref. 1999-01-24 00:28:37 +00:00
Bruce Momjian 598a4e15dd Remove unused Choose node. 1999-01-23 23:28:09 +00:00
Bruce Momjian bd8ffc6f3f Hi!
INTERSECT and EXCEPT is available for postgresql-v6.4!

The patch against v6.4 is included at the end of the current text
(in uuencoded form!)

I also included the text of my Master's Thesis. (a postscript
version). I hope that you find something of it useful and would be
happy if parts of it find their way into the PostgreSQL documentation
project (If so, tell me, then I send the sources of the document!)

The contents of the document are:
  -) The first chapter might be of less interest as it gives only an
     overview on SQL.

  -) The second chapter gives a description on much of PostgreSQL's
     features (like user defined types etc. and how to use these features)

  -) The third chapter starts with an overview of PostgreSQL's internal
     structure with focus on the stages a query has to pass (i.e. parser,
     planner/optimizer, executor). Then a detailed description of the
     implementation of the Having clause and the Intersect/Except logic is
     given.

Originally I worked on v6.3.2 but never found time enough to prepare
and post a patch. Now I applied the changes to v6.4 to get Intersect
and Except working with the new version. Chapter 3 of my documentation
deals with the changes against v6.3.2, so keep that in mind when
comparing the parts of the code printed there with the patched sources
of v6.4.

Here are some remarks on the patch. There are some things that have
still to be done but at the moment I don't have time to do them
myself. (I'm doing my military service at the moment) Sorry for that
:-(

-) I used a rewrite technique for the implementation of the Except/Intersect
   logic which rewrites the query to a semantically equivalent query before
   it is handed to the rewrite system (for views, rules etc.), planner,
   executor etc.

-) In v6.3.2 the types of the attributes of two select statements
   connected by the UNION keyword had to match 100%. In v6.4 the types
   only need to be familiar (i.e. int and float can be mixed). Since this
   feature did not exist when I worked on Intersect/Except it
   does not work correctly for Except/Intersect queries WHEN USED IN
   COMBINATION WITH UNIONS! (i.e. sometimes the wrong type is used for the
   resulting table. This is because until now the types of the attributes of
   the first select statement have been used for the resulting table.
   When Intersects and/or Excepts are used in combination with Unions it
   might happen, that the first select statement of the original query
   appears at another position in the query which will be executed. The reason
   for this is the technique used for the implementation of
   Except/Intersect which does a query rewrite!)
   NOTE: It is NOT broken for pure UNION queries and pure INTERSECT/EXCEPT
         queries!!!

-) I had to add the field intersect_clause to some data structures
   but did not find time to implement printfuncs for the new field.
   This does NOT break the debug modes but when an Except/Intersect
   is used the query debug output will be the already rewritten query.

-) Massive changes to the grammar rules for SELECT and INSERT statements
   have been necessary (see comments in gram.y and documentation for
   deatails) in order to be able to use mixed queries like
   (SELECT ... UNION (SELECT ... EXCEPT SELECT)) INTERSECT SELECT...;

-) When using UNION/EXCEPT/INTERSECT you will get:
   NOTICE: equal: "Don't know if nodes of type xxx are equal".
   I did not have  time to add comparsion support for all the needed nodes,
   but the default behaviour of the function equal met my requirements.
   I did not dare to supress this message!

   That's the reason why the regression test for union will fail: These
   messages are also included in the union.out file!

-) Somebody of you changed the union_planner() function for v6.4
   (I copied the targetlist to new_tlist and that was removed and
   replaced by a cleanup of the original targetlist). These chnages
   violated some having queries executed against views so I changed
   it back again. I did not have time to examine the differences between the
   two versions but now it works :-)
   If you want to find out, try the file queries/view_having.sql on
   both versions and compare the results . Two queries won't produce a
   correct result with your version.

regards

    Stefan
1999-01-18 00:10:17 +00:00
Bruce Momjian 7a6b562fdf Apply Win32 patch from Horak Daniel. 1999-01-17 06:20:06 +00:00
Thomas G. Lockhart 4140c2f30e Add support for the CASE statement in the rewrite handling.
Allows (at least some) rules and views.
Still some trouble (crashes) with target CASE columns spanning tables,
 but lots now works.
1998-12-14 00:02:17 +00:00
Thomas G. Lockhart bedd04a551 Implement CASE expression. 1998-12-04 15:34:49 +00:00
Vadim B. Mikheev 6beba218d7 New HeapTuple structure/interface. 1998-11-27 19:52:36 +00:00
Vadim B. Mikheev 34680930d5 Fix using indices in OR.
EXPLAIN all indices used.
1998-11-22 10:48:45 +00:00
Bruce Momjian f03729c621 Fix for NOT in where clause causing crash. 1998-11-09 02:49:13 +00:00
Bruce Momjian 173c555948 Make functions static or ifdef NOT_USED. Prevent pg_version creation. 1998-10-08 18:30:52 +00:00
Bruce Momjian 3f8bc47d6a cnf'ify cleanup 1998-10-04 03:30:56 +00:00
Tom Lane d33bbb5b1f Get rid of some long-dead code that thinks NOTIFY is passed to the
planner/optimizer/executor.  It isn't.
Besides, most of the removed code consists of comments about how
it's not right.
1998-10-01 02:04:01 +00:00
Bruce Momjian b932b1b1c4 Allow 8-key indexes. 1998-09-23 04:22:14 +00:00
Bruce Momjian 3ce8a1b4ba Fix for SELECT NOT boolfield FROM table 1998-09-22 21:48:27 +00:00
Bruce Momjian a3c5a3cb2f Cleanup for oid8[] from Tatsuo Ishii. 1998-09-22 20:28:15 +00:00
Bruce Momjian 748e300317 Fix for AND/OR handling. 1998-09-21 15:41:28 +00:00
Bruce Momjian 25a64f7519 Fix for \z formatting from Tom Lane. 1998-09-21 02:25:29 +00:00
Vadim B. Mikheev 9a2949e5dd Fix using GroupBy/non-GroupBy expressions in HAVING. 1998-09-09 03:48:17 +00:00
Vadim B. Mikheev 994cfba1e5 Fix GroupBY func broken by HAVING. 1998-09-08 02:50:20 +00:00
Marc G. Fournier 370d6cdb64 From: David Hartwig <daybee@bellatlantic.net>
I put some extra checks to make sure a query was a good candidate for
rewrite into a UNION.    Besides the existing checks:

1.  Make sure the AND/OR tree was rectangular.  ( i.e.    3 X 4  or 10 X
3)
2.  Only one table.
3.  Must have an AND dimension.
4.  At least 9 OP expressions total

Also  cleaned up and commented.
1998-09-04 12:52:23 +00:00
Bruce Momjian b3f8bbb973 Oops missing file. 1998-09-03 05:09:27 +00:00
Bruce Momjian fcecc5ca1e [Part #1: Type: text/plain, Encoding: 7bit, Size: 59]
I will be cleaning this up more before the Oct 1 deadline.

David Hartwig.  AND/OR fix.
1998-09-03 02:34:35 +00:00
Bruce Momjian fa1a8d6a97 OK, folks, here is the pgindent output. 1998-09-01 04:40:42 +00:00
Bruce Momjian af74855a60 Renaming cleanup, no pgindent yet. 1998-09-01 03:29:17 +00:00
Bruce Momjian 24a05f5b3e Fix for regproc 1998-08-31 07:55:50 +00:00
Bruce Momjian 0705b02f18 OR clause index fix 1998-08-31 07:19:56 +00:00
Bruce Momjian 9728ce7499 This is the first (of hopefully few) AIX port patches. This patch
was tested with Linux/GCC.  I still have some issues with with the
snprintf() function.

David Hartwig
1998-08-29 04:09:29 +00:00
Bruce Momjian 648f007fdb I have found a minor problem with current configure.in.
[AC_MSG_RESULT(yes) AC_DEFINE(HAVE_LONG_INT_64)],

this line produces something like:

  echo "$ac_t""yes" 1>&6 cat >> confdefs.h <<\EOF

and would append garbage "yes cat" to confdefs.h. Of course the
result confdefs.h is not syntactically correct therefore following
tests using confdefs.h would all fail.  To avoid the problem, we
could switch the order of AC_MSG_RESULT and AC_DEFINE (see attached
patch). This happend on my LinuxPPC box.


Tatsuo Ishii t-ishii@sra.co.jp
1998-08-24 04:09:39 +00:00
Bruce Momjian 15cb32d93e This is the final state of the rule system for 6.4 after the
patch is applied:

	Rewrite rules on relation level work fine now.

	Event qualifications on insert/update/delete  rules  work
	fine now.

	I  added  the  new  keyword  OLD to reference the CURRENT
	tuple. CURRENT will be removed in 6.5.

	Update rules can  reference  NEW  and  OLD  in  the  rule
	qualification and the actions.

	Insert/update/delete rules on views can be established to
	let them behave like real tables.

	For  insert/update/delete  rules  multiple  actions   are
	supported  now.   The  actions  can also be surrounded by
	parantheses to make psql  happy.   Multiple  actions  are
	required if update to a view requires updates to multiple
	tables.

	Regular users  are  permitted  to  create/drop  rules  on
	tables     they     have     RULE     permissions     for
	(DefineQueryRewrite() is  now  able  to  get  around  the
	access  restrictions  on  pg_rewrite).  This enables view
	creation for regular users too. This  required  an  extra
	boolean  parameter  to  pg_parse_and_plan() that tells to
	set skipAcl on all rangetable entries  of  the  resulting
	queries.       There      is      a      new     function
	pg_exec_query_acl_override()  that  could  be   used   by
	backend utilities to use this facility.

	All rule actions (not only views) inherit the permissions
	of the event relations  owner.  Sample:  User  A  creates
	tables    T1    and    T2,   creates   rules   that   log
	INSERT/UPDATE/DELETE on T1 in T2 (like in the  regression
	tests  for rules I created) and grants ALL but RULE on T1
	to user B.  User B  can  now  fully  access  T1  and  the
	logging  happens  in  T2.  But user B cannot access T2 at
	all, only the rule actions can. And due to  missing  RULE
	permissions on T1, user B cannot disable logging.

	Rules  on  the  attribute  level are disabled (they don't
	work properly and since regular users are  now  permitted
	to create rules I decided to disable them).

	Rules  on  select  must have exactly one action that is a
	select (so select rules must be a view definition).

	UPDATE NEW/OLD rules  are  disabled  (still  broken,  but
	triggers can do it).

	There are two new system views (pg_rule and pg_view) that
	show the definition of the rules or views so the db admin
	can  see  what  the  users do. They use two new functions
	pg_get_ruledef() and pg_get_viewdef() that are  builtins.

	The functions pg_get_ruledef() and pg_get_viewdef() could
	be used to implement rule and view support in pg_dump.

	PostgreSQL is now the only database system I  know,  that
	has rewrite rules on the query level. All others (where I
	found a  rule  statement  at  all)  use  stored  database
	procedures  or  the  like  (triggers as we call them) for
	active rules (as some call them).

    Future of the rule system:

	The now disabled parts  of  the  rule  system  (attribute
	level,  multiple  actions on select and update new stuff)
	require a complete new rewrite handler from scratch.  The
	old one is too badly wired up.

	After  6.4  I'll  start to work on a new rewrite handler,
	that fully supports the attribute level  rules,  multiple
	actions on select and update new.  This will be available
	for 6.5 so we get full rewrite rule capabilities.

Jan
1998-08-24 01:38:11 +00:00
Bruce Momjian 7971539020 heap_fetch requires buffer pointer, must be released; heap_getnext
no longer returns buffer pointer, can be gotten from scan;
	descriptor; bootstrap can create multi-key indexes;
pg_procname index now is multi-key index; oidint2, oidint4, oidname
are gone (must be removed from regression tests); use System Cache
rather than sequential scan in many places; heap_modifytuple no
longer takes buffer parameter; remove unused buffer parameter in
a few other functions; oid8 is not index-able; remove some use of
single-character variable names; cleanup Buffer variables usage
and scan descriptor looping; cleaned up allocation and freeing of
tuples; 18k lines of diff;
1998-08-19 02:04:17 +00:00
Thomas G. Lockhart 4c91723d35 Check for null pointer returned from get_opname().
Don't bother checking for alternate strategies if so
 since it was more likely a function or some other non-operator anyway.
1998-08-16 05:37:04 +00:00
Thomas G. Lockhart 6912beea70 Allow binary-compatible indices to be considered when checking for valid
indices for restriction clauses containing a constant.
Note that if an index does not match directly (usually because the types
 on both side of the clause don't match), and if a binary-compatible index
 is identified, then the operator function will be replaced by a new
 one. Should not be a problem, but be sure that if types are listed as
 being binary compatible (in parse_coerce.h) then the comparison functions
 are also binary-compatible, giving equivalent results.
1998-08-14 16:13:07 +00:00
Bruce Momjian 024d5f74ba index strategy cleanup 1998-08-11 19:32:39 +00:00
Bruce Momjian 956b91a944 Cleanups of optimizer. 1998-08-10 04:49:39 +00:00
Bruce Momjian 2d32d909b5 Cleanup optimizer function names and clarify code. 1998-08-10 02:26:40 +00:00
Bruce Momjian a08dc16c47 New pgindent. 1998-08-09 04:59:10 +00:00
Bruce Momjian 111b80ce00 cleanups. 1998-08-09 04:17:38 +00:00
Bruce Momjian e46df2ff6e OPTIMIZER_DEBUG additions. 1998-08-07 05:02:32 +00:00
Bruce Momjian d9be0ff432 MergeSort was sometimes called mergejoin and was confusing. Now
it is now only mergejoin.
1998-08-04 16:44:31 +00:00
Bruce Momjian c8b42a6151 Update flow chart. 1998-08-04 00:42:14 +00:00
Bruce Momjian b88e9784b6 Cleanup of OR processing. 1998-08-03 05:49:24 +00:00
Bruce Momjian 39844ac2c3 Fix for OR handling with multiple indexes. 1998-08-02 07:10:38 +00:00
Bruce Momjian 2c6b370e64 Cleanup of OR fix. 1998-08-01 22:44:55 +00:00
Bruce Momjian 0a2e5cdfc9 Allow index use with OR clauses. 1998-08-01 22:12:13 +00:00
Vadim B. Mikheev 83d3626b1f Matching clauses to functional indices was broken, now fixed. 1998-07-31 15:10:40 +00:00
Vadim B. Mikheev be8300b18f Use Snapshot in heap access methods. 1998-07-27 19:38:40 +00:00
Bruce Momjian 809fc91fdd Fix HAVING patch missing cast. 1998-07-24 15:54:10 +00:00
Bruce Momjian 128d827d4b I'm sorry, but I think I introduced a little bug with my last patch.
Everyone using an [NOT] EXISTS subquery will have noticed that
already.

The bug is in "subselect.c" in the function "SS_process_sublinks()".

Here the whole function as it *SHOULD BE*:

Stephan
1998-07-24 04:03:10 +00:00
Bruce Momjian 7702d7aa4b target list fixes. 1998-07-20 21:18:35 +00:00
Bruce Momjian 61700b4089 Makefile removal of internal.c. 1998-07-20 20:01:48 +00:00
Bruce Momjian 3dd2eabc53 Cleanup makeTargetEntry and remove internal.c. 1998-07-20 19:53:53 +00:00
Bruce Momjian 97ac8f7ffc Use defines rather than constants for types. 1998-07-20 19:21:45 +00:00
Bruce Momjian 460b20a43f 1) Queries using the having clause on base tables should work well
now. Here some tested features, (examples included in the patch):

1.1) Subselects in the having clause 1.2) Double nested subselects
1.3) Subselects used in the where clause and in the having clause
     simultaneously 1.4) Union Selects using having 1.5) Indexes
on the base relations are used correctly 1.6) Unallowed Queries
are prevented (e.g. qualifications in the
     having clause that belong to the where clause) 1.7) Insert
into as select

2) Queries using the having clause on view relations also work
   but there are some restrictions:

2.1) Create View as Select ... Having ...; using base tables in
the select 2.1.1) The Query rewrite system:

2.1.2) Why are only simple queries allowed against a view from 2.1)
? 2.2) Select ... from testview1, testview2, ... having...; 3) Bug
in ExecMergeJoin ??


Regards Stefan
1998-07-19 05:49:26 +00:00
Bruce Momjian 584f9438ca Rename Rel to RelOptInfo. 1998-07-18 04:22:52 +00:00
Bruce Momjian 9e964f90fb Fix explain for union and inheritance. Rename Append structure
members to be clearer.  Fix cost computation for these.
1998-07-15 14:54:39 +00:00
Bruce Momjian 683f399391 Change atttypmod from int16 to int32, for Thomas. 1998-07-12 21:29:40 +00:00
Bruce Momjian 6bd323c6b3 Remove un-needed braces around single statements. 1998-06-15 19:30:31 +00:00
Bruce Momjian 27db9ecd0b Fix macros that were not properly surrounded by parens or braces. 1998-06-15 18:40:05 +00:00
Bruce Momjian 09baa3cc81 This patch...
1. Removes the unnecessary "#define AbcRegProcedure 123"'s from
pg_proc.h.

2. Changes those #defines to use the names already defined in
fmgr.h.

3. Forces the make of fmgr.h in backend/Makefile instead of having
it
   made as a dependency in access/common/Makefile  *hack*hack*hack*

4. Rearranged the #includes to a less helter-skelter arrangement,
also
    changing <file.h> to "file.h" to signify a non-system header.

5. Removed "pg_proc.h" from files where its only purpose was for
the
   #defines removed in item #1.

6. Added "fmgr.h" to each file changed for completeness sake.

Turns out that #6 was not necessary for some files because fmgr.h
was being included in a roundabout way SIX levels deep by the first
include.

"access/genam.h"
 ->"access/relscan.h"
   ->"utils/rel.h"
     ->"access/strat.h"
       ->"access/skey.h"
	 ->"fmgr.h"

So adding fmgr.h really didn't add anything to the compile, hopefully
just made it clearer to the programmer.

S Darren.
1998-04-27 04:08:07 +00:00
Bruce Momjian 5529b783a8 Move HAVING function to proper file. 1998-04-15 15:29:57 +00:00
Bruce Momjian 8eb08ae6b9 Cleanup up code. 1998-04-13 21:07:15 +00:00
Bruce Momjian 645146260e Cleanup of compiler warnings. 1998-04-06 02:38:26 +00:00
Bruce Momjian 1e801a8f16 Hi,
Attached you'll find a (big) patch that fixes make dep and make
depend in all Makefiles where I found it to be appropriate.

It also removes the dependency in Makefile.global for NAMEDATALEN
and OIDNAMELEN by making backend/catalog/genbki.sh and bin/initdb/initdb.sh
a little smarter.

This no longer requires initdb.sh that is turned into initdb with
a sed script when installing Postgres, hence initdb.sh should be
renamed to initdb (after the patch has been applied :-) )

This patch is against the 6.3 sources, as it took a while to
complete.

Please review and apply,

Cheers,

Jeroen van Vianen
1998-04-06 00:32:26 +00:00
Vadim B. Mikheev bb80f8a918 Fix merging pathes of pruned rels ("indices are unused" problem). 1998-04-02 07:27:15 +00:00
Bruce Momjian 8dc48ba877 Small HAVING cleanup. 1998-03-31 23:31:10 +00:00
Bruce Momjian d7050cb68c Merge rename name page into alter table. Fix UNION with DISTINCT
or ORDER BY bug.
1998-03-31 04:44:35 +00:00
Bruce Momjian 01ecb2e3a0 documentation for HAVING, clean up UNION comment. 1998-03-30 19:05:10 +00:00
Bruce Momjian 9a0dd4fb18 There's a patch attached to fix gcc 2.8.x warnings, except for the
yyerror ones from bison. It also includes a few 'enhancements' to
the C programming style (which are, of course, personal).

The other patch removes the compilation of backend/lib/qsort.c, as
qsort() is a standard function in stdlib.h and can be used any
where else (and it is). It was only used in
backend/optimizer/geqo/geqo_pool.c, backend/optimizer/path/predmig.c,
and backend/storage/page/bufpage.c

> > Some or all of these changes might not be appropriate for v6.3,
since we > > are in beta testing and since they do not affect the
current functionality.  > > For those cases, how about submitting
patches based on the final v6.3 > > release?

There's more to come. Please review these patches. I ran the
regression tests and they only failed where this was expected
(random, geo, etc).

Cheers,

Jeroen
1998-03-30 16:47:35 +00:00
Bruce Momjian c579ce0fb0 I started adding the Having Clause and it works quite fine for
sequential scans! (I think it will also work with hash, index, etc
but I did not check it out! I made some High level changes which
should work for all access methods, but maybe I'm wrong. Please
let me know.)

Now it is possible to make queries like:

select s.sname, max(p.pid), min(p.pid) from part p, supplier s
where s.sid=p.sid group by s.sname having max(pid)=6 and min(pid)=1
or avg(pid)=4;

Having does not work yet for queries that contain a subselect
statement in the Having clause, I'll try to fix this in the next
days.

If there are some bugs, please let me know, I'll start to read the
mailinglists now!

Now here is the patch against the original 6.3 version (no snapshot!!):

Stefan
1998-03-30 16:36:43 +00:00
Bruce Momjian a866d1adef Fix for Datasize = 0 error, from Vadim. 1998-03-16 05:49:32 +00:00
Bruce Momjian 4d72e2b1c6 subselect notes from Vadim. 1998-03-16 05:37:16 +00:00
Bruce Momjian a32450a585 pgindent run before 6.3 release, with Thomas' requested changes. 1998-02-26 04:46:47 +00:00
Vadim B. Mikheev e51c674c59 Support for subselects. 1998-02-13 03:40:23 +00:00
Vadim B. Mikheev 9184073324 Call union_planner() instead of planner(). 1998-02-13 03:39:26 +00:00
Vadim B. Mikheev 4a6e3a6a9f Old planner() becomes union_planner(); new planner() makes initialization
of some global variables to support subselects and calls union_planner().
Calls to SS_replace_correlation_vars() and SS_process_sublinks() in
query_planner() before planning.
Get rid of #ifdef INDEXSCAN_PATCH in createplan.c.
1998-02-13 03:37:04 +00:00
Vadim B. Mikheev a3f1c3673f Quite limited support for subselects in clausesel.c.
Get rid of #ifdef INDEXSCAN_PATCH in indxpath.c.
1998-02-13 03:29:39 +00:00
Bruce Momjian 24cab6bd0d Goodbye register keyword. Compiler knows better. 1998-02-11 19:14:04 +00:00
Bruce Momjian 2c482cdbf2 Pass attypmod through to executor by adding to Var and Resdom. 1998-02-10 04:02:59 +00:00
Bruce Momjian 7f31669bea Add Var.varlevelup to code. More parser cleanup. 1998-01-20 22:12:17 +00:00
Bruce Momjian c65ea0e040 New pg_attribute.atttypmod for type-specific information like
varchar length.

Cleans up code so attlen is always length.

Removed varchar() hack added earlier.

Will fix bug in selecting varchar() fields, and varchar() can be
variable length.
1998-01-16 23:21:07 +00:00
PostgreSQL Daemon baef78d96b Thank god for searchable mail archives.
Patch by: wieck@sapserv.debis.de (Jan Wieck)

   One  of  the design rules of PostgreSQL is extensibility. And
   to follow this rule means (at least for me) that there should
   not  only  be a builtin PL.  Instead I would prefer a defined
   interface for PL implemetations.
1998-01-15 19:46:37 +00:00
Bruce Momjian 763ff8aef8 Remove Query->qry_aggs and qry_numaggs and replace with Query->hasAggs.
Pass List* of Aggregs into executor, and create needed array there.
No longer need to double-processs Aggregs with second copy in Query.

Fix crash when doing:

	select sum(x+1) from test where 1 > 0;
1998-01-15 19:00:16 +00:00
Bruce Momjian f22d8e6668 Function cleanupo for List* when it should be Node *. 1998-01-14 19:55:53 +00:00
Bruce Momjian cb3ce64f2e Cleanup of prototypes. FIx for PQtrace start/stop several times. 1998-01-14 15:48:51 +00:00
Marc G. Fournier 374bb5d261 Some *very* major changes by darrenk@insightdist.com (Darren King)
==========================================
What follows is a set of diffs that cleans up the usage of BLCKSZ.

As a side effect, the person compiling the code can change the
value of BLCKSZ _at_their_own_risk_.  By that, I mean that I've
tried it here at 4096 and 16384 with no ill-effects.  A value
of 4096 _shouldn't_ affect much as far as the kernel/file system
goes, but making it bigger than 8192 can have severe consequences
if you don't know what you're doing.  16394 worked for me, _BUT_
when I went to 32768 and did an initdb, the SCSI driver broke and
the partition that I was running under went to hell in a hand
basket. Had to reboot and do a good bit of fsck'ing to fix things up.

The patch can be safely applied though.  Just leave BLCKSZ = 8192
and everything is as before.  It basically only cleans up all of the
references to BLCKSZ in the code.

If this patch is applied, a comment in the config.h file though above
the BLCKSZ define with warning about monkeying around with it would
be a good idea.

Darren  darrenk@insightdist.com

(Also cleans up some of the #includes in files referencing BLCKSZ.)
==========================================
1998-01-13 04:05:12 +00:00
Bruce Momjian 679d39b9c8 Goodbye ABORT. Hello ERROR for all errors. 1998-01-07 21:07:04 +00:00
Bruce Momjian 9d00fbbeb0 Change some labels in bootparse to make ctags happy. Clean up outfunc/readfunc code and add missing fields for Query structure and new Union fields. Fix optimizer bug shown in new \do command. Change WARN to ERROR in contrib and regression stuff. 1998-01-06 18:53:02 +00:00
Bruce Momjian 0d9fc5afd6 Change elog(WARN) to elog(ERROR) and elog(ABORT). 1998-01-05 03:35:55 +00:00
Bruce Momjian a1dd409053 Fix for ORDER BY in UNION. 1997-12-29 04:31:50 +00:00
Bruce Momjian a01b085c78 Cleanup of UNION ALL fix. Manual page updates. 1997-12-29 01:13:37 +00:00
Bruce Momjian 4ce24c8aa9 UNION work for UNION ALL and other union stuff. 1997-12-27 06:41:41 +00:00
Vadim B. Mikheev d8949adc20 Cleaning GCC warnings. 1997-12-26 06:02:26 +00:00
Bruce Momjian 6231e161c9 Implementation of UNIONs. 1997-12-24 06:06:58 +00:00
Bruce Momjian e4bd9127cb Remove regression in function. 1997-12-23 03:27:23 +00:00
Bruce Momjian d404f1006b Fix for select 1=1 or 2=2, select 1=1 and 2=2, and select sum(2+2). 1997-12-22 05:42:25 +00:00
Bruce Momjian 78a055a659 Remove some recursion in optimizer and clean up some code there. 1997-12-21 05:18:48 +00:00
Bruce Momjian 7fd4782504 Fix aggregates on inherited tables. 1997-12-20 07:59:44 +00:00
Marc G. Fournier 6e337eef45 Major cleanout of PORTNAME variables from Makefiles...bound to screw up
some of the ports...
1997-12-20 00:29:35 +00:00
Marc G. Fournier 5379b84eff More cleanups. I can now compile without PORTNAME being defined n
Makefile.global.

End result, if all goes well, should allow for much easier porting, since
there will no longer be a concept of a "port".  Most, if not everything,
*should* be determined by configure, or by the compiler itself.  Still
work to be done though :)
1997-12-19 02:09:10 +00:00
Bruce Momjian 72c296dffc Remove init_query_planner(), merged into planner(). 1997-12-18 19:41:44 +00:00
Bruce Momjian 6a45941f2f Remove Existential, and ifdef out generate_fjoin. Neither did anything. 1997-12-18 12:54:45 +00:00
Bruce Momjian 4469eb63a3 Cost cleanup. 1997-12-18 12:30:44 +00:00
Bruce Momjian d3f0e87d17 Cost cleanup. 1997-12-18 12:21:02 +00:00
Bruce Momjian c64cc3228a Fix Query handling for inheritance, and cost computations. 1997-12-18 03:03:41 +00:00
Bruce Momjian d158fce8eb Add optimizer README file. 1997-12-17 18:02:33 +00:00
Bruce Momjian c60f70b53f Rename pg_plan and pg_eval to be more meaningful. 1997-12-11 17:36:58 +00:00
Bruce Momjian 4a5b781d71 Break parser functions into smaller files, group together. 1997-11-25 22:07:18 +00:00
Bruce Momjian 3fa2bb316c Remove archive stuff. 1997-11-21 18:12:58 +00:00
Bruce Momjian e9e1ff226f Remove all time travel stuff. Small parser cleanup. 1997-11-20 23:24:03 +00:00
Vadim B. Mikheev 6be30fb524 Fix handling of functions with non-attribute first argument in WHERE
clauses.
1997-09-25 12:48:15 +00:00
Vadim B. Mikheev c42f7f1460 Fix GROUP BY when order of entries is different from order in target list. 1997-09-25 12:21:15 +00:00
Bruce Momjian 3f365ba0fc Inline memset() as MemSet(). 1997-09-18 20:22:58 +00:00
Bruce Momjian 59f6a57e59 Used modified version of indent that understands over 100 typedefs. 1997-09-08 21:56:23 +00:00
Bruce Momjian 075cede748 Add typdefs to pgindent run. 1997-09-08 20:59:27 +00:00
Bruce Momjian 319dbfa736 Another PGINDENT run that changes variable indenting and case label indenting. Also static variable indenting. 1997-09-08 02:41:22 +00:00
Bruce Momjian 1ccd423235 Massive commit to run PGINDENT on all *.c and *.h files. 1997-09-07 05:04:48 +00:00
Bruce Momjian ec05063be0 Cleanups needed for indent. 1997-09-05 20:20:56 +00:00
Bruce Momjian 240a018176 Cleanups needed for indent. 1997-09-05 19:59:11 +00:00
Bruce Momjian ae50c8d84b Cleanups needed for indent. 1997-09-05 19:32:44 +00:00
Bruce Momjian a1635450b3 Cleanups needed for indent. Remove }; 1997-09-05 18:13:45 +00:00
Bruce Momjian 11ac1bf268 More NOT_USEDs 1997-08-20 14:54:35 +00:00
Bruce Momjian 1d8bbfd2e7 Make functions static where possible, enclose unused functions in #ifdef NOT_USED. 1997-08-19 21:40:56 +00:00
Bruce Momjian 022903f22e Reduce open() calls. Replace fopen() calls with calls to fd.c functions. 1997-08-18 02:15:04 +00:00
Bruce Momjian ea5b5357cd Remove more (void) and fix -Wall warnings. 1997-08-12 22:55:25 +00:00
Bruce Momjian 3ac9d2fff3 Various compile errors concerning overflow due to shifts, unsigned, and bad prototypes, from Solaris, from Diab Jerius 1997-07-24 20:19:10 +00:00
Vadim B. Mikheev 0f576413bc Fix replace_agg_clause() for unary operators. 1997-06-12 17:26:15 +00:00
Vadim B. Mikheev dee872de5c geqo_rel_paths(): compute_joinrel_size() shouldn't be called
for non-JoinPath path! So now we have:
    if ( IsA_JoinPath (cheapest) )
        rel->size = compute_joinrel_size(cheapest);
1997-06-11 02:44:12 +00:00
Marc G. Fournier 90d0cf0000 From: Robert Bruccoleri <bruc@bms.com>
Subject: [PORTS] Patches for Irix 6.4

I have worked out how to compile PostgreSQL on Irix 6.4 using the -n32 compiler
mode and version 7.1 of the C compiler. (The n32 compiler use 32 bits
addressing,
but allows access to all the instructions in the MIPS4 instruction set.)
There were several problems:

1) The ld command is not referenced as a macro in all the Makefiles. On
this platform, you have to include -n32 on all the ld commands. Makefiles
were changed as needed.

3) Lots of warnings are generated from the compiler. Since the regression
tests worked OK, I didn't attempt to fix them. If anyone wants the compilation
log, please let me know, and I'll email it to you.

The version of postgresql was 970602. Here is Makefile.custom:

CUSTOM_COPT = -O2 -n32
MK_NO_LORDER = 1
LD = ld -n32
CC += -n32
1997-06-11 01:13:10 +00:00
Vadim B. Mikheev f4161503e6 if ( rel->size <= 0 )
rel->size = compute_rel_size(rel);
1997-06-10 07:55:47 +00:00
Vadim B. Mikheev cbb4213af4 if ( new_rel->size <= 0 )
new_rel->size = compute_rel_size(new_rel);
1997-06-10 07:53:55 +00:00
Vadim B. Mikheev e3d2f1f35d gimme_tree(): got rid of compute_rel_size() -
compute_joinrel_size already called by geqo_rel_paths.
1997-06-06 03:18:02 +00:00
Marc G. Fournier c0178f27a2 From: "D'Arcy J.M. Cain" <darcy@druid.net>
Subject: [HACKERS] src.original/./backend/lib/fstack.c

Another change I suggested.  I bracket an unused function and add a
return to quiet the compiler.  In addition I added an internal
consistency check.
1997-06-06 00:38:17 +00:00
Marc G. Fournier f50b103ce1 From: "D'Arcy J.M. Cain" <darcy@druid.net>
Subject: [HACKERS] backend/optimizer/geqo/geqo_erx.c

I sent these changes in with a bunch of others.  Some were folded in but
others, like these, were not.  I am not sure why so I am resending this
to the developers list by itself for discussion.

The readon why I suggest these changes is that the compiler can't tell
that minimum_count is initialized before it is used.  The tests that I
add in here will cause an immediate error if it doesn't.  As the comments
below suggest, if it is 100% guaranteed that the variable will always
be initialized then how this is so should be commented here.  I don't
know how much strain the actual test puts on the performance but if it
isn't too much then maybe leave it in for absolute safety anyway.

There are also a few returns just to stop warnings.
1997-06-06 00:37:23 +00:00
Vadim B. Mikheev 11073bee5c allpaths.c:find_join_paths(): compute_rel_size() shouldn't be called
for join-relations. Sizes already computed by
prune_rel_paths():compute_joinrel_size().

joinrels.c:
<                   if ( _use_right_sided_plans_ )
---
>                   if ( _use_right_sided_plans_ &&
>                               length (outer_rel->relids) > 1 )

 - r_plans are useful when outer_rel is join-relation... It
decreases the size of search space...
1997-06-05 09:33:52 +00:00
Vadim B. Mikheev 05404562fb Use GEQO if _use_geqo_ is TRUE and # of relations is >= _use_geqo_rels_
(both are settable via SET geqo TO ...).
1997-06-02 11:14:40 +00:00
Bruce Momjian 8bc7439ccf Enable GEQO for more than six tables, from Martin. 1997-06-01 02:56:00 +00:00
Vadim B. Mikheev 4a8c3dddc3 Consider right-sided plans if _use_right_sided_plans_ is true. 1997-05-20 10:37:26 +00:00
Vadim B. Mikheev a4792bd3d6 #ifdef GEQO
bool _use_geqo_ = true;
#else
bool _use_geqo_ = false;
#endif

_use_geqo_ is settable via SET var TO ...
1997-04-29 04:37:22 +00:00
Vadim B. Mikheev a1fbd470a9 Fix GroupBy: enable functions over aggregates and GroupBy-ed fields
in target list.
1997-04-29 04:32:50 +00:00
Vadim B. Mikheev 67712200f1 * Hack for non-functional btree npages estimation:
* npages = index_pages * selectivity_of_1st_attr_clause(s)
1997-04-24 16:07:14 +00:00
Vadim B. Mikheev 72d271177c Have to copyObject((void*)clauseinfo) for a relation'
joininfo (in add_join_clause_info_to_rels()) : clause may be
commutted later.
1997-04-24 16:04:23 +00:00
Vadim B. Mikheev e349eb6e2c Bug (yet unfixed but not fatal) found: Re-moving index clauses from the
nestloop's join clauses doesn't work in some cases:
         *    1. fix_indxqual_references may change varattno-s in
         *       inner_indxqual;
         *    2. clauses may be commuted
1997-04-24 15:59:58 +00:00
Vadim B. Mikheev a1ac1989cf Save Var' order in index_outerjoin_references(). 1997-04-24 15:54:52 +00:00
Vadim B. Mikheev 4ec8a148ed Add innercost to result in cost_hashjoin. 1997-04-24 15:49:30 +00:00
Vadim B. Mikheev 051b4210e3 Fix for Hash and arrays 1997-04-22 03:32:38 +00:00
Vadim B. Mikheev f3054b24c2 Fix for -Wno-error 1997-04-21 04:26:47 +00:00
Marc G. Fournier 953ac7b55a Fix up the -Wno-error problem for non-gcc compilers
Pointed out by many many ppl
1997-04-15 17:24:26 +00:00
Marc G. Fournier 1c688d1bbe From: "Martin S. Utesch" <utesch@aut.tu-freiberg.de>
Subject: Re: [HACKERS] GEQO and views (rules)


Oke, this was caused by a classic bug :-/
I thougth, root->base_relation_list_ could be
represented as relid string 1-2-3-4- etc.

Instead, in case of views, the count of relids doesn't start with "1" but
maybe 4-5-6- etc . :-(

GEQO patch follows ... views are now all right.
1997-04-09 08:31:29 +00:00
Vadim B. Mikheev 610d0d00ed 1. Enable to have different _CPU_PAGE_WEIGHT_ for heap and index.
2. PageWeights are variables now.
3. Fixed using ceil((double)selec*indextuples) as estimation
for expected heap pages: ceil((double)selec*relpages) now.
1997-04-09 02:13:41 +00:00
Vadim B. Mikheev fa2629b7ea Fix (hack) IndexSelectivity():
use sum(npages)/((nkeys == 1) ? 1 : nkeys + 1) as expected index page
estimation for multi-key quals - instead of sum(npages).
In old code npages for x > 10 and x < 20 is twice as for x > 10 - cool ?
1997-04-09 01:52:04 +00:00
Vadim B. Mikheev d12e27a5f3 Changes for GROUP BY func_results:
AddGroupAttrToTlist() is not called from anywhere now.
1997-04-05 06:39:58 +00:00
Vadim B. Mikheev c50d8474d3 Changes for GROUP BY func_results. 1997-04-05 06:37:37 +00:00
Marc G. Fournier c7b40e6058 This commit represents a clean compile with the new templates under
FreeBSD

The Makefile(s) have all been cleaned up such that there is a single
LDFLAGS vs LD_ADD or LDADD or LDFLAGS or LDFLAGS_BE.  The Makefile(s)
should be alot more straightforward then they were before...and
consistent
1997-04-04 10:43:16 +00:00