Commit Graph

5896 Commits

Author SHA1 Message Date
Bruce Momjian 721996d889 Cleanup patch for exec() handling. 2003-05-03 05:13:20 +00:00
Bruce Momjian a7fd03e1de Handle clog structure in shared memory in exec() case, for Win32. 2003-05-03 03:52:07 +00:00
Bruce Momjian 36fa297497 SECOND ATTEMPT
Dump/read non-default GUC values for use by exec'ed backend, for Win32.
2003-05-02 22:02:47 +00:00
Bruce Momjian 9f0d69f527 Back out second part of patch. 2003-05-02 22:01:51 +00:00
Bruce Momjian a2e038fbee Back out last commit --- wrong patch. 2003-05-02 21:59:31 +00:00
Bruce Momjian fb1f7ccec5 Dump/read non-default GUC values for use by exec'ed backends, for Win32. 2003-05-02 21:52:42 +00:00
Tom Lane de28dc9a04 Portal and memory management infrastructure for extended query protocol.
Both plannable queries and utility commands are now always executed
within Portals, which have been revamped so that they can handle the
load (they used to be good only for single SELECT queries).  Restructure
code to push command-completion-tag selection logic out of postgres.c,
so that it won't have to be duplicated between simple and extended queries.
initdb forced due to addition of a field to Query nodes.
2003-05-02 20:54:36 +00:00
Tom Lane 1940434f1e Repair sloppiness about where cached mergeclause pathkeys are allocated.
Without this fix, CVS tip dumps core when running the regression tests
with geqo_threshold = 2.  I would think that a similar patch might be
needed in 7.3, but cannot duplicate the failure in that branch --- so
for now, leave well enough alone.
2003-05-02 19:48:53 +00:00
Tom Lane 0c57d69dd7 Update to describe new set of globally-known contexts planned for support
of extended query features in new FE/BE protocol.  TransactionCommandContext
is gone (PortalContext replaces it for some purposes), and QueryContext
has taken on a new meaning (MessageContext plays its old role).
2003-04-30 19:04:12 +00:00
Tom Lane aa282d4446 Infrastructure for deducing Param types from context, in the same way
that the types of untyped string-literal constants are deduced (ie,
when coerce_type is applied to 'em, that's what the type must be).
Remove the ancient hack of storing the input Param-types array as a
global variable, and put the info into ParseState instead.  This touches
a lot of files because of adjustment of routine parameter lists, but
it's really not a large patch.  Note: PREPARE statement still insists on
exact specification of parameter types, but that could easily be relaxed
now, if we wanted to do so.
2003-04-29 22:13:11 +00:00
Tom Lane 4a5f38c4e6 Code review for holdable-cursors patch. Fix error recovery, memory
context sloppiness, some other things.  Includes Neil's mopup patch
of 22-Apr.
2003-04-29 03:21:30 +00:00
Tom Lane 1045655a25 Prevent coredump in current_schemas() if someone has just deleted a
schema that was in our search path.
2003-04-27 23:22:13 +00:00
Tom Lane 982430f846 Put back encoding-conversion step in processing of incoming queries;
I had inadvertently omitted it while rearranging things to support
length-counted incoming messages.  Also, change the parser's API back
to accepting a 'char *' query string instead of 'StringInfo', as the
latter wasn't buying us anything except overhead.  (I think when I put
it in I had some notion of making the parser API 8-bit-clean, but
seeing that flex depends on null-terminated input, that's not really
ever gonna happen.)
2003-04-27 20:09:44 +00:00
Tom Lane 351372e585 Department of second thoughts: probably still need an IsTransactionState
test in there...
2003-04-27 18:01:46 +00:00
Tom Lane 5f15fa8d06 Clean up some problems in SetClientEncoding: failed to honor doit flag
in all cases, leaked TopMemoryContext memory in others.  Make the
interaction between SetClientEncoding and InitializeClientEncoding
cleaner and better documented.  I suspect these changes should be
back-patched into 7.3, but will wait on Tatsuo's verification.
2003-04-27 17:31:25 +00:00
Tom Lane 3a496c8af0 Repair permissions problem in RI triggers: query parsing has to be done
as the correct user, not only query execution.  Per report from Sean
Chittenden.
2003-04-26 22:21:47 +00:00
Tom Lane 4db9689d1a Add transaction status field to ReadyForQuery messages, and make room
for tableID/columnID in RowDescription.  (The latter isn't really
implemented yet though --- the backend always sends zeroes, and libpq
just throws away the data.)
2003-04-26 20:23:00 +00:00
Tom Lane 2b1e36c7c0 Tweak stats collector start logic so that we will not try to spawn a
new stats collector oftener than once a minute.  Per gripe from Erik Walthinsen
4/25/03.
2003-04-26 02:57:14 +00:00
Tom Lane 9fdb1de3ba Make [VACUUM] ANALYZE safe on zero-column tables. 2003-04-25 21:29:18 +00:00
Tom Lane 9cbaf72177 In the continuing saga of FE/BE protocol revisions, add reporting of
initial values and runtime changes in selected parameters.  This gets
rid of the need for an initial 'select pg_client_encoding()' query in
libpq, bringing us back to one message transmitted in each direction
for a standard connection startup.  To allow server version to be sent
using the same GUC mechanism that handles other parameters, invent the
concept of a never-settable GUC parameter: you can 'show server_version'
but it's not settable by any GUC input source.  Create 'lc_collate' and
'lc_ctype' never-settable parameters so that people can find out these
settings without need for pg_controldata.  (These side ideas were all
discussed some time ago in pgsql-hackers, but not yet implemented.)
2003-04-25 19:45:10 +00:00
Tom Lane 3831636645 const-ify info_cb() to match recent openssl releases. Per Joe Conway. 2003-04-25 04:37:23 +00:00
Tom Lane f779a34c16 Fix breakage induced by yours truly in Kerberos and PAM code. 2003-04-25 03:28:55 +00:00
Tom Lane 6687650ce6 COPY and pg_dump failed to cope with zero-column tables. Fix 'em. 2003-04-25 02:28:22 +00:00
Bruce Momjian db7e46a76d Use closesocket() for all socket/pipe closing, because Win32 requires
it, and map that to close() on Unix.
2003-04-25 01:24:00 +00:00
Tom Lane 5f677af2da Adjust subquery qual pushdown rules so that we can push down a qual
into a UNION that has some type coercions applied to the component
queries, so long as the qual itself does not reference any columns that
have such coercions.  Per example from Jonathan Bartlett 24-Apr-03.
2003-04-24 23:43:09 +00:00
Bruce Momjian 555fe9dda8 Add Win32 Makefile for IPC stuff. 2003-04-24 21:25:34 +00:00
Bruce Momjian 4a10ce5db3 No need for include for Win32 right now. 2003-04-24 21:24:36 +00:00
Bruce Momjian 20ead395c7 Add Win32 shmem/sema prototypes. 2003-04-24 21:23:01 +00:00
Tom Lane f690920a75 Infrastructure for upgraded error reporting mechanism. elog.c is
rewritten and the protocol is changed, but most elog calls are still
elog calls.  Also, we need to contemplate mechanisms for controlling
all this functionality --- eg, how much stuff should appear in the
postmaster log?  And what API should libpq expose for it?
2003-04-24 21:16:45 +00:00
Bruce Momjian a91c5be6a4 pgindent new Win32 files. 2003-04-24 18:14:22 +00:00
Bruce Momjian 1a67e4869c Add shared memory and semaphore routines for Win32.
Also update copyright to be ours, with approval from Jan.
2003-04-24 17:20:23 +00:00
Bruce Momjian d670bf378c Add shared memory and semaphore routines for Win32. 2003-04-24 17:16:13 +00:00
Tom Lane 8a703496a2 getaddrinfo has no business doing unlink(). 2003-04-22 03:52:56 +00:00
Tom Lane 5ed27e35f3 Another round of protocol changes. Backend-to-frontend messages now all
have length words.  COPY OUT reimplemented per new protocol: it doesn't
need \. anymore, thank goodness.  COPY BINARY to/from frontend works,
at least as far as the backend is concerned --- libpq's PQgetline API
is not up to snuff, and will have to be replaced with something that is
null-safe.  libpq uses message length words for performance improvement
(no cycles wasted rescanning long messages), but not yet for error
recovery.
2003-04-22 00:08:07 +00:00
Tom Lane ca944bd2d4 Prevent palloc(0) error when parent table has zero columns. 2003-04-21 15:19:55 +00:00
Tom Lane 1dc3a62ec7 stddev() and variance() should return NULL when there is just one input
value, per recent discussion on pgsql-general.
2003-04-21 00:22:24 +00:00
Tom Lane f9ba0a7fe5 Apple's assembler likes the inlined TAS syntax too, so no reason to
maintain a separate out-of-line version of PPC tas() anymore.
Also fix S_UNLOCK for __powerpc64__ platforms.
2003-04-20 21:54:34 +00:00
Tom Lane b40bc9eac6 Avoid O(N^2) behavior with lots of deferred triggers by making
deferredTriggerInvokeEvents only scan events added since it last ran.
Stephan Szabo, some corrections by Tom Lane.
2003-04-20 17:03:25 +00:00
Bruce Momjian c3b7d2d522 Allow \r and \r\n termination for COPY files.
Output \r\n termination on Win32.

Disallow literal carriage return as a data value,
backslash-carriage-return and \r still allowed.

Doc changes already committed.
2003-04-19 20:36:03 +00:00
Bruce Momjian 9c48cae3e4 Add pipe parameter to COPY function to allow proper line termination. 2003-04-19 19:55:37 +00:00
Tom Lane 3df163ad89 Add more documentation about shared memory costs. 2003-04-19 00:37:28 +00:00
Tom Lane bd8d441775 Second round of FE/BE protocol changes. Frontend->backend messages now
have length counts, and COPY IN data is packetized into messages.
2003-04-19 00:02:30 +00:00
Bruce Momjian 4d4953fc41 Make Win32 tests to match existing Cygwin tests, where appropriate. 2003-04-18 01:03:42 +00:00
Tom Lane cb7fb3ca95 First phase of FE/BE protocol modifications: new StartupPacket layout
with variable-width fields.  No more truncation of long user names.
Also, libpq can now send its environment-variable-driven SET commands
as part of the startup packet, saving round trips to server.
2003-04-17 22:26:02 +00:00
Tom Lane 1426db5d95 Fix stupid oversight ... 2003-04-16 04:37:58 +00:00
Tom Lane 5ab15591d9 eqjoinsel's logic for case where MCV lists are not present should
account for NULLs; in hindsight this is obvious since the code for
the MCV-lists case would reduce to this when there are zero entries
in both lists.  Per example from Alec Mitchell.
2003-04-15 05:18:12 +00:00
Tom Lane 0851e12244 Reorganize clog's error reporting so that PANIC on clog I/O error can
be reduced to a plain ERROR.  Should make it at least a little less
painful to deal with data-corruption problems.
2003-04-14 17:31:33 +00:00
Tom Lane 3fd5faed5b Second try at avoiding conflicts with system isblank(). 2003-04-13 04:07:17 +00:00
Tom Lane ff5456feae Add code to provide useful dynamic-linking error messages on OS X. 2003-04-13 01:19:06 +00:00
Tom Lane ae02cf3c44 Guard against macro versions of isblank(). 2003-04-12 22:28:33 +00:00
Tatsuo Ishii 35a0995992 Fix encoding conversion function bug.
See following posting for more details.

Subject: Re: [HACKERS] [BUGS] Bug #943: Server-Encoding from EUC_TW to UTF-8 doesn't
From: Tatsuo Ishii <t-ishii@sra.co.jp>
To: michael.enke@wincor-nixdorf.com, pgsql-bugs@postgresql.org
Cc: pgsql-hackers@postgresql.org
Date: Sat, 12 Apr 2003 10:51:45 +0900 (JST)
2003-04-12 07:53:57 +00:00
Tom Lane 5674460bb0 Fix error recovery for SSL_read/SSL_write calls. 2003-04-10 23:03:08 +00:00
Tom Lane da2060e5fd Remove premature attempt to constant-fold type coercion expressions.
While usually safe, this fails if the coercion function needs the
query snapshot to be set already.  Per example from Nigel Andrews.
2003-04-10 02:47:46 +00:00
Tom Lane 730840c9b6 First phase of work on array improvements. ARRAY[x,y,z] constructor
expressions, ARRAY(sub-SELECT) expressions, some array functions.
Polymorphic functions using ANYARRAY/ANYELEMENT argument and return
types.  Some regression tests in place, documentation is lacking.
Joe Conway, with some kibitzing from Tom Lane.
2003-04-08 23:20:04 +00:00
Tom Lane 20f8480927 Mark TimeScales constants as double to avoid integer overflow in some compilers. 2003-04-08 17:02:04 +00:00
Tom Lane dbb7503660 Remove extraneous semicolons. 2003-04-08 16:57:45 +00:00
Jan Wieck cd203f3395 Avoid primary key lookup (and lock) if foreign key does not change
on UPDATE.

This get's rid of the long standing annoyance that updating a row
that has foreign keys locks all the referenced rows even if the
foreign key values do not change.

The trick is to actually do a check identical to NO ACTION after an
eventually done UPDATE in the SET DEFAULT case. Since a SET DEFAULT
operation should have moved referencing rows to a new "home", a following
NO ACTION check can only fail if the column defaults of the referencing
table resulted in the key we actually deleted. Thanks to Stephan.

Jan
2003-04-07 20:30:38 +00:00
Tom Lane afe1185cf0 Remove unnecessary dt2local() call. 2003-04-07 15:04:03 +00:00
Peter Eisentraut cb1d036acb Generate pg_config.h.in by autoheader. Separate out manually editable
parts.  Standardize spelling of comments in pg_config.h.
2003-04-06 22:45:23 +00:00
Bruce Momjian 3a8f67d091 Fix compile problem with Win32 macro used inside another macro. 2003-04-05 19:54:12 +00:00
Bruce Momjian d46e643822 Add Win32 path handling for / vs. \ and drive letters. 2003-04-04 20:42:13 +00:00
Bruce Momjian 9bad936f67 Handle cp, rm, and exec for Win32. 2003-04-04 20:40:45 +00:00
Tom Lane d685417fbb Avoid repeated computation of the constants date2j(1970, 1, 1) and
date2j(2000, 1, 1).  Should make for some marginal speed improvement
in date/time operations.
2003-04-04 04:50:44 +00:00
Tom Lane 3b4ca4c0d9 Code review for pg_stat_get_backend_activity_start patch --- fix
return type, make protection condition agree with recent change to
pg_stat_get_backend_activity, clean up documentation.
2003-04-04 03:03:54 +00:00
Tom Lane a385186ff7 Remove zero_damaged_pages from postgresql.conf.sample; the only way to
find out about it is to read the documentation that tells you how
dangerous it is.  Add default_transaction_read_only to documentation;
seems to have been overlooked in patch that added read-only transactions.
Clean up check_guc comparison script, which has been suffering bit rot.
2003-04-03 23:32:47 +00:00
Tom Lane f1fb9e0097 Prevent EXPLAIN (without ANALYZE) SELECT ... INTO from creating an INTO
table.  Needed due to recent change that makes us call ExecutorStart
even when not planning to carry out the query.
2003-04-03 22:35:48 +00:00
Tom Lane 14e6823c7c Don't re-invent the strchr() wheel. 2003-04-03 21:50:23 +00:00
Tom Lane 61c9ea0f3c Fix load_user/load_group to not leave dangling pointers around if the
config files are present on one pass and not present on a later pass.
2003-04-03 21:25:02 +00:00
Tom Lane 906dce0464 Repair incorrect checking of grouped/ungrouped variables in the presence
of unnamed joins; per pghackers discussion 31-Mar-03.
2003-04-03 18:04:09 +00:00
Tom Lane ec54a6efcf Fix buffer overrun in to_ascii(), per report from Guido Notari. 2003-04-02 21:07:59 +00:00
Tom Lane 794162bb1a Fix convSockAddr6to4(): eliminate bogus assumptions about byte ordering,
remove useless SockAddr_ntop() call.  Per report from Andreas Pflug.
2003-04-02 20:00:21 +00:00
Tom Lane d6f1aa9760 Fix platform-dependent failure introduced by recent to_char changes
(ye good olde uninitialized-local-variable).
2003-04-02 02:33:52 +00:00
Tom Lane 1d650da2e5 This is a derived file and should never have been added to CVS. 2003-04-02 00:58:08 +00:00
Tom Lane 1da6eb7fda Whack getaddrinfo() patch around until it works, more or less, on
machines without IPv6.  Or at least it works on HPUX 10.20 ...
2003-04-02 00:49:28 +00:00
Tom Lane f8a15f632d Add missing semicolon. 2003-04-01 23:42:55 +00:00
Bruce Momjian 50be3e5efe The following patch cleans up the deferred trigger mechanism. There is
an unneeded memory context and some variables that are not used anymore.
It's pretty trivial and the regression tests pass fine.  There's no
change in functionality, only deletion of unused code.  I left an empty
function because maybe I'll need it for nested transactions.

Alvaro Herrera
2003-03-31 20:47:51 +00:00
Tom Lane 7cd30e1590 TestConfiguration returns int, not bool. This mistake is relatively
harmless on signed-char machines but would lead to core dump in the
deadlock detection code if char is unsigned.  Amazingly, this bug has
been here since 7.1 and yet wasn't reported till now.  Thanks to Robert
Bruccoleri for providing the opportunity to track it down.
2003-03-31 20:32:29 +00:00
Bruce Momjian 5e1c330227 Properly document default value of log_min_error_statement in postgresql.conf. 2003-03-30 21:38:02 +00:00
Peter Eisentraut 82a91eb54e Simplify the socket handling code by supplying a replacement getaddrinfo()
function if the OS doesn't provide one.
2003-03-29 11:31:52 +00:00
Bruce Momjian bf7ca0a769 [ Backpatch to 7.3.X.]
SSL_read/write can error needing ERROR_WANT_READ or ERROR_WANT_WRITE.
2003-03-29 05:00:15 +00:00
Bruce Momjian 0184db50a0 [ Backpatch to 7.3.X.]
typing error in src/backend/libpq/be-secure.c ???

Long Description
In src/backend/libpq/be-secure.c: secure_write
on SSL_ERROR_WANT_WRITE call secure_read instead
secure_write again. May be is this a typing error?

Sergey N. Yatskevich (syatskevich@n21lab.gosniias.msk.ru)
2003-03-29 03:56:44 +00:00
Tom Lane fd42262836 Add code to apply some simple sanity checks to the header fields of a
page when it's read in, per pghackers discussion around 17-Feb.  Add a
GUC variable zero_damaged_pages that causes the response to be a WARNING
followed by zeroing the page, rather than the normal ERROR; this is per
Hiroshi's suggestion that there needs to be a way to get at the data
in the rest of the table.
2003-03-28 20:17:13 +00:00
Tom Lane 1bd159e4e9 Fix bogus coding of SET DEFAULT ri triggers ... or at least make it less
bogus than it was.  Per bug report from Adrian Pop.
2003-03-27 19:25:40 +00:00
Bruce Momjian 6f2d02d306 Fix syntax error in to_char fixes --- was defining variable in main code
block, ala C++.
2003-03-27 17:10:55 +00:00
Bruce Momjian 4b0b8dadd2 Add new files. 2003-03-27 16:53:15 +00:00
Bruce Momjian 54f7338fa1 This patch implements holdable cursors, following the proposal
(materialization into a tuple store) discussed on pgsql-hackers earlier.
I've updated the documentation and the regression tests.

Notes on the implementation:

- I needed to change the tuple store API slightly -- it assumes that it
won't be used to hold data across transaction boundaries, so the temp
files that it uses for on-disk storage are automatically reclaimed at
end-of-transaction. I added a flag to tuplestore_begin_heap() to control
this behavior. Is changing the tuple store API in this fashion OK?

- in order to store executor results in a tuple store, I added a new
CommandDest. This works well for the most part, with one exception: the
current DestFunction API doesn't provide enough information to allow the
Executor to store results into an arbitrary tuple store (where the
particular tuple store to use is chosen by the call site of
ExecutorRun). To workaround this, I've temporarily hacked up a solution
that works, but is not ideal: since the receiveTuple DestFunction is
passed the portal name, we can use that to lookup the Portal data
structure for the cursor and then use that to get at the tuple store the
Portal is using. This unnecessarily ties the Portal code with the
tupleReceiver code, but it works...

The proper fix for this is probably to change the DestFunction API --
Tom suggested passing the full QueryDesc to the receiveTuple function.
In that case, callers of ExecutorRun could "subclass" QueryDesc to add
any additional fields that their particular CommandDest needed to get
access to. This approach would work, but I'd like to think about it for
a little bit longer before deciding which route to go. In the mean time,
the code works fine, so I don't think a fix is urgent.

- (semi-related) I added a NO SCROLL keyword to DECLARE CURSOR, and
adjusted the behavior of SCROLL in accordance with the discussion on
-hackers.

- (unrelated) Cleaned up some SGML markup in sql.sgml, copy.sgml

Neil Conway
2003-03-27 16:51:29 +00:00
Bruce Momjian 7a3e7b64ac to_char fixes, Karel Zak 2003-03-27 16:35:31 +00:00
Tom Lane bf576cc014 GetTupleForTrigger must use outer transaction's command counter for time
qual checking, not GetCurrentCommandId.  Per test case from Steve Wolfe.
2003-03-27 14:33:11 +00:00
Peter Eisentraut 5e5c5cd31a Merge documentation into one book. (Build with "make html".) Replace
vague cross-references with real links.
2003-03-25 16:15:44 +00:00
Tom Lane 6ba159f9cf Ignore SIGXFSZ (if platform has it), so that ulimit violations work like
disk-full conditions instead of provoking a backend crash.  Per suggestion
from Frederic Surleau.
2003-03-24 22:40:14 +00:00
Tom Lane fddc2d94ce Modify keys_are_unique optimization to release buffer pins before it
returns NULL.  This avoids out-of-buffers failures during many-way
indexscans, as in Shraibman's complaint of 21-Mar.
2003-03-24 21:42:33 +00:00
Bruce Momjian 346182ca92 Add comment to postgresql.conf:
#search_path = '$user,public'   # schema names
2003-03-24 20:39:10 +00:00
Bruce Momjian 8670e3588f Prevent multiple queries in a single string into a single transaction
when autocommit is off, and document grouping when autocommit is on.
2003-03-24 18:33:52 +00:00
Tom Lane 0489783011 Adjust amrescan code so that it's allowed to call index_rescan with a
NULL key pointer, indicating that the existing scan key should be reused.
This behavior isn't used yet but will be needed for my planned fix to
the keys_are_unique code.
2003-03-23 23:01:03 +00:00
Tom Lane 8d9e025e7f Instead of storing pg_statistic stavalues entries as text strings, store
them as arrays of the internal datatype.  This requires treating the
stavalues columns as 'anyarray' rather than 'text[]', which is not 100%
kosher but seems to work fine for the purposes we need for pg_statistic.
Perhaps in the future 'anyarray' will be allowed more generally.
2003-03-23 05:14:37 +00:00
Tom Lane efeffae245 Tweak selectivity and related routines to cope with domains. Per report
from Andreas Pflug.
2003-03-23 01:49:02 +00:00
Tom Lane 9323cb0aab Department of second thoughts: probably shouldn't use nth() to get the
appropriate targetlist entry out of the subquery.  Use an explicit search
like we do everywhere else.
2003-03-22 17:11:25 +00:00
Bruce Momjian ed11ccf4d4 Fix comment-only query to return Null result set, rather than nothing.
Cleans up blank query handling to be more consistent.
2003-03-22 04:23:34 +00:00
Bruce Momjian aaf11b931f Back out to_char fixes until regression tests are fixed. 2003-03-22 02:12:24 +00:00
Tom Lane 05f916e6ad Adjust subquery qual pushdown rules to be more forgiving: if a qual
refers to a non-DISTINCT output column of a DISTINCT ON subquery, or
if it refers to a function-returning-set, we cannot push it down.
But the old implementation refused to push down *any* quals if the
subquery had any such 'dangerous' outputs.  Now we just look at the
output columns actually referenced by each qual expression.  More code
than before, but probably no slower since we don't make unnecessary checks.
2003-03-22 01:49:38 +00:00
Tom Lane e43094b124 Fix compile warning. 2003-03-21 23:18:52 +00:00
Bruce Momjian e02f818311 Add hostmask() function:
+       <entry><function>hostmask</function>(<type>inet</type>)</entry>
+       <entry><type>inet</type></entry>
+       <entry>construct hostmask for network</entry>
+       <entry><literal>hostmask('192.168.23.20/30')</literal></entry>
+       <entry><literal>0.0.0.3</literal></entry>

Greg Wickham
2003-03-21 21:54:29 +00:00
Peter Eisentraut 1a7f4ed525 Make "win" a separate port from "cygwin". This means you can now
configure under native Windows (MinGW that is), but you won't get very far
compiling yet.  The dynaloader files are from Jan Wieck's patch set.
2003-03-21 17:18:34 +00:00
Bruce Momjian 063da9dce6 Fix ALTER TABLE / CLUSTER ON breakage.
Alvaro Herrera1
2003-03-21 15:43:02 +00:00
Bruce Momjian 9a9719e482 Allow error query to start transaction in autocommit off mode. 2003-03-21 04:33:15 +00:00
Bruce Momjian 3bb7e1ef11 Fix sequence casting. 2003-03-21 03:55:21 +00:00
Tom Lane d72f6c7503 Reimplement NUMERIC datatype using base-10000 arithmetic; also improve
some of the algorithms for higher functions.  I see about a factor of ten
speedup on the 'numeric' regression test, but it's unlikely that that test
is representative of real-world applications.
initdb forced due to change of on-disk representation for NUMERIC.
2003-03-21 01:58:05 +00:00
Bruce Momjian 3be6367b9f This patch creates a function named pg_get_triggerdef that takes the oid of
a trigger as its parameter.  It is basically copied from the pg_dump
code.

Christopher Kings-Lynne
2003-03-20 18:58:02 +00:00
Bruce Momjian 432b9b0f75 Add ALTER TABLE <tablename> CLUSTER ON <indexname>
Alvaro Herrera
2003-03-20 18:52:48 +00:00
Bruce Momjian db5d7ccac9 It would also be handy if users could see their own pg_stat_activity
queries while the rest remain blank.

Kevin Brown
2003-03-20 18:51:16 +00:00
Bruce Momjian 5f65225fa3 Todo items:
Add ALTER SEQUENCE to modify min/max/increment/cache/cycle values

Also updated create sequence docs to mention NO MINVALUE, & NO MAXVALUE.

New Files:
doc/src/sgml/ref/alter_sequence.sgml
src/test/regress/expected/sequence.out
src/test/regress/sql/sequence.sql


ALTER SEQUENCE is NOT transactional.  It behaves similarly to setval().
It matches the proposed SQL200N spec, as well as Oracle in most ways --
Oracle lacks RESTART WITH for some strange reason.

--
Rod Taylor <rbt@rbt.ca>
2003-03-20 07:02:11 +00:00
Bruce Momjian d7f10705b4 Attached is a patch that limits the range tested by horology to
what is capable using integer-datatime timestamps. It does attempt
to exercise the maximum allowable timestamp range.
Also is a small error check when converting a timestamp from external
to internal format that prevents out of range timestamps from being
entered.

Files patched:
        Index: src/backend/utils/adt/timestamp.c
                Added range check to prevent out of range timestamps
                from being used.

        Index: src/test/regress/sql/horology.sql
        Index: src/test/regress/expected/horology-no-DST-before-1970.out
        Index: src/test/regress/expected/horology-solaris-1947.out
                Limited range of timestamps being checked to
                Jan 1, 4713 BC  to Dec 31, 294276

In creating this patch, I have seen some definite problems with integer
timestamps and how they react when used near their limits. For example,
the following statement gives the correct result:

        SELECT timestamp without time zone 'Jan 1, 4713 BC'
               + interval '109203489 days' AS "Dec 31, 294276";

However, this statement which is the logical inverse of the above
gives incorrect results:

        SELECT timestamp without time zone '12/31/294276'
             - timestamp without time zone 'Jan 1, 4713 BC' AS "109203489 Days";

John Cochran
2003-03-20 06:03:00 +00:00
Bruce Momjian 94701fb24b Peter found bug in the to_char() routine for PL/MI options. This
patch fix it -- but this patch doesn't contains tests or docs fixes. I
 will send it later.

 Fixed outputs:

select  to_char(x, '9999.999')  as x,
        to_char(x, 'S9999.999') as s,
        to_char(x, 'SG9999.999') as sg,
        to_char(x, 'MI9999.999') as mi,
        to_char(x, 'PL9999.999') as pl,
        to_char(x, 'PLMI9999.999') as plmi,
        to_char(x, '9999.999SG') as sg2,
        to_char(x, '9999.999PL') as pl2,
        to_char(x, '9999.999MI') as mi2 from num;

Karel Zak
2003-03-20 05:19:26 +00:00
Bruce Momjian 8000fdd462 > > - Move SEQ_MAXVALUE, SEQ_MINVALUE definitions to sequence.h
> >
> > - Add check in pg_dump to see if the value returned is the max /min
> > values and replace with NO MAXVALUE, NO MINVALUE.
> >
> > - Change START and INCREMENT to use START WITH and INCREMENT BY syntax.
> > This makes it a touch easier to port to other databases with sequences
> > (Oracle).  PostgreSQL supports both syntaxes already.
>
> +       char            bufm[100],
> +                               bufx[100];
>
> This seems to be an arbitary size. Why not set it to the actual maximum
> length?
>
> Also:
>
> +       snprintf(bufm, 100, INT64_FORMAT, SEQ_MINVALUE);
> +       snprintf(bufx, 100, INT64_FORMAT, SEQ_MAXVALUE);
>
> sizeof(bufm), sizeof(bufx) is probably the more
> maintenance-friendly/standard way to do it.

I changed the code to use sizeof - but will wait for a response from
Peter before changing the size.  It's consistent throughout the sequence
code to be 100 for this purpose.

Rod Taylor <rbt@rbt.ca>
2003-03-20 05:18:15 +00:00
Bruce Momjian a00431b8d8 "Information_schema" changes
- Add domain check constraints to "check_constraints" view
- Create "domains" view
- Create "domain_constraints" view

--
Rod Taylor <rbt@rbt.ca>
2003-03-20 05:06:55 +00:00
Bruce Momjian 15ce2d2e4a > I can see a couple possible downsides: (a) the library might have some
> weird behavior across fork boundaries; (b) the additional memory space
> that has to be duplicated into child processes will cost something per
> child launch, even if the child never uses it.  But these are only
> arguments that it might not *always* be a prudent thing to do, not that
> we shouldn't give the DBA the tool to do it if he wants.  So fire away.

Here is a patch for the above, including a documentation update. It
creates a new GUC variable "preload_libraries", that accepts a list in
the form:

   preload_libraries = '$libdir/mylib1:initfunc,$libdir/mylib2'

If ":initfunc" is omitted or not found, no initialization function is
executed, but the library is still preloaded. If "$libdir/mylib" isn't
found, the postmaster refuses to start.

In my testing with PL/R, it reduces the first call to a PL/R function
(after connecting) from almost 2 seconds, down to about 8 ms.

Joe Conway
2003-03-20 04:51:44 +00:00
Bruce Momjian a18331004a Add start time to pg_stat_activity
Neil Conway
2003-03-20 03:34:57 +00:00
Tom Lane 48dfa0d057 Arrange to print the relevant key values when reporting a foreign-key
violation.  Also, factor out some duplicate code in the RI triggers.
Patch by Dmitry Tkach, reviewed by Stephan Szabo and Tom Lane.
2003-03-15 21:19:40 +00:00
Bruce Momjian 35911088ff A typo in src/backend/libpq/hba.c breaks local ident authentication
in the SO_PEERCRED case. elif is misspelled as elsif for the test.
A patch is attached.

Bruno Wolff III
2003-03-15 16:18:25 +00:00
Bruce Momjian c90354bad0 Remove unneeded dash blocks around function start comments. 2003-03-14 22:40:31 +00:00
Tom Lane 7931bfa764 Make eval_const_expressions simplify FieldSelect from a whole-row Var
into an ordinary one-field Var.  Per example from Chris Mungall.
2003-03-14 00:55:17 +00:00
Tom Lane 2a1ef30b57 Prevent infinite loop in ln_var() due to roundoff error.
Per report from Dave Marin.
2003-03-14 00:15:32 +00:00
Tom Lane 6c4996fa6b GROUP BY got confused if there were multiple equal() GROUP BY items.
This bug has been latent since 7.0 or maybe even further back, but it
was only exposed when parse_clause.c stopped suppressing duplicate
items (see its rev 1.96 of 18-Aug-02).
2003-03-13 16:58:35 +00:00
Tom Lane 31e69ccb21 Add explicit tests for division by zero to all user-accessible integer
division and modulo functions, to avoid problems on OS X (which fails to
trap 0 divide at all) and Windows (which traps it in some bizarre
nonstandard fashion).  Standardize on 'division by zero' as the one true
spelling of this error message.  Add regression tests as suggested by
Neil Conway.
2003-03-11 21:01:33 +00:00
Tom Lane 6261c75014 Implement SQL92-compatible FIRST, LAST, ABSOLUTE n, RELATIVE n options
for FETCH and MOVE.
2003-03-11 19:40:24 +00:00
Tom Lane e4704001ea This patch fixes a bunch of spelling mistakes in comments throughout the
PostgreSQL source code.

Neil Conway
2003-03-10 22:28:22 +00:00
Tom Lane aa83bc04e0 Restructure parsetree representation of DECLARE CURSOR: now it's a
utility statement (DeclareCursorStmt) with a SELECT query dangling from
it, rather than a SELECT query with a few unusual fields in it.  Add
code to determine whether a planned query can safely be run backwards.
If DECLARE CURSOR specifies SCROLL, ensure that the plan can be run
backwards by adding a Materialize plan node if it can't.  Without SCROLL,
you get an error if you try to fetch backwards from a cursor that can't
handle it.  (There is still some discussion about what the exact
behavior should be, but this is necessary infrastructure in any case.)
Along the way, make EXPLAIN DECLARE CURSOR work.
2003-03-10 03:53:52 +00:00
Tom Lane aa60eecc37 Revise tuplestore and nodeMaterial so that we don't have to read the
entire contents of the subplan into the tuplestore before we can return
any tuples.  Instead, the tuplestore holds what we've already read, and
we fetch additional rows from the subplan as needed.  Random access to
the previously-read rows works with the tuplestore, and doesn't affect
the state of the partially-read subplan.  This is a step towards fixing
the problems with cursors over complex queries --- we don't want to
stick in Materialize nodes if they'll prevent quick startup for a cursor.
2003-03-09 02:19:13 +00:00
Tom Lane f7cffbbbd7 Tweak dependency code to suppress NOTICEs generated by new method for
cleaning out temp namespaces.  We don't really want the server log to be
cluttered with 'Drop cascades to table foo' every time someone uses a
temp table...
2003-03-06 22:54:49 +00:00
Tom Lane 4b6c198a6a Add code to dump contents of free space map into $PGDATA/global/pg_fsm.cache
at database shutdown, and then load it again at database startup.  This
preserves our hard-won knowledge of free space across restarts (given
an orderly shutdown, that is).
2003-03-06 00:04:27 +00:00
Tom Lane 21591967bc Turns out new IN implementation has got some problems in an UPDATE or
DELETE with inherited target table.  Fix it; add a regression test.
Also, correct ancient misspelling of 'inherited'.
2003-03-05 20:01:04 +00:00
Tom Lane 147fbf9c6e Repair bug reported by Laurent Perez: bad plan generated when UPDATE or
DELETE of an inheritance tree references another inherited relation.
This bug has been latent since 7.1; I'm still not quite sure why 7.1 and
7.2 don't manifest it (at least, they don't crash on a simple test case).
2003-03-05 18:38:14 +00:00
Tom Lane 391eb5e5b6 Reimplement free-space-map management as per recent discussions.
Adjustable threshold is gone in favor of keeping track of total requested
page storage and doling out proportional fractions to each relation
(with a minimum amount per relation, and some quantization of the results
to avoid thrashing with small changes in page counts).  Provide special-
case code for indexes so as not to waste space storing useless page
free space counts.  Restructure internal data storage to be a flat array
instead of list-of-chunks; this may cost a little more work in data
copying when reorganizing, but allows binary search to be used during
lookup_fsm_page_entry().
2003-03-04 21:51:22 +00:00
Tom Lane a455c94257 Prevent clustering on incomplete indexes: partial indexes are verboten,
as are non-amindexnulls AMs unless first column is attnotnull.
2003-03-03 04:37:37 +00:00
Tom Lane 30a695d356 Be smart about outer-join qualifications that mention only one side of
the join, per recent discussion on pgsql-sql.  Not clear that this will
come up often in real queries, but it's not any more expensive to do it
right, so we may as well do it right.
2003-03-02 23:46:34 +00:00
Tom Lane 191ef2b407 Change EXTRACT(EPOCH FROM timestamp) so that a timestamp without time zone
is assumed to be in local time, not GMT.  This improves consistency with
other operations, which all assume local timezone when it matters.  Per
bug #897.
2003-02-27 21:36:58 +00:00
Tom Lane 84666801ed Remove REWRITE_INVOKE_MAX in favor of making an accurate check for
recursion in RewriteQuery(); also, detect recursion in fireRIRrules(),
so as to catch self-referential views per example from Ryan VanderBijl.
Minor code restructuring to make it easier to catch recursive case.
2003-02-25 23:47:43 +00:00
Tom Lane 0797bb5c50 During VACUUM FULL, truncate off any deletable pages that are at the
end of a btree index.  This isn't super-effective, since we won't move
nondeletable pages, but it's better than nothing.  Also, improve stats
displayed during VACUUM VERBOSE.
2003-02-24 00:57:17 +00:00
Tom Lane 3981f2195f Remove no-longer-used FixBTree GUC variable. 2003-02-23 23:27:21 +00:00
Tom Lane 61b22d3aab btree page recycling can be done as soon as page's next-xact label is
older than current Xmin; we don't have to wait till it's older than
GlobalXmin.
2003-02-23 23:20:52 +00:00
Tom Lane 3bbd6af37c Adjust btbulkdelete logic so that only one WAL record is issued while
deleting multiple index entries on a single index page.  This makes for
a very substantial reduction in the amount of WAL traffic during a
large delete operation.
2003-02-23 22:43:09 +00:00
Tom Lane 13dadef8b5 Improve coding of log_heap_clean() and heap_xlog_clean(). 2003-02-23 20:32:12 +00:00
Tom Lane 88dc31e3f2 First cut at recycling space in btree indexes. Still some rough edges
to fix, but it seems to basically work...
2003-02-23 06:17:13 +00:00
Tom Lane 27854915b9 If a shutdown request comes in while we're still starting up, don't
service it until after we execute SetThisStartUpID().  Else shutdown
process will write the wrong SUI into the shutdown checkpoint, which
seems likely to be trouble --- although I've not quite figured out
how significant it really is.
2003-02-23 04:48:19 +00:00
Tom Lane 80d6a277c9 Simplify timezone-handling code per proposal to pghackers: get rid of
setting timezone-related variables during transaction start.  They were
not used anyway in platforms that HAVE_TM_ZONE or HAVE_INT_TIMEZONE,
which it appears is *all* the platforms we are currently supporting.
For platforms that have neither, we now only support UTC or numeric-
offset-from-UTC timezones.
2003-02-22 05:57:45 +00:00
Tom Lane 799bc58dc7 More infrastructure for btree compaction project. Tree-traversal code
now knows what to do upon hitting a dead page (in theory anyway, it's
untested...).  Add a post-VACUUM-cleanup entry point for index AMs, to
provide a place for dead-page scavenging to happen.
Also, fix oversight that broke btpo_prev links in temporary indexes.
initdb forced due to additions in pg_am.
2003-02-22 00:45:05 +00:00
Tom Lane 70508ba7ae Make btree index structure adjustments and WAL logging changes needed to
support btree compaction, as per proposal of a few days ago.  btree index
pages no longer store parent links, instead they have a level indicator
(counting up from zero for leaf pages).  The FixBTree recovery logic is
removed, and replaced by code that detects missing parent-level insertions
during WAL replay.  Also, generate appropriate WAL entries when updating
btree metapage and when building a btree index from scratch.  I believe
btree indexes are now completely WAL-legal for the first time.
initdb forced due to index and WAL changes.
2003-02-21 00:06:22 +00:00
Tom Lane 4df0f1d26f Fix timestamptz_in so that parsing of 'now'::timestamptz gives right
answer when SET TIMEZONE has been done since the start of the current
transaction.  Per bug report from Robert Haas.
I plan some futher cleanup in HEAD, but this is a low-risk patch for
the immediate issue in 7.3.
2003-02-20 05:24:55 +00:00
Bruce Momjian 69c049cef4 Back out LOCKTAG changes by Rod Taylor, pending code review. Sorry. 2003-02-19 23:41:15 +00:00
Tatsuo Ishii e2a618fe25 Fix for GUC client_encoding variable not being handled
correctly. See following thread for more details.

Subject: [HACKERS] client_encoding directive is ignored in postgresql.conf
From: Tatsuo Ishii <t-ishii@sra.co.jp>
Date: Wed, 29 Jan 2003 22:24:04 +0900 (JST)
2003-02-19 14:31:26 +00:00
Bruce Momjian cde8bbc413 This patch makes the following changes to the documentation:
- more work from the SGML police

- some grammar improvements: rewriting a paragraph or two, replacing
contractions where (IMHO) appropriate

- fix missing utility commands in lock mode docs

- improve CLUSTER, REINDEX, SET SESSION AUTHORIZATION ref pages

Neil Conway
2003-02-19 04:06:28 +00:00
Bruce Momjian d0f3a7e9c4 - Modifies LOCKTAG to include a 'classId'. Relation receive a classId of
RelOid_pg_class, and transaction locks XactLockTableId. RelId is renamed
to objId.

- LockObject() and UnlockObject() functions created, and their use
sprinkled throughout the code to do descent locking for domains and
types. They accept lock modes AccessShare and AccessExclusive, as we
only really need a 'read' and 'write' lock at the moment.  Most locking
cases are held until the end of the transaction.

This fixes the cases Tom mentioned earlier in regards to locking with
Domains.  If the patch is good, I'll work on cleaning up issues with
other database objects that have this problem (most of them).

Rod Taylor
2003-02-19 04:02:54 +00:00
Bruce Momjian 81f6db4803 Allow PQcmdTuples to return row counts for MOVE and FETCH.
Neil Conway
2003-02-19 03:59:02 +00:00
Bruce Momjian a286f73210 The following patches eliminate the overflows in the j2date() and date2j()
functions which limited the maximum date for a timestamp to AD 1465001.
The new limit is AD 5874897.
The files affected are:

doc/src/sgml/datatype.sgml:
    Documentation change due to patch. Included is a notice about
    the reduced range when using an eight-byte integer for timestamps.

src/backend/utils/adt/datetime.c:
    Replacement functions for j2date() and date2j() functions.

src/include/utils/datetime.h:
    Corrected a bug with the limit on the earliest possible date,
    Nov 23,-4713 has a Julian day count of -1. The earliest possible
    date should be Nov 24, -4713 with a day count of 0.

src/test/regress/expected/horology-no-DST-before-1970.out:
src/test/regress/expected/horology-solaris-1947.out:
src/test/regress/expected/horology.out:
    Copies of expected output for regression testing.
    Note: Only horology.out has been physically tested. I do not have access
    to a Solaris box and I don't know how to provoke the "pre-1970" test.

src/test/regress/sql/horology.sql:
    Added some test cases to check extended range.

John Cochran
2003-02-19 03:48:11 +00:00
Bruce Momjian 9ee8e7a39e Update README. 2003-02-18 03:33:50 +00:00
Tom Lane f690acf104 Async_NotifyHandler must save and restore ImmediateInterruptOK. Fixes
known problem with failure to respond to 'pg_ctl stop -m fast', and
probable problems if SIGINT or SIGTERM arrives while processing a
SIGUSR2 interrupt that arrived while waiting for a new client query.
2003-02-18 02:53:29 +00:00
Bruce Momjian 32cc6cbe23 Rename 'holder' references to 'proclock' for PROCLOCK references, for
consistency.
2003-02-18 02:13:24 +00:00
Tom Lane 72933a92c7 Back off previous patch to skip projection step in scan plan nodes,
in the case where the node immediately above the scan is a Hash, Sort,
or Material node.  In these cases it's better to do the projection
so that we don't store unneeded columns in the hash/sort/materialize
table.  Per discussion a few days ago with Anagh Lal.
2003-02-16 06:06:32 +00:00
Tom Lane 51972a9d5d COALESCE() and NULLIF() are now first-class expressions, not macros
that turn into CASE expressions.  They evaluate their arguments at most
once.  Patch by Kris Jurka, review and (very light) editorializing by me.
2003-02-16 02:30:39 +00:00
Tom Lane 0d7abfe7cf Marginal tweaks to make sure that roundoff error won't cause us to make
a bad choice between sorted and hashed aggregation.
2003-02-15 21:39:58 +00:00
Tom Lane 056467ec6b Teach planner how to propagate pathkeys from sub-SELECTs in FROM up to
the outer query.  (The implementation is a bit klugy, but it would take
nontrivial restructuring to make it nicer, which this is probably not
worth.)  This avoids unnecessary sort steps in examples like
SELECT foo,count(*) FROM (SELECT ... ORDER BY foo,bar) sub GROUP BY foo
which means there is now a reasonable technique for controlling the
order of inputs to custom aggregates, even in the grouping case.
2003-02-15 20:12:41 +00:00
Tom Lane 2dde90ad8d Fix SPI result logic for case where there are multiple statements of the
same type in a rule.  Per bug report from Pavel Hanak.
2003-02-14 21:12:45 +00:00
Bruce Momjian 0e010a54a3 Update FAQ's in head and 7.3.X. 2003-02-14 14:05:00 +00:00
Tom Lane 874e8cef99 Remove bogus manipulation of SIGPIPE; the backend already runs with
SIGPIPE disabled, and does not need to waste two syscalls per I/O on it.
2003-02-14 00:18:41 +00:00
Tom Lane c4ebf7b150 Parser was dropping foreign-key constraints on the floor if present in
an ALTER TABLE ADD COLUMN command.  Per bug #896.
2003-02-13 22:50:01 +00:00
Tom Lane f4a72f773c Repair rule permissions-checking bug reported by Tim Burgess 10-Feb-02:
the table(s) modified by the original query would get checked for the
type of write permission needed by a rule query.
2003-02-13 21:39:50 +00:00
Tom Lane 18e8f06c9d Arrange to give error when a SetOp member statement refers to a variable
of the containing query (which really can only happen in a rule context).
Per example from Brandon Craig Rhodes.  Also, make the error message
more specific for the similar case with sub-select in FROM.  The revised
coding should be easier to adapt to SQL99's LATERAL(), when we get around
to supporting that.
2003-02-13 20:45:22 +00:00
Tom Lane 5f5da0a6cb transformExpr() was missing some cases it ought to allow; per report
from Greg Stark.  Also, twiddle the FuncCall case to not scribble on
the input structure, which was the proximate cause of the problem.
Someday we ought to fix things so that transformExpr() isn't called
on already-transformed trees ...
2003-02-13 18:29:07 +00:00
Tom Lane 478c95a0dc Prevent timetz2tm() from scribbling on its input in HAVE_INT64_TIMESTAMP case. 2003-02-13 17:04:19 +00:00
Bruce Momjian e529e9fa44 [ Revert patch ]
> =================================================================
> User interface proposal for multi-row function targetlist entries
> =================================================================
> 1. Only one targetlist entry may return a set.
> 2. Each targetlist item (other than the set returning one) is
>    repeated for each item in the returned set.
>

Having gotten no objections (actually, no response at all), I can only
assume no one had heartburn with this change. The attached patch covers
the first of the two proposals, i.e. restricting the target list to only
one set returning function.

Joe Conway
2003-02-13 05:53:46 +00:00
Bruce Momjian 48ee6f4916 This trivial patch removes the usage of some old statistics code that no
longer works -- IncrHeapAccessStat() didn't actually *do* anything
anymore, so no reason to keep it around AFAICS. I also fixed a
grammatical error in a comment.


Neil Conway
2003-02-13 05:35:11 +00:00
Bruce Momjian f249daf9b7 Adds in NO MAXVALUE and NO MINVALUE options for create sequence per 200X
spec, which will also make alter sequence a touch easier.

sequence.c  init_params() will check for settings which have been
defined twice, and complain.

Rod Taylor
2003-02-13 05:25:24 +00:00
Bruce Momjian 6cb1f4fe44 The "random" regression test uses a function called oidrand(), which
takes two parameters, an OID x and an integer y, and returns "true" with
probability 1/y (the OID argument is ignored). This can be useful -- for
example, it can be used to select a random sampling of the rows in a
table (which is what the "random" regression test uses it for).

This patch removes that function, because it was old and messy. The old
function had the following problems:

- it was undocumented

- it was poorly named

- it was designed to workaround an optimizer bug that no longer exists
(the OID argument is to ensure that the optimizer won't optimize away
calls to the function; AFAIK marking the function as 'volatile' suffices
nowadays)

- it used a different random-number generation technique than the other
PSRNG-related functions in the backend do (it called random() like they
do, but it had its own logic for setting a set and deciding when to
reseed the RNG).

Ok, this patch removes oidrand(), oidsrand(), and userfntest(), and
improves the SGML docs a little bit (un-commenting the setseed()
documentation).

Neil Conway
2003-02-13 05:24:04 +00:00
Bruce Momjian 8195f8f042 Code for WITHOUT OIDS.
On Wed, 2003-01-08 at 21:59, Christopher Kings-Lynne wrote:
> I agree.  I want to remove OIDs from heaps of our tables when we go to 7.3.
> I'd rather not have to do it in the dump due to down time.


Rod Taylor <rbt@rbt.ca>
2003-02-13 05:20:05 +00:00
Bruce Momjian 8add2e1bca This patch makes pg_get_constraintdef support UNIQUE, PRIMARY KEY and
CHECK constraints.

There are apparently no other types of constraint in pg_constraint, so
now all bases are covered.  Also, this patch assumes that consrc for a
CHECK constraint is always bracketed so that it's not necessary to add
extra brackets.

Christopher Kings-Lynne
2003-02-13 05:10:39 +00:00
Bruce Momjian d21de3b121 > =================================================================
> User interface proposal for multi-row function targetlist entries
> =================================================================
> 1. Only one targetlist entry may return a set.
> 2. Each targetlist item (other than the set returning one) is
>    repeated for each item in the returned set.
>

Having gotten no objections (actually, no response at all), I can only assume
no one had heartburn with this change. The attached patch covers the first of
the two proposals, i.e. restricting the target list to only one set returning
function.

It compiles cleanly, and passes all regression tests. If there are no
objections, please apply.

Any suggestions on where this should be documented (other than maybe sql-select)?

Thanks,

Joe

p.s. Here's what the previous example now looks like:
CREATE TABLE bar(f1 int, f2 text, f3 int);
INSERT INTO bar VALUES(1, 'Hello', 42);
INSERT INTO bar VALUES(2, 'Happy', 45);

CREATE TABLE foo(a int, b text);
INSERT INTO foo VALUES(42, 'World');
INSERT INTO foo VALUES(42, 'Everyone');
INSERT INTO foo VALUES(45, 'Birthday');
INSERT INTO foo VALUES(45, 'New Year');

CREATE TABLE foo2(a int, b text);
INSERT INTO foo2 VALUES(42, '!!!!');
INSERT INTO foo2 VALUES(42, '????');
INSERT INTO foo2 VALUES(42, '####');
INSERT INTO foo2 VALUES(45, '$$$$');

CREATE OR REPLACE FUNCTION getfoo(int) RETURNS SETOF text AS '
   SELECT b FROM foo WHERE a = $1
' language 'sql';

CREATE OR REPLACE FUNCTION getfoo2(int) RETURNS SETOF text AS '
   SELECT b FROM foo2 WHERE a = $1
' language 'sql';

regression=# SELECT f1, f2, getfoo(f3) AS f4 FROM bar;
  f1 |  f2   |    f4
----+-------+----------
   1 | Hello | World
   1 | Hello | Everyone
   2 | Happy | Birthday
   2 | Happy | New Year
(4 rows)

regression=# SELECT f1, f2, getfoo(f3) AS f4, getfoo2(f3) AS f5 FROM bar;
ERROR:  Only one target list entry may return a set result


Joe Conway
2003-02-13 05:06:35 +00:00
Tom Lane 9069a5fc33 Use a varno not chosen at random for dummy variables in the top-level
targetlist of a set-operation tree.  I'm not sure that this solution
will really stand the test of time --- perhaps we need to make a special
RTE for such vars to refer to.  But this quick hack fixes Brandon Craig
Rhodes' complaint of 10-Feb-02 about EXCEPT in CREATE RULE, while not
changing any behavior in the better-tested cases where leftmostRTI is
one anyway.
2003-02-11 04:13:06 +00:00
Tom Lane 8a4fdce9f2 Fix thinko in new logic about pushing down non-nullability constraints:
constraints appearing in outer-join qualification clauses are restricted
as to when and where they can be pushed down.  Add regression test
to catch future errors in this area.
2003-02-10 17:08:50 +00:00
Tom Lane ec8f0e82ef Add code to show join rule (for outer and IN joins) in join type name. 2003-02-10 17:06:23 +00:00
Tom Lane c5ba16a83c Get rid of last few vestiges of parsetree dependency on grammar token
codes, per discussion from last March.  parse.h should now be included
*only* by gram.y, scan.l, keywords.c, parser.c.  This prevents surprising
misbehavior after seemingly-trivial grammar adjustments.
2003-02-10 04:44:47 +00:00
Tom Lane b5956a2f22 Detect case where an outer join can be reduced to a plain inner join
because there are WHERE clauses that will reject the null-extended rows.
Per suggestion from Brandon Craig Rhodes, 19-Nov-02.
2003-02-09 23:57:19 +00:00
Tom Lane 39b7ec3309 Create a distinction between Lists of integers and Lists of OIDs, to get
rid of the assumption that sizeof(Oid)==sizeof(int).  This is one small
step towards someday supporting 8-byte OIDs.  For the moment, it doesn't
do much except get rid of a lot of unsightly casts.
2003-02-09 06:56:28 +00:00
Tom Lane 3646ab58b4 Remove bogus comment (too freely copied & pasted). 2003-02-09 00:35:55 +00:00
Tom Lane 145014f811 Make further use of new bitmapset code: executor's chgParam, extParam,
locParam lists can be converted to bitmapsets to speed updating.  Also,
replace 'locParam' with 'allParam', which contains all the paramIDs
relevant to the node (i.e., the union of extParam and locParam); this
saves a step during SetChangedParamList() without costing anything
elsewhere.
2003-02-09 00:30:41 +00:00
Tom Lane c15a4c2aef Replace planner's representation of relation sets, per pghackers discussion.
Instead of Lists of integers, we now store variable-length bitmap sets.
This should be faster as well as less error-prone.
2003-02-08 20:20:55 +00:00
Tom Lane 3acf422316 Revise mechanism for getting rid of temp tables at backend shutdown.
Instead of grovelling through pg_class to find them, make use of the
handy dandy dependency mechanism: just delete everything that depends
on our temp schema.  Unlike the pg_class scan, the dependency mechanism
is smart enough to delete things in an order that doesn't fall foul of
any dependency restrictions.  Fixes problem reported by David Heggie:
a temp table with a serial column may cause a backend FATAL exit at
shutdown time, if it chances to try to delete the temp sequence first.
2003-02-07 01:33:06 +00:00
Tom Lane 00f1a41ab2 Make flatten_join_alias_vars() do the right thing when expanding an alias
referenced from a subquery.  Per example from Stefanos Harhalakis.
2003-02-06 22:21:11 +00:00
Tom Lane 77ede8900d Create a GUC variable REGEX_FLAVOR to control the type of regular
expression accepted by the regex operators, per discussion yesterday.

Along the way, reduce deadlock_timeout from PGC_POSTMASTER to PGC_SIGHUP
category.  It is probably best to insist that all backends share the same
setting, but that doesn't mean it has to be frozen at startup.
2003-02-06 20:25:33 +00:00
Tom Lane e24977f3a4 Allow qualified type names in CREATE CAST, DROP CAST. Also allow the
construction 'SETOF type[]' which for some reason was previously
overlooked (you'd have to name the array type directly to make it work).
2003-02-05 20:16:42 +00:00
Tom Lane 7bcc6d98fb Replace regular expression package with Henry Spencer's latest version
(extracted from Tcl 8.4.1 release, as Henry still hasn't got round to
making it a separate library).  This solves a performance problem for
multibyte, as well as upgrading our regexp support to match recent Tcl
and nearly match recent Perl.
2003-02-05 17:41:33 +00:00
Tom Lane 2d1f940542 Minor code cleanup: remove no-longer-useful pull_subplans() function,
and convert pull_agg_clause() into count_agg_clause(), which is a more
efficient way of doing what it's really being used for.
2003-02-04 00:50:01 +00:00
Tom Lane 85caf1784a Detect duplicate aggregate calls and evaluate only one copy. This
speeds up some useful real-world cases like
SELECT x, COUNT(*) FROM t GROUP BY x HAVING COUNT(*) > 100.
2003-02-04 00:48:23 +00:00
Tom Lane ef5842b5f7 #ifdef out stuff that shouldn't be compiled when not USE_SSL.
Curious that gcc doesn't complain about unreferenced static variables.
2003-02-03 22:33:51 +00:00
Tom Lane 3752e85bad Determine the set of constraints applied to a domain at executor
startup, not in the parser; this allows ALTER DOMAIN to work correctly
with domain constraint operations stored in rules.  Rod Taylor;
code review by Tom Lane.
2003-02-03 21:15:45 +00:00
Bruce Momjian 6b196c0754 Don't print NO ACTION foreign key actions in dumps and psql \d. 2003-02-03 15:17:24 +00:00
Tom Lane 4cff59d8d5 Tweak planner and executor to avoid doing ExecProject() in table scan
nodes where it's not really necessary.  In many cases where the scan node
is not the topmost plan node (eg, joins, aggregation), it's possible to
just return the table tuple directly instead of generating an intermediate
projection tuple.  In preliminary testing, this reduced the CPU time
needed for 'SELECT COUNT(*) FROM foo' by about 10%.
2003-02-03 15:07:08 +00:00
Bruce Momjian 0d3e36b668 Move pg_service.conf.sample to /interfaces/libpq. 2003-02-03 14:24:07 +00:00
Bruce Momjian 802a4d4111 Change MOVE LAST to MOVE ALL.
Standard says FETCH LAST is after last row, and we don't do that.
2003-02-03 14:04:24 +00:00
Tom Lane c7bceca156 Implement EXPLAIN EXECUTE. By Neil Conway, with some kibitzing from
Tom Lane.
2003-02-02 23:46:38 +00:00
Tom Lane 967e8a37ab Fix nodeUnique to behave correctly when reversing direction after reaching
either end of subplan results.  This prevents misbehavior of cursors
on SELECT DISTINCT ... queries.  Per bug report 1-Feb-02.
2003-02-02 19:08:57 +00:00