summaryrefslogtreecommitdiff
path: root/src/backend/parser
AgeCommit message (Collapse)Author
2010-10-02Behave correctly if INSERT ... VALUES is decorated with additional clauses.Tom Lane
In versions 8.2 and up, the grammar allows attaching ORDER BY, LIMIT, FOR UPDATE, or WITH to VALUES, and hence to INSERT ... VALUES. But the special-case code for VALUES in transformInsertStmt() wasn't expecting any of those, and just ignored them, leading to unexpected results. Rather than complicate the special-case path, just ensure that the presence of any of those clauses makes us treat the query as if it had a general SELECT. Per report from Hitoshi Harada.
2010-09-25Further fixes to the pg_get_expr() security fix in back branches.Tom Lane
It now emerges that the JDBC driver expects to be able to use pg_get_expr() on an output of a sub-SELECT. So extend the check logic to be able to recurse into a sub-SELECT to see if the argument is ultimately coming from an appropriate column. Per report from Thomas Kellerer.
2010-09-22Some more gitignore cleanups: cover contrib and PL regression test outputs.Tom Lane
Also do some further work in the back branches, where quite a bit wasn't covered by Magnus' original back-patch.
2010-09-22Convert cvsignore to gitignore, and add .gitignore for build targets.Magnus Hagander
2010-07-30Improved version of patch to protect pg_get_expr() against misuse:Tom Lane
look through join alias Vars to avoid breaking join queries, and move the test to someplace where it will catch more possible ways of calling a function. We still ought to throw away the whole thing in favor of a data-type-based solution, but that's not feasible in the back branches. Completion of back-port of my patch of yesterday.
2010-06-30stringToNode() and deparse_expression_pretty() crash on invalid input,Heikki Linnakangas
but we have nevertheless exposed them to users via pg_get_expr(). It would be too much maintenance effort to rigorously check the input, so put a hack in place instead to restrict pg_get_expr() so that the argument must come from one of the system catalog columns known to contain valid expressions. Per report from Rushabh Lathia. Backpatch to 7.4 which is the oldest supported version at the moment.
2010-05-08Work around a subtle portability problem in use of printf %s format.Tom Lane
Depending on which spec you read, field widths and precisions in %s may be counted either in bytes or characters. Our code was assuming bytes, which is wrong at least for glibc's implementation, and in any case libc might have a different idea of the prevailing encoding than we do. Hence, for portable results we must avoid using anything more complex than just "%s" unless the string to be printed is known to be all-ASCII. This patch fixes the cases I could find, including the psql formatting failure reported by Hernan Gonzalez. In HEAD only, I also added comments to some places where it appears safe to continue using "%.*s".
2009-01-30Defend against null input in analyze_requires_snapshot(), per reportTom Lane
from Rushabh Lathia. Back-patch of patch of 2009-01-08. This is necessary in 8.3, as reported by Bjorn Munch. It's not currently necessary in 8.2, AFAICS, but seems best to include it there too.
2008-12-13Fix failure to ensure that a snapshot is available to datatype input functionsTom Lane
when they are invoked by the parser. We had been setting up a snapshot at plan time but really it needs to be done earlier, before parse analysis. Per report from Dmitry Koterov. Also fix two related problems discovered while poking at this one: exec_bind_message called datatype input functions without establishing a snapshot, and SET CONSTRAINTS IMMEDIATE could call trigger functions without establishing a snapshot. Backpatch to 8.2. The underlying problem goes much further back, but it is masked in 8.1 and before because we didn't attempt to invoke domain check constraints within datatype input. It would only be exposed if a C-language datatype input function used the snapshot; which evidently none do, or we'd have heard complaints sooner. Since this code has changed a lot over time, a back-patch is hardly risk-free, and so I'm disinclined to patch further than absolutely necessary.
2008-10-26Better solution to the IN-list issue: instead of having an arbitrary cutoff,Tom Lane
treat Var and non-Var IN-list items differently. Only non-Var items are candidates to go into an ANY(ARRAY) construct --- we put all Vars as separate OR conditions on the grounds that that leaves more scope for optimization. Per suggestion from Robert Haas.
2008-10-25Add a heuristic to transformAExprIn() to make it prefer expanding "x IN (list)"Tom Lane
into an OR of equality comparisons, rather than x = ANY(ARRAY[...]), when there are Vars in the right-hand side. This avoids a performance regression compared to pre-8.2 releases, in cases where the OR form can be optimized into scans of multiple indexes. Limit the possible downside by preferring this form only when the list isn't very long (I set the cutoff at 32 elements, which is a bit arbitrary but in the right ballpark). Per discussion with Jim Nasby. In passing, also make it try the OR form if it cannot select a common type for the array elements; we've seen a complaint or two about how the OR form worked for such cases and ARRAY doesn't.
2008-04-05Defend against JOINs having more than 32K columns altogether. We cannotTom Lane
currently support this because we must be able to build Vars referencing join columns, and varattno is only 16 bits wide. Perhaps this should be improved in future, but considering that it never came up before, I'm not sure the problem is worth much effort. Per bug #4070 from Marcello Ceschia. The problem seems largely academic in 8.0 and 7.4, because they have (different) O(N^2) performance issues with such wide joins, but back-patch all the way anyway.
2008-02-07Some variants of ALTER OWNER tried to make the "object" field of theTom Lane
statement be a list of bare C strings, rather than String nodes, which is what they need to be for copyfuncs/equalfuncs to work. Fortunately these node types never go out to disk (if they did, we'd likely have noticed the problem sooner), so we can just fix it without creating a need for initdb. This bug has been there since 8.0, but 8.3 exposes it in a more common code path (Parse messages) than prior releases did. Per bug #3940 from Vladimir Kokovic.
2007-09-27Fix Assert failure in ExpandColumnRefStar --- what I thought was a can'tTom Lane
happen condition can happen given incorrect input. The real problem is that gram.y should try harder to distinguish * from "*" --- the latter is a legal column name per spec, and someday we ought to treat it that way. However fixing that is too invasive for a back-patch, and it's too late for the 8.3 cycle too. So just reduce the Assert to a plain elog for now. Per report from NikhilS.
2007-06-20transformColumnDefinition failed to complain aboutTom Lane
create table foo (bar int default null default 3); due to not thinking about the special-case handling of DEFAULT NULL. Problem noticed while investigating bug #3396.
2007-01-06Fix filtered_base_yylex() to save and restore base_yylval and base_yyllocTom Lane
properly when doing a lookahead. The lack of this was causing various interesting misbehaviors when one tries to use "with" as a plain identifier.
2006-11-28Fix some translator comments so that xgettext finds them and pgindent doesPeter Eisentraut
not destroy them. Maybe we can adjust pgindent sometime.
2006-11-05Fix recently-understood problems with handling of XID freezing, particularlyTom Lane
in PITR scenarios. We now WAL-log the replacement of old XIDs with FrozenTransactionId, so that such replacement is guaranteed to propagate to PITR slave databases. Also, rather than relying on hint-bit updates to be preserved, pg_clog is not truncated until all instances of an XID are known to have been replaced by FrozenTransactionId. Add new GUC variables and pg_autovacuum columns to allow management of the freezing policy, so that users can trade off the size of pg_clog against the amount of freezing work done. Revise the already-existing code that forces autovacuum of tables approaching the wraparound point to make it more bulletproof; also, revise the autovacuum logic so that anti-wraparound vacuuming is done per-table rather than per-database. initdb forced because of changes in pg_class, pg_database, and pg_autovacuum catalogs. Heikki Linnakangas, Simon Riggs, and Tom Lane.
2006-10-13Code and docs review for ALTER TABLE INHERIT/NO INHERIT patch.Tom Lane
2006-10-11Repair incorrect check for coercion of unknown literal to ANYARRAY, a bugTom Lane
I introduced in 7.4.1 :-(. It's correct to allow unknown to be coerced to ANY or ANYELEMENT, since it's a real-enough data type, but it most certainly isn't an array datatype. This can cause a backend crash but AFAICT is not exploitable as a security hole. Per report from Michael Fuhr. Note: as fixed in HEAD, this changes a constant in the pg_stats view, resulting in a change in the expected regression outputs. The back-branch patches have been hacked to avoid that, so that pre-existing installations won't start failing their regression tests.
2006-10-11Code review for LIKE INCLUDING CONSTRAINTS patch --- improve comments,Tom Lane
don't cheat on the raw-vs-cooked status of a constraint.
2006-10-07Added missing entry (CASCADED) in keywords table.Peter Eisentraut
2006-10-04pgindent run for 8.2.Bruce Momjian
2006-09-28Fix IS NULL and IS NOT NULL tests on row-valued expressions to conform toTom Lane
the SQL spec, viz IS NULL is true if all the row's fields are null, IS NOT NULL is true if all the row's fields are not null. The former coding got this right for a limited number of cases with IS NULL (ie, those where it could disassemble a ROW constructor at parse time), but was entirely wrong for IS NOT NULL. Per report from Teodor. I desisted from changing the behavior for arrays, since on closer inspection it's not clear that there's any support for that in the SQL spec. This probably needs more consideration.
2006-09-25Fix notice message from DROP FUNCTION IF EXISTS, and improve messageTom Lane
for DROP AGGREGATE IF EXISTS. Per report from Teodor.
2006-09-22Fix bugs in plpgsql and ecpg caused by assuming that isspace() would onlyTom Lane
return true for exactly the characters treated as whitespace by their flex scanners. Per report from Victor Snezhko and subsequent investigation. Also fix a passel of unsafe usages of <ctype.h> functions, that is, ye olde char-vs-unsigned-char issue. I won't miss <ctype.h> when we are finally able to stop using it.
2006-09-18Fix problems with column name list of CREATE TABLE AS being applied toTom Lane
the input query's target list too soon, causing it to affect processing of ORDER BY in the input query.
2006-09-18Fix CREATE TABLE ... AS VALUES ... to work rather than Assert'ing;Tom Lane
oversight in original implementation of VALUES. Also fix an oversight in recent addition of options to CREATE TABLE AS: they weren't getting propagated if the query was a set-operation such as UNION.
2006-09-03Code review for UPDATE SET (columnlist) patch. Make it handle as muchTom Lane
of the syntax as this fundamentally dead-end approach can, in particular combinations of single and multi column assignments. Improve rather inadequate documentation and provide some regression tests.
2006-09-03Revert FETCH/MOVE int64 patch. Was using incorrect checks forBruce Momjian
fetch/move in scan.l.
2006-09-03Remove unnecessary copyObject() call in update (values) code.Bruce Momjian
2006-09-02Small code cleanup for recent UPDATE SET (values) patch.Bruce Momjian
2006-09-02Add UPDATE tab SET ROW (col, ...) = (val, ...) for updatingBruce Momjian
multiple columns Susanne Ebrecht
2006-09-02Change FETCH/MOVE to use int8.Bruce Momjian
Dhanaraj M
2006-08-30Extend COPY to support COPY (SELECT ...) TO ...Tom Lane
Bernd Helmle
2006-08-25Add the ability to create indexes 'concurrently', that is, withoutTom Lane
blocking concurrent writes to the table. Greg Stark, with a little help from Tom Lane.
2006-08-21Fix all known problems with pg_dump's handling of serial sequencesTom Lane
by abandoning the idea that it should say SERIAL in the dump. Instead, dump serial sequences and column defaults just like regular ones. Add a new backend command ALTER SEQUENCE OWNED BY to let pg_dump recreate the sequence-to-column dependency that was formerly created "behind the scenes" by SERIAL. This restores SERIAL to being truly "just a macro" consisting of component operations that can be stated explicitly in SQL. Furthermore, the new command allows sequence ownership to be reassigned, so that old mistakes can be cleaned up. Also, downgrade the OWNED-BY dependency from INTERNAL to AUTO, since there is no longer any very compelling argument why the sequence couldn't be dropped while keeping the column. (This forces initdb, to be sure the right kinds of dependencies are in there.) Along the way, add checks to prevent ALTER OWNER or SET SCHEMA on an owned sequence; you can now only do this indirectly by changing the owning table's owner or schema. This is an oversight in previous releases, but probably not worth back-patching.
2006-08-14Cause '*' and 'foo.*' notations to mark the referenced RTE(s) asTom Lane
requiring read permissions. Up till now there was no possible case in which the RTEs wouldn't already have ACL_SELECT set ... but now that you can say something like 'INSERT INTO foo ... RETURNING *' this is an essential step. With this commit, a RETURNING clause adds the requirement for SELECT permissions on the target table if and only if the clause actually reads the value of at least one target-table column.
2006-08-12Tweak SPI_cursor_open to allow INSERT/UPDATE/DELETE RETURNING; this wasTom Lane
merely a matter of fixing the error check, since the underlying Portal infrastructure already handles it. This in turn allows these statements to be used in some existing plpgsql and plperl contexts, such as a plpgsql FOR loop. Also, do some marginal code cleanup in places that were being sloppy about distinguishing SELECT from SELECT INTO.
2006-08-12Remove ancient, obsolete comment.Tom Lane
2006-08-12Add INSERT/UPDATE/DELETE RETURNING, with basic docs and regression tests.Tom Lane
plpgsql support to come later. Along the way, convert execMain's SELECT INTO support into a DestReceiver, in order to eliminate some ugly special cases. Jonah Harris and Tom Lane
2006-08-10Fix UNION/INTERSECT/EXCEPT so that when two inputs being merged haveTom Lane
same data type and same typmod, we show that typmod as the output typmod, rather than generic -1. This responds to several complaints over the past few years about UNIONs unexpectedly dropping length or precision info.
2006-08-02Wups, got the test for contain_vars_of_level-not-needed wrong inTom Lane
transformInsertStmt: the target table is already in p_rtable at that point.
2006-08-02Add a HINT per suggestion from Michael Glaesemann. Also, tweak OLD/NEWTom Lane
test to avoid expensive contain_vars_of_level() scan in the normal case where we're not inside a rule.
2006-08-02Add support for multi-row VALUES clauses as part of INSERT statementsJoe Conway
(e.g. "INSERT ... VALUES (...), (...), ...") and elsewhere as allowed by the spec. (e.g. similar to a FROM clause subselect). initdb required. Joe Conway and Tom Lane.
2006-07-31Change the bootstrap sequence so that toast tables for system catalogs areTom Lane
created in the bootstrap phase proper, rather than added after-the-fact by initdb. This is cleaner than before because it allows us to retire the undocumented ALTER TABLE ... CREATE TOAST TABLE command, but the real reason I'm doing it is so that toast tables of shared catalogs will now have predetermined OIDs. This will allow a reasonably clean solution to the problem of locking tables before we load their relcache entries, to appear in a forthcoming patch.
2006-07-27Aggregate functions now support multiple input arguments. I also tookTom Lane
the opportunity to treat COUNT(*) as a zero-argument aggregate instead of the old hack that equated it to COUNT(1); this is materially cleaner (no more weird ANYOID cases) and ought to be at least a tiny bit faster. Original patch by Sergey Koposov; review, documentation, simple regression tests, pg_dump and psql support by moi.
2006-07-26Code review for bigint-LIMIT patch. Fix missed planner dependency,Tom Lane
eliminate unnecessary code, force initdb because stored rules change (limit nodes are now supposed to be int8 not int4 expressions). Update comments and error messages, which still all said 'integer'.
2006-07-26Change LIMIT/OFFSET to use int8Bruce Momjian
Dhanaraj M
2006-07-15Fix some missing inclusions identified with new pgcheckdefines tool.Tom Lane