[PATCHES] dollar quoting for plpgsql
Tom Lane wrote: I think plpgsql's lexer also needs to be taught about dollar-quoting. The attached patch appears to do the trick: floobl=# create or replace function testme() returns text language plpgsql as $$ floobl$# begin return $foo$a'\b$bar$foo$; end; floobl$# $$; CREATE FUNCTION floobl=# select testme(); testme -- a'\b$bar (1 row) floobl=# cheers andrew Index: src/pl/plpgsql/src/scan.l === RCS file: /projects/cvsroot/pgsql-server/src/pl/plpgsql/src/scan.l,v retrieving revision 1.31 diff -c -r1.31 scan.l *** src/pl/plpgsql/src/scan.l 24 Feb 2004 22:06:32 - 1.31 --- src/pl/plpgsql/src/scan.l 25 Feb 2004 16:32:28 - *** *** 57,62 --- 57,63 static bool have_lookahead_token; static const char *cur_line_start; static intcur_line_num; + static char*dolqstart; /* current $foo$ quote start string */ int plpgsql_SpaceScanned = 0; %} *** *** 70,76 %option case-insensitive ! %xIN_STRING IN_COMMENT digit [0-9] ident_start [A-Za-z\200-\377_] --- 71,77 %option case-insensitive ! %xIN_STRING IN_COMMENT IN_DOLLARQUOTE digit [0-9] ident_start [A-Za-z\200-\377_] *** *** 84,89 --- 85,98 space [ \t\n\r\f] + /* $foo$ style quotes (dollar quoting) + * copied stright from the backend SQL parser + */ + dolq_start[A-Za-z\200-\377_] + dolq_cont [A-Za-z\200-\377_0-9] + dolqdelim \$({dolq_start}{dolq_cont}*)?\$ + dolqinside[^$]+ + %% /* -- * Local variables in scanner to remember where *** *** 288,293 --- 297,336 (errcode(ERRCODE_DATATYPE_MISMATCH), errmsg(unterminated string))); } + + {dolqdelim} { + start_lineno = plpgsql_scanner_lineno(); + start_charpos = yytext; + dolqstart = pstrdup(yytext); + BEGIN(IN_DOLLARQUOTE); + } + IN_DOLLARQUOTE{dolqdelim} { + if (strcmp(yytext, dolqstart) == 0) + { + pfree(dolqstart); + yyleng -= (yytext - start_charpos); + yytext = start_charpos; + BEGIN INITIAL; + return T_STRING; + } + else + { + /* +* When we fail to match $...$ to dolqstart, transfer +* the $... part to the output, but put back the final +* $ for rescanning. Consider $delim$...$junk$delim$ +*/ + yyless(yyleng-1); + } + } + IN_DOLLARQUOTE{dolqinside} { } + IN_DOLLARQUOTE. { /* needed for $ inside the quoted text */ } + IN_DOLLARQUOTEEOF { + plpgsql_error_lineno = start_lineno; + ereport(ERROR, + (errcode(ERRCODE_DATATYPE_MISMATCH), +errmsg(unterminated dollar quoted string))); + } /* -- * Any unmatched character is returned as is ---(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] dollar quoting for plpgsql
Andrew Dunstan [EMAIL PROTECTED] writes: I think plpgsql's lexer also needs to be taught about dollar-quoting. The attached patch appears to do the trick: Applied. It needed a little more work to handle RAISE NOTICE reasonably, but I took care of that. regards, tom lane ---(end of broadcast)--- TIP 8: explain analyze is your friend
[PATCHES] win32 patch
I have applied the following patch. It was submitted a while ago.: For application to HEAD, following community review. * Changes incorrect CYGWIN defines to __CYGWIN__ * Some localtime returns NULL checks (when unchecked cause SEGVs under Win32 regression tests) * Rationalized CreateSharedMemoryAndSemaphores and AttachSharedMemoryAndSemaphores (Bruce, I finally remembered to do it); requires attention. Claudio Natoli -- Bruce Momjian| http://candle.pha.pa.us [EMAIL PROTECTED] | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup.| Newtown Square, Pennsylvania 19073 Index: src/backend/bootstrap/bootstrap.c === RCS file: /projects/cvsroot/pgsql-server/src/backend/bootstrap/bootstrap.c,v retrieving revision 1.175 diff -c -r1.175 bootstrap.c *** src/backend/bootstrap/bootstrap.c 7 Jan 2004 18:56:25 - 1.175 --- src/backend/bootstrap/bootstrap.c 5 Feb 2004 12:36:15 - *** *** 428,434 #ifdef EXEC_BACKEND if (IsUnderPostmaster) ! AttachSharedMemoryAndSemaphores(); #endif XLOGPathInit(); --- 428,434 #ifdef EXEC_BACKEND if (IsUnderPostmaster) ! CreateSharedMemoryAndSemaphores(false, MaxBackends, 0); #endif XLOGPathInit(); Index: src/backend/commands/user.c === RCS file: /projects/cvsroot/pgsql-server/src/backend/commands/user.c,v retrieving revision 1.136 diff -c -r1.136 user.c *** src/backend/commands/user.c 2 Feb 2004 17:21:07 - 1.136 --- src/backend/commands/user.c 5 Feb 2004 12:36:16 - *** *** 139,149 bufsize = strlen(filename) + 12; tempname = (char *) palloc(bufsize); snprintf(tempname, bufsize, %s.%d, filename, MyProcPid); ! #if defined(WIN32) || defined(CYGWIN) filename = repalloc(filename, strlen(filename) + 1 + strlen(.new)); strcat(filename, .new); #endif ! oumask = umask((mode_t) 077); fp = AllocateFile(tempname, w); umask(oumask); --- 139,149 bufsize = strlen(filename) + 12; tempname = (char *) palloc(bufsize); snprintf(tempname, bufsize, %s.%d, filename, MyProcPid); ! #if defined(WIN32) || defined(__CYGWIN__) filename = repalloc(filename, strlen(filename) + 1 + strlen(.new)); strcat(filename, .new); #endif ! oumask = umask((mode_t) 077); fp = AllocateFile(tempname, w); umask(oumask); *** *** 290,296 bufsize = strlen(filename) + 12; tempname = (char *) palloc(bufsize); snprintf(tempname, bufsize, %s.%d, filename, MyProcPid); ! #if defined(WIN32) || defined(CYGWIN) filename = repalloc(filename, strlen(filename) + 1 + strlen(.new)); strcat(filename, .new); #endif --- 290,296 bufsize = strlen(filename) + 12; tempname = (char *) palloc(bufsize); snprintf(tempname, bufsize, %s.%d, filename, MyProcPid); ! #if defined(WIN32) || defined(__CYGWIN__) filename = repalloc(filename, strlen(filename) + 1 + strlen(.new)); strcat(filename, .new); #endif *** *** 465,471 user_file_update_needed = false; write_user_file(urel); heap_close(urel, NoLock); ! #if defined(WIN32) || defined(CYGWIN) { /* Rename active file while not holding an exclusive lock */ char *filename = user_getfilename(), *filename_new; --- 465,471 user_file_update_needed = false; write_user_file(urel); heap_close(urel, NoLock); ! #if defined(WIN32) || defined(__CYGWIN__) { /* Rename active file while not holding an exclusive lock */ char *filename = user_getfilename(), *filename_new; *** *** 484,490 group_file_update_needed = false; write_group_file(grel); heap_close(grel, NoLock); ! #if defined(WIN32) || defined(CYGWIN) { /* Rename active file while not holding an exclusive lock */ char *filename = group_getfilename(), *filename_new; --- 484,490 group_file_update_needed = false; write_group_file(grel); heap_close(grel, NoLock); ! #if defined(WIN32) || defined(__CYGWIN__) { /* Rename active file while not holding an exclusive lock */ char *filename = group_getfilename(), *filename_new; Index: src/backend/port/sysv_shmem.c === RCS file:
Re: [PATCHES] CYGWIN correction; ipci rationalizationg
Patch applied. Thanks. --- Claudio Natoli wrote: Any chance someone could take a peek at this before it bit-rots? Cheers, Claudio -Original Message- From: Claudio Natoli To: [EMAIL PROTECTED] Sent: 2/6/04 12:27 AM Subject: [PATCHES] CYGWIN correction; ipci rationalization For application to HEAD, following community review. * Changes incorrect CYGWIN defines to __CYGWIN__ * Some localtime returns NULL checks (when unchecked cause SEGVs under Win32 regression tests) * Rationalized CreateSharedMemoryAndSemaphores and AttachSharedMemoryAndSemaphores (Bruce, I finally remembered to do it); requires attention. Cheers, Claudio --- Certain disclaimers and policies apply to all email sent from Memetrics. For the full text of these disclaimers and policies see a href=http://www.memetrics.com/emailpolicy.html;http://www.memetrics.com/em ailpolicy.html/a -- Bruce Momjian| http://candle.pha.pa.us [EMAIL PROTECTED] | (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 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html
Re: [PATCHES] dirmod (pg_usleep) bit-rot
Patch applied. Thanks. --- Claudio Natoli wrote: For immediate application to HEAD. Corrects bit-rot of recently applied patch. win32/cygwin only. --- Certain disclaimers and policies apply to all email sent from Memetrics. For the full text of these disclaimers and policies see a href=http://www.memetrics.com/emailpolicy.html;http://www.memetrics.com/em ailpolicy.html/a [ Attachment, skipping... ] ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster -- Bruce Momjian| http://candle.pha.pa.us [EMAIL PROTECTED] | (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]