break;
case OBJECT_DOMCONSTRAINT:
{
- List *domname;
ObjectAddress domaddr;
char *constrname;
- domname = list_truncate(list_copy(objname), list_length(objname) - 1);
- constrname = strVal(llast(objname));
- domaddr = get_object_address_type(OBJECT_DOMAIN, domname, missing_ok);
+ domaddr = get_object_address_type(OBJECT_DOMAIN, objname, missing_ok);
+ constrname = strVal(linitial(objargs));
address.classId = ConstraintRelationId;
address.objectId = get_domain_constraint_oid(domaddr.objectId,
* Find the ObjectAddress for a type or domain
*/
static ObjectAddress
-get_object_address_type(ObjectType objtype,
- List *objname, bool missing_ok)
+get_object_address_type(ObjectType objtype, List *objname, bool missing_ok)
{
ObjectAddress address;
TypeName *typename;
Type tup;
- typename = makeTypeNameFromNameList(objname);
+ typename = (TypeName *) linitial(objname);
address.classId = TypeRelationId;
address.objectId = InvalidOid;
* given object type. Most use a simple string Values list, but there
* are some exceptions.
*/
- if (type == OBJECT_TYPE || type == OBJECT_DOMAIN)
- {
- Datum *elems;
- bool *nulls;
- int nelems;
- TypeName *typname;
-
- deconstruct_array(namearr, TEXTOID, -1, false, 'i',
- &elems, &nulls, &nelems);
- if (nelems != 1)
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("name list length must be exactly %d", 1)));
- if (nulls[0])
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("name or argument lists may not contain nulls")));
- typname = typeStringToTypeName(TextDatumGetCString(elems[0]));
- name = typname->names;
- }
- else if (type == OBJECT_CAST)
+ if (type == OBJECT_TYPE || type == OBJECT_DOMAIN || type == OBJECT_CAST ||
+ type == OBJECT_DOMCONSTRAINT)
{
Datum *elems;
bool *nulls;
*/
switch (type)
{
- case OBJECT_DOMCONSTRAINT:
- if (list_length(name) < 2)
- ereport(ERROR,
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("name list length must be at least %d", 2)));
- break;
case OBJECT_LARGEOBJECT:
if (list_length(name) != 1)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
- errmsg("name list length must be %d", 1)));
+ errmsg("name list length must be exactly %d", 1)));
break;
+ case OBJECT_DOMCONSTRAINT:
case OBJECT_OPCLASS:
case OBJECT_OPFAMILY:
case OBJECT_CAST:
opt_column_list columnList opt_name_list
sort_clause opt_sort_clause sortby_list index_params
name_list role_list from_clause from_list opt_array_bounds
- qualified_name_list any_name any_name_list
+ qualified_name_list any_name any_name_list type_name_list
any_operator expr_list attrs
target_list opt_target_list insert_column_list set_target_list
set_clause_list set_clause multiple_set_clause
n->concurrent = false;
$$ = (Node *)n;
}
+ | DROP TYPE_P type_name_list opt_drop_behavior
+ {
+ DropStmt *n = makeNode(DropStmt);
+ n->removeType = OBJECT_TYPE;
+ n->missing_ok = FALSE;
+ n->objects = $3;
+ n->behavior = $4;
+ n->concurrent = false;
+ $$ = (Node *) n;
+ }
+ | DROP TYPE_P IF_P EXISTS type_name_list opt_drop_behavior
+ {
+ DropStmt *n = makeNode(DropStmt);
+ n->removeType = OBJECT_TYPE;
+ n->missing_ok = TRUE;
+ n->objects = $5;
+ n->behavior = $6;
+ n->concurrent = false;
+ $$ = (Node *) n;
+ }
+ | DROP DOMAIN_P type_name_list opt_drop_behavior
+ {
+ DropStmt *n = makeNode(DropStmt);
+ n->removeType = OBJECT_DOMAIN;
+ n->missing_ok = FALSE;
+ n->objects = $3;
+ n->behavior = $4;
+ n->concurrent = false;
+ $$ = (Node *) n;
+ }
+ | DROP DOMAIN_P IF_P EXISTS type_name_list opt_drop_behavior
+ {
+ DropStmt *n = makeNode(DropStmt);
+ n->removeType = OBJECT_DOMAIN;
+ n->missing_ok = TRUE;
+ n->objects = $5;
+ n->behavior = $6;
+ n->concurrent = false;
+ $$ = (Node *) n;
+ }
| DROP INDEX CONCURRENTLY any_name_list opt_drop_behavior
{
DropStmt *n = makeNode(DropStmt);
| INDEX { $$ = OBJECT_INDEX; }
| FOREIGN TABLE { $$ = OBJECT_FOREIGN_TABLE; }
| EVENT TRIGGER { $$ = OBJECT_EVENT_TRIGGER; }
- | TYPE_P { $$ = OBJECT_TYPE; }
- | DOMAIN_P { $$ = OBJECT_DOMAIN; }
| COLLATION { $$ = OBJECT_COLLATION; }
| CONVERSION_P { $$ = OBJECT_CONVERSION; }
| SCHEMA { $$ = OBJECT_SCHEMA; }
{ $$ = lappend($1, makeString($3)); }
;
+type_name_list:
+ Typename { $$ = list_make1(list_make1($1)); }
+ | type_name_list ',' Typename { $$ = lappend($1, list_make1($3)); }
/*****************************************************************************
*
n->comment = $6;
$$ = (Node *) n;
}
+ | COMMENT ON TYPE_P Typename IS comment_text
+ {
+ CommentStmt *n = makeNode(CommentStmt);
+ n->objtype = OBJECT_TYPE;
+ n->objname = list_make1($4);
+ n->objargs = NIL;
+ n->comment = $6;
+ $$ = (Node *) n;
+ }
+ | COMMENT ON DOMAIN_P Typename IS comment_text
+ {
+ CommentStmt *n = makeNode(CommentStmt);
+ n->objtype = OBJECT_DOMAIN;
+ n->objname = list_make1($4);
+ n->objargs = NIL;
+ n->comment = $6;
+ $$ = (Node *) n;
+ }
| COMMENT ON AGGREGATE func_name aggr_args IS comment_text
{
CommentStmt *n = makeNode(CommentStmt);
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_DOMCONSTRAINT;
- n->objname = lappend($7, makeString($4));
- n->objargs = NIL;
+ /*
+ * should use Typename not any_name in the production, but
+ * there's a shift/reduce conflict if we do that, so fix it
+ * up here.
+ */
+ n->objname = list_make1(makeTypeNameFromNameList($7));
+ n->objargs = list_make1(makeString($4));
n->comment = $9;
$$ = (Node *) n;
}
| INDEX { $$ = OBJECT_INDEX; }
| SEQUENCE { $$ = OBJECT_SEQUENCE; }
| TABLE { $$ = OBJECT_TABLE; }
- | DOMAIN_P { $$ = OBJECT_DOMAIN; }
- | TYPE_P { $$ = OBJECT_TYPE; }
| VIEW { $$ = OBJECT_VIEW; }
| MATERIALIZED VIEW { $$ = OBJECT_MATVIEW; }
| COLLATION { $$ = OBJECT_COLLATION; }
n->label = $8;
$$ = (Node *) n;
}
+ | SECURITY LABEL opt_provider ON TYPE_P Typename
+ IS security_label
+ {
+ SecLabelStmt *n = makeNode(SecLabelStmt);
+ n->provider = $3;
+ n->objtype = OBJECT_TYPE;
+ n->objname = list_make1($6);
+ n->objargs = NIL;
+ n->label = $8;
+ $$ = (Node *) n;
+ }
+ | SECURITY LABEL opt_provider ON DOMAIN_P Typename
+ IS security_label
+ {
+ SecLabelStmt *n = makeNode(SecLabelStmt);
+ n->provider = $3;
+ n->objtype = OBJECT_TYPE;
+ n->objname = list_make1($6);
+ n->objargs = NIL;
+ n->label = $8;
+ $$ = (Node *) n;
+ }
| SECURITY LABEL opt_provider ON AGGREGATE func_name aggr_args
IS security_label
{
| SCHEMA { $$ = OBJECT_SCHEMA; }
| SEQUENCE { $$ = OBJECT_SEQUENCE; }
| TABLE { $$ = OBJECT_TABLE; }
- | DOMAIN_P { $$ = OBJECT_TYPE; }
| ROLE { $$ = OBJECT_ROLE; }
| TABLESPACE { $$ = OBJECT_TABLESPACE; }
- | TYPE_P { $$ = OBJECT_TYPE; }
| VIEW { $$ = OBJECT_VIEW; }
| MATERIALIZED VIEW { $$ = OBJECT_MATVIEW; }
;
('cast', '{int8}', '{int4}'),
('collation', '{default}', '{}'),
('table constraint', '{addr_nsp, gentable, a_chk}', '{}'),
- ('domain constraint', '{addr_nsp, gendomain, domconstr}', '{}'),
+ ('domain constraint', '{addr_nsp.gendomain}', '{domconstr}'),
('conversion', '{pg_catalog, ascii_to_mic}', '{}'),
('default value', '{addr_nsp, gentable, b}', '{}'),
('language', '{plpgsql}', '{}'),