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

Function par_field

src/gpre/sql.cpp:5807–5904  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5805//
5806
5807static gpre_fld* par_field( gpre_req* request, gpre_rel* relation)
5808{
5809 gpre_fld* field = make_field(relation);
5810
5811 SQL_par_field_dtype(request, field, false);
5812
5813 if (MSC_match(KW_COMPUTED))
5814 {
5815 if (field->fld_global)
5816 PAR_error("Cannot use domains to override computed column size");
5817 if (field->fld_array_info)
5818 PAR_error("Computed columns cannot be arrays");
5819
5820 par_computed(request, field);
5821 }
5822
5823 // Check if default value was specified
5824
5825 if (gpreGlob.token_global.tok_keyword == KW_DEFAULT)
5826 {
5827 field->fld_default_source = CPR_start_text();
5828 PAR_get_token();
5829
5830 if (MSC_match(KW_USER))
5831 field->fld_default_value = MSC_node(nod_user_name, 0);
5832 // Begin sql/date/time/timestamp
5833 else if (MSC_match(KW_CURRENT_DATE))
5834 field->fld_default_value = MSC_node(nod_current_date, 0);
5835 else if (MSC_match(KW_CURRENT_TIME))
5836 field->fld_default_value = MSC_node(nod_current_time, 0);
5837 else if (MSC_match(KW_CURRENT_TIMESTAMP))
5838 field->fld_default_value = MSC_node(nod_current_timestamp, 0);
5839 // End sql/date/time/timestamp
5840 else if (MSC_match(KW_NULL))
5841 field->fld_default_value = MSC_node(nod_null, 0);
5842 else
5843 {
5844 if (MSC_match(KW_MINUS))
5845 {
5846 if (gpreGlob.token_global.tok_type != tok_number)
5847 CPR_s_error("<number>");
5848
5849 gpre_nod* literal_node = EXP_literal();
5850 field->fld_default_value = MSC_unary(nod_negate, literal_node);
5851 }
5852 else if ((field->fld_default_value = EXP_literal()) == NULL)
5853 CPR_s_error("<constant>");
5854 }
5855 CPR_end_text(field->fld_default_source);
5856 }
5857
5858
5859 // Check for any column level constraints
5860
5861 cnstrt** constraint_ref = &field->fld_constraints;
5862 bool in_constraints = true;
5863
5864 while (in_constraints)

Callers 3

act_alter_tableFunction · 0.70
act_create_tableFunction · 0.70
act_declare_tableFunction · 0.70

Calls 15

make_fieldFunction · 0.85
SQL_par_field_dtypeFunction · 0.85
MSC_matchFunction · 0.85
par_computedFunction · 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
par_field_constraintFunction · 0.85

Tested by

no test coverage detected