summaryrefslogtreecommitdiff
path: root/src/backend/parser
AgeCommit message (Collapse)Author
2009-10-06Change CREATE TABLE so that column default expressions coming from differentHEADmasterTom Lane
inheritance parent tables are compared using equal(), instead of doing strcmp() on the nodeToString representation. The old implementation was always a tad cheesy, and it finally fails completely as of 8.4, now that the node tree might contain syntax location information. equal() knows it's supposed to ignore those fields, but strcmp() hardly can. Per recent report from Scott Ribe.
2009-10-05Create an ALTER DEFAULT PRIVILEGES command, which allows users to adjustTom Lane
the privileges that will be applied to subsequently-created objects. Such adjustments are always per owning role, and can be restricted to objects created in particular schemas too. A notable benefit is that users can override the traditional default privilege settings, eg, the PUBLIC EXECUTE privilege traditionally granted by default for functions. Petr Jelinek
2009-09-27Sync psql's scanner with recent changes in backend scanner's flex rules.Tom Lane
Marko Kreen, Tom Lane
2009-09-25Prevent isolated second surrogate in U& syntaxPeter Eisentraut
2009-09-25Remove backup states from Unicode escapes patchPeter Eisentraut
2009-09-22Unicode escapes in E'...' stringsPeter Eisentraut
Author: Marko Kreen <[email protected]>
2009-09-22Implement the DO statement to support execution of PL code without havingTom Lane
to create a function for it. Procedural languages now have an additional entry point, namely a function to execute an inline code block. This seemed a better design than trying to hide the transient-ness of the code from the PL. As of this patch, only plpgsql has an inline handler, but probably people will soon write handlers for the other standard PLs. In passing, remove the long-dead LANCOMPILER option of CREATE LANGUAGE. Petr Jelinek
2009-09-21Surrogate pair support for U& string and identifier syntaxPeter Eisentraut
This is mainly to make the functionality consistent with the proposed \u escape syntax.
2009-09-21Define a new, more extensible syntax for COPY options.Tom Lane
This is intentionally similar to the recently revised syntax for EXPLAIN options, ie, (name value, ...). The old syntax is still supported for backwards compatibility, but we intend that any options added in future will be provided only in the new syntax. Robert Haas, Emmanuel Cecchet
2009-09-09Fix bug with WITH RECURSIVE immediately inside WITH RECURSIVE. 99% of theTom Lane
code was already okay with this, but the hack that obtained the output column types of a recursive union in advance of doing real parse analysis of the recursive union forgot to handle the case where there was an inner WITH clause available to the non-recursive term. Best fix seems to be to refactor so that we don't need the "throwaway" parse analysis step at all. Instead, teach the transformSetOperationStmt code to set up the CTE's output column information after it's processed the non-recursive term normally. Per report from David Fetter.
2009-08-28Derived files that are shipped in the distribution used to be built in thePeter Eisentraut
source directory even for out-of-tree builds. They are now alsl built in the build tree. This should be more convenient for certain developers' workflows, and shouldn't really break anything else.
2009-08-27Modify the definition of window-function PARTITION BY and ORDER BY clausesTom Lane
so that their elements are always taken as simple expressions over the query's input columns. It originally seemed like a good idea to make them act exactly like GROUP BY and ORDER BY, right down to the SQL92-era behavior of accepting output column names or numbers. However, that was not such a great idea, for two reasons: 1. It permits circular references, as exhibited in bug #5018: the output column could be the one containing the window function itself. (We actually had a regression test case illustrating this, but nobody thought twice about how confusing that would be.) 2. It doesn't seem like a good idea for, eg, "lead(foo) OVER (ORDER BY foo)" to potentially use two completely different meanings for "foo". Accordingly, narrow down the behavior of window clauses to use only the SQL99-compliant interpretation that the expressions are simple expressions.
2009-08-26Add -Wno-error to CFLAGS from gram.o as long as it's broken.Peter Eisentraut
2009-08-18Allow mixing of traditional and SQL:2008 LIMIT/OFFSET syntax. Being rigidTom Lane
about it doesn't simplify the grammar at all, and it does invite confusion among those who only read the SELECT syntax summary and not the full details. Per gripe from Jaime Casanova.
2009-08-02Add ALTER TABLE ... ALTER COLUMN ... SET STATISTICS DISTINCTTom Lane
Robert Haas
2009-07-30Merge the Constraint and FkConstraint node types into a single type.Tom Lane
This was foreseen to be a good idea long ago, but nobody had got round to doing it. The recent patch for deferred unique constraints made transformConstraintAttrs() ugly enough that I decided it was time. This change will also greatly simplify parsing of deferred CHECK constraints, if anyone ever gets around to implementing that. While at it, add a location field to Constraint, and use that to provide an error cursor for some of the constraint-related error messages.
2009-07-29Support deferrable uniqueness constraints.Tom Lane
The current implementation fires an AFTER ROW trigger for each tuple that looks like it might be non-unique according to the index contents at the time of insertion. This works well as long as there aren't many conflicts, but won't scale to massive unique-key reassignments. Improving that case is a TODO item. Dean Rasheed
2009-07-26Extend EXPLAIN to allow generic options to be specified.Tom Lane
The original syntax made it difficult to add options without making them into reserved words. This change parenthesizes the options to avoid that problem, and makes provision for an explicit (and perhaps non-Boolean) value for each option. The original syntax is still supported, but only for the two original options ANALYZE and VERBOSE. As a test case, add a COSTS option that can suppress the planner cost estimates. This may be useful for including EXPLAIN output in the regression tests, which are otherwise unable to cope with cross-platform variations in cost estimates. Robert Haas
2009-07-25Allow * as parameter for FORCE QUOTE for COPY CSV. Itagaki Takahiro.Andrew Dunstan
2009-07-20DROP IF EXISTS for columns and constraints. Andres Freund.Andrew Dunstan
2009-07-16Make backend header files C++ safePeter Eisentraut
This alters various incidental uses of C++ key words to use other similar identifiers, so that a C++ compiler won't choke outright. You still (probably) need extern "C" { }; around the inclusion of backend headers. based on a patch by Kurt Harriman <[email protected]> Also add a script cpluspluscheck to check for C++ compatibility in the future. As of right now, this passes without error for me.
2009-07-14Tweak the core scanner so that it can be used by plpgsql too.Tom Lane
Changes: Pass in the keyword lookup array instead of having it be hardwired. (This incidentally allows elimination of some duplicate coding in ecpg.) Re-order the token declarations in gram.y so that non-keyword tokens have numbers that won't change when keywords are added or removed. Add ".." and ":=" to the set of tokens recognized by scan.l. (Since these combinations are nowhere legal in core SQL, this does not change anything except the precise wording of the error you get when you write this.)
2009-07-13Although the flex documentation avers that yyalloc and yyrealloc takeTom Lane
size_t arguments, the emitted scanner actually prototypes them with type yy_size_t, which is sometimes not the same thing depending on flex version and platform. Easiest fix seems to be to use yy_size_t. Per buildfarm results.
2009-07-13Convert the core lexer and parser into fully reentrant code, by making useTom Lane
of features added to flex and bison since this code was originally written. This change doesn't in itself offer any new capability, but it's needed infrastructure for planned improvements in plpgsql. Another feature now available in flex is the ability to make it use palloc instead of malloc, so do that to avoid possible memory leaks. (We should at some point change the other lexers likewise, but this commit doesn't touch them.)
2009-07-12Move some declarations in the raw-parser header files to create a clearerTom Lane
distinction between the external API (parser.h) and declarations that only need to be visible within the raw parser code (gramparse.h, which now is only included by parser.c, gram.y, scan.l, and keywords.c). This is in preparation for the upcoming change to a reentrant lexer, which will require referencing YYSTYPE in the declarations of base_yylex and filtered_base_yylex, hence gram.h will have to be included by gramparse.h. We don't want any more files than absolutely necessary to depend on gram.h, so some cleanup is called for.
2009-07-06Per SQL spec (in particular, the grammar in SQL:2008 7.13) we should allowTom Lane
parentheses around the <query expression body> that follows a WITH clause, eg with cte(foo) as ( values(0) ) ((select foo from cte)); This seems to be just an oversight/thinko in gram.y. Noted while experimenting with bug #4902.
2009-06-18Fix the just-reported problem that you can't specify all four trigger eventTom Lane
types in CREATE TRIGGER. While at it, clean up the amazingly tedious and inextensible way that the trigger event type list was handled. Per report from Greg Sabino Mullane.
2009-06-13Fix get_sort_group_operators() so that it doesn't think arrays can be groupedTom Lane
via hashing. Eventually we ought to make that possible, but it won't happen for 8.4. Per yesterday's report from Robert Haas.
2009-06-118.4 pgindent run, with new combined Linux/FreeBSD/MinGW typedef listBruce Momjian
provided by Andrew.
2009-06-04Improve the recently-added support for properly pluralized error messagesTom Lane
by extending the ereport() API to cater for pluralization directly. This is better than the original method of calling ngettext outside the elog.c code because (1) it avoids double translation, which wastes cycles and in the worst case could give a wrong result; and (2) it avoids having to use a different coding method in PL code than in the core backend. The client-side uses of ngettext are not touched since neither of these concerns is very pressing in the client environment. Per my proposal of yesterday.
2009-05-27Ignore RECHECK in CREATE OPERATOR CLASS, just throwing a NOTICE, instead ofTom Lane
throwing an error as 8.4 had been doing. The error interfered with porting old database definitions (particularly for pg_migrator) without really buying any safety. Per bug #4817 and subsequent discussion.
2009-05-12Modify find_inheritance_children() and find_all_inheritors() to add theTom Lane
ability to lock relations as they scan pg_inherits, and to ignore any relations that have disappeared by the time we get lock on them. This makes uses of these functions safe against concurrent DROP operations on child tables: we will effectively ignore any just-dropped child, rather than possibly throwing an error as in recent bug report from Thomas Johansson (and similar past complaints). The behavior should not change otherwise, since the code was acquiring those same locks anyway, just a little bit later. An exception is LockTableCommand(), which is still behaving unsafely; but that seems to require some more discussion before we change it.
2009-05-12Do some minor code refactoring in preparation for changing the APIs ofTom Lane
find_inheritance_children() and find_all_inheritors(). I got annoyed that these are buried inside the planner but mostly used elsewhere. So, create a new file catalog/pg_inherits.c and put them there, along with a couple of other functions that search pg_inherits. The code that modifies pg_inherits is (still) in tablecmds.c --- it's kind of entangled with unrelated code that modifies pg_depend and other stuff, so pulling it out seemed like a bigger change than I wanted to make right now. But this file provides a natural home for it if anyone ever gets around to that. This commit just moves code around; it doesn't change anything, except I succumbed to the temptation to make a couple of trivial optimizations in typeInheritsFrom().
2009-05-05Make new complaint about unsafe Unicode literals include an error location.Tom Lane
Every other ereport in scan.l has one, this should too.
2009-05-05Disable the use of Unicode escapes in string constants (U&'') whenPeter Eisentraut
standard_conforming_strings is not on, for security reasons.
2009-04-28Move SERVER to the right place in the alphabetically sorted keyword list.Heikki Linnakangas
2009-04-24Fix some more 'variable may be used uninitialized' warnings from gcc 4.4.Tom Lane
2009-04-19Rethink the idea of having plpgsql depend on parser/gram.h. Aside from theTom Lane
fact that this is breaking the MSVC build, it's probably not really a good idea to expand the dependencies of gram.h any further than the core parser; for instance the value of SCONST might depend on which bison version you'd built with. Better to expose an additional call point in parser.c, so move what I had put into pl_funcs.c into parser.c. Also PGDLLIMPORT'ify the reference to standard_conforming_strings, per buildfarm results.
2009-04-19Fix de-escaping checks so that we will reject \000 as well as other invalidlyTom Lane
encoded sequences. Per discussion of a couple of days ago.
2009-04-14Fix broken {xufailed} production that made HEAD fail onTom Lane
select u&42 from table-with-a-u-column; Also fix missing SET_YYLLOC() in the {dolqfailed} production that I suppose this was based on. The latter is a pre-existing bug, but the only effect is to misplace the error cursor by one token, so probably not worth backpatching.
2009-04-06Rename the new CREATE DATABASE options to set collation and ctype intoHeikki Linnakangas
LC_COLLATE and LC_CTYPE, per discussion on pgsql-hackers.
2009-04-04Remove the recently added node types ReloptElem and OptionDefElem in favorTom Lane
of adding optional namespace and action fields to DefElem. Having three node types that do essentially the same thing bloats the code and leads to errors of confusion, such as in yesterday's bug report from Khee Chin.
2009-03-26Gettext plural supportPeter Eisentraut
In the backend, I changed only a handful of exemplary or important-looking instances to make use of the plural support; there is probably more work there. For the rest of the source, this should cover all relevant cases.
2009-03-08Add comments about kwlookup.c expectationsAlvaro Herrera
2009-03-07Separate the key word list that lived in keywords.c into a new header fileAlvaro Herrera
kwlist.h, to avoid having to link the backend object file into other programs like pg_dump. We can now simply symlink a single source file from the backend (kwlookup.c, containing the shared routine ScanKeywordLookup) and compile it locally, which is a lot cleaner.
2009-03-04Clarify to the translator that yyerror() deals with the translation ofPeter Eisentraut
"syntax error", not the literal string. I was previously confused on this matter, but I have now verified that everything is translated properly.
2009-02-24Add the possibility to specify an explicit validator function for foreign-dataPeter Eisentraut
wrappers (similar to procedural languages). This way we don't need to retain the nearly empty libraries, and we are more free in how to implement the wrapper API in the future.
2009-02-11Change ALTER TABLE SET WITHOUT OIDS to rewrite the whole table to physicallyTom Lane
get rid of the OID column. This eliminates the problem discovered by Heikki back in November that 8.4's suppression of "unnecessary" junk filtering in INSERT/SELECT could lead to an Assert failure, or storing of oids into a table that shouldn't have them if Asserts are off. While that particular problem could have been solved in other ways, it seems likely to be just a forerunner of things to come if we continue to allow tables to contain rows that disagree with the pg_class.relhasoids setting. It's better to make this operation slow than to sacrifice performance or risk bugs in more common code paths. Also, add ALTER TABLE SET WITH OIDS to rewrite the table to add oids. This was a bit more controversial, but in view of the very small amount of extra code needed given the current ALTER TABLE infrastructure, it seems best to eliminate the asymmetry in features.
2009-02-02Allow reloption names to have qualifiers, initially supporting a TOASTAlvaro Herrera
qualifier, and add support for this in pg_dump. This allows TOAST tables to have user-defined fillfactor, and will also enable us to move the autovacuum parameters to reloptions without taking away the possibility of setting values for TOAST tables.
2009-01-22Support column-level privileges, as required by SQL standard.Tom Lane
Stephen Frost, with help from KaiGai Kohei and others