Commit Graph

3310 Commits

Author SHA1 Message Date
Tom Lane 25a7a7f446 Clean up grotty references to CacheCxt (externs inside functions,
duplicate global declarations, no points for style at all!)
2000-05-20 23:11:29 +00:00
Tatsuo Ishii 1a6daef70d Enhance multibyte support.
SJIS UDC (NEC selection IBM kanji) support contributed by Eiji Tokuya
2000-05-20 13:12:26 +00:00
Tatsuo Ishii f1cb756c38 Add KEEPALIVE option to the socket of backend. This will automatically
terminate the backend that has no frontend anymore.
2000-05-20 13:10:54 +00:00
Tom Lane f923260ec8 Revise FlushRelationBuffers/ReleaseRelationBuffers per discussion with
Hiroshi.  ReleaseRelationBuffers now removes rel's buffers from pool,
instead of merely marking them nondirty.  The old code would leave valid
buffers for a deleted relation, which didn't cause any known problems
but can't possibly be a good idea.  There were several places which called
ReleaseRelationBuffers *and* FlushRelationBuffers, which is now
unnecessary; but there were others that did not.  FlushRelationBuffers
no longer emits a warning notice if it finds dirty buffers to flush,
because with the current bufmgr behavior that's not an unexpected
condition.  Also, FlushRelationBuffers will flush out all dirty buffers
for the relation regardless of block number.  This ensures that
pg_upgrade's expectations are met about tuple on-row status bits being
up-to-date on disk.  Lastly, tweak BufTableDelete() to clear the
buffer's tag so that no one can mistake it for being a still-valid
buffer for the page it once held.  Formerly, the buffer would not be
found by buffer hashtable searches after BufTableDelete(), but it would
still be thought to belong to its old relation by the routines that
sequentially scan the shared-buffer array.  Again I know of no bugs
caused by that, but it still can't be a good idea.
2000-05-19 03:22:31 +00:00
Tom Lane db90fdf9ab Correct busted syntax of CC invocation for tas.s. 2000-05-19 02:50:32 +00:00
Bruce Momjian 6108a7ed6a Change remove function warning for built-ins. 2000-05-18 16:09:38 +00:00
Bruce Momjian feaf1fc137 Throw NOTICE on built-in function removal 2000-05-18 15:45:00 +00:00
Tom Lane ba26aeebc1 Reduce COPY IN lock from AccessExclusive to a more reasonable
RowExclusive (my fault).  Also, install a check to prevent people
from trying COPY BINARY to stdout/from stdin.  No way that will
work unless we redesign the frontend COPY protocol ... which is
not worth the trouble in the near future ...
2000-05-18 01:52:45 +00:00
Bruce Momjian a47e20b049 Several compilation and run-time problems occur when building on SGI
IRIX systems using the native compilers.  A summary is:
- Various files use "//" as a comment delimiter in c files.
- Problems caused by assuming "char" is signed.
  cash.in: building -signed the rules regression test fails as described
    in FAQ_QNX4.  If CHAR_MAX is "255U" then ((signed char)CHAR_MAX) is -1.
  postmaster.c: random number regression test failed without this change.
- Some generic build issues and warning message cleanup.

David Kaelbling
2000-05-16 20:48:52 +00:00
Tom Lane 6dd06737ba Remove configure check for how to abbreviate 'tr A-Z a-z', and instead
just use the portable form,
tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
There were a bunch of places that weren't paying attention to configure's
result anyway (including configure itself!?); clean them up too.
2000-05-16 02:14:15 +00:00
Bruce Momjian bdeeb4fe8a Finally fix LISTEN problem. 2000-05-14 03:18:35 +00:00
Tom Lane e8e7b6305a Tweak selectivity for area-based operators. Still a crock... 2000-05-13 06:04:46 +00:00
Bruce Momjian a28f117790 This is the second time I've answered this exact same problem in two
days.  It seems to be a FAQ, and I think I know why. When creating a 'c'
language function, CREATE FUNCTION is fed the shared object filename,
and seems to succeed. Only when trying to use the function is an error
thrown, by which time the coder thinks something's wrong with executing
the code, not with loading it.

I think I once saw it proposed to load shared objects at function creation
time, but that idea was shot down on the grounds of resident memory bloat,
ISTR. Here's a patch for a compromise: all it does is stat() the file,
just like the loader code does, so that the errors caused by non existent
files, and no directory 'x' permissions (the most common ones, it seems),
get caught while the developer is still thinking about code loading. It
doesn't catch all errors (like the code not being readable by the postgres
user) but seems to catch the most common, without actually opening the file.

What do you think?

Ross
2000-05-12 18:51:59 +00:00
Tom Lane 475cb157b9 Squash some more CLUSTER bugs. Never has worked on multiple-column
indexes, apparently, nor on functional indexes with more than one input
column (force of natts = 1 was in the wrong branch of IF statement).
Coredumped if source relation contained any uncommitted tuples, due to
failure to test for success return from heap_fetch.  Fetched tuple
was passed directly to heap_insert, which clobbers the TID and commit
status in the tuple header it's given, which meant that the source
relation's tuples all got trashed as the copy proceeded.  Abort partway
through, and you're left with a lot of missing tuples.
I wonder what else is lurking here ...
2000-05-12 16:10:09 +00:00
Tom Lane 01911c98db Repair list-vs-node confusion that resulted in failure for INNER JOIN ON.
Make it behave correctly when there are more than two tables being
joined, also.  Update regression test expected outputs.
2000-05-12 01:33:56 +00:00
Bruce Momjian 8101d0c571 Makefile CFLAGS cleanups. 2000-05-11 17:46:35 +00:00
Tom Lane 37c652f89b Fix CLUSTER ... or at least undo the bit-rot it's suffered since 6.5.
It's still pretty fundamentally bogus :-(.
Freebie side benefit: ALTER TABLE RENAME works on indexes now.
2000-05-11 03:54:18 +00:00
Tom Lane 3bd03b3803 Make the indexes on pg_group be shared system relations. 2000-05-05 03:09:43 +00:00
Tom Lane 570a58f427 Don't leak a file descriptor when updating pg_pwd file. Also, check for
failure of rename() call.
2000-05-04 20:06:07 +00:00
Tatsuo Ishii 832877e95a Modify getdatabaseencoding(), pg_encoding_to_char()
pg_char_to_encoding() in multibyte disbaled case so that it does not
throw an error, rather return HARD CODED default value (currently SQL_ASCII).
This would solve the "non-mb backend vs. mb-enabled frontend" problem.
2000-05-02 08:13:08 +00:00
Tom Lane f6a3b87c7b Reset CurrentMemoryContext to TopMemoryContext at the beginning of error
cleanup, ie, as soon as we have caught the longjmp.  This ensures that
current context will be a valid context throughout error cleanup.  Before
it was possible that current context was pointing at a context that would
get deleted during cleanup, leaving any subsequent pallocs in deep
trouble.  I was able to provoke an Assert failure when compiled with
asserts + -DCLOBBER_FREED_MEMORY, if I did something that would cause
an error to be reported by the backend large-object code, because indeed
that code operates in a context that gets deleted partway through xact
abort --- and CurrentMemoryContext was still pointing at it!  Boo hiss.
2000-04-30 21:29:23 +00:00
Tom Lane e0095c6c42 Remove bogus 'xid loop detected' check, which actually wasn't detecting
loops, but just arbitrarily failing at 1000 locks.
2000-04-30 21:23:31 +00:00
Tom Lane a90dc572ed Setting statistic options from SET PG_OPTIONS caused a backend crash
because StatFp never got set in that case.  Set it immediately before
use to eliminate such problems.
2000-04-28 05:07:34 +00:00
Tom Lane f106779263 Except_Intersect_Rewrite() failed to ignore resjunk targetlist entries,
thus causing failure if one sub-select had resjunk entries that the other
did not (cf. bug report from Espinosa 4/27/00).
2000-04-27 20:32:41 +00:00
Tom Lane d6eac08f11 Repair problem noted by Elphick: make_rels_by_joins failed to handle
cases where joinclauses were present but some joins have to be made
by cartesian-product join anyway.  An example is
SELECT * FROM a,b,c WHERE (a.f1 + b.f2 + c.f3) = 0;
Even though all the rels have joinclauses, we must join two of them
in cartesian style before we can use the join clause...
2000-04-27 18:35:04 +00:00
Tom Lane 85a5303877 -D switch to postmaster should override any PGDATA environment variable
that might be hanging about.  Now it does ... amazing nobody noticed
this before ...
2000-04-27 02:59:17 +00:00
Tom Lane 1b4f150541 Tweak outUnique to include uniqColIdx[] field in the printout. This does
not cause any compatibility problems because stored rules don't contain
plan nodes --- in fact, we don't even have a readfunc for Unique nodes.
2000-04-26 23:39:10 +00:00
Tom Lane 6a4fa7eccb On HPUX, shl_load should be called with options BIND_IMMEDIATE rather
than BIND_DEFERRED.  That way, if the loaded library has unresolved
references, shl_load fails cleanly.  As we had it, shl_load would
succeed and then the dynlinker would call abort() when we try to call
into the loaded library.  abort()ing a backend is uncool.
2000-04-26 23:35:34 +00:00
Hiroshi Inoue 56e09ddf0c change reindex ERROR/NOTICE message 2000-04-25 10:38:38 +00:00
Tom Lane f46c1f1e33 Check that user-specified opclass in CREATE INDEX corresponds to operators
that will actually work on the column datatype.
2000-04-25 02:45:54 +00:00
Tom Lane 97f0521d8e Produce an appropriate error message when opclass is not supported by
specified index access method.  Clean up wording of some existing error
messages, too.
2000-04-23 01:44:55 +00:00
Tom Lane 8994662a0b 7.0 buffer manager can support different backends running with different
fsync settings, so the -F option no longer needs to be treated as secure.
2000-04-23 00:13:16 +00:00
Tom Lane 87e701b8d5 Clean up const-vs-not-const compiler warning in MULTIBYTE code.
'Twas my fault, I think.
2000-04-20 22:40:18 +00:00
Tom Lane 7c22d2e5f0 Correct error in rewriter that caused SELECT count(*) FROM view
to give wrong results: it should be looking at inJoinSet not inFromCl.
Also, make 'modified' flag be local to ApplyRetrieveRule: we should
append a rule's quals to the query iff that particular rule applies,
not if we have fired any previously-considered rule for the query!
2000-04-20 00:31:49 +00:00
Tom Lane 32e192d712 Repair coredump seen when a view refers to an inheritance group
(SELECT FROM table*).  Cause was reference to 'eref' field of an RTE,
which is null in an RTE loaded from a stored rule parsetree.  There
wasn't any good reason to be touching the refname anyway...
2000-04-18 05:52:35 +00:00
Tom Lane 25442d8d2f Correct oversight in hashjoin cost estimation: nodeHash sizes its hash
table for an average of NTUP_PER_BUCKET tuples/bucket, but cost_hashjoin
was assuming a target load of one tuple/bucket.  This was causing a
noticeable underestimate of hashjoin costs.
2000-04-18 05:43:02 +00:00
Tom Lane 82849df6c6 Add new selectivity estimation functions for pattern-matching operators
(LIKE and regexp matches).  These are not yet referenced in pg_operator,
so by default the system will continue to use eqsel/neqsel.
Also, tweak convert_to_scalar() logic so that common prefixes of strings
are stripped off, allowing better accuracy when all strings in a table
share a common prefix.
2000-04-16 04:41:03 +00:00
Tom Lane 8c3b52e7b2 Allow COPY WITH OIDS to system OID values --- rely on unique indexes to
prevent duplicate OIDs from being added.  Clean up redundant error
messages.
2000-04-16 04:27:52 +00:00
Tom Lane a6acf1a06a Show failing OID in 'cache lookup failed' messages. 2000-04-16 04:25:42 +00:00
Tom Lane 1460dd0eff Show failing OID in 'cache lookup failed' messages. 2000-04-16 04:16:55 +00:00
Tom Lane 8064a49f6f get_relattval() should treat a NULL constant as a non-constant expression,
since it has no way to indicate to its caller that the constant is
actually NULL.  This prevents coredump in cases like
  WHERE textfield < null::text;
2000-04-16 01:55:45 +00:00
Tom Lane 4ca7d148cb elog(NOTICE) during COPY incorrectly reset lineno to 0, causing any
subsequent elogs() in the same COPY operation to display the wrong
line number.  Fix is to clear lineno only when elog level is such
that we will not return to caller.
2000-04-15 19:13:08 +00:00
Thomas G. Lockhart d221e149b4 Fix (well, add) support for ISO "week" in date_part(). Needed for ODBC.
Fix spelling of "millennium".
 Thanks to Mika Nystrom <mika@camembert.cs.caltech.edu> for spotting this.
2000-04-14 15:22:10 +00:00
Tom Lane 07672d4e0a Skip setsockopt(SO_REUSEADDR) for the Unix-domain postmaster socket on
all platforms, not just SCO.  The operation is undefined for Unix-domain
sockets anyway.  It seems SCO is not the only platform that complains
instead of treating the call as a no-op.
2000-04-14 00:51:58 +00:00
Tom Lane 9d91db4fde Repair bug reported by Wickstrom: backend would crash if WHERE clause
contained a sub-SELECT nested within an AND/OR tree that cnfify()
thought it should rearrange.  Same physical sub-SELECT node could
end up linked into multiple places in resulting expression tree.
This is harmless for most node types, but not for SubLink.
Repair bug by making physical copies of subexpressions that get
logically duplicated by cnfify().  Also, tweak the heuristic that
decides whether it's a good idea to do cnfify() --- we don't really
want that to happen when it would cause multiple copies of a subselect
to be generated, I think.
2000-04-14 00:19:17 +00:00
Jan Wieck 3e00c9db4a Fixed CREATE TYPE to recognize changed parsenodes
Jan
2000-04-13 11:51:07 +00:00
Bruce Momjian 52f77df613 Ye-old pgindent run. Same 4-space tabs. 2000-04-12 17:17:23 +00:00
Bruce Momjian 37e7c7dfcb Fix assert with missing semicolon 2000-04-12 04:58:09 +00:00
Tom Lane 2692d329eb Tweak smgrblindwrt per advice from Vadim: add parameter indicating
whether to do fsync or not, and if so (which should be seldom) just
do the fsync immediately.  This way we need not build data structures
in md.c/fd.c for blind writes.
2000-04-10 23:41:52 +00:00
Bruce Momjian a447ae2221 The constant in backend/utils/misc/trace.c, line 32 limits the length of
logged queries to 1024, truncating longer queries.  That is about half of
the size I need (I have a union that is 2K long).  Can someone consider
bumping it to 4K or so?  Patch attached...

Regards,
Ed Loehr
2000-04-10 19:25:29 +00:00
Hiroshi Inoue 8a5851880e Fix an Assert bug(was my fault) pointed out by Tom Lane. 2000-04-10 00:45:42 +00:00
Tom Lane 1f6d8b90b8 Buffer manager modifications to keep a local buffer-dirtied bit as well
as a shared dirtybit for each shared buffer.  The shared dirtybit still
controls writing the buffer, but the local bit controls whether we need
to fsync the buffer's file.  This arrangement fixes a bug that allowed
some required fsyncs to be missed, and should improve performance as well.
For more info see my post of same date on pghackers.
2000-04-09 04:43:20 +00:00
Tom Lane 9c38a8d296 Further tweaking of indexscan cost estimates. 2000-04-09 04:31:37 +00:00
Bruce Momjian 9b7ba2002d Add new pg_options.sample file. 2000-04-08 19:38:00 +00:00
Tom Lane bb7e5dc2c0 Tweak TypeCategory to treat new BIT types as of STRING category, rather
than not knowing what they are at all.  Perhaps they should have their own
type category?  Hard to say.  In the meantime, doing it this way allows
SELECT 'unknown' || 'unknown' to continue being resolved as textcat,
instead of spitting out an ambiguous-operator error.
2000-04-08 19:29:40 +00:00
Tom Lane ed845c7374 Fix relcache refcount leakage when inv_drop is applied
to a non-LO relation.
2000-04-08 04:37:07 +00:00
Thomas G. Lockhart 0337938fbf Add zpbit and varbit data types from Adrian Joubert
<a.joubert@albourne.com>.
2000-04-08 02:13:11 +00:00
Tom Lane dc070fdea6 Add copyObject logic for TruncateStmt and a few other utility-statement
parse node types.  This allows these statements to be placed in a plpgsql
function.  Also, see to it that statement types not handled by the copy
logic will draw an appropriate elog(ERROR), instead of leaving a null
pointer that will cause coredump later on.  More utility statements could
be added if anyone felt like turning the crank.
2000-04-08 00:21:15 +00:00
Bruce Momjian 28fb1c196b Update create_rule manual page. 2000-04-07 19:17:51 +00:00
Thomas G. Lockhart a349733bbb Add transcendental math functions (sine, cosine, etc)
Add a random number generator and seed setter (random(), SET SEED)
Fix up the interval*float8 math to carry partial months
 into the time field.
Add float8*interval so we have symmetry in the available math.
Fix the parser and define.c to accept SQL92 types as field arguments.
Fix the parser to accept SQL92 types for CREATE TYPE, etc. This is
 necessary to allow...
Bit/varbit support in contrib/bit cleaned up to compile and load
 cleanly. Still needs some work before final release.
Implement the "SOME" keyword as a synonym for "ANY" per SQL92.
Implement ascii(text), ichar(int4), repeat(text,int4) to help
 support the ODBC driver.
Enable the TRUNCATE() function mapping in the ODBC driver.
2000-04-07 13:40:45 +00:00
Vadim B. Mikheev 71b4790b6d Commebts & one check in EndEvalPlanQual(). 2000-04-07 07:24:47 +00:00
Tom Lane e4d8d43c52 Fix (I hope) resource leakage in EvalPlanQual: open subplans must be
properly shut down in EndPlan, else we fail to free buffers and so forth
that they hold.
2000-04-07 00:59:17 +00:00
Tom Lane 891039c15f Partial fix for EvalPlanQual bugs reported by Magnus Hagander, 3-Apr.
Ensure that outer tuple link needed for inner indexscan qual evaluation
gets set in the EvalPlanQual case.  This stops coredump, but we still
have resource leaks due to failure to clean up EvalPlanQual properly...
2000-04-07 00:30:41 +00:00
Bruce Momjian 65ea4f677f Allow vacuum of temporary tables 2000-04-06 18:12:07 +00:00
Tom Lane eace269b47 Repair assert failure in tuple-chain-moving logic (introduced by yours
truly, I'm afraid).
2000-04-06 00:29:51 +00:00
Tom Lane 5240c76729 Actually, that still wasn't quite right. If we skip a query because of
xact abort state in pg_exec_query_dest, we should continue scanning the
querytree list, on the off chance that one of the later queries in the
string is COMMIT or ROLLBACK.
2000-04-04 23:52:50 +00:00
Tom Lane 708f82f191 Fix bug noted by Bruce: FETCH in an already-aborted transaction block
would crash, due to premature invocation of SetQuerySnapshot().  Clean
up problems with handling of multiple queries by splitting
pg_parse_and_plan into two routines.  The old code would not, for
example, do the right thing with END; SELECT... submitted in one query
string when it had been in transaction abort state, because it'd decide
to skip planning the SELECT before it had executed the END.  New
arrangement is simpler and doesn't force caller to plan if only
parse+rewrite is needed.
2000-04-04 21:44:40 +00:00
Tom Lane 7fbf0af22b When rewriting an aggregate introduced into WHERE, allow agg argument to
be an expression not just a simple Var, so long as only one table is
referenced (so that code isn't really any more difficult than before).
This whole thing is still fundamentally bogus, but at least we can accept
a few more cases than before.
2000-04-04 02:30:52 +00:00
Tom Lane 1c72a8a37a Fix extremely nasty little bug observed when a sub-SELECT appears in
WHERE in a place where it can be part of a nestloop inner indexqual.
As the code stood, it put the same physical sub-Plan node into both
indxqual and indxqualorig of the IndexScan plan node.  That confused
later processing in the optimizer (which expected that tracing the
subPlan list would visit each subplan node exactly once), and would
probably have blown up in the executor if the planner hadn't choked first.
Fix by making the 'fixed' indexqual be a complete deep copy of the
original indexqual, rather than trying to share nodes below the topmost
operator node.  This had further ramifications though, because we were
making the aforesaid list of sub-Plan nodes during SS_process_sublinks
which is run before construction of the 'fixed' indexqual, meaning that
the copy of the sub-Plan didn't show up in that list.  Fix by rearranging
logic so that the sub-Plan list is built by the final set_plan_references
pass, not in SS_process_sublinks.  This may sound like a mess, but it's
actually a good deal cleaner now than it was before, because we are no
longer dependent on the assumption that planning will never make a copy
of a sub-Plan node.
2000-04-04 01:21:48 +00:00
Tom Lane 14bc951d30 Fix low-probability bug in relcache startup: write_irels wrote the
pg_internal.init file in-place, which meant that if another backend
started at about the same time, it might read the incomplete file.
init_irels tries to guard against that, but I have now seen a crash
due to reading bad data from a partly-written file.  (This may indicate
a kernel bug on my platform?  Not sure.)  Anyway, clearly the safest
course is to write the new pg_internal.init file under a unique temporary
filename, and rename it into place only after it's all written.
2000-03-31 19:39:22 +00:00
Tom Lane ca05ba2a9d Get rid of SetBufferWriteMode(), which was an accident waiting to happen.
In the event of an elog() while the mode was set to immediate write,
there was no way for it to be set back to the normal delayed write.
The mechanism was a waste of space and cycles anyway, since the only user
was varsup.c, which could perfectly well call FlushBuffer directly.
Now it does just that, and the notion of a write mode is gone.
2000-03-31 02:43:31 +00:00
Tom Lane 5717dcb8a7 New coding for SET provoked a 'var might be used uninitialized' warning
from gcc.  Which wasn't actually a code bug, but I don't like warnings.
2000-03-31 02:11:03 +00:00
Thomas G. Lockhart 362575b782 Enable more flexible syntax for the SET command. Now allows single floats,
single integers, and lists of names, without surrounding them with quotes.
Remove all tokens which are defined as operators from ColID and ColLabel
 to avoid precedence confusion. Thanks to Tom Lane for catching this.
2000-03-30 06:02:36 +00:00
Tom Lane e55985d3be Tweak indexscan cost estimation: round estimated # of tuples visited up
to next integer.  Previously, if selectivity was small, we could compute
very tiny scan cost on the basis of estimating that only 0.001 tuple
would be fetched, which is silly.  This naturally led to some rather
silly plans...
2000-03-30 00:53:30 +00:00
Thomas G. Lockhart 1b113a23e5 Change rules for interpreting date/time input to disallow 1 and 3 character
years. Rejects dates like '0.085', which were accepted previously.
2000-03-29 03:57:18 +00:00
Thomas G. Lockhart 2dabd2cd1f Allow full type names in CREATE FUNCTION arguments and return type.
Move CREATE FUNCTION/WITH clause to end of statement to get around
 shift/reduce conflicts with type names containing "WITH".
Add lots of tokens as allowed ColId's and/or ColLabel's,
 so this should be a complete set for the v7.0 release.
2000-03-27 17:12:06 +00:00
Tom Lane 0a27641c1a nodeAgg has always been willing to accept an aggregate with a finalFunc
and only one transition state, but the CREATE AGGREGATE code rejected
this combination.
2000-03-26 19:43:58 +00:00
Peter Eisentraut 4579e68db2 Updated user's guide to match new psql's output format
Fixed bug in createdb/alternative location
2000-03-26 18:32:30 +00:00
Tom Lane 5c462baebc transformCreateStmt should put Ident nodes, not ColumnDef nodes, into
keys lists of Constraint nodes.  This eliminates a type pun that would
probably have caused trouble someday, and eliminates circular references
in the parsetree that were causing trouble now.
Also, change parser's uses of strcasecmp() to strcmp().  Since scan.l
has downcased any unquoted identifier, it is never correct to check an
identifier with strcasecmp() in the parser.  For example,
	CREATE TABLE FOO (f1 int, UNIQUE("F1"));
was accepted, which is wrong, and xlateSqlFunc did more than it should:
select datetime();
ERROR:  Function 'timestamp()' does not exist
(good)
select "DateTime"();
ERROR:  Function 'timestamp()' does not exist
(bad)
2000-03-24 23:34:19 +00:00
Tom Lane 8cbeb5f131 Save a few cycles in simple cases: no need to call cost_sort() when there
is no presorted path to compare with.
2000-03-24 21:40:43 +00:00
Tom Lane 39cd6e2e91 outfuncs.c was missing a print routine for Material plan nodes, leading
to trouble when trying to EXPLAIN VERBOSE a plan containing one.
2000-03-24 02:58:25 +00:00
Tom Lane eca02fee2c Rename bytea functions to not have upper-case letters in their names.
Clean up grotty coding in them, too.  AFAICS from the CVS logs, these
have been broken since Postgres95, so I'm not going to insist on an
initdb to fix them now...
2000-03-24 02:41:46 +00:00
Tom Lane 7177bbac29 A little further tweaking of the range-query selectivity logic:
to avoid undue sensitivity to roundoff error, believe that a zero
or slightly negative range estimate should represent a small
positive selectivity, rather than falling back on a generic default
estimate.
2000-03-23 23:35:47 +00:00
Bruce Momjian 6d79d6027c >> 5. empty define that results in an empty but terminated line ( ; )
easy (maybe dumb) fix for 5 in attachment define.patch

greetings, Andreas
2000-03-23 23:16:49 +00:00
Bruce Momjian 4ddc50dffa Hmm, absolute pathnames for the copy makes sense. I'll whip up that
patch in a second. Should be sufficent to just make sure the first
character is a '/', right?

Ross J. Reedstrom
2000-03-23 21:38:58 +00:00
Tom Lane 5c63975504 Float-to-int conversion functions should return NULL when given NULL
input, not throw a gratuitous elog().
2000-03-23 07:40:00 +00:00
Tom Lane 37ab088770 Remove no-longer-necessary restriction against uplevel correlation vars
outside WHERE clause.  Fix a couple of places that didn't handle uplevel
refs cleanly.
2000-03-23 07:38:30 +00:00
Tom Lane dadb14fa60 Hack parse_coerce so it won't try to constant-fold the dummy Const
nodes introduced by make_subplan().  It'd be better if we used a
different node type for subplan result placeholders, but for now...
2000-03-23 07:36:03 +00:00
Tom Lane 9da6d2c0e7 ExecSubPlan needs to be able to cope with RelabelType nodes atop the
Const placeholder nodes for subplan result values.
2000-03-23 07:32:58 +00:00
Tom Lane 1afaa2557a If we cannot get a real estimate for the selectivity of a range query,
use a default value that's fairly small.  We were generating a result
of about 0.1, but I think 0.01 is probably better --- want to encourage
use of an indexscan in this situation.
2000-03-23 00:58:36 +00:00
Tom Lane cad764f349 Improve selectivity estimation involving string constants: pay attention
to more than one character, and try to do the right thing in non-ASCII
locales.
2000-03-23 00:55:42 +00:00
Tom Lane 1d5e7a6f46 Repair logic flaw in cost estimator: cost_nestloop() was estimating CPU
costs using the inner path's parent->rows count as the number of tuples
processed per inner scan iteration.  This is wrong when we are using an
inner indexscan with indexquals based on join clauses, because the rows
count in a Relation node reflects the selectivity of the restriction
clauses for that rel only.  Upshot was that if join clause was very
selective, we'd drastically overestimate the true cost of the join.
Fix is to calculate correct output-rows estimate for an inner indexscan
when the IndexPath node is created and save it in the path node.
Change of path node doesn't require initdb, since path nodes don't
appear in saved rules.
2000-03-22 22:08:35 +00:00
Thomas G. Lockhart dcdcada7e9 Add syntax for BIT() and BIT VARYING(), but no underlying implementation
is available yet.
Remove redundant call to xlateSqlType() in the character
 type handling code.
2000-03-21 06:00:41 +00:00
Tom Lane 3ee8f7e207 Restructure planning code so that preprocessing of targetlist and quals
to simplify constant expressions and expand SubLink nodes into SubPlans
is done in a separate routine subquery_planner() that calls union_planner().
We formerly did most of this work in query_planner(), but that's the
wrong place because it may never see the real targetlist.  Splitting
union_planner into two routines also allows us to avoid redundant work
when union_planner is invoked recursively for UNION and inheritance
cases.  Upshot is that it is now possible to do something like
select float8(count(*)) / (select count(*) from int4_tbl)  from int4_tbl
group by f1;
which has never worked before.
2000-03-21 05:12:12 +00:00
Tom Lane aafe86d995 Correct typo in error message. 2000-03-21 04:20:45 +00:00
Bruce Momjian 2216584bcf Reverse out BYTEA type coersion. 2000-03-20 15:42:47 +00:00
Vadim B. Mikheev df238b2c06 Turn XLOG off (do not create log file). 2000-03-20 07:25:39 +00:00
Tom Lane 3caa56fe5e Emit 'this operator is deprecated' warnings for ':' and ';'. 2000-03-20 05:20:34 +00:00
Bruce Momjian 7f116a6b83 Update for BYTEAOID. 2000-03-20 04:26:01 +00:00
Bruce Momjian 0e1f485f5f Add compatiblity information for bytea. 2000-03-20 04:02:47 +00:00
Hiroshi Inoue fe8098ed0c Add FORCE keyword to ColID 2000-03-20 00:24:37 +00:00
Tom Lane b178865891 cash_words_out function truncated its output by 1 character due to
incorrect use of StrNCpy.
2000-03-19 22:10:52 +00:00
Tom Lane 58422dd0af Several calls to StrNCpy incorrectly subtracted 1 from the length arg,
leading to postmaster accepting args 1 shorter than it had room for.
2000-03-19 22:10:08 +00:00
Tom Lane d6429e552d Minor code rearrangement & doc improvement in eval_const_expressions(). 2000-03-19 18:20:38 +00:00
Tom Lane a73b75615f transformExpr() did the Wrong Thing if applied to a SubLink node that
had already been transformed.  This led to failure in examples like
UPDATE table SET fld = (SELECT ...).  Repair this, and revise the
comments to explain that transformExpr has to be robust against this
condition.  Someday we might want to fix the callers so that
transformExpr is never invoked on its own output, but that someday
is not today.
2000-03-19 07:13:58 +00:00
Tom Lane 440b0fea3d Another go-round with resolution of ambiguous functions and operators.
In function parsing, try for an actual function of the given name and
input types before trying to interpret the function call as a type
coercion request, rather than after.  Before, a function that had the
same name as a type and operated on a binary-compatible type wouldn't
get invoked.  Also, cross-pollinate between func_select_candidates and
oper_select_candidates to ensure that they use as nearly the same
resolution rules as possible.  A few other minor code cleanups too.
2000-03-19 00:19:39 +00:00
Tom Lane f11d253e25 In can_coerce_type, verify that a possible type-coercion function
actually returns the type it is named for.
2000-03-19 00:15:39 +00:00
Tom Lane d63e05a638 Improve error message wording in unary_op_error() --- suggest that
problem could be lack of parentheses.  This addresses cases like
X UserOp UserOp Y, which will be parsed as (X UserOp) UserOp Y,
whereas what likely was wanted was X UserOp (UserOp Y).
2000-03-18 19:53:54 +00:00
Tom Lane f91dd7880f Clean up minor compiler warnings. 2000-03-18 18:57:16 +00:00
Tom Lane f945f46193 Modify lexing of multi-char operators per pghackers discussion around
16-Mar-00: trailing + or - is not part of the operator unless the operator
also contains characters not present in SQL92-defined operators.  This
solves the 'X=-Y' problem without unduly constraining users' choice of
operator names --- in particular, no existing Postgres operator names
become invalid.

Also, remove processing of // comments, as agreed in the same thread.
2000-03-18 18:03:12 +00:00
Tom Lane 15115344f0 Just noticed that the grammar actually has no provision for '+' as a
prefix operator :-(.  Bad enough that we have no implementation of
unary plus, but at least with this fix the grammar will take it.
2000-03-18 04:32:35 +00:00
Bruce Momjian caa6fc1ba2 Add translation of timespan to interval. 2000-03-18 00:33:45 +00:00
Tom Lane 0e314d747e Add safety check on expression nesting depth. Default value is set by
a config.h #define, and the runtime value can be controlled via SET.
2000-03-17 05:29:07 +00:00
Tom Lane 341b328b18 Fix a bunch of minor portability problems and maybe-bugs revealed by
running gcc and HP's cc with warnings cranked way up.  Signed vs unsigned
comparisons, routines declared static and then defined not-static,
that kind of thing.  Tedious, but perhaps useful...
2000-03-17 02:36:41 +00:00
Thomas G. Lockhart 9e7166096e Support full POSIX-style time zone: EST+3, PST-3, etc.
We probably support a superset of the spec, but I don't have the spec
 to confirm this.
Update regression tests to include tests for this format.
2000-03-16 14:38:42 +00:00
Tom Lane d14c8aab99 Turns out that Mazurkiewicz's gripe about 'function inheritance' is
actually a type-coercion problem.  If you have a function defined on
class A, and class B inherits from A, then the function ought to work
on class B as well --- but coerce_type didn't know that.  Now it does.
2000-03-16 06:35:07 +00:00
Tom Lane e64a331179 Fix some (more) problems with subselects in rules. Rewriter failed to
mark query as having subselects if a subselect was added from a rule
WHERE condition (as opposed to a rule action).  Also, fix adjustment
of varlevelsup so that it actually has some prospect of working when
inserting an expression containing a subselect into a subquery.
2000-03-16 03:23:18 +00:00
Bruce Momjian 4a3a1e2cf1 Hi,
small changes in formatting.c code (better memory usage ...etc.) and
better
to_char's cache (will fastly for more to_char()s in one query).

(It is probably end of to_char() development in 7.0 cycle.)

                                                Karel
2000-03-16 01:35:41 +00:00
Tom Lane 6358e654ca Update comment obsoleted by Thomas's latest fixes. 2000-03-15 23:42:14 +00:00
Tom Lane 1763a7c1ea Tweak GROUP BY so that it will still accept result-column names, but only
after trying to resolve the item as an input-column name.  This allows us
to be compliant with the SQL92 spec for queries that fall within the spec,
while still accepting the same out-of-spec queries as 6.5 did.  You'll only
lose if there is an output column name that is the same as an input
column name, but doesn't refer to the same value.  7.0 will interpret
such a GROUP BY spec differently than 6.5 did.  No way around that, because
6.5 was clearly not spec compliant.
2000-03-15 23:31:19 +00:00
Tom Lane 77f4885393 Fix busted TRANSLATE() code --- it coredumped due to pfree()'ing the
wrong pointer.
2000-03-15 17:24:18 +00:00
Tom Lane 84b9507f78 Remove another incorrect UserAbortTransactionBlock() call. 2000-03-15 07:02:56 +00:00
Tom Lane fe189063b8 Remove gratuitous and incorrect begin/commit transaction calls in
CREATE DB/DROP DB.  If you didn't think they were wrong, try what
happens when you compile with -DCLOBBER_FREED_MEMORY --- database
name displayed in error messages is trashed, because transaction
abort freed it.  Also, remove trailing periods in error messages,
per our prevailing style.
2000-03-15 06:50:51 +00:00
Tom Lane ce3b489b97 Add 'datetime' -> 'timestamp' conversion to xlateSqlFunc() to ease
the pain of updating apps to 7.0.  Should we also translate some of
the 'datetime_foo' functions that exist in 6.* ?
2000-03-15 05:31:55 +00:00
Tom Lane 34235a295b Cache fmgr lookup data for index's getnext() function in IndexScanDesc,
so that the fmgr lookup only has to happen once per index scan and not
once per tuple.  Seems to save 5% or so of CPU time for an indexscan.
2000-03-14 23:52:01 +00:00
Thomas G. Lockhart 6456810078 Implement column aliases on views "CREATE VIEW name (collist)".
Implement TIME WITH TIME ZONE type (timetz internal type).
Remap length() for character strings to CHAR_LENGTH() for SQL92
 and to remove the ambiguity with geometric length() functions.
Keep length() for character strings for backward compatibility.
Shrink stored views by removing internal column name list from visible rte.
Implement min(), max() for time and timetz data types.
Implement conversion of TIME to INTERVAL.
Implement abs(), mod(), fac() for the int8 data type.
Rename some math functions to generic names:
 round(), sqrt(), cbrt(), pow(), etc.
Rename NUMERIC power() function to pow().
Fix int2 factorial to calculate result in int4.
Enhance the Oracle compatibility function translate() to work with string
 arguments (from Edwin Ramirez).
Modify pg_proc system table to remove OID holes.
2000-03-14 23:06:59 +00:00
Tom Lane c40a0a1b52 Marginal performance improvement in LockBuffer --- calculate address
of BufferLocks[] entry just once.  Seems to save 10% or so of the
routine's runtime, which'd not be worth worrying about if it weren't
such a hotspot.
2000-03-14 22:46:27 +00:00
Bruce Momjian e02cde4b0a > I have improved the System V semaphore emulation of the QNX4 port.
Please
> apply the attached patch to
>
> backend/port/qnx4
>
> Andreas Kardos
>
2000-03-14 18:12:06 +00:00
Tom Lane 6217a8c7ba Fix some bogosities in the code that deals with estimating the fraction
of tuples we are going to retrieve from a sub-SELECT.  Must have been
half asleep when I did this code the first time :-(
2000-03-14 02:23:15 +00:00
Tom Lane e631df3c1b Extend numeric_round and numeric_trunc to accept negative scale inputs
(ie, allow rounding to occur at a digit position left of the decimal
point).  Apparently this is how Oracle handles it, and there are
precedents in other programming languages as well.
2000-03-13 02:31:13 +00:00
Tom Lane 57cf09591b Remove unnecessary limitations on lengths of bpchar and varchar constants.
Since we detect oversize tuples elsewhere, I see no reason not to allow
string constants that are 'too long' --- after all, they might never get
stored in a tuple at all.
2000-03-13 01:54:07 +00:00
Tom Lane a84c95634e Performance improvement for lexing long strings: increase flex's
YY_READ_BUF_SIZE, which turns out to have nothing to do with buffer size.
It's just a totally arbitrary upper limit on how much data myinput() is
asked for at one time.
2000-03-13 01:52:06 +00:00
Tom Lane 7cb253ed19 Somehow, the variant NATIONAL CHAR [ VARYING ] was missing from the
set of SQL-standard type names that we accept.
2000-03-12 20:09:41 +00:00
Tom Lane 1879175b18 Fix performance bug in constant-expression simplifier. After finding
that the inputs to a given operator can be recursively simplified to
constants, it was evaluating the operator using the op's *original*
(unsimplified) arg list, so that any subexpressions had to be evaluated
again.  A constant subexpression at depth N got evaluated N times.
Probably not very important in practical situations, but it made us look
real slow in MySQL's 'crashme' test...
2000-03-12 19:32:06 +00:00
Tom Lane ef3386affe Fix performance problem in fireRIRonSubselect: with nested subqueries,
fireRIRonSubselect was invoked twice at each subselect, leading to an
exponential amount of wasted effort.
2000-03-12 18:57:05 +00:00
Tom Lane 117fa25ae1 Clean up grammar's handling of NULL in expressions: a_expr_or_null is
gone, replaced by plain a_expr.  The few places where we needed to
distinguish NULL from a_expr are now handled by tests inside the actions
rather than by separate productions.  This allows us to accept queries
like 'SELECT 1 + NULL' without requiring parentheses around the NULL.
2000-03-12 00:39:52 +00:00
Tom Lane e8be8ffaf0 Further tweaking of logic that decides when to materialize an uncorrelated
subplan: do it if subplan has subplans itself, and always do it if the
subplan is an indexscan.  (I originally set it to materialize an indexscan
only if the indexqual is fairly selective, but I dunno what I was
thinking ... an unselective indexscan is still expensive ...)
2000-03-11 23:53:41 +00:00
Tom Lane bbe1ff7404 Make TypeCategory think that NAME is a member of type
category STRING.  Also, if UNKNOWNOID is passed in, return UNKNOWN_TYPE
not USER_TYPE.
2000-03-11 23:19:50 +00:00
Tom Lane c9f287e49b Further fixes for bogus list-slinging, scribbling on input, etc in type
coercion code.  I'm beginning to wonder why we have separate candidate
selection routines for functions, operators, and aggregates --- shouldn't
this code all be unified?  But meanwhile,
	SELECT 'a' LIKE 'a';
finally works; the code for dealing with unknown input types for operators
was pretty busted.
2000-03-11 23:17:47 +00:00
Tom Lane f3a9d75ebd Finish cleaning up backend's handling of /* ... */ and -- comments,
per pghackers discussion around 20-Feb.  Also add specific error messages
for unterminated comments and unterminated quoted strings.  These things
are nonissues for input coming from psql, but they do matter for input
coming from other front ends.
2000-03-11 05:14:06 +00:00
Tom Lane dad5bb01ba Redo permissions-checking code so that it does the right thing at APPEND
nodes.  The former version failed to check permissions of relations that
were referenced in second and later clauses of UNIONs, and it did not
check permissions of tables referenced via inheritance.
2000-03-09 05:15:33 +00:00
Hiroshi Inoue fd9ff86bd9 Trial implementation of ALTER DROP COLUMN.
They are #ifdef'd.
Add -D_DROP_COLUMN_HACK__ compile option
to evaluate it.
2000-03-09 05:00:26 +00:00
Tom Lane 6513946cbb Extend #ifdef CLOBBER_FREED_MEMORY debugging option so that memory
freed wholesale by AllocSetReset() is overwritten too.
2000-03-08 23:42:58 +00:00
Tom Lane 84a89e24ee Repair access-to-already-freed-memory error recently introduced into
VACUUM.
2000-03-08 23:41:00 +00:00
Tom Lane baeafa91f3 Clean up gmake warning caused by recent NetBSD patch. <grumble> 2000-03-08 22:00:19 +00:00
Bruce Momjian f43ec05d05 I've made a diff against the 7.0beta1 tree that accomplishes several things:
1) adds NetBSD shared lib support on both ELF and a.out platforms

        2) replaces "-L$(LIBPQDIR) -lpq" with "$(LIBPQ)" defined in
           Makefile.global.  This makes it much easier to build stuff in
           the source tree after you've already installed the libraries.

        3) adds TEMPLATEDIR in Makefile.global that indicates where the
           database templates are stored.  This separates the template files
           from real libraries that are installed in $(LIBDIR).
        4) changes include order of <readline/readline.h> and <readline.h>.
           The latest GNU readline installs its headers under a readline
           subdirectory.

In addition to applying the patch below the following files need to be copied:

        backend/port/dynloader:
                bsd.h -> netbsd.h
                bsd.c -> netbsd.c
        include/port:
                bsd.h -> netbsd.h
        makefiles:
                Makefile.bsd -> Makefile.netbsd

It would be great to see this incorporated into the source tree before
the 7.0 release is cut.

        Thanks!

     -- Johnny C. Lam <lamj@stat.cmu.edu>
2000-03-08 01:58:46 +00:00
Bruce Momjian 26c953e373 Bruce and all:
Here's a patch to fix the " '.' not allowed in db path" problem I ran into.
I removed '.' from the set of illegial characters, but added backtick. I also
included an explicit test for attempting include a reference to a parent dir.

How that?

Ross
2000-03-08 01:46:47 +00:00
Bruce Momjian ab7fd11846 Reversed out inet patch. 2000-03-08 01:44:37 +00:00
Bruce Momjian eae5184d11 Hi,
the to_char() source code is large, here are regression tests for
numeric/timestamp/int8 part. It is probably enough test for formatting
code in the formatting.c module. The others (float4/float8/int4) types
share this formatting code and eventual bugs for these types aren't
few probable.

 Patch fix timestamp_to_char() for infinity/invalid timestamp too.


                                                Karel
2000-03-08 01:34:41 +00:00
Bruce Momjian 0c5422912e Protects you from coredumps if you do eg. str::int4 where str is a text
field. cf. Tom Lane's <19021.950544016@sss.pgh.pa.us> 14 Feb hackers
message.

Cheers,

Patrick Welche
2000-03-07 23:58:38 +00:00
Bruce Momjian 8fa8f80c1a I've recently written to pgsql-ports about a problem with PG7.0 on NT
(Subj: [PORTS] initdb problem on NT with 7.0).  Since nobody helped me,
I had to find out the reson.  The difference between NT and Linux (for
instance) is that "open( path, O_RDWR );" opens a file in text mode.  So
sometime less block can be read than required.

I suggest a following patch.  BTW the situation appeared before, see
hba.c, pqcomm.c and others.


Alexei Zakharov
2000-03-07 23:49:31 +00:00
Tom Lane 9606f36210 Someone (probably me) forgot about handling of typecasts applied to
parameters.
2000-03-07 23:30:53 +00:00
Bruce Momjian 52d39d519a Sorting for the inet data type randomly returns the wrong result
when you have networks with the same prefix, but different netmasks.

This is due to the fact that occassionally there is random
(uninitialized?)
data in the extra bits past the point where the netmask cares about
them.

ie (real data from a real live database):

  10.0/10 == 00001010.00100000.00100000.00011000
  10.0/11 == 00001010.00000000.00000000.00000000
                        ^ Bad data, normally never seen

The v4bitncmp() function was only taking one bit length argument so
it would determine that the networks were different, even though
they really aren't (and the netmask test wouldn't be used).  This
ONLY happens if the tuple with the longer bit length is used as the
ip_bits() for the v4bitncmp call AND there happens to be junk data
in place in the shorter tuple.  Odd and random, but I saw it happen
a couple times so...


Ryan Mooney
2000-03-07 23:01:43 +00:00
Tom Lane 0eb5ab8250 Apply a MATERIAL node to the result of an uncorrelated subplan, if it
looks like it will save computation to do so.
2000-03-02 04:08:16 +00:00
Tom Lane 9f198423df Hmm, it seems nodeMaterial has been broken for a good long while;
closing a relcache entry more times than you open it is not cool.
2000-03-02 04:06:39 +00:00
Tom Lane 1bd6f76ed6 equalAttr() had its strcmp test backwards :-( 2000-03-01 18:47:43 +00:00
Tom Lane 73dd716285 Small performance improvement in comparetup_heap. 2000-03-01 17:14:09 +00:00
Hiroshi Inoue a50aaa7289 Change reindex command to work properly with gist/hash/rtree 2000-03-01 05:39:24 +00:00
Tom Lane ab3dc66426 Simplify parsing of column constraints by treating constraint attributes
as independent clauses in the grammar.  analyze.c takes care of putting
the data where it belongs and complaining about invalid combinations.
Also, make TEMP (and TEMPORARY) non-reserved words.
2000-03-01 05:18:20 +00:00
Tatsuo Ishii ea8cadbf94 Remove using puts() to print messages. Instead use TPRINTF. 2000-03-01 02:39:46 +00:00
Jan Wieck b1e4b56144 Changed execution time of ON <event> RESTRICT referential
integrity triggers to after statement allways. Ignores
deferred state now, closer to SQL3 semantics.

Jan
2000-02-29 12:28:25 +00:00
Bruce Momjian cf1d2165b3 Fix comment spacing. 2000-02-28 08:51:43 +00:00
Tom Lane 18baa9790e Looks like I broke SET variable = DEFAULT awhile ago. Ooops. 2000-02-27 21:10:41 +00:00
Tom Lane 84ccfdf087 Avoid a little bit of unnecessary computation in canonicalize_qual. 2000-02-27 19:45:44 +00:00
Tom Lane 52a8d71203 Add lztext to TypeCategory so that lztext OP text cases will work
correctly (the lztext value will be promoted to text automatically).
2000-02-27 18:54:43 +00:00
Jan Wieck 75133d9a46 Reactivated LZTEXT data type and changed rule plan- and qual-strings
into lztext.

Jan
2000-02-27 12:02:34 +00:00
Tom Lane f884130241 Minor improvements in regprocout() and oidvectortypes(). 2000-02-27 03:30:27 +00:00
Tom Lane 66fe0fc87e Fix poorly worded error messages for unary operator type resolution
failures.  Fix some outright bugs too, including a reference to
uninitialized memory that would cause failures like this one:
select -('1234567890.1234567'::text);
ERROR:  Unable to locate type oid 2139062143 in catalog
2000-02-27 02:48:15 +00:00
Tom Lane 22cab26131 Clean up dependencies for version.o. 2000-02-27 01:26:12 +00:00
Tom Lane aff830a760 Add date and time datatype handling to convert_to_scalar. (I was waiting
for Thomas to do the datetime consolidation before touching this, but
it's done now...)
2000-02-26 23:03:12 +00:00
Tom Lane baeef0e172 Change rule dumper to produce reasonable output for casts that assign
a specific length or precision, such as foo::char(8).  Remove erroneous
removal of user-written casts at the top level of a SELECT target item.
2000-02-26 21:13:18 +00:00
Tom Lane 7173c485c8 Fix exprTypmod to recognize length-coercion function expressions,
such as bpchar(char_expression, N), and pull out the attrtypmod that
the function is coercing to.  This allows correct deduction of the
column type in examples such as
CREATE VIEW v AS SELECT f1::char(8) FROM tbl;
Formerly we labeled v's column as char-of-unknown-length not char(8).
Also, this change causes the parser not to insert a redundant length
coercion function if the user has explicitly casted an INSERT or UPDATE
expression to the right length.
2000-02-26 21:11:10 +00:00
Tom Lane 6f11af0c62 I had managed to break acceptance of "char", which worked in 6.5 to
refer to the single-byte char type.  7.0 was taking it as bpchar(1).
2000-02-26 18:13:41 +00:00
Tom Lane 664908f564 Undo a couple of mistaken applications of NameStr() to StringInfos.
It worked, because they both have fields named 'data', but it's surely
trouble waiting to happen.  I wonder whether there are more ...
2000-02-26 06:36:44 +00:00
Tom Lane 08b1040374 Shared-memory hashtables have non-extensible directories, which means
it's a good idea to choose the directory size based on the expected
number of entries.  But ShmemInitHash was using a hard-wired constant.
Boo hiss.  This accounts for recent report of postmaster failure when
asking for 64K or more buffers.
2000-02-26 05:25:55 +00:00
Tom Lane 4926709563 Fix longstanding bug that kept functional indexes from working when you
defaulted the opclass.  This addresses TODO item
* Allow creation of functional indexes to use default types
(Does that make it a feature?  Oh dear...)
2000-02-25 02:58:48 +00:00
Bruce Momjian 46ba3f839d Suppress timespan and datetime ops from being brought in via pg_dump
from previous release.
2000-02-24 16:34:21 +00:00
Hiroshi Inoue f017d7eeee Check pending cancel request before waiting for lock 2000-02-24 04:36:01 +00:00
Hiroshi Inoue a5e944580f Add the check CommonSpecialPortal in use(my fault) 2000-02-24 04:34:38 +00:00
Tom Lane 9110b33f46 Add numeric <-> int8 and numeric <-> int2 conversion functions, as well
as a unary minus operator for numeric.  Now that long numeric constants
will get converted to NUMERIC in early parsing, it's essential to have
numeric->int8 conversion to avoid 'can't convert' errors on undecorated
int8 constants.  Threw in the rest for completeness while I was in the
area.
I did not force an initdb for this, since the system will still run
without the new pg_proc/pg_operator entries.  Possibly I should've.
2000-02-24 02:05:30 +00:00
Tom Lane 512669db9e Make make_const() check the size and precision of a T_Float Value,
and produce either FLOAT8 or NUMERIC output depending on whether the
value fits in a float8 or not.  This is almost back to the way the
code was before I changed T_Float, but there is a critical difference:
now, when a numeric constant doesn't fit in float8, it will be treated
as type NUMERIC instead of type UNKNOWN.
2000-02-24 01:59:17 +00:00
Tom Lane 399a570fe2 int8in failed to detect overflow; it really should. 2000-02-24 01:54:40 +00:00
Hiroshi Inoue 5525297465 Change cancel while waiting-for-lock stuff. 2000-02-22 09:55:26 +00:00
Tom Lane e391c15ca5 First post-beta1 bug fix :-(. Silly typo in new coding for doNegate
failed to negate a negative value back to positive, so '- - 123.45'
did the wrong thing.
2000-02-22 00:05:04 +00:00
Tom Lane e1a95def8b Quick hack solution so that pg_dump of views works. Needs repair after
Thomas gets back, but better this than nonfunctional pg_dump in the beta.
2000-02-21 20:18:11 +00:00
Tom Lane fc8e6c7746 Oops, commited a test version of this file by accident. Revert. 2000-02-21 18:49:54 +00:00
Tom Lane 393f313227 Change parse-time representation of float literals (which include oversize
integers) to be strings instead of 'double'.  We convert from string form
to internal representation only after type resolution has determined the
correct type for the constant.  This eliminates loss-of-precision worries
and gets rid of the change in behavior seen at 17 digits with the
previous kluge.
2000-02-21 18:47:12 +00:00
Hiroshi Inoue 4b4dbf8cba Fix "Invalid XID in t_cmin" error in vacuum. 2000-02-21 07:49:40 +00:00
Tom Lane d8cedf67ad Clean up some really grotty coding in catcache.c, improve hashing
performance in catcache lookups.
2000-02-21 03:36:59 +00:00
Hiroshi Inoue a60c9e33e9 fix the TODO
* Allow PQrequestCancel() to terminate when in waiting-for-lock state
Changes are limited to BACKEND,however.
2000-02-21 02:42:37 +00:00
Tom Lane be05edd812 Tweak planner to use OFFSET+LIMIT, not just LIMIT, as estimate of the
portion of the query result that will be retrieved.  As far as I could
tell, the consensus was that we should let the planner do the best it
can with a LIMIT query, and require the user to add ORDER BY if he
wants consistent results from different LIMIT values.
2000-02-21 01:13:04 +00:00
Tom Lane 07c495f5d8 Further cleanups for type coercion: treat the locution typename(argument)
as representing a type coercion request in more cases than we did before.
It will work now whenever no underlying function is required, ie if the
coercion is binary-compatible or if the argument is a previously untyped
string constant.  Otherwise, you still need a real function to exist.
2000-02-20 23:04:06 +00:00
Tom Lane 57b30e8e22 Create a new expression node type RelabelType, which exists solely to
represent the result of a binary-compatible type coercion.  At runtime
it just evaluates its argument --- but during type resolution, exprType
will pick up the output type of the RelabelType node instead of the type
of the argument.  This solves some longstanding problems with dropped
type coercions, an example being 'select now()::abstime::int4' which
used to produce date-formatted output, not an integer, because the
coercion to int4 was dropped on the floor.
2000-02-20 21:32:16 +00:00
Tom Lane 5253c518ae Fix broken list-slinging logic in func_select_candidate and
agg_select_candidate, which could cause them to keep more candidates
than they should and thus fail to select a single match.  I had
previously fixed the identical bug in oper_select_candidate, but
didn't realize that the same error was repeated over here.
Also, repair func_select_candidate's curious notion that it could
scribble on the input type-OID vector.  That was causing failure to
apply necessary type coercion later on, leading to malfunction of
examples such as select date('now').
2000-02-20 06:35:08 +00:00
Tom Lane f4d108a257 Even after the great date/time consolidation, TypeCategory() was still
a few bricks shy of a load concerning knowing all the date/time types.
This is real bad because it interferes with func_select_candidate()'s
willingness to disambiguate functions --- func_select_candidate() will
punt unless all the available choices have the same type category.
I think this whole mechanism needs redesigned, but in the meantime
this is a needed patch.
2000-02-20 06:28:42 +00:00
Tom Lane 4467194b44 Reduce proc_exit(1) to proc_exit(0) for errors detected in backend
command line processing.  As it stood, a bogus PGOPTIONS value from
a client would force a database system restart.  Not bad as a denial-
of-service attack...
2000-02-20 04:26:35 +00:00
Tom Lane 37a71f90b2 Fix SERIAL columns, which Thomas inadvertently broke parsing of.
Revised code probably accepts some silly combinations, but that's better
than not accepting valid ones.
2000-02-20 02:14:58 +00:00
Tom Lane 751a14e60c Repair longstanding violation of SQL92 semantics: GROUP BY would
interpret a column name as an output column alias (targetlist AS name),
ather than a real column name as it ought to.  According to the spec,
only ORDER BY should look at output column names.  I left in GROUP BY's
willingness to use an output column number ('GROUP BY 2'), even though
this is also contrary to the spec --- again, only ORDER BY is supposed
to accept that.  But there is no possible reason to want to GROUP BY
an integer constant, so keeping this old behavior won't break any
SQL-compliant queries.  DISTINCT ON will behave the same as GROUP BY.

Change numerology regress test, which depended on the incorrect
behavior.
2000-02-19 23:45:07 +00:00
Tom Lane f46571165d Get rid of postgres.c's separate parsing logic for PGDATESTYLE env.
variable, instead calling same code in variable.c that is used to parse
SET DATESTYLE.  Fix bug: although backend's startup datestyle had been
changed to ISO, 'RESET DATESTYLE' and 'SET DATESTYLE TO DEFAULT' didn't
know about it.  For consistency I have made the latter two reset to the
PGDATESTYLE-defined initial value, which may not be the same as the
compiled-in default of ISO.
2000-02-19 22:10:47 +00:00
Tom Lane bd43ae0ecd Accept the noise-word ALL in aggregate function invocations for SQL92
compliance.  Wish they were all that easy...
2000-02-19 19:37:21 +00:00
Thomas G. Lockhart dfdff4e0f1 First workaround solution for Jan's column constraint attributes. 2000-02-19 08:25:49 +00:00
Tom Lane 3cfdd8fdf2 Clean up scan.l's handling of \r vs \n --- they are reliably treated as
equivalent now, which should make Windows and Mac clients happier.
Also fix failure to handle SQL comments between segments of a multiline
quoted literal.
2000-02-19 04:17:25 +00:00
Tom Lane 905404a246 Remove gcc warnings. The Postgres world isn't really safe
for 'const' qualifiers yet ...
2000-02-19 02:29:07 +00:00
Tom Lane 3cbcb78a3d Plug some more memory leaks in the planner. It still leaks like a sieve,
but this is as good as it'll get for this release...
2000-02-18 23:47:31 +00:00
Hiroshi Inoue e3a97b370c Implement reindex command 2000-02-18 09:30:20 +00:00
Tom Lane 8cb624262a Replace inefficient _bt_invokestrat calls with direct calls to the
appropriate btree three-way comparison routine.  Not clear why the
three-way comparison routines were being used in some paths and not
others in btree --- incomplete changes by someone long ago, maybe?
Anyway, this makes for a nice speedup in CREATE INDEX.
2000-02-18 06:32:39 +00:00
Hiroshi Inoue 3ca3bb7d8b Fix assert bug(was my fault) 2000-02-17 05:00:38 +00:00
Tom Lane 598ea2c359 Finish repairing 6.5's problems with r-tree indexes: create appropriate
selectivity functions and make the r-tree operators use them.  The
estimation functions themselves are just stubs, unfortunately, but
perhaps someday someone will make them compute realistic estimates.
Change pg_am so that the optimizer can reliably tell the difference
between ordered and unordered indexes --- before it would think that
an r-tree index can be scanned in '<<' order, which is not right AFAIK.
Repair broken negator links for network_sup and related ops.
Initdb forced.  This might be my last initdb force for 7.0 ... hope so
anyway ...
2000-02-17 03:40:02 +00:00
Thomas G. Lockhart bf566b202e All regression tests pass except for rules.sql (unrelated).
Implement "date/time grand unification".
 Transform datetime and timespan into timestamp and interval.
 Deprecate datetime and timespan, though translate to new types in gram.y.
 Transform all datetime and timespan catalog entries into new types.
 Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
 Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
  routines for all date/time types.
 date.{h,c} now deals with date, time types.
 timestamp.{h,c} now deals with timestamp, interval types.
 nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:17:02 +00:00
Thomas G. Lockhart 41f1f5b76a Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
 Deprecate datetime and timespan, though translate to new types in gram.y.
 Transform all datetime and timespan catalog entries into new types.
 Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
 Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
  routines for all date/time types.
 date.{h,c} now deals with date, time types.
 timestamp.{h,c} now deals with timestamp, interval types.
 nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 17:26:26 +00:00
Thomas G. Lockhart c97672b083 Make ISO date style (e.g. "2000-02-16 09:33") the default.
Implement "date/time grand unification".
 Transform datetime and timespan into timestamp and interval.
 Deprecate datetime and timespan, though translate to new types in gram.y.
 Transform all datetime and timespan catalog entries into new types.
 Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
 Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
  routines for all date/time types.
 date.{h,c} now deals with date, time types.
 timestamp.{h,c} now deals with timestamp, interval types.
 nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 17:25:49 +00:00
Tom Lane 68be513f8b If we don't have any stats for a boolean column, assume
the disbursion is 0.5, not something small.
2000-02-16 01:00:23 +00:00
Tom Lane deee4e1612 Make eqsel produce better results for boolean columns,
and make scalarltsel a little more forgiving at the boundaries of the
known range of a column value.
2000-02-16 00:59:27 +00:00
Tom Lane 47dde30222 Remove long-dead code. 2000-02-15 23:12:26 +00:00
Tom Lane 90e160beff Fix missing lfirst() in ListTableAsAttrs(). This code
doesn't seem to be used at the moment, but as long as I'm looking at it...
2000-02-15 23:09:08 +00:00
Tom Lane b1577a7c78 New cost model for planning, incorporating a penalty for random page
accesses versus sequential accesses, a (very crude) estimate of the
effects of caching on random page accesses, and cost to evaluate WHERE-
clause expressions.  Export critical parameters for this model as SET
variables.  Also, create SET variables for the planner's enable flags
(enable_seqscan, enable_indexscan, etc) so that these can be controlled
more conveniently than via PGOPTIONS.

Planner now estimates both startup cost (cost before retrieving
first tuple) and total cost of each path, so it can optimize queries
with LIMIT on a reasonable basis by interpolating between these costs.
Same facility is a win for EXISTS(...) subqueries and some other cases.

Redesign pathkey representation to achieve a major speedup in planning
(I saw as much as 5X on a 10-way join); also minor changes in planner
to reduce memory consumption by recycling discarded Path nodes and
not constructing unnecessary lists.

Minor cleanups to display more-plausible costs in some cases in
EXPLAIN output.

Initdb forced by change in interface to index cost estimation
functions.
2000-02-15 20:49:31 +00:00
Tom Lane 6124c674ce Silence gcc warning about uninitialized var. 2000-02-15 18:17:33 +00:00
Tom Lane 16620abe12 Removed unused var to silence gcc warning. 2000-02-15 18:15:12 +00:00
Tom Lane 4c2071c8bf Repair bogus rule display of attr lists. 2000-02-15 08:24:12 +00:00
Tom Lane 1204c3e964 Remove some // comments, which are not ANSI C last I heard. 2000-02-15 07:47:37 +00:00
Thomas G. Lockhart a344a6e7b5 Carry column aliases from the parser frontend. Enables queries like
SELECT a FROM t1 tx (a);
Allow join syntax, including queries like
  SELECT * FROM t1 NATURAL JOIN t2;
Update RTE structure to hold column aliases in an Attr structure.
2000-02-15 03:38:29 +00:00
Thomas G. Lockhart 5c4b2b23af Add "DEC" as synonym for "DECIMAL".
Add "SESSION_USER" as SQL92 keyword; equivalent to CURRENT_USER for now.
Implement column aliases (aka correlation names) and more join syntax.
Fix up indenting and tabbing.
2000-02-15 03:26:38 +00:00
Thomas G. Lockhart 929e50ece8 Recognize special case of POSIX time zone: "GMT+8" and "GMT-8".
Still needs to be done for the general case:
 "tz+/-#" where tz is a 3 char string.
This will probably involve moving code around to other places.
2000-02-15 03:17:09 +00:00
Thomas G. Lockhart 7c07006ad4 Fix up error and log messages. 2000-02-15 03:00:37 +00:00
Bruce Momjian a2226ad237 contrib-array.patch
this is an old patch which I have already submitted and never seen
        in the sources. It corrects the datatype oids used in some iterator
        functions. This bug has been reported to me by many other people.

contrib-datetime.patch

        some code contributed by Reiner Dassing <dassing@wettzell.ifag.de>

contrib-makefiles.patch

        fixes all my contrib makefiles which don't work with some compilers,
        as reported to me by another user.

contrib-miscutil.patch

        an old patch for one of my old contribs.

contrib-string.patch

        a small change to the c-like text output functions. Now the '{'
        is escaped only at the beginning of the string to distinguish it
        from arrays, and the '}' is no more escaped.

elog-lineno.patch

        adds the current lineno of CopyFrom to elog messages. This is very
        useful when you load a 1 million tuples table from an external file
        and there is a bad value somehere. Currently you get an error message
        but you can't know where is the bad data. The patch uses a variable
        which was declared static in copy.c. The variable is now exported
        and initialized to 0. It is always cleared at the end of the copy
        or at the first elog message or when the copy is canceled.
        I know this is very ugly but I can't find any better way of knowing
        where the copy fails and I have this problem quite often.

plperl-makefile.patch

        fixes a typo in a makefile, but the error must be elsewhere because
        it is a file generated automatically. Please have a look.

tprintf-timestamp.patch

        restores the original 2-digit year format, assuming that the two
        century digits don't carry much information and that '000202' is
        easier to read than 20000202. Being only a log file it shouldn't
        break anything.

Please apply the patches before the next scheduled code freeze.

I also noticed that some of the contribs don't compile correcly. Should we
ask people to fix their code or rename their makefiles so that they are
ignored by the top makefile?

--
Massimo Dal Zotto
2000-02-13 18:59:53 +00:00
Bruce Momjian 77d31cf3c1 2. trigger.c fails to compile due to a syntax error. It contains
a switch statement that has an empty default label.  A label of a
    switch statement must be followed by a statement (or a label which
    is followed by a statement (or a label which ...)).

3.  Files include stringinfo.h failed to compile.  The macro,
    'appendStringInfoCharMacro' is implemented with a '?:' operation
    that returns a void expression for the true part and a char expresion
    for the false part.  Both the true and false parts of the '?:' oper-
    ator must return the same type.

Billy G. Allie
2000-02-13 13:21:11 +00:00
Bruce Momjian 7528fd2d52 Add btree indexing of boolean values
Don Baccus
2000-02-10 19:51:52 +00:00
Hiroshi Inoue 3dec14197b Enable backward sequential scan even after reaching EOF. 2000-02-09 03:49:47 +00:00
Tom Lane 1960f4be14 Ooops ... 'char c' can hold a char, but it can't hold EOF ... 2000-02-09 00:10:11 +00:00
Bruce Momjian 394af52795 I'm sending patch with new version of to_char numbers formatting.
The PostgreSQL's to_char() is very compatible with Oracle's to_char
 now. I hope that to_char's 3000 rows of source is without bugs, but
 will good if anyone test it, for me it works very well :-)


                                                        Karel

----------------------------------------------------------------------
Karel Zak <zakkr@zf.jcu.cz>              http://home.zf.jcu.cz/~zakkr/
2000-02-08 15:57:01 +00:00
Bruce Momjian 4842ef8624 Mask removal of network_ops in 7.0. 2000-02-07 21:24:15 +00:00
Jan Wieck aef647a274 Enabled MATCH <unspecified>
Jan
2000-02-07 18:12:49 +00:00
Jan Wieck f59daf80f7 Added complete MATCH <unspecified> support contributed by Don Baccus.
Jan
2000-02-07 17:50:38 +00:00
Tom Lane d8733ce674 Repair planning bugs caused by my misguided removal of restrictinfo link
fields in JoinPaths --- turns out that we do need that after all :-(.
Also, rearrange planner so that only one RelOptInfo is created for a
particular set of joined base relations, no matter how many different
subsets of relations it can be created from.  This saves memory and
processing time compared to the old method of making a bunch of RelOptInfos
and then removing the duplicates.  Clean up the jointree iteration logic;
not sure if it's better, but I sure find it more readable and plausible
now, particularly for the case of 'bushy plans'.
2000-02-07 04:41:04 +00:00
Hiroshi Inoue 7d738f9586 Remove ugly call ImmediateSharedRelationCacheInvalidate()
from md.c.
2000-02-07 02:38:18 +00:00
Jan Wieck 4acf890948 Removed special hack causing ON UPDATE NO ACTION trigger to
be suppressed.

Jan
2000-02-06 10:19:45 +00:00
Tom Lane 81fc1d5edb Rename same() to sameseti() to have a slightly less generic name. Move
nonoverlap_sets() and is_subset() to list.c, where they should have lived
to begin with, and rename to nonoverlap_setsi and is_subseti since they
only work on integer lists.
2000-02-06 03:27:35 +00:00
Tom Lane 60be6da731 Replace nth() calls in inner loops with traversal of the list via
lnext, to eliminate O(N^2) behavior with lots of indexquals.
2000-02-05 23:19:44 +00:00
Tom Lane 78296c2797 Further cleanup for OR-of-AND WHERE-clauses. orindxpath can now handle
extracting from an AND subclause just those opclauses that are relevant
for a particular index.  For example, we can now consider using an index
on x to process WHERE (x = 1 AND y = 2) OR (x = 2 AND y = 4) OR ...
2000-02-05 18:26:09 +00:00
Jan Wieck ad15560573 Enabling automatic primary key detection for self-referencing
FOREIGN KEY constraint during CREATE TABLE. Tnx to Stephan.

Jan
2000-02-05 00:20:38 +00:00
Jan Wieck 582ec175c9 Small bugfix for DROP TABLE if table is self-referenced by
a FOREIGN KEY constraint.

Jan
2000-02-04 23:45:04 +00:00
Jan Wieck ddd596d386 Added ALTER TABLE ... ADD CONSTRAINT (provided by Stephan Szabo).
Added constraint dumping capability to pg_dump (also from Stephan)

Fixed DROP TABLE -> RelationBuildTriggers: 2 record(s) not found for rel
error.

Fixed little error in gram.y I made the last days.

Jan
2000-02-04 18:49:34 +00:00
Tom Lane b64826a47d Squash longstanding memory leak: when catcache.c copied a tuple into
the cache context, it didn't bother to free the tuple that
CatalogIndexFetchTuple had allocated in the transaction context.
Do enough cache lookups in the same xact, and you start to notice...
2000-02-04 03:16:03 +00:00
Tom Lane d24ef0d08f Make EXPLAIN results for Append, Group, Agg, Unique nodes more plausible.
Group and Unique use an arbitrary assumption that there will be about
10% as many groups as input tuples --- perhaps someday we can refine this.
2000-02-03 06:12:19 +00:00
Tom Lane 40055db1eb Repair relation refcount leakage caused by SELECT FOR UPDATE. 2000-02-03 00:02:58 +00:00
Jan Wieck 31a8996ba4 Inconsistency in CREATE CONSTRAINT TRIGGER with the
actions performed by analyse.c when creating table constraints.

Jan
2000-02-02 20:54:17 +00:00
Tom Lane a152ebeec6 Fix problems seen in parallel regress tests when SI buffer overruns (causing
syscache and relcache flushes).  Relcache entry rebuild now preserves
original tupledesc, rewrite rules, and triggers if possible, so that pointers
to these things remain valid --- if these things change while relcache entry
has positive refcount, we elog(ERROR) to avoid later crash.  Arrange for
xact-local rels to be rebuilt when an SI inval message is seen for them,
so that they are updated by CommandCounterIncrement the same as regular rels.
(This is useful because of Hiroshi's recent changes to process our own SI
messages at CommandCounterIncrement time.)  This allows simplification of
some routines that previously hacked around the lack of an automatic update.
catcache now keeps its own copy of tupledesc for its relation, rather than
depending on the relcache's copy; this avoids needing to reinitialize catcache
during a cache flush, which saves some cycles and eliminates nasty circularity
problems that occur if a cache flush happens while trying to initialize a
catcache.
Eliminate a number of permanent memory leaks that used to happen during
catcache or relcache flush; not least of which was that catcache never
freed any cached tuples!  (Rule parsetree storage is still leaked, however;
will fix that separately.)
Nothing done yet about code that uses tuples retrieved by SearchSysCache
for longer than is safe.
2000-01-31 04:35:57 +00:00
Tom Lane ca0f1435ec Hmm, equalfuncs didn't know about SortClause or GroupClause
nodes...
2000-01-31 01:21:39 +00:00
Tom Lane 04103e00f1 Modify uses of RelationFlushRelation and RelationCacheInvalidate so that
we *always* rebuild, rather than deleting, an invalidated relcache entry
that has positive refcount.  Otherwise an SI cache overrun leads to
dangling Relation pointers all over the place!
2000-01-29 19:51:59 +00:00
Peter Eisentraut 2b84cbb60f A few minor psql enhancements
Initdb help correction
Changed end/abort to commit/rollback and changed related notices
Commented out way old printing functions in libpq
Fixed a typo in alter table / alter column
2000-01-29 16:58:54 +00:00