[PATCHES] Memory leak in BootStrapXLOG()
Bruce Momjian pgman@candle.pha.pa.us wrote: BTW, I found memory leak in BootStrapXLOG(). The buffer allocated by malloc() is not free()ed. ISSUE_BOOTSTRAP_MEMORYLEAK in this patch points out it. (But this leak is not serious, because this function is called only once.) Does the following patch fix the memory leak you described? Yes, the revised patch has no leak by using stack instead of malloc(). This leak is trivial, but anyway direct io needs an aligned buffer. IMHO any of the following is ok. [A] 1st patch char *buffer; void* buffer0; buffer0 = malloc(BLCKSZ + XLOG_EXTRA_BUFFERS); buffer = (char *) XLOG_BUFFERS_ALIGN(buffer0); free(buffer0); [B] 2nd patch char *buffer; char buffer0[BLCKSZ + XLOG_EXTRA_BUFFERS + MAXIMUM_ALIGNOF]; buffer = XLOG_BUFFERS_ALIGN(buffer0); [C] following code is simple if we don't care the memory leak. char *buffer; buffer = XLOG_BUFFERS_ALIGN( malloc(BLCKSZ + XLOG_EXTRA_BUFFERS) ); --- ITAGAKI Takahiro NTT Cyber Space Laboratories ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org
Re: [PATCHES] SQLSTATE again
Hello I have new version. I'll send it early. Regards Pavel Stehule On Sat, 4 Jun 2005, Bruce Momjian wrote: Your patch has been added to the PostgreSQL unapplied patches list at: http://momjian.postgresql.org/cgi-bin/pgpatches It will be applied as soon as one of the PostgreSQL committers reviews and approves it. --- Pavel Stehule wrote: Hello I changed implementation of SQLSTATE from block scope variables on function scope variables. I am not sure if it's moust elegant solution, but is very similar Oracle behavior (there is session scope variable) CREATE OR REPLACE FUNCTION ff() RETURNS void AS $$ BEGIN RAISE NOTICE 'No exception: % %', SQLSTATE, SQLERRM; DECLARE x integer; BEGIN x := 10/0; EXCEPTION WHEN OTHERS THEN BEGIN RAISE NOTICE 'Div: % %', SQLSTATE, SQLERRM; BEGIN RAISE NOTICE 'Div2: % %', SQLSTATE, SQLERRM; RAISE EXCEPTION 'My user exception'; EXCEPTION WHEN OTHERS THEN RAISE NOTICE 'User: % %', SQLSTATE, SQLERRM; END; RAISE NOTICE '1: % %', SQLSTATE, SQLERRM; END; RAISE NOTICE '2: % %', SQLSTATE, SQLERRM; END; RAISE NOTICE '3: % %', SQLSTATE, SQLERRM; END; $$ LANGUAGE plpgsql; select ff(); NOTICE: No exception: 0 Successful completion NOTICE: Div: 22012 division by zero NOTICE: Div2: 22012 division by zero NOTICE: User: P0001 My user exception NOTICE: 1: 0 Successful completion NOTICE: 2: 0 Successful completion NOTICE: 3: 0 Successful completion Any comments? Regards Pavel Stehule Content-Description: [ Attachment, skipping... ] ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster
Re: [PATCHES] lastval()
Yes please... ... That's exactly what I've been asking for -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Neil Conway Sent: Monday, June 06, 2005 12:18 PM To: Dennis Bjorklund Cc: pgsql-patches@postgresql.org Subject: Re: [PATCHES] lastval() If you're busy, I can clean this up and apply it. I wonder if it would be better to have lastval() return the last value returned by nextval() or setval() for the current session, regardless of any intervening DROP SEQUENCE commands. This would simplify the implementation (we can just store the int8 value produced by the last nextval() / setval() rather than a pointer to the sequence object itself), although it is debatable whether this behavior is more logical or not. Comments? -Neil ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
Re: [PATCHES] [HACKERS] WAL: O_DIRECT and multipage-writer (+ memory
Tom Lane wrote: Bruce Momjian pgman@candle.pha.pa.us writes: BTW, I found memory leak in BootStrapXLOG(). The buffer allocated by malloc() is not free()ed. ISSUE_BOOTSTRAP_MEMORYLEAK in this patch points out it. (But this leak is not serious, because this function is called only once.) Does the following patch fix the memory leak you described? You realize this is a waste of code, no? It's not like the bootstrap subprocess frees every single bit of memory it ever allocates, and even less like it'd be profitable to try to make it do so ... the memory will go away anyway when the subprocess exits. I guess, but the person reported a leak so I figured I would fix it. -- Bruce Momjian| http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup.| Newtown Square, Pennsylvania 19073 ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly
Re: [PATCHES] Faster install-sh in C
On Sat, Jun 04, 2005 at 08:42:29PM -0400, Bruce Momjian wrote: I am using 'cp' in current CVS for this. I assume it is as fast as the C implementation, but if not, please let me know. Yes, your change did make the installation considerably faster so I abandoned the binary install idea. Thanks. -- Alvaro Herrera ([EMAIL PROTECTED]) Lo esencial es invisible para los ojos (A. de Saint Exúpery) ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
Re: [PATCHES] regexp_replace
Tom Lane wrote: Bruce Momjian pgman@candle.pha.pa.us writes: Your patch has been added to the PostgreSQL unapplied patches list at: a_ogawa00 wrote: This patch provides a new function regexp_replace. regexp_replace extends a replace function and enables text search by the regular expression. And, a back reference can be used within a replace string. (This patch for PostgreSQL 7.4.3) Don't we have this functionality already? It's even SQL-spec ... Uh, all I see it replace(), which isn't regex: row entryliteralfunctionreplace/function(parameterstring/parameter typetext/type, parameterfrom/parameter typetext/type, parameterto/parameter typetext/type)/literal/entry entrytypetext/type/entry entryReplace all occurrences in parameterstring/parameter of substring parameterfrom/parameter with substring parameterto/parameter /entry entryliteralreplace( 'abcdefabcdef', 'cd', 'XX')/literal/entry entryliteralabXXefabXXef/literal/entry /row test= SELECT replace('abc','a','d'); replace - dbc (1 row) test= SELECT replace('abc','[a-c]','d'); replace - abc (1 row) -- Bruce Momjian| http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup.| Newtown Square, Pennsylvania 19073 ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
Re: [PATCHES] regexp_replace
Nice. Patch removed. --- Tom Lane wrote: Bruce Momjian pgman@candle.pha.pa.us writes: Tom Lane wrote: Don't we have this functionality already? It's even SQL-spec ... Uh, all I see it replace(), which isn't regex: The SQL-spec function is substring(string from pattern for escape-char); see http://www.postgresql.org/docs/8.0/static/functions-matching.html#FUNCTIONS-SIMILARTO-REGEXP and we also have a variant of that for POSIX rather than SQL-style regexps: http://www.postgresql.org/docs/8.0/static/functions-matching.html#FUNCTIONS-POSIX-REGEXP regards, tom lane ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED] -- Bruce Momjian| http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup.| Newtown Square, Pennsylvania 19073 ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster
Re: [PATCHES] Server instrumentation: pg_terminate_backend, pg_reload_conf
Andreas Pflug wrote: Bruce Momjian wrote: Andreas Pflug wrote: This patch reenables pg_terminate_backend, allowing (superuser only, of course) to terminate a backend. As taken from the discussion some weeks earlier, SIGTERM seems to be used quite widely, without a report of misbehavior so while the code path is officially not too well tested, in practice it's working ok and helpful. I thought we had a discussion that the places we accept SIGTERM might be places that can exit if the postmaster is shutting down, but might not be places we can exit if the postmaster continues running, e.g. holding locks. Have you checked all the places we honor SIGTERM to check that we are safe to exit? I know Tom had concerns about that. My patch is purely to enable a supervisor to issue a SIGTERM using a pgsql client, instead of doing it from a server command line. It's not meant to fix the underlying problems. We don't support sending SIGTERM from the server command line to individual backends, so why add support for it in SQL? -- Bruce Momjian| http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup.| Newtown Square, Pennsylvania 19073 ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org
Re: [PATCHES] pg_starttime()
Bruce Momjian pgman@candle.pha.pa.us writes: Andreas Pflug wrote: I'd also propose to name this function pg_postmaster_starttime() to clarify its purpose. Agreed, or pg_server_start_time()? Which is better? It's not instantly obvious whether server means the postmaster or the current backend process, so I'd vote with Andreas on this. But I also like start_time better than starttime ... regards, tom lane ---(end of broadcast)--- TIP 8: explain analyze is your friend
Re: [PATCHES] regexp_replace
On Mon, Jun 06, 2005 at 12:02:18PM -0400, Bruce Momjian wrote: Patch removed because we already have this functionality. We don't yet have this functionality, as the patch allows for using second and later regex matches () in the replacement pattern. The function is misnamed. It should be called regex_replace_all() or some such, as it violates the principle of least astonishment by replacing all instances by default. Every other regex replacement defaults to replace first, not replace all. Or maybe it should take a bool for replace all, or...? Anyhow, it's worth a discussion :) Cheers, D --- a_ogawa00 wrote: This patch provides a new function regexp_replace. regexp_replace extends a replace function and enables text search by the regular expression. And, a back reference can be used within a replace string. (This patch for PostgreSQL 7.4.3) Function: regexp_replace(str, pattern, replace_str) Retuen Type: text Description: Replace all matched string in str. pattern is regular expression pattern. replace_str is replace string that can use '\1' - '\9', and '\'. '\1' - '\9' is back reference to the n'th subexpression. '\' is matched string. (example1) select regexp_replace('ABC-DEF', '(\\w+)-(\\w+)', '\\2-\\1') result: DEF-ABC (example2) update tab1 set col1 = regexp_replace(col1, '[A-Z]', ''); --- Atsushi Ogawa [EMAIL PROTECTED] --- cut here --- *** ./src/backend/regex/regexec.c.orig Tue Jul 20 08:45:39 2004 --- ./src/backend/regex/regexec.c Tue Jul 20 08:49:36 2004 *** *** 110,115 --- 110,116 regmatch_t *pmatch; rm_detail_t *details; chr*start; /* start of string */ + chr*search_start; /* search start of string */ chr*stop; /* just past end of string */ int err;/* error code if any (0 none) */ regoff_t *mem;/* memory vector for backtracking */ *** *** 168,173 --- 169,175 pg_regexec(regex_t *re, const chr *string, size_t len, + size_t search_start, rm_detail_t *details, size_t nmatch, regmatch_t pmatch[], *** *** 219,224 --- 221,227 v-pmatch = pmatch; v-details = details; v-start = (chr *) string; + v-search_start = (chr *) string + search_start; v-stop = (chr *) string + len; v-err = 0; if (backref) *** *** 288,294 NOERR(); MDEBUG((\nsearch at %ld\n, LOFF(v-start))); cold = NULL; ! close = shortest(v, s, v-start, v-start, v-stop, cold, (int *) NULL); freedfa(s); NOERR(); if (v-g-cflags REG_EXPECT) --- 291,298 NOERR(); MDEBUG((\nsearch at %ld\n, LOFF(v-start))); cold = NULL; ! close = shortest(v, s, v-search_start, v-search_start, v-stop, !cold, (int *) NULL); freedfa(s); NOERR(); if (v-g-cflags REG_EXPECT) *** *** 415,421 assert(d != NULL s != NULL); cold = NULL; ! close = v-start; do { MDEBUG((\ncsearch at %ld\n, LOFF(close))); --- 419,425 assert(d != NULL s != NULL); cold = NULL; ! close = v-search_start; do { MDEBUG((\ncsearch at %ld\n, LOFF(close))); *** ./src/backend/utils/adt/regexp.c.orig Tue Jul 20 08:50:08 2004 --- ./src/backend/utils/adt/regexp.cTue Jul 20 09:00:05 2004 *** *** 80,116 /* ! * RE_compile_and_execute - compile and execute a RE, caching if possible * ! * Returns TRUE on match, FALSE on no match * ! *text_re --- the pattern, expressed as an *untoasted* TEXT object ! *dat --- the data to match against (need not be null-terminated) ! *dat_len --- the length of the data string ! *cflags --- compile options for the pattern ! *nmatch, pmatch --- optional return area for match details * ! * Both pattern and data are given in the database encoding. We internally ! * convert to array of pg_wchar which is what Spencer's regex package wants. */ ! static bool ! RE_compile_and_execute(text *text_re, unsigned char *dat, int dat_len, ! int cflags, int nmatch, regmatch_t *pmatch) { int text_re_len = VARSIZE(text_re); - pg_wchar *data; - size_t data_len; pg_wchar *pattern; size_t pattern_len; int i; int
Re: [PATCHES] uptime function to postmaster
Bruce Momjian pgman@candle.pha.pa.us writes: I think we should return intervals only when we can't return meaningful timestamp values. I don't have any logic to back up that opinion, though. It's easy: a value measured as an interval will be obsolete by the time it's delivered to the client. A start timestamp is actually meaningful information that will still be correct when used; uptime is fragile. regards, tom lane ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster
Re: [PATCHES] regexp_replace
David Fetter wrote: On Mon, Jun 06, 2005 at 12:02:18PM -0400, Bruce Momjian wrote: Patch removed because we already have this functionality. We don't yet have this functionality, as the patch allows for using second and later regex matches () in the replacement pattern. The function is misnamed. It should be called regex_replace_all() or some such, as it violates the principle of least astonishment by replacing all instances by default. Every other regex replacement defaults to replace first, not replace all. Or maybe it should take a bool for replace all, or...? Anyhow, it's worth a discussion :) Does anyone want to argue that this additional functionality is significant and deserves its own function or an additional argument to the existing function? -- Bruce Momjian| http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup.| Newtown Square, Pennsylvania 19073 ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
Re: [PATCHES] logfile for psql patch update
Your patch has been added to the PostgreSQL unapplied patches list at: http://momjian.postgresql.org/cgi-bin/pgpatches It will be applied as soon as one of the PostgreSQL committers reviews and approves it. --- [EMAIL PROTECTED] wrote: This update replaces the previous patch for the psql logfile option The print.c routine is also built into src/bin/scripts The ifdef USE_LOGFILE wrapper is to keep out compile errors when the routine is linked into programs other than psql Lorne -- --- [EMAIL PROTECTED] --- [ Type application/octet-stream treated as attachment, skipping... ] ---(end of broadcast)--- TIP 8: explain analyze is your friend -- Bruce Momjian| http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup.| Newtown Square, Pennsylvania 19073 ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match
[PATCHES] AT TIME ZONE with full timezones
This patch makes it possible to use the full set of timezones when doing 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... Docs updates forthcoming assuming this approach is considered good ;-) //Magnus timezones.patch Description: timezones.patch ---(end of broadcast)--- TIP 7: don't forget to increase your free space map settings
Re: [PATCHES] Implement support for TCP_KEEPCNT, TCP_KEEPIDLE, TCP_KEEPINTVL
Oliver Jowett wrote: Bruce Momjian wrote: Is this patch being worked on? I have shelved it for the moment, waiting on any further comments from Tom before reworking it. I thought he wanted the patch modified so keepalive could never be turned off, but that the OS default parameters could be changed. -- Bruce Momjian| http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup.| Newtown Square, Pennsylvania 19073 ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send unregister YourEmailAddressHere to [EMAIL PROTECTED])
Re: [PATCHES] using strxfrm for having multi locale/please vote for
On Mon, Jun 06, 2005 at 10:11:15PM -0400, Bruce Momjian wrote: Greg Stark wrote: Yes it's true that on some OSes it wouldn't be tolerably efficient but on glibc it's more than tolerable. If better solutions (strxfrm_l) become available at some point in the future then it would be about as efficient as it could be on platforms where those features are available. There are some things I think ICU can fix for us like indexing non-C localed columns. Huh, we already do that, don't we? -- Alvaro Herrera (alvherre[a]surnet.cl) Everybody understands Mickey Mouse. Few understand Hermann Hesse. Hardly anybody understands Einstein. And nobody understands Emperor Norton. ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]