Commit Graph

497 Commits

Author SHA1 Message Date
Tom Lane 42fbb6dbe7 Clean up various memory leaks within plpgsql, and re-enable the
exec_eval_simple_expr shortcut, which was diked out in 7.1 because it
leaked too much space.  CVS tip now leaks no memory in Chris Ruprecht's
example, which formerly leaked to the tune of 500 MB.  (Much of this
is work that Jan already did; this commit just cleans up around the
edges.)
2001-08-02 21:31:23 +00:00
Bruce Momjian 5c4d1398a6 Back out SET AUTHORIZATION patch until security is resolved. 2001-07-12 17:42:08 +00:00
Bruce Momjian d946b2083a I updated the patch to use the SET AUTHORIZATION { INVOKER | DEFINER }
terminology. Also, the function owner is now determined and saved at compile
time (no gotchas here, right?)/

Mark Volpe
2001-07-11 18:54:19 +00:00
Tom Lane a056f14be0 Cause plpgsql's PERFORM to behave according to its documentation,
which says that PERFORM will execute any SELECT query and discard the
result.  The former implementation would in fact raise an error if the
result contained more than one row or more than one column.

Also, change plpgsql's error-logging mechanism to emit the additional
messages about error location at NOTICE rather than DEBUG level.  This
allows them to be seen by the client without having to dig into the
postmaster log file (which may be nonexistent or inaccessible by the
client).
2001-05-28 19:33:24 +00:00
Jan Wieck d27f363e3f Enhancement of SPI to get access to portals
- New functions to create a portal using a prepared/saved
  SPI plan or lookup an existing portal by name.
- Functions to fetch/move from/in portals. Results are placed
  in the usual SPI_processed and SPI_tuptable, so the entire
  set of utility functions can be used to gain attribute access.
- Prepared/saved SPI plans now use their own memory context
  and SPI_freeplan(plan) can remove them.
- Tuple result sets (SPI_tuptable) now uses it's own memory
  context and can be free'd by SPI_freetuptable(tuptab).

Enhancement of PL/pgSQL

- Uses generic named portals internally in FOR ... SELECT
  loops to avoid running out of memory on huge result sets.
- Support for CURSOR and REFCURSOR syntax using the new SPI
  functionality. Cursors used internally only need no explicit
  transaction block. Refcursor variables can be used inside
  of explicit transaction block to pass cursors between main
  application and functions.


Jan
2001-05-21 14:22:19 +00:00
Tom Lane eb62f076d0 Un-break exec_move_row() for case that a NULL tuple and tupdesc are
passed, which occurs when no rows are retrieved by a SELECT.
Mea maxima culpa ... I should have caught this.
2001-05-08 01:00:53 +00:00
Tom Lane 8bb3c8fe54 exec_move_row() should be more forgiving of tuples with a different
number of columns than it was expecting, for reasons that are now
documented in the code...
2001-04-30 20:05:40 +00:00
Bruce Momjian 0686d49da0 Remove dashes in comments that don't need them, rewrap with pgindent. 2001-03-22 06:16:21 +00:00
Bruce Momjian 9e1552607a pgindent run. Make it all clean. 2001-03-22 04:01:46 +00:00
Tom Lane 414f94f262 Change plpgsql's GET DIAGNOSTICS statement to use SQL99-compatible
syntax.  Fix the RESULT_OID case, which never worked.  Add documentation.
2001-02-19 19:49:53 +00:00
Tom Lane 8a2cdd77ad EXECUTE of a SELECT ... INTO now draws a 'not implemented' error,
rather than executing the INTO clause with non-plpgsql semantics
as it was doing for the last few weeks/months.  This keeps our options
open for making it do the right plpgsql-ish thing in future without
creating a backwards compatibility problem.  There is no loss of
functionality since people can get the same behavior with CREATE TABLE AS.
2001-02-09 00:14:26 +00:00
Tom Lane c9fe128316 Clean up per-tuple memory leaks in trigger firing and plpgsql
expression evaluation.
2001-01-22 00:50:07 +00:00
Tom Lane 682b128993 Fix NOT NULL option for plpgsql variables (doesn't look like it
could ever have worked...)
2001-01-06 01:43:01 +00:00
Tom Lane afeb8c4819 Clean up some unnecessary fragility in EXECUTE command. 2001-01-04 02:38:02 +00:00
Tom Lane f5371feef9 Fix inadequate tree-walking code in exec_eval_clear_fcache. 2000-12-01 20:43:59 +00:00
Tom Lane a933ee38bb Change SearchSysCache coding conventions so that a reference count is
maintained for each cache entry.  A cache entry will not be freed until
the matching ReleaseSysCache call has been executed.  This eliminates
worries about cache entries getting dropped while still in use.  See
my posting to pg-hackers of even date for more info.
2000-11-16 22:30:52 +00:00
Tom Lane 3bfbe6991a Clean up compiler warning. 2000-09-12 19:41:40 +00:00
Jan Wieck c59077dd7b GET DIAGNOSTICS statement to PL/pgSQL to access SPI_processed
and SPI_return values. Patch from Philip Warner.

Jan
2000-09-05 09:02:18 +00:00
Jan Wieck d4266620e1 Added EXECUTE command to PL/pgSQL for execution of
dynamic SQL and utility statements.

Jan
2000-08-31 13:26:16 +00:00
Tom Lane 782c16c6a1 SQL-language functions are now callable in ordinary fmgr contexts ...
for example, an SQL function can be used in a functional index.  (I make
no promises about speed, but it'll work ;-).)  Clean up and simplify
handling of functions returning sets.
2000-08-24 03:29:15 +00:00
Tom Lane 37168b8da4 Clean up handling of variable-free qual clauses. System now does the
right thing with variable-free clauses that contain noncachable functions,
such as 'WHERE random() < 0.5' --- these are evaluated once per
potential output tuple.  Expressions that contain only Params are
now candidates to be indexscan quals --- for example, 'var = ($1 + 1)'
can now be indexed.  Cope with RelabelType nodes atop potential indexscan
variables --- this oversight prevents 7.0.* from recognizing some
potentially indexscanable situations.
2000-08-13 02:50:35 +00:00
Tom Lane c298d74d49 More functions updated to new fmgr style --- money, name, tid datatypes.
We're reaching the mopup stage here (good thing too, this is getting
tedious).
2000-08-03 16:35:08 +00:00
Tom Lane badce86a2c First stage of reclaiming memory in executor by resetting short-term
memory contexts.  Currently, only leaks in expressions executed as
quals or projections are handled.  Clean up some old dead cruft in
executor while at it --- unused fields in state nodes, that sort of thing.
2000-07-12 02:37:39 +00:00
Tom Lane 40f64064ff Update textin() and textout() to new fmgr style. This is just phase
one of updating the whole text datatype, but there are so dang many
calls of these two routines that it seems worth a separate commit.
2000-07-05 23:12:09 +00:00
Tom Lane 0f1e39643d Third round of fmgr updates: eliminate calls using fmgr() and
fmgr_faddr() in favor of new-style calls.  Lots of cleanup of
sloppy casts to use XXXGetDatum and DatumGetXXX ...
2000-05-30 04:25:00 +00:00
Tom Lane 0a7fb4e918 First round of changes for new fmgr interface. fmgr itself and the
key call sites are changed, but most called functions are still oldstyle.
An exception is that the PL managers are updated (so, for example, NULL
handling now behaves as expected in plperl and plpgsql functions).
NOTE initdb is forced due to added column in pg_proc.
2000-05-28 17:56:29 +00:00
Tom Lane 45cc0e9b27 plpgsql RAISE statement was careless about the possibility of a NULL
field value being displayed; produced coredump instead of the expected
<NULL> display.
2000-04-28 00:12:44 +00:00
Bruce Momjian 52f77df613 Ye-old pgindent run. Same 4-space tabs. 2000-04-12 17:17:23 +00:00
Tom Lane 73f5b0847b exec_simple_check_plan() must not allow a plan having initPlans or
subPlans to be considered 'simple'.  This fixes reported problem with
'return exists (select 1 from foo);' in plpgsql function.
2000-03-11 06:19:00 +00:00
Hiroshi Inoue 5b58de124e Allow SELECT .. FOR UPDATE in PL/pgSQL. 2000-02-07 03:39:13 +00:00
Tom Lane 584e646ad8 Fix a passel of problems with incorrect calls to typinput and typoutput
functions, which would lead to trouble with datatypes that paid attention
to the typelem or typmod parameters to these functions.  In particular,
incorrect code in pg_aggregate.c explains the platform-specific failures
that have been reported in NUMERIC avg().
2000-01-15 22:43:25 +00:00
Bruce Momjian b78769fda2 Fix it's and its to be correct. 2000-01-05 18:23:54 +00:00
Bruce Momjian fc955b14ea Add system indexes to match all caches.
Make all system indexes unique.
Make all cache loads use system indexes.
Rename *rel to *relid in inheritance tables.
Rename cache names to be clearer.
1999-11-22 17:56:41 +00:00
Bruce Momjian 86ef36c907 New NameStr macro to convert Name to Str. No need for var.data anymore.
Fewer calls to nameout.

Better use of RelationGetRelationName.
1999-11-07 23:08:36 +00:00
Bruce Momjian 4b2c2850bf Clean up #include in /include directory. Add scripts for checking includes. 1999-07-15 15:21:54 +00:00
Tom Lane b31aa64f4a Make exec_simple_check_plan() check for a null plan, so
that it doesn't crash when processing a utility statement.
1999-07-04 01:03:01 +00:00
Bruce Momjian 07842084fe pgindent run over code. 1999-05-25 16:15:34 +00:00
Bruce Momjian 4853495e03 Change error messages to oids come out as %u and not %d. Change has no
real affect now.
1999-05-10 00:46:32 +00:00
Tom Lane 09c5e84072 Change elog(ERROR) to get back to main loop via a plain sigsetjmp,
instead of doing a kill(self, SIGQUIT) and expecting the signal handler
to do it.  Also, clean up inconsistent definitions of the sigjmp buffer
in the several files that already referenced it.
1999-04-20 02:19:59 +00:00
Bruce Momjian 48ea8b76db Hi,
I have solved some problems with dynamic loading on NT. It is possible
to
run succesfully both trigger and plpgsql regression tests. The patch is
in
the included file "diff".

                        Dan
1999-03-22 16:45:30 +00:00
Bruce Momjian 9322950aa4 Cleanup of source files where 'return' or 'var =' is alone on a line. 1999-02-03 21:18:02 +00:00
Jan Wieck 28d8b42ca5 Speedup of PL/pgSQL by calling ExecEvalExpr() directly
instead of SPI_execp() for simple expressions.

Jan
1999-01-27 16:15:22 +00:00
Tom Lane 52065cf347 Clean up trivial compiler warning from gcc. 1999-01-17 21:53:32 +00:00
Bruce Momjian 18af384bb7 Unixware patches from Billy G. Allie. 1998-10-04 15:38:58 +00:00
Bruce Momjian fa1a8d6a97 OK, folks, here is the pgindent output. 1998-09-01 04:40:42 +00:00
Bruce Momjian af74855a60 Renaming cleanup, no pgindent yet. 1998-09-01 03:29:17 +00:00
Bruce Momjian 0c5e541a9a move plpgsql to src/pl for Jan. 1998-08-24 19:14:51 +00:00