Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- add DLLIMPORT to Dynamic_library_path declaration for Win32

- add pkglib_path[] declaration for Win32
- modify debug code for PROTECT/UNPROTECT
- add missing UNPROTECT(1) in spi code -- fix for "stack imbalance" warning
  • Loading branch information...
commit e2736847d3fb2be13359e2a6c49ebf64768f7f2f 1 parent eb1f22e
jconway authored
Showing with 28 additions and 14 deletions.
  1. +3 −1 pg_backend_support.c
  2. +5 −3 pg_rsupport.c
  3. +15 −0 plr.c
  4. +5 −10 plr.h
View
4 pg_backend_support.c
@@ -42,7 +42,9 @@
#endif
/* GUC variable */
-extern char *Dynamic_library_path;
+extern DLLIMPORT char *Dynamic_library_path;
+/* Postgres global */
+extern DLLIMPORT char pkglib_path[];
/* compiled function hash table */
extern HTAB *plr_HashTable;
View
8 pg_rsupport.c
@@ -2,7 +2,7 @@
* PL/R - PostgreSQL support for R as a
* procedural language (PL)
*
- * Copyright (c) 2003-2006 by Joseph E. Conway
+ * Copyright (c) 2003, 2004 by Joseph E. Conway
* ALL RIGHTS RESERVED
*
* Joe Conway <mail@joeconway.com>
@@ -142,6 +142,7 @@ plr_SPI_exec(SEXP rsql)
PROTECT(rsql = AS_CHARACTER(rsql));
sql = CHAR(STRING_ELT(rsql, 0));
+ UNPROTECT(1);
if (sql == NULL)
error("%s", "cannot exec empty query");
@@ -285,6 +286,7 @@ plr_SPI_prepare(SEXP rsql, SEXP rargtypes)
PROTECT(rsql = AS_CHARACTER(rsql));
sql = CHAR(STRING_ELT(rsql, 0));
+ UNPROTECT(1);
if (sql == NULL)
error("%s", "cannot prepare empty query");
@@ -341,6 +343,8 @@ plr_SPI_prepare(SEXP rsql, SEXP rargtypes)
else
typeids = NULL;
+ UNPROTECT(1);
+
/* switch to SPI memory context */
oldcontext = MemoryContextSwitchTo(plr_SPI_context);
@@ -355,8 +359,6 @@ plr_SPI_prepare(SEXP rsql, SEXP rargtypes)
}
PLR_PG_CATCH();
PLR_PG_END_TRY();
-
- UNPROTECT(2);
if (pplan == NULL)
{
View
15 plr.c
@@ -1533,3 +1533,18 @@ getModulesSql(Oid nspOid)
return sql->data;
}
+#ifdef DEBUGPROTECT
+SEXP
+pg_protect(SEXP s, char *fn, int ln)
+{
+ elog(NOTICE, "\tPROTECT\t1\t%s\t%d", fn, ln);
+ return protect(s);
+}
+
+void
+pg_unprotect(int n, char *fn, int ln)
+{
+ elog(NOTICE, "\tUNPROTECT\t%d\t%s\t%d", n, fn, ln);
+ unprotect(n);
+}
+#endif /* DEBUGPROTECT */
View
15 plr.h
@@ -90,17 +90,12 @@
#ifdef DEBUGPROTECT
#undef PROTECT
-#define PROTECT(s) \
- do { \
- elog(NOTICE, "\tPROTECT\t1\t%s\t%d", __FILE__, __LINE__); \
- protect(s); \
- } while (0)
+extern SEXP pg_protect(SEXP s, char *fn, int ln);
+#define PROTECT(s) pg_protect(s, __FILE__, __LINE__)
+
#undef UNPROTECT
-#define UNPROTECT(n) \
- do { \
- elog(NOTICE, "\tUNPROTECT\t%d\t%s\t%d", n, __FILE__, __LINE__); \
- unprotect(n); \
- } while (0)
+extern void pg_unprotect(int n, char *fn, int ln);
+#define UNPROTECT(n) pg_unprotect(n, __FILE__, __LINE__)
#endif /* DEBUGPROTECT */
#define xpfree(var_) \
Please sign in to comment.
Something went wrong with that request. Please try again.