Commit be703cd9 authored by Thomas G. Lockhart's avatar Thomas G. Lockhart

Implement nested block comments in the backend and in psql.

 Include updates for the comment.sql regression test.
Implement SET SESSION CHARACTERISTICS and SET DefaultXactIsoLevel.
Implement SET SESSION CHARACTERISTICS TRANSACTION COMMIT
 and SET AutoCommit in the parser only.
 Need to add code to actually do something.
Implement WITHOUT TIME ZONE type qualifier.
Define SCHEMA keyword, along with stubbed-out grammar.
Implement "[IN|INOUT|OUT] [varname] type" function arguments
 in parser only; INOUT and OUT throws an elog(ERROR).
Add PATH as a type-specific token, since PATH is in SQL99
 to support schema resource search and resolution.
parent 1e901bbe
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: analyze.c,v 1.149 2000/07/02 04:04:09 tgl Exp $
* $Id: analyze.c,v 1.150 2000/07/14 15:43:32 thomas Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -200,6 +200,38 @@ transformStmt(ParseState *pstate, Node *parseTree)
result = transformAlterTableStmt(pstate, (AlterTableStmt *) parseTree);
break;
case T_SetSessionStmt:
{
List *l;
/* Session is a list of SetVariable nodes
* so just run through the list.
*/
SetSessionStmt *stmt = (SetSessionStmt *) parseTree;
l = stmt->args;
/* First check for duplicate keywords (disallowed by SQL99) */
while (l != NULL)
{
VariableSetStmt *v = (VariableSetStmt *) lfirst(l);
List *ll = lnext(l);
while (ll != NULL)
{
VariableSetStmt *vv = (VariableSetStmt *) lfirst(ll);
if (strcmp(v->name, vv->name) == 0)
elog(ERROR, "SET SESSION CHARACTERISTICS duplicated entry not allowed");
ll = lnext(ll);
}
l = lnext(l);
}
l = stmt->args;
result = transformStmt(pstate, lfirst(l));
l = lnext(l);
if (l != NULL)
extras_after = lappend(extras_after, lfirst(l));
}
break;
/*------------------------
* Optimizable statements
*------------------------
......
This diff is collapsed.
......@@ -8,11 +8,7 @@
*
*
* IDENTIFICATION
<<<<<<< keywords.c
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.78 2000/07/03 23:09:43 wieck Exp $
=======
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.78 2000/07/03 23:09:43 wieck Exp $
>>>>>>> 1.73
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.79 2000/07/14 15:43:32 thomas Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -61,6 +57,7 @@ static ScanKeyword ScanKeywords[] = {
{"cast", CAST},
{"char", CHAR},
{"character", CHARACTER},
{"characteristics", CHARACTERISTICS},
{"check", CHECK},
{"close", CLOSE},
{"cluster", CLUSTER},
......@@ -134,6 +131,7 @@ static ScanKeyword ScanKeywords[] = {
{"inherits", INHERITS},
{"initially", INITIALLY},
{"inner", INNER_P},
{"inout", INOUT},
{"insensitive", INSENSITIVE},
{"insert", INSERT},
{"instead", INSTEAD},
......@@ -192,10 +190,12 @@ static ScanKeyword ScanKeywords[] = {
{"option", OPTION},
{"or", OR},
{"order", ORDER},
{"out", OUT},
{"outer", OUTER_P},
{"overlaps", OVERLAPS},
{"partial", PARTIAL},
{"password", PASSWORD},
{"path", PATH_P},
{"pendant", PENDANT},
{"position", POSITION},
{"precision", PRECISION},
......@@ -218,12 +218,14 @@ static ScanKeyword ScanKeywords[] = {
{"rollback", ROLLBACK},
{"row", ROW},
{"rule", RULE},
{"schema", SCHEMA},
{"scroll", SCROLL},
{"second", SECOND_P},
{"select", SELECT},
{"sequence", SEQUENCE},
{"serial", SERIAL},
{"serializable", SERIALIZABLE},
{"session", SESSION},
{"session_user", SESSION_USER},
{"set", SET},
{"setof", SETOF},
......@@ -273,6 +275,7 @@ static ScanKeyword ScanKeywords[] = {
{"when", WHEN},
{"where", WHERE},
{"with", WITH},
{"without", WITHOUT},
{"work", WORK},
{"year", YEAR_P},
{"zone", ZONE},
......
......@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.72 2000/06/14 18:17:37 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.73 2000/07/14 15:43:32 thomas Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -72,6 +72,8 @@ static char *literalbuf; /* expandable buffer */
static int literallen; /* actual current length */
static int literalalloc; /* current allocated buffer size */
static int xcdepth = 0;
#define startlit() (literalbuf[0] = '\0', literallen = 0)
static void addlit(char *ytext, int yleng);
......@@ -157,7 +159,7 @@ xdinside [^"]+
*/
xcstart \/\*{op_chars}*
xcstop \*+\/
xcinside ([^*]+)|(\*+[^/])
xcinside [^*/]+
digit [0-9]
letter [\200-\377_A-Za-z]
......@@ -247,15 +249,29 @@ other .
{whitespace} { /* ignore */ }
{xcstart} {
xcdepth = 0;
BEGIN(xc);
/* Put back any characters past slash-star; see above */
yyless(2);
}
<xc>{xcstop} { BEGIN(INITIAL); }
<xc>{xcstart} {
xcdepth++;
/* Put back any characters past slash-star; see above */
yyless(2);
}
<xc>{xcstop} {
if (xcdepth <= 0)
BEGIN(INITIAL);
else
xcdepth--;
}
<xc>{xcinside} { /* ignore */ }
<xc>{op_chars} { /* ignore */ }
<xc><<EOF>> { elog(ERROR, "Unterminated /* comment"); }
{xbstart} {
......
......@@ -4,7 +4,7 @@
* Support for grand unified configuration scheme, including SET
* command, configuration file, and command line options.
*
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.6 2000/07/12 17:38:48 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.7 2000/07/14 15:43:47 thomas Exp $
*
* Copyright 2000 by PostgreSQL Global Development Group
* Written by Peter Eisentraut <peter_e@gmx.net>.
......@@ -508,7 +508,7 @@ set_config_option(const char * name, const char * value, GucContext
type = find_option(name, &record);
if (type == PGC_NONE)
{
elog(elevel, "not a valid option name: %s", name);
elog(elevel, "'%s' is not a valid option name", name);
return false;
}
......@@ -520,14 +520,14 @@ set_config_option(const char * name, const char * value, GucContext
if (record->context == PGC_POSTMASTER && context != PGC_POSTMASTER)
{
if (context != PGC_SIGHUP)
elog(ERROR, "%s cannot be changed after server start", name);
elog(ERROR, "'%s' cannot be changed after server start", name);
else
return true;
}
else if (record->context == PGC_SIGHUP && context != PGC_SIGHUP &&
context != PGC_POSTMASTER)
{
elog(ERROR, "%s cannot be changed now", name);
elog(ERROR, "'%s' cannot be changed now", name);
/* Hmm, the idea of the SIGHUP context is "ought to be global,
* but can be changed after postmaster start". But there's
* nothing that prevents a crafty administrator from sending
......@@ -537,7 +537,7 @@ set_config_option(const char * name, const char * value, GucContext
&& context != PGC_POSTMASTER)
{
if (context != PGC_SIGHUP)
elog(ERROR, "%s cannot be set after connection start", name);
elog(ERROR, "'%s' cannot be set after connection start", name);
else
return true;
}
......@@ -562,7 +562,7 @@ set_config_option(const char * name, const char * value, GucContext
bool boolval;
if (!parse_bool(value, &boolval))
{
elog(elevel, "expected boolean value for option %s", name);
elog(elevel, "Option '%s' requires a boolean value", name);
return false;
}
if (DoIt)
......@@ -583,12 +583,14 @@ set_config_option(const char * name, const char * value, GucContext
if (!parse_int(value, &intval))
{
elog(elevel, "expected integer value for option %s", name);
elog(elevel, "Option '%s' expects an integer value", name);
return false;
}
if (intval < conf->min || intval > conf->max)
{
elog(elevel, "value out of permissible range %d .. %d", conf->min, conf->max);
elog(elevel, "Option '%s' value %d is outside"
" of permissible range [%d .. %d]",
name, intval, conf->min, conf->max);
return false;
}
if (DoIt)
......@@ -609,12 +611,14 @@ set_config_option(const char * name, const char * value, GucContext
if (!parse_real(value, &dval))
{
elog(elevel, "expected real number for option %s", name);
elog(elevel, "Option '%s' expects a real number", name);
return false;
}
if (dval < conf->min || dval > conf->max)
{
elog(elevel, "value out of permissible range %g .. %g", conf->min, conf->max);
elog(elevel, "Option '%s' value %g is outside"
" of permissible range [%g .. %g]",
name, dval, conf->min, conf->max);
return false;
}
if (DoIt)
......@@ -633,7 +637,7 @@ set_config_option(const char * name, const char * value, GucContext
{
if (conf->parse_hook && !(conf->parse_hook)(value))
{
elog(elevel, "value '%s' not accepted for option %s", value, name);
elog(elevel, "Option '%s' rejects value '%s'", name, value);
return false;
}
if (DoIt)
......@@ -705,7 +709,7 @@ GetConfigOption(const char * name)
opttype = find_option(name, &record);
if (opttype == PGC_NONE)
elog(ERROR, "not a valid option name: %s", name);
elog(ERROR, "Option '%s' is not recognized", name);
switch(opttype)
{
......
......@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.32 2000/06/30 18:03:40 momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.33 2000/07/14 15:43:49 thomas Exp $
*/
#include "postgres.h"
#include "mainloop.h"
......@@ -45,6 +45,7 @@ MainLoop(FILE *source)
bool success;
volatile char in_quote; /* == 0 for no in_quote */
volatile bool in_xcomment; /* in extended comment */
volatile int xcdepth;
volatile int paren_level;
unsigned int query_start;
volatile int count_eof = 0;
......@@ -316,14 +317,26 @@ MainLoop(FILE *source)
{
if (line[i] == '*' && line[i + thislen] == '/')
{
in_xcomment = false;
ADVANCE_1;
if (xcdepth > 0)
{
xcdepth--;
}
else
{
in_xcomment = false;
ADVANCE_1;
}
}
else if (line[i] == '/' && line[i + thislen] == '*')
{
xcdepth++;
}
}
/* start of extended comment? */
else if (line[i] == '/' && line[i + thislen] == '*')
{
xcdepth = 0;
in_xcomment = true;
ADVANCE_1;
}
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: nodes.h,v 1.70 2000/06/28 03:33:15 tgl Exp $
* $Id: nodes.h,v 1.71 2000/07/14 15:43:51 thomas Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -193,6 +193,7 @@ typedef enum NodeTag
T_AlterGroupStmt,
T_DropGroupStmt,
T_ReindexStmt,
T_SetSessionStmt,
T_A_Expr = 700,
T_Attr,
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: parsenodes.h,v 1.108 2000/06/12 03:41:03 momjian Exp $
* $Id: parsenodes.h,v 1.109 2000/07/14 15:43:51 thomas Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -688,6 +688,16 @@ typedef struct ExplainStmt
bool verbose; /* print plan info */
} ExplainStmt;
/* ----------------------
* Set Session Statement
* ----------------------
*/
typedef struct SetSessionStmt
{
NodeTag type;
List *args;
} SetSessionStmt;
/* ----------------------
* Set Statement
* ----------------------
......
......@@ -34,4 +34,32 @@ SELECT 'after multi-line' AS fifth;
after multi-line
(1 row)
--
-- Nested comments
--
/*
SELECT 'trailing' as x1; -- inside block comment
*/
/* This block comment surrounds a query which itself has a block comment...
SELECT /* embedded single line */ 'embedded' AS x2;
*/
SELECT -- continued after the following block comments...
/* Deeply nested comment.
This includes a single apostrophe to make sure we aren't decoding this part as a string.
SELECT 'deep nest' AS n1;
/* Second level of nesting...
SELECT 'deeper nest' as n2;
/* Third level of nesting...
SELECT 'deepest nest' as n3;
*/
Hoo boy. Still two deep...
*/
Now just one deep...
*/
'deeply nested example' AS sixth;
sixth
-----------------------
deeply nested example
(1 row)
/* and this is the end of the file */
......@@ -12,5 +12,31 @@ SELECT 'before multi-line' AS fourth;
*/
SELECT 'after multi-line' AS fifth;
/* and this is the end of the file */
--
-- Nested comments
--
/*
SELECT 'trailing' as x1; -- inside block comment
*/
/* This block comment surrounds a query which itself has a block comment...
SELECT /* embedded single line */ 'embedded' AS x2;
*/
SELECT -- continued after the following block comments...
/* Deeply nested comment.
This includes a single apostrophe to make sure we aren't decoding this part as a string.
SELECT 'deep nest' AS n1;
/* Second level of nesting...
SELECT 'deeper nest' as n2;
/* Third level of nesting...
SELECT 'deepest nest' as n3;
*/
Hoo boy. Still two deep...
*/
Now just one deep...
*/
'deeply nested example' AS sixth;
/* and this is the end of the file */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment