Commit Graph

14650 Commits

Author SHA1 Message Date
Tom Lane 56b01dc9ff Make SPI set SPI_processed for CREATE TABLE AS / SELECT INTO commands;
this in turn causes CREATE TABLE AS in plpgsql to set ROW_COUNT.
This is how it behaved before 7.4; I had unintentionally changed the
behavior in a bit of sloppy micro-optimization.
2005-06-09 21:25:22 +00:00
Tom Lane dce83e76e0 Add missing #include -- mea culpa. 2005-06-09 21:01:25 +00:00
Tom Lane 3ace84594e Defend against omitted paramLengths[] array in PQsendQueryParams.
Per Volkan Yazici.
2005-06-09 20:01:16 +00:00
Tom Lane 532ca3083d Avoid bare 'struct Node;' declaration --- provokes annoying warnings
on some compilers.
2005-06-09 18:44:05 +00:00
Bruce Momjian 5c4955981e \(rs should be \\(rs, per Tom. 2005-06-09 18:40:06 +00:00
Tom Lane 82358ca936 Put a critical section around update of hash index metapage. Per
discussion with Qingqing Zhou.
2005-06-09 18:23:50 +00:00
Bruce Momjian ebc8649892 Since I needed this feature badly, I added the -n / --schema switch to
pg_restore. It restores the given schemaname only. It can be used in
conjunction with the -t and other switches to make the selection very
fine grained.

Richard van den Bergg, CISSP
2005-06-09 17:56:51 +00:00
Bruce Momjian 4d0e7b4aac Please find attached a patch (diff -c against cvs HEAD) to add a
function that accepts a double precision argument assumed to be a Unix
epoch timestamp and returns timestamp with time zone, and accompanying
documentation.

Usage:

test=# select to_timestamp(200120400);
       to_timestamp
------------------------
  1976-05-05 14:00:00+09
(1 row)

Michael Glaesemann
2005-06-09 16:35:09 +00:00
Bruce Momjian 4a5cda7bba I've created a patch which adds support for troff "-ms" output to
psql.  i.e. "\pset format troff-ms".  The patch also corrects some
problems with the "latex" format, notably defining an extra column in
the output table, and correcting some alignment issues; it also
changes the output to match the border setting as documented in the
manual page and as shown with the "aligned" format.

The troff-ms output is mostly identical to the latex output allowing
for the differences between the two typesetters.

The output should be saved in a file and piped as follows:

  cat file | tbl | troff -T ps -ms > file.ps
or
  tbl file | troff -T ps -ms > file.ps

Because it contains tabs, you'll need to redirect psql output or use
"script", rather than pasting from a terminal window, due to the tabs
which can be replaced with spaces.

Roger Leigh
2005-06-09 15:27:27 +00:00
Tom Lane a31ad27fc5 Simplify the planner's join clause management by storing join clauses
of a relation in a flat 'joininfo' list.  The former arrangement grouped
the join clauses according to the set of unjoined relids used in each;
however, profiling on test cases involving lots of joins proves that
that data structure is a net loss.  It takes more time to group the
join clauses together than is saved by avoiding duplicate tests later.
It doesn't help any that there are usually not more than one or two
clauses per group ...
2005-06-09 04:19:00 +00:00
Tom Lane e3a33a9a9f Marginal hack to avoid spending a lot of time in find_join_rel during
large planning problems: when the list of join rels gets too long, make
an auxiliary hash table that hashes on the identifying Bitmapset.
2005-06-08 23:02:05 +00:00
Tom Lane 77c168a836 Remove grammar productions for prefix and postfix % and ^ operators,
as well as the existing pg_catalog entries for prefix and postfix %.
These have never been documented, though they did appear in one old
regression test.  This avoids surprising behavior in cases like
"SELECT -25 % -10".  Per recent discussion.
Note: although there is a catalog change here, I did not force initdb
since there's no harm in leaving the inaccessible entries in one's
copy of pg_operator.
2005-06-08 21:15:29 +00:00
Tom Lane f5b2f60bd1 Change WAL-logging scheme for multixacts to be more like regular
transaction IDs, rather than like subtrans; in particular, the information
now survives a database restart.  Per previous discussion, this is
essential for PITR log shipping and for 2PC.
2005-06-08 15:50:28 +00:00
Neil Conway 593badd30b Correct an omission in the syntax error message emitted by EXECUTE INTO
in pl/pgsql.
2005-06-08 00:49:36 +00:00
Bruce Momjian fbc4edfba7 Mention ipcrm and ipcclean in error message. 2005-06-07 16:54:18 +00:00
Tom Lane c14f2ba7a4 Use just NULL not NULL::TEXT --- the latter coding is unnecessary and
not schema-safe.  Per report from Jochem van Dieten.
2005-06-07 14:04:48 +00:00
Neil Conway 657c098e41 Add a function lastval(), which returns the value returned by the
last nextval() or setval() performed by the current session. Update the
docs, add regression tests, and bump the catalog version. Patch from
Dennis Björklund, various improvements by Neil Conway.
2005-06-07 07:08:35 +00:00
Neil Conway c59887f916 Add support for an optional INTO clause to PL/PgSQL's EXECUTE command.
This allows the result of executing a SELECT to be assigned to a row
variable, record variable, or list of scalars. Docs and regression tests
updated. Per Pavel Stehule, improvements and cleanup by Neil Conway.
2005-06-07 02:47:23 +00:00
Bruce Momjian 1b000116fb Ipcrm -> ipcclean in error message:
---------------------------------------------------------------------------

While playing around, I got the following error message:

--
FATAL:  pre-existing shared memory block (key 5432001, ID 90898435) is
still in use
HINT:  If you're sure there are no old server processes still running,
remove the shared memory block with the command "ipcrm", or just delete
the file "/home/hlinnaka/pgsql/data/postmaster.pid".
---

Thats normal because I used "kill -9 postmaster" to shut down.

The hint advises me to use "ipcrm", but there's the "ipcclean" script in
bin for just this purpose. The hint should probably advise to use
ipcclean.

The attached patch replaces all occurances of "ipcrm" with "ipcclean" in
src/backend/utils/init/miscinit.c and all the translations in
src/backend/po.

While reviewing the patch, I noticed a likely typo in hr.po. While I
don't
speak Croatian, the translation seems to advise to use the "icpm(1)"
command. I changed that to "ipcclean" too.

Heikki Linnakangas
2005-06-07 01:36:40 +00:00
Tom Lane ee7ac7b11e Modify XLogInsert API to make callers specify whether pages to be backed
up have the standard layout with unused space between pd_lower and pd_upper.
When this is set, XLogInsert will omit the unused space without bothering
to scan it to see if it's zero.  That saves time in XLogInsert, and also
allows reversion of my earlier patch to make PageRepairFragmentation et al
explicitly re-zero freed space.  Per suggestion by Heikki Linnakangas.
2005-06-06 20:22:58 +00:00
Tom Lane 4c8495a1f2 Remove the mostly-stubbed-out-anyway support routines for WAL UNDO.
That code is never going to be used in the foreseeable future, and
where it's more than a stub it's making the redo routines harder to
read.
2005-06-06 17:01:25 +00:00
Tom Lane 9a586fe0c5 Nab some low-hanging fruit: replace the planner's base_rel_list and
other_rel_list with a single array indexed by rangetable index.
This reduces find_base_rel from O(N) to O(1) without any real penalty.
While find_base_rel isn't one of the major bottlenecks in any profile
I've seen so far, it was starting to creep up on the radar screen
for complex queries --- so might as well fix it.
2005-06-06 04:13:36 +00:00
Tom Lane 9ab4d98168 Remove planner's private fields from Query struct, and put them into
a new PlannerInfo struct, which is passed around instead of the bare
Query in all the planning code.  This commit is essentially just a
code-beautification exercise, but it does open the door to making
larger changes to the planner data structures without having to muck
with the widely-known Query struct.
2005-06-05 22:32:58 +00:00
Bruce Momjian bebe7c5600 Here's a patch to do the following:
1. Rename spi_return_next to return_next.
2. Add a new test for return_next.
3. Update the expected output.
4. Update the documentation.

Abhijit Menon-Sen
2005-06-05 03:16:42 +00:00
Tom Lane 27bdb0c40d Code for SET/SHOW TIME ZONE with a fixed-interval timezone was not
prepared for HAVE_INT64_TIMESTAMP.  Per report from Guillaume Beaudoin.
2005-06-05 01:48:34 +00:00
Tom Lane a4996a8953 Replace the parser's namespace tree (which formerly had the same
representation as the jointree) with two lists of RTEs, one showing
the RTEs accessible by qualified names, and the other showing the RTEs
accessible by unqualified names.  I think this is conceptually simpler
than what we did before, and it's sure a whole lot easier to search.
This seems to eliminate the parse-time bottleneck for deeply nested
JOIN structures that was exhibited by phil@vodafone.
2005-06-05 00:38:11 +00:00
Bruce Momjian 24af7d4b68 Back out patch:
---------------------------------------------------------------------------

Tom Lane <tgl@sss.pgh.pa.us> writes:
> a_ogawa <a_ogawa@hi-ho.ne.jp> writes:
> > It is a reasonable idea. However, the majority part of MemSet was not
> > able to be avoided by this idea. Because the per-tuple contexts are used
> > at the early stage of executor.
>
> Drat.  Well, what about changing that?  We could introduce additional
> contexts or change the startup behavior so that the ones that are
> frequently reset don't have any data in them unless you are working
> with pass-by-ref values inside the inner loop.

That might be possible. However, I think that we should change only
aset.c about this article.
I thought further: We can check whether context was used from the last
reset even when blocks list is not empty. Please see attached patch.
2005-06-04 22:57:22 +00:00
Bruce Momjian 954108f92d Add comment for multi-byte computation. 2005-06-04 20:56:13 +00:00
Bruce Momjian 72c53ac3a7 Allow kerberos name and username case sensitivity to be specified from
postgresql.conf.

---------------------------------------------------------------------------


Here's an updated version of the patch, with the following changes:

1) No longer uses "service name" as "application version". It's instead
hardcoded as "postgres". It could be argued that this part should be
backpatched to 8.0, but it doesn't make a big difference until you can
start changing it with GUC / connection parameters. This change only
affects kerberos 5, not 4.

2) Now downcases kerberos usernames when the client is running on win32.

3) Adds guc option for "krb_caseins_users" to make the server ignore
case mismatch which is required by some KDCs such as Active Directory.
Off by default, per discussion with Tom. This change only affects
kerberos 5, not 4.

4) Updated so it doesn't conflict with the rendevouz/bonjour patch
already in ;-)

Magnus Hagander
2005-06-04 20:42:43 +00:00
Bruce Momjian d995014fac At 2005-05-21 20:18:50 +0530, ams@oryx.com wrote:
>
> > The second issue is where plperl returns a large result set.

I have attached the following seven patches to address this problem:

1. Trivial. Replaces some errant spaces with tabs.

2. Trivial. Fixes the spelling of Jan's name, and gets rid of many
   inane, useless, annoying, and often misleading comments. Here's
   a sample: "plperl_init_all() - Initialize all".

   (I have tried to add some useful comments here and there, and will
   continue to do so now and again.)

3. Trivial. Splits up some long lines.

4. Converts SRFs in PL/Perl to use a Tuplestore and SFRM_Materialize
   to return the result set, based on the PL/PgSQL model.

   There are two major consequences: result sets will spill to disk when
   they can no longer fit in work_mem; and "select foo_srf()" no longer
   works. (I didn't lose sleep over the latter, since that form is not
   valid in PL/PgSQL, and it's not documented in PL/Perl.)

5. Trivial, but important. Fixes use of "undef" instead of undef. This
   would cause empty functions to fail in bizarre ways. I suspect that
   there's still another (old) bug here. I'll investigate further.

6. Moves the majority of (4) out into a new plperl_return_next()
   function, to make it possible to expose the functionality to
   Perl; cleans up some of the code besides.

7. Add an spi_return_next function for use in Perl code.

If you want to apply the patches and try them out, 8-composite.diff is
what you should use. (Note: my patches depend upon Andrew's use-strict
and %_SHARED patches being applied.)

Here's something to try:

    create or replace function foo() returns setof record as $$
    $i = 0;
    for ("World", "PostgreSQL", "PL/Perl") {
        spi_return_next({f1=>++$i, f2=>'Hello', f3=>$_});
    }
    return;
    $$ language plperl;
    select * from foo() as (f1 integer, f2 text, f3 text);

(Many thanks to Andrews Dunstan and Supernews for their help.)

Abhijit Menon-Sen
2005-06-04 20:33:06 +00:00
Bruce Momjian 3cf1fd3263 Tom Lane <tgl@sss.pgh.pa.us> writes:
> a_ogawa <a_ogawa@hi-ho.ne.jp> writes:
> > It is a reasonable idea. However, the majority part of MemSet was not
> > able to be avoided by this idea. Because the per-tuple contexts are used
> > at the early stage of executor.
>
> Drat.  Well, what about changing that?  We could introduce additional
> contexts or change the startup behavior so that the ones that are
> frequently reset don't have any data in them unless you are working
> with pass-by-ref values inside the inner loop.

That might be possible. However, I think that we should change only
aset.c about this article.
I thought further: We can check whether context was used from the last
reset even when blocks list is not empty. Please see attached patch.

The effect of the patch that I measured is as follows:

o Execution time that executed the SQL ten times.
(1)Linux(CPU: Pentium III, Compiler option: -O2)
 - original: 24.960s
 - patched : 23.114s

(2)Linux(CPU: Pentium 4, Compiler option: -O2)
 - original: 8.730s
 - patched : 7.962s

(3)Solaris(CPU: Ultra SPARC III, Compiler option: -O2)
 - original: 37.0s
 - patched : 33.7s

Atsushi Ogawa (a_ogawa)
2005-06-04 20:14:12 +00:00
Tom Lane e18e8f8735 Change expandRTE() and ResolveNew() back to taking just the single
RTE of interest, rather than the whole rangetable list.  This makes
the API more understandable and avoids duplicate RTE lookups.  This
patch reverts no-longer-needed portions of my patch of 2004-08-19.
2005-06-04 19:19:42 +00:00
Bruce Momjian fb91a83e0e Back out make_mkid change. 2005-06-04 18:20:43 +00:00
Bruce Momjian 00750f3f30 Improve readability of config location params by adding newline. 2005-06-04 18:13:59 +00:00
Bruce Momjian 1bc9235224 Fix NUMERIC modulus to properly truncate division in computation.
Division rounding was causing incorrect results.  Test case:

	test=> SELECT 12345678901234567890 % 123;
	 ?column?
	----------
	       78
	(1 row)

Was returning -45.
2005-06-04 14:12:50 +00:00
Neil Conway 5788cca558 Remove unused 'printCost' field from ExplainState, and simplify the code
accordingly (this field was always initialized to true). Patch from
Alvaro Herrera.
2005-06-04 02:07:09 +00:00
Tom Lane ba42002461 Revise handling of dropped columns in JOIN alias lists to avoid a
performance problem pointed out by phil@vodafone: to wit, we were
spending O(N^2) time to check dropped-ness in an N-deep join tree,
even in the case where the tree was freshly constructed and couldn't
possibly mention any dropped columns.  Instead of recursing in
get_rte_attribute_is_dropped(), change the data structure definition:
the joinaliasvars list of a JOIN RTE must have a NULL Const instead
of a Var at any position that references a now-dropped column.  This
costs nothing during normal parse-rewrite-plan path, and instead we
have a linear-time update to make when loading a stored rule that
might contain now-dropped columns.  While at it, move the responsibility
for acquring locks on relations referenced by rules into this separate
function (which I therefore chose to call AcquireRewriteLocks).
This saves effort --- namely, duplicated lock grabs in parser and rewriter
--- in the normal path at a cost of one extra non-locked heap_open()
in the stored-rule path; seems a good tradeoff.  A fringe benefit is
that it is now *much* clearer that we acquire lock on relations referenced
in rules before we make any rewriter decisions based on their properties.
(I don't know of any bug of that ilk, but it wasn't exactly clear before.)
2005-06-03 23:05:30 +00:00
Tom Lane 3531383224 Just noticed that you can't Query-Cancel a long planner run, because
no part of the planner did CHECK_FOR_INTERRUPTS().  Add one in a
suitably strategic spot.
2005-06-03 19:00:12 +00:00
Tom Lane b5ebef7c41 Push enable/disable of notify and catchup interrupts all the way down
to just around the bare recv() call that gets a command from the client.
The former placement in PostgresMain was unsafe because the intermediate
processing layers (especially SSL) use facilities such as malloc that are
not necessarily re-entrant.  Per report from counterstorm.com.
2005-06-02 21:03:25 +00:00
Tom Lane 8dfb616606 The no-lexer-backup speedup hadn't been there a week before somebody
broke it.  Maybe we do need an automated check ...
2005-06-02 17:45:19 +00:00
Michael Meskes 2d5d691d15 - Fixed memory leak in ecpglib by adding some missing free() commands.
- Added patch by Gavin Scott <gavin@planetacetech.com> for Intel 64bit hardware.
2005-06-02 12:35:11 +00:00
Tom Lane 21fda22ec4 Change CRCs in WAL records from 64bit to 32bit for performance reasons.
Instead of a separate CRC on each backup block, include backup blocks
in their parent WAL record's CRC; this is important to ensure that the
backup block really goes with the WAL record, ie there was not a page
tear right at the start of the backup block.  Implement a simple form
of compression of backup blocks: drop any run of zeroes starting at
pd_lower, so as not to store the unused 'hole' that commonly exists in
PG heap and index pages.  Tweak PageRepairFragmentation and related
routines to ensure they keep the unused space zeroed, so that the above
compression method remains effective.  All per recent discussions.
2005-06-02 05:55:29 +00:00
Bruce Momjian b51366396b Add support for \x hex strings in psql variables. 2005-06-02 01:23:48 +00:00
Bruce Momjian 65537ac1b4 Add support for \x hex escapes in backend strings. Octal was already
supported.  This follows the C standard escapes.
2005-06-02 01:23:08 +00:00
Bruce Momjian 202e6e73e6 Add support for \x hex escapes in COPY.
Sergey Ten
2005-06-02 01:21:22 +00:00
Bruce Momjian b6e5c4ad0a Fix log_statement to properly recognize SELECT INTO and CREATE TABLE AS
and DDL statements.

Backpatch fix to 8.0.X.

Per report from Murthy Kambhampaty
2005-06-01 23:27:03 +00:00
Tom Lane 1e85fa2008 patternsel() was improperly stripping RelabelType from the derived
expressions it constructed, causing scalarineqsel to become confused
if the underlying variable was of a domain type.  Per report from
Kevin Grittner.
2005-06-01 17:05:11 +00:00
Tom Lane a91fa39028 Add test to WAL replay to verify that xl_prev points back to the previous
WAL record; this is necessary to be sure we recognize stale WAL records
when a WAL page was only partially written during a system crash.
2005-05-31 19:10:28 +00:00
Tom Lane 982888bddc Fix information_schema for OUT and INOUT parameters. 2005-05-31 03:36:24 +00:00
Tom Lane 6dfe64ee57 Teach ruleutils to drill down into RECORD-type Vars in the same way
that the parser now can, so that it can reverse-list cases involving
FieldSelect from a RECORD Var.
2005-05-31 03:03:59 +00:00
Tom Lane 83b72ee286 ParseComplexProjection should make use of expandRecordVariable so that
it can handle cases like (foo.x).y where foo is a subquery and x is
a function-returning-RECORD RTE in that subquery.
2005-05-31 01:03:23 +00:00
Tom Lane 978129f28e Document get_call_result_type() and friends; mark TypeGetTupleDesc()
and RelationNameGetTupleDesc() as deprecated; remove uses of the
latter in the contrib library.  Along the way, clean up crosstab()
code and documentation a little.
2005-05-30 23:09:07 +00:00
Bruce Momjian 25146d3c29 Add support for NUMERIC ^ NUMERIC based on power(numeric, numeric). 2005-05-30 20:59:17 +00:00
Tom Lane ac25dbd84b Add support for FUNCTION RTEs to build_physical_tlist(), so that the
physical-tlist optimization can be applied to FunctionScan nodes as well
as regular tables and SubqueryScans.
2005-05-30 18:55:49 +00:00
Bruce Momjian 3e8dbc846c Support only octal for psql PROMPT values, rather than the confusing
hex/decimal/octal.  Documentation already updated.

BACKWARD COMPATIBLE CHANGE
2005-05-30 18:28:11 +00:00
Bruce Momjian 33294d57c7 Use {xqoctesc} lex macro now that \ddd is standard. 2005-05-30 16:48:47 +00:00
Bruce Momjian f13c132072 Have psql escape bytes in strings for variables follow the backend
conventions of only allowing octal, like \045.  Remove support for
\decimal, \0octal, and \0xhex which matches the strtol() function but
didn't make sense with backslashes.

These now return the same character:

	test=> \set x '\54'
	test=> \echo :x
	,
	test=> \set x '\054'
	test=> \echo :x
	,

THIS IS A BACKWARD COMPATIBILITY CHANGE.
2005-05-30 14:50:35 +00:00
Neil Conway adfeef55cb When enqueueing after-row triggers for updates of a table with a foreign
key, compare the new and old row versions. If the foreign key column has
not changed, we needn't enqueue the trigger, since the update cannot
violate the foreign key. This optimization was previously applied in the
RI trigger function, but it is more efficient to avoid firing the trigger
altogether. Per recent discussion on pgsql-hackers.

Also add a regression test for some unintuitive foreign key behavior, and
refactor some code that deals with the OIDs of the various RI trigger
functions.
2005-05-30 07:20:59 +00:00
Neil Conway f99b75b0a0 Create separate ON INSERT and ON UPDATE triggers on tables with foreign
keys, rather than a single trigger for both events. This should not change
functionality, but it is more consistent: previously, there were trigger
functions for both "check_insert" and "check_update", but the former was
used for both events.

Bump catalog version number (not strictly necessary, but best to be
cautious).
2005-05-30 06:52:38 +00:00
Tom Lane 0832fb74df Fix longstanding oversight in ruleutils.c: it doesn't regurgitate
a FOR UPDATE clause, if one is present.
2005-05-30 01:57:27 +00:00
Tom Lane cfd9be939e Change the UNKNOWN type to have an internal representation matching
cstring, rather than text, so as to eliminate useless conversions
inside the parser.  Per recent discussion.
2005-05-30 01:20:50 +00:00
Tom Lane c8f81df41b Skip eval_const_expressions when the query is such that the expression
would be evaluated only once anyway (ie, it's just a SELECT with no
FROM or an INSERT ... VALUES).  The planner can't do it any faster than
the executor, so no point in an extra copying of the expression tree.
2005-05-30 01:04:44 +00:00
Tom Lane 03a542ba63 Avoid unnecessary fetch from pg_shadow in the normal case in
pg_class_aclmask().  We only need to do this when we have to check
pg_shadow.usecatupd, and that's not relevant unless the target table
is a system catalog.  So we can usually avoid one syscache lookup.
2005-05-29 23:38:05 +00:00
Tom Lane 140b078d2a Improve LockAcquire API per my recent proposal. All error conditions
are now reported via elog, eliminating the need to test the result code
at most call sites.  Make it possible for the caller to distinguish a
freshly acquired lock from one already held in the current transaction.
Use that capability to avoid redundant AcceptInvalidationMessages() calls
in LockRelation().
2005-05-29 22:45:02 +00:00
Tom Lane 299c442077 Make superuser.c maintain a simple one-entry cache holding the superuser
status of the most recently queried userid.  Since the common pattern is
many successive queries about the same user (ie, the current user) this
can save a lot of syscache probes.
2005-05-29 20:38:06 +00:00
Tom Lane db86f29617 Marginal hack to save a little bit of time in bpcharin() when typmod is -1,
which is a common case.
2005-05-29 20:15:59 +00:00
Tom Lane 7cac50271d Avoid unnecessary call of rangeTableEntry_used() for the result relation
of a query.
2005-05-29 18:34:57 +00:00
Tom Lane d66daabec9 Remove typeidIsValid() checks in can_coerce_type(). These checks
were pretty expensive and I believe the case they were put in to
defend against can no longer arise, now that we have dependency checks
to prevent deletion of a type entry that is still referenced.  Certainly
the example given in the CVS log entry can't happen anymore.
Since this was the only use of typeidIsValid(), remove the routine too.
2005-05-29 18:24:14 +00:00
Tom Lane bbc048319f expandRTE and get_rte_attribute_type mistakenly always imputed typmod -1
to columns of an RTE that was a function returning RECORD with a column
definition list.  Apparently no one has tried to use non-default typmod
with a function returning RECORD before.
2005-05-29 17:10:23 +00:00
Tom Lane e92a88272e Modify hash_search() API to prevent future occurrences of the error
spotted by Qingqing Zhou.  The HASH_ENTER action now automatically
fails with elog(ERROR) on out-of-memory --- which incidentally lets
us eliminate duplicate error checks in quite a bunch of places.  If
you really need the old return-NULL-on-out-of-memory behavior, you
can ask for HASH_ENTER_NULL.  But there is now an Assert in that path
checking that you aren't hoping to get that behavior in a palloc-based
hash table.
Along the way, remove the old HASH_FIND_SAVE/HASH_REMOVE_SAVED actions,
which were not being used anywhere anymore, and were surely too ugly
and unsafe to want to see revived again.
2005-05-29 04:23:07 +00:00
Tom Lane f8a051604f Bgwriter should PANIC if it runs out of memory for pending-fsyncs
hash table.  This is a pretty unlikely scenario, since the table
should be tiny, but we can't guarantee continued correct operation
if it does occur.  Spotted by Qingqing Zhou.
2005-05-28 17:21:32 +00:00
Tom Lane 6d9ee03148 get_expr_result_type has to be prepared to pull type information
from a RECORD Const node, because that's what it may be faced with
after constant-folding of a function returning RECORD.  Per example
from Michael Fuhr.
2005-05-28 05:10:47 +00:00
Tom Lane 32e8fc4a28 Arrange to cache fmgr lookup information for an index's access method
routines in the index's relcache entry, instead of doing a fresh fmgr_info
on every index access.  We were already doing this for the index's opclass
support functions; not sure why we didn't think to do it for the AM
functions too.  This supersedes the former method of caching (only)
amgettuple in indexscan scan descriptors; it's an improvement because the
function lookup can be amortized across multiple statements instead of
being repeated for each statement.  Even though lookup for builtin
functions is pretty cheap, this seems to drop a percent or two off some
simple benchmarks.
2005-05-27 23:31:21 +00:00
Bruce Momjian d4b50caf25 Display only 9 subsecond digits instead of 10 for time values, for
consistency and to prevent rounding for days < 30.  Also round off all
trailing zeros, rather than leaving an even number of digits.
2005-05-27 21:31:23 +00:00
Bruce Momjian 5dafb69e17 Re-order 'else' clause for clarity. 2005-05-27 18:33:30 +00:00
Bruce Momjian fbdb203a39 Back out part of patch that should be applied later. 2005-05-27 15:16:45 +00:00
Bruce Momjian 22f0303023 Fix compile of entab to use stdarg.h. Clean up includes.
Marko Kreen
2005-05-27 15:15:31 +00:00
Neil Conway a4374f9070 Remove second argument from textToQualifiedNameList(), as it is no longer
used. From Jaime Casanova.
2005-05-27 00:57:49 +00:00
Bruce Momjian 1b3bb23cc8 Use Abs() macro to replace ? :. 2005-05-26 16:44:05 +00:00
Bruce Momjian f35d493d16 Back out:
Display only 9 not 10 digits of precision for timestamp values when
using non-integer timestamps.  This prevents the display of rounding
errors for common values like days < 32.
2005-05-26 15:26:00 +00:00
Bruce Momjian dabde323b2 Back out SQLSTATE and SQLERRM support. 2005-05-26 04:08:32 +00:00
Bruce Momjian 4c862b18f9 Display only 9 not 10 digits of precision for timestamp values when
using non-integer timestamps.  This prevents the display of rounding
errors for common values like days < 32.
2005-05-26 03:48:25 +00:00
Neil Conway b3195dae49 Minor cleanup for recent SQLSTATE / SQLERRM patch: spell "successful"
correctly, style fixes.
2005-05-26 03:18:53 +00:00
Neil Conway 63e0d612f5 Adjust datetime parsing to be more robust. We now pass the length of the
working buffer into ParseDateTime() and reject too-long input there,
rather than checking the length of the input string before calling
ParseDateTime(). The old method was bogus because ParseDateTime() can use
a variable amount of working space, depending on the content of the
input string (e.g. how many fields need to be NUL terminated). This fixes
a minor stack overrun -- I don't _think_ it's exploitable, although I
won't claim to be an expert.

Along the way, fix a bug reported by Mark Dilger: the working buffer
allocated by interval_in() was too short, which resulted in rejecting
some perfectly valid interval input values. I added a regression test for
this fix.
2005-05-26 02:04:14 +00:00
Tom Lane 15e4d1e2a7 Tweak the backend scanner (and psqlscan.l, which must track the backend
scanner anyway) to avoid having any backup states.  According to the
flex manual, this should speed things up, and indeed the backend scanner
is about a third faster according to some quick profiling checks.
I haven't tried to measure the speed change in psql, but it probably
is similar.
2005-05-26 01:24:29 +00:00
Bruce Momjian 38af680ad5 Add PL/pgSQL SQLSTATE and SQLERRM support which sets these values on
error.

Pavel Stehule
2005-05-26 00:16:31 +00:00
Bruce Momjian 8c792fe9cb At the head of wchareq, length of (multibyte) character is compared by
using pg_mblen. Therefore, pg_mblen is executed many times, and it
becomes a bottleneck.

This patch makes a short cut, and reduces execution frequency of
pg_mblen by comparing the first byte first.

a_ogawa
2005-05-25 22:59:33 +00:00
Bruce Momjian bbb586ff21 Quick patch to adress a recent concern on the mailing list
about adding an errant "TO" when we already have a TO. Since
TO cannot be a valid column name (we must quote it), we can
simply ignore the tab-completion if the previous word
was a "TO".

Greg Sabino Mullane
2005-05-25 22:12:05 +00:00
Bruce Momjian b492c3accc Add parentheses to macros when args are used in computations. Without
them, the executation behavior could be unexpected.
2005-05-25 21:40:43 +00:00
Tom Lane 872c1497fc Previous fix for "x FULL JOIN y ON true" failed to handle the case
where there was also a WHERE-clause restriction that applied to the
join.  The check on restrictlist == NIL is really unnecessary anyway,
because select_mergejoin_clauses already checked for and complained
about any unmergejoinable join clauses.  So just take it out.
2005-05-24 18:02:31 +00:00
Tom Lane bc6444dc6a Fix PL makefiles to support running regression tests in VPATH builds. 2005-05-24 17:07:41 +00:00
Tom Lane 1a022f71d8 Add -I$(srcdir) to CPPFLAGS to make psqlscan.c compile in vpath builds.
Not sure why this hasn't been reported before; perhaps it is not needed
with newer gcc versions, but it definitely fails here.
2005-05-24 16:45:23 +00:00
Tatsuo Ishii a90e9d662e Inserting 5 characters into char(10) does not produce 5 padding spaces
if they are two-byte multibyte characters. Same thing can be happen
if octet_length(multibyte_chars) == n where n is char(n).
Long standing bug since 7.3 days. Per report and fix from Yoshiyuki Asaba.
2005-05-24 15:45:34 +00:00
Neil Conway 11a0c3741f Add regression tests for previously-untested PL/Perl features. From
Andrew Dunstan.
2005-05-24 08:05:36 +00:00
Neil Conway 443f21737d Fix weird indentation of function return type. 2005-05-24 07:16:27 +00:00
Bruce Momjian c0ac38d082 Log queries for client-side prepare/execute. Simon Riggs
Log prepare query during execute.  Bruce Momjian
2005-05-24 04:18:04 +00:00
Bruce Momjian f534820d4d Put parentheses around use of macro arguments in FMODULO and TMODULO. 2005-05-24 04:03:01 +00:00
Bruce Momjian 09ff9dbe2b Remove more extraneous parentheses in date/time functions. 2005-05-24 02:09:45 +00:00
Bruce Momjian 4550c1e519 More macro cleanups for date/time. 2005-05-23 21:54:02 +00:00
Bruce Momjian 5ebaae801c Add datetime macros for constants, for clarity:
#define SECS_PER_DAY  86400
#define USECS_PER_DAY INT64CONST(86400000000)
#define USECS_PER_HOUR    INT64CONST(3600000000)
#define USECS_PER_MINUTE INT64CONST(60000000)
#define USECS_PER_SEC INT64CONST(1000000)
2005-05-23 18:56:55 +00:00
Bruce Momjian 33d0d4ce96 Remove unnecessary parentheses in datetime/timestamp code. 2005-05-23 17:13:14 +00:00
Tom Lane c1393173aa Avoid redundant relation lock grabs during planning, and make sure
that we acquire a lock on relations added to the query due to inheritance.
Formerly, no such lock was held throughout planning, which meant that
a schema change could occur to invalidate the plan before it's even
been completed.
2005-05-23 03:01:14 +00:00
Neil Conway 353f111f98 Fix typo in PL/Perl Safe.pm initialization that prevented the proper
sharing of %_SHARED. From Andrew Dunstan.
2005-05-23 01:57:51 +00:00
Tom Lane e2159f3842 Teach the planner to remove SubqueryScan nodes from the plan if they
aren't doing anything useful (ie, neither selection nor projection).
Also, extend to SubqueryScan the hacks already in place to avoid
unnecessary ExecProject calls when the result would just be the same
tuple the subquery already delivered.  This saves some overhead in
UNION and other set operations, as well as avoiding overhead for
unflatten-able subqueries.  Per example from Sokolov Yura.
2005-05-22 22:30:20 +00:00
Bruce Momjian 875813439d Remove excess parens, use Abs instead of : ?. 2005-05-21 03:38:05 +00:00
Bruce Momjian 6dc7760ac3 Add support for wal_fsync_writethrough for Darwin, and restructure the
code to better handle writethrough.

Chris Campbell
2005-05-20 14:53:26 +00:00
Neil Conway f3567eeaf2 Implement md5(bytea), update regression tests and documentation. Patch
from Abhijit Menon-Sen, minor editorialization from Neil Conway. Also,
improve md5(text) to allocate a constant-sized buffer on the stack
rather than via palloc.

Catalog version bumped.
2005-05-20 01:29:56 +00:00
Tom Lane ff0c143a3b Make a comment pgindent-proof, per suggestion from Alvaro. 2005-05-19 23:58:51 +00:00
Tom Lane f519d04a43 Update comment that I missed the first time around. 2005-05-19 23:57:11 +00:00
Tom Lane 191b13aaca Factor out lock cleanup code that is needed in several places in lock.c.
Also, remove the rather useless return value of LockReleaseAll.  Change
response to detection of corruption in the shared lock tables to PANIC,
since that is the only way of cleaning up fully.
Originally an idea of Heikki Linnakangas, variously hacked on by
Alvaro Herrera and Tom Lane.
2005-05-19 23:30:18 +00:00
Tom Lane ee3b71f6bc Split the shared-memory array of PGPROC pointers out of the sinval
communication structure, and make it its own module with its own lock.
This should reduce contention at least a little, and it definitely makes
the code seem cleaner.  Per my recent proposal.
2005-05-19 21:35:48 +00:00
Neil Conway 6910032a56 Upon closer inspection, Greg's psql tab completion patch leaks memory.
Fix the leak, and add a comment to note that the return value of
previous_word must be free'd.
2005-05-18 05:01:10 +00:00
Neil Conway 4c1f9a0f0b psql tab completion improvements, from Greg Sabino Mullane:
* Made DELETE into "DELETE FROM"
* Moved ANALZYE to the end of the list to ease EXPLAIN / VACUUM
  conflicts
* Removed the ANALYZE xx semicolon completion: we don't do that anywhere
  else
* Add DECLARE support
* Add parens for DROP AGGREGATE
* Add "CASCADE | RESTRICT" for DROP xx
* Make EXPLAIN <tab> a lot smarter
* GROUP "BY" and ORDER "BY"
* "ISOLATION" becomes "ISOLATION LEVEL"
* Fix error in which REVOKE xx ON yy was receiving "TO", now gets "FROM"
* Add GRANT/REVOKE xx ON yy TO/FROM choices: usernames, GROUP, PUBLIC
* PREPARE xx <tab> AS "SELECT | INSERT | UPDATE | DELETE"
* Add = at end of UPDATE xx SET yy
* Beef up VACUUM stuff
2005-05-18 04:47:40 +00:00
Tom Lane a9c4c9cd52 Extend the pg_locks system view so that it can fully display all lock
types, as per recent discussion.
2005-05-17 21:46:11 +00:00
Tom Lane 4e7d6f5349 Add a --dbname option to the pg_regress script, and use pl_regression
for testing PLs and contrib_regression for testing contrib, instead of
overwriting the core system's regression database as formerly done.
Andrew Dunstan
2005-05-17 18:26:23 +00:00
Tom Lane f9ad8a2802 Guard against duplicate IDs in input file in SortTocFromFile().
Per report from Brian Hackett.
2005-05-17 17:30:29 +00:00
Neil Conway c891e05f26 Cleanup GiST header files. Since GiST extensions are often written as
external projects, we should be careful about what parts of the GiST
API are considered implementation details, and which are part of the
public API. Therefore, I've moved internal-only declarations into
gist_private.h -- future backward-incompatible changes to gist.h should
be made with care, to avoid needlessly breaking external GiST extensions.

Also did some related header cleanup: remove some unnecessary #includes
from gist.h, and remove some unused definitions: isAttByVal(), _gistdump(),
and GISTNStrategies.
2005-05-17 03:34:18 +00:00
Neil Conway eda6dd32d1 GiST improvements:
- make sure we always invoke user-supplied GiST methods in a short-lived
  memory context. This means the backend isn't exposed to any memory leaks
  that be in those methods (in fact, it is probably a net loss for most
  GiST methods to bother manually freeing memory now). This also means
  we can do away with a lot of ugly manual memory management in the
  GiST code itself.

- keep the current page of a GiST index scan pinned, rather than doing a
  ReadBuffer() for each tuple produced by the scan. Since ReadBuffer() is
  expensive, this is a perf. win

- implement dead tuple killing for GiST indexes (which is easy to do, now
  that we keep a pin on the current scan page). Now all the builtin indexes
  implement dead tuple killing.

- cleanup a lot of ugly code in GiST
2005-05-17 00:59:30 +00:00
Tom Lane da56e57695 Modify tidbitmap.c to avoid creating a hash table until there is more
than one heap page represented in the bitmap.  This is a bit ugly but
it cuts overhead fairly effectively in simple join cases.  Per example
from Sergey Koposov.
2005-05-17 00:43:47 +00:00
Neil Conway 3994ffb479 Fix a few minor mistakes in header comments. From Qingqing Zhou. 2005-05-16 05:52:13 +00:00
Tom Lane 7e94998c89 Adjust out-of-date comment. 2005-05-16 00:19:04 +00:00
Tom Lane 2ef172a2a4 Fix latent bug in ExecSeqRestrPos: it leaves the plan node's result slot
in an inconsistent state.  (This is only latent because in reality
ExecSeqRestrPos is dead code at the moment ... but someday maybe it won't
be.)  Add some comments about what the API for plan node mark/restore
actually is, because it's not immediately obvious.
2005-05-15 21:19:55 +00:00
Neil Conway eb0d00a9be Various style cleanups for GiST; no changes to functionality. 2005-05-15 04:08:29 +00:00
Bruce Momjian c9a382b2ed Rename Rendezvous to Bonjour to match OS/X renaming. 2005-05-15 00:26:19 +00:00
Tom Lane c8a6b52705 Further marginal speed hacking: in MemoryContextReset, don't call
MemoryContextResetChildren unless necessary.
2005-05-14 23:16:29 +00:00
Tom Lane fabef3044a Minor refactoring to eliminate duplicate code and make startup a
tad faster.
2005-05-14 21:29:23 +00:00
Tom Lane 05b4293bd8 Minor speed hacks in AllocSetReset: avoid clearing the freelist headers
when the blocks list is empty (there can surely be no freelist items if
the context contains no memory), and use MemSetAligned not MemSet to
clear the headers (we assume alignof(pointer) >= alignof(int32)).
Per discussion with Atsushi Ogawa.  He proposes some further hacking
that I'm not yet sold on, but these two changes are unconditional wins
since there is no case in which they make things slower.
2005-05-14 20:29:13 +00:00
Tom Lane 0ff7a2c2ad Convert the existing regression test scripts for the various optional
PLs to use the standard pg_regress infrastructure.  No changes in the
tests themselves.  Andrew Dunstan
2005-05-14 17:55:22 +00:00
Tom Lane 184e7a73a5 Revise nodeMergejoin in light of example provided by Guillaume Smet.
When one side of the join has a NULL, we don't want to uselessly try
to match it against every remaining tuple of the other side.  While
at it, rewrite the comparison machinery to avoid multiple evaluations
of the left and right input expressions and to use a btree comparator
where available, instead of double operator calls.  Also revise the
state machine to eliminate redundant comparisons and hopefully make it
more readable too.
2005-05-13 21:20:16 +00:00
Bruce Momjian 2979334d47 Add -N make flag to bcc builds from /src dir. 2005-05-13 18:12:35 +00:00
Neil Conway 167bc6c621 Add regression test for consecutive newlines in COPY CSV mode. (There is
no bug related to this functionality in HEAD, but it's worth adding a test
for anyway.) From Andrew Dunstan.
2005-05-13 06:33:40 +00:00
Tom Lane 3b6073de71 Remove some unnecessary code: since ExecMakeFunctionResultNoSets does not
want to handle set inputs, it should just pass NULL for isDone, not make
its own failure check.
2005-05-12 20:41:56 +00:00
Tom Lane 34b788d674 Give pg_regress a --load-language option, so that it can be used to test
other PLs besides plpgsql.  Andrew Dunstan
2005-05-11 21:52:03 +00:00
Bruce Momjian c5c1cc3bf8 This patch will ensure that the hash table iteration performed by
AtCommit_Portals is restarted when a portal is deleted. This is
necessary since the deletion of a portal may cause the deletion of
another which on rare occations may cause the iterator to return a
deleted portal an thus a renewed attempt delete.

Thomas Hallgren
2005-05-11 18:05:37 +00:00
Neil Conway 3140437495 This patch refactors away some duplicated code in the index AM build
methods: they all invoke UpdateStats() since they have computed the
number of heap tuples, so I created a function in catalog/index.c that
each AM now calls.
2005-05-11 06:24:55 +00:00
Neil Conway 48f8eadffb This patch reduces the size of the message header used by statistics
collector messages, per recent discussion on pgsql-patches. This
actually required quite a few changes -- for example,
"databaseid != InvalidOid" was used to check whether a slot in the
backend entry table was initialized, but that no longer works since
the slot might be initialized prior to receiving the BESTART message
which contains the database id. We now use procpid > 0 to indicate
that a slot is non-empty.

Other changes:

- various comment improvements and cleanups
- there's no need to zero-out the entire activity buffer in
  pgstat_add_backend(), we can just set activity[0] to '\0'.
- remove the counting of the # of connections to a database; this
  was not used anywhere

One change in behavior I wasn't sure about: previously, the code
would create a hash table entry for a database as soon as any message
was received whose header referenced that database. Now, we only
create hash table entries as needed (so for example BESTART won't
create a database hash table entry, since it doesn't need to
access anything in the per-db hash table). It would be easy enough
to retain the old behavior, but AFAICS it is not required.
2005-05-11 01:41:41 +00:00
Neil Conway f38e413b20 Code cleanup: in C89, there is no point casting the first argument to
memset() or MemSet() to a char *. For one, memset()'s first argument is
a void *, and further void * can be implicitly coerced to/from any other
pointer type.
2005-05-11 01:26:02 +00:00
Bruce Momjian 35e1651508 Back out check for unreferenced files.
Heikki Linnakangas
2005-05-10 22:27:30 +00:00
Bruce Momjian a4dde3bff3 Report index name on CLUSTER failure. Also, suggest ALTER TABLE
WITHOUT CLUSTER for cluster failure of a single table in a full db
cluster.
2005-05-10 13:16:26 +00:00
Neil Conway dc5ebcfcce Fix typo in comment. 2005-05-10 05:15:07 +00:00
Neil Conway 8c4da76cf3 Regression tests for the COPY CSV header feature. From Andrew Dunstan. 2005-05-10 00:16:07 +00:00
Neil Conway 1580f6cd6e Update "expected" regression test output for the recent stats collector
checkin. My apologies for breaking the tests.
2005-05-09 15:43:22 +00:00
Tatsuo Ishii 9dfb763f24 Fix duplicate call to WRITE_NODE_FIELD(whereClause) in _outSelectStmt 2005-05-09 15:09:19 +00:00
Tom Lane 1198d63397 Add some defenses against functions declared to return set that don't
actually follow the protocol; per example from Kris Jurka.
2005-05-09 14:28:39 +00:00
Neil Conway 4744c1a0a1 Complete the following TODO items:
* Add session start time to pg_stat_activity
* Add the client IP address and port to pg_stat_activity

Original patch from Magnus Hagander, code review by Neil Conway. Catalog
version bumped. This patch sends the client IP address and port number in
every statistics message; that's not ideal, but will be fixed up shortly.
2005-05-09 11:31:34 +00:00
Tom Lane 1199026e9e Update release checklist to reflect that HISTORY and INSTALL don't
need to be created by hand anymore.
2005-05-08 23:34:15 +00:00
Tom Lane 30f540be43 Repair very-low-probability race condition between relation extension
and VACUUM: in the interval between adding a new page to the relation
and formatting it, it was possible for VACUUM to come along and decide
it should format the page too.  Though not harmful in itself, this would
cause data loss if a third transaction were able to insert tuples into
the vacuumed page before the original extender got control back.
2005-05-07 21:32:24 +00:00
Tom Lane b72e5fa17b Adjust time qual checking code so that we always check TransactionIdIsInProgress
before we check commit/abort status.  Formerly this was done in some paths
but not all, with the result that a transaction might be considered
committed for some purposes before it became committed for others.
Per example found by Jan Wieck.
2005-05-07 21:22:01 +00:00
Tom Lane 4cd4ed0cc2 Fix case in which a debug printout would print already-pfreed data. 2005-05-07 18:14:25 +00:00
Bruce Momjian 3adba41a3c Add comment on C locale test for upper/lower/initcap(). 2005-05-07 15:18:17 +00:00
Bruce Momjian b63990c6a8 Add COPY WITH CVS HEADER to allow a heading line as the first line in
COPY.

Andrew Dunstan
2005-05-07 02:22:49 +00:00
Bruce Momjian ce1ab398dd Update backend flowchart HTML. 2005-05-06 19:13:02 +00:00
Bruce Momjian 33c5fce8db Update flowchart sections to match current CVS. 2005-05-06 19:07:17 +00:00
Bruce Momjian 63ef676781 Markup improvements. 2005-05-06 18:25:46 +00:00
Bruce Momjian 8903592b10 Update backend flowchard wording 2005-05-06 18:23:13 +00:00
Tom Lane 278bd0cc22 For some reason access/tupmacs.h has been #including utils/memutils.h,
which is neither needed by nor related to that header.  Remove the bogus
inclusion and instead include the header in those C files that actually
need it.  Also fix unnecessary inclusions and bad inclusion order in
tsearch2 files.
2005-05-06 17:24:55 +00:00
Bruce Momjian acc4f3e3cb Update comment to mention "Name classification hierarchy" as place to
check for reserved words.
2005-05-06 03:42:17 +00:00
Bruce Momjian 902338e06d Convert some mulit-line comments in copy.c to single line, as appropriate. 2005-05-06 02:56:42 +00:00
Tom Lane fba2a104c6 Marginal performance improvements in dynahash: make sure that everything
associated with a hashtable is allocated in that hashtable's private
context, so that hash_destroy only has to destroy the context and not
do any retail pfree's; and tighten the inner loop of hash_seq_search.
2005-05-06 00:19:14 +00:00
Tom Lane 6f1ca7e457 Fix bogus hashtable setup. (This code has quite a few other problems
too, but that one is in my way at the moment.)
2005-05-05 22:18:27 +00:00
Tom Lane c2e729fa20 Make standalone backends ignore pg_database.datallowconn, so that there
is a way to recover from disabling connections to all databases at once.
2005-05-05 19:53:26 +00:00
Bruce Momjian bd9b2fa84b Add comments on WSAStartup usage. 2005-05-05 16:40:42 +00:00
Bruce Momjian 3731a400b4 Add WSACleanup() for Win32 socket cleanup.
Jason Erickson
2005-05-05 16:36:12 +00:00
Tom Lane db70a31294 Adjust nodeBitmapIndexscan to keep the target index opened from plan
startup to end, rather than re-opening it in each MultiExecBitmapIndexScan
call.  I had foolishly thought that opening/closing wouldn't be much
more expensive than a rescan call, but that was sheer brain fade.

This seems to fix about half of the performance lossage reported by
Sergey Koposov.  I'm still not sure where the other half went.
2005-05-05 03:37:23 +00:00
Tom Lane d468e19a06 Allow implicit cast from any named composite type to RECORD. At the
moment this has no particular use except to allow table rows to be
passed to record_out(), but that case seems to be useful in itself
per recent example from Elein.  Further down the road we could look
at letting PL functions be declared to accept RECORD parameters.
2005-05-05 00:19:47 +00:00
Tom Lane 13f75e378e Use postmaster_is_alive() check in pg_ctl restart as well as pg_ctl status,
so that restart doesn't fail when old postmaster died unbetimes.
2005-05-04 22:35:15 +00:00
Tom Lane f593dda030 Spell DELIMITER correctly, per Seamus Dean. 2005-05-04 14:25:24 +00:00
Tom Lane 126eaef651 Clean up MultiXactIdExpand's API by separating out the case where we
are creating a new MultiXactId from two regular XIDs.  The original
coding was unnecessarily complicated and didn't save any code anyway.
2005-05-03 19:42:41 +00:00
Tom Lane 893b57c871 Alter the signature for encoding conversion functions to declare the
output area as INTERNAL not CSTRING.  This is to prevent people from
calling the functions by hand.  This is a permanent solution for the
back branches but I hope it is just a stopgap for HEAD.
2005-05-03 19:17:59 +00:00
Tom Lane 177af51c04 Change tsearch2 to not use the unsafe practice of creating functions
that return INTERNAL without also having INTERNAL arguments.  Since the
functions in question aren't meant to be called by hand anyway, I just
redeclared them to take 'internal' instead of 'text'.  Also add code
to ProcedureCreate() to enforce the restriction, as I should have done
to start with :-(
2005-05-03 16:51:00 +00:00
Bruce Momjian 76668e6eb4 Check the file system on postmaster startup and report any unreferenced
files in the server log.

Heikki Linnakangas
2005-05-02 18:26:54 +00:00
Neil Conway f478856c7f Change SPI functions to use a `long' when specifying the number of tuples
to produce when running the executor. This is consistent with the internal
executor APIs (such as ExecutorRun), which also use a long for this purpose.
It also allows FETCH_ALL to be passed -- since FETCH_ALL is defined as
LONG_MAX, this wouldn't have worked on platforms where int and long are of
different sizes. Per report from Tzahi Fadida.
2005-05-02 00:37:07 +00:00
Tom Lane 6c412f0605 Change CREATE TYPE to require datatype output and send functions to have
only one argument.  (Per recent discussion, the option to accept multiple
arguments is pretty useless for user-defined types, and would be a likely
source of security holes if it was used.)  Simplify call sites of
output/send functions to not bother passing more than one argument.
2005-05-01 18:56:19 +00:00
Neil Conway 628c0893fd Remove the contents of the src/corba subdirectory: this has been dead code
for a long time.
2005-05-01 06:15:51 +00:00
Tom Lane 7f8d2fe31c Change catalog entries for record_out and record_send to show only one
argument, since that's all they are using now.  Adjust type_sanity
regression test so that it will complain if anyone tries to define
multiple-argument output functions in future.
2005-04-30 20:31:39 +00:00
Tom Lane d7018abe06 Make record_out and record_send extract type information from the passed
record object itself, rather than relying on a second OID argument to be
correct.  This patch just changes the function behavior and not the
catalogs, so it's OK to back-patch to 8.0.  Will remove the now-redundant
second argument in pg_proc in a separate patch in HEAD only.
2005-04-30 20:04:33 +00:00
Tom Lane 93b2477278 Use the standard lock manager to establish priority order when there
is contention for a tuple-level lock.  This solves the problem of a
would-be exclusive locker being starved out by an indefinite succession
of share-lockers.  Per recent discussion with Alvaro.
2005-04-30 19:03:33 +00:00
Neil Conway 47458f8c2f GCC 4.0 includes a new warning option, -Wformat-literal, that emits
a warning when a variable is used as a format string for printf()
and similar functions (if the variable is derived from untrusted
data, it could include unexpected formatting sequences). This
emits too many warnings to be enabled by default, but it does
flag a few dubious constructs in the Postgres tree. This patch
fixes up the obvious variants: functions that are passed a variable
format string but no additional arguments.

Most of these are harmless (e.g. the ruleutils stuff), but there
is at least one actual bug here: if you create a trigger named
"%sfoo", pg_dump will read uninitialized memory and fail to dump
the trigger correctly.
2005-04-30 08:08:51 +00:00
Bruce Momjian 16d4418bf5 Fix BCC to not define compiler location. 2005-04-30 04:00:07 +00:00
Tom Lane 3a694bb0a1 Restructure LOCKTAG as per discussions of a couple months ago.
Essentially, we shoehorn in a lockable-object-type field by taking
a byte away from the lockmethodid, which can surely fit in one byte
instead of two.  This allows less artificial definitions of all the
other fields of LOCKTAG; we can get rid of the special pg_xactlock
pseudo-relation, and also support locks on individual tuples and
general database objects (including shared objects).  None of those
possibilities are actually exploited just yet, however.

I removed pg_xactlock from pg_class, but did not force initdb for
that change.  At this point, relkind 's' (SPECIAL) is unused and
could be removed entirely.
2005-04-29 22:28:24 +00:00
Bruce Momjian 32d3b47e6f Remove extern from optreset that was just added. 2005-04-29 14:30:11 +00:00
Bruce Momjian 930dd70992 Improve cleanup from win32 client-only build. 2005-04-29 14:07:27 +00:00
Bruce Momjian 7cebfdf211 Backpatch BCC compile changes to 8.0.X for psql. 2005-04-29 13:42:21 +00:00
Neil Conway 18b5ef5a76 This patch fixes a bug in the error message emitted by pg_restore on an
incorrect -F argument: write_msg() expects its first parameter to be a
"module name", not the format string.
2005-04-29 07:08:06 +00:00
Tom Lane bedb78d386 Implement sharable row-level locks, and use them for foreign key references
to eliminate unnecessary deadlocks.  This commit adds SELECT ... FOR SHARE
paralleling SELECT ... FOR UPDATE.  The implementation uses a new SLRU
data structure (managed much like pg_subtrans) to represent multiple-
transaction-ID sets.  When more than one transaction is holding a shared
lock on a particular row, we create a MultiXactId representing that set
of transactions and store its ID in the row's XMAX.  This scheme allows
an effectively unlimited number of row locks, just as we did before,
while not costing any extra overhead except when a shared lock actually
has to be shared.   Still TODO: use the regular lock manager to control
the grant order when multiple backends are waiting for a row lock.

Alvaro Herrera and Tom Lane.
2005-04-28 21:47:18 +00:00
Dennis Bjorklund d902e7d63b Fix a whitespace problem. From Alvaro Herrera. 2005-04-28 15:51:57 +00:00
Bruce Momjian a65b1b738c Add psql \set ON_ERROR_ROLLBACK to allow statements in a transaction to
error without affecting the entire transaction.  Valid values are
"on|interactive|off".
2005-04-28 13:09:59 +00:00
Tom Lane c20fb65780 On further experimentation, there were still a couple of bugs in
ExpandIndirectionStar() ... and in markTargetListOrigin() too.
2005-04-25 22:02:30 +00:00
Tom Lane dfc5c72961 Fix ExpandIndirectionStar to handle cases where the expression to be
expanded is of RECORD type, eg
'select (foo).* from (select foo(f1) from t1) ss'
where foo() is a function declared with multiple OUT parameters.
2005-04-25 21:03:25 +00:00
Tom Lane ea19c8772e get_expr_result_type probably needs to be able to handle OpExpr as well
as FuncExpr, to cover cases where a function returning tuple is invoked
via an operator.
2005-04-25 20:59:44 +00:00
Tom Lane a0ea71333a Avoid rechecking lossy operators twice in a bitmap scan plan. 2005-04-25 04:27:12 +00:00
Tom Lane 1fcd4b7a07 While determining the filter clauses for an index scan (either plain
or bitmap), use pred_test to be a little smarter about cases where a
filter clause is logically unnecessary.  This may be overkill for the
plain indexscan case, but it's definitely useful for OR'd bitmap scans.
2005-04-25 03:58:30 +00:00
Tom Lane 79a1b00226 Replace slightly klugy create_bitmap_restriction() function with a
more efficient routine in restrictinfo.c (which can make use of
make_restrictinfo_internal).
2005-04-25 02:14:48 +00:00
Tom Lane 5b05185262 Remove support for OR'd indexscans internal to a single IndexScan plan
node, as this behavior is now better done as a bitmap OR indexscan.
This allows considerable simplification in nodeIndexscan.c itself as
well as several planner modules concerned with indexscan plan generation.
Also we can improve the sharing of code between regular and bitmap
indexscans, since they are now working with nigh-identical Plan nodes.
2005-04-25 01:30:14 +00:00
Tom Lane 186655e9a5 Adjust nodeBitmapIndexscan.c to not keep the index open across calls,
but just to open and close it during MultiExecBitmapIndexScan.  This
avoids acquiring duplicate resources (eg, multiple locks on the same
relation) in a tree with many bitmap scans.  Also, don't bother to
lock the parent heap at all here, since we must be underneath a
BitmapHeapScan node that will be holding a suitable lock.
2005-04-24 18:16:38 +00:00
Tom Lane 8403741796 Actually, nodeBitmapIndexscan.c doesn't need to create a standard
ExprContext at all, since it never evaluates any qual or tlist expressions.
2005-04-24 17:32:46 +00:00
Tom Lane 24475a7618 Put back example of using Result node to execute an INSERT. 2005-04-24 15:32:07 +00:00
Neil Conway 947eb97560 Update some comments to use SQL examples rather than QUEL. From Simon
Riggs.
2005-04-24 11:46:21 +00:00
Bruce Momjian 3b0a5e50d7 Update VACUUM VERBOSE FSM message, per Tom. 2005-04-24 03:51:49 +00:00
Tom Lane 35f9b461f1 Repair two TIME WITH TIME ZONE bugs found by Dennis Vshivkov. Comparison
of timetz values misbehaved in --enable-integer-datetime cases, and
EXTRACT(EPOCH) subtracted the zone instead of adding it in all cases.
Backpatch to all supported releases (except --enable-integer-datetime code
does not exist in 7.2).
2005-04-23 22:53:05 +00:00