Bruce Momjian [Tue, 30 Nov 1999 03:57:29 +0000 (03:57 +0000)]
create/alter user extension
This one should work much better than the one I sent in previously. The
functionality is the same, but the patch was missing one file resulting
in
the compilation failing. The docs also received a minor fix.
The first four are asynchronous analogues of PQconnectdb and PQreset -
they allow an application to connect to the DB without blocking on
remote I/O.
The PQsetenv functions perform an environment negotiation with the
server.
Internal to libpq, pqReadReady and pqWriteReady have been made available
across the library (they were previously static functions inside
fe-misc.c). A lot of internal rearrangement has been necessary to
support these changes.
The API documentation has been updated also.
Caveats:
o The Windows code does not default to using non-blocking sockets,
since I have no documentation: Define WIN32_NON_BLOCKING_CONNECTIONS to
do that.
Bruce Momjian [Mon, 29 Nov 1999 23:42:03 +0000 (23:42 +0000)]
Small patch which fixes the ODBC driver so it doesn't segfault if:
You have CommLog and Debug enabled
You encounter in error in any operation (SQLConnect/SQLExec).
Previously, the extra logging didn't check for NULL pointers
when trying to print some of the strings- the socket error
message could frequently be NULL by design (if there was no socket
error)
and Solaris does not handle NULLS passed to things like printf
("%s\n",string);
gracefully.
This basically duplicates the functionality found in Linux where passing
a null pointer
to printf prints "(NULL)". No very elegant, but the logging is for debug
only anyway.
Tom Lane [Mon, 29 Nov 1999 04:43:15 +0000 (04:43 +0000)]
Add permissions check: now one must be the Postgres superuser or the
table owner in order to vacuum a table. This is mainly to prevent
denial-of-service attacks via repeated vacuums. Allow VACUUM to gather
statistics about system relations, except for pg_statistic itself ---
not clear that it's worth the trouble to make that case work cleanly.
Cope with possible tuple size overflow in pg_statistic tuples; I'm
surprised we never realized that could happen. Hold a couple of locks
a little longer to try to prevent deadlocks between concurrent VACUUMs.
There still seem to be some problems in that last area though :-(
Tom Lane [Sun, 28 Nov 1999 22:02:17 +0000 (22:02 +0000)]
Fix "Unable to identify an operator =$" problem that occurred when pgsql
expressions were written without spaces between operators and operands.
Problem was that something like "if new.f1=new.f2 then" would be translated
to "if $1=$2 then", and the Postgres lexer would tokenize that the wrong
way. Fix is to emit spaces around $paramno constructs to ensure they are
seen as separate tokens.
Tom Lane [Sun, 28 Nov 1999 02:10:01 +0000 (02:10 +0000)]
Remove pg_vlock locking from VACUUM, allowing multiple VACUUMs to run in
parallel --- and, not incidentally, removing a common reason for needing
manual cleanup by the DB admin after a crash. Remove initial global
delete of pg_statistics rows in VACUUM ANALYZE; this was not only bad
for performance of other backends that had to run without stats for a
while, but it was fundamentally broken because it was done outside any
transaction. Surprising we didn't see more consequences of that.
Detect attempt to run VACUUM inside a transaction block. Check for
query cancel request before starting vacuum of each table. Clean up
vacuum's private portal storage if vacuum is aborted.
Tom Lane [Sun, 28 Nov 1999 02:03:04 +0000 (02:03 +0000)]
Delete pg_statistics rows for a relation during heap_destroy_with_catalog.
By dropping stats rows here, we eliminate the need for VACUUM to do a
wholesale remove of stats rows. Before, pg_statistics was wiped clean
at the start of VACUUM, ensuring poor planning results for any backends
running in parallel until VACUUM got around to rebuilding the stats for
the relations they are accessing.
Tom Lane [Sat, 27 Nov 1999 17:56:18 +0000 (17:56 +0000)]
Oops, forgot to commit this one last week. Part of patch to update
regress test expected outputs for change in 'Cannot insert a duplicate key'
error message wording.
Bruce Momjian [Fri, 26 Nov 1999 04:24:17 +0000 (04:24 +0000)]
* Includes tab completion. It's not magic, but it's very cool. At any
rate
it's better than what used to be there.
* Does proper SQL "host variable" substitution as pointed out by Andreas
Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
and ';' are treated (escape with \ to send to backend). This does
_not_
affect the '::' cast operator, but perhaps others that contain : or ;
(but there are none right now).
* To show description with a <something> listing, append '?' to command
name, e.g., \df?. This seemed to be the convenient and logical
solution.
Or append a '+' to see more useless information, e.g., \df+.
* Fixed fflush()'ing bug pointed out by Jan during the regression test
discussion.
* Added LastOid variable. This ought to take care of TODO item "Add a
function to return the last inserted oid, for use in psql scripts"
(under CLIENTS)
E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid
* \d command shows constraints, rules, and triggers defined on the table
(in addition to indices)
* Various fixes, optimizations, corrections
* Documentation update as well
Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.
Tom Lane [Tue, 23 Nov 1999 01:04:38 +0000 (01:04 +0000)]
verify_password() leaked a file descriptor if it failed to find the given
userid in the flat password file. Do it enough times and the postmaster
panicked :-(
Bruce Momjian [Mon, 22 Nov 1999 17:56:41 +0000 (17:56 +0000)]
Add system indexes to match all caches.
Make all system indexes unique.
Make all cache loads use system indexes.
Rename *rel to *relid in inheritance tables.
Rename cache names to be clearer.
Tom Lane [Mon, 22 Nov 1999 02:06:31 +0000 (02:06 +0000)]
Clean up some problems in error recovery --- elog() was pretty broken
for the case of errors in backend startup, and proc_exit's method for
coping with errors during proc_exit was *completely* busted. Fixed per
discussions on pghackers around 11/6/99.
Tom Lane [Mon, 22 Nov 1999 02:03:21 +0000 (02:03 +0000)]
Come to think of it, DropBuffers() could have the same problem as
ReleaseRelationBuffers --- need to wait if anyone is trying to flush
out that buffer.
Tom Lane [Mon, 22 Nov 1999 01:19:42 +0000 (01:19 +0000)]
ReleaseRelationBuffers() failed to check for I/O in progress on a buffer
it wants to release. This leads to a race condition: does the backend
that's trying to flush the buffer do so before the one that's deleting the
relation does so? Usually no problem, I expect, but on occasion this could
lead to hard-to-reproduce complaints from md.c, especially mdblindwrt.
Tom Lane [Sun, 21 Nov 1999 23:25:47 +0000 (23:25 +0000)]
Combine index_info and find_secondary_indexes into a single routine that
returns a list of RelOptInfos, eliminating the need for static state
in index_info. That static state was a direct cause of coredumps; if
anything decided to elog(ERROR) partway through an index_info search of
pg_index, the next query would try to close a scan pointer that was
pointing at no-longer-valid memory. Another example of the reasons to
avoid static state variables...
Tom Lane [Sun, 21 Nov 1999 20:01:10 +0000 (20:01 +0000)]
index_destroy() must grab exclusive access to the parent table
of the index it wants to destroy. This ensures that no other backend is
actively scanning or updating that index. Getting exclusive access on
the index alone is NOT sufficient, because the executor is rather
cavalier about getting locks on indexes --- see ExecOpenIndices().
It might be better to grab index locks in the executor, but I'm not
sure the extra lockmanager traffic is really worth it just to make
index_destroy cleaner.
Tom Lane [Sun, 21 Nov 1999 04:16:17 +0000 (04:16 +0000)]
Change backend-side COPY to write files with permissions 644 not 666
(whoever thought world-writable files were a good default????). Modify
the pg_pwd code so that pg_pwd is created with 600 permissions. Modify
initdb so that permissions on a pre-existing PGDATA directory are not
blindly accepted: if the dir is already there, it does chmod go-rwx
to be sure that the permissions are OK and the dir actually is owned
by postgres.
Tom Lane [Sun, 21 Nov 1999 01:58:22 +0000 (01:58 +0000)]
Repair problem exposed by Jan's new parallel-regression-test scaffold:
inval.c thought it could safely use the catcache to look up the OIDs of
system relations. Not good, considering that inval.c could be called
during catcache loading, if a shared-inval message arrives. Rip out the
lookup logic and instead use the known OIDs from pg_class.h.
Tom Lane [Sun, 21 Nov 1999 01:53:39 +0000 (01:53 +0000)]
Tweak run_check.sh so it prints the name of each test in a parallel group
as that test finishes --- helps to give the impression that something is
happening...
Tom Lane [Sat, 20 Nov 1999 21:39:36 +0000 (21:39 +0000)]
Fix problems with CURRENT_DATE and related functions being used in
table defaults or rules: translate them to a function call so that
parse_coerce doesn't reduce them to a date or time constant immediately.
Also, eliminate a lot of redundancy in the expression grammar by
defining a new nonterminal com_expr, which contains all the productions
that can be shared by a_expr and b_expr.
Tom Lane [Tue, 16 Nov 1999 06:13:36 +0000 (06:13 +0000)]
Modify elog() logic so that it won't try to longjmp(Warn_restart) before
Warn_restart has been set by the backend main loop. This means that
elog(ERROR) or elog(FATAL) in the postmaster or during backend startup
now have well-defined behavior: proc_exit() rather than coredump.
In the case of elog() inside the postmaster, I think that proc_exit()
is probably not enough --- don't we want our child backends to be
forced to quit too? But I don't understand Vadim's recent changes in
this area, so I'll leave it to him to look over and tweak if needed.
Tom Lane [Mon, 15 Nov 1999 02:00:15 +0000 (02:00 +0000)]
Implement subselects in target lists. Also, relax requirement that
subselects can only appear on the righthand side of a binary operator.
That's still true for quantified predicates like x = ANY (SELECT ...),
but a subselect that delivers a single result can now appear anywhere
in an expression. This is implemented by changing EXPR_SUBLINK sublinks
to represent just the (SELECT ...) expression, without any 'left hand
side' or combining operator --- so they're now more like EXISTS_SUBLINK.
To handle the case of '(x, y, z) = (SELECT ...)', I added a new sublink
type MULTIEXPR_SUBLINK, which acts just like EXPR_SUBLINK used to.
But the grammar will only generate one for a multiple-left-hand-side
row expression.
Tom Lane [Fri, 12 Nov 1999 06:39:34 +0000 (06:39 +0000)]
Fix ExecSubPlan to handle nulls per the SQL spec --- it didn't combine
nulls with non-nulls using proper three-valued boolean logic. Also clean
up ExecQual to make it clearer that ExecQual *does* follow the SQL spec
for boolean nulls. See '[BUGS] (null) != (null)' thread around 10/26/99
for more detail.
Bruce Momjian [Thu, 11 Nov 1999 00:10:14 +0000 (00:10 +0000)]
In the spirit of TODO item
* Add use of 'const' for varibles in source tree
(which is misspelled, btw.)
I went through the front-end libpq code and did so. This affects in
particular the various accessor functions (such as PQdb() and
PQgetvalue()) as well as, by necessity, the internal helpers they use.
I have been really thorough in that regard, perhaps some people will find
it annoying that things like
char * foo = PQgetvalue(res, 0, 0)
will generate a warning. On the other hand it _should_ generate one. This
is no real compatibility break, although a few clients will have to be
fixed to suppress warnings. (Which again would be in the spirit of the
above TODO.)
In addition I replaced some int's by size_t's and removed some warnings
(and generated some new ones -- grmpf!). Also I rewrote PQoidStatus (so it
actually honors the const!) and supplied a new function PQoidValue that
returns a proper Oid type. This is only front-end stuff, none of the
communicaton stuff was touched.
The psql patch also adds some new consts to honor the new libpq situation,
as well as fixes a fatal condition that resulted when using the -V
(--version) option and there is no database listening.
So, to summarize, the psql you should definitely put in (with or without
the libpq). If you think I went too far with the const-mania in libpq, let
me know and I'll make adjustments. If you approve it, I will also update
the docs.
Tom Lane [Fri, 5 Nov 1999 06:43:45 +0000 (06:43 +0000)]
environment variable set by MULTIBYTE startup code should be
stored in malloc'd space, not in a static variable. Otherwise environment
variable list is corrupted if libpq is dynamically unlinked...