Commit Graph

475 Commits

Author SHA1 Message Date
Tom Lane c328b6dd8b Replace pg_attribute.attisinherited with attislocal and attinhcount
columns, to allow more correct behavior in multiple-inheritance cases.
Patch by Alvaro Herrera, review by Tom Lane.
2002-09-22 19:42:52 +00:00
Tom Lane 9946b83ded Bring SIMILAR TO and SUBSTRING into some semblance of conformance with
the SQL99 standard.  (I'm not sure that the character-class features are
quite right, but that can be fixed later.)  Document SQL99 and POSIX
regexps as being different features; provide variants of SUBSTRING for
each.
2002-09-22 17:27:25 +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
Tom Lane 6fe27ca2fb Fix some operator-precedence problems. New constructs IS DISTINCT FRM
and IS [NOT] OF were not being parsed consistently with other IS forms.
Also, make the world a little safer for functions named LEFT, RIGHT, etc.
2002-09-05 22:52:48 +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 64505ed58b Code review for standalone composite types, query-specified composite
types, SRFs.  Not happy with memory management yet, but I'll commit these
other changes.
2002-08-29 00:17:06 +00:00
Bruce Momjian 81dfa2ce43 backend where a statically sized buffer is written to. Most of these
should be pretty safe in practice, but it's probably better to be safe
than sorry.

I was actually looking for cases where NAMEDATALEN is assumed to be
32, but only found one. That's fixed too, as well as a few bits of
code cleanup.

Neil Conway
2002-08-28 20:46:24 +00:00
Bruce Momjian 6077db92c2 Allow FOR UPDATE to appear after LIMIT/OFFSET to match MySQL syntax and as
a more logical ordering.
2002-08-28 14:35:37 +00:00
Tom Lane 28e82066a1 PREPARE/EXECUTE statements. Patch by Neil Conway, some kibitzing
from Tom Lane.
2002-08-27 04:55:12 +00:00
Tom Lane 6ebc90b045 Remove Ident nodetype in favor of using String nodes; this fixes some
latent wrong-struct-type bugs and makes the coding style more uniform,
since the majority of places working with lists of column names were
already using Strings not Idents.  While at it, remove vestigial
support for Stream node type, and otherwise-unreferenced nodes.h entries
for T_TupleCount and T_BaseNode.
NB: full recompile is recommended due to changes of Node type numbers.
This shouldn't force an initdb though.
2002-08-19 15:08:47 +00:00
Bruce Momjian b1a5f87209 Tom Lane wrote:
> There's no longer a separate call to heap_storage_create in that routine
> --- the right place to make the test is now in the storage_create
> boolean parameter being passed to heap_create.  A simple change, but
> it passeth patch's understanding ...

Thanks.

Attached is a patch against cvs tip as of 8:30 PM PST or so. Turned out
that even after fixing the failed hunks, there was a new spot in
bufmgr.c which needed to be fixed (related to temp relations;
RelationUpdateNumberOfBlocks). But thankfully the regression test code
caught it :-)

Joe Conway
2002-08-15 16:36:08 +00:00
Tom Lane a5e6e99357 Allow schema-qualified operator names to be used in the optional
arguments of CREATE OPERATOR.
2002-08-10 19:01:53 +00:00
Tatsuo Ishii 6206a880cf Add SQL99 CONVERT() function. 2002-08-06 05:40:47 +00:00
Tom Lane 07f9682de4 Preliminary code review for anonymous-composite-types patch: fix breakage
of functions returning domain types, update documentation for typtype,
move get_typtype to lsyscache.c (actually, resurrect the old version),
add defense against creating pseudo-typed table columns, fix some
bogus list-parsing in grammar.  Issues remain with respect to alias
handling and type checking; Joe is on those.
2002-08-05 02:30:50 +00:00
Bruce Momjian 9218689b69 Attached are two patches to implement and document anonymous composite
types for Table Functions, as previously proposed on HACKERS. Here is a
brief explanation:

1. Creates a new pg_type typtype: 'p' for pseudo type (currently either
     'b' for base or 'c' for catalog, i.e. a class).

2. Creates new builtin type of typtype='p' named RECORD. This is the
     first of potentially several pseudo types.

3. Modify FROM clause grammer to accept:
     SELECT * FROM my_func() AS m(colname1 type1, colname2 type1, ...)
     where m is the table alias, colname1, etc are the column names, and
     type1, etc are the column types.

4. When typtype == 'p' and the function return type is RECORD, a list
     of column defs is required, and when typtype != 'p', it is
disallowed.

5. A check was added to ensure that the tupdesc provide via the parser
     and the actual return tupdesc match in number and type of
attributes.

When creating a function you can do:
     CREATE FUNCTION foo(text) RETURNS setof RECORD ...

When using it you can do:
     SELECT * from foo(sqlstmt) AS (f1 int, f2 text, f3 timestamp)
       or
     SELECT * from foo(sqlstmt) AS f(f1 int, f2 text, f3 timestamp)
       or
     SELECT * from foo(sqlstmt) f(f1 int, f2 text, f3 timestamp)

Included in the patches are adjustments to the regression test sql and
expected files, and documentation.

p.s.
     This potentially solves (or at least improves) the issue of builtin
     Table Functions. They can be bootstrapped as returning RECORD, and
     we can wrap system views around them with properly specified column
     defs. For example:

     CREATE VIEW pg_settings AS
       SELECT s.name, s.setting
       FROM show_all_settings()AS s(name text, setting text);

     Then we can also add the UPDATE RULE that I previously posted to
     pg_settings, and have pg_settings act like a virtual table, allowing
     settings to be queried and set.


Joe Conway
2002-08-04 19:48:11 +00:00
Thomas G. Lockhart eb121ba2cf Implement IS OF and IS NOT OF type predicate.
Can now do queries of the form: SELECT value IS OF (integer, float8);
Define macros for handling typmod manipulation for date/time types.
 Should be more robust than all of that brute-force inline code.
Rename macros for masking and typmod manipulation to put TIMESTAMP_
 or INTERVAL_ in front of the macro name, to reduce the possibility
 of name space collisions.
Allow bit string constants without fully-specified length declaration.
Try implementing CREATE TABLE/OF as a mapping to inheritance.
 May be appropriate, or may be replace later with something more exactly
 like one might expect from databases without the feature.
2002-08-04 06:51:23 +00:00
Bruce Momjian 19e0e35bcd The attached patch implements START TRANSACTION, per SQL99. The
functionality of the command is basically identical to that of
BEGIN; it just accepts a few extra options (only one of which
PostgreSQL currently implements), and is standards-compliant.
The patch includes a simple regression test and documentation.

[ Regression tests removed, per Peter.]

Neil Conway
2002-08-04 04:31:44 +00:00
Tom Lane ce7565ab91 Instead of having a configure-time DEFAULT_ATTSTATTARGET, store -1 in
attstattarget to indicate 'use the default'.  The default is now a GUC
variable default_statistics_target, and so may be changed on the fly.  Along
the way we gain the ability to have pg_dump dump the per-column statistics
target when it's not the default.  Patch by Neil Conway, with some kibitzing
from Tom Lane.
2002-07-31 17:19:54 +00:00
Bruce Momjian 6e9893047e The attached patch removes the last remnants of support for
'tioga recipes', whatever those are -- Peter E. killed most
of it a couple days ago, but this patch removes the rest. Most
of it was #ifdef'ed out anyway.

Neil Conway
2002-07-30 16:55:45 +00:00
Tom Lane ea4686e3e1 Implement CREATE/DROP OPERATOR CLASS. Work still remains: need more
documentation (xindex.sgml should be rewritten), need to teach pg_dump
about it, need to update contrib modules that currently build pg_opclass
entries by hand.  Original patch by Bill Studenmund, grammar adjustments
and general update for 7.3 by Tom Lane.
2002-07-29 22:14:11 +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
Bruce Momjian b34cbe006f The attached patch fixes 2 trivial warnings generated by bison 1.35,
as a result of Peter's recent CREATE CAST changes.

Neil Conway
2002-07-20 05:58:34 +00:00
Peter Eisentraut 97377048b4 pg_cast table, and standards-compliant CREATE/DROP CAST commands, plus
extension to create binary compatible casts.  Includes dependency tracking
as well.

pg_proc.proimplicit is now defunct, but will be removed in a separate
commit.

pg_dump provides a migration path from the previous scheme to declare
casts.  Dumping binary compatible casts is currently impossible, though.
2002-07-18 23:11:32 +00:00
Bruce Momjian 7d78bac108 Back out BETWEEN node patch, was causing initdb failure. 2002-07-18 17:14:20 +00:00
Tom Lane 11333426f1 Implement DROP SCHEMA. It lacks support for dropping conversions and
operator classes, both of which are schema-local and so should really
be droppable.
2002-07-18 16:47:26 +00:00
Bruce Momjian a90db34b54 The attached patch (against HEAD) implements
COPY x (a,d,c,b) from stdin;
  COPY x (a,c) to stdout;

as well as the corresponding changes to pg_dump to use the new
functionality.  This functionality is not available when using
the BINARY option.  If a column is not specified in the COPY FROM
statement, its default values will be used.

In addition to this functionality, I tweaked a couple of the
error messages emitted by the new COPY <options> checks.

Brent Verner
2002-07-18 04:43:51 +00:00
Bruce Momjian 3e22406ec6 Finished the Between patch Christopher started.
Implements between (symmetric / asymmetric) as a node.

Executes the left or right expression once, makes a Const out of the
resulting Datum and executes the >=, <= portions out of the Const sets.

Of course, the parser does a fair amount of preparatory work for this to
happen.

Rod Taylor
2002-07-18 04:41:46 +00:00
Tatsuo Ishii eb335a034b I have committed many support files for CREATE CONVERSION. Default
conversion procs and conversions are added in initdb. Currently
supported conversions are:

UTF-8(UNICODE) <--> SQL_ASCII, ISO-8859-1 to 16, EUC_JP, EUC_KR,
		    EUC_CN, EUC_TW, SJIS, BIG5, GBK, GB18030, UHC,
		    JOHAB, TCVN

EUC_JP <--> SJIS
EUC_TW <--> BIG5
MULE_INTERNAL <--> EUC_JP, SJIS, EUC_TW, BIG5

Note that initial contents of pg_conversion system catalog are created
in the initdb process. So doing initdb required is ideal, it's
possible to add them to your databases by hand, however. To accomplish
this:

psql -f your_postgresql_install_path/share/conversion_create.sql your_database

So I did not bump up the version in cataversion.h.

TODO:
Add more conversion procs
Add [CASCADE|RESTRICT] to DROP CONVERSION
Add tuples to pg_depend
Add regression tests
Write docs
Add SQL99 CONVERT command?
--
Tatsuo Ishii
2002-07-18 02:02:30 +00:00
Tom Lane 5af19e4227 Add more dependency insertions --- this completes the basic pg_depend
functionality.  Of note: dropping a table that has a SERIAL column
defined now drops the associated sequence automatically.
2002-07-16 22:12:20 +00:00
Tom Lane d5fa19c6ee Add COMMENT ON CONSTRAINT facility (from Rod Taylor's pg_constraint patch).
Fix comment.c to not depend on parser token values, per discussion awhile
back.
2002-07-14 23:38:13 +00:00
Tom Lane 7c6df91dda Second phase of committing Rod Taylor's pg_depend/pg_constraint patch.
pg_relcheck is gone; CHECK, UNIQUE, PRIMARY KEY, and FOREIGN KEY
constraints all have real live entries in pg_constraint.  pg_depend
exists, and RESTRICT/CASCADE options work on most kinds of DROP;
however, pg_depend is not yet very well populated with dependencies.
(Most of the ones that are present at this point just replace formerly
hardwired associations, such as the implicit drop of a relation's pg_type
entry when the relation is dropped.)  Need to add more logic to create
dependency entries, improve pg_dump to dump constraints in place of
indexes and triggers, and add some regression tests.
2002-07-12 18:43:19 +00:00
Tatsuo Ishii fcc962566a Add new CREATE CONVERSION/DROP CONVERSION command.
This is the first cut toward CREATE CONVERSION/DROP CONVERSION implementaion.
The commands can now add/remove tuples to the new pg_conversion system
catalog, but that's all. Still need work to make them actually working.
Documentations, regression tests also need work.
2002-07-11 07:39:28 +00:00
Bruce Momjian 1666970275 I've fixed up the way domain constraints (not null and type length)
are managed as per request.

Moved from merging with table attributes to applying themselves during
coerce_type() and coerce_type_typmod.

Regression tests altered to test the cast() scenarios.

Rod Taylor
2002-07-06 20:16:36 +00:00
Thomas G. Lockhart 68d9fbeb55 Implement the IS DISTINCT FROM operator per SQL99.
Reused the Expr node to hold DISTINCT which strongly resembles
 the existing OP info. Define DISTINCT_EXPR which strongly resembles
 the existing OPER_EXPR opType, but with handling for NULLs required
 by SQL99.
We have explicit support for single-element DISTINCT comparisons
 all the way through to the executor. But, multi-element DISTINCTs
 are handled by expanding into a comparison tree in gram.y as is done for
 other row comparisons. Per discussions, it might be desirable to move
 this into one or more purpose-built nodes to be handled in the backend.
Define the optional ROW keyword and token per SQL99.
 This allows single-element row constructs, which were formerly disallowed
 due to shift/reduce conflicts with parenthesized a_expr clauses.
Define the SQL99 TREAT() function. Currently, use as a synonym for CAST().
2002-07-04 15:24:11 +00:00
Tom Lane 131f801d37 First phase of applying Rod Taylor's pg_depend patch. This just adds
RESTRICT/CASCADE syntax to the DROP commands that need it, and propagates
the behavioral option through the parser to the routines that execute
drops.  Doesn't do anything useful yet, but I figured I'd commit these
changes so I could get out of the parser area while working on the rest.
2002-07-01 15:27:56 +00:00
Thomas G. Lockhart 90edb265e3 Implement SQL99 CREATE CAST and DROP CAST statements.
Also implement alternative forms to expose the PostgreSQL CREATE FUNCTION
 features.
Implement syntax for READ ONLY and READ WRITE clauses in SET TRANSACTION.
 READ WRITE is already implemented (of course).
Implement syntax for "LIKE table" clause in CREATE TABLE. Should be fairly
 easy to complete since it resembles SELECT INTO.
Implement MATCH SIMPLE clause for foreign key definitions. This is explicit
 SQL99 syntax for the default behavior, so we now support it :)
Start implementation of shorthand for national character literals in
 scanner. For now, just swallow the leading "N", but sometime soon let's
 figure out how to pass leading type info from the scanner to the parser.
 We should use the same technique for binary and hex bit string literals,
 though it might be unusual to have two apparently independent literal
 types fold into the same storage type.
2002-06-22 02:04:55 +00:00
Bruce Momjian d84fe82230 Update copyright to 2002. 2002-06-20 20:29:54 +00:00
Bruce Momjian c2c2fd57ee Improve COPY syntax to use WITH clause, keep backward compatibility. 2002-06-20 16:00:44 +00:00
Bruce Momjian e136986afb Properly mark rules that return no value. 2002-06-19 15:40:58 +00:00
Bruce Momjian 8080ac74d5 Wrap long gram.y lines. 2002-06-18 17:56:41 +00:00
Bruce Momjian 71fd49e28d Change CREATE DATABASE to use DefElem instead of constructing structure
members in gram.y.  This is the prefered method for WITH and arbitrary
param/value pairs.
2002-06-18 17:27:58 +00:00
Bruce Momjian 3d564953cd Improve rule action ordering in gram.y, more cleanups. 2002-06-18 00:28:11 +00:00
Bruce Momjian e25f9e4f5d Mark noise keyword actions with {} rather than returning TRUE, like
opt_with and from_in.
2002-06-17 20:38:04 +00:00
Bruce Momjian 42423c7195 Manually indent gram.y to be consistent. 2002-06-17 20:27:43 +00:00
Bruce Momjian 10f05d8127 Merge ALTER GROUP ADD/DROP rules by creating add_drop action. 2002-06-17 07:00:27 +00:00
Bruce Momjian f91ee129a7 Simplify optional WITH handling in CREATE USER, ALTER USER, CREATE
GROUP.  Make WITH optional in CREATE DATABASE for consistency.
2002-06-17 05:40:32 +00:00
Thomas G. Lockhart 133df7ce70 Add LOCALTIME and LOCALTIMESTAMP functions per SQL99 standard.
Remove ODBC-compatible empty parentheses from calls to SQL99 functions
 for which these parentheses do not match the standard.
Update the ODBC driver to ensure compatibility with the ODBC standard
 for these functions (e.g. CURRENT_TIMESTAMP, CURRENT_USER, etc).
Include a new appendix in the User's Guide which lists the labeled features
 for SQL99 (the labeled features replaced the "basic", "intermediate",
 and "advanced" categories from SQL92). features.sgml does not yet split
 this list into "supported" and "unsupported" lists.
2002-06-15 03:00:09 +00:00
Thomas G. Lockhart bbc9b759d6 Add PLACING to the list of reserved keywords. Added as a token in the last
update to support the new OVERLAY() function.
2002-06-13 14:16:43 +00:00
Thomas G. Lockhart ea01a451cc Implement SQL99 OVERLAY(). Allows substitution of a substring in a string.
Implement SQL99 SIMILAR TO as a synonym for our existing operator "~".
Implement SQL99 regular expression SUBSTRING(string FROM pat FOR escape).
 Extend the definition to make the FOR clause optional.
 Define textregexsubstr() to actually implement this feature.
Update the regression test to include these new string features.
 All tests pass.
Rename the regular expression support routines from "pg95_xxx" to "pg_xxx".
Define CREATE CHARACTER SET in the parser per SQL99. No implementation yet.
2002-06-11 15:44:38 +00:00
Jan Wieck 469cb65aca Katherine Ward wrote:
> Changes to avoid collisions with WIN32 & MFC names...
> 1.  Renamed:
>       a.  PROC => PGPROC
>       b.  GetUserName() => GetUserNameFromId()
>       c.  GetCurrentTime() => GetCurrentDateTime()
>       d.  IGNORE => IGNORE_DTF in include/utils/datetime.h & utils/adt/datetim
>
> 2.  Added _P to some lex/yacc tokens:
>       CONST, CHAR, DELETE, FLOAT, GROUP, IN, OUT

Jan
2002-06-11 13:40:53 +00:00