mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-24 18:55:04 +08:00
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.
This commit is contained in:
parent
22c922269f
commit
85128e5d56
@ -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).
|
||||
*
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/parser/parser.h,v 1.24 2009/01/01 17:24:00 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/include/parser/parser.h,v 1.25 2009/04/19 21:50:08 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -18,4 +18,6 @@
|
||||
|
||||
extern List *raw_parser(const char *str);
|
||||
|
||||
extern char *pg_parse_string_token(const char *token);
|
||||
|
||||
#endif /* PARSER_H */
|
||||
|
@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.122 2009/04/19 18:52:57 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.123 2009/04/19 21:50:09 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -2737,10 +2737,9 @@ plpgsql_sql_error_callback(void *arg)
|
||||
/*
|
||||
* Convert a string-literal token to the represented string value.
|
||||
*
|
||||
* To do this, we need to invoke the core lexer. To avoid confusion between
|
||||
* the core bison/flex definitions and our own, the actual invocation is in
|
||||
* pl_funcs.c. Here we are only concerned with setting up the right errcontext
|
||||
* state, which is handled the same as in check_sql_expr().
|
||||
* To do this, we need to invoke the core lexer. Here we are only concerned
|
||||
* with setting up the right errcontext state, which is handled the same as
|
||||
* in check_sql_expr().
|
||||
*/
|
||||
static char *
|
||||
parse_string_token(const char *token)
|
||||
@ -2758,7 +2757,7 @@ parse_string_token(const char *token)
|
||||
syntax_errcontext.previous = error_context_stack->previous;
|
||||
error_context_stack = &syntax_errcontext;
|
||||
|
||||
result = plpgsql_parse_string_token(token);
|
||||
result = pg_parse_string_token(token);
|
||||
|
||||
/* Restore former ereport callback */
|
||||
error_context_stack = previous_errcontext;
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_funcs.c,v 1.77 2009/04/19 18:52:57 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_funcs.c,v 1.78 2009/04/19 21:50:09 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -17,8 +17,6 @@
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include "parser/gramparse.h"
|
||||
#include "parser/gram.h"
|
||||
#include "parser/scansup.h"
|
||||
|
||||
|
||||
@ -461,41 +459,6 @@ plpgsql_convert_ident(const char *s, char **output, int numidents)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* plpgsql_parse_string_token - get the value represented by a string literal
|
||||
*
|
||||
* We do not make plpgsql's lexer produce the represented value, because
|
||||
* in many cases we don't need it. Instead this function is invoked when
|
||||
* we do need it. The input is the T_STRING token as identified by the lexer.
|
||||
*
|
||||
* The result is a palloc'd string.
|
||||
*
|
||||
* Note: this is called only from plpgsql's gram.y, but we can't just put it
|
||||
* there because including parser/gram.h there would cause confusion.
|
||||
*/
|
||||
char *
|
||||
plpgsql_parse_string_token(const char *token)
|
||||
{
|
||||
int ctoken;
|
||||
|
||||
/*
|
||||
* We use the core lexer to do the dirty work. Aside from getting the
|
||||
* right results for escape sequences and so on, this helps us produce
|
||||
* appropriate warnings for escape_string_warning etc.
|
||||
*/
|
||||
scanner_init(token);
|
||||
|
||||
ctoken = base_yylex();
|
||||
|
||||
if (ctoken != SCONST)
|
||||
elog(ERROR, "unexpected result from base lexer: %d", ctoken);
|
||||
|
||||
scanner_finish();
|
||||
|
||||
return base_yylval.str;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Statement type as a string, for use in error messages etc.
|
||||
*/
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.111 2009/04/19 18:52:57 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.112 2009/04/19 21:50:09 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -880,7 +880,6 @@ extern void plpgsql_ns_rename(char *oldname, char *newname);
|
||||
* ----------
|
||||
*/
|
||||
extern void plpgsql_convert_ident(const char *s, char **output, int numidents);
|
||||
extern char *plpgsql_parse_string_token(const char *token);
|
||||
extern const char *plpgsql_stmt_typename(PLpgSQL_stmt *stmt);
|
||||
extern void plpgsql_dumptree(PLpgSQL_function *func);
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/scan.l,v 1.68 2009/04/19 18:52:57 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/scan.l,v 1.69 2009/04/19 21:50:09 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -43,7 +43,7 @@ static int cur_line_num;
|
||||
static int xcdepth = 0; /* depth of nesting in slash-star comments */
|
||||
static char *dolqstart; /* current $foo$ quote start string */
|
||||
|
||||
extern bool standard_conforming_strings;
|
||||
extern PGDLLIMPORT bool standard_conforming_strings;
|
||||
|
||||
bool plpgsql_SpaceScanned = false;
|
||||
%}
|
||||
|
Loading…
Reference in New Issue
Block a user