diff options
author | Tom Lane | 2009-04-19 21:50:09 +0000 |
---|---|---|
committer | Tom Lane | 2009-04-19 21:50:09 +0000 |
commit | 85128e5d56f45558634331b171acaa67ce7ed028 (patch) | |
tree | 31b08702ee5aad9989f1103b657f7df1c11e0734 /src/backend/parser/parser.c | |
parent | 22c922269f5f8a80267389e1c879c0b65fbba902 (diff) |
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.
Diffstat (limited to 'src/backend/parser/parser.c')
-rw-r--r-- | src/backend/parser/parser.c | 32 |
1 files changed, 31 insertions, 1 deletions
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 $ * *------------------------------------------------------------------------- */ @@ -63,6 +63,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). * * The filter is needed because in some cases the standard SQL grammar |