summaryrefslogtreecommitdiff
path: root/src/backend/parser
Commit message (Collapse)AuthorAgeFilesLines
* Hello.Bruce Momjian1999-10-261-13/+87
| | | | | | | | | | | | | | | | | | | The following patch extends the COMMENT ON functionality to the rest of the database objects beyond just tables, columns, and views. The grammer of the COMMENT ON statement now looks like: COMMENT ON [ [ DATABASE | INDEX | RULE | SEQUENCE | TABLE | TYPE | VIEW ] <objname> | COLUMN <relation>.<attribute> | AGGREGATE <aggname> <aggtype> | FUNCTION <funcname> (arg1, arg2, ...) | OPERATOR <op> (leftoperand_typ rightoperand_typ) | TRIGGER <triggername> ON relname> Mike Mascari (mascarim@yahoo.com)
* I have a patch for postgresql-snapshot(1999-10-22).Bruce Momjian1999-10-221-5/+11
| | | | | | | | | | | | This patch fix a TODO list item. * require SELECT DISTINCT target list to have all ORDER BY columns example ogawa=> select distinct x from t1 order by y; ERROR: ORDER BY columns must appear in SELECT DISTINCT target list --- Atsushi Ogawa
* Remove fixed-size literal buffer from scan.l, and repairTom Lane1999-10-182-62/+73
| | | | | | | | boundary-condition bug in myinput() which caused flex scanner to fail on tokens larger than a bufferload. Turns out flex doesn't want null- terminated input ... and if it gives you a 1-character buffer, you'd better supply a character, not a null, lest you be thought to be reporting end of input.
* This patch implements ORACLE's COMMENT SQL command.Bruce Momjian1999-10-152-4/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | >From the ORACLE 7 SQL Language Reference Manual: ----------------------------------------------------- COMMENT Purpose: To add a comment about a table, view, snapshot, or column into the data dictionary. Prerequisites: The table, view, or snapshot must be in your own schema or you must have COMMENT ANY TABLE system privilege. Syntax: COMMENT ON [ TABLE table ] | [ COLUMN table.column] IS 'text' You can effectively drop a comment from the database by setting it to the empty string ''. ----------------------------------------------------- Example: COMMENT ON TABLE workorders IS 'Maintains base records for workorder information'; COMMENT ON COLUMN workorders.hours IS 'Number of hours the engineer worked on the task'; to drop a comment: COMMENT ON COLUMN workorders.hours IS ''; The current patch will simply perform the insert into pg_description, as per the TODO. And, of course, when the table is dropped, any comments relating to it or any of its attributes are also dropped. I haven't looked at the ODBC source yet, but I do know from an ODBC client standpoint that the standard does support the notion of table and column comments. Hopefully the ODBC driver is already fetching these values from pg_description, but if not, it should be trivial. Hope this makes the grade, Mike Mascari (mascarim@yahoo.com)
* Allow \r as whitespace.Bruce Momjian1999-10-091-2/+2
|
* Fix for "--" comment and no trailing newline, as seen in Perl.Bruce Momjian1999-10-081-2/+2
|
* Fix planner and rewriter to follow SQL semantics for tables that areTom Lane1999-10-076-167/+125
| | | | | | | | | | | 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.
* Allow comment-only lines, and ;;; lines too.Bruce Momjian1999-10-051-8/+19
|
* Reimplement parsing and storage of default expressions and constraintTom Lane1999-10-032-442/+117
| | | | | | | | | | | | | | | expressions in CREATE TABLE. There is no longer an emasculated expression syntax for these things; it's full a_expr for constraints, and b_expr for defaults (unfortunately the fact that NOT NULL is a part of the column constraint syntax causes a shift/reduce conflict if you try a_expr. Oh well --- at least parenthesized boolean expressions work now). Also, stored expression for a column default is not pre-coerced to the column type; we rely on transformInsertStatement to do that when the default is actually used. This means "f1 datetime default 'now'" behaves the way people usually expect it to. BTW, all the support code is now there to implement ALTER TABLE ADD CONSTRAINT and ALTER TABLE ADD COLUMN with a default value. I didn't actually teach ALTER TABLE to call it, but it wouldn't be much work.
* Teach parse_coerce about non-cachable functions (actually,Tom Lane1999-10-021-32/+17
| | | | make it call eval_const_expressions() so that it doesn't have to know).
* Allow CREATE FUNCTION's WITH clause to be used for all language types,Tom Lane1999-10-021-2/+1
| | | | | | | not just C, so that ISCACHABLE attribute can be specified for user-defined functions. Get rid of ParamString node type, which wasn't actually being generated by gram.y anymore, even though define.c thought that was what it was getting. Clean up minor bug in dfmgr.c (premature heap_close).
* Disable new FROM-clause warning.Bruce Momjian1999-09-292-2/+8
|
* This is part #1 for of the DEFERRED CONSTRAINT TRIGGER support.Jan Wieck1999-09-292-6/+162
| | | | | | | | | | | | Implements the CREATE CONSTRAINT TRIGGER and SET CONSTRAINTS commands. TODO: Generic builtin trigger procedures Automatic execution of appropriate CREATE CONSTRAINT... at CREATE TABLE Support of new trigger type in pg_dump Swapping of huge # of events to disk Jan
* Add subquery mention in auto-create table entry.Bruce Momjian1999-09-282-5/+11
|
* More cleanup for | and ^.Bruce Momjian1999-09-281-13/+9
|
* More cleanup for | and ^.Bruce Momjian1999-09-281-7/+67
|
* Fix for creation of operator |.Bruce Momjian1999-09-281-5/+25
|
* I have been working with user defined types and user defined cBruce Momjian1999-09-281-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | functions. One problem that I have encountered with the function manager is that it does not allow the user to define type conversion functions that convert between user types. For instance if mytype1, mytype2, and mytype3 are three Postgresql user types, and if I wish to define Postgresql conversion functions like I run into problems, because the Postgresql dynamic loader would look for a single link symbol, mytype3, for both pieces of object code. If I just change the name of one of the Postgresql functions (to make the symbols distinct), the automatic type conversion that Postgresql uses, for example, when matching operators to arguments no longer finds the type conversion function. The solution that I propose, and have implemented in the attatched patch extends the CREATE FUNCTION syntax as follows. In the first case above I use the link symbol mytype2_to_mytype3 for the link object that implements the first conversion function, and define the Postgresql operator with the following syntax The patch includes changes to the parser to include the altered syntax, changes to the ProcedureStmt node in nodes/parsenodes.h, changes to commands/define.c to handle the extra information in the AS clause, and changes to utils/fmgr/dfmgr.c that alter the way that the dynamic loader figures out what link symbol to use. I store the string for the link symbol in the prosrc text attribute of the pg_proc table which is currently unused in rows that reference dynamically loaded functions. Bernie Frankpitt
* Reverse out last scan.l patch for minus handling.\Bruce Momjian1999-09-283-7/+7
|
* Sorry, guys. Here is the ultimate patch which keeps the entireBruce Momjian1999-09-271-2/+2
| | | | | | | | | | behavior as it was, apart from forbidding minus-terminated operators. Seems that I have to break the habit of doing before thinking properly :-/ The point is that my second patch breaks constructs like a & b or a ! b. This patch is to be applied instead of any of two other today's patches. Leon
* Following advice from Michael Ansley, I broke up the patch inBruce Momjian1999-09-271-97/+10
| | | | | | | two: one fixes uminus and other literal length. They are to be applied - uminus first, then possilbly literal on top of uminus. Leon
* Emit warning on SELECT pg_language.*Bruce Momjian1999-09-272-5/+14
|
* Add TRUNCATE command, with psql help and sgml additions.Bruce Momjian1999-09-232-5/+21
|
* Mega-commit to make heap_open/heap_openr/heap_close take anTom Lane1999-09-185-55/+41
| | | | | | | | | | | | | | | | | additional argument specifying the kind of lock to acquire/release (or 'NoLock' to do no lock processing). Ensure that all relations are locked with some appropriate lock level before being examined --- this ensures that relevant shared-inval messages have been processed and should prevent problems caused by concurrent VACUUM. Fix several bugs having to do with mismatched increment/decrement of relation ref count and mismatched heap_open/close (which amounts to the same thing). A bogus ref count on a relation doesn't matter much *unless* a SI Inval message happens to arrive at the wrong time, which is probably why we got away with this sloppiness for so long. Repair missing grab of AccessExclusiveLock in DROP TABLE, ALTER/RENAME TABLE, etc, as noted by Hiroshi. Recommend 'make clean all' after pulling this update; I modified the Relation struct layout slightly. Will post further discussion to pghackers list shortly.
* Allow ISOLATION and LEVEL as column names. These are SQL92 reserved wordsThomas G. Lockhart1999-09-141-1/+3
| | | | which do not need to be so for our parser. Apparently omitted earlier.
* Allow CASE statement to contain *only* untyped result clauses or nulls.Thomas G. Lockhart1999-09-131-2/+3
| | | | | | | Almost worked before, but forgot one place to check. Reported by Tatsuo Ishii. Still does not do the right thing if inserting into a non-string target column. Should look for a type coersion later, but doesn't.
* Eliminate token length assumption in scanstr().Tom Lane1999-09-112-7/+9
|
* Mike Ansley's fixes for long queries. This change justTom Lane1999-09-071-17/+11
| | | | | | | corrects flex myinput() routine so that it doesn't assume there is only one bufferload of data. We still have the issue of getting rid of YY_USES_REJECT so that the scanner can cope with tokens larger than its initial buffer size.
* Clean up some bugs in oper_select_candidate(), notably theTom Lane1999-08-261-24/+29
| | | | | | last loop which would return the *first* surviving-to-that-point candidate regardless of which one actually passed the test. This was producing such curious results as 'oid % 2' getting translated to 'int2(oid) % 2'.
* Revise implementation of SubLinks so that there is a consistent,Tom Lane1999-08-251-20/+46
| | | | | | | | | documented intepretation of the lefthand and oper fields. Fix a number of obscure problems while at it --- for example, the old code failed if the parser decided to insert a type-coercion function just below the operator of a SubLink. CAUTION: this will break stored rules that contain subplans. You may need to initdb.
* coerce_type() failed to guard against trying to convert a NULLTom Lane1999-08-241-17/+17
| | | | | constant to a different type. Not sure that this could happen in ordinary parser usage, but it can in some new code I'm working on...
* Remove bogus code in oper_exact --- if it didn't find an exactTom Lane1999-08-232-100/+29
| | | | | | | | | match then it tried for a self-commutative operator with the reversed input data types. This is pretty silly; there could never be such an operator, except maybe in binary-compatible-type scenarios, and we have oper_inexact for that. Besides which, the oprsanity regress test would complain about such an operator. Remove nonfunctional code and simplify routine calling convention accordingly.
* Further planner/optimizer cleanups. Move all set_tlist_referencesTom Lane1999-08-222-7/+6
| | | | | | | | | | and fix_opids processing to a single recursive pass over the plan tree executed at the very tail end of planning, rather than haphazardly here and there at different places. Now that tlist Vars do not get modified until the very end, it's possible to get rid of the klugy var_equal and match_varid partial-matching routines, and just use plain equal() throughout the optimizer. This is a step towards allowing merge and hash joins to be done on expressions instead of only Vars ...
* Major revision of sort-node handling: push knowledge of queryTom Lane1999-08-214-132/+144
| | | | | | | | | | | | | sort order down into planner, instead of handling it only at the very top level of the planner. This fixes many things. An explicit sort is now avoided if there is a cheaper alternative (typically an indexscan) not only for ORDER BY, but also for the internal sort of GROUP BY. It works even when there is no other reason (such as a WHERE condition) to consider the indexscan. It works for indexes on functions. It works for indexes on functions, backwards. It's just so cool... CAUTION: I have changed the representation of SortClause nodes, therefore THIS UPDATE BREAKS STORED RULES. You will need to initdb.
* Old multi-byte bug. Forgot to rename #ifdef MB to #ifdef MULTIBYTETatsuo Ishii1999-08-181-2/+2
| | | | Now SET NAMES working again...
* Small updates to #include lists for pending optimizer checkin.Tom Lane1999-08-162-3/+4
|
* Move funcid_get_rettype() to lsyscache.Tom Lane1999-08-161-23/+3
|
* Repair the check for redundant UNIQUE and PRIMARY KEY indices.Thomas G. Lockhart1999-08-151-13/+33
| | | | | Also, improve it so that it checks for multi-column constraints. Thanks to Mark Dalphin <mdalphin@amgen.com> for reporting the problem.
* Revise parse_coerce() to handle coercion of int and floatTom Lane1999-08-054-235/+110
| | | | | constants, not only string constants, at parse time. Get rid of parser_typecast2(), which is bogus and redundant...
* Allow a_expr not just AexprConst in the right-hand list ofTom Lane1999-07-281-46/+49
| | | | | IN and NOT IN operators. Rewrite grotty implementation of IN-list parsing ... look Ma, no global variable ...
* First cut at doing LIKE/regex indexing optimization inTom Lane1999-07-271-156/+4
| | | | | | | | | | | | | | | | | | optimizer rather than parser. This has many advantages, such as not getting fooled by chance uses of operator names ~ and ~~ (the operators are identified by OID now), and not creating useless comparison operations in contexts where the comparisons will not actually be used as indexquals. The new code also recognizes exact-match LIKE and regex patterns, and produces an = indexqual instead of >= and <=. This change does NOT fix the problem with non-ASCII locales: the code still doesn't know how to generate an upper bound indexqual for non-ASCII collation order. But it's no worse than before, just the same deficiency in a different place... Also, dike out loc_restrictinfo fields in Plan nodes. These were doing nothing useful in the absence of 'expensive functions' optimization, and they took a considerable amount of processing to fill in.
* Complain about INSERT ... SELECT ... ORDER BY, which we do notTom Lane1999-07-201-86/+110
| | | | | | support, but which the grammar was accepting. Also, fix several bugs having to do with failure to copy fields up from a subselect to a select or insert node.
* Rewrite parser's handling of INSERT ... SELECT so that processingTom Lane1999-07-196-1254/+772
| | | | | | | | | of the SELECT part of the statement is just like a plain SELECT. All INSERT-specific processing happens after the SELECT parsing is done. This eliminates many problems, e.g. INSERT ... SELECT ... GROUP BY using the wrong column labels. Ensure that DEFAULT clauses are coerced to the target column type, whether or not stored clause produces the right type. Substantial cleanup of parser's array support.
* Move some system includes into c.h, and remove duplicates.Bruce Momjian1999-07-1716-48/+17
|
* Add config.h as needed.Bruce Momjian1999-07-171-3/+1
|
* Support subscripts on bare column names.Tom Lane1999-07-161-116/+73
|
* Allow bare column names to be subscripted as arrays. ThisTom Lane1999-07-161-249/+75
| | | | | | | | | | | | | | | creates a reduce/reduce conflict, which I resolved by changing the 'AexprConst -> Typename Sconst' rule to 'AexprConst -> SimpleTypename Sconst'. In other words, a subscripted type declaration can't be used in that syntax any longer. This seems a small price to pay for not having to qualify subscripted columns anymore. Other cleanups: rename res_target_list to update_target_list, and remove productions for variants that are not legal in an UPDATE target list; rename res_target_list2 to plain target_list; delete position_expr in favor of using b_expr in that production; merge opt_indirection into attr nonterminal, since there are no places where an unsubscripted attr is wanted; fix typos in Param support; change case_arg so that an arbitrary a_expr is allowed, not only a column name.
* Final cleanup.Bruce Momjian1999-07-1613-43/+42
|
* Remove unused #includes in *.c files.Bruce Momjian1999-07-1510-58/+10
|
* Clean up #include in /include directory. Add scripts for checking includes.Bruce Momjian1999-07-157-13/+11
|