Skip to content

Commit 226d7c6

Browse files
committed
Support USER MAPPING statements
1 parent 9322e5c commit 226d7c6

File tree

1 file changed

+106
-2
lines changed

1 file changed

+106
-2
lines changed

src/backend/parser/cypher_gram.y

+106-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121

2222
#include "postgraph.h"
2323

24+
#include "access/tableam.h"
2425
#include "catalog/index.h"
26+
#include "catalog/pg_am.h"
2527
#include "catalog/pg_class.h"
2628
#include "nodes/makefuncs.h"
2729
#include "nodes/nodes.h"
@@ -309,10 +311,11 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
309311
NotifyStmt ListenStmt UnlistenStmt
310312
TransactionStmt TransactionStmtLegacy TruncateStmt
311313
UpdateStmt
312-
PreparableStmt
314+
PreparableStmt CreateAmStmt
313315
VacuumStmt VariableResetStmt VariableSetStmt
314316
ViewStmt
315317
DropSubscriptionStmt AlterSubscriptionStmt CreateSubscriptionStmt
318+
DropUserMappingStmt CreateUserMappingStmt AlterUserMappingStmt
316319

317320
%type <node> select_no_parens select_with_parens select_clause
318321
simple_select
@@ -486,7 +489,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
486489
%type <list> OptSchemaEltList
487490
%type <string> RoleId
488491
%type <string> unicode_normal_form
489-
%type <rolespec> RoleSpec
492+
%type <rolespec> auth_ident RoleSpec
490493

491494
%type <node> cypher_query_start
492495
%type <list> cypher_query_body
@@ -576,6 +579,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
576579
%type <string> opt_existing_window_name
577580
%type <integer> opt_window_exclusion_clause
578581
%type <string> all_op
582+
%type <chr> am_type
579583
/* names */
580584

581585
%type <defelt> drop_option
@@ -892,6 +896,7 @@ stmt:
892896
| AlterSeqStmt
893897
| AlterSubscriptionStmt
894898
| AlterSystemStmt
899+
| AlterUserMappingStmt
895900
| AlterObjectDependsStmt
896901
| AlterObjectSchemaStmt
897902
| AlterOpFamilyStmt
@@ -912,6 +917,7 @@ stmt:
912917
| CopyStmt
913918
| ClosePortalStmt
914919
| ClusterStmt
920+
| CreateAmStmt
915921
| CreateAsStmt
916922
| CreateCastStmt
917923
| CreatedbStmt
@@ -928,6 +934,7 @@ stmt:
928934
| CreateStatsStmt
929935
| CreateSubscriptionStmt
930936
| CreateTransformStmt
937+
| CreateUserMappingStmt
931938
| CreateOpClassStmt
932939
| CreateSchemaStmt
933940
| CreateSeqStmt
@@ -953,6 +960,7 @@ stmt:
953960
| DropSubscriptionStmt
954961
| DropTableSpaceStmt
955962
| DropTransformStmt
963+
| DropUserMappingStmt
956964
| ExecuteStmt
957965
| ExplainStmt
958966
| FetchStmt
@@ -8500,6 +8508,27 @@ opt_check_option:
85008508
| /* EMPTY */ { $$ = NO_CHECK_OPTION; }
85018509
;
85028510

8511+
/*****************************************************************************
8512+
*
8513+
* QUERY:
8514+
* CREATE ACCESS METHOD name HANDLER handler_name
8515+
*
8516+
*****************************************************************************/
8517+
8518+
CreateAmStmt: CREATE ACCESS METHOD name TYPE_P am_type HANDLER handler_name
8519+
{
8520+
CreateAmStmt *n = makeNode(CreateAmStmt);
8521+
n->amname = $4;
8522+
n->handler_name = $8;
8523+
n->amtype = $6;
8524+
$$ = (Node *) n;
8525+
}
8526+
;
8527+
8528+
am_type:
8529+
INDEX { $$ = AMTYPE_INDEX; }
8530+
| TABLE { $$ = AMTYPE_TABLE; }
8531+
;
85038532

85048533
/*****************************************************************************
85058534
*
@@ -12676,6 +12705,81 @@ opt_ordinality: WITH ORDINALITY { $$ = true; }
1267612705
;
1267712706

1267812707

12708+
/*****************************************************************************
12709+
*
12710+
* QUERY:
12711+
* CREATE USER MAPPING FOR auth_ident SERVER name [OPTIONS]
12712+
*
12713+
*****************************************************************************/
12714+
12715+
CreateUserMappingStmt: CREATE USER MAPPING FOR auth_ident SERVER name create_generic_options
12716+
{
12717+
CreateUserMappingStmt *n = makeNode(CreateUserMappingStmt);
12718+
n->user = $5;
12719+
n->servername = $7;
12720+
n->options = $8;
12721+
n->if_not_exists = false;
12722+
$$ = (Node *) n;
12723+
}
12724+
| CREATE USER MAPPING IF NOT EXISTS FOR auth_ident SERVER name create_generic_options
12725+
{
12726+
CreateUserMappingStmt *n = makeNode(CreateUserMappingStmt);
12727+
n->user = $8;
12728+
n->servername = $10;
12729+
n->options = $11;
12730+
n->if_not_exists = true;
12731+
$$ = (Node *) n;
12732+
}
12733+
;
12734+
12735+
/* User mapping authorization identifier */
12736+
auth_ident: RoleSpec { $$ = $1; }
12737+
| USER { $$ = makeRoleSpec(ROLESPEC_CURRENT_USER, @1); }
12738+
;
12739+
12740+
/*****************************************************************************
12741+
*
12742+
* QUERY :
12743+
* DROP USER MAPPING FOR auth_ident SERVER name
12744+
*
12745+
* XXX you'd think this should have a CASCADE/RESTRICT option, even if it's
12746+
* only pro forma; but the SQL standard doesn't show one.
12747+
****************************************************************************/
12748+
12749+
DropUserMappingStmt: DROP USER MAPPING FOR auth_ident SERVER name
12750+
{
12751+
DropUserMappingStmt *n = makeNode(DropUserMappingStmt);
12752+
n->user = $5;
12753+
n->servername = $7;
12754+
n->missing_ok = false;
12755+
$$ = (Node *) n;
12756+
}
12757+
| DROP USER MAPPING IF EXISTS FOR auth_ident SERVER name
12758+
{
12759+
DropUserMappingStmt *n = makeNode(DropUserMappingStmt);
12760+
n->user = $7;
12761+
n->servername = $9;
12762+
n->missing_ok = true;
12763+
$$ = (Node *) n;
12764+
}
12765+
;
12766+
12767+
/*****************************************************************************
12768+
*
12769+
* QUERY :
12770+
* ALTER USER MAPPING FOR auth_ident SERVER name OPTIONS
12771+
*
12772+
****************************************************************************/
12773+
12774+
AlterUserMappingStmt: ALTER USER MAPPING FOR auth_ident SERVER name alter_generic_options
12775+
{
12776+
AlterUserMappingStmt *n = makeNode(AlterUserMappingStmt);
12777+
n->user = $5;
12778+
n->servername = $7;
12779+
n->options = $8;
12780+
$$ = (Node *) n;
12781+
}
12782+
;
1267912783

1268012784
/*****************************************************************************
1268112785
*

0 commit comments

Comments
 (0)