Commit Graph

67 Commits

Author SHA1 Message Date
Tom Lane 6c1d4662af Finish implementation of hashed aggregation. Add enable_hashagg GUC
parameter to allow it to be forced off for comparison purposes.
Add ORDER BY clauses to a bunch of regression test queries that will
otherwise produce randomly-ordered output in the new regime.
2002-11-21 00:42:20 +00:00
Tom Lane c1f91a38e2 Fix rewrite code so that rules are in fact executed in order by name,
rather than being reordered according to INSTEAD attribute for
implementation convenience.
Also, increase compiled-in recursion depth limit from 10 to 100 rewrite
cycles.  10 seems pretty marginal for situations where multiple rules
exist for the same query.  There was a complaint about this recently,
so I'm going to bump it up.  (Perhaps we should make the limit a GUC
parameter, but that's too close to being a new feature to do in beta.)
2002-10-19 19:00:47 +00:00
Tom Lane 4a0c3a6142 Department of second thoughts: suppressing implicit casts everywhere in
ruleutils display is not such a great idea.  For arguments of functions
and operators I think we'd better keep the historical behavior of showing
such casts explicitly, to ensure that the function/operator is reparsed
the same way when the rule is reloaded.  This also makes the output of
EXPLAIN less obscurantist about exactly what's happening.
2002-09-19 22:48:34 +00:00
Tom Lane b26dfb9522 Extend pg_cast castimplicit column to a three-way value; this allows us
to be flexible about assignment casts without introducing ambiguity in
operator/function resolution.  Introduce a well-defined promotion hierarchy
for numeric datatypes (int2->int4->int8->numeric->float4->float8).
Change make_const to initially label numeric literals as int4, int8, or
numeric (never float8 anymore).
Explicitly mark Func and RelabelType nodes to indicate whether they came
from a function call, explicit cast, or implicit cast; use this to do
reverse-listing more accurately and without so many heuristics.
Explicit casts to char, varchar, bit, varbit will truncate or pad without
raising an error (the pre-7.2 behavior), while assigning to a column without
any explicit cast will still raise an error for wrong-length data like 7.3.
This more nearly follows the SQL spec than 7.2 behavior (we should be
reporting a 'completion condition' in the explicit-cast cases, but we have
no mechanism for that, so just do silent truncation).
Fix some problems with enforcement of typmod for array elements;
it didn't work at all in 'UPDATE ... SET array[n] = foo', for example.
Provide a generalized array_length_coerce() function to replace the
specialized per-array-type functions that used to be needed (and were
missing for NUMERIC as well as all the datetime types).
Add missing conversions int8<->float4, text<->numeric, oid<->int8.
initdb forced.
2002-09-18 21:35:25 +00:00
Bruce Momjian ed7f780016 Fix ordering regression problem on freebsd/alpha by adding ORDER BY. 2002-09-02 05:20:56 +00:00
Tom Lane 248c67d7ed CREATE OR REPLACE VIEW, CREATE OR REPLACE RULE.
Gavin Sherry, Neil Conway, and Tom Lane all got their hands dirty
on this one ...
2002-09-02 02:13:02 +00:00
Tom Lane 1bab464eb4 Code review for pg_locks feature. Make shmemoffset of PROCLOCK structs
available (else there's no way to interpret the list links).  Change
pg_locks view to show transaction ID locks separately from ordinary
relation locks.  Avoid showing N duplicate rows when the same lock is
held multiple times (seems unlikely that users care about exact hold
count).  Improve documentation.
2002-08-31 17:14:28 +00:00
Tom Lane 8a24a55c81 Fix ruleutils to dump column definition lists for anonymous record types
defined in the FROM clause.  From Joe Conway, with some tweaks.
2002-08-29 01:19:41 +00:00
Bruce Momjian ec11403023 Make change for pg_locks table. 2002-08-27 18:06:00 +00:00
Peter Eisentraut c828ec8820 Make pg_dump output more portable and more pleasing to look at.
The -n and -N options were removed.  Quoting is now smart enough to
supply quotes if and only if necessary.

Numerical types are now printed without quotes, except in cases of
special values such as NaN.

Boolean values printed as true and false.

Most string literals now do not escape whitespace characters (newlines,
etc.) for portability.

SET SESSION AUTHORIZATION argument is a string literal, to follow SQL.

Made commands output by pg_dump use consistent spacing and indentation.
2002-08-18 09:36:26 +00:00
Bruce Momjian 82119a696e [ Newest version of patch applied.]
This patch is an updated version of the lock listing patch. I've made
the following changes:

    - write documentation
    - wrap the SRF in a view called 'pg_locks': all user-level
      access should be done through this view
    - re-diff against latest CVS

One thing I chose not to do is adapt the SRF to use the anonymous
composite type code from Joe Conway. I'll probably do that eventually,
but I'm not really convinced it's a significantly cleaner way to
bootstrap SRF builtins than the method this patch uses (of course, it
has other uses...)

Neil Conway
2002-08-17 13:04:19 +00:00
Bruce Momjian 45e2544584 As discussed on several occasions previously, the new anonymous
composite type capability makes it possible to create a system view
based on a table function in a way that is hopefully palatable to
everyone. The attached patch takes advantage of this, moving
show_all_settings() from contrib/tablefunc into the backend (renamed
all_settings(). It is defined as a builtin returning type RECORD. During
initdb a system view is created to expose the same information presently
available through SHOW ALL. For example:

test=# select * from pg_settings where name like '%debug%';
          name          | setting
-----------------------+---------
  debug_assertions      | on
  debug_pretty_print    | off
  debug_print_parse     | off
  debug_print_plan      | off
  debug_print_query     | off
  debug_print_rewritten | off
  wal_debug             | 0
(7 rows)


Additionally during initdb two rules are created which make it possible
to change settings by updating the system view -- a "virtual table" as
Tom put it. Here's an example:

Joe Conway
2002-08-15 02:51:27 +00:00
Tom Lane 3b78826bb5 Make the standard system views schema-aware.
I did not force an initdb via catversion ... but the rules
regression test will fail until you do an initdb.
2002-08-08 19:39:05 +00:00
Peter Eisentraut 739adf32ee Remove unused system table columns:
pg_language.lancompiler
pg_operator.oprprec
pg_operator.oprisleft
pg_proc.proimplicit
pg_proc.probyte_pct
pg_proc.properbyte_cpu
pg_proc.propercall_cpu
pg_proc.prooutin_ratio
pg_shadow.usetrace
pg_type.typprtlen
pg_type.typreceive
pg_type.typsend

Attempts to use the obsoleted attributes of pg_operator or pg_proc
in the CREATE commands will be greeted by a warning.  For pg_type,
there is no warning (yet) because pg_dump scripts still contain these
attributes.

Also remove new but already obsolete spellings
isVolatile, isStable, isImmutable in WITH clause.  (Use new syntax
instead.)
2002-07-24 19:11:14 +00:00
Tom Lane 53cedcac22 Retire xlateSqlType/xlateSqlFunc; all type name translations are now
handled as special productions.  This is needed to keep us honest about
user-schema type names that happen to coincide with system type names.
Per pghackers discussion 24-Apr.  To avoid bloating the keyword list
too much, I removed the translations for datetime, timespan, and lztext,
all of which were slated for destruction several versions back anyway.
2002-05-03 00:32:19 +00:00
Tom Lane 25dfba3954 Make ruleutils.c use format_type for printing typenames. Minor tweaks
in quoting rules and recognition of implicit type coercions.
2002-04-28 00:49:13 +00:00
Tom Lane 6d6ca2166c Change naming rule for ON SELECT rules of views: they're all just
_RETURN now, since there's no need to keep 'em unique anymore.
2002-04-19 23:13:54 +00:00
Tom Lane b3120804ad Rule names are now unique per-relation, rather than unique globally.
DROP RULE and COMMENT ON RULE syntax adds an 'ON tablename' clause,
similar to TRIGGER syntaxes.  To allow loading of existing pg_dump
files containing COMMENT ON RULE, the COMMENT code will still accept
the old syntax --- but only if the target rulename is unique across
the whole database.
2002-04-18 20:01:11 +00:00
Tom Lane 902a6a0a4b Restructure representation of aggregate functions so that they have pg_proc
entries, per pghackers discussion.  This fixes aggregates to live in
namespaces, and also simplifies/speeds up lookup in parse_func.c.
Also, add a 'proimplicit' flag to pg_proc that controls whether a type
coercion function may be invoked implicitly, or only explicitly.  The
current settings of these flags are more permissive than I would like,
but we will need to debate and refine the behavior; for now, I avoided
breaking regression tests as much as I could.
2002-04-11 20:00:18 +00:00
Tom Lane 95ef6a3448 First phase of SCHEMA changes, concentrating on fixing the grammar and
the parsetree representation.  As yet we don't *do* anything with schema
names, just drop 'em on the floor; but you can enter schema-compatible
command syntax, and there's even a primitive CREATE SCHEMA command.
No doc updates yet, except to note that you can now extract a field
from a function-returning-row's result with (foo(...)).fieldname.
2002-03-21 16:02:16 +00:00
Peter Eisentraut 1aac2c852a User and database-specific session defaults for run-time configuration
variables.  New commands ALTER DATABASE ... SET and ALTER USER ... SET.
2002-03-01 22:45:19 +00:00
Tom Lane 70e6003c76 Use LEFT JOIN, not FULL JOIN, in statistical views. 2001-10-16 20:51:35 +00:00
Tom Lane 6fdf7bed60 Fixes for datetime-related regress tests, from Tom Lockhart. 2001-09-29 15:17:42 +00:00
Thomas G. Lockhart 1f075a32ee Add separate regression tests for timetz and the new timestamptz type.
Modify the timestamp test to reflect the "no time zone" behavior of this
 new code; timestamptz resembles the old timestamp code.
2001-09-28 08:00:11 +00:00
Tom Lane d4f4b971a4 Sequences are now based on int8, not int4, arithmetic. SERIAL pseudo-type
has an alias SERIAL4 and a sister SERIAL8.  SERIAL8 is just the same
except the created column is type int8 not int4.
initdb forced.  Note this also breaks any chance of pg_upgrade from 7.1,
unless we hack up pg_upgrade to drop and recreate sequences.  (Which is
not out of the question, but I don't wanna do it.)
2001-08-16 20:38:56 +00:00
Tom Lane 5f7c2bdb53 sum() on int2 and int4 columns now uses an int8, not numeric, accumulator
for speed reasons; its result type also changes to int8.  avg() on these
datatypes now accumulates the running sum in int8 for speed; but we still
deliver the final result as numeric, so that fractional accuracy is
preserved.

count() now counts and returns in int8, not int4.  I am a little nervous
about this possibly breaking users' code, but there didn't seem to be
a strong sentiment for avoiding the problem.  If we get complaints during
beta, we can change count back to int4 and add a "count8" aggregate.
For that matter, users can do it for themselves with a simple CREATE
AGGREGATE command; the int4inc function is still present, so no C hacking
is needed.

Also added max() and min() aggregates for OID that do proper unsigned
comparison, instead of piggybacking on int4 aggregates.

initdb forced.
2001-08-14 22:21:59 +00:00
Tom Lane bf56f0759b Make OIDs optional, per discussions in pghackers. WITH OIDS is still the
default, but OIDS are removed from many system catalogs that don't need them.
Some interesting side effects: TOAST pointers are 20 bytes not 32 now;
pg_description has a three-column key instead of one.

Bugs fixed in passing: BINARY cursors work again; pg_class.relhaspkey
has some usefulness; pg_dump dumps comments on indexes, rules, and
triggers in a valid order.

initdb forced.
2001-08-10 18:57:42 +00:00
Tom Lane cb052e0bf1 Fix rule rewriter so that new ordering of ON INSERT actions applies
in cases of qualified rules as well as unqualified ones.  Tweak rules
test to avoid cluttering output with dummy SELECT results.  Update
documentation to match code.
2001-07-09 23:50:32 +00:00
Jan Wieck 8d80b0d980 Statistical system views (yet without the config stuff, but
it's hard to keep such massive changes in sync with the tree
so I need to get it in and work from there now).

Jan
2001-06-22 19:16:24 +00:00
Tom Lane 16ea152b7e Revoke public read access from pg_statistic, create new system view
pg_stats to provide controlled (and, hopefully, more readable) access
to statistics.  Comments on definition of pg_stats welcome.
I didn't force initdb, but the rules regress test will fail until you
do one.
2001-06-14 19:47:25 +00:00
Tom Lane 5ce8ab96f5 Add regress test case for INSERT ... SELECT in rules. 2000-12-05 19:15:49 +00:00
Tom Lane fdbd6ca75e Simplify definition of pg_tables and pg_views views by making use of
new separate relkind for views (per some discussion back in September).
I didn't force initdb, but rules regress test will show differences
until you do one.
2000-11-21 01:11:50 +00:00
Tom Lane d8e582e236 Revert rules.out to non-broken state. I will with difficulty hold my
tongue about the sloppiness of (a) submitting and (b) committing this
file.
2000-10-08 02:51:50 +00:00
Bruce Momjian 7ea8403c8a The beos port in the source tree doesn't even compile. and even
after that dynamic loading isn't working and shared memory handling is
broken.

        Attached with this message, there is a Zip file which contain :

        * beos.diff = patch file generated with difforig
        * beos = folder with beos support files which need to be moved in /
src/backend/port
        * expected = foler with three file for message and precision
difference in regression test
        * regression.diff = rule problem (need to kill the backend manualy)
        * dynloader = dynloader files (they are also in the pacth files,
but there is so much modification that I have join full files)

        Everything works except a problem in 'rules' Is there some problems
with rules in the current tree ? It used to works with last week tree.

Cyril VELTER
2000-10-07 14:39:21 +00:00
Peter Eisentraut 457ac0331c Implement differentiation between CURRENT_USER and SESSION_USER as per SQL.
There is still no effective difference but it will kick in once setuid
functions exist (not included here).  Make old getpgusername() alias for
current_user.
2000-09-19 18:18:04 +00:00
Tom Lane ed5003c584 First cut at full support for OUTER JOINs. There are still a few loose
ends to clean up (see my message of same date to pghackers), but mostly
it works.  INITDB REQUIRED!
2000-09-12 21:07:18 +00:00
Bruce Momjian 332f0f5fc0 Rename rule CURRENT to OLD in source tree. Add mapping for backward
compatiblity with old rules.
2000-06-12 19:40:58 +00:00
Tom Lane 2ae20ef98a Update regression tests for ONLY and other recent changes. 2000-06-10 05:19:26 +00:00
Tom Lane a95eec6792 Add a regress test case for SELECT count(*) FROM view, so that we'll
know if that case ever breaks again...
2000-04-20 00:32:57 +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 e1a95def8b Quick hack solution so that pg_dump of views works. Needs repair after
Thomas gets back, but better this than nonfunctional pg_dump in the beta.
2000-02-21 20:18:11 +00:00
Tom Lane ee97d103cc To avoid confusion during early beta testing, commit the current rules
test output as expected output.  We'll probably want to change this again
after something's done about the verbosity of column alias display.
2000-02-21 18:42:35 +00:00
Tom Lane 260b6afc79 Update remaining tests for new psql, with the exception of 'arrays',
which is broken in some weird way that I don't understand.  I think it
may be exposing a bug in the new psql --- for one thing, I get different
results when I run psql by hand than the regress script gets.  What
the heck???
2000-01-09 03:48:39 +00:00
Jan Wieck e2aef49694 Added empty TOASTER files and corrected some minor glitches
in regression tests.

Jan
1999-12-21 00:06:44 +00:00
Tom Lane a8ae19ec3d aggregate(DISTINCT ...) works, per SQL spec.
Note this forces initdb because of change of Aggref node in stored rules.
1999-12-13 01:27:21 +00:00
Tom Lane 1891f0e913 Update rules test for extra quoting in rule deparser. 1999-12-06 02:38:56 +00:00
Tom Lane 3eb1c82277 Fix planner and rewriter to follow SQL semantics for tables that are
mentioned in FROM but not elsewhere in the query: such tables should be
joined over anyway.  Aside from being more standards-compliant, this allows
removal of some very ugly hacks for COUNT(*) processing.  Also, allow
HAVING clause without aggregate functions, since SQL does.  Clean up
CREATE RULE statement-list syntax the same way Bruce just fixed the
main stmtmulti production.
CAUTION: addition of a field to RangeTblEntry nodes breaks stored rules;
you will have to initdb if you have any rules.
1999-10-07 04:23:24 +00:00
Tom Lane 0655b1500f Less noisy rule display... 1999-10-04 04:38:46 +00:00
Tom Lane b40ac42efb Teach parse_coerce about non-cachable functions (actually,
make it call eval_const_expressions() so that it doesn't have to know).
1999-10-02 23:29:19 +00:00
Tom Lane cd243d27ce Revise rule-printing routines to use expandable StringInfo buffers, so that
they have no hardwired limit on the length of a rule's text.  Fix a couple
of minor bugs in passing --- deparsed UPDATE queries didn't have quotes
around relation name, and quotes and backslashes in constant values weren't
backslash-quoted.
1999-10-02 01:08:05 +00:00