summaryrefslogtreecommitdiff
path: root/src/pl/plperl/plperl.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2006-03-14 22:48:25 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2006-03-14 22:48:25 +0000
commit20ab467d76d78271006818d2baf4c9c8658d1f38 (patch)
tree7a536111b5cc4e494ac75558aad5655dfc8ab964 /src/pl/plperl/plperl.c
parent48fb696753e267447f99914c7968d0b4ffb5c5dc (diff)
Improve parser so that we can show an error cursor position for errors
during parse analysis, not only errors detected in the flex/bison stages. This is per my earlier proposal. This commit includes all the basic infrastructure, but locations are only tracked and reported for errors involving column references, function calls, and operators. More could be done later but this seems like a good set to start with. I've also moved the ReportSyntaxErrorPosition logic out of psql and into libpq, which should make it available to more people --- even within psql this is an improvement because warnings weren't handled by ReportSyntaxErrorPosition.
Diffstat (limited to 'src/pl/plperl/plperl.c')
-rw-r--r--src/pl/plperl/plperl.c39
1 files changed, 12 insertions, 27 deletions
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c
index fc8af5634bf..362bf774725 100644
--- a/src/pl/plperl/plperl.c
+++ b/src/pl/plperl/plperl.c
@@ -1,7 +1,7 @@
/**********************************************************************
* plperl.c - perl as a procedural language for PostgreSQL
*
- * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.105 2006/03/11 16:43:22 momjian Exp $
+ * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.106 2006/03/14 22:48:23 tgl Exp $
*
**********************************************************************/
@@ -19,12 +19,13 @@
#include "commands/trigger.h"
#include "executor/spi.h"
#include "funcapi.h"
+#include "mb/pg_wchar.h"
+#include "miscadmin.h"
+#include "nodes/makefuncs.h"
+#include "parser/parse_type.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/typcache.h"
-#include "miscadmin.h"
-#include "mb/pg_wchar.h"
-#include "parser/parse_type.h"
/* define this before the perl headers get a chance to mangle DLLIMPORT */
extern DLLIMPORT bool check_function_bodies;
@@ -1950,7 +1951,6 @@ plperl_spi_prepare(char* query, int argc, SV ** argv)
plperl_query_desc *qdesc;
void *plan;
int i;
- HeapTuple typeTup;
MemoryContext oldcontext = CurrentMemoryContext;
ResourceOwner oldowner = CurrentResourceOwner;
@@ -1977,33 +1977,18 @@ plperl_spi_prepare(char* query, int argc, SV ** argv)
************************************************************/
for (i = 0; i < argc; i++)
{
- char *argcopy;
- List *names = NIL;
- ListCell *l;
- TypeName *typename;
-
- /************************************************************
- * Use SplitIdentifierString() on a copy of the type name,
- * turn the resulting pointer list into a TypeName node
- * and call typenameType() to get the pg_type tuple.
- ************************************************************/
- argcopy = pstrdup(SvPV(argv[i],PL_na));
- SplitIdentifierString(argcopy, '.', &names);
- typename = makeNode(TypeName);
- foreach(l, names)
- typename->names = lappend(typename->names, makeString(lfirst(l)));
-
- typeTup = typenameType(typename);
+ List *names;
+ HeapTuple typeTup;
+
+ /* Parse possibly-qualified type name and look it up in pg_type */
+ names = stringToQualifiedNameList(SvPV(argv[i], PL_na),
+ "plperl_spi_prepare");
+ typeTup = typenameType(NULL, makeTypeNameFromNameList(names));
qdesc->argtypes[i] = HeapTupleGetOid(typeTup);
perm_fmgr_info(((Form_pg_type) GETSTRUCT(typeTup))->typinput,
&(qdesc->arginfuncs[i]));
qdesc->argtypioparams[i] = getTypeIOParam(typeTup);
ReleaseSysCache(typeTup);
-
- list_free(typename->names);
- pfree(typename);
- list_free(names);
- pfree(argcopy);
}
/************************************************************