Skip to content

Instantly share code, notes, and snippets.

@lfittl
Created September 10, 2025 19:21
Show Gist options
  • Save lfittl/fe41c6ae8ddf9c11fb2142fd7c456e6c to your computer and use it in GitHub Desktop.
Save lfittl/fe41c6ae8ddf9c11fb2142fd7c456e6c to your computer and use it in GitHub Desktop.
Yugabyte parser customizations (PG15)
diff --git a/Users/lfittl/Code/postgres/src/backend/parser/gram.y b/src/postgres/src/backend/parser/gram.y
index 0b9cd62bf0..75ee847230 100644
--- a/Users/lfittl/Code/postgres/src/backend/parser/gram.y
+++ b/src/postgres/src/backend/parser/gram.y
@@ -65,6 +65,11 @@
#include "utils/numeric.h"
#include "utils/xml.h"
+/* YB includes */
+#include "miscadmin.h"
+#include "utils/builtins.h"
+#include "yb/yql/pggate/ybc_gflags.h"
+
/*
* Location tracking support --- simpler than bison's default, since we only
@@ -166,8 +171,42 @@ typedef struct KeyActions
#define parser_yyerror(msg) scanner_yyerror(msg, yyscanner)
#define parser_errposition(pos) scanner_errposition(pos, yyscanner)
+#define parser_ybc_not_support(pos, feature) \
+ ybc_not_support(pos, yyscanner, feature " not supported yet", -1, NULL)
+
+#define parser_ybc_warn_ignored(pos, feature, issue) \
+ ybc_not_support_signal(pos, yyscanner, \
+ feature " not supported yet and will be ignored", \
+ issue, NULL, WARNING)
+
+#define parser_ybc_signal_unsupported(pos, feature, issue) \
+ ybc_not_support(pos, yyscanner, feature " not supported yet", issue, NULL)
+
+#define parser_ybc_signal_unsupported_by_flag(pos, feature, flag, extra_hint) \
+ ybc_not_support(pos, yyscanner, \
+ feature " not supported due to setting of flag --" flag, \
+ -2, extra_hint)
+
+#define parser_ybc_not_support_in_templates(pos, feature) \
+ ybc_not_support_in_templates(pos, yyscanner, feature " is not supported in template0/template1 yet")
+
+#define parser_ybc_beta_feature(pos, feature, has_own_flag) \
+ check_beta_feature(pos, yyscanner, has_own_flag ? "FLAGS_ysql_beta_feature_" feature : NULL, feature)
+
+#define parser_ybc_deprecated_feature_warning(pos, feature) \
+ ybc_deprecated_feature_warning(pos, yyscanner, feature)
+
static void base_yyerror(YYLTYPE *yylloc, core_yyscan_t yyscanner,
const char *msg);
+static void ybc_not_support_signal(int pos, core_yyscan_t yyscanner,
+ const char *msg, int issue,
+ const char *extra_hint, int signal_level);
+static void ybc_not_support(int pos, core_yyscan_t yyscanner, const char *msg,
+ int issue, const char *extra_hint);
+static void ybc_not_support_in_templates(int pos, core_yyscan_t yyscanner, const char *msg);
+static void check_beta_feature(int pos, core_yyscan_t yyscanner, const char* flag, const char* feature);
+static void ybc_deprecated_feature_warning(int pos, core_yyscan_t yyscanner, const char *feature);
+
static RawStmt *makeRawStmt(Node *stmt, int stmt_location);
static void updateRawStmtEnd(RawStmt *rs, int end_location);
static Node *makeColumnRef(char *colname, List *indirection,
@@ -281,6 +320,10 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
MergeWhenClause *mergewhen;
struct KeyActions *keyactions;
struct KeyAction *keyaction;
+
+ YbOptSplit *splitopt;
+ char *grpopt;
+ YbRowBounds *rowbounds;
}
%type <node> stmt toplevel_stmt schema_stmt routine_body_stmt
@@ -427,7 +470,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
old_aggr_definition old_aggr_list
oper_argtypes RuleActionList RuleActionMulti
opt_column_list columnList opt_name_list
- sort_clause opt_sort_clause sortby_list index_params stats_params
+ sort_clause opt_sort_clause sortby_list yb_index_params stats_params
opt_include opt_c_include index_including_params
name_list role_list from_clause from_list opt_array_bounds
qualified_name_list any_name any_name_list type_name_list
@@ -640,6 +683,21 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
%type <list> hash_partbound
%type <defelt> hash_partbound_elem
+/* YB types */
+%type <boolean> opt_concurrently_matview yb_opt_cascade
+%type <grpopt> OptTableGroup
+%type <ival> Oid opt_yb_hash opt_yb_index_sort_order yb_hash
+ yb_opt_concurrently_index
+%type <list> oid_list yb_hash_index_expr_list yb_hash_index_expr_with_alias
+ yb_index_expr_list_hash_elems yb_split_point yb_split_points
+%type <node> YbBackfillIndexStmt YbCreateTableGroupStmt YbCreateProfileStmt
+ YbDropProfileStmt
+%type <rolespec> OptTableGroupOwner
+%type <rowbounds> YbRowBounds
+%type <splitopt> SplitClause YbOptSplit
+%type <str> OptTableSpaceLocation opt_for_bfinstr partition_key row_key
+ read_time row_key_end row_key_start yb_opt_alias
+
/*
* Non-keyword token types. These are hard-wired into the "flex" lexer.
@@ -743,6 +801,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
TABLE TABLES TABLESAMPLE TABLESPACE TEMP TEMPLATE TEMPORARY TEXT_P THEN
TIES TIME TIMESTAMP TO TRAILING TRANSACTION TRANSFORM
+
TREAT TRIGGER TRIM TRUE_P
TRUNCATE TRUSTED TYPE_P TYPES_P
@@ -761,6 +820,26 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
ZONE
+ _YB_ACCOUNT_P
+
+ _YB_BACKFILL_P
+
+ _YB_CHANGE_P _YB_COLOCATED_P _YB_COLOCATION_P
+
+ _YB_FAILED_LOGIN_ATTEMPTS_P
+
+ _YB_HASH_P
+
+ _YB_NONCONCURRENTLY_P _YB_NOPROFILE_P
+
+ _YB_PROFILE_P
+
+ _YB_SPLIT_P
+
+ _YB_TABLEGROUP_P _YB_TABLEGROUPS_P _YB_TABLETS_P
+
+ _YB_UNLOCK_P
+
/*
* The grammar thinks these are keywords, but they are not in the kwlist.h
* list and so can never be entered directly. The filter in parser.c
@@ -825,6 +904,19 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
*/
%nonassoc UNBOUNDED /* ideally would have same precedence as IDENT */
%nonassoc IDENT PARTITION RANGE ROWS GROUPS PRECEDING FOLLOWING CUBE ROLLUP
+
+ /*
+ * YB: Break shift/reduce conflict in hash column declaration "col HASH" by
+ * giving a higher precedence to HASH as a sort order over operator class.
+ */
+%nonassoc _YB_HASH_P
+%nonassoc NO_OPCLASS
+ /*
+ * YB: Break shift/reduce conflict in hash column declaration "(col) HASH" by
+ * giving a higher precedence to col as an expression list over a single expression.
+ */
+%nonassoc EXPR_LIST
+
%left Op OPERATOR /* multi-character ops and user-defined operators */
%left '+' '-'
%left '*' '/' '%'
@@ -936,6 +1028,11 @@ toplevel_stmt:
| TransactionStmtLegacy
;
+/*
+ * YB: The checks in the "stmt" rule are only for bug-prevention. If we miss an
+ * error check on an unsupported feature, these checks will stop unsupported
+ * statements from being processed further.
+ */
stmt:
AlterEventTrigStmt
| AlterCollationStmt
@@ -944,44 +1041,44 @@ stmt:
| AlterDefaultPrivilegesStmt
| AlterDomainStmt
| AlterEnumStmt
- | AlterExtensionStmt
- | AlterExtensionContentsStmt
+ | AlterExtensionStmt { parser_ybc_beta_feature(@1, "extension", true); }
+ | AlterExtensionContentsStmt { parser_ybc_beta_feature(@1, "extension", true); }
| AlterFdwStmt
| AlterForeignServerStmt
| AlterFunctionStmt
| AlterGroupStmt
- | AlterObjectDependsStmt
+ | AlterObjectDependsStmt { parser_ybc_not_support(@1, "This statement"); }
| AlterObjectSchemaStmt
| AlterOwnerStmt
| AlterOperatorStmt
| AlterTypeStmt
| AlterPolicyStmt
| AlterSeqStmt
- | AlterSystemStmt
+ | AlterSystemStmt { parser_ybc_not_support(@1, "This statement"); }
| AlterTableStmt
- | AlterTblSpcStmt
- | AlterCompositeTypeStmt
+ | AlterTblSpcStmt { parser_ybc_signal_unsupported(@1, "This statement", 1153); }
+ | AlterCompositeTypeStmt { parser_ybc_not_support(@1, "This statement"); }
| AlterPublicationStmt
| AlterRoleSetStmt
| AlterRoleStmt
- | AlterSubscriptionStmt
+ | AlterSubscriptionStmt { parser_ybc_not_support(@1, "This statement"); }
| AlterStatsStmt
- | AlterTSConfigurationStmt
- | AlterTSDictionaryStmt
+ | AlterTSConfigurationStmt { parser_ybc_beta_feature(@1, "alter text search configuration", false); }
+ | AlterTSDictionaryStmt { parser_ybc_not_support(@1, "This statement"); }
| AlterUserMappingStmt
| AnalyzeStmt
| CallStmt
- | CheckPointStmt
+ | CheckPointStmt { parser_ybc_beta_feature(@1, "checkpoint", false); }
| ClosePortalStmt
- | ClusterStmt
+ | ClusterStmt { parser_ybc_not_support(@1, "This statement"); }
| CommentStmt
| ConstraintsSetStmt
| CopyStmt
| CreateAmStmt
- | CreateAsStmt
- | CreateAssertionStmt
+ | CreateAsStmt { parser_ybc_not_support_in_templates(@1, "This statement"); }
+ | CreateAssertionStmt { parser_ybc_not_support(@1, "This statement"); }
| CreateCastStmt
- | CreateConversionStmt
+ | CreateConversionStmt { parser_ybc_not_support(@1, "This statement"); }
| CreateDomainStmt
| CreateExtensionStmt
| CreateFdwStmt
@@ -997,12 +1094,12 @@ stmt:
| CreatePolicyStmt
| CreatePLangStmt
| CreateSchemaStmt
- | CreateSeqStmt
- | CreateStmt
- | CreateSubscriptionStmt
+ | CreateSeqStmt { parser_ybc_not_support_in_templates(@1, "This statement"); }
+ | CreateStmt { parser_ybc_not_support_in_templates(@1, "This statement"); }
+ | CreateSubscriptionStmt { parser_ybc_not_support(@1, "This statement"); }
| CreateStatsStmt
| CreateTableSpaceStmt
- | CreateTransformStmt
+ | CreateTransformStmt { parser_ybc_not_support(@1, "This statement"); }
| CreateTrigStmt
| CreateEventTrigStmt
| CreateRoleStmt
@@ -1020,9 +1117,9 @@ stmt:
| DropOpFamilyStmt
| DropOwnedStmt
| DropStmt
- | DropSubscriptionStmt
+ | DropSubscriptionStmt { parser_ybc_not_support(@1, "This statement"); }
| DropTableSpaceStmt
- | DropTransformStmt
+ | DropTransformStmt { parser_ybc_not_support(@1, "This statement"); }
| DropRoleStmt
| DropUserMappingStmt
| DropdbStmt
@@ -1031,15 +1128,15 @@ stmt:
| FetchStmt
| GrantStmt
| GrantRoleStmt
- | ImportForeignSchemaStmt
+ | ImportForeignSchemaStmt { parser_ybc_beta_feature(@1, "foreign data wrapper", false); }
| IndexStmt
| InsertStmt
- | ListenStmt
+ | ListenStmt { parser_ybc_warn_ignored(@1, "LISTEN", 1872); }
| RefreshMatViewStmt
- | LoadStmt
+ | LoadStmt { parser_ybc_not_support(@1, "This statement"); }
| LockStmt
- | MergeStmt
- | NotifyStmt
+ | MergeStmt { parser_ybc_not_support(@1, "This statement"); }
+ | NotifyStmt { parser_ybc_warn_ignored(@1, "NOTIFY", 1872); }
| PrepareStmt
| ReassignOwnedStmt
| ReindexStmt
@@ -1054,7 +1151,7 @@ stmt:
| SelectStmt
| TransactionStmt
| TruncateStmt
- | UnlistenStmt
+ | UnlistenStmt { parser_ybc_warn_ignored(@1, "UNLISTEN", 1872); }
| UpdateStmt
| VacuumStmt
| VariableResetStmt
@@ -1063,6 +1160,13 @@ stmt:
| ViewStmt
| /*EMPTY*/
{ $$ = NULL; }
+
+ /* YB stmts */
+ | YbBackfillIndexStmt
+ | YbCreateProfileStmt
+ | YbDropProfileStmt
+ /* YB deprecated stmts */
+ | YbCreateTableGroupStmt
;
/*****************************************************************************
@@ -1164,6 +1268,30 @@ AlterOptRoleElem:
{
$$ = makeDefElem("rolemembers", (Node *) $2, @1);
}
+ | _YB_PROFILE_P name
+ {
+ if (!*YBCGetGFlags()->ysql_enable_profile)
+ parser_ybc_not_support(@1, "PROFILE");
+ $$ = makeDefElem("profile", (Node *)makeString($2), @1);
+ }
+ | _YB_NOPROFILE_P
+ {
+ if (!*YBCGetGFlags()->ysql_enable_profile)
+ parser_ybc_not_support(@1, "PROFILE");
+ $$ = makeDefElem("noprofile", (Node *)makeInteger(false), @1);
+ }
+ | _YB_ACCOUNT_P LOCK_P
+ {
+ if (!*YBCGetGFlags()->ysql_enable_profile)
+ parser_ybc_not_support(@1, "PROFILE");
+ $$ = makeDefElem("unlocked", (Node *)makeInteger(false), @1);
+ }
+ | _YB_ACCOUNT_P _YB_UNLOCK_P
+ {
+ if (!*YBCGetGFlags()->ysql_enable_profile)
+ parser_ybc_not_support(@1, "PROFILE");
+ $$ = makeDefElem("unlocked", (Node *)makeInteger(true), @1);
+ }
| IDENT
{
/*
@@ -1203,6 +1331,10 @@ AlterOptRoleElem:
*/
$$ = makeDefElem("inherit", (Node *) makeBoolean(false), @1);
}
+ else if (strcmp($1, "lock") == 0)
+ $$ = makeDefElem("islocked", (Node *)makeInteger(true), @1);
+ else if (strcmp($1, "open") == 0)
+ $$ = makeDefElem("islocked", (Node *)makeInteger(false), @1);
else
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
@@ -1446,6 +1578,8 @@ CreateSchemaStmt:
/* One can omit the schema name or the authorization id. */
n->schemaname = $3;
n->authrole = $5;
+ if ($6 != NIL)
+ parser_ybc_not_support(@6, "CREATE SCHEMA with elements");
n->schemaElts = $6;
n->if_not_exists = false;
$$ = (Node *) n;
@@ -1457,6 +1591,8 @@ CreateSchemaStmt:
/* ...but not both */
n->schemaname = $3;
n->authrole = NULL;
+ if ($4 != NIL)
+ parser_ybc_not_support(@4, "CREATE SCHEMA with elements");
n->schemaElts = $4;
n->if_not_exists = false;
$$ = (Node *) n;
@@ -2039,7 +2175,7 @@ AlterTableStmt:
n->missing_ok = true;
$$ = (Node *) n;
}
- | ALTER TABLE ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait
+ | ALTER TABLE ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait yb_opt_cascade
{
AlterTableMoveAllStmt *n =
makeNode(AlterTableMoveAllStmt);
@@ -2047,11 +2183,13 @@ AlterTableStmt:
n->orig_tablespacename = $6;
n->objtype = OBJECT_TABLE;
n->roles = NIL;
+ n->yb_relation = NULL;
n->new_tablespacename = $9;
n->nowait = $10;
+ n->yb_cascade = $11;
$$ = (Node *) n;
}
- | ALTER TABLE ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait
+ | ALTER TABLE ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait yb_opt_cascade
{
AlterTableMoveAllStmt *n =
makeNode(AlterTableMoveAllStmt);
@@ -2059,10 +2197,25 @@ AlterTableStmt:
n->orig_tablespacename = $6;
n->objtype = OBJECT_TABLE;
n->roles = $9;
+ n->yb_relation = NULL;
n->new_tablespacename = $12;
n->nowait = $13;
+ n->yb_cascade = $14;
$$ = (Node *) n;
}
+ | ALTER TABLE ALL IN_P TABLESPACE name _YB_COLOCATED_P WITH relation_expr SET TABLESPACE name opt_nowait yb_opt_cascade
+ {
+ AlterTableMoveAllStmt *n =
+ makeNode(AlterTableMoveAllStmt);
+ n->orig_tablespacename = $6;
+ n->objtype = OBJECT_TABLE;
+ n->roles = NIL;
+ n->yb_relation = $9;
+ n->new_tablespacename = $12;
+ n->nowait = $13;
+ n->yb_cascade = $14;
+ $$ = (Node *)n;
+ }
| ALTER INDEX qualified_name alter_table_cmds
{
AlterTableStmt *n = makeNode(AlterTableStmt);
@@ -2093,7 +2246,7 @@ AlterTableStmt:
n->missing_ok = false;
$$ = (Node *) n;
}
- | ALTER INDEX ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait
+ | ALTER INDEX ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait yb_opt_cascade
{
AlterTableMoveAllStmt *n =
makeNode(AlterTableMoveAllStmt);
@@ -2101,11 +2254,13 @@ AlterTableStmt:
n->orig_tablespacename = $6;
n->objtype = OBJECT_INDEX;
n->roles = NIL;
+ n->yb_relation = NULL;
n->new_tablespacename = $9;
n->nowait = $10;
+ n->yb_cascade = $11;
$$ = (Node *) n;
}
- | ALTER INDEX ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait
+ | ALTER INDEX ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait yb_opt_cascade
{
AlterTableMoveAllStmt *n =
makeNode(AlterTableMoveAllStmt);
@@ -2113,8 +2268,10 @@ AlterTableStmt:
n->orig_tablespacename = $6;
n->objtype = OBJECT_INDEX;
n->roles = $9;
+ n->yb_relation = NULL;
n->new_tablespacename = $12;
n->nowait = $13;
+ n->yb_cascade = $14;
$$ = (Node *) n;
}
| ALTER SEQUENCE qualified_name alter_table_cmds
@@ -2177,7 +2334,7 @@ AlterTableStmt:
n->missing_ok = true;
$$ = (Node *) n;
}
- | ALTER MATERIALIZED VIEW ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait
+ | ALTER MATERIALIZED VIEW ALL IN_P TABLESPACE name SET TABLESPACE name opt_nowait yb_opt_cascade
{
AlterTableMoveAllStmt *n =
makeNode(AlterTableMoveAllStmt);
@@ -2185,11 +2342,13 @@ AlterTableStmt:
n->orig_tablespacename = $7;
n->objtype = OBJECT_MATVIEW;
n->roles = NIL;
+ n->yb_relation = NULL;
n->new_tablespacename = $10;
n->nowait = $11;
+ n->yb_cascade = $12;
$$ = (Node *) n;
}
- | ALTER MATERIALIZED VIEW ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait
+ | ALTER MATERIALIZED VIEW ALL IN_P TABLESPACE name OWNED BY role_list SET TABLESPACE name opt_nowait yb_opt_cascade
{
AlterTableMoveAllStmt *n =
makeNode(AlterTableMoveAllStmt);
@@ -2197,8 +2356,10 @@ AlterTableStmt:
n->orig_tablespacename = $7;
n->objtype = OBJECT_MATVIEW;
n->roles = $10;
+ n->yb_relation = NULL;
n->new_tablespacename = $13;
n->nowait = $14;
+ n->yb_cascade = $15;
$$ = (Node *) n;
}
| ALTER FOREIGN TABLE relation_expr alter_table_cmds
@@ -2405,6 +2566,7 @@ alter_table_cmd:
/* ALTER TABLE <name> ALTER [COLUMN] <colname> SET ( column_parameter = value [, ... ] ) */
| ALTER opt_column ColId SET reloptions
{
+ parser_ybc_signal_unsupported(@1, "ALTER action ALTER COLUMN ... SET", 1124);
AlterTableCmd *n = makeNode(AlterTableCmd);
n->subtype = AT_SetOptions;
@@ -2415,6 +2577,7 @@ alter_table_cmd:
/* ALTER TABLE <name> ALTER [COLUMN] <colname> RESET ( column_parameter [, ... ] ) */
| ALTER opt_column ColId RESET reloptions
{
+ parser_ybc_signal_unsupported(@1, "ALTER action ALTER COLUMN ... RESET", 1124);
AlterTableCmd *n = makeNode(AlterTableCmd);
n->subtype = AT_ResetOptions;
@@ -2425,6 +2588,7 @@ alter_table_cmd:
/* ALTER TABLE <name> ALTER [COLUMN] <colname> SET STORAGE <storagemode> */
| ALTER opt_column ColId SET STORAGE ColId
{
+ parser_ybc_signal_unsupported(@1, "ALTER action ALTER COLUMN ... SET STORAGE", 1124);
AlterTableCmd *n = makeNode(AlterTableCmd);
n->subtype = AT_SetStorage;
@@ -2607,6 +2771,7 @@ alter_table_cmd:
/* ALTER TABLE <name> CLUSTER ON <indexname> */
| CLUSTER ON name
{
+ parser_ybc_signal_unsupported(@1, "ALTER action CLUSTER ON", 1124);
AlterTableCmd *n = makeNode(AlterTableCmd);
n->subtype = AT_ClusterOn;
@@ -2616,6 +2781,7 @@ alter_table_cmd:
/* ALTER TABLE <name> SET WITHOUT CLUSTER */
| SET WITHOUT CLUSTER
{
+ parser_ybc_signal_unsupported(@1, "ALTER action SET WITHOUT CLUSTER", 1124);
AlterTableCmd *n = makeNode(AlterTableCmd);
n->subtype = AT_DropCluster;
@@ -2709,6 +2875,7 @@ alter_table_cmd:
/* ALTER TABLE <name> ENABLE RULE <rule> */
| ENABLE_P RULE name
{
+ parser_ybc_signal_unsupported(@1, "ALTER action ENABLE RULE", 1124);
AlterTableCmd *n = makeNode(AlterTableCmd);
n->subtype = AT_EnableRule;
@@ -2718,6 +2885,7 @@ alter_table_cmd:
/* ALTER TABLE <name> ENABLE ALWAYS RULE <rule> */
| ENABLE_P ALWAYS RULE name
{
+ parser_ybc_signal_unsupported(@1, "ALTER action ENABLE ALWAYS RULE", 1124);
AlterTableCmd *n = makeNode(AlterTableCmd);
n->subtype = AT_EnableAlwaysRule;
@@ -2727,6 +2895,7 @@ alter_table_cmd:
/* ALTER TABLE <name> ENABLE REPLICA RULE <rule> */
| ENABLE_P REPLICA RULE name
{
+ parser_ybc_signal_unsupported(@1, "ALTER action ENABLE REPLICA RULE", 1124);
AlterTableCmd *n = makeNode(AlterTableCmd);
n->subtype = AT_EnableReplicaRule;
@@ -2736,6 +2905,7 @@ alter_table_cmd:
/* ALTER TABLE <name> DISABLE RULE <rule> */
| DISABLE_P RULE name
{
+ parser_ybc_signal_unsupported(@1, "ALTER action DISABLE RULE", 1124);
AlterTableCmd *n = makeNode(AlterTableCmd);
n->subtype = AT_DisableRule;
@@ -2745,6 +2915,7 @@ alter_table_cmd:
/* ALTER TABLE <name> INHERIT <parent> */
| INHERIT qualified_name
{
+ parser_ybc_beta_feature(@1, "inheritance", false);
AlterTableCmd *n = makeNode(AlterTableCmd);
n->subtype = AT_AddInherit;
@@ -2754,6 +2925,7 @@ alter_table_cmd:
/* ALTER TABLE <name> NO INHERIT <parent> */
| NO INHERIT qualified_name
{
+ parser_ybc_beta_feature(@1, "inheritance", false);
AlterTableCmd *n = makeNode(AlterTableCmd);
n->subtype = AT_DropInherit;
@@ -2804,6 +2976,7 @@ alter_table_cmd:
n->subtype = AT_SetTableSpace;
n->name = $3;
+ n->yb_cascade = false;
$$ = (Node *) n;
}
/* ALTER TABLE <name> SET (...) */
@@ -2904,6 +3077,11 @@ alter_using:
| /* EMPTY */ { $$ = NULL; }
;
+yb_opt_cascade:
+ CASCADE { $$ = true; }
+ | /* EMPTY */ { $$ = false; }
+ ;
+
replica_identity:
NOTHING
{
@@ -2929,8 +3107,16 @@ replica_identity:
n->name = NULL;
$$ = (Node *) n;
}
+ | _YB_CHANGE_P
+ {
+ ReplicaIdentityStmt *n = makeNode(ReplicaIdentityStmt);
+ n->identity_type = YB_REPLICA_IDENTITY_CHANGE;
+ n->name = NULL;
+ $$ = (Node *) n;
+ }
| USING INDEX name
{
+ parser_ybc_signal_unsupported(@1, "ALTER TABLE REPLICA IDENTITY USING INDEX", 1124);
ReplicaIdentityStmt *n = makeNode(ReplicaIdentityStmt);
n->identity_type = REPLICA_IDENTITY_INDEX;
@@ -2947,6 +3133,8 @@ opt_reloptions: WITH reloptions { $$ = $2; }
| /* EMPTY */ { $$ = NIL; }
;
+/* YB: TODO: add interleaved to reloption_list.
+ Eventually deprecate using colocated */
reloption_list:
reloption_elem { $$ = list_make1($1); }
| reloption_list ',' reloption_elem { $$ = lappend($1, $3); }
@@ -3127,6 +3315,7 @@ hash_partbound:
AlterCompositeTypeStmt:
ALTER TYPE_P any_name alter_type_cmds
{
+ parser_ybc_signal_unsupported(@1, "ALTER TYPE", 1893);
AlterTableStmt *n = makeNode(AlterTableStmt);
/* can't use qualified_name, sigh */
@@ -3146,6 +3335,7 @@ alter_type_cmd:
/* ALTER TYPE <name> ADD ATTRIBUTE <coldef> [RESTRICT|CASCADE] */
ADD_P ATTRIBUTE TableFuncElement opt_drop_behavior
{
+ parser_ybc_signal_unsupported(@1, "ALTER TYPE ADD ATTRIBUTE", 1893);
AlterTableCmd *n = makeNode(AlterTableCmd);
n->subtype = AT_AddColumn;
@@ -3156,6 +3346,7 @@ alter_type_cmd:
/* ALTER TYPE <name> DROP ATTRIBUTE IF EXISTS <attname> [RESTRICT|CASCADE] */
| DROP ATTRIBUTE IF_P EXISTS ColId opt_drop_behavior
{
+ parser_ybc_signal_unsupported(@1, "ALTER TYPE DROP ATTRIBUTE", 1893);
AlterTableCmd *n = makeNode(AlterTableCmd);
n->subtype = AT_DropColumn;
@@ -3167,6 +3358,7 @@ alter_type_cmd:
/* ALTER TYPE <name> DROP ATTRIBUTE <attname> [RESTRICT|CASCADE] */
| DROP ATTRIBUTE ColId opt_drop_behavior
{
+ parser_ybc_signal_unsupported(@1, "ALTER TYPE DROP ATTRIBUTE", 1893);
AlterTableCmd *n = makeNode(AlterTableCmd);
n->subtype = AT_DropColumn;
@@ -3178,6 +3370,7 @@ alter_type_cmd:
/* ALTER TYPE <name> ALTER ATTRIBUTE <attname> [SET DATA] TYPE <typename> [RESTRICT|CASCADE] */
| ALTER ATTRIBUTE ColId opt_set_data TYPE_P Typename opt_collate_clause opt_drop_behavior
{
+ parser_ybc_signal_unsupported(@1, "ALTER TYPE ALTER ATTRIBUTE", 1893);
AlterTableCmd *n = makeNode(AlterTableCmd);
ColumnDef *def = makeNode(ColumnDef);
@@ -3465,6 +3658,7 @@ copy_generic_opt_arg_list_item:
CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')'
OptInherit OptPartitionSpec table_access_method_clause OptWith
OnCommitOption OptTableSpace
+ YbOptSplit OptTableGroup
{
CreateStmt *n = makeNode(CreateStmt);
@@ -3480,11 +3674,45 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')'
n->oncommit = $12;
n->tablespacename = $13;
n->if_not_exists = false;
+
+ n->split_options = $14;
+ n->tablegroupname = $15;
+ if ($14 && $2 == RELPERSISTENCE_TEMP)
+ {
+ ereport(WARNING,
+ (errmsg("split options on TEMP table will be ignored")));
+ }
+ if ($9 && $14)
+ {
+ n->split_options = NULL;
+ ereport(WARNING,
+ (errmsg("split options on a partitioned table will be ignored")));
+ }
+ if ($15 && $2 == RELPERSISTENCE_TEMP)
+ {
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("cannot use TABLEGROUP with TEMP table")));
+ }
+ if ($13 && $15)
+ {
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("cannot use TABLEGROUP with TABLESPACE"),
+ errdetail("The tablespace of the tablegroup will be used.")));
+ }
+ if ($14 && $15)
+ {
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("cannot use TABLEGROUP with SPLIT")));
+ }
$$ = (Node *) n;
}
| CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name '('
OptTableElementList ')' OptInherit OptPartitionSpec table_access_method_clause
OptWith OnCommitOption OptTableSpace
+ YbOptSplit OptTableGroup
{
CreateStmt *n = makeNode(CreateStmt);
@@ -3500,11 +3728,45 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')'
n->oncommit = $15;
n->tablespacename = $16;
n->if_not_exists = true;
+
+ n->split_options = $17;
+ n->tablegroupname = $18;
+ if ($17 && $2 == RELPERSISTENCE_TEMP)
+ {
+ ereport(WARNING,
+ (errmsg("split options on TEMP table will be ignored")));
+ }
+ if ($12 && $17)
+ {
+ n->split_options = NULL;
+ ereport(WARNING,
+ (errmsg("split options on a partitioned table will be ignored")));
+ }
+ if ($18 && $2 == RELPERSISTENCE_TEMP)
+ {
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("cannot use TABLEGROUP with TEMP table")));
+ }
+ if ($16 && $18)
+ {
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("cannot use TABLEGROUP with TABLESPACE"),
+ errdetail("The tablespace of the tablegroup will be used.")));
+ }
+ if ($17 && $18)
+ {
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("cannot use TABLEGROUP with SPLIT")));
+ }
$$ = (Node *) n;
}
| CREATE OptTemp TABLE qualified_name OF any_name
OptTypedTableElementList OptPartitionSpec table_access_method_clause
OptWith OnCommitOption OptTableSpace
+ YbOptSplit OptTableGroup
{
CreateStmt *n = makeNode(CreateStmt);
@@ -3521,11 +3783,45 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')'
n->oncommit = $11;
n->tablespacename = $12;
n->if_not_exists = false;
+
+ n->split_options = $13;
+ n->tablegroupname = $14;
+ if ($13 && $2 == RELPERSISTENCE_TEMP)
+ {
+ ereport(WARNING,
+ (errmsg("split options on TEMP table will be ignored")));
+ }
+ if ($8 && $13)
+ {
+ n->split_options = NULL;
+ ereport(WARNING,
+ (errmsg("split options on a partitioned table will be ignored")));
+ }
+ if ($14 && $2 == RELPERSISTENCE_TEMP)
+ {
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("cannot use TABLEGROUP with TEMP table")));
+ }
+ if ($12 && $14)
+ {
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("cannot use TABLEGROUP with TABLESPACE"),
+ errdetail("The tablespace of the tablegroup will be used.")));
+ }
+ if ($13 && $14)
+ {
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("cannot use TABLEGROUP with SPLIT")));
+ }
$$ = (Node *) n;
}
| CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name OF any_name
OptTypedTableElementList OptPartitionSpec table_access_method_clause
OptWith OnCommitOption OptTableSpace
+ YbOptSplit OptTableGroup
{
CreateStmt *n = makeNode(CreateStmt);
@@ -3542,11 +3838,45 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')'
n->oncommit = $14;
n->tablespacename = $15;
n->if_not_exists = true;
+
+ n->split_options = $16;
+ n->tablegroupname = $17;
+ if ($16 && $2 == RELPERSISTENCE_TEMP)
+ {
+ ereport(WARNING,
+ (errmsg("split options on TEMP table will be ignored")));
+ }
+ if ($11 && $16)
+ {
+ n->split_options = NULL;
+ ereport(WARNING,
+ (errmsg("split options on a partitioned table will be ignored")));
+ }
+ if ($17 && $2 == RELPERSISTENCE_TEMP)
+ {
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("cannot use TABLEGROUP with TEMP table")));
+ }
+ if ($15 && $17)
+ {
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("cannot use TABLEGROUP with TABLESPACE"),
+ errdetail("The tablespace of the tablegroup will be used.")));
+ }
+ if ($16 && $17)
+ {
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("cannot use TABLEGROUP with SPLIT")));
+ }
$$ = (Node *) n;
}
| CREATE OptTemp TABLE qualified_name PARTITION OF qualified_name
OptTypedTableElementList PartitionBoundSpec OptPartitionSpec
table_access_method_clause OptWith OnCommitOption OptTableSpace
+ YbOptSplit
{
CreateStmt *n = makeNode(CreateStmt);
@@ -3563,11 +3893,24 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')'
n->oncommit = $13;
n->tablespacename = $14;
n->if_not_exists = false;
+
+ n->split_options = $15;
+ if ($15 && $2 == RELPERSISTENCE_TEMP)
+ {
+ ereport(WARNING,
+ (errmsg("split options on TEMP table will be ignored")));
+ }
+ if ($10 && $15)
+ {
+ n->split_options = NULL;
+ ereport(WARNING,
+ (errmsg("split options on a partitioned table will be ignored")));
+ }
$$ = (Node *) n;
}
| CREATE OptTemp TABLE IF_P NOT EXISTS qualified_name PARTITION OF
qualified_name OptTypedTableElementList PartitionBoundSpec OptPartitionSpec
- table_access_method_clause OptWith OnCommitOption OptTableSpace
+ table_access_method_clause OptWith OnCommitOption OptTableSpace YbOptSplit
{
CreateStmt *n = makeNode(CreateStmt);
@@ -3584,6 +3927,19 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')'
n->oncommit = $16;
n->tablespacename = $17;
n->if_not_exists = true;
+
+ n->split_options = $18;
+ if ($18 && $2 == RELPERSISTENCE_TEMP)
+ {
+ ereport(WARNING,
+ (errmsg("split options on TEMP table will be ignored")));
+ }
+ if ($13 && $18)
+ {
+ n->split_options = NULL;
+ ereport(WARNING,
+ (errmsg("split options on a partitioned table will be ignored")));
+ }
$$ = (Node *) n;
}
;
@@ -3755,6 +4111,8 @@ ColConstraint:
| ConstraintAttr { $$ = $1; }
| COLLATE any_name
{
+ if (!YBIsCollationEnabled())
+ parser_ybc_signal_unsupported(@1, "COLLATE", 1127);
/*
* Note: the CollateClause is momentarily included in
* the list built by ColQualList, but we split it out
@@ -3816,6 +4174,13 @@ ColConstraintElem:
}
| PRIMARY KEY opt_definition OptConsTableSpace
{
+ if ($4)
+ {
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("cannot set TABLESPACE for PRIMARY KEY INDEX"),
+ errdetail("The tablespace of the indexed table will be used.")));
+ }
Constraint *n = makeNode(Constraint);
n->contype = CONSTR_PRIMARY;
@@ -3984,7 +4349,11 @@ TableLikeOptionList:
TableLikeOption:
COMMENTS { $$ = CREATE_TABLE_LIKE_COMMENTS; }
- | COMPRESSION { $$ = CREATE_TABLE_LIKE_COMPRESSION; }
+ | COMPRESSION
+ {
+ parser_ybc_signal_unsupported(@1, "LIKE COMPRESSION", 1129);
+ $$ = CREATE_TABLE_LIKE_COMPRESSION;
+ }
| CONSTRAINTS { $$ = CREATE_TABLE_LIKE_CONSTRAINTS; }
| DEFAULTS { $$ = CREATE_TABLE_LIKE_DEFAULTS; }
| IDENTITY_P { $$ = CREATE_TABLE_LIKE_IDENTITY; }
@@ -4043,6 +4412,22 @@ ConstraintElem:
processCASbits($9, @9, "UNIQUE",
&n->deferrable, &n->initdeferred, NULL,
NULL, yyscanner);
+
+ /* YB: Make column list available as index params also */
+ ListCell *lc;
+ foreach(lc, $4)
+ {
+ IndexElem *index_elem = makeNode(IndexElem);
+ index_elem->name = pstrdup(strVal(lfirst(lc)));
+ index_elem->expr = NULL;
+ index_elem->indexcolname = NULL;
+ index_elem->collation = NIL;
+ index_elem->opclass = NIL;
+ index_elem->ordering = SORTBY_DEFAULT;
+ index_elem->nulls_ordering = SORTBY_NULLS_DEFAULT;
+ n->yb_index_params = lappend(n->yb_index_params, index_elem);
+ }
+
$$ = (Node *) n;
}
| UNIQUE ExistingIndex ConstraintAttributeSpec
@@ -4061,21 +4446,40 @@ ConstraintElem:
NULL, yyscanner);
$$ = (Node *) n;
}
- | PRIMARY KEY '(' columnList ')' opt_c_include opt_definition OptConsTableSpace
+ | PRIMARY KEY '(' yb_index_params ')' opt_c_include opt_definition OptConsTableSpace
ConstraintAttributeSpec
{
Constraint *n = makeNode(Constraint);
n->contype = CONSTR_PRIMARY;
n->location = @1;
- n->keys = $4;
+ /*
+ * YB: For Postgres' purpose, make index params available
+ * as a column list also
+ */
+ ListCell *lc;
+ foreach(lc, $4)
+ {
+ IndexElem *index_elem = (IndexElem *)lfirst(lc);
+ n->keys = lappend(n->keys, makeString(index_elem->name));
+ }
n->including = $6;
n->options = $7;
n->indexname = NULL;
+ if ($8)
+ {
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("cannot set TABLESPACE for PRIMARY KEY INDEX"),
+ errdetail("The tablespace of the indexed table will be used.")));
+ }
n->indexspace = $8;
processCASbits($9, @9, "PRIMARY KEY",
&n->deferrable, &n->initdeferred, NULL,
NULL, yyscanner);
+
+ n->yb_index_params = $4;
+
$$ = (Node *) n;
}
| PRIMARY KEY ExistingIndex ConstraintAttributeSpec
@@ -4098,6 +4502,7 @@ ConstraintElem:
opt_c_include opt_definition OptConsTableSpace OptWhereClause
ConstraintAttributeSpec
{
+ parser_ybc_signal_unsupported(@1, "EXCLUDE constraint", 3944);
Constraint *n = makeNode(Constraint);
n->contype = CONSTR_EXCLUSION;
@@ -4137,7 +4542,11 @@ ConstraintElem:
}
;
-opt_no_inherit: NO INHERIT { $$ = true; }
+opt_no_inherit: NO INHERIT
+ {
+ parser_ybc_beta_feature(@1, "inheritance", false);
+ $$ = true;
+ }
| /* EMPTY */ { $$ = false; }
;
@@ -4317,7 +4726,11 @@ key_action:
}
;
-OptInherit: INHERITS '(' qualified_name_list ')' { $$ = $3; }
+OptInherit: INHERITS '(' qualified_name_list ')'
+ {
+ parser_ybc_beta_feature(@1, "inheritance", false);
+ $$ = $3;
+ }
| /*EMPTY*/ { $$ = NIL; }
;
@@ -4395,6 +4808,18 @@ OnCommitOption: ON COMMIT DROP { $$ = ONCOMMIT_DROP; }
| /*EMPTY*/ { $$ = ONCOMMIT_NOOP; }
;
+OptTableGroup:
+ _YB_TABLEGROUP_P name
+ {
+ parser_ybc_beta_feature(@1, "tablegroup", true);
+ $$ = $2;
+ }
+ | /*EMPTY*/
+ {
+ $$ = NULL;
+ }
+ ;
+
OptTableSpace: TABLESPACE name { $$ = $2; }
| /*EMPTY*/ { $$ = NULL; }
;
@@ -4406,6 +4831,47 @@ OptConsTableSpace: USING INDEX TABLESPACE name { $$ = $4; }
ExistingIndex: USING INDEX name { $$ = $3; }
;
+YbOptSplit:
+ _YB_SPLIT_P '(' SplitClause ')'
+ {
+ $$ = $3;
+ }
+ | _YB_SPLIT_P SplitClause
+ {
+ $$ = $2;
+ }
+ | /* EMPTY */
+ {
+ $$ = (YbOptSplit*) NULL;
+ }
+ ;
+
+SplitClause:
+ INTO Iconst _YB_TABLETS_P
+ {
+ $$ = makeNode(YbOptSplit);
+ $$->split_type = NUM_TABLETS;
+ $$->num_tablets = $2;
+ $$->split_points = NULL;
+ }
+ | AT VALUES '(' yb_split_points ')'
+ {
+ $$ = makeNode(YbOptSplit);
+ $$->split_type = SPLIT_POINTS;
+ $$->num_tablets = -1;
+ $$->split_points = $4;
+ }
+ ;
+
+yb_split_points:
+ yb_split_point { $$ = list_make1($1); }
+ | yb_split_points ',' yb_split_point { $$ = lappend($1, $3); }
+ ;
+
+yb_split_point:
+ '(' expr_list ')' { $$ = $2; }
+ ;
+
/*****************************************************************************
*
* QUERY :
@@ -4639,7 +5105,7 @@ OptNoLog: UNLOGGED { $$ = RELPERSISTENCE_UNLOGGED; }
*****************************************************************************/
RefreshMatViewStmt:
- REFRESH MATERIALIZED VIEW opt_concurrently qualified_name opt_with_data
+ REFRESH MATERIALIZED VIEW opt_concurrently_matview qualified_name opt_with_data
{
RefreshMatViewStmt *n = makeNode(RefreshMatViewStmt);
@@ -4650,6 +5116,20 @@ RefreshMatViewStmt:
}
;
+opt_concurrently_matview:
+ CONCURRENTLY
+ {
+ $$ = true;
+ }
+ | _YB_NONCONCURRENTLY_P
+ {
+ $$ = false;
+ }
+ | /*EMPTY*/
+ {
+ $$ = false;
+ }
+ ;
/*****************************************************************************
*
@@ -4738,6 +5218,10 @@ SeqOptElem: AS SimpleTypename
{
$$ = makeDefElem("increment", (Node *) $3, @1);
}
+ | LOGGED
+ {
+ $$ = makeDefElem("logged", NULL, @1);
+ }
| MAXVALUE NumericOnly
{
$$ = makeDefElem("maxvalue", (Node *) $2, @1);
@@ -4760,7 +5244,6 @@ SeqOptElem: AS SimpleTypename
}
| SEQUENCE NAME_P any_name
{
- /* not documented, only used by pg_dump */
$$ = makeDefElem("sequence_name", (Node *) $3, @1);
}
| START opt_with NumericOnly
@@ -4775,6 +5258,10 @@ SeqOptElem: AS SimpleTypename
{
$$ = makeDefElem("restart", (Node *) $3, @1);
}
+ | UNLOGGED
+ {
+ $$ = makeDefElem("unlogged", NULL, @1);
+ }
;
opt_by: BY
@@ -4809,6 +5296,11 @@ NumericOnly_list: NumericOnly { $$ = list_make1($1); }
CreatePLangStmt:
CREATE opt_or_replace opt_trusted opt_procedural LANGUAGE name
{
+ /* YB: Old code structure.
+ * n->replace = $2; (if_not_exists)
+ * n->plname = $6; (extname)
+ */
+
/*
* We now interpret parameterless CREATE LANGUAGE as
* CREATE EXTENSION. "OR REPLACE" is silently translated
@@ -4872,6 +5364,35 @@ opt_procedural:
| /*EMPTY*/
;
+/*****************************************************************************
+ *
+ * QUERY:
+ * CREATE TABLEGROUP tablegroup
+ *
+ * TODO: Later extend this to include INTERLEAVED
+ *
+ *****************************************************************************/
+
+YbCreateTableGroupStmt:
+ CREATE _YB_TABLEGROUP_P name OptTableGroupOwner opt_reloptions OptTableSpace
+ {
+ parser_ybc_not_support_in_templates(@1, "Tablegroup");
+ parser_ybc_beta_feature(@1, "tablegroup", true);
+
+ YbCreateTableGroupStmt *n = makeNode(YbCreateTableGroupStmt);
+ n->tablegroupname = $3;
+ n->owner = $4;
+ n->options = $5;
+ n->tablespacename = $6;
+ n->implicit = false;
+ $$ = (Node *) n;
+ }
+ ;
+
+OptTableGroupOwner: OWNER RoleSpec { $$ = $2; }
+ | /*EMPTY */ { $$ = NULL; }
+ ;
+
/*****************************************************************************
*
* QUERY:
@@ -4879,18 +5400,26 @@ opt_procedural:
*
*****************************************************************************/
-CreateTableSpaceStmt: CREATE TABLESPACE name OptTableSpaceOwner LOCATION Sconst opt_reloptions
+CreateTableSpaceStmt: CREATE TABLESPACE name OptTableSpaceOwner OptTableSpaceLocation opt_reloptions
{
CreateTableSpaceStmt *n = makeNode(CreateTableSpaceStmt);
n->tablespacename = $3;
n->owner = $4;
- n->location = $6;
- n->options = $7;
+ n->options = $6;
+ if (n->options == NULL && $5 == NULL) {
+ parser_yyerror("While creating tablespaces, one of "
+ "LOCATION or WITH options should be present");
+ }
$$ = (Node *) n;
+
}
;
+OptTableSpaceLocation: LOCATION Sconst { parser_ybc_warn_ignored(@1, "LOCATION", 6569); $$ = $2; }
+ | /*EMPTY */ { $$ = NULL; }
+ ;
+
OptTableSpaceOwner: OWNER RoleSpec { $$ = $2; }
| /*EMPTY */ { $$ = NULL; }
;
@@ -4917,7 +5446,76 @@ DropTableSpaceStmt: DROP TABLESPACE name
{
DropTableSpaceStmt *n = makeNode(DropTableSpaceStmt);
- n->tablespacename = $5;
+ n->tablespacename = $5;
+ n->missing_ok = true;
+ $$ = (Node *) n;
+ }
+ ;
+
+/*****************************************************************************
+ *
+ * QUERY:
+ * CREATE PROFILE name LIMIT FAILED_LOGIN_ATTEMPTS <number>
+ *
+ *****************************************************************************/
+
+YbCreateProfileStmt: CREATE _YB_PROFILE_P name LIMIT _YB_FAILED_LOGIN_ATTEMPTS_P Iconst
+ {
+ if (!*YBCGetGFlags()->ysql_enable_profile)
+ parser_ybc_not_support(@1, "PROFILE");
+ YbCreateProfileStmt *n = makeNode(YbCreateProfileStmt);
+
+ n->prfname = $3;
+ if (strcmp(n->prfname, "default") == 0)
+ ereport(ERROR,
+ (errcode(ERRCODE_RESERVED_NAME),
+ errmsg("profile name \"%s\" is reserved",
+ "default"),
+ parser_errposition(@3)));
+
+ n->prffailedloginattempts = makeInteger($6);
+ $$ = (Node *) n;
+ }
+ ;
+
+/*****************************************************************************
+ *
+ * QUERY:
+ * DROP PROFILE [IF EXISTS] name
+ *
+ *****************************************************************************/
+
+YbDropProfileStmt: DROP _YB_PROFILE_P name
+ {
+ if (!*YBCGetGFlags()->ysql_enable_profile)
+ parser_ybc_not_support(@1, "PROFILE");
+ YbDropProfileStmt *n = makeNode(YbDropProfileStmt);
+
+ n->prfname = $3;
+ if (strcmp(n->prfname, "default") == 0)
+ ereport(ERROR,
+ (errcode(ERRCODE_RESERVED_NAME),
+ errmsg("profile name \"%s\" is reserved",
+ "default"),
+ parser_errposition(@3)));
+
+ n->missing_ok = false;
+ $$ = (Node *) n;
+ }
+ | DROP _YB_PROFILE_P IF_P EXISTS name
+ {
+ if (!*YBCGetGFlags()->ysql_enable_profile)
+ parser_ybc_not_support(@1, "PROFILE");
+ YbDropProfileStmt *n = makeNode(YbDropProfileStmt);
+
+ n->prfname = $5;
+ if (strcmp(n->prfname, "default") == 0)
+ ereport(ERROR,
+ (errcode(ERRCODE_RESERVED_NAME),
+ errmsg("profile name \"%s\" is reserved",
+ "default"),
+ parser_errposition(@3)));
+
n->missing_ok = true;
$$ = (Node *) n;
}
@@ -5749,6 +6347,7 @@ CreateTrigStmt:
FOR EACH ROW TriggerWhen
EXECUTE FUNCTION_or_PROCEDURE func_name '(' TriggerFuncArgs ')'
{
+ parser_ybc_signal_unsupported(@1, "CREATE CONSTRAINT TRIGGER", 1709);
CreateTrigStmt *n = makeNode(CreateTrigStmt);
n->replace = $2;
@@ -5819,7 +6418,11 @@ TriggerOneEvent:
;
TriggerReferencing:
- REFERENCING TriggerTransitions { $$ = $2; }
+ REFERENCING TriggerTransitions
+ {
+ parser_ybc_signal_unsupported(@1, "REFERENCING clause (transition tables)", 1668);
+ $$ = $2;
+ }
| /*EMPTY*/ { $$ = NIL; }
;
@@ -6038,6 +6641,7 @@ enable_trigger:
CreateAssertionStmt:
CREATE ASSERTION any_name CHECK '(' a_expr ')' ConstraintAttributeSpec
{
+ parser_ybc_not_support(@1, "CREATE ASSERTION");
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("CREATE ASSERTION is not yet implemented")));
@@ -6181,6 +6785,8 @@ DefineStmt:
}
| CREATE COLLATION any_name definition
{
+ if (!YBIsCollationEnabled())
+ parser_ybc_not_support(@1, "CREATE COLLATION");
DefineStmt *n = makeNode(DefineStmt);
n->kind = OBJECT_COLLATION;
@@ -6191,6 +6797,8 @@ DefineStmt:
}
| CREATE COLLATION IF_P NOT EXISTS any_name definition
{
+ if (!YBIsCollationEnabled())
+ parser_ybc_not_support(@1, "CREATE COLLATION");
DefineStmt *n = makeNode(DefineStmt);
n->kind = OBJECT_COLLATION;
@@ -6202,6 +6810,8 @@ DefineStmt:
}
| CREATE COLLATION any_name FROM any_name
{
+ if (!YBIsCollationEnabled())
+ parser_ybc_not_support(@1, "CREATE COLLATION");
DefineStmt *n = makeNode(DefineStmt);
n->kind = OBJECT_COLLATION;
@@ -6212,6 +6822,8 @@ DefineStmt:
}
| CREATE COLLATION IF_P NOT EXISTS any_name FROM any_name
{
+ if (!YBIsCollationEnabled())
+ parser_ybc_not_support(@1, "CREATE COLLATION");
DefineStmt *n = makeNode(DefineStmt);
n->kind = OBJECT_COLLATION;
@@ -6615,6 +7227,8 @@ DropStmt: DROP object_type_any_name IF_P EXISTS any_name_list opt_drop_behavior
n->removeType = $2;
n->missing_ok = true;
n->objects = $5;
+ if (list_length($5) > 1 && n->removeType != OBJECT_TABLE)
+ parser_ybc_signal_unsupported(@5, "DROP multiple objects", 880);
n->behavior = $6;
n->concurrent = false;
$$ = (Node *) n;
@@ -6626,6 +7240,8 @@ DropStmt: DROP object_type_any_name IF_P EXISTS any_name_list opt_drop_behavior
n->removeType = $2;
n->missing_ok = false;
n->objects = $3;
+ if (list_length($3) > 1 && n->removeType != OBJECT_TABLE)
+ parser_ybc_signal_unsupported(@3, "DROP multiple objects", 880);
n->behavior = $4;
n->concurrent = false;
$$ = (Node *) n;
@@ -6637,6 +7253,8 @@ DropStmt: DROP object_type_any_name IF_P EXISTS any_name_list opt_drop_behavior
n->removeType = $2;
n->missing_ok = true;
n->objects = $5;
+ if (list_length($5) > 1 && n->removeType != OBJECT_TABLE)
+ parser_ybc_signal_unsupported(@5, "DROP multiple objects", 880);
n->behavior = $6;
n->concurrent = false;
$$ = (Node *) n;
@@ -6648,6 +7266,8 @@ DropStmt: DROP object_type_any_name IF_P EXISTS any_name_list opt_drop_behavior
n->removeType = $2;
n->missing_ok = false;
n->objects = $3;
+ if (list_length($3) > 1 && n->removeType != OBJECT_TABLE)
+ parser_ybc_signal_unsupported(@3, "DROP multiple objects", 880);
n->behavior = $4;
n->concurrent = false;
$$ = (Node *) n;
@@ -6720,6 +7340,7 @@ DropStmt: DROP object_type_any_name IF_P EXISTS any_name_list opt_drop_behavior
}
| DROP INDEX CONCURRENTLY any_name_list opt_drop_behavior
{
+ parser_ybc_not_support(@1, "DROP INDEX CONCURRENTLY");
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_INDEX;
@@ -6731,6 +7352,7 @@ DropStmt: DROP object_type_any_name IF_P EXISTS any_name_list opt_drop_behavior
}
| DROP INDEX CONCURRENTLY IF_P EXISTS any_name_list opt_drop_behavior
{
+ parser_ybc_not_support(@1, "DROP INDEX CONCURRENTLY");
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_INDEX;
@@ -6750,8 +7372,13 @@ object_type_any_name:
| MATERIALIZED VIEW { $$ = OBJECT_MATVIEW; }
| INDEX { $$ = OBJECT_INDEX; }
| FOREIGN TABLE { $$ = OBJECT_FOREIGN_TABLE; }
- | COLLATION { $$ = OBJECT_COLLATION; }
- | CONVERSION_P { $$ = OBJECT_CONVERSION; }
+ | COLLATION
+ {
+ if (!YBIsCollationEnabled())
+ parser_ybc_not_support(@1, "DROP COLLATION");
+ $$ = OBJECT_COLLATION;
+ }
+ | CONVERSION_P { parser_ybc_not_support(@1, "DROP CONVERSION"); $$ = OBJECT_CONVERSION; }
| STATISTICS { $$ = OBJECT_STATISTIC_EXT; }
| TEXT_P SEARCH PARSER { $$ = OBJECT_TSPARSER; }
| TEXT_P SEARCH DICTIONARY { $$ = OBJECT_TSDICTIONARY; }
@@ -6782,6 +7409,11 @@ drop_type_name:
| PUBLICATION { $$ = OBJECT_PUBLICATION; }
| SCHEMA { $$ = OBJECT_SCHEMA; }
| SERVER { $$ = OBJECT_FOREIGN_SERVER; }
+ | _YB_TABLEGROUP_P
+ {
+ parser_ybc_beta_feature(@1, "tablegroup", true);
+ $$ = OBJECT_YBTABLEGROUP;
+ }
;
/* object types attached to a table */
@@ -7164,6 +7796,7 @@ FetchStmt: FETCH fetch_args
}
| MOVE fetch_args
{
+ parser_ybc_not_support(@1, "MOVE");
FetchStmt *n = (FetchStmt *) $2;
n->ismove = true;
@@ -7200,6 +7833,7 @@ fetch_args: cursor_name
}
| PRIOR opt_from_in cursor_name
{
+ parser_ybc_signal_unsupported(@1, "FETCH PRIOR", 6514);
FetchStmt *n = makeNode(FetchStmt);
n->portalname = $3;
@@ -7209,6 +7843,7 @@ fetch_args: cursor_name
}
| FIRST_P opt_from_in cursor_name
{
+ parser_ybc_signal_unsupported(@1, "FETCH FIRST", 6514);
FetchStmt *n = makeNode(FetchStmt);
n->portalname = $3;
@@ -7218,6 +7853,7 @@ fetch_args: cursor_name
}
| LAST_P opt_from_in cursor_name
{
+ parser_ybc_signal_unsupported(@1, "FETCH LAST", 6514);
FetchStmt *n = makeNode(FetchStmt);
n->portalname = $3;
@@ -7227,6 +7863,7 @@ fetch_args: cursor_name
}
| ABSOLUTE_P SignedIconst opt_from_in cursor_name
{
+ parser_ybc_signal_unsupported(@1, "FETCH ABSOLUTE", 6514);
FetchStmt *n = makeNode(FetchStmt);
n->portalname = $4;
@@ -7236,6 +7873,7 @@ fetch_args: cursor_name
}
| RELATIVE_P SignedIconst opt_from_in cursor_name
{
+ parser_ybc_signal_unsupported(@1, "FETCH RELATIVE", 6514);
FetchStmt *n = makeNode(FetchStmt);
n->portalname = $4;
@@ -7245,6 +7883,9 @@ fetch_args: cursor_name
}
| SignedIconst opt_from_in cursor_name
{
+ if ($1 < 0) {
+ parser_ybc_signal_unsupported(@1, "FETCH -", 6514);
+ }
FetchStmt *n = makeNode(FetchStmt);
n->portalname = $3;
@@ -7272,6 +7913,9 @@ fetch_args: cursor_name
}
| FORWARD SignedIconst opt_from_in cursor_name
{
+ if ($2 < 0) {
+ parser_ybc_signal_unsupported(@1, "FETCH FORWARD -", 6514);
+ }
FetchStmt *n = makeNode(FetchStmt);
n->portalname = $4;
@@ -7290,6 +7934,7 @@ fetch_args: cursor_name
}
| BACKWARD opt_from_in cursor_name
{
+ parser_ybc_signal_unsupported(@1, "FETCH BACKWARD", 6514);
FetchStmt *n = makeNode(FetchStmt);
n->portalname = $3;
@@ -7299,6 +7944,7 @@ fetch_args: cursor_name
}
| BACKWARD SignedIconst opt_from_in cursor_name
{
+ parser_ybc_signal_unsupported(@1, "FETCH BACKWARD", 6514);
FetchStmt *n = makeNode(FetchStmt);
n->portalname = $4;
@@ -7308,6 +7954,7 @@ fetch_args: cursor_name
}
| BACKWARD ALL opt_from_in cursor_name
{
+ parser_ybc_signal_unsupported(@1, "FETCH BACKWARD", 6514);
FetchStmt *n = makeNode(FetchStmt);
n->portalname = $4;
@@ -7615,6 +8262,14 @@ privilege_target:
n->objs = $2;
$$ = n;
}
+ | _YB_TABLEGROUP_P name_list
+ {
+ PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
+ n->targtype = ACL_TARGET_OBJECT;
+ n->objtype = OBJECT_YBTABLEGROUP;
+ n->objs = $2;
+ $$ = n;
+ }
| TABLESPACE name_list
{
PrivTarget *n = (PrivTarget *) palloc(sizeof(PrivTarget));
@@ -7843,6 +8498,7 @@ defacl_privilege_target:
| FUNCTIONS { $$ = OBJECT_FUNCTION; }
| ROUTINES { $$ = OBJECT_FUNCTION; }
| SEQUENCES { $$ = OBJECT_SEQUENCE; }
+ | _YB_TABLEGROUPS_P { $$ = OBJECT_YBTABLEGROUP; }
| TYPES_P { $$ = OBJECT_TYPE; }
| SCHEMAS { $$ = OBJECT_SCHEMA; }
;
@@ -7852,13 +8508,13 @@ defacl_privilege_target:
*
* QUERY: CREATE INDEX
*
- * Note: we cannot put TABLESPACE clause after WHERE clause unless we are
- * willing to make TABLESPACE a fully reserved word.
+ * Note: we cannot put TABLESPACE / SPLIT clause after WHERE clause
+ * unless we are willing to make them fully reserved words.
*****************************************************************************/
-IndexStmt: CREATE opt_unique INDEX opt_concurrently opt_index_name
- ON relation_expr access_method_clause '(' index_params ')'
- opt_include opt_unique_null_treatment opt_reloptions OptTableSpace where_clause
+IndexStmt: CREATE opt_unique INDEX yb_opt_concurrently_index opt_index_name
+ ON relation_expr access_method_clause '(' yb_index_params ')'
+ opt_include opt_unique_null_treatment opt_reloptions OptTableSpace YbOptSplit where_clause
{
IndexStmt *n = makeNode(IndexStmt);
@@ -7872,7 +8528,8 @@ IndexStmt: CREATE opt_unique INDEX opt_concurrently opt_index_name
n->nulls_not_distinct = !$13;
n->options = $14;
n->tableSpace = $15;
- n->whereClause = $16;
+ n->split_options = $16;
+ n->whereClause = $17;
n->excludeOpNames = NIL;
n->idxcomment = NULL;
n->indexOid = InvalidOid;
@@ -7888,9 +8545,9 @@ IndexStmt: CREATE opt_unique INDEX opt_concurrently opt_index_name
n->reset_default_tblspc = false;
$$ = (Node *) n;
}
- | CREATE opt_unique INDEX opt_concurrently IF_P NOT EXISTS name
- ON relation_expr access_method_clause '(' index_params ')'
- opt_include opt_unique_null_treatment opt_reloptions OptTableSpace where_clause
+ | CREATE opt_unique INDEX yb_opt_concurrently_index IF_P NOT EXISTS name
+ ON relation_expr access_method_clause '(' yb_index_params ')'
+ opt_include opt_unique_null_treatment opt_reloptions OptTableSpace YbOptSplit where_clause
{
IndexStmt *n = makeNode(IndexStmt);
@@ -7904,7 +8561,8 @@ IndexStmt: CREATE opt_unique INDEX opt_concurrently opt_index_name
n->nulls_not_distinct = !$16;
n->options = $17;
n->tableSpace = $18;
- n->whereClause = $19;
+ n->split_options = $19;
+ n->whereClause = $20;
n->excludeOpNames = NIL;
n->idxcomment = NULL;
n->indexOid = InvalidOid;
@@ -7932,6 +8590,25 @@ opt_concurrently:
| /*EMPTY*/ { $$ = false; }
;
+yb_opt_concurrently_index:
+ CONCURRENTLY
+ {
+ parser_ybc_not_support_in_templates(@1, "Concurrent index creation");
+ $$ = YB_CONCURRENCY_EXPLICIT_ENABLED;
+ }
+ | _YB_NONCONCURRENTLY_P
+ {
+ $$ = YB_CONCURRENCY_DISABLED;
+ }
+ | /*EMPTY*/
+ {
+ $$ = (*YBCGetGFlags()->ysql_disable_index_backfill ||
+ YbIsConnectedToTemplateDb())
+ ? YB_CONCURRENCY_DISABLED
+ : YB_CONCURRENCY_IMPLICIT_ENABLED;
+ }
+ ;
+
opt_index_name:
name { $$ = $1; }
| /*EMPTY*/ { $$ = NULL; }
@@ -7939,33 +8616,77 @@ opt_index_name:
access_method_clause:
USING name { $$ = $2; }
- | /*EMPTY*/ { $$ = DEFAULT_INDEX_TYPE; }
+ | /*EMPTY*/ { $$ = IsYugaByteEnabled() ? NULL : DEFAULT_INDEX_TYPE; }
+ ;
+
+yb_opt_alias:
+ AS ColId
+ {
+ if (!IsBinaryUpgrade)
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error at or near \"AS\"")));
+ $$ = $2;
+ }
+ | /* empty */ { $$ = NULL; }
;
-index_params: index_elem { $$ = list_make1($1); }
- | index_params ',' index_elem { $$ = lappend($1, $3); }
+yb_index_params: index_elem
+ {
+ $$ = list_make1($1);
+ }
+ | yb_index_expr_list_hash_elems
+ {
+ $$ = $1;
+ }
+ | yb_index_params ',' index_elem
+ {
+ if ($3->ordering == SORTBY_HASH)
+ {
+ IndexElem *last_elem = (IndexElem *)llast($1);
+ if (last_elem->ordering == SORTBY_HASH)
+ ereport(ERROR,
+ (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+ errmsg("multiple hash columns must be defined as a "
+ "single hash column group"),
+ parser_errposition(@3)));
+ else
+ ereport(ERROR,
+ (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+ errmsg("hash column not allowed after an ASC/DESC column"),
+ parser_errposition(@3)));
+ }
+ $$ = lappend($1, $3);
+ }
+ | yb_index_params ',' yb_index_expr_list_hash_elems
+ {
+ ereport(ERROR,
+ (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+ errmsg("hash column not allowed after an ASC/DESC column"),
+ parser_errposition(@3)));
+ }
;
index_elem_options:
- opt_collate opt_class opt_asc_desc opt_nulls_order
+ opt_collate opt_class opt_yb_index_sort_order opt_nulls_order yb_opt_alias
{
$$ = makeNode(IndexElem);
$$->name = NULL;
$$->expr = NULL;
- $$->indexcolname = NULL;
+ $$->indexcolname = $5;
$$->collation = $1;
$$->opclass = $2;
$$->opclassopts = NIL;
$$->ordering = $3;
$$->nulls_ordering = $4;
}
- | opt_collate any_name reloptions opt_asc_desc opt_nulls_order
+ | opt_collate any_name reloptions opt_yb_index_sort_order opt_nulls_order yb_opt_alias
{
$$ = makeNode(IndexElem);
$$->name = NULL;
$$->expr = NULL;
- $$->indexcolname = NULL;
+ $$->indexcolname = $6;
$$->collation = $1;
$$->opclass = $2;
$$->opclassopts = $3;
@@ -7992,7 +8713,77 @@ index_elem: ColId index_elem_options
| '(' a_expr ')' index_elem_options
{
$$ = $4;
- $$->expr = $2;
+ Node *node = $2;
+ if (node->type == T_ColumnRef) {
+ $$->name = strVal(linitial(((ColumnRef *)node)->fields));
+ $$->expr = NULL;
+ } else {
+ $$->expr = node;
+ }
+ }
+ ;
+
+/*
+ * expr_list index element is not allowed as ASC/DESC key. Always treat it as HASH.
+ */
+opt_yb_hash: yb_hash { $$ = $1; }
+ | /* EMPTY */ { $$ = SORTBY_HASH; }
+ ;
+
+yb_hash_index_expr_with_alias:
+ a_expr AS ColId
+ {
+ if (!IsBinaryUpgrade)
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("syntax error at or near \"AS\"")));
+ $$ = list_make2($1, makeString($3));
+ }
+ | a_expr %prec EXPR_LIST
+ {
+ $$ = list_make2($1, NULL);
+ }
+ ;
+
+
+yb_hash_index_expr_list:
+ yb_hash_index_expr_with_alias
+ {
+ $$ = list_make1($1);
+ }
+ | yb_hash_index_expr_list ',' yb_hash_index_expr_with_alias
+
+ {
+ $$ = lappend($1, $3);
+ }
+ ;
+
+
+yb_index_expr_list_hash_elems: '(' yb_hash_index_expr_list ')' opt_yb_hash
+ {
+ $$ = NULL;
+ ListCell *lc;
+ foreach (lc, $2)
+ {
+ IndexElem *index_elem = makeNode(IndexElem);
+ List *pair = (List *) lfirst(lc);
+ Node *node = (Node *) linitial(pair);
+ char *alias = lsecond(pair) != NULL ?
+ strVal(lsecond(pair)) : NULL;
+ if (node->type == T_ColumnRef) {
+ index_elem->name = strVal(linitial(((ColumnRef *)node)->fields));
+ index_elem->expr = NULL;
+ } else {
+ index_elem->name = NULL;
+ index_elem->expr = copyObject(node);
+ }
+ index_elem->indexcolname = alias;
+ index_elem->collation = NIL;
+ index_elem->opclass = NIL;
+ index_elem->ordering = $4;
+ index_elem->nulls_ordering = SORTBY_NULLS_DEFAULT;
+ $$ = lappend($$, index_elem);
+ }
}
;
@@ -8004,12 +8795,15 @@ index_including_params: index_elem { $$ = list_make1($1); }
| index_including_params ',' index_elem { $$ = lappend($1, $3); }
;
-opt_collate: COLLATE any_name { $$ = $2; }
+opt_collate: COLLATE any_name {
+ if (!YBIsCollationEnabled())
+ parser_ybc_not_support(@1, "CREATE INDEX COLLATE");
+ $$ = $2; }
| /*EMPTY*/ { $$ = NIL; }
;
opt_class: any_name { $$ = $1; }
- | /*EMPTY*/ { $$ = NIL; }
+ | /*EMPTY*/ %prec NO_OPCLASS { $$ = NIL; }
;
opt_asc_desc: ASC { $$ = SORTBY_ASC; }
@@ -8017,11 +8811,121 @@ opt_asc_desc: ASC { $$ = SORTBY_ASC; }
| /*EMPTY*/ { $$ = SORTBY_DEFAULT; }
;
+/*
+ * For YugabyteDB, index column can be hash-distributed also.
+ */
+yb_hash: _YB_HASH_P { $$ = SORTBY_HASH; }
+ ;
+
+opt_yb_index_sort_order: opt_asc_desc { $$ = $1; }
+ | yb_hash { $$ = $1; }
+ ;
+
opt_nulls_order: NULLS_LA FIRST_P { $$ = SORTBY_NULLS_FIRST; }
| NULLS_LA LAST_P { $$ = SORTBY_NULLS_LAST; }
| /*EMPTY*/ { $$ = SORTBY_NULLS_DEFAULT; }
;
+YbBackfillIndexStmt:
+ _YB_BACKFILL_P INDEX oid_list opt_for_bfinstr
+ READ TIME read_time YbRowBounds
+ {
+ parser_ybc_not_support_in_templates(@1, "Index backfill");
+
+ YbBackfillIndexStmt *n = makeNode(YbBackfillIndexStmt);
+ n->oid_list = $3;
+
+ n->bfinfo = makeNode(YbBackfillInfo);
+ n->bfinfo->bfinstr = $4;
+ {
+ char *nptr = $7;
+ char *end;
+ errno = 0;
+ n->bfinfo->read_time = strtou64(nptr, &end, 10);
+ if (!(*nptr != '\0' && *end == '\0')
+ || errno == ERANGE)
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("read time must be uint64"),
+ parser_errposition(@6)));
+ if (!n->bfinfo->read_time)
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("read time must be larger than 0"),
+ parser_errposition(@6)));
+ }
+ n->bfinfo->row_bounds = $8;
+ $$ = (Node *)n;
+ }
+ ;
+
+opt_for_bfinstr:
+ /*EMPTY*/ { $$ = NULL; }
+ | WITH XCONST
+ {
+ /* Strip the leading 'x' */
+ $$ = $2 + 1;
+ }
+ ;
+
+oid_list: Oid
+ {
+ $$ = list_make1_oid($1);
+ }
+ | oid_list ',' Oid
+ {
+ $$ = lappend_oid($1, $3);
+ }
+ ;
+
+read_time:
+ Iconst
+ {
+ $$ = psprintf("%d", $1);
+ }
+ | FCONST
+ {
+ $$ = $1;
+ }
+ ;
+
+YbRowBounds: PARTITION partition_key
+ {
+ $$ = makeNode(YbRowBounds);
+ /* Strip the leading 'x' */
+ $$->partition_key = $2 + 1;
+ $$->row_key_start = NULL;
+ $$->row_key_end = NULL;
+ }
+ | PARTITION partition_key FROM row_key_start
+ {
+ $$ = makeNode(YbRowBounds);
+ /* Strip the leading 'x' */
+ $$->partition_key = $2 + 1;
+ $$->row_key_start = $4 + 1;
+ $$->row_key_end = NULL;
+ }
+ | PARTITION partition_key FROM row_key_start TO row_key_end
+ {
+ $$ = makeNode(YbRowBounds);
+ /* Strip the leading 'x' */
+ $$->partition_key = $2 + 1;
+ $$->row_key_start = $4 + 1;
+ $$->row_key_end = $6 + 1;
+ }
+ ;
+
+partition_key:
+ XCONST { $$ = $1; };
+
+row_key_start:
+ row_key { $$ = $1; };
+
+row_key_end:
+ row_key { $$ = $1; };
+
+row_key: XCONST { $$ = $1; };
+
/*****************************************************************************
*
@@ -8601,6 +9505,7 @@ AlterFunctionStmt:
}
| ALTER PROCEDURE function_with_argtypes alterfunc_opt_list opt_restrict
{
+ parser_ybc_signal_unsupported(@1, "ALTER PROCEDURE", 2717);
AlterFunctionStmt *n = makeNode(AlterFunctionStmt);
n->objtype = OBJECT_PROCEDURE;
@@ -8610,6 +9515,7 @@ AlterFunctionStmt:
}
| ALTER ROUTINE function_with_argtypes alterfunc_opt_list opt_restrict
{
+ parser_ybc_signal_unsupported(@1, "ALTER ROUTINE", 2717);
AlterFunctionStmt *n = makeNode(AlterFunctionStmt);
n->objtype = OBJECT_ROUTINE;
@@ -8914,6 +9820,7 @@ opt_if_exists: IF_P EXISTS { $$ = true; }
CreateTransformStmt: CREATE opt_or_replace TRANSFORM FOR Typename LANGUAGE name '(' transform_element_list ')'
{
+ parser_ybc_not_support(@1, "CREATE TRANSFORM");
CreateTransformStmt *n = makeNode(CreateTransformStmt);
n->replace = $2;
@@ -8946,6 +9853,7 @@ transform_element_list: FROM SQL_P WITH FUNCTION function_with_argtypes ',' TO S
DropTransformStmt: DROP TRANSFORM opt_if_exists FOR Typename LANGUAGE name opt_drop_behavior
{
+ parser_ybc_not_support(@1, "DROP TRANSFORM");
DropStmt *n = makeNode(DropStmt);
n->removeType = OBJECT_TRANSFORM;
@@ -8967,6 +9875,8 @@ DropTransformStmt: DROP TRANSFORM opt_if_exists FOR Typename LANGUAGE name opt_d
ReindexStmt:
REINDEX reindex_target_type opt_concurrently qualified_name
{
+ if (!*YBCGetGFlags()->ysql_enable_reindex)
+ parser_ybc_not_support(@1, "REINDEX");
ReindexStmt *n = makeNode(ReindexStmt);
n->kind = $2;
@@ -8974,12 +9884,23 @@ ReindexStmt:
n->name = NULL;
n->params = NIL;
if ($3)
+ {
+ parser_ybc_not_support(@1, "REINDEX CONCURRENTLY");
n->params = lappend(n->params,
makeDefElem("concurrently", NULL, @3));
+ }
+ /* YB: Only support INDEX target. */
+ if (n->kind != REINDEX_OBJECT_INDEX)
+ {
+ Assert(n->kind == REINDEX_OBJECT_TABLE);
+ parser_ybc_not_support(@2, "REINDEX TABLE");
+ }
+
$$ = (Node *) n;
}
| REINDEX reindex_target_multitable opt_concurrently name
{
+ parser_ybc_not_support(@1, "REINDEX SCHEMA/DATABASE/SYSTEM");
ReindexStmt *n = makeNode(ReindexStmt);
n->kind = $2;
@@ -8993,6 +9914,8 @@ ReindexStmt:
}
| REINDEX '(' utility_option_list ')' reindex_target_type opt_concurrently qualified_name
{
+ if (!*YBCGetGFlags()->ysql_enable_reindex)
+ parser_ybc_not_support(@1, "REINDEX");
ReindexStmt *n = makeNode(ReindexStmt);
n->kind = $5;
@@ -9000,12 +9923,23 @@ ReindexStmt:
n->name = NULL;
n->params = $3;
if ($6)
+ {
+ parser_ybc_not_support(@1, "REINDEX CONCURRENTLY");
n->params = lappend(n->params,
makeDefElem("concurrently", NULL, @6));
+ }
+
+ /* Only support INDEX target. */
+ if (n->kind != REINDEX_OBJECT_INDEX)
+ {
+ Assert(n->kind == REINDEX_OBJECT_TABLE);
+ parser_ybc_not_support(@5, "REINDEX TABLE");
+ }
$$ = (Node *) n;
}
| REINDEX '(' utility_option_list ')' reindex_target_multitable opt_concurrently name
{
+ parser_ybc_not_support(@1, "REINDEX SCHEMA/DATABASE/SYSTEM");
ReindexStmt *n = makeNode(ReindexStmt);
n->kind = $5;
@@ -9037,6 +9971,7 @@ reindex_target_multitable:
AlterTblSpcStmt:
ALTER TABLESPACE name SET reloptions
{
+ parser_ybc_signal_unsupported(@1, "ALTER TABLESPACE", 1153);
AlterTableSpaceOptionsStmt *n =
makeNode(AlterTableSpaceOptionsStmt);
@@ -9047,6 +9982,7 @@ AlterTblSpcStmt:
}
| ALTER TABLESPACE name RESET reloptions
{
+ parser_ybc_signal_unsupported(@1, "ALTER TABLESPACE", 1153);
AlterTableSpaceOptionsStmt *n =
makeNode(AlterTableSpaceOptionsStmt);
@@ -9075,6 +10011,8 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
}
| ALTER COLLATION any_name RENAME TO name
{
+ if (!YBIsCollationEnabled())
+ parser_ybc_not_support(@1, "ALTER COLLATION");
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_COLLATION;
@@ -9085,6 +10023,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
}
| ALTER CONVERSION_P any_name RENAME TO name
{
+ parser_ybc_not_support(@1, "ALTER CONVERSION");
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_CONVERSION;
@@ -9115,6 +10054,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
}
| ALTER DOMAIN_P any_name RENAME CONSTRAINT name TO name
{
+ parser_ybc_not_support(@1, "ALTER DOMAIN RENAME CONSTRAINT");
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_DOMCONSTRAINT;
@@ -9155,6 +10095,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
}
| ALTER opt_procedural LANGUAGE name RENAME TO name
{
+ parser_ybc_not_support(@1, "ALTER LANGUAGE");
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_LANGUAGE;
@@ -9165,6 +10106,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
}
| ALTER OPERATOR CLASS any_name USING name RENAME TO name
{
+ parser_ybc_not_support(@1, "ALTER OPERATOR CLASS");
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_OPCLASS;
@@ -9207,6 +10149,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
}
| ALTER PROCEDURE function_with_argtypes RENAME TO name
{
+ parser_ybc_signal_unsupported(@1, "ALTER PROCEDURE", 2717);
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_PROCEDURE;
@@ -9227,6 +10170,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
}
| ALTER ROUTINE function_with_argtypes RENAME TO name
{
+ parser_ybc_signal_unsupported(@1, "ALTER ROUTINE", 2717);
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_ROUTINE;
@@ -9257,6 +10201,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
}
| ALTER SUBSCRIPTION name RENAME TO name
{
+ parser_ybc_not_support(@1, "ALTER SUBSCRIPTION");
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_SUBSCRIPTION;
@@ -9517,6 +10462,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
}
| ALTER RULE name ON qualified_name RENAME TO name
{
+ parser_ybc_not_support(@1, "ALTER RULE");
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_RULE;
@@ -9566,8 +10512,19 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
n->missing_ok = false;
$$ = (Node *) n;
}
+ | ALTER _YB_TABLEGROUP_P name RENAME TO name
+ {
+ parser_ybc_beta_feature(@1, "tablegroup", true);
+ RenameStmt *n = makeNode(RenameStmt);
+ n->renameType = OBJECT_YBTABLEGROUP;
+ n->subname = $3;
+ n->newname = $6;
+ n->missing_ok = false;
+ $$ = (Node *)n;
+ }
| ALTER TABLESPACE name RENAME TO name
{
+ parser_ybc_not_support(@1, "ALTER TABLESPACE");
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_TABLESPACE;
@@ -9638,6 +10595,7 @@ RenameStmt: ALTER AGGREGATE aggregate_with_argtypes RENAME TO name
}
| ALTER TYPE_P any_name RENAME ATTRIBUTE name TO name opt_drop_behavior
{
+ parser_ybc_signal_unsupported(@1, "ALTER TYPE", 1893);
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_ATTRIBUTE;
@@ -9678,6 +10636,7 @@ AlterObjectDependsStmt:
}
| ALTER PROCEDURE function_with_argtypes opt_no DEPENDS ON EXTENSION name
{
+ parser_ybc_signal_unsupported(@1, "ALTER PROCEDURE DEPENDS ON EXTENSION", 2717);
AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
n->objectType = OBJECT_PROCEDURE;
@@ -9688,6 +10647,7 @@ AlterObjectDependsStmt:
}
| ALTER ROUTINE function_with_argtypes opt_no DEPENDS ON EXTENSION name
{
+ parser_ybc_signal_unsupported(@1, "ALTER ROUTINE DEPENDS ON EXTENSION", 2717);
AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
n->objectType = OBJECT_ROUTINE;
@@ -9698,6 +10658,7 @@ AlterObjectDependsStmt:
}
| ALTER TRIGGER name ON qualified_name opt_no DEPENDS ON EXTENSION name
{
+ parser_ybc_signal_unsupported(@1, "ALTER TRIGGER DEPENDS ON EXTENSION", 1156);
AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
n->objectType = OBJECT_TRIGGER;
@@ -9709,6 +10670,7 @@ AlterObjectDependsStmt:
}
| ALTER MATERIALIZED VIEW qualified_name opt_no DEPENDS ON EXTENSION name
{
+ parser_ybc_signal_unsupported(@1, "ALTER MATERIALIZED VIEW DEPENDS ON EXTENSION", 1131);
AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
n->objectType = OBJECT_MATVIEW;
@@ -9719,6 +10681,7 @@ AlterObjectDependsStmt:
}
| ALTER INDEX qualified_name opt_no DEPENDS ON EXTENSION name
{
+ parser_ybc_signal_unsupported(@1, "ALTER INDEX DEPENDS ON EXTENSION", 1130);
AlterObjectDependsStmt *n = makeNode(AlterObjectDependsStmt);
n->objectType = OBJECT_INDEX;
@@ -9742,6 +10705,7 @@ opt_no: NO { $$ = true; }
AlterObjectSchemaStmt:
ALTER AGGREGATE aggregate_with_argtypes SET SCHEMA name
{
+ parser_ybc_signal_unsupported(@1, "ALTER AGGREGATE SET SCHEMA", 2717);
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_AGGREGATE;
@@ -9752,6 +10716,8 @@ AlterObjectSchemaStmt:
}
| ALTER COLLATION any_name SET SCHEMA name
{
+ if (!YBIsCollationEnabled())
+ parser_ybc_not_support(@1, "ALTER COLLATION SET SCHEMA");
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_COLLATION;
@@ -9762,6 +10728,7 @@ AlterObjectSchemaStmt:
}
| ALTER CONVERSION_P any_name SET SCHEMA name
{
+ parser_ybc_not_support(@1, "ALTER CONVERSION SET SCHEMA");
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_CONVERSION;
@@ -9772,6 +10739,7 @@ AlterObjectSchemaStmt:
}
| ALTER DOMAIN_P any_name SET SCHEMA name
{
+ parser_ybc_not_support(@1, "ALTER DOMAIN SET SCHEMA");
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_DOMAIN;
@@ -9812,6 +10780,7 @@ AlterObjectSchemaStmt:
}
| ALTER OPERATOR CLASS any_name USING name SET SCHEMA name
{
+ parser_ybc_not_support(@1, "ALTER OPERATOR CLASS SET SCHEMA");
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_OPCLASS;
@@ -9832,6 +10801,7 @@ AlterObjectSchemaStmt:
}
| ALTER PROCEDURE function_with_argtypes SET SCHEMA name
{
+ parser_ybc_signal_unsupported(@1, "ALTER PROCEDURE SET SCHEMA", 2717);
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_PROCEDURE;
@@ -9842,6 +10812,7 @@ AlterObjectSchemaStmt:
}
| ALTER ROUTINE function_with_argtypes SET SCHEMA name
{
+ parser_ybc_signal_unsupported(@1, "ALTER ROUTINE SET SCHEMA", 2717);
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_ROUTINE;
@@ -9962,6 +10933,7 @@ AlterObjectSchemaStmt:
}
| ALTER MATERIALIZED VIEW qualified_name SET SCHEMA name
{
+ parser_ybc_signal_unsupported(@1, "ALTER MATERIALIZED VIEW SET SCHEMA", 1131);
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_MATVIEW;
@@ -9972,6 +10944,7 @@ AlterObjectSchemaStmt:
}
| ALTER MATERIALIZED VIEW IF_P EXISTS qualified_name SET SCHEMA name
{
+ parser_ybc_signal_unsupported(@1, "ALTER MATERIALIZED VIEW SET SCHEMA", 1131);
AlterObjectSchemaStmt *n = makeNode(AlterObjectSchemaStmt);
n->objectType = OBJECT_MATVIEW;
@@ -10208,6 +11181,15 @@ AlterOwnerStmt: ALTER AGGREGATE aggregate_with_argtypes OWNER TO RoleSpec
n->newowner = $6;
$$ = (Node *) n;
}
+ | ALTER _YB_TABLEGROUP_P name OWNER TO RoleSpec
+ {
+ parser_ybc_beta_feature(@1, "tablegroup", true);
+ AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
+ n->objectType = OBJECT_YBTABLEGROUP;
+ n->object = (Node *) makeString($3);
+ n->newowner = $6;
+ $$ = (Node *)n;
+ }
| ALTER TABLESPACE name OWNER TO RoleSpec
{
AlterOwnerStmt *n = makeNode(AlterOwnerStmt);
@@ -10362,6 +11344,7 @@ PublicationObjSpec:
}
| TABLES IN_P SCHEMA ColId
{
+ parser_ybc_not_support(@1, "CREATE/ALTER PUBLICATION SCHEMA");
$$ = makeNode(PublicationObjSpec);
$$->pubobjtype = PUBLICATIONOBJ_TABLES_IN_SCHEMA;
$$->name = $4;
@@ -10369,6 +11352,7 @@ PublicationObjSpec:
}
| TABLES IN_P SCHEMA CURRENT_SCHEMA
{
+ parser_ybc_not_support(@1, "CREATE/ALTER PUBLICATION SCHEMA");
$$ = makeNode(PublicationObjSpec);
$$->pubobjtype = PUBLICATIONOBJ_TABLES_IN_CUR_SCHEMA;
$$->location = @4;
@@ -10422,6 +11406,7 @@ PublicationObjSpec:
}
| CURRENT_SCHEMA
{
+ parser_ybc_not_support(@1, "CREATE/ALTER PUBLICATION SCHEMA");
$$ = makeNode(PublicationObjSpec);
$$->pubobjtype = PUBLICATIONOBJ_CONTINUATION;
$$->location = @1;
@@ -10501,6 +11486,7 @@ AlterPublicationStmt:
CreateSubscriptionStmt:
CREATE SUBSCRIPTION name CONNECTION Sconst PUBLICATION name_list opt_definition
{
+ parser_ybc_not_support(@1, "CREATE SUBSCRIPTION");
CreateSubscriptionStmt *n =
makeNode(CreateSubscriptionStmt);
n->subname = $3;
@@ -10520,6 +11506,7 @@ CreateSubscriptionStmt:
AlterSubscriptionStmt:
ALTER SUBSCRIPTION name SET definition
{
+ parser_ybc_not_support(@1, "ALTER SUBSCRIPTION");
AlterSubscriptionStmt *n =
makeNode(AlterSubscriptionStmt);
@@ -10530,6 +11517,7 @@ AlterSubscriptionStmt:
}
| ALTER SUBSCRIPTION name CONNECTION Sconst
{
+ parser_ybc_not_support(@1, "ALTER SUBSCRIPTION");
AlterSubscriptionStmt *n =
makeNode(AlterSubscriptionStmt);
@@ -10540,6 +11528,7 @@ AlterSubscriptionStmt:
}
| ALTER SUBSCRIPTION name REFRESH PUBLICATION opt_definition
{
+ parser_ybc_not_support(@1, "ALTER SUBSCRIPTION");
AlterSubscriptionStmt *n =
makeNode(AlterSubscriptionStmt);
@@ -10550,6 +11539,7 @@ AlterSubscriptionStmt:
}
| ALTER SUBSCRIPTION name ADD_P PUBLICATION name_list opt_definition
{
+ parser_ybc_not_support(@1, "ALTER SUBSCRIPTION");
AlterSubscriptionStmt *n =
makeNode(AlterSubscriptionStmt);
@@ -10561,6 +11551,7 @@ AlterSubscriptionStmt:
}
| ALTER SUBSCRIPTION name DROP PUBLICATION name_list opt_definition
{
+ parser_ybc_not_support(@1, "ALTER SUBSCRIPTION");
AlterSubscriptionStmt *n =
makeNode(AlterSubscriptionStmt);
@@ -10572,6 +11563,7 @@ AlterSubscriptionStmt:
}
| ALTER SUBSCRIPTION name SET PUBLICATION name_list opt_definition
{
+ parser_ybc_not_support(@1, "ALTER SUBSCRIPTION");
AlterSubscriptionStmt *n =
makeNode(AlterSubscriptionStmt);
@@ -10583,6 +11575,7 @@ AlterSubscriptionStmt:
}
| ALTER SUBSCRIPTION name ENABLE_P
{
+ parser_ybc_not_support(@1, "ALTER SUBSCRIPTION");
AlterSubscriptionStmt *n =
makeNode(AlterSubscriptionStmt);
@@ -10594,6 +11587,7 @@ AlterSubscriptionStmt:
}
| ALTER SUBSCRIPTION name DISABLE_P
{
+ parser_ybc_not_support(@1, "ALTER SUBSCRIPTION");
AlterSubscriptionStmt *n =
makeNode(AlterSubscriptionStmt);
@@ -10623,6 +11617,7 @@ AlterSubscriptionStmt:
DropSubscriptionStmt: DROP SUBSCRIPTION name opt_drop_behavior
{
+ parser_ybc_not_support(@1, "DROP SUBSCRIPTION");
DropSubscriptionStmt *n = makeNode(DropSubscriptionStmt);
n->subname = $3;
@@ -10632,6 +11627,7 @@ DropSubscriptionStmt: DROP SUBSCRIPTION name opt_drop_behavior
}
| DROP SUBSCRIPTION IF_P EXISTS name opt_drop_behavior
{
+ parser_ybc_not_support(@1, "DROP SUBSCRIPTION");
DropSubscriptionStmt *n = makeNode(DropSubscriptionStmt);
n->subname = $5;
@@ -10849,6 +11845,7 @@ TransactionStmt:
}
| PREPARE TRANSACTION Sconst
{
+ parser_ybc_signal_unsupported(@1, "PREPARE TRANSACTION", 1125);
TransactionStmt *n = makeNode(TransactionStmt);
n->kind = TRANS_STMT_PREPARE;
@@ -10857,6 +11854,7 @@ TransactionStmt:
}
| COMMIT PREPARED Sconst
{
+ parser_ybc_signal_unsupported(@1, "COMMIT PREPARED", 1125);
TransactionStmt *n = makeNode(TransactionStmt);
n->kind = TRANS_STMT_COMMIT_PREPARED;
@@ -10865,6 +11863,7 @@ TransactionStmt:
}
| ROLLBACK PREPARED Sconst
{
+ parser_ybc_signal_unsupported(@1, "ROLLBACK PREPARED", 1125);
TransactionStmt *n = makeNode(TransactionStmt);
n->kind = TRANS_STMT_ROLLBACK_PREPARED;
@@ -11016,9 +12015,21 @@ ViewStmt: CREATE OptTemp VIEW qualified_name opt_column_list opt_reloptions
;
opt_check_option:
- WITH CHECK OPTION { $$ = CASCADED_CHECK_OPTION; }
- | WITH CASCADED CHECK OPTION { $$ = CASCADED_CHECK_OPTION; }
- | WITH LOCAL CHECK OPTION { $$ = LOCAL_CHECK_OPTION; }
+ WITH CHECK OPTION
+ {
+ parser_ybc_not_support(@1, "VIEW WITH CHECK OPTION");
+ $$ = CASCADED_CHECK_OPTION;
+ }
+ | WITH CASCADED CHECK OPTION
+ {
+ parser_ybc_not_support(@1, "VIEW WITH CASCADED CHECK OPTION");
+ $$ = CASCADED_CHECK_OPTION;
+ }
+ | WITH LOCAL CHECK OPTION
+ {
+ parser_ybc_not_support(@1, "VIEW WITH LOCAL CHECK OPTION");
+ $$ = LOCAL_CHECK_OPTION;
+ }
| /* EMPTY */ { $$ = NO_CHECK_OPTION; }
;
@@ -11031,6 +12042,7 @@ opt_check_option:
LoadStmt: LOAD file_name
{
+ parser_ybc_not_support(@1, "LOAD");
LoadStmt *n = makeNode(LoadStmt);
n->filename = $2;
@@ -11100,6 +12112,17 @@ createdb_opt_name:
| OWNER { $$ = pstrdup($1); }
| TABLESPACE { $$ = pstrdup($1); }
| TEMPLATE { $$ = pstrdup($1); }
+ | _YB_COLOCATED_P
+ {
+ ereport(WARNING,
+ (errcode(ERRCODE_WARNING_DEPRECATED_FEATURE),
+ errmsg("'colocated' syntax is deprecated and will be removed in a future release"),
+ errhint("Use 'colocation' instead of 'colocated'."),
+ parser_errposition(@1)));
+ $$ = pstrdup($1);
+ }
+ | _YB_COLOCATION_P { $$ = pstrdup($1); }
+ | AS OF { $$ = pstrdup("clone_time"); }
;
/*
@@ -11136,6 +12159,9 @@ AlterDatabaseStmt:
}
| ALTER DATABASE name SET TABLESPACE name
{
+ parser_ybc_not_support(@1, "ALTER DATABASE SET TABLESPACE");
+ // TODO(Deepayan): Ensure database shdep on tablespace updates to
+ // new tablespace
AlterDatabaseStmt *n = makeNode(AlterDatabaseStmt);
n->dbname = $3;
@@ -11239,6 +12265,8 @@ drop_option:
AlterCollationStmt: ALTER COLLATION any_name REFRESH VERSION_P
{
+ if (!YBIsCollationEnabled())
+ parser_ybc_not_support(@1, "ALTER COLLATION");
AlterCollationStmt *n = makeNode(AlterCollationStmt);
n->collname = $3;
@@ -11257,6 +12285,7 @@ AlterCollationStmt: ALTER COLLATION any_name REFRESH VERSION_P
AlterSystemStmt:
ALTER SYSTEM_P SET generic_set
{
+ parser_ybc_not_support(@1, "ALTER SYSTEM");
AlterSystemStmt *n = makeNode(AlterSystemStmt);
n->setstmt = $4;
@@ -11264,6 +12293,7 @@ AlterSystemStmt:
}
| ALTER SYSTEM_P RESET generic_reset
{
+ parser_ybc_not_support(@1, "ALTER SYSTEM RESET");
AlterSystemStmt *n = makeNode(AlterSystemStmt);
n->setstmt = $4;
@@ -11305,6 +12335,7 @@ AlterDomainStmt:
/* ALTER DOMAIN <domain> DROP NOT NULL */
| ALTER DOMAIN_P any_name DROP NOT NULL_P
{
+ parser_ybc_not_support(@1, "ALTER DOMAIN DROP NOT NULL");
AlterDomainStmt *n = makeNode(AlterDomainStmt);
n->subtype = 'N';
@@ -11314,6 +12345,7 @@ AlterDomainStmt:
/* ALTER DOMAIN <domain> SET NOT NULL */
| ALTER DOMAIN_P any_name SET NOT NULL_P
{
+ parser_ybc_not_support(@1, "ALTER DOMAIN SET NOT NULL");
AlterDomainStmt *n = makeNode(AlterDomainStmt);
n->subtype = 'O';
@@ -11323,6 +12355,7 @@ AlterDomainStmt:
/* ALTER DOMAIN <domain> ADD CONSTRAINT ... */
| ALTER DOMAIN_P any_name ADD_P TableConstraint
{
+ parser_ybc_not_support(@1, "ALTER DOMAIN ADD CONSTRAINT");
AlterDomainStmt *n = makeNode(AlterDomainStmt);
n->subtype = 'C';
@@ -11333,6 +12366,7 @@ AlterDomainStmt:
/* ALTER DOMAIN <domain> DROP CONSTRAINT <name> [RESTRICT|CASCADE] */
| ALTER DOMAIN_P any_name DROP CONSTRAINT name opt_drop_behavior
{
+ parser_ybc_not_support(@1, "ALTER DOMAIN DROP CONSTRAINT");
AlterDomainStmt *n = makeNode(AlterDomainStmt);
n->subtype = 'X';
@@ -11345,6 +12379,7 @@ AlterDomainStmt:
/* ALTER DOMAIN <domain> DROP CONSTRAINT IF EXISTS <name> [RESTRICT|CASCADE] */
| ALTER DOMAIN_P any_name DROP CONSTRAINT IF_P EXISTS name opt_drop_behavior
{
+ parser_ybc_not_support(@1, "ALTER DOMAIN DROP CONSTRAINT");
AlterDomainStmt *n = makeNode(AlterDomainStmt);
n->subtype = 'X';
@@ -11357,6 +12392,7 @@ AlterDomainStmt:
/* ALTER DOMAIN <domain> VALIDATE CONSTRAINT <name> */
| ALTER DOMAIN_P any_name VALIDATE CONSTRAINT name
{
+ parser_ybc_not_support(@1, "ALTER DOMAIN VALIDATE CONSTRAINT");
AlterDomainStmt *n = makeNode(AlterDomainStmt);
n->subtype = 'V';
@@ -11380,6 +12416,7 @@ opt_as: AS
AlterTSDictionaryStmt:
ALTER TEXT_P SEARCH DICTIONARY any_name definition
{
+ parser_ybc_not_support(@1, "ALTER TEXT SEARCH DICTIONARY");
AlterTSDictionaryStmt *n = makeNode(AlterTSDictionaryStmt);
n->dictname = $5;
@@ -11478,6 +12515,7 @@ CreateConversionStmt:
CREATE opt_default CONVERSION_P any_name FOR Sconst
TO Sconst FROM any_name
{
+ parser_ybc_not_support(@1, "CREATE CONVERSION");
CreateConversionStmt *n = makeNode(CreateConversionStmt);
n->conversion_name = $4;
@@ -11502,6 +12540,7 @@ CreateConversionStmt:
ClusterStmt:
CLUSTER opt_verbose qualified_name cluster_index_specification
{
+ parser_ybc_not_support(@1, "CLUSTER");
ClusterStmt *n = makeNode(ClusterStmt);
n->relation = $3;
@@ -11523,6 +12562,7 @@ ClusterStmt:
}
| CLUSTER opt_verbose
{
+ parser_ybc_not_support(@1, "CLUSTER");
ClusterStmt *n = makeNode(ClusterStmt);
n->relation = NULL;
@@ -11535,6 +12575,7 @@ ClusterStmt:
/* kept for pre-8.3 compatibility */
| CLUSTER opt_verbose name ON qualified_name
{
+ parser_ybc_not_support(@1, "CLUSTER");
ClusterStmt *n = makeNode(ClusterStmt);
n->relation = $5;
@@ -11799,6 +12840,7 @@ ExecuteStmt: EXECUTE name execute_param_clause
| CREATE OptTemp TABLE create_as_target AS
EXECUTE name execute_param_clause opt_with_data
{
+ parser_ybc_not_support(@1, "CREATE TABLE AS EXECUTE");
CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt);
ExecuteStmt *n = makeNode(ExecuteStmt);
@@ -11997,7 +13039,7 @@ opt_on_conflict:
;
opt_conf_expr:
- '(' index_params ')' where_clause
+ '(' yb_index_params ')' where_clause
{
$$ = makeNode(InferClause);
$$->indexElems = $2;
@@ -12072,17 +13114,57 @@ LockStmt: LOCK_P opt_table relation_expr_list opt_lock opt_nowait
;
opt_lock: IN_P lock_type MODE { $$ = $2; }
- | /*EMPTY*/ { $$ = AccessExclusiveLock; }
+ | /*EMPTY*/
+ {
+ if (!*YBCGetGFlags()->enable_object_locking_for_table_locks)
+ parser_ybc_not_support(@0, "ACCESS EXCLUSIVE lock mode");
+ $$ = AccessExclusiveLock;
+ }
;
lock_type: ACCESS SHARE { $$ = AccessShareLock; }
- | ROW SHARE { $$ = RowShareLock; }
- | ROW EXCLUSIVE { $$ = RowExclusiveLock; }
- | SHARE UPDATE EXCLUSIVE { $$ = ShareUpdateExclusiveLock; }
- | SHARE { $$ = ShareLock; }
- | SHARE ROW EXCLUSIVE { $$ = ShareRowExclusiveLock; }
- | EXCLUSIVE { $$ = ExclusiveLock; }
- | ACCESS EXCLUSIVE { $$ = AccessExclusiveLock; }
+ | ROW SHARE
+ {
+ if (!*YBCGetGFlags()->enable_object_locking_for_table_locks)
+ parser_ybc_not_support(@1, "ROW SHARE");
+ $$ = RowShareLock;
+ }
+ | ROW EXCLUSIVE
+ {
+ if (!*YBCGetGFlags()->enable_object_locking_for_table_locks)
+ parser_ybc_not_support(@1, "ROW EXCLUSIVE");
+ $$ = RowExclusiveLock;
+ }
+ | SHARE UPDATE EXCLUSIVE
+ {
+ if (!*YBCGetGFlags()->enable_object_locking_for_table_locks)
+ parser_ybc_not_support(@1, "SHARE UPDATE EXCLUSIVE");
+ $$ = ShareUpdateExclusiveLock;
+ }
+ | SHARE
+ {
+ if (!*YBCGetGFlags()->enable_object_locking_for_table_locks)
+ parser_ybc_not_support(@1, "SHARE");
+ $$ = ShareLock;
+ }
+ | SHARE ROW EXCLUSIVE
+ {
+ if (!*YBCGetGFlags()->enable_object_locking_for_table_locks)
+ parser_ybc_not_support(@1, "SHARE ROW EXCLUSIVE");
+ $$ = ShareRowExclusiveLock;
+ }
+ | EXCLUSIVE
+ {
+ if (!*YBCGetGFlags()->enable_object_locking_for_table_locks)
+ parser_ybc_not_support(@1, "EXCLUSIVE");
+ $$ = ExclusiveLock;
+ }
+ | ACCESS EXCLUSIVE
+ {
+ if (!*YBCGetGFlags()->enable_object_locking_for_table_locks)
+ parser_ybc_not_support(@1, "ACCESS EXCLUSIVE");
+ $$ = AccessExclusiveLock;
+ }
;
opt_nowait: NOWAIT { $$ = true; }
@@ -13681,6 +14763,7 @@ where_or_current_clause:
WHERE a_expr { $$ = $2; }
| WHERE CURRENT_P OF cursor_name
{
+ parser_ybc_signal_unsupported(@1, "WHERE CURRENT OF", 737);
CurrentOfExpr *n = makeNode(CurrentOfExpr);
/* cvarno is filled in by parse analysis */
@@ -15893,7 +16976,7 @@ subquery_Op:
*/
;
-expr_list: a_expr
+expr_list: a_expr %prec EXPR_LIST
{
$$ = list_make1($1);
}
@@ -16421,6 +17504,13 @@ SignedIconst: Iconst { $$ = $1; }
| '-' Iconst { $$ = - $2; }
;
+/*
+ * YB: Iconst does not accept large OID such as 2147500041, use SignedIconst to
+ * convert it to -2147467255 instead. See process_integer_literal and strtoint
+ * for details.
+ */
+Oid: SignedIconst { $$ = $1; };
+
/* Role specifications */
RoleId: RoleSpec
{
@@ -16955,6 +18045,20 @@ unreserved_keyword:
| YEAR_P
| YES_P
| ZONE
+ | _YB_ACCOUNT_P
+ | _YB_BACKFILL_P
+ | _YB_CHANGE_P
+ | _YB_COLOCATED_P
+ | _YB_COLOCATION_P
+ | _YB_FAILED_LOGIN_ATTEMPTS_P
+ | _YB_HASH_P
+ | _YB_NOPROFILE_P
+ | _YB_PROFILE_P
+ | _YB_SPLIT_P
+ | _YB_TABLEGROUP_P
+ | _YB_TABLEGROUPS_P
+ | _YB_TABLETS_P
+ | _YB_UNLOCK_P
;
/* Column identifier --- keywords that can be column, table, etc names.
@@ -17055,6 +18159,7 @@ type_func_name_keyword:
| SIMILAR
| TABLESAMPLE
| VERBOSE
+ | _YB_NONCONCURRENTLY_P
;
/* Reserved keyword --- these keywords are usable only as a ColLabel.
@@ -17574,6 +18679,21 @@ bare_label_keyword:
| XMLTABLE
| YES_P
| ZONE
+ | _YB_ACCOUNT_P
+ | _YB_BACKFILL_P
+ | _YB_CHANGE_P
+ | _YB_COLOCATED_P
+ | _YB_COLOCATION_P
+ | _YB_FAILED_LOGIN_ATTEMPTS_P
+ | _YB_HASH_P
+ | _YB_NONCONCURRENTLY_P
+ | _YB_NOPROFILE_P
+ | _YB_PROFILE_P
+ | _YB_SPLIT_P
+ | _YB_TABLEGROUP_P
+ | _YB_TABLEGROUPS_P
+ | _YB_TABLETS_P
+ | _YB_UNLOCK_P
;
%%
@@ -18447,7 +19567,7 @@ preprocess_pubobj_list(List *pubobjspec_list, core_yyscan_t yyscanner)
if (!pubobj->name && !pubobj->pubtable)
ereport(ERROR,
errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("invalid table name at or near"),
+ errmsg("invalid table name"),
parser_errposition(pubobj->location));
if (pubobj->name)
@@ -18489,7 +19609,7 @@ preprocess_pubobj_list(List *pubobjspec_list, core_yyscan_t yyscanner)
else
ereport(ERROR,
errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("invalid schema name at or near"),
+ errmsg("invalid schema name"),
parser_errposition(pubobj->location));
}
@@ -18566,3 +19686,143 @@ parser_init(base_yy_extra_type *yyext)
{
yyext->parsetree = NIL; /* in case grammar forgets to set it */
}
+
+static int
+errhint_for_not_supported(int issue, const char *extra_hint)
+{
+ if (issue > 0)
+ {
+ errhint("See https://github.com/yugabyte/yugabyte-db/issues/%d. "
+ "React with thumbs up to raise its priority",
+ issue);
+ }
+ else if (issue == -2)
+ {
+ if (extra_hint)
+ {
+ errhint("%s", extra_hint);
+ }
+ }
+ else
+ {
+ errhint("Please report the issue on "
+ "https://github.com/YugaByte/yugabyte-db/issues");
+ }
+ return 0; /* return value does not matter */
+}
+
+/*----------
+ * Signal that a feature is currently unsupported.
+ *
+ * Issue helps explain why:
+ *
+ * issue>0: The feature hasn't been (fully) implemented yet;
+ * GitHub issue # issue tracks this.
+ * issue == -1: Ditto but no GitHub issue has been assigned for this yet
+ * issue == -2: Custom hint message (e.g., the feature is implemented but
+ * is currently turned off at the moment due to a flag)
+ * ----------
+ */
+static void
+raise_feature_not_supported_signal(int pos, core_yyscan_t yyscanner,
+ const char *msg, int issue,
+ const char *extra_hint, int signal_level)
+{
+ ereport(signal_level,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("%s", msg),
+ errhint_for_not_supported(issue, extra_hint),
+ parser_errposition(pos)));
+}
+
+static void
+raise_feature_not_supported(int pos, core_yyscan_t yyscanner, const char *msg,
+ int issue, const char *extra_hint)
+{
+ raise_feature_not_supported_signal(pos, yyscanner, msg, issue, extra_hint,
+ YBUnsupportedFeatureSignalLevel());
+}
+
+static void
+ybc_not_support_signal(int pos, core_yyscan_t yyscanner, const char *msg,
+ int issue, const char *extra_hint, int signal_level)
+{
+ static int use_yb_parser = -1;
+ if (use_yb_parser == -1)
+ {
+ use_yb_parser = YBIsUsingYBParser();
+ }
+
+ if (use_yb_parser)
+ {
+ raise_feature_not_supported_signal(pos, yyscanner, msg, issue,
+ extra_hint, signal_level);
+ }
+}
+
+static void
+ybc_not_support(int pos, core_yyscan_t yyscanner, const char *msg, int issue,
+ const char *extra_hint)
+{
+ ybc_not_support_signal(pos, yyscanner, msg, issue, extra_hint,
+ YBUnsupportedFeatureSignalLevel());
+}
+
+static void
+ybc_not_support_in_templates(int pos, core_yyscan_t yyscanner, const char *msg)
+{
+ static int restricted = -1;
+ if (restricted == -1)
+ {
+ restricted = YBIsUsingYBParser() && YbIsConnectedToTemplateDb();
+ }
+
+ if (restricted && !IsYsqlUpgrade)
+ {
+ raise_feature_not_supported(pos, yyscanner, msg, -1, NULL);
+ }
+}
+
+static bool
+beta_features_enabled()
+{
+ static int beta_enabled = -1;
+ if (beta_enabled == -1)
+ {
+ beta_enabled = YBCIsEnvVarTrueWithDefault("FLAGS_ysql_beta_features", false);
+ }
+ return beta_enabled;
+}
+
+static void
+check_beta_feature(int pos, core_yyscan_t yyscanner, const char *flag, const char *feature)
+{
+ if (YBIsUsingYBParser() && !beta_features_enabled() && !(flag && YBCIsEnvVarTrue(flag)))
+ {
+ const char* general_hint =
+ "Set 'ysql_beta_features' yb-tserver gflag to true to suppress the warning"
+ " for all beta features.";
+
+ ereport(WARNING,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("'%s' is a beta feature!", feature),
+ flag != NULL ?
+ errhint("To suppress this warning, set the '%s' yb-tserver gflag to true.\n(%s)",
+ (flag + 6), general_hint) :
+ errhint("%s", general_hint),
+ parser_errposition(pos)));
+ if (strcmp(feature, "tablegroup") == 0)
+ {
+ ybc_deprecated_feature_warning(pos, yyscanner, feature);
+ }
+ }
+}
+
+static void
+ybc_deprecated_feature_warning(int pos, core_yyscan_t yyscanner, const char *feature)
+{
+ ereport(WARNING,
+ (errcode(ERRCODE_WARNING_DEPRECATED_FEATURE),
+ errmsg("'%s' feature is deprecated and will be removed in a future release", feature),
+ parser_errposition(pos)));
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment