MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / act_create_domain

Function act_create_domain

src/gpre/sql.cpp:1785–1860  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1783//
1784
1785static act* act_create_domain()
1786{
1787 // create request block
1788
1789 gpre_req* request = MSC_request(REQ_ddl);
1790 if (gpreGlob.isc_databases && !gpreGlob.isc_databases->dbb_next)
1791 request->req_database = gpreGlob.isc_databases;
1792 else
1793 PAR_error("Can only CREATE DOMAIN in context of single database");
1794
1795 // create action block
1796
1797 act* action = MSC_action(request, ACT_create_domain);
1798
1799 gpre_fld* field = make_field(0);
1800 MSC_match(KW_AS);
1801 SQL_par_field_dtype(request, field, false);
1802
1803 // Check if default value was specified
1804
1805 if (gpreGlob.token_global.tok_keyword == KW_DEFAULT)
1806 {
1807 field->fld_default_source = CPR_start_text();
1808 PAR_get_token();
1809
1810 if (MSC_match(KW_USER))
1811 field->fld_default_value = MSC_node(nod_user_name, 0);
1812 else if (MSC_match(KW_NULL))
1813 field->fld_default_value = MSC_node(nod_null, 0);
1814 else
1815 {
1816 if (MSC_match(KW_MINUS))
1817 {
1818 if (gpreGlob.token_global.tok_type != tok_number)
1819 CPR_s_error("<number>");
1820
1821 gpre_nod* literal_node = EXP_literal();
1822 field->fld_default_value = MSC_unary(nod_negate, literal_node);
1823 }
1824 else if ((field->fld_default_value = EXP_literal()) == NULL)
1825 CPR_s_error("<constant>");
1826 }
1827 CPR_end_text(field->fld_default_source);
1828 }
1829
1830
1831 // Check for any column level constraints
1832
1833 cnstrt** cnstrt_ptr = &field->fld_constraints;
1834 bool in_constraints = true;
1835
1836 while (in_constraints)
1837 {
1838 switch (gpreGlob.token_global.tok_keyword)
1839 {
1840 case KW_CONSTRAINT:
1841 case KW_CHECK:
1842 case KW_NOT:

Callers 1

act_createFunction · 0.85

Calls 15

MSC_requestFunction · 0.85
MSC_actionFunction · 0.85
make_fieldFunction · 0.85
MSC_matchFunction · 0.85
SQL_par_field_dtypeFunction · 0.85
CPR_start_textFunction · 0.85
PAR_get_tokenFunction · 0.85
MSC_nodeFunction · 0.85
CPR_s_errorFunction · 0.85
EXP_literalFunction · 0.85
MSC_unaryFunction · 0.85
CPR_end_textFunction · 0.85

Tested by

no test coverage detected