From 85128e5d56f45558634331b171acaa67ce7ed028 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 19 Apr 2009 21:50:09 +0000 Subject: Rethink the idea of having plpgsql depend on parser/gram.h. Aside from the fact that this is breaking the MSVC build, it's probably not really a good idea to expand the dependencies of gram.h any further than the core parser; for instance the value of SCONST might depend on which bison version you'd built with. Better to expose an additional call point in parser.c, so move what I had put into pl_funcs.c into parser.c. Also PGDLLIMPORT'ify the reference to standard_conforming_strings, per buildfarm results. --- src/backend/parser/parser.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'src/backend/parser/parser.c') diff --git a/src/backend/parser/parser.c b/src/backend/parser/parser.c index 1004e014d47..2e42b6f6687 100644 --- a/src/backend/parser/parser.c +++ b/src/backend/parser/parser.c @@ -14,7 +14,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parser.c,v 1.76 2009/01/01 17:23:46 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parser.c,v 1.77 2009/04/19 21:50:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -62,6 +62,36 @@ raw_parser(const char *str) } +/* + * pg_parse_string_token - get the value represented by a string literal + * + * Given the textual form of a SQL string literal, produce the represented + * value as a palloc'd string. It is caller's responsibility that the + * passed string does represent one single string literal. + * + * We export this function to avoid having plpgsql depend on internal details + * of the core grammar (such as the token code assigned to SCONST). Note + * that since the scanner isn't presently re-entrant, this cannot be used + * during use of the main parser/scanner. + */ +char * +pg_parse_string_token(const char *token) +{ + int ctoken; + + scanner_init(token); + + ctoken = base_yylex(); + + if (ctoken != SCONST) /* caller error */ + elog(ERROR, "expected string constant, got token code %d", ctoken); + + scanner_finish(); + + return base_yylval.str; +} + + /* * Intermediate filter between parser and base lexer (base_yylex in scan.l). * -- cgit v1.2.3