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

Commit0fec77a

Browse files
committed
SQL:2008 syntax CURRENT_CATALOG, CURRENT_SCHEMA, SET CATALOG, SET SCHEMA.
1 parentb1eeeb2 commit0fec77a

File tree

6 files changed

+97
-16
lines changed

6 files changed

+97
-16
lines changed

‎doc/src/sgml/func.sgml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.450 2008/10/14 17:12:32 tgl Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.451 2008/10/27 09:37:46 petere Exp $ -->
22

33
<chapter id="functions">
44
<title>Functions and Operators</title>
@@ -3184,7 +3184,8 @@ cast(-44 as bit(12)) <lineannotation>111111010100</lineannotation>
31843184
function fails and returns null. To indicate the part of the
31853185
pattern that should be returned on success, the pattern must contain
31863186
two occurrences of the escape character followed by a double quote
3187-
(<literal>"</>). The text matching the portion of the pattern
3187+
(<literal>"</>). <!-- " font-lock sanity -->
3188+
The text matching the portion of the pattern
31883189
between these markers is returned.
31893190
</para>
31903191

@@ -10932,14 +10933,20 @@ postgres=# select * from unnest2(array[[1,2],[3,4]]);
1093210933
</thead>
1093310934

1093410935
<tbody>
10936+
<row>
10937+
<entry><literal><function>current_catalog</function></literal></entry>
10938+
<entry><type>name</type></entry>
10939+
<entry>name of current database (called <quote>catalog</quote> in the SQL standard)</entry>
10940+
</row>
10941+
1093510942
<row>
1093610943
<entry><literal><function>current_database</function>()</literal></entry>
1093710944
<entry><type>name</type></entry>
1093810945
<entry>name of current database</entry>
1093910946
</row>
1094010947

1094110948
<row>
10942-
<entry><literal><function>current_schema</function>()</literal></entry>
10949+
<entry><literal><function>current_schema</function>[()]</literal></entry>
1094310950
<entry><type>name</type></entry>
1094410951
<entry>name of current schema</entry>
1094510952
</row>
@@ -11055,6 +11062,10 @@ postgres=# select * from unnest2(array[[1,2],[3,4]]);
1105511062
<secondary>current</secondary>
1105611063
</indexterm>
1105711064

11065+
<indexterm>
11066+
<primary>current_catalog</primary>
11067+
</indexterm>
11068+
1105811069
<indexterm>
1105911070
<primary>current_database</primary>
1106011071
</indexterm>
@@ -11083,9 +11094,12 @@ postgres=# select * from unnest2(array[[1,2],[3,4]]);
1108311094

1108411095
<note>
1108511096
<para>
11086-
<function>current_user</function>, <function>session_user</function>, and
11087-
<function>user</function> have special syntactic status in <acronym>SQL</acronym>:
11088-
they must be called without trailing parentheses.
11097+
<function>current_catalog</function>, <function>current_schema</function>,
11098+
<function>current_user</function>, <function>session_user</function>,
11099+
and <function>user</function> have special syntactic status
11100+
in <acronym>SQL</acronym>: they must be called without trailing
11101+
parentheses (optional in PostgreSQL in the case
11102+
of <function>current_schema</function>).
1108911103
</para>
1109011104
</note>
1109111105

‎doc/src/sgml/ref/set.sgml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/set.sgml,v 1.92 2008/03/10 12:39:22 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/set.sgml,v 1.93 2008/10/27 09:37:47 petere Exp $
33
PostgreSQL documentation
44
-->
55

@@ -150,6 +150,17 @@ SET [ SESSION | LOCAL ] TIME ZONE { <replaceable class="PARAMETER">timezone</rep
150150
special syntax:
151151

152152
<variablelist>
153+
<varlistentry>
154+
<term><literal>SCHEMA</literal></term>
155+
<listitem>
156+
<para>
157+
<literal>SET SCHEMA '<replaceable>value</>'</> is an alias for
158+
<literal>SET search_path TO <replaceable>value</></>. Only one
159+
schema can be specified using this syntax.
160+
</para>
161+
</listitem>
162+
</varlistentry>
163+
153164
<varlistentry>
154165
<term><literal>NAMES</literal></term>
155166
<listitem>

‎src/backend/catalog/sql_features.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ F731INSERT column privilegesNO
295295
F741Referential MATCH typesNOno partial match yet
296296
F751View CHECK enhancementsNO
297297
F761Session managementYES
298-
F762CURRENT_CATALOGNOsame as current_database()
299-
F763CURRENT_SCHEMANOsame as current_schema()
298+
F762CURRENT_CATALOGYES
299+
F763CURRENT_SCHEMAYES
300300
F771Connection managementYES
301301
F781Self-referencing operationsYES
302302
F791Insensitive cursorsYES

‎src/backend/parser/gram.y

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.629 2008/10/2708:47:14 petere Exp $
14+
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.630 2008/10/2709:37:47 petere Exp $
1515
*
1616
* HISTORY
1717
* AUTHORDATEMAJOR EVENT
@@ -401,12 +401,13 @@ static TypeName *TableFuncTypeName(List *columns);
401401
BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT
402402
BOOLEAN_P BOTH BY
403403

404-
CACHE CALLED CASCADE CASCADED CASE CAST CHAIN CHAR_P
404+
CACHE CALLED CASCADE CASCADED CASE CASTCATALOG_PCHAIN CHAR_P
405405
CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE
406406
CLUSTER COALESCE COLLATE COLUMN COMMENT COMMIT
407407
COMMITTED CONCURRENTLY CONFIGURATION CONNECTION CONSTRAINT CONSTRAINTS
408408
CONTENT_P CONTINUE_P CONVERSION_P COPY COST CREATE CREATEDB
409-
CREATEROLE CREATEUSER CROSS CSV CTYPE CURRENT_P CURRENT_DATE CURRENT_ROLE
409+
CREATEROLE CREATEUSER CROSS CSV CTYPE CURRENT_P
410+
CURRENT_CATALOG CURRENT_DATE CURRENT_ROLE CURRENT_SCHEMA
410411
CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE
411412

412413
DATA_P DATABASE DAY_P DEALLOCATE DEC DECIMAL_P DECLARE DEFAULT DEFAULTS
@@ -1133,6 +1134,22 @@ set_rest:/* Generic SET syntaxes: */
11331134
n->args =$5;
11341135
$$ = n;
11351136
}
1137+
|CATALOG_PSconst
1138+
{
1139+
ereport(ERROR,
1140+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1141+
errmsg("current database cannot be changed"),
1142+
scanner_errposition(@2)));
1143+
$$ =NULL;/*not reached*/
1144+
}
1145+
|SCHEMASconst
1146+
{
1147+
VariableSetStmt *n = makeNode(VariableSetStmt);
1148+
n->kind = VAR_SET_VALUE;
1149+
n->name ="search_path";
1150+
n->args = list_make1(makeStringConst($2,@2));
1151+
$$ = n;
1152+
}
11361153
|NAMESopt_encoding
11371154
{
11381155
VariableSetStmt *n = makeNode(VariableSetStmt);
@@ -8401,6 +8418,28 @@ func_expr:func_name '(' ')'
84018418
n->location = @1;
84028419
$$ = (Node *)n;
84038420
}
8421+
| CURRENT_CATALOG
8422+
{
8423+
FuncCall *n =makeNode(FuncCall);
8424+
n->funcname =SystemFuncName("current_database");
8425+
n->args = NIL;
8426+
n->agg_star =FALSE;
8427+
n->agg_distinct =FALSE;
8428+
n->func_variadic =FALSE;
8429+
n->location = @1;
8430+
$$ = (Node *)n;
8431+
}
8432+
| CURRENT_SCHEMA
8433+
{
8434+
FuncCall *n =makeNode(FuncCall);
8435+
n->funcname =SystemFuncName("current_schema");
8436+
n->args = NIL;
8437+
n->agg_star =FALSE;
8438+
n->agg_distinct =FALSE;
8439+
n->func_variadic =FALSE;
8440+
n->location = @1;
8441+
$$ = (Node *)n;
8442+
}
84048443
| CAST'(' a_expr AS Typename')'
84058444
{ $$ =makeTypeCast($3, $5, @1); }
84068445
| EXTRACT'(' extract_list')'
@@ -9336,6 +9375,7 @@ unreserved_keyword:
93369375
| CALLED
93379376
| CASCADE
93389377
| CASCADED
9378+
| CATALOG_P
93399379
| CHAIN
93409380
| CHARACTERISTICS
93419381
| CHECKPOINT
@@ -9625,6 +9665,7 @@ type_func_name_keyword:
96259665
| BETWEEN
96269666
| BINARY
96279667
| CROSS
9668+
| CURRENT_SCHEMA
96289669
| FREEZE
96299670
| FULL
96309671
| ILIKE
@@ -9667,6 +9708,7 @@ reserved_keyword:
96679708
| COLUMN
96689709
| CONSTRAINT
96699710
| CREATE
9711+
| CURRENT_CATALOG
96709712
| CURRENT_DATE
96719713
| CURRENT_ROLE
96729714
| CURRENT_TIME

‎src/backend/parser/keywords.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.204 2008/10/22 11:00:34 petere Exp $
14+
* $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.205 2008/10/27 09:37:47 petere Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -83,6 +83,7 @@ const ScanKeyword ScanKeywords[] = {
8383
{"cascaded",CASCADED,UNRESERVED_KEYWORD},
8484
{"case",CASE,RESERVED_KEYWORD},
8585
{"cast",CAST,RESERVED_KEYWORD},
86+
{"catalog",CATALOG_P,UNRESERVED_KEYWORD},
8687
{"chain",CHAIN,UNRESERVED_KEYWORD},
8788
{"char",CHAR_P,COL_NAME_KEYWORD},
8889
{"character",CHARACTER,COL_NAME_KEYWORD},
@@ -116,8 +117,10 @@ const ScanKeyword ScanKeywords[] = {
116117
{"csv",CSV,UNRESERVED_KEYWORD},
117118
{"ctype",CTYPE,UNRESERVED_KEYWORD},
118119
{"current",CURRENT_P,UNRESERVED_KEYWORD},
120+
{"current_catalog",CURRENT_CATALOG,RESERVED_KEYWORD},
119121
{"current_date",CURRENT_DATE,RESERVED_KEYWORD},
120122
{"current_role",CURRENT_ROLE,RESERVED_KEYWORD},
123+
{"current_schema",CURRENT_SCHEMA,TYPE_FUNC_NAME_KEYWORD},
121124
{"current_time",CURRENT_TIME,RESERVED_KEYWORD},
122125
{"current_timestamp",CURRENT_TIMESTAMP,RESERVED_KEYWORD},
123126
{"current_user",CURRENT_USER,RESERVED_KEYWORD},

‎src/interfaces/ecpg/preproc/preproc.y

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.377 2008/10/21 08:38:16 petere Exp $*/
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.378 2008/10/27 09:37:47 petere Exp $*/
22

33
/* Copyright comment*/
44
%{
@@ -423,12 +423,13 @@ add_typedef(char *name, char * dimension, char * length, enum ECPGttype type_enu
423423
BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT
424424
BOOLEAN_P BOTH BY
425425

426-
CACHE CALLED CASCADE CASCADED CASE CAST CHAIN CHAR_P
426+
CACHE CALLED CASCADE CASCADED CASE CASTCATALOG_PCHAIN CHAR_P
427427
CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE
428428
CLUSTER COALESCE COLLATE COLUMN COMMENT COMMIT
429429
COMMITTED CONCURRENTLY CONFIGURATION CONNECTION CONSTRAINT CONSTRAINTS
430430
CONTENT_P CONTINUE_P CONVERSION_P COPY COST CREATE CREATEDB
431-
CREATEROLE CREATEUSER CROSS CSV CTYPE CURRENT_P CURRENT_DATE CURRENT_ROLE
431+
CREATEROLE CREATEUSER CROSS CSV CTYPE CURRENT_P
432+
CURRENT_CATALOG CURRENT_DATE CURRENT_ROLE CURRENT_SCHEMA
432433
CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE
433434

434435
DATA_P DATABASE DAY_P DEALLOCATE DEC DECIMAL_P DECLARE DEFAULT DEFAULTS
@@ -1217,6 +1218,10 @@ set_rest:/* Generic SET syntaxes: */
12171218
{$$ = cat2_str(make_str("transaction"),$2); }
12181219
|SESSIONCHARACTERISTICSASTRANSACTIONtransaction_mode_list
12191220
{$$ = cat2_str(make_str("session characteristics as transaction"),$5); }
1221+
|CATALOG_PSconst
1222+
{$$ = cat2_str(make_str("catalog"),$2); }
1223+
|SCHEMASconst
1224+
{$$ = cat2_str(make_str("schema"),$2); }
12201225
|NAMESopt_encoding
12211226
{$$ = cat2_str(make_str("names"),$2); }
12221227
|ROLEColId_or_Sconst
@@ -4469,6 +4474,10 @@ func_expr: func_name '(' ')'
44694474
{$$ = make_str("session_user"); }
44704475
|USER
44714476
{$$ = make_str("user"); }
4477+
|CURRENT_CATALOG
4478+
{$$ = make_str("current_catalog"); }
4479+
|CURRENT_SCHEMA
4480+
{$$ = make_str("current_schema"); }
44724481
|CAST'('a_exprASTypename')'
44734482
{$$ = cat_str(5, make_str("cast("),$3, make_str("as"),$5, make_str(")")); }
44744483
|EXTRACT'('extract_list')'
@@ -6867,10 +6876,12 @@ reserved_keyword:
68676876
|CONSTRAINT{$$ = make_str("constraint"); }
68686877
|CREATE{$$ = make_str("create"); }
68696878
|CURRENT_P {$$ = make_str("current"); }
6879+
|CURRENT_CATALOG{$$ = make_str("current_catalog"); }
68706880
|CURRENT_DATE{$$ = make_str("current_date"); }
68716881
|CURRENT_TIME{$$ = make_str("current_time"); }
68726882
|CURRENT_TIMESTAMP{$$ = make_str("current_timestamp"); }
68736883
|CURRENT_ROLE{$$ = make_str("current_role"); }
6884+
|CURRENT_SCHEMA{$$ = make_str("current_schema"); }
68746885
|CURRENT_USER{$$ = make_str("current_user"); }
68756886
|DEFAULT{$$ = make_str("default"); }
68766887
|DEFERRABLE{$$ = make_str("deferrable"); }

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp