Bruce Momjian [Tue, 28 Sep 1999 04:34:56 +0000 (04:34 +0000)]
I have been working with user defined types and user defined c
functions. One problem that I have encountered with the function
manager is that it does not allow the user to define type conversion
functions that convert between user types. For instance if mytype1,
mytype2, and mytype3 are three Postgresql user types, and if I wish to
define Postgresql conversion functions like
I run into problems, because the Postgresql dynamic loader would look
for a single link symbol, mytype3, for both pieces of object code. If
I just change the name of one of the Postgresql functions (to make the
symbols distinct), the automatic type conversion that Postgresql uses,
for example, when matching operators to arguments no longer finds the
type conversion function.
The solution that I propose, and have implemented in the attatched
patch extends the CREATE FUNCTION syntax as follows. In the first case
above I use the link symbol mytype2_to_mytype3 for the link object
that implements the first conversion function, and define the
Postgresql operator with the following syntax
The patch includes changes to the parser to include the altered
syntax, changes to the ProcedureStmt node in nodes/parsenodes.h,
changes to commands/define.c to handle the extra information in the AS
clause, and changes to utils/fmgr/dfmgr.c that alter the way that the
dynamic loader figures out what link symbol to use. I store the
string for the link symbol in the prosrc text attribute of the pg_proc
table which is currently unused in rows that reference dynamically
loaded
functions.
Tom Lane [Tue, 28 Sep 1999 02:03:19 +0000 (02:03 +0000)]
Fix nodeAgg coredump in case where lower-level plan has
an empty targetlist *and* fails to return any tuples, as will happen
for example with 'SELECT COUNT(1) FROM table WHERE ...' if the where-
clause selects no tuples. It's so nice to make a fix by diking out code,
instead of adding more...
Bruce Momjian [Mon, 27 Sep 1999 21:02:54 +0000 (21:02 +0000)]
Sorry, guys. Here is the ultimate patch which keeps the entire
behavior as it was, apart from forbidding minus-terminated
operators. Seems that I have to break the habit of doing before
thinking properly :-/ The point is that my second patch breaks
constructs like a & b or a ! b. This patch is to be applied
instead of any of two other today's patches.
Bruce Momjian [Mon, 27 Sep 1999 19:40:40 +0000 (19:40 +0000)]
Following advice from Michael Ansley, I broke up the patch in
two: one fixes uminus and other literal length. They are to be
applied - uminus first, then possilbly literal on top of uminus.
Bruce Momjian [Mon, 27 Sep 1999 19:16:29 +0000 (19:16 +0000)]
Hello,
Two patches included:
- the first one enables the use of bool variables in fields which might
become NULL.
Up to now the lib told you that NULL is not a bool variable, even if
you provide a indicator.
- the second patch checks whether a value is null and issues an error if
no indicator is provided.
Sidenote: IIRC, the variable should be left alone if the value is NULL.
ECPGlib sets it's value to 0 on NULL. Is this a violation of the
standard?
Bruce Momjian [Mon, 27 Sep 1999 03:13:16 +0000 (03:13 +0000)]
Lots of patches coming in from me today :-)
When drawing up a very simple "text-drawing" of how the negotiation is done,
I realised I had done this last part (fallback) in a very stupid way. Patch
#4 fixes this, and does it in a much better way.
Included is also the simple text-drawing of how the negotiation is done.
Tom Lane [Sun, 26 Sep 1999 21:21:15 +0000 (21:21 +0000)]
Modify nodeAgg.c so that no rows are returned for a GROUP BY
with no input rows, per pghackers discussions around 7/22/99. Clean up
a bunch of ugly coding while at it; remove redundant re-lookup of
aggregate info at start of each new GROUP. Arrange to pfree intermediate
values when they are pass-by-ref types, so that aggregates on pass-by-ref
types no longer eat memory. This takes care of a couple of TODO items...
Tom Lane [Sun, 26 Sep 1999 02:28:44 +0000 (02:28 +0000)]
Implement constant-expression simplification per Bernard
Frankpitt, plus some improvements from yours truly. The simplifier depends
on the proiscachable field of pg_proc to tell it whether a function is
safe to pre-evaluate --- things like nextval() are not, for example.
Update pg_proc.h to contain reasonable cacheability information; as of
6.5.* hardly any functions were marked cacheable. I may have erred too
far in the other direction; see recent mail to pghackers for more info.
This update does not force an initdb, exactly, but you won't see much
benefit from the simplifier until you do one.
Tom Lane [Fri, 24 Sep 1999 00:25:33 +0000 (00:25 +0000)]
Several changes here, not very related but touching some of the same files.
* Buffer refcount cleanup (per my "progress report" to pghackers, 9/22).
* Add links to backend PROC structs to sinval's array of per-backend info,
and use these links for routines that need to check the state of all
backends (rather than the slow, complicated search of the ShmemIndex
hashtable that was used before). Add databaseOID to PROC structs.
* Use this to implement an interlock that prevents DESTROY DATABASE of
a database containing running backends. (It's a little tricky to prevent
a concurrently-starting backend from getting in there, since the new
backend is not able to lock anything at the time it tries to look up
its database in pg_database. My solution is to recheck that the DB is
OK at the end of InitPostgres. It may not be a 100% solution, but it's
a lot better than no interlock at all...)
* In ALTER TABLE RENAME, flush buffers for the relation before doing the
rename of the physical files, to ensure we don't get failures later from
mdblindwrt().
* Update TRUNCATE patch so that it actually compiles against current
sources :-(.
You should do "make clean all" after pulling these changes.
Bruce Momjian [Thu, 23 Sep 1999 19:11:09 +0000 (19:11 +0000)]
One last missing quoting bug in pg_dump:
now that sequence names are properly quoted for field defaults, mixed
case sequence names are generated. These are properly quoted in the
CREATE SEQUENCE lines, but not in the SELECT nextval lines, as per
below:
Tom Lane [Sun, 19 Sep 1999 17:20:58 +0000 (17:20 +0000)]
Remove incorrect 'Assert(targetList != NULL)'. An
INSERT ... DEFAULT VALUES statement does indeed have a null targetlist,
at least during parse and rewrite stages.
Tom Lane [Sat, 18 Sep 1999 19:10:19 +0000 (19:10 +0000)]
Update regress test expected outputs for small changes in
error message wording, due to most cases of no-such-relation now being
detected in central heap_open code rather than on an ad-hoc basis.
Tom Lane [Sat, 18 Sep 1999 19:08:25 +0000 (19:08 +0000)]
Mega-commit to make heap_open/heap_openr/heap_close take an
additional argument specifying the kind of lock to acquire/release (or
'NoLock' to do no lock processing). Ensure that all relations are locked
with some appropriate lock level before being examined --- this ensures
that relevant shared-inval messages have been processed and should prevent
problems caused by concurrent VACUUM. Fix several bugs having to do with
mismatched increment/decrement of relation ref count and mismatched
heap_open/close (which amounts to the same thing). A bogus ref count on
a relation doesn't matter much *unless* a SI Inval message happens to
arrive at the wrong time, which is probably why we got away with this
sloppiness for so long. Repair missing grab of AccessExclusiveLock in
DROP TABLE, ALTER/RENAME TABLE, etc, as noted by Hiroshi.
Recommend 'make clean all' after pulling this update; I modified the
Relation struct layout slightly.
Will post further discussion to pghackers list shortly.
Hiroshi Inoue wrote:
>
> Hello Vadim,
>
> I have a question about vacuum.
>
> VACUUM has a phase like commit which calls TransactionIdCommit().
> But if elog(ERROR) occured after that,the status of transaction is
> changed from XID_COMMIT to XID_ABORT.
>
> Seems to me this causes inconsistency.
> Shoudn't AbortTransaction() be changed not to call TransacionIdAbort()
> in case of vacuum.
Allow CASE statement to contain *only* untyped result clauses or nulls.
Almost worked before, but forgot one place to check.
Reported by Tatsuo Ishii.
Still does not do the right thing if inserting into a non-string target
column. Should look for a type coersion later, but doesn't.
Tom Lane [Mon, 13 Sep 1999 03:00:19 +0000 (03:00 +0000)]
Patch to cure O(N^2) behavior in libpq when reading a long
message under a kernel that only returns one packet per recv() call. This
didn't use to matter much, but it starts to get annoying with multi-megabyte
EXPLAIN VERBOSE responses...
Tom Lane [Mon, 13 Sep 1999 00:17:25 +0000 (00:17 +0000)]
First cut at doing something reasonable with OR-of-ANDs WHERE
conditions. There are some pretty bogus heuristics in prepqual.c that
try to decide whether to output CNF or DNF format; they need to be replaced,
likely. Right now the code is probably too willing to choose DNF form,
which might hurt performance in some cases that used to work OK.
But at least we have a foundation to build on.
Tom Lane [Sun, 12 Sep 1999 18:08:17 +0000 (18:08 +0000)]
Further improvements in cnfify: reduce amount of self-recursion
in or_normalize, remove detection of duplicate subexpressions (since it's
highly unlikely to be worth the amount of time it takes), and introduce
a dnfify() entry point so that unintelligible backwards logic in UNION
processing can be eliminated. This is just an intermediate step ---
next thing is to look at not forcing the qual into CNF form when it would
be better off in DNF form.
Tom Lane [Sat, 11 Sep 1999 22:28:11 +0000 (22:28 +0000)]
Eliminate query length limitation imposed by pg_client_to_server
and pg_server_to_client. Eliminate copy.c's restriction on the length
of a single attribute.
Tom Lane [Sat, 11 Sep 1999 22:02:51 +0000 (22:02 +0000)]
Update protocol doc to emphasize that backend can return
arbitrarily long strings, and frontends should cope gracefully. Goes
along with long query and long error message changes...
Tom Lane [Sat, 11 Sep 1999 19:06:42 +0000 (19:06 +0000)]
Eliminate elog()'s hardwired limit on length of an error message.
This change seems necessary in conjunction with long queries, and it
cleans up some bogosity in connection with long EXPLAIN texts anyway.
Note that current libpq will accept any length error message (at least
until it runs out of memory); prior versions have a limit of 8K, but
will cleanly discard excess error text, so there shouldn't be any
big compatibility problems with old clients.
Tom Lane [Thu, 9 Sep 1999 16:25:35 +0000 (16:25 +0000)]
Repair incorrect cleanup of heap memory allocation during
transaction abort --- before it only worked if there was exactly one level
of allocation context stacked in the blank portal. Now it does the right
thing for any depth, including zero...
Tom Lane [Thu, 9 Sep 1999 02:36:04 +0000 (02:36 +0000)]
Repair error noticed by Roberto Cornacchia: selectivity code
was rejecting negative attnums as bogus, which of course they are not.
Add code to get_attdisbursion to produce a useful value for OID attribute,
since VACUUM does not store stats for system attributes.
Also, repair bug that's been in eqjoinsel for a long time: it was taking
the max of the two columns' disbursions, whereas it should use the min.