Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit85128e5

Browse files
committed
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 goodidea 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'dbuilt with. Better to expose an additional call point in parser.c, somove what I had put into pl_funcs.c into parser.c. Also PGDLLIMPORT'ifythe reference to standard_conforming_strings, per buildfarm results.
1 parent22c9222 commit85128e5

File tree

6 files changed

+43
-50
lines changed

6 files changed

+43
-50
lines changed

‎src/backend/parser/parser.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* Portions Copyright (c) 1994, Regents of the University of California
1515
*
1616
* IDENTIFICATION
17-
* $PostgreSQL: pgsql/src/backend/parser/parser.c,v 1.76 2009/01/01 17:23:46 momjian Exp $
17+
* $PostgreSQL: pgsql/src/backend/parser/parser.c,v 1.77 2009/04/19 21:50:08 tgl Exp $
1818
*
1919
*-------------------------------------------------------------------------
2020
*/
@@ -62,6 +62,36 @@ raw_parser(const char *str)
6262
}
6363

6464

65+
/*
66+
* pg_parse_string_token - get the value represented by a string literal
67+
*
68+
* Given the textual form of a SQL string literal, produce the represented
69+
* value as a palloc'd string. It is caller's responsibility that the
70+
* passed string does represent one single string literal.
71+
*
72+
* We export this function to avoid having plpgsql depend on internal details
73+
* of the core grammar (such as the token code assigned to SCONST). Note
74+
* that since the scanner isn't presently re-entrant, this cannot be used
75+
* during use of the main parser/scanner.
76+
*/
77+
char*
78+
pg_parse_string_token(constchar*token)
79+
{
80+
intctoken;
81+
82+
scanner_init(token);
83+
84+
ctoken=base_yylex();
85+
86+
if (ctoken!=SCONST)/* caller error */
87+
elog(ERROR,"expected string constant, got token code %d",ctoken);
88+
89+
scanner_finish();
90+
91+
returnbase_yylval.str;
92+
}
93+
94+
6595
/*
6696
* Intermediate filter between parser and base lexer (base_yylex in scan.l).
6797
*

‎src/include/parser/parser.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/parser/parser.h,v 1.24 2009/01/01 17:24:00 momjian Exp $
10+
* $PostgreSQL: pgsql/src/include/parser/parser.h,v 1.25 2009/04/19 21:50:08 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -18,4 +18,6 @@
1818

1919
externList*raw_parser(constchar*str);
2020

21+
externchar*pg_parse_string_token(constchar*token);
22+
2123
#endif/* PARSER_H */

‎src/pl/plpgsql/src/gram.y

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.122 2009/04/1918:52:57 tgl Exp $
12+
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.123 2009/04/1921:50:09 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -2737,10 +2737,9 @@ plpgsql_sql_error_callback(void *arg)
27372737
/*
27382738
* Convert a string-literal token to the represented string value.
27392739
*
2740-
* To do this, we need to invoke the core lexer. To avoid confusion between
2741-
* the core bison/flex definitions and our own, the actual invocation is in
2742-
* pl_funcs.c. Here we are only concerned with setting up the right errcontext
2743-
* state, which is handled the same as in check_sql_expr().
2740+
* To do this, we need to invoke the core lexer. Here we are only concerned
2741+
* with setting up the right errcontext state, which is handled the same as
2742+
* in check_sql_expr().
27442743
*/
27452744
staticchar *
27462745
parse_string_token(constchar *token)
@@ -2758,7 +2757,7 @@ parse_string_token(const char *token)
27582757
syntax_errcontext.previous = error_context_stack->previous;
27592758
error_context_stack = &syntax_errcontext;
27602759

2761-
result =plpgsql_parse_string_token(token);
2760+
result =pg_parse_string_token(token);
27622761

27632762
/* Restore former ereport callback*/
27642763
error_context_stack = previous_errcontext;

‎src/pl/plpgsql/src/pl_funcs.c

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_funcs.c,v 1.77 2009/04/1918:52:57 tgl Exp $
11+
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_funcs.c,v 1.78 2009/04/1921:50:09 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -17,8 +17,6 @@
1717

1818
#include<ctype.h>
1919

20-
#include"parser/gramparse.h"
21-
#include"parser/gram.h"
2220
#include"parser/scansup.h"
2321

2422

@@ -461,41 +459,6 @@ plpgsql_convert_ident(const char *s, char **output, int numidents)
461459
}
462460

463461

464-
/*
465-
* plpgsql_parse_string_token - get the value represented by a string literal
466-
*
467-
* We do not make plpgsql's lexer produce the represented value, because
468-
* in many cases we don't need it. Instead this function is invoked when
469-
* we do need it. The input is the T_STRING token as identified by the lexer.
470-
*
471-
* The result is a palloc'd string.
472-
*
473-
* Note: this is called only from plpgsql's gram.y, but we can't just put it
474-
* there because including parser/gram.h there would cause confusion.
475-
*/
476-
char*
477-
plpgsql_parse_string_token(constchar*token)
478-
{
479-
intctoken;
480-
481-
/*
482-
* We use the core lexer to do the dirty work. Aside from getting the
483-
* right results for escape sequences and so on, this helps us produce
484-
* appropriate warnings for escape_string_warning etc.
485-
*/
486-
scanner_init(token);
487-
488-
ctoken=base_yylex();
489-
490-
if (ctoken!=SCONST)
491-
elog(ERROR,"unexpected result from base lexer: %d",ctoken);
492-
493-
scanner_finish();
494-
495-
returnbase_yylval.str;
496-
}
497-
498-
499462
/*
500463
* Statement type as a string, for use in error messages etc.
501464
*/

‎src/pl/plpgsql/src/plpgsql.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.111 2009/04/1918:52:57 tgl Exp $
11+
* $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.112 2009/04/1921:50:09 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -880,7 +880,6 @@ extern void plpgsql_ns_rename(char *oldname, char *newname);
880880
* ----------
881881
*/
882882
externvoidplpgsql_convert_ident(constchar*s,char**output,intnumidents);
883-
externchar*plpgsql_parse_string_token(constchar*token);
884883
externconstchar*plpgsql_stmt_typename(PLpgSQL_stmt*stmt);
885884
externvoidplpgsql_dumptree(PLpgSQL_function*func);
886885

‎src/pl/plpgsql/src/scan.l

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/pl/plpgsql/src/scan.l,v 1.68 2009/04/1918:52:57 tgl Exp $
12+
* $PostgreSQL: pgsql/src/pl/plpgsql/src/scan.l,v 1.69 2009/04/1921:50:09 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -43,7 +43,7 @@ static intcur_line_num;
4343
staticintxcdepth =0;/* depth of nesting in slash-star comments*/
4444
staticchar *dolqstart;/* current $foo$ quote start string*/
4545

46-
externboolstandard_conforming_strings;
46+
externPGDLLIMPORTboolstandard_conforming_strings;
4747

4848
bool plpgsql_SpaceScanned =false;
4949
%}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp