Code cleanup of user name and user id handling in the backend. The current
user is now defined in terms of the user id, the user name is only computed
upon request (for display purposes). This is kind of the opposite of the
previous state, which would maintain the user name and compute the user id
for permission checks.
Besides perhaps saving a few cycles (integer vs string), this now creates a
single point of attack for changing the user id during a connection, for
purposes of "setuid" functions, etc.
Peter Eisentraut [Thu, 31 Aug 2000 16:12:35 +0000 (16:12 +0000)]
Fix relative path references so that make knowns which dependencies refer
to one another. Sort out builddir vs srcdir variable namings. Remove some
now obsoleted make variables.
Tom Lane [Wed, 30 Aug 2000 20:30:06 +0000 (20:30 +0000)]
AbortOutOfAnyTransaction() just before backend exit, to ensure that
resources are cleaned up if the user disconnected mid-transaction.
Great thanks to Hiroshi for pointing out what should have been obvious...
Hiroshi Inoue [Wed, 30 Aug 2000 08:48:55 +0000 (08:48 +0000)]
Improve the following.
=# create table t (id int4 unique);
NOTICE: CREATE TABLE/UNIQUE will create implicit index 't_id_key' for table 't'
=# begin;
query: drop table t;
NOTICE: Caution: DROP TABLE cannot be rolled back, so don't abort now
NOTICE: Caution: DROP INDEX cannot be rolled back, so don't abort now
=# rollback;
=# drop table t;
NOTICE: mdopen: couldn't open t: No such file or directory
NOTICE: RelationIdBuildRelation: smgropen(t): No such file or directory
NOTICE: mdopen: couldn't open t: No such file or directory
NOTICE: mdopen: couldn't open t: No such file or directory
NOTICE: mdopen: couldn't open t_id_key: No such file or directory
NOTICE: RelationIdBuildRelation: smgropen(t_id_key): No such file or directory
NOTICE: mdopen: couldn't open t: No such file or directory
NOTICE: RelationIdBuildRelation: smgropen(t): No such file or directory
NOTICE: mdopen: couldn't open t: No such file or directory
ERROR: cannot open relation t
Bruce Momjian [Tue, 29 Aug 2000 04:41:48 +0000 (04:41 +0000)]
* to_char:
- full support for IW (ISO week) and vice versa conversion for IW too
(the to_char 'week' support is now complete and I hope correct).
Thomas, I use for IW code from timestamp.c, for this I create separate
function date2isoweek() from original 'case DTK_WEEK:' code in the
timestamp_part(). I mean will better use one code for same feature in
date_part() and in to_char(). The isoweek2date() is added to timestamp.c
too. Right?
IMHO in 7.1 will all to_char's features complete. It is cca 41 templates
for date/time and cca 21 for numbers.
* to_ascii:
- gcc, is it correct now? :-)
In the patch is documentation for to_char's IW and for to_ascii().
Bruce Momjian [Tue, 29 Aug 2000 04:20:47 +0000 (04:20 +0000)]
This is mostly the same as an earlier patch I
didn't hear anything about, but which would
have broken with the function manager changes
anyway.
Well, this patch checks that a unique constraint
of some form (unique or pk) is on the referenced
columns of an FK constraint and that the columns
in the referencing table exist at creation time.
The former is to move closer to SQL compatibility
and the latter is in answer to a bug report.
I also added a basic check of this functionality
to the alter table and foreign key regression
tests.
Bruce Momjian [Tue, 29 Aug 2000 04:15:43 +0000 (04:15 +0000)]
Here is a patch against the same cvs tree as the SSL patch (Aug 20).
I hope I didn't mess the SGML up too bad, but somebody should definitly
look that over. I tried to steal as much as I could from around :-)
This patch updates:
* Installation instructions (paragraph on how to compile with openssl)
* Documentation of pg_hba.conf (added "hostssl" record docs)
* Libpq documentation (added connection option, documentation of
PQgetssl() function)
* Add section on SSL to "Server Runtime Environment"
If you beleive any particular area needs more attention, please let me know.
Peter Eisentraut [Mon, 28 Aug 2000 11:53:23 +0000 (11:53 +0000)]
New configure test for flex, which recognizes only flex but does so in all
incarnations (I hope). When an acceptable flex version is not found, print
instructive error messages from both configure and the makefiles, so that
users can continue building anyway.
Tom Lane [Sun, 27 Aug 2000 21:50:18 +0000 (21:50 +0000)]
Clean up callers of AllocateFile and BasicOpenFile to ensure that
a reasonable error message (including the kernel errno message)
is reported on any file open failure.
Tom Lane [Sun, 27 Aug 2000 21:48:00 +0000 (21:48 +0000)]
Change ReleaseLruFile() usage so that if we cannot release any more
virtual FDs, we just return the ENFILE/EMFILE error to the caller,
rather than immediate elog(). This allows more robust behavior in
the postmaster, which uses AllocateFile() but does not want elog().
Peter Eisentraut [Sat, 26 Aug 2000 21:11:45 +0000 (21:11 +0000)]
Fix AC_FUNC_ACCEPT_ARGTYPES to accept `const struct sockaddr *' as second
argument, change the order of tests for the third argument to be safe
against missing prototypes, and make it fail hard if none of the
combinations succeed.
Tom Lane [Fri, 25 Aug 2000 18:05:54 +0000 (18:05 +0000)]
Avoid creating a TOAST table if we can prove that the maximum tuple
length is < TOAST_TUPLE_THRESHOLD, even with toastable column types
present. For example, CREATE TABLE foo (f1 int, f2 varchar(100))
does not require a toast table, even though varchar is a toastable
type.
Fix typos and inconsistancies found by He Weiping
(aka Henry) <laser@zhangmai.com.cn>.
Fix new problems in insert.sgml and create_function.sgml which kept jade
from completing.
Tatsuo Ishii [Fri, 25 Aug 2000 14:24:09 +0000 (14:24 +0000)]
Change return type of:
pg_mb2wchar(const unsigned char *, pg_wchar *);
pg_mb2wchar_with_len(const unsigned char *, pg_wchar *, int);
from void to int. Now they return the number of
wide chars.
Peter Eisentraut [Fri, 25 Aug 2000 10:00:35 +0000 (10:00 +0000)]
Make the location of the Kerberos server key file run time configurable
(rather than compile time). For libpq, even when Kerberos support is
compiled in, the default user name should still fall back to geteuid()
if it can't be determined via the Kerberos system.
A couple of fixes for string type configuration parameters, now that there
is one.
Tom Lane [Thu, 24 Aug 2000 03:29:15 +0000 (03:29 +0000)]
SQL-language functions are now callable in ordinary fmgr contexts ...
for example, an SQL function can be used in a functional index. (I make
no promises about speed, but it'll work ;-).) Clean up and simplify
handling of functions returning sets.
Add functions to convert to and from text, and to truncate to MAC OUI.
Remove hardcoded macaddr_manuf(), which had really old, obsolete info.
Replace this with some contrib/mac/ code to maniag OUI info from IEEE.
Fix several <ulink> tags which refer to e-mail addresses
but were missing the "mailto:" prefix.
Fix typo.
Thanks to Neil Conway <nconway@klamath.dyndns.org> for the heads-up.
Tom Lane [Tue, 22 Aug 2000 04:06:22 +0000 (04:06 +0000)]
Fix a many-legged critter reported by chifungfan@yahoo.com: under the
right circumstances a hash join executed as a DECLARE CURSOR/FETCH
query would crash the backend. Problem as seen in current sources was
that the hash tables were stored in a context that was a child of
TransactionCommandContext, which got zapped at completion of the FETCH
command --- but cursor cleanup executed at COMMIT expected the tables
to still be valid. I haven't chased down the details as seen in 7.0.*
but I'm sure it's the same general problem.
Tom Lane [Mon, 21 Aug 2000 20:55:31 +0000 (20:55 +0000)]
Move pg_checkretval out of the planner (where it never belonged) into
pg_proc.c (where it's actually used). Fix it to correctly handle tlists
that contain resjunk target items, and improve error messages. This
addresses bug reported by Krupnikov 6-July-00.
Tom Lane [Mon, 21 Aug 2000 18:23:18 +0000 (18:23 +0000)]
Fix format_type() to display correct lengths for BIT/BIT VARYING.
Also, make it depend on type OIDs rather than type names for more
consistency with rest of backend.
Tom Lane [Mon, 21 Aug 2000 17:22:36 +0000 (17:22 +0000)]
fmgr interface mopup work. Use new DatumGetBool and BoolGetDatum
macros where appropriate (the code used to have several different ways
of doing that, including Int32, Int8, UInt8, ...). Remove last few
references to float32 and float64 typedefs --- it's all float4/float8
now. The typedefs themselves should probably stay in c.h for a release
or two, though, to avoid breaking user-written C functions.
Tom Lane [Mon, 21 Aug 2000 04:48:57 +0000 (04:48 +0000)]
First pass at integrating BIT and BIT VARYING code from Adriaan Joubert.
Update functions to new-style fmgr, make BIT and VARBIT be binary-
equivalent, add entries to allow these types to be btree indexed,
correct a few bugs. BIT/VARBIT are now toastable, too.
NOTE: initdb forced due to catalog updates.
Tom Lane [Sun, 13 Aug 2000 02:50:35 +0000 (02:50 +0000)]
Clean up handling of variable-free qual clauses. System now does the
right thing with variable-free clauses that contain noncachable functions,
such as 'WHERE random() < 0.5' --- these are evaluated once per
potential output tuple. Expressions that contain only Params are
now candidates to be indexscan quals --- for example, 'var = ($1 + 1)'
can now be indexed. Cope with RelabelType nodes atop potential indexscan
variables --- this oversight prevents 7.0.* from recognizing some
potentially indexscanable situations.
Tom Lane [Sat, 12 Aug 2000 05:15:24 +0000 (05:15 +0000)]
Mop-up for removal of ':' and ';' operators ... like, say, actually
take 'em out of pg_operator. Also remove from scan.l's set of legal
operator characters. Update documentation.
Tom Lane [Fri, 11 Aug 2000 23:45:35 +0000 (23:45 +0000)]
copyObject() and equal() now know about all parse-time node types,
including utility statements. Still can't copy or compare executor
state, but at present that doesn't seem to be necessary. This makes
it possible to execute most (all?) utility statements in plpgsql.
Had to change parsetree representation of CreateTrigStmt so that it
contained only legal Nodes, and not bare string constants.
Tom Lane [Tue, 8 Aug 2000 15:43:12 +0000 (15:43 +0000)]
Remove 'func_tlist' from Func expression nodes, likewise 'param_tlist'
from Param nodes, per discussion a few days ago on pghackers. Add new
expression node type FieldSelect that implements the functionality where
it's actually needed. Clean up some other unused fields in Func nodes
as well.
NOTE: initdb forced due to change in stored expression trees for rules.
Tom Lane [Mon, 7 Aug 2000 20:16:13 +0000 (20:16 +0000)]
TOAST mop-up work: update comments for tuple-size-related symbols such
as MaxHeapAttributeNumber. Increase MaxAttrSize to something more
reasonable (given what it's used for, namely checking char(n) declarations,
I didn't make it the full 1G that it could theoretically be --- 10Mb
seemed a more reasonable number). Improve calculation of MaxTupleSize.
Allow LIKE and ILIKE as TokenId (and hence ColId) to make sure that they
are allowed in the func_name production. Otherwise, we can't define
more like() and ilike() functions for new data types.
Clean up code to remove the explicit backslash cruft.
If the backslash default is still wanted, just pass a backslash
to MatchText() for the two-parameter callable routines.
Tom Lane [Mon, 7 Aug 2000 00:51:42 +0000 (00:51 +0000)]
Clean up bogosities in use of random(3) and srandom(3) --- do not assume
that RAND_MAX applies to them, since it doesn't. Instead add a
config.h parameter MAX_RANDOM_VALUE. This is currently set at 2^31-1
but could be auto-configured if that ever proves necessary. Also fix
some outright bugs like calling srand() where srandom() is appropriate.
Implement LIKE/ESCAPE. Change parser to use like()/notlike()
rather than the "~~" operator; this made it easy to add ESCAPE features.
Implement ILIKE, NOT ILIKE, and the ESCAPE clause for them.
afaict this is not MultiByte clean, but lots of other stuff isn't either.
Fix up underlying support code for LIKE/NOT LIKE.
Things should be faster and does not require internal string copying.
Update regression test to add explicit checks for
LIKE/NOT LIKE/ILIKE/NOT ILIKE.
Remove colon and semi-colon operators as threatened in 7.0.
Implement SQL99 COMMIT/AND NO CHAIN.
Throw elog(ERROR) on COMMIT/AND CHAIN per spec
since we don't yet support it.
Implement SQL99 CREATE/DROP SCHEMA as equivalent to CREATE DATABASE.
This is only a stopgap or demo since schemas will have another
implementation soon.
Remove a few unused production rules to get rid of warnings
which crept in on the last commit.
Fix up tabbing in some places by removing embedded spaces.
Implement LIKE/ESCAPE. Change parser to use like()/notlike()
rather than the "~~" operator; this made it easy to add ESCAPE features.
Implement ILIKE, NOT ILIKE, and the ESCAPE clause for them.
afaict this is not MultiByte clean, but lots of other stuff isn't either.
Fix up underlying support code for LIKE/NOT LIKE.
Things should be faster and does not require internal string copying.
Update regression test to add explicit checks for
LIKE/NOT LIKE/ILIKE/NOT ILIKE.
Remove colon and semi-colon operators as threatened in 7.0.
Implement SQL99 COMMIT/AND NO CHAIN.
Throw elog(ERROR) on COMMIT/AND CHAIN per spec
since we don't yet support it.
Implement SQL99 CREATE/DROP SCHEMA as equivalent to CREATE DATABASE.
This is only a stopgap or demo since schemas will have another
implementation soon.
Remove a few unused production rules to get rid of warnings
which crept in on the last commit.
Fix up tabbing in some places by removing embedded spaces.
Support SQL99 embedded double-quote syntax for quoted identifiers.
Allow this in the parser and in pg_dump, but it is probably not enough
for a complete solution.
Better to have the feature started then never here.
Tom Lane [Sun, 6 Aug 2000 04:40:08 +0000 (04:40 +0000)]
Toast all the system-table columns that seem to need it. It turns out
that giving pg_proc a toast table required solving the same problems
we'd have to solve for pg_class --- pg_proc is one of the relations
that gets bootstrapped in relcache.c. Solution is to go back at the
end of initialization and read in the *real* pg_class row to replace
the phony entry created by formrdesc(). This should work as long as
there's no need to touch any toasted values during initialization,
which seems a reasonable assumption.
Although I did not add a toast-table for every single system table
with a varlena attribute, I believe that it would work to just do
ALTER TABLE pg_class CREATE TOAST TABLE. So anyone who's really
intent on having several thousand ACL entries for a rel could do it.
NOTE: I didn't force initdb, but you must do one to see the effects
of this patch.
Tom Lane [Sun, 6 Aug 2000 04:26:40 +0000 (04:26 +0000)]
Clean up inefficiency in ExecRelCheck, and cause it to do the right
thing when there are multiple result relations. Formerly, during
something like 'UPDATE foo*', foo's constraints and *only* foo's
constraints would be applied to all foo's children. Wrong-o ...
Tom Lane [Sun, 6 Aug 2000 04:17:47 +0000 (04:17 +0000)]
Ensure that catcache 'busy' flags are reset at transaction abort.
Without this, an elog during cache-entry load leaves that catcache
unusable. elog in that segment of code is pretty unusual but it can
happen.
Tom Lane [Sun, 6 Aug 2000 04:13:22 +0000 (04:13 +0000)]
Copy sub-Query nodes to avoid trouble when same sub-Query is linked to
multiple times in the parsetree (can happen in COALESCE or BETWEEN
contexts, for example). This is a pretty grotty solution --- it will
do for now, but perhaps we can do better when we redesign querytrees.
What we need is a consistent policy about whether querytrees should be
considered read-only structures or not ...
Philip Warner [Sat, 5 Aug 2000 09:57:46 +0000 (09:57 +0000)]
- Only disable triggers for the table being loaded
- disable triggers prior to BLOB load
- better query for loading blob xrefs
- Fixes to error handling code
Bruce Momjian [Fri, 4 Aug 2000 15:45:12 +0000 (15:45 +0000)]
to_ascii( text )
- encode 'text' from database encoding to ASCII
to_ascii('\256\341k')
to_ascii( text, int4 )
- encode 'text' from 'int4' encoding to ASCII
to_ascii('\256\341k', 8)
to_ascii( text, name )
- encode 'text' from 'name' encoding to ASCII
to_ascii('\256\341k', 'LATIN2')
Now is supported LATIN1, LATIN2, WIN1250. For other character sets I
haven't good resources. Add new encoding is easy...
If encoding is not supported returns ERROR.
Note --- not exists total corect conversion to ASCII, this function try
convert chars those is _probably_ interpret-able in ASCII for
others use ' '. But for example for all Czech characters it is
sufficient ... hmm Chinese / JAP and other complicated langs
have
bad luck here :-(
Tom Lane [Fri, 4 Aug 2000 04:16:17 +0000 (04:16 +0000)]
Fix tuptoaster bugs induced by making bytea toastable. Durn thing was
trying to toast tuples inserted into toast tables! Fix is two-pronged:
first, ensure all columns of a toast table are marked attstorage='p',
and second, alter the target chunk size so that it's less than the
threshold for trying to toast a tuple. (Code tried to do that but the
expression was wrong.) A few cosmetic cleanups in tuptoaster too.
NOTE: initdb forced due to change in toaster chunk-size.