Re: [HACKERS] [PATCHES] Continue transactions after errors in psql
Applied. --- pgman wrote: pgman wrote: Tom Lane wrote: Bruce Momjian pgman@candle.pha.pa.us writes: Tom Lane wrote: Well, that's just a matter of choosing good (ie short) names for the backslash commands. I was trying to be clear rather than proposing names I would actually want to use ;-). Any suggestions? Well, if we allowed ON_ERROR_ROLLBACK to work in non-interactive sessions we could just do: \set ON_ERROR_ROLLBACK on DROP TABLE foo; \set ON_ERROR_ROLLBACK off That isn't the same thing at all. The syntax I was proposing allows the script writer to define a savepoint covering multiple statements, whereas the above does not. Well, it fits the use case posted, that is to conditionally roll back a _single_ failed query. I don't see the need to add a new infrastructure/command unless people have a use case for rolling back a group of statements on failure. I have no seen such a description yet. OK, updated patch that allows for 'on/interactive/off'. Seems there are enough use cases to add an 'interactive' option. -- 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 Index: doc/src/sgml/ref/psql-ref.sgml === RCS file: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v retrieving revision 1.134 diff -c -c -r1.134 psql-ref.sgml *** doc/src/sgml/ref/psql-ref.sgml14 Mar 2005 06:19:01 - 1.134 --- doc/src/sgml/ref/psql-ref.sgml28 Apr 2005 03:35:00 - *** *** 2050,2055 --- 2050,2077 /varlistentry varlistentry + indexterm +primaryrollback/primary +secondarypsql/secondary + /indexterm + termvarnameON_ERROR_ROLLBACK/varname/term + listitem + para + When literalon/, if a statement in a transaction block + generates an error, the error is ignored and the transaction + continues. When literalinteractive/, such errors are only + ignored in interactive sessions, and not when reading script + files. When literaloff/ (the default), a statement in a + transaction block that generates an error aborts the entire + transaction. The on_error_rollback-on mode works by issuing an + implicit commandSAVEPONT/ for you, just before each command + that is in a transaction block, and rolls back to the savepoint + on error. + /para + /listitem + /varlistentry + + varlistentry termvarnameON_ERROR_STOP/varname/term listitem para Index: src/bin/psql/common.c === RCS file: /cvsroot/pgsql/src/bin/psql/common.c,v retrieving revision 1.96 diff -c -c -r1.96 common.c *** src/bin/psql/common.c 22 Feb 2005 04:40:52 - 1.96 --- src/bin/psql/common.c 28 Apr 2005 03:35:01 - *** *** 941,951 bool SendQuery(const char *query) { ! PGresult *results; ! TimevalStruct before, ! after; ! boolOK; ! if (!pset.db) { psql_error(You are currently not connected to a database.\n); --- 941,953 bool SendQuery(const char *query) { ! PGresult*results; ! TimevalStruct before, after; ! bool OK, on_error_rollback_savepoint = false; ! PGTransactionStatusType transaction_status; ! static bool on_error_rollback_warning = false; ! const char *rollback_str; ! if (!pset.db) { psql_error(You are currently not connected to a database.\n); *** *** 973,979 SetCancelConn(); ! if (PQtransactionStatus(pset.db) == PQTRANS_IDLE !GetVariableBool(pset.vars, AUTOCOMMIT) !command_no_begin(query)) { --- 975,983 SetCancelConn(); ! transaction_status = PQtransactionStatus(pset.db); ! ! if (transaction_status == PQTRANS_IDLE !GetVariableBool(pset.vars, AUTOCOMMIT) !command_no_begin(query)) { *** *** 987,992 --- 991,1023 } PQclear(results); } + else if (transaction_status == PQTRANS_INTRANS + (rollback_str = GetVariable(pset.vars, ON_ERROR_ROLLBACK)) != NULL + /* !off and !interactive is 'on' */ + pg_strcasecmp(rollback_str, off) != 0 +
Re: [PATCHES] Cleaning up unreferenced table files
Uh, you forgot to add cleanup.h. --- Heikki Linnakangas wrote: On Tue, 26 Apr 2005, Alvaro Herrera wrote: You forgot the attachment? Damn. It happens time after time... - Heikki Content-Description: [ Attachment, skipping... ] -- 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] Cleaning up unreferenced table files
How embarrasing... I hope it's all there now. On Thu, 28 Apr 2005, Bruce Momjian wrote: Uh, you forgot to add cleanup.h. --- Heikki Linnakangas wrote: On Tue, 26 Apr 2005, Alvaro Herrera wrote: You forgot the attachment? Damn. It happens time after time... - Heikki Content-Description: [ Attachment, skipping... ] -- 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 - HeikkiIndex: doc/src/sgml/maintenance.sgml === RCS file: /projects/cvsroot/pgsql/doc/src/sgml/maintenance.sgml,v retrieving revision 1.41 diff -c -r1.41 maintenance.sgml *** doc/src/sgml/maintenance.sgml 20 Feb 2005 02:21:26 - 1.41 --- doc/src/sgml/maintenance.sgml 28 Apr 2005 17:32:41 - *** *** 474,479 --- 474,496 /para /sect1 + sect1 id=cleanup-after-crash + titleCleanup after crash/title + + indexterm zone=cleanup-after-crash +primarystale file/primary + /indexterm + + para +productnamePostgreSQL/productname recovers automatically after crash +using the write-ahead log (see xref linkend=wal) and no manual +operations are normally needed. However, if there was a transaction running +when the crash occured that created or dropped a relation, the +transaction might have left a stale file in the data directory. If this +happens, you will get a notice in the log file stating which files can be +deleted. + /para + /sect1 sect1 id=logfile-maintenance titleLog File Maintenance/title Index: src/backend/access/transam/xlog.c === RCS file: /projects/cvsroot/pgsql/src/backend/access/transam/xlog.c,v retrieving revision 1.188 diff -c -r1.188 xlog.c *** src/backend/access/transam/xlog.c 23 Apr 2005 18:49:54 - 1.188 --- src/backend/access/transam/xlog.c 28 Apr 2005 17:32:41 - *** *** 42,47 --- 42,48 #include utils/builtins.h #include utils/guc.h #include utils/relcache.h + #include utils/cleanup.h /* *** *** 4520,4525 --- 4521,4528 CreateCheckPoint(true, true); + CleanupStaleRelFiles(); + /* * Close down recovery environment */ Index: src/backend/catalog/catalog.c === RCS file: /projects/cvsroot/pgsql/src/backend/catalog/catalog.c,v retrieving revision 1.59 diff -c -r1.59 catalog.c *** src/backend/catalog/catalog.c 14 Apr 2005 20:03:23 - 1.59 --- src/backend/catalog/catalog.c 28 Apr 2005 17:32:41 - *** *** 106,111 --- 106,144 return path; } + /* + * GetTablespacePath - construct path to a tablespace symbolic link + * + * Result is a palloc'd string. + * + * XXX this must agree with relpath and GetDatabasePath! + */ + char * + GetTablespacePath(Oid spcNode) + { + int pathlen; + char *path; + + Assert(spcNode != GLOBALTABLESPACE_OID); + + if (spcNode == DEFAULTTABLESPACE_OID) + { + /* The default tablespace is {datadir}/base */ + pathlen = strlen(DataDir) + 5 + 1; + path = (char *) palloc(pathlen); + snprintf(path, pathlen, %s/base, +DataDir); + } + else + { + /* All other tablespaces have symlinks in pg_tblspc */ + pathlen = strlen(DataDir) + 11 + OIDCHARS + 1; + path = (char *) palloc(pathlen); + snprintf(path, pathlen, %s/pg_tblspc/%u, +DataDir, spcNode); + } + return path; + } /* * IsSystemRelation Index: src/backend/commands/tablespace.c === RCS file: /projects/cvsroot/pgsql/src/backend/commands/tablespace.c,v retrieving revision 1.17 diff -c -r1.17 tablespace.c *** src/backend/commands/tablespace.c 14 Apr 2005 20:03:24 - 1.17 --- src/backend/commands/tablespace.c 28 Apr 2005 17:32:41 - *** *** 341,348 /* * All seems well, create the symlink */ ! linkloc = (char *) palloc(strlen(DataDir) + 11 + 10 + 1); ! sprintf(linkloc, %s/pg_tblspc/%u, DataDir, tablespaceoid); if (symlink(location, linkloc) 0) ereport(ERROR, --- 341,347 /* * All seems well, create the symlink */ ! linkloc = GetTablespacePath(tablespaceoid); if (symlink(location, linkloc) 0) ereport(ERROR,
[PATCHES] Update Borland makefile and improve MSC makefile
The following applied patch allows Borland C to build libpq, and improves the structure of the MSC makefile. I almost got BCC to build psql but got an error with popen() which I could not find a fix. -- 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 Index: src/bin/psql/bcc32.mak === RCS file: /cvsroot/pgsql/src/bin/psql/bcc32.mak,v retrieving revision 1.12 diff -c -c -r1.12 bcc32.mak *** src/bin/psql/bcc32.mak 28 Sep 2004 16:17:26 - 1.12 --- src/bin/psql/bcc32.mak 29 Apr 2005 04:17:41 - *** *** 1,6 # Makefile for Borland C++ 5.5 # Borland C++ base install directory goes here ! # BCB=d:\Borland\Bcc55 !MESSAGE Building PSQL.EXE ... !MESSAGE --- 1,17 # Makefile for Borland C++ 5.5 + # Borland C++ base install directory goes here ! # BCB=c:\Borland\Bcc55 ! ! !IF $(BCB) == ! !MESSAGE You must edit bcc32.mak and define BCB at the top ! !ERROR missing BCB ! !ENDIF ! ! !IF $(__NMAKE__) == ! !MESSAGE You must use the -N compatibility flag, e.g. make -N -f bcc32.make ! !ERROR missing -N ! !ENDIF !MESSAGE Building PSQL.EXE ... !MESSAGE *** *** 19,25 !MESSAGE You can specify a configuration when running MAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE ! !MESSAGE make -DCFG=[Release | Debug] /f bcc32.mak !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE --- 30,36 !MESSAGE You can specify a configuration when running MAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE ! !MESSAGE make -N -DCFG=[Release | Debug] -f bcc32.mak !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE *** *** 49,58 !endif REFDOCDIR=../../../doc/src/sgml/ref .path.obj = $(INTDIR) ! .c.obj: ! $(CPP) -o$(INTDIR)\$ $(CPP_PROJ) $ ALL : sql_help.h psqlscan.c ..\..\port\pg_config_paths.h $(OUTDIR)\psql.exe --- 60,88 !endif REFDOCDIR=../../../doc/src/sgml/ref + CPP_PROJ = -I$(BCB)\include;..\..\include;..\..\interfaces\libpq;..\..\include\port\win32 \ +-c -D$(USERDEFINES) -DFRONTEND -n$(INTDIR) -tWM -tWC -q -5 -a8 -pc -X -w-use \ + -w-par -w-pia -w-csu -w-aus -w-ccc + + !IFDEF DEBUG + CPP_PROJ = $(CPP_PROJ) -Od -r- -k -v -y -vi- -D_DEBUG + LIBPG_DIR = Debug + !ELSE + CPP_PROJ = $(CPP_PROJ) -O -Oi -OS -DNDEBUG + LIBPG_DIR = Release + !ENDIF + + !IFDEF DLL_LIBS + CPP_PROJ = $(CPP_PROJ) -D_RTLDLL + LIBRARIES = cw32mti.lib ..\..\interfaces\libpq\$(LIBPG_DIR)\blibpqdll.lib + !ELSE + CPP_PROJ = $(CPP_PROJ) -DBCC32_STATIC + LIBRARIES = cw32mt.lib ..\..\interfaces\libpq\$(LIBPG_DIR)\blibpq.lib + !ENDIF + .path.obj = $(INTDIR) ! USERDEFINES = WIN32;_CONSOLE;_MBCS;HAVE_STRDUP ALL : sql_help.h psqlscan.c ..\..\port\pg_config_paths.h $(OUTDIR)\psql.exe *** *** 86,153 [EMAIL PROTECTED] $(OUTDIR)\psql.exe [EMAIL PROTECTED] $(INTDIR)\..\..\port\pg_config_paths.h ! ..\..\port\pg_config_paths.h: win32.mak ! echo #define PGBINDIR $@ ! echo #define PGSHAREDIR $@ ! echo #define SYSCONFDIR $@ ! echo #define INCLUDEDIR $@ ! echo #define PKGINCLUDEDIR $@ ! echo #define INCLUDEDIRSERVER $@ ! echo #define LIBDIR $@ ! echo #define PKGLIBDIR $@ ! echo #define LOCALEDIR $@ ! ! $(OUTDIR) : ! if not exist $(OUTDIR)/$(NULL) mkdir $(OUTDIR) ! ! USERDEFINES = WIN32;_CONSOLE;_MBCS;HAVE_STRDUP ! ! # --- ! CPP_PROJ = -I$(BCB)\include;..\..\include;..\..\interfaces\libpq;..\..\include\port\win32 \ !-c -D$(USERDEFINES) -DFRONTEND -tWM -tWC -q -5 -a8 -pc -X -w-use -w-par -w-pia \ ! -w-csu -w-aus -w-ccc !IFDEF DEBUG ! CPP_PROJ = $(CPP_PROJ) -Od -r- -k -v -y -vi- -D_DEBUG ! LIBPG_DIR = Debug !ELSE ! CPP_PROJ = $(CPP_PROJ) -O -Oi -OS -DNDEBUG ! LIBPG_DIR = Release !ENDIF ! !IFDEF DLL_LIBS ! CPP_PROJ = $(CPP_PROJ) -D_RTLDLL ! LIBRARIES = cw32mti.lib ..\..\interfaces\libpq\$(LIBPG_DIR)\blibpqdll.lib ! !ELSE ! CPP_PROJ = $(CPP_PROJ) -DBCC32_STATIC ! LIBRARIES = cw32mt.lib ..\..\interfaces\libpq\$(LIBPG_DIR)\blibpq.lib ! !ENDIF ! LINK32=ilink32.exe ! LINK32_FLAGS=-L$(BCB)\lib;.\$(LIBPG_DIR) -x -v ! LINK32_OBJS= \ ! command.obj \ ! common.obj \ ! copy.obj \ ! describe.obj \ ! help.obj \ ! input.obj \ ! large_obj.obj \ ! mainloop.obj \ ! mbprint.obj ! print.obj \ ! prompt.obj \ ! startup.obj \ ! stringutils.obj \ ! tab-complete.obj \ ! variables.obj \
Re: [PATCHES] [INTERFACES] bcc32 libpq compile problem
Fabio Guidi wrote: the compiler build correctly the package without error message ? Bruce Momjian ha scritto: I downloaded the Borland compiler and am running build tests now. I finally got it working. I had to make major changes to the build file. The new attached bcc32.mak should build on your 8.0.X system, and this file will be in 8.0.3. -- 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 # Makefile for Borland C++ 5.5 # Will build a Win32 static library libpq.lib #and a Win32 dynamic library libpq.dll with import library libpqdll.lib # Borland C++ base install directory goes here # BCB=c:\Borland\Bcc55 !IF $(BCB) == !MESSAGE You must edit bcc32.mak and define BCB at the top !ERROR misssing BCB !ENDIF !IF $(__NMAKE__) == !MESSAGE You must use the -N compatibility flag, e.g. make -N -f bcc32.make !ERROR missing -N !ENDIF !MESSAGE Building the Win32 DLL and Static Library... !MESSAGE !IF $(CFG) == CFG=Release !MESSAGE No configuration specified. Defaulting to Release. !MESSAGE !ELSE !MESSAGE Configuration $(CFG) !MESSAGE !ENDIF !IF $(CFG) != Release $(CFG) != Debug !MESSAGE Invalid configuration $(CFG) specified. !MESSAGE You can specify a configuration when running MAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE make -N -DCFG=[Release | Debug] -f bcc32.mak !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE Release (Win32 Release DLL and Static Library) !MESSAGE Debug (Win32 Debug DLL and Static Library) !MESSAGE !ERROR An invalid configuration was specified. !ENDIF !IF $(OS) == Windows_NT NULL= !ELSE NULL=nul !ENDIF !IF $(CFG) == Debug DEBUG=1 OUTDIR=.\Debug INTDIR=.\Debug !ELSE OUTDIR=.\Release INTDIR=.\Release !ENDIF OUTFILENAME=blibpq USERDEFINES=FRONTEND;NDEBUG;WIN32;_WINDOWS;HAVE_VSNPRINTF;HAVE_STRDUP; CPP=bcc32.exe CPP_PROJ = -I$(BCB)\include;..\..\include -n$(INTDIR) -WD -c -D$(USERDEFINES) -tWM \ -a8 -X -w-use -w-par -w-pia -w-csu -w-aus -w-ccc !IFDEF DEBUG CPP_PROJ= $(CPP_PROJ) -Od -r- -k -v -y -vi- -D_DEBUG !else CPP_PROJ= $(CPP_PROJ) -O -Oi -OS -DNDEBUG !endif ALL : config $(OUTDIR) $(OUTDIR)\blibpq.dll $(OUTDIR)\blibpq.lib CLEAN : [EMAIL PROTECTED] $(INTDIR)\getaddrinfo.obj [EMAIL PROTECTED] $(INTDIR)\pgstrcasecmp.obj [EMAIL PROTECTED] $(INTDIR)\thread.obj [EMAIL PROTECTED] $(INTDIR)\inet_aton.obj [EMAIL PROTECTED] $(INTDIR)\crypt.obj [EMAIL PROTECTED] $(INTDIR)\noblock.obj [EMAIL PROTECTED] $(INTDIR)\md5.obj [EMAIL PROTECTED] $(INTDIR)\ip.obj [EMAIL PROTECTED] $(INTDIR)\fe-auth.obj [EMAIL PROTECTED] $(INTDIR)\fe-protocol2.obj [EMAIL PROTECTED] $(INTDIR)\fe-protocol3.obj [EMAIL PROTECTED] $(INTDIR)\fe-connect.obj [EMAIL PROTECTED] $(INTDIR)\fe-exec.obj [EMAIL PROTECTED] $(INTDIR)\fe-lobj.obj [EMAIL PROTECTED] $(INTDIR)\fe-misc.obj [EMAIL PROTECTED] $(INTDIR)\fe-print.obj [EMAIL PROTECTED] $(INTDIR)\fe-secure.obj [EMAIL PROTECTED] $(INTDIR)\pqexpbuffer.obj [EMAIL PROTECTED] $(INTDIR)\pqsignal.obj [EMAIL PROTECTED] $(OUTDIR)\libpqdll.obj [EMAIL PROTECTED] $(OUTDIR)\win32.obj [EMAIL PROTECTED] $(INTDIR)\wchar.obj [EMAIL PROTECTED] $(INTDIR)\encnames.obj [EMAIL PROTECTED] $(INTDIR)\pthread-win32.obj [EMAIL PROTECTED] $(OUTDIR)\$(OUTFILENAME).lib [EMAIL PROTECTED] $(OUTDIR)\$(OUTFILENAME)dll.lib [EMAIL PROTECTED] $(OUTDIR)\libpq.res [EMAIL PROTECTED] $(OUTDIR)\$(OUTFILENAME).dll [EMAIL PROTECTED] $(OUTDIR)\$(OUTFILENAME).tds [EMAIL PROTECTED] $(INTDIR)\pg_config_paths.h LIB32=tlib.exe LIB32_FLAGS= LIB32_OBJS= \ $(INTDIR)\win32.obj \ $(INTDIR)\getaddrinfo.obj \ $(INTDIR)\pgstrcasecmp.obj \ $(INTDIR)\thread.obj \ $(INTDIR)\inet_aton.obj \ $(INTDIR)\crypt.obj \ $(INTDIR)\noblock.obj \ $(INTDIR)\md5.obj \ $(INTDIR)\ip.obj \ $(INTDIR)\fe-auth.obj \ $(INTDIR)\fe-protocol2.obj \ $(INTDIR)\fe-protocol3.obj \ $(INTDIR)\fe-connect.obj \ $(INTDIR)\fe-exec.obj \ $(INTDIR)\fe-lobj.obj \ $(INTDIR)\fe-misc.obj \ $(INTDIR)\fe-print.obj \ $(INTDIR)\fe-secure.obj \ $(INTDIR)\pqexpbuffer.obj \ $(INTDIR)\pqsignal.obj \ $(INTDIR)\wchar.obj \ $(INTDIR)\encnames.obj \ $(INTDIR)\pthread-win32.obj config: ..\..\include\pg_config.h pthread.h pg_config_paths.h ..\..\include\pg_config.h: ..\..\include\pg_config.h.win32 copy ..\..\include\pg_config.h.win32 ..\..\include\pg_config.h pthread.h: pthread.h.win32 copy pthread.h.win32 pthread.h