summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt
AgeCommit message (Collapse)Author
2005-07-29Move dbsize functions into the backend. New functions:Bruce Momjian
pg_tablespace_size pg_database_size pg_relation_size pg_complete_relation_size pg_size_pretty Remove /contrib/dbsize. Dave Page
2005-07-29Fix typo.Bruce Momjian
uniware
2005-07-29Thank you for applying patch --- regexp_replace.Bruce Momjian
An attached patch is a small additional improvement. This patch use appendStringInfoText instead of appendStringInfoString. There is an overhead of PG_TEXT_GET_STR when appendStringInfoString is executed by text type. This can be reduced by appendStringInfoText. Atsushi Ogawa
2005-07-28Make use of new list primitives list_append_unique and list_concat_uniqueTom Lane
where applicable.
2005-07-27Fix a few macro definitions to ensure that unary minus is enclosed inNeil Conway
parentheses. This avoids possible operator precedence problems, and is consistent with most of the macro definitions in the tree.
2005-07-26Add a role property 'rolinherit' which, when false, denotes that the roleTom Lane
doesn't automatically inherit the privileges of roles it is a member of; for such a role, membership in another role can be exploited only by doing explicit SET ROLE. The default inherit setting is TRUE, so by default the behavior doesn't change, but creating a user with NOINHERIT gives closer adherence to our current reading of SQL99. Documentation still lacking, and I think the information schema needs another look.
2005-07-26Add pg_has_role() family of privilege inquiry functions modeled after theTom Lane
existing ones for object privileges. Update the information_schema for roles --- pg_has_role() makes this a whole lot easier, removing the need for most of the explicit joins with pg_user. The views should be a tad faster now, too. Stephen Frost and Tom Lane.
2005-07-24Fix rounding problem in interval_div by using rint(), and improveBruce Momjian
interval_mul function.
2005-07-23Improve computations of interval_div to prevent rounding problem on AIX.Bruce Momjian
2005-07-23Andrew pointed out that the current fix didn't handle dates that wereBruce Momjian
near daylight savings time boudaries. This handles it properly, e.g. test=> select '2005-04-03 04:00:00'::timestamp at time zone 'America/Los_Angeles'; timezone ------------------------ 2005-04-03 07:00:00-04 (1 row)
2005-07-23Fix AT TIME ZONE for timestamps without time zones:Bruce Momjian
test=> select (CURRENT_DATE + '05:00'::time)::timestamp at time zone 'Canada/Pacific'; timezone ------------------------ 2005-07-22 08:00:00-04 (1 row)
2005-07-22Fix AT TIME ZONE for timestamps without time zones:Bruce Momjian
test=> select ('2005-07-20 00:00:00'::timestamp without time zone) at time zone 'Europe/Paris'; timezone ------------------------ 2005-07-19 22:00:00-04 Udpate documentation.
2005-07-22Fix insufficient check for overflow in tm2abstime(), per report from jw.Tom Lane
2005-07-22More removal of unneeded parentheses.Bruce Momjian
2005-07-22More spacing adjustmentsBruce Momjian
2005-07-22More minor spacing improvements.Bruce Momjian
2005-07-22Code spacing improvement, particularly *tm spacing.Bruce Momjian
2005-07-21Update DAYS_PER_MONTH comment.Bruce Momjian
Add SECS_PER_YEAR and MINS_PER_HOUR macros.
2005-07-21Fix integer timestamp build for macro changes.Bruce Momjian
2005-07-21Remove unnecessary parentheses in assignments.Bruce Momjian
Add spaces where needed. Reference time interval variables as tinterval.
2005-07-21Add time/date macros for code clarity:Bruce Momjian
#define DAYS_PER_YEAR 365.25 #define MONTHS_PER_YEAR 12 #define DAYS_PER_MONTH 30 #define HOURS_PER_DAY 24
2005-07-20Add 'day' field to INTERVAL so 1 day interval can be distinguished fromBruce Momjian
24 hours. This is very helpful for daylight savings time: select '2005-05-03 00:00:00 EST'::timestamp with time zone + '24 hours'; ?column? ---------------------- 2005-05-04 01:00:00-04 select '2005-05-03 00:00:00 EST'::timestamp with time zone + '1 day'; ?column? ---------------------- 2005-05-04 01:00:00-04 Michael Glaesemann
2005-07-20Fix interval division and multiplication, before:Bruce Momjian
test=> select '4 months'::interval / 5; ?column? --------------- 1 mon -6 days (1 row) after: test=> select '4 months'::interval / 5; ?column? ---------- 24 days (1 row) The problem was the use of rint() to round, and then find the remainder, causing the negative values.
2005-07-15Check for out-of-range varoattno in deparse_context_for_subplan.Tom Lane
I have seen this case in CVS tip due to new "physical tlist" optimization for subqueries. I believe it probably can't happen in existing releases, but the check is not going to hurt anything, so backpatch to 8.0 just in case.
2005-07-14Adjust permissions checking for ALTER OWNER commands: instead ofTom Lane
requiring superuserness always, allow an owner to reassign ownership to any role he is a member of, if that role would have the right to create a similar object. These three requirements essentially state that the would-be alterer has enough privilege to DROP the existing object and then re-CREATE it as the new role; so we might as well let him do it in one step. The ALTER TABLESPACE case is a bit squirrely, but the whole concept of non-superuser tablespace owners is pretty dubious anyway. Stephen Frost, code review by Tom Lane.
2005-07-12Improve comments for AdjustIntervalForTypmod.Bruce Momjian
Blank line adjustments.
2005-07-12Change 5e0 to 5.0, for consistency.Bruce Momjian
2005-07-10Missed adding extra argument to array_recv in a couple of placesTom Lane
(harmless, actually, but let's be tidy).
2005-07-10Change typreceive function API so that receive functions get the sameTom Lane
optional arguments as text input functions, ie, typioparam OID and atttypmod. Make all the datatypes that use typmod enforce it the same way in typreceive as they do in typinput. This fixes a problem with failure to enforce length restrictions during COPY FROM BINARY.
2005-07-10I made the patch that implements regexp_replace again.Bruce Momjian
The specification of this function is as follows. regexp_replace(source text, pattern text, replacement text, [flags text]) returns text Replace string that matches to regular expression in source text to replacement text. - pattern is regular expression pattern. - replacement is replace string that can use '\1'-'\9', and '\&'. '\1'-'\9': back reference to the n'th subexpression. '\&' : entire matched string. - flags can use the following values: g: global (replace all) i: ignore case When the flags is not specified, case sensitive, replace the first instance only. Atsushi Ogawa
2005-07-07Track dependencies on shared objects (which is to say, roles; we alreadyTom Lane
have adequate mechanisms for tracking the contents of databases and tablespaces). This solves the longstanding problem that you can drop a user who still owns objects and/or has access permissions. Alvaro Herrera, with some kibitzing from Tom Lane.
2005-07-07pg_column_size() cleanup for messages and code cleanup.Bruce Momjian
Mark Kirkwood
2005-07-06Add pg_column_size() to return storage size of a column, includingBruce Momjian
possible compression. Mark Kirkwood
2005-07-04I made the patch that improved the performance of replace_text().Bruce Momjian
The content of the patch is as follows: (1)Create shortcut when subtext was not found. (2)Stop using LEFT and RIGHT macro. In LEFT and RIGHT macro, TEXTPOS is executed by the same content as execution immediately before. The execution frequency of TEXTPOS can be reduced by using text_substring instead of LEFT and RIGHT macro. (3)Add appendStringInfoText, and use it instead of appendStringInfoString. There is an overhead of PG_TEXT_GET_STR when appendStringInfoString is executed by text type. This can be reduced by appendStringInfoText. (4)Reduce execution of TEXTDUP. The effect of the patch that I measured is as follows: - The Data for test was created by 'pgbench -i'. - Test SQL: select replace(aid, '9', 'A') from accounts; - Test results: Linux(CPU: Pentium III, Compiler option: -O2) original: 1.515s patched: 1.250s Atsushi Ogawa
2005-07-04Fix date_trunct for December dates that are in the next year, e.g.:Bruce Momjian
SELECT date_trunc('week', '2002-12-31'::date); Backpatch to 8.0.X. Per report from Nick Johnson.
2005-07-04Arrange for the postmaster (and standalone backends, initdb, etc) toTom Lane
chdir into PGDATA and subsequently use relative paths instead of absolute paths to access all files under PGDATA. This seems to give a small performance improvement, and it should make the system more robust against naive DBAs doing things like moving a database directory that has a live postmaster in it. Per recent discussion.
2005-07-02Add E'' to internally created SQL strings that contain backslashes.Bruce Momjian
Improve code clarity by using macros for E'' processing.
2005-07-01Migrate rtree_gist functionality into the core system, and add someTom Lane
basic regression tests for GiST to the standard regression tests. I took the opportunity to add an rtree-equivalent gist opclass for circles; the contrib version only covered boxes and polygons, but indexing circles is very handy for distance searches.
2005-06-30Fix build break on BSD, OSX, and other systems: add missing <sys/time.h>Neil Conway
include.
2005-06-29Clean up the rather historically encumbered interface to now() andTom Lane
current time: provide a GetCurrentTimestamp() function that returns current time in the form of a TimestampTz, instead of separate time_t and microseconds fields. This is what all the callers really want anyway, and it eliminates low-level dependencies on AbsoluteTime, which is a deprecated datatype that will have to disappear eventually.
2005-06-29More cleanup on roles patch. Allow admin option to be inherited throughTom Lane
role memberships; make superuser/createrole distinction do something useful; fix some locking and CommandCounterIncrement issues; prevent creation of loops in the membership graph.
2005-06-28Bring syntax of role-related commands into SQL compliance. To avoidTom Lane
syntactic conflicts, both privilege and role GRANT/REVOKE commands have to use the same production for scanning the list of tokens that might eventually turn out to be privileges or role names. So, change the existing GRANT/REVOKE code to expect a list of strings not pre-reduced AclMode values. Fix a couple other minor issues while at it, such as InitializeAcl function name conflicting with a Windows system function.
2005-06-28Replace pg_shadow and pg_group by new role-capable catalogs pg_authidTom Lane
and pg_auth_members. There are still many loose ends to finish in this patch (no documentation, no regression tests, no pg_dump support for instance). But I'm going to commit it now anyway so that Alvaro can make some progress on shared dependencies. The catalog changes should be pretty much done.
2005-06-26Add Oracle-compatible GREATEST and LEAST functions. Pavel StehuleTom Lane
2005-06-24Extend r-tree operator classes to handle Y-direction tests equivalentTom Lane
to the existing X-direction tests. An rtree class now includes 4 actual 2-D tests, 4 1-D X-direction tests, and 4 1-D Y-direction tests. This involved adding four new Y-direction test operators for each of box and polygon; I followed the PostGIS project's lead as to the names of these operators. NON BACKWARDS COMPATIBLE CHANGE: the poly_overleft (&<) and poly_overright (&>) operators now have semantics comparable to box_overleft and box_overright. This is necessary to make r-tree indexes work correctly on polygons. Also, I changed circle_left and circle_right to agree with box_left and box_right --- formerly they allowed the boundaries to touch. This isn't actually essential given the lack of any r-tree opclass for circles, but it seems best to sync all the definitions while we are at it.
2005-06-24Code cleanup: remove 3 duplicate static function declarations.Neil Conway
2005-06-22More trivial dead code removal: in int_to_roman(), checking for "num == -1"Neil Conway
is redundant after a check has already been made for "num < 0". The "set" variable can also be removed, as it is now no longer used. Per checking with Karel, this is the right fix. Per Coverity static analysis performed by EnterpriseDB.
2005-06-19Simplify uses of readdir() by creating a function ReadDir() thatTom Lane
includes error checking and an appropriate ereport(ERROR) message. This gets rid of rather tedious and error-prone manipulation of errno, as well as a Windows-specific bug workaround, at more than a dozen call sites. After an idea in a recent patch by Heikki Linnakangas.
2005-06-18Add a time-of-preparation column to the pg_prepared_xacts view, per anTom Lane
old suggestion by Oliver Jowett. Also, add a transaction column to the pg_locks view to show the xid of each transaction holding or awaiting locks; this allows prepared transactions to be properly associated with the locks they own. There was already a column named 'transaction', and I chose to rename it to 'transactionid' --- since this column is new in the current devel cycle there should be no backwards compatibility issue to worry about.
2005-06-15This patch makes it possible to use the full set of timezones when doingBruce Momjian
"AT TIME ZONE", and not just the shorlist previously available. For example: SELECT CURRENT_TIMESTAMP AT TIME ZONE 'Europe/London'; works fine now. It will also obey whatever DST rules were in effect at just that date, which the previous implementation did not. It also supports the AT TIME ZONE on the timetz datatype. The whole handling of DST is a bit bogus there, so I chose to make it use whatever DST rules are in effect at the time of executig the query. not sure if anybody is actuallyi *using* timetz though, it seems pretty unpredictable just because of this... Magnus Hagander