MySQL 8.4.6
Source Code Documentation
parse_tree_column_attrs.h
Go to the documentation of this file.
1/* Copyright (c) 2016, 2025, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef PARSE_TREE_COL_ATTRS_INCLUDED
25#define PARSE_TREE_COL_ATTRS_INCLUDED
26
27#include <assert.h>
28#include <sys/types.h> // ulong, uint. TODO: replace with cstdint
29
30#include <optional>
31#include <type_traits>
32#include <vector>
33
34#include "field_types.h"
35#include "lex_string.h"
36#include "my_alloc.h"
37#include "my_base.h"
38#include "my_compiler.h"
39
40#include "my_inttypes.h"
41#include "my_sys.h"
43#include "mysql_com.h"
44#include "mysqld_error.h"
45#include "sql/derror.h"
46#include "sql/field.h"
47#include "sql/gis/srid.h"
48#include "sql/item.h"
49#include "sql/item_timefunc.h"
50#include "sql/mem_root_array.h"
51#include "sql/parse_location.h"
52#include "sql/parse_tree_helpers.h" // move_cf_appliers
54#include "sql/parser_yystype.h"
55#include "sql/sql_alter.h"
56#include "sql/sql_check_constraint.h" // Sql_check_constraint_spec
57#include "sql/sql_class.h"
58#include "sql/sql_error.h"
59#include "sql/sql_lex.h"
60#include "sql/sql_list.h"
61#include "sql/sql_parse.h"
63
64class String;
65
66/**
67 Parse context for column type attribute specific parse tree nodes.
68
69 For internal use in the contextualization code.
70
71 @ingroup ptn_column_attrs ptn_gcol_attrs
72*/
74 const bool is_generated; ///< Owner column is a generated one.
75 std::vector<CreateFieldApplier> cf_appliers;
76 Column_parse_context(THD *thd_arg, Query_block *select_arg, bool is_generated)
77 : Parse_context(thd_arg, select_arg), is_generated(is_generated) {}
78};
79
80/**
81 Base class for all column attributes in @SQL{CREATE/ALTER TABLE}
82
83 @ingroup ptn_column_attrs ptn_gcol_attrs
84*/
85class PT_column_attr_base : public Parse_tree_node_tmpl<Column_parse_context> {
86 protected:
87 explicit PT_column_attr_base(const POS &pos)
89
90 public:
91 enum Attr_type {
111 };
112
114
115 virtual void apply_type_flags(ulong *) const {}
116 virtual void apply_alter_info_flags(ulonglong *) const {}
117 virtual void apply_comment(LEX_CSTRING *) const {}
118 virtual void apply_default_value(Item **) const {}
120 virtual void apply_on_update_value(Item **) const {}
121 virtual void apply_srid_modifier(std::optional<gis::srid_t> *) const {}
123 const CHARSET_INFO **to [[maybe_unused]],
124 bool *has_explicit_collation
125 [[maybe_unused]]) const {
126 return false;
127 }
129 Sql_check_constraint_spec_list *check_const_list [[maybe_unused]]) {
130 return false;
131 }
132 virtual Attr_type attr_type() const { return AT_NONE; }
133
134 /**
135 Check for the [NOT] ENFORCED characteristic.
136
137 @returns true if the [NOT] ENFORCED follows the CHECK(...) clause,
138 false otherwise.
139 */
140 virtual bool has_constraint_enforcement() const { return false; }
141
142 /**
143 Check if constraint is enforced.
144 Method must be called only when has_constraint_enforcement() is true (i.e
145 when [NOT] ENFORCED follows the CHECK(...) clause).
146
147 @returns true if constraint is enforced.
148 false otherwise.
149 */
150 virtual bool is_constraint_enforced() const { return false; }
151
152 /**
153 Update the ENFORCED/NOT ENFORCED state of the CHECK constraint.
154
155 @param enforced true if ENFORCED, false if NOT ENFORCED.
156
157 @returns false if success, true if error (e.g. if [NOT] ENFORCED follows
158 something other than the CHECK clause.)
159 */
160 virtual bool set_constraint_enforcement(bool enforced [[maybe_unused]]) {
161 return true; // error
162 }
163};
164
165/**
166 Node for the @SQL{NULL} column attribute
167
168 @ingroup ptn_column_attrs
169*/
171 public:
172 explicit PT_null_column_attr(const POS &pos) : PT_column_attr_base(pos) {}
173 void apply_type_flags(ulong *type_flags) const override {
174 *type_flags &= ~NOT_NULL_FLAG;
175 *type_flags |= EXPLICIT_NULL_FLAG;
176 }
177
178 enum Attr_type attr_type() const override { return AT_NULL_COLUMN_ATTR; }
179};
180
181/**
182 Node for the @SQL{NOT NULL} column attribute
183
184 @ingroup ptn_column_attrs
185*/
187 public:
188 explicit PT_not_null_column_attr(const POS &pos) : PT_column_attr_base(pos) {}
189 void apply_type_flags(ulong *type_flags) const override {
190 *type_flags |= NOT_NULL_FLAG;
191 }
192
193 enum Attr_type attr_type() const override { return AT_NOT_NULL_COLUMN_ATTR; }
194};
195
196/**
197 Node for the @SQL{NOT SECONDARY} column attribute
198
199 @ingroup ptn_column_attrs
200*/
202 public:
203 explicit PT_secondary_column_attr(const POS &pos)
204 : PT_column_attr_base(pos) {}
205 void apply_type_flags(unsigned long *type_flags) const override {
206 *type_flags |= NOT_SECONDARY_FLAG;
207 }
208
209 enum Attr_type attr_type() const override { return AT_SECONDARY_COLUMN_ATTR; }
210};
211
212/**
213 Node for the @SQL{UNIQUE [KEY]} column attribute
214
215 @ingroup ptn_column_attrs
216*/
218 public:
219 explicit PT_unique_key_column_attr(const POS &pos)
220 : PT_column_attr_base(pos) {}
221
222 void apply_type_flags(ulong *type_flags) const override {
223 *type_flags |= UNIQUE_FLAG;
224 }
225
226 void apply_alter_info_flags(ulonglong *flags) const override {
228 }
229
230 enum Attr_type attr_type() const override {
232 }
233};
234
235/**
236 Node for the @SQL{PRIMARY [KEY]} column attribute
237
238 @ingroup ptn_column_attrs
239*/
241 public:
242 explicit PT_primary_key_column_attr(const POS &pos)
243 : PT_column_attr_base(pos) {}
244
245 void apply_type_flags(ulong *type_flags) const override {
246 *type_flags |= PRI_KEY_FLAG | NOT_NULL_FLAG;
247 }
248
249 void apply_alter_info_flags(ulonglong *flags) const override {
251 }
252
253 enum Attr_type attr_type() const override {
255 }
256};
257
258/**
259 Node for the @SQL{[CONSTRAINT [symbol]] CHECK '(' expr ')'} column attribute.
260
261 @ingroup ptn_column_attrs
262*/
266
267 public:
269 Item *expr)
270 : super(pos) {
272 col_cc_spec.check_expr = expr;
273 }
274
275 bool set_constraint_enforcement(bool enforced) override {
276 col_cc_spec.is_enforced = enforced;
277 return false;
278 }
279
280 void apply_alter_info_flags(ulonglong *flags) const override {
282 }
283
285 Sql_check_constraint_spec_list *check_const_list) override {
286 assert(check_const_list != nullptr);
287 return (check_const_list->push_back(&col_cc_spec));
288 }
289
291 return (super::do_contextualize(pc) ||
293 }
294
295 enum Attr_type attr_type() const override {
297 }
298};
299
300/**
301 Node for the @SQL{[NOT] ENFORCED} column attribute.
302
303 @ingroup ptn_column_attrs
304*/
306 public:
307 explicit PT_constraint_enforcement_attr(const POS &pos, bool enforced)
308 : PT_column_attr_base(pos), m_enforced(enforced) {}
309
310 bool has_constraint_enforcement() const override { return true; }
311
312 bool is_constraint_enforced() const override { return m_enforced; }
313
314 enum Attr_type attr_type() const override {
316 }
317
318 private:
319 const bool m_enforced;
320};
321
322/**
323 Node for the @SQL{COMMENT @<comment@>} column attribute
324
325 @ingroup ptn_column_attrs
326*/
329
330 public:
331 explicit PT_comment_column_attr(const POS &pos, const LEX_CSTRING &comment)
333
334 void apply_comment(LEX_CSTRING *to) const override { *to = comment; }
335
336 enum Attr_type attr_type() const override { return AT_COMMENT_COLUMN_ATTR; }
337};
338
339/**
340 Node for the @SQL{COLLATE @<collation@>} column attribute
341
342 @ingroup ptn_column_attrs
343*/
345 public:
348 assert(m_collation != nullptr);
349 }
350
352 bool *has_explicit_collation) const override {
353 if (*has_explicit_collation) {
354 pc->thd->syntax_error_at(m_pos, ER_INVALID_MULTIPLE_CLAUSES, "COLLATE");
355 return true;
356 }
357 *has_explicit_collation = true;
359 }
360
361 enum Attr_type attr_type() const override { return AT_COLLATE_COLUMN_ATTR; }
362
363 private:
365};
366
367// Specific to non-generated columns only:
368
369/**
370 Node for the @SQL{DEFAULT @<expression@>} column attribute
371
372 @ingroup ptn_not_gcol_attr
373*/
376
378
379 public:
380 explicit PT_default_column_attr(const POS &pos, Item *item)
381 : super(pos), item(item) {}
382 void apply_default_value(Item **value) const override { *value = item; }
384 if (pc->is_generated) {
385 my_error(ER_WRONG_USAGE, MYF(0), "DEFAULT", "generated column");
386 return true;
387 }
388 return super::do_contextualize(pc) || item->itemize(pc, &item);
389 }
390 void apply_type_flags(ulong *type_flags) const override {
391 if (item->type() == Item::NULL_ITEM) *type_flags |= EXPLICIT_NULL_FLAG;
392 }
393
394 enum Attr_type attr_type() const override { return AT_DEFAULT_COLUMN_ATTR; }
395};
396
397/**
398 Node for the @SQL{UPDATE NOW[([@<precision@>])]} column attribute
399
400 @ingroup ptn_not_gcol_attr
401*/
404
406 Item *item = nullptr;
407
408 public:
410 : super(pos), precision(precision) {}
411 void apply_on_update_value(Item **value) const override { *value = item; }
412
414 if (pc->is_generated) {
415 my_error(ER_WRONG_USAGE, MYF(0), "ON UPDATE", "generated column");
416 return true;
417 }
418 if (super::do_contextualize(pc)) return true;
419
421 return item == nullptr;
422 }
423
424 enum Attr_type attr_type() const override { return AT_ON_UPDATE_COLUMN_ATTR; }
425};
426
427/**
428 Node for the @SQL{AUTO_INCREMENT} column attribute
429
430 @ingroup ptn_not_gcol_attr
431*/
434
435 public:
437 : PT_column_attr_base(pos) {}
438
439 void apply_type_flags(ulong *type_flags) const override {
440 *type_flags |= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG;
441 }
443 if (pc->is_generated) {
444 my_error(ER_WRONG_USAGE, MYF(0), "AUTO_INCREMENT", "generated column");
445 return true;
446 }
447 return super::do_contextualize(pc);
448 }
449
450 enum Attr_type attr_type() const override {
452 }
453};
454
455/**
456 Node for the @SQL{SERIAL DEFAULT VALUE} column attribute
457
458 @ingroup ptn_not_gcol_attr
459*/
462
463 public:
464 explicit PT_serial_default_value_column_attr(const POS &pos) : super(pos) {}
465
466 void apply_type_flags(ulong *type_flags) const override {
468 }
469 void apply_alter_info_flags(ulonglong *flags) const override {
471 }
473 if (pc->is_generated) {
474 my_error(ER_WRONG_USAGE, MYF(0), "SERIAL DEFAULT VALUE",
475 "generated column");
476 return true;
477 }
478 return super::do_contextualize(pc);
479 }
480 enum Attr_type attr_type() const override {
482 }
483};
484
485/**
486 Node for the @SQL{COLUMN_FORMAT @<DEFAULT|FIXED|DYNAMIC@>} column attribute
487
488 @ingroup ptn_not_gcol_attr
489*/
492
494
495 public:
498 : super(pos), format(format) {}
499
500 void apply_type_flags(ulong *type_flags) const override {
501 *type_flags &= ~(FIELD_FLAGS_COLUMN_FORMAT_MASK);
502 *type_flags |= format << FIELD_FLAGS_COLUMN_FORMAT;
503 }
505 if (pc->is_generated) {
506 my_error(ER_WRONG_USAGE, MYF(0), "COLUMN_FORMAT", "generated column");
507 return true;
508 }
509 return super::do_contextualize(pc);
510 }
511 enum Attr_type attr_type() const override {
513 }
514};
515
516/**
517 Node for the @SQL{STORAGE @<DEFAULT|DISK|MEMORY@>} column attribute
518
519 @ingroup ptn_not_gcol_attr
520*/
523
525
526 public:
528 : super(pos), media(media) {}
529
530 void apply_type_flags(ulong *type_flags) const override {
531 *type_flags &= ~(FIELD_FLAGS_STORAGE_MEDIA_MASK);
532 *type_flags |= media << FIELD_FLAGS_STORAGE_MEDIA;
533 }
535 if (pc->is_generated) {
536 my_error(ER_WRONG_USAGE, MYF(0), "STORAGE", "generated column");
537 return true;
538 }
539 return super::do_contextualize(pc);
540 }
541 enum Attr_type attr_type() const override {
543 }
544};
545
546/// Node for the SRID column attribute
549
551
552 public:
553 explicit PT_srid_column_attr(const POS &pos, gis::srid_t srid)
554 : super(pos), m_srid(srid) {}
555
556 void apply_srid_modifier(std::optional<gis::srid_t> *srid) const override {
557 *srid = m_srid;
558 }
559
560 enum Attr_type attr_type() const override { return AT_SRID_COLUMN_ATTR; }
561};
562
563/// Node for the generated default value, column attribute
566
567 public:
569 : super(pos) {
572 }
573
575 Value_generator **default_value_expression) override {
576 *default_value_expression = &m_default_value_expression;
577 }
578
580 // GC and default value expressions are mutually exclusive and thus only
581 // one is allowed to be present on the same column definition.
582 if (pc->is_generated) {
583 my_error(ER_WRONG_USAGE, MYF(0), "DEFAULT", "generated column");
584 return true;
585 }
586 Parse_context expr_pc(pc->thd, pc->select);
587 return super::do_contextualize(pc) ||
590 }
591
592 enum Attr_type attr_type() const override {
594 }
595
596 private:
598};
599
600/**
601 Node for the @SQL{VISIBLE|INVISIBLE} column attribute
602
603 @ingroup ptn_column_attrs
604*/
607
608 public:
609 explicit PT_column_visibility_attr(const POS &pos, bool is_visible)
610 : super(pos), m_is_visible(is_visible) {}
611 void apply_type_flags(unsigned long *type_flags) const override {
612 *type_flags &= ~FIELD_IS_INVISIBLE;
613 if (!m_is_visible) *type_flags |= FIELD_IS_INVISIBLE;
614 }
615
616 enum Attr_type attr_type() const override {
618 }
619
620 private:
621 const bool m_is_visible;
622};
623
624// Type nodes:
625
626/**
627 Base class for all column type nodes
628
629 @ingroup ptn_column_types
630*/
631class PT_type : public Parse_tree_node {
632 public:
634
635 protected:
636 explicit PT_type(const POS &pos, enum_field_types type)
637 : Parse_tree_node(pos), type(type) {}
638
639 public:
640 virtual ulong get_type_flags() const { return 0; }
641 virtual const char *get_length() const { return nullptr; }
642 virtual const char *get_dec() const { return nullptr; }
643 virtual const CHARSET_INFO *get_charset() const { return nullptr; }
644 virtual uint get_uint_geom_type() const { return 0; }
645 virtual List<String> *get_interval_list() const { return nullptr; }
646 virtual bool is_serial_type() const { return false; }
647};
648
649/**
650 Node for numeric types
651
652 Type list:
653 * NUMERIC, REAL, DOUBLE, DECIMAL and FIXED,
654 * INTEGER, INT, INT1, INT2, INT3, INT4, TINYINT, SMALLINT, MEDIUMINT and
655 BIGINT.
656
657 @ingroup ptn_column_types
658*/
659class PT_numeric_type : public PT_type {
660 const char *length;
661 const char *dec;
662 ulong options;
663
664 using Parent_type = std::remove_const<decltype(PT_type::type)>::type;
665
666 public:
667 PT_numeric_type(const POS &pos, THD *thd, Numeric_type type_arg,
668 const char *length, const char *dec, ulong options)
669 : PT_type(pos, static_cast<Parent_type>(type_arg)),
670 length(length),
671 dec(dec),
673 assert((options & ~(UNSIGNED_FLAG | ZEROFILL_FLAG)) == 0);
674
675 if (type_arg != Numeric_type::DECIMAL && dec != nullptr) {
677 ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT,
678 ER_THD(thd, ER_WARN_DEPRECATED_FLOAT_DIGITS));
679 }
680 if (options & UNSIGNED_FLAG) {
682 ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT,
683 ER_THD(thd, ER_WARN_DEPRECATED_FLOAT_UNSIGNED));
684 }
685 }
686 PT_numeric_type(const POS &pos, THD *thd, Int_type type_arg,
687 const char *length, ulong options)
688 : PT_type(pos, static_cast<enum_field_types>(type_arg)),
689 length(length),
690 dec(nullptr),
692 assert((options & ~(UNSIGNED_FLAG | ZEROFILL_FLAG)) == 0);
693
694 if (length != nullptr) {
696 ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT,
697 ER_THD(thd, ER_WARN_DEPRECATED_INTEGER_DISPLAY_WIDTH));
698 }
699 }
700
701 ulong get_type_flags() const override {
703 }
704 const char *get_length() const override { return length; }
705 const char *get_dec() const override { return dec; }
706};
707
708/**
709 Node for the BIT type
710
711 @ingroup ptn_column_types
712*/
713class PT_bit_type : public PT_type {
714 const char *length;
715
716 public:
717 explicit PT_bit_type(const POS &pos)
718 : PT_type(pos, MYSQL_TYPE_BIT), length("1") {}
719 explicit PT_bit_type(const POS &pos, const char *length)
721
722 const char *get_length() const override { return length; }
723};
724
725/**
726 Node for the BOOL/BOOLEAN type
727
728 @ingroup ptn_column_types
729*/
730class PT_boolean_type : public PT_type {
731 public:
732 explicit PT_boolean_type(const POS &pos) : PT_type(pos, MYSQL_TYPE_TINY) {}
733 const char *get_length() const override { return "1"; }
734};
735
736enum class Char_type : ulong {
740};
741
742class PT_char_type : public PT_type {
743 const char *length;
745 const bool force_binary;
746
747 using Parent_type = std::remove_const<decltype(PT_type::type)>::type;
748
749 public:
750 PT_char_type(const POS &pos, Char_type char_type, const char *length,
751 const CHARSET_INFO *charset, bool force_binary = false)
752 : PT_type(pos, static_cast<Parent_type>(char_type)),
753 length(length),
756 assert(charset == nullptr || !force_binary);
757 }
758 PT_char_type(const POS &pos, Char_type char_type, const CHARSET_INFO *charset,
759 bool force_binary = false)
760 : PT_char_type(pos, char_type, "1", charset, force_binary) {}
761 ulong get_type_flags() const override {
762 return force_binary ? BINCMP_FLAG : 0;
763 }
764 const char *get_length() const override { return length; }
765 const CHARSET_INFO *get_charset() const override { return charset; }
766};
767
768enum class Blob_type {
772};
773
774/**
775 Node for BLOB types
776
777 Types: BLOB, TINYBLOB, MEDIUMBLOB, LONGBLOB, LONG, LONG VARBINARY,
778 LONG VARCHAR, TEXT, TINYTEXT, MEDIUMTEXT, LONGTEXT.
779
780 @ingroup ptn_column_types
781*/
782class PT_blob_type : public PT_type {
783 const char *length;
785 const bool force_binary;
786
787 using Parent_type = std::remove_const<decltype(PT_type::type)>::type;
788
789 public:
790 PT_blob_type(const POS &pos, Blob_type blob_type, const CHARSET_INFO *charset,
791 bool force_binary = false)
792 : PT_type(pos, static_cast<Parent_type>(blob_type)),
796 assert(charset == nullptr || !force_binary);
797 }
798 explicit PT_blob_type(const POS &pos, const char *length)
799 : PT_type(pos, MYSQL_TYPE_BLOB),
800 length(length),
802 force_binary(false) {}
803
804 ulong get_type_flags() const override {
805 return force_binary ? BINCMP_FLAG : 0;
806 }
807 const CHARSET_INFO *get_charset() const override { return charset; }
808 const char *get_length() const override { return length; }
809};
810
811/**
812 Node for the YEAR type
813
814 @ingroup ptn_column_types
815*/
816class PT_year_type : public PT_type {
817 public:
818 explicit PT_year_type(const POS &pos) : PT_type(pos, MYSQL_TYPE_YEAR) {}
819};
820
821/**
822 Node for the DATE type
823
824 @ingroup ptn_column_types
825*/
826class PT_date_type : public PT_type {
827 public:
828 explicit PT_date_type(const POS &pos) : PT_type(pos, MYSQL_TYPE_DATE) {}
829};
830
831enum class Time_type : ulong {
834};
835
836/**
837 Node for the TIME, TIMESTAMP and DATETIME types
838
839 @ingroup ptn_column_types
840*/
841class PT_time_type : public PT_type {
842 const char *dec;
843
844 using Parent_type = std::remove_const<decltype(PT_type::type)>::type;
845
846 public:
847 PT_time_type(const POS &pos, Time_type time_type, const char *dec)
848 : PT_type(pos, static_cast<Parent_type>(time_type)), dec(dec) {}
849
850 const char *get_dec() const override { return dec; }
851};
852
853/**
854 Node for the TIMESTAMP type
855
856 @ingroup ptn_column_types
857*/
859 typedef PT_type super;
860
861 const char *dec;
863
864 public:
865 explicit PT_timestamp_type(const POS &pos, const char *dec)
867
868 const char *get_dec() const override { return dec; }
869 ulong get_type_flags() const override { return type_flags; }
870
871 bool do_contextualize(Parse_context *pc) override {
872 if (super::do_contextualize(pc)) return true;
873 /*
874 TIMESTAMP fields are NOT NULL by default, unless the variable
875 explicit_defaults_for_timestamp is true.
876 */
877 if (!pc->thd->variables.explicit_defaults_for_timestamp)
879 /*
880 To flag the current statement as dependent for binary
881 logging on the session var. Extra copying to Lex is
882 done in case prepared stmt.
883 */
886
887 return false;
888 }
889};
890
891/**
892 Node for spatial types
893
894 Types: GEOMETRY, GEOMCOLLECTION/GEOMETRYCOLLECTION, POINT, MULTIPOINT,
895 LINESTRING, MULTILINESTRING, POLYGON, MULTIPOLYGON
896
897 @ingroup ptn_column_types
898*/
899class PT_spacial_type : public PT_type {
901
902 public:
905
906 const CHARSET_INFO *get_charset() const override { return &my_charset_bin; }
907 uint get_uint_geom_type() const override { return geo_type; }
908 const char *get_length() const override { return nullptr; }
909};
910
912
913template <Enum_type enum_type>
917 const bool force_binary;
918
919 using Parent_type = std::remove_const<decltype(PT_type::type)>::type;
920
921 public:
923 const CHARSET_INFO *charset, bool force_binary)
924 : PT_type(pos, static_cast<Parent_type>(enum_type)),
928 assert(charset == nullptr || !force_binary);
929 }
930
931 const CHARSET_INFO *get_charset() const override { return charset; }
932 ulong get_type_flags() const override {
933 return force_binary ? BINCMP_FLAG : 0;
934 }
935 List<String> *get_interval_list() const override { return interval_list; }
936};
937
938/**
939 Node for the ENUM type
940
941 @ingroup ptn_column_types
942*/
944
945/**
946 Node for the SET type
947
948 @ingroup ptn_column_types
949*/
951
952class PT_serial_type : public PT_type {
953 public:
954 explicit PT_serial_type(const POS &pos) : PT_type(pos, MYSQL_TYPE_LONGLONG) {}
955
956 ulong get_type_flags() const override {
958 }
959 bool is_serial_type() const override { return true; }
960};
961
962/**
963 Node for the JSON type
964
965 @ingroup ptn_column_types
966*/
967class PT_json_type : public PT_type {
968 public:
969 explicit PT_json_type(const POS &pos) : PT_type(pos, MYSQL_TYPE_JSON) {}
970 const CHARSET_INFO *get_charset() const override { return &my_charset_bin; }
971};
972
973/**
974 Base class for both generated and regular column definitions
975
976 @ingroup ptn_create_table
977*/
981
982 public:
984 ulong type_flags = 0;
985 const char *length = nullptr;
986 const char *dec = nullptr;
987 const CHARSET_INFO *charset = nullptr;
993 Item *default_value = nullptr;
996 /// Holds the expression to generate default values
998 std::optional<gis::srid_t> m_srid{};
999 // List of column check constraint's specification.
1001
1002 protected:
1004
1006 : super(pos), type_node(type_node) {}
1007
1008 public:
1009 bool do_contextualize(Parse_context *pc) override {
1011 return true;
1012
1013 type = type_node->type;
1016 dec = type_node->get_dec();
1022 if (check_const_spec_list == nullptr) return true; // OOM
1023 return false;
1024 }
1025
1026 private:
1028 PT_column_attr_base *cand) {
1029 // skip de-duplicating these types. NONE is used for (secondary) engine
1030 // attributes, cf. make_column_engine_attribute and
1031 // make_column_secondary_engine_attribute
1032 switch (cand->attr_type()) {
1033 case PT_column_attr_base::AT_NONE: // engine attributes
1035 case PT_column_attr_base::AT_COLLATE_COLUMN_ATTR: // avoid test breaks
1036 return false;
1037 default:
1038 break;
1039 }
1040
1041 for (auto attr : *attrs) {
1042 if (attr->attr_type() == cand->attr_type()) return true;
1043 }
1044 return false;
1045 }
1046
1047 protected:
1050 if (attrs != nullptr) {
1051 if (attrs->size() > 1) {
1052 // Keep only last instance of most attributes that override any
1053 // preceding ones. This avoids contextualizing attributes that will
1054 // later be ignored anyway.
1055 Mem_root_array<PT_column_attr_base *> *unique_attrs = new (pc->mem_root)
1057 unique_attrs->reserve(attrs->size());
1058 for (long i = static_cast<long>(attrs->size()) - 1; i >= 0; i--) {
1059 if (is_overridden(unique_attrs, (*attrs)[i])) continue;
1060 unique_attrs->push_back((*attrs)[i]); // reversed order..
1061 }
1062 attrs->clear();
1063 // Reverse order again to get back original order. Needed for attributes
1064 // which are opposed, e.g. NOT NULL vs NULL.
1065 for (auto attr : *unique_attrs) attrs->push_front(attr);
1066 }
1067
1068 for (auto attr : *attrs) {
1069 if (attr->contextualize(pc)) return true;
1070 attr->apply_type_flags(&type_flags);
1071 attr->apply_alter_info_flags(&alter_info_flags);
1072 attr->apply_comment(&comment);
1073 attr->apply_default_value(&default_value);
1074 attr->apply_gen_default_value(&default_val_info);
1075 attr->apply_on_update_value(&on_update_value);
1076 attr->apply_srid_modifier(&m_srid);
1077 if (attr->apply_collation(pc, &charset, &has_explicit_collation))
1078 return true;
1079 if (attr->add_check_constraints(check_const_spec_list)) return true;
1080 }
1081 }
1082 return false;
1083 }
1084};
1085
1086/**
1087 Base class for regular (non-generated) column definition nodes
1088
1089 @ingroup ptn_create_table
1090*/
1093
1095
1096 public:
1097 PT_field_def(const POS &pos, PT_type *type_node_arg,
1099 : super(pos, type_node_arg), opt_attrs(opt_attrs) {}
1100
1101 bool do_contextualize(Parse_context *pc_arg) override {
1102 Column_parse_context pc(pc_arg->thd, pc_arg->select, false);
1104 return true;
1105
1106 move_cf_appliers(pc_arg, &pc);
1107 return false;
1108 }
1109};
1110
1111/**
1112 Base class for generated column definition nodes
1113
1114 @ingroup ptn_create_table
1115*/
1118
1122
1123 public:
1124 PT_generated_field_def(const POS &pos, PT_type *type_node_arg, Item *expr,
1127 : super(pos, type_node_arg),
1129 expr(expr),
1131
1132 bool do_contextualize(Parse_context *pc_arg) override {
1133 Column_parse_context pc(pc_arg->thd, pc_arg->select, true);
1135 expr->itemize(&pc, &expr))
1136 return true;
1137
1138 // column of type serial cannot be generated
1139 if (type_node->is_serial_type()) {
1140 my_error(ER_WRONG_USAGE, MYF(0), "SERIAL", "generated column");
1141 return true;
1142 }
1143
1145 if (gcol_info == nullptr) return true; // OOM
1150
1151 return false;
1152 }
1153};
1154
1156
1157#endif /* PARSE_TREE_COL_ATTRS_INCLUDED */
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
ulonglong flags
Definition: sql_alter.h:429
@ ADD_CHECK_CONSTRAINT
Set for add check constraint.
Definition: sql_alter.h:319
@ ALTER_ADD_INDEX
Set for ADD INDEX | ADD KEY | ADD PRIMARY KEY | ADD UNIQUE KEY | ADD UNIQUE INDEX | ALTER ADD [COLUMN...
Definition: sql_alter.h:229
geometry_type
Definition: field.h:718
Definition: item_timefunc.h:1183
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:936
@ NULL_ITEM
A NULL value.
Definition: item.h:981
virtual bool itemize(Parse_context *pc, Item **res) final
The same as contextualize() but with additional parameter.
Definition: item.h:1252
virtual enum Type type() const =0
Definition: sql_list.h:467
bool push_back(const Element_type &element)
Adds a new element at the end of the array, after its current last element.
Definition: mem_root_array.h:186
size_t size() const
Definition: mem_root_array.h:407
bool push_front(const Element_type &element)
Adds a new element at the beginning of the array.
Definition: mem_root_array.h:228
void clear()
Erases all of the elements.
Definition: mem_root_array.h:129
bool reserve(size_t n)
Reserves space for array elements.
Definition: mem_root_array.h:155
Node for the AUTO_INCREMENT column attribute.
Definition: parse_tree_column_attrs.h:432
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:433
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:439
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:450
PT_auto_increment_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:436
bool do_contextualize(Column_parse_context *pc) override
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_column_attrs.h:442
Node for the BIT type.
Definition: parse_tree_column_attrs.h:713
PT_bit_type(const POS &pos)
Definition: parse_tree_column_attrs.h:717
const char * get_length() const override
Definition: parse_tree_column_attrs.h:722
const char * length
Definition: parse_tree_column_attrs.h:714
PT_bit_type(const POS &pos, const char *length)
Definition: parse_tree_column_attrs.h:719
Node for BLOB types.
Definition: parse_tree_column_attrs.h:782
const CHARSET_INFO * charset
Definition: parse_tree_column_attrs.h:784
PT_blob_type(const POS &pos, Blob_type blob_type, const CHARSET_INFO *charset, bool force_binary=false)
Definition: parse_tree_column_attrs.h:790
const char * length
Definition: parse_tree_column_attrs.h:783
PT_blob_type(const POS &pos, const char *length)
Definition: parse_tree_column_attrs.h:798
const char * get_length() const override
Definition: parse_tree_column_attrs.h:808
const CHARSET_INFO * get_charset() const override
Definition: parse_tree_column_attrs.h:807
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:804
std::remove_const< decltype(PT_type::type)>::type Parent_type
Definition: parse_tree_column_attrs.h:787
const bool force_binary
Definition: parse_tree_column_attrs.h:785
Node for the BOOL/BOOLEAN type.
Definition: parse_tree_column_attrs.h:730
const char * get_length() const override
Definition: parse_tree_column_attrs.h:733
PT_boolean_type(const POS &pos)
Definition: parse_tree_column_attrs.h:732
Definition: parse_tree_column_attrs.h:742
std::remove_const< decltype(PT_type::type)>::type Parent_type
Definition: parse_tree_column_attrs.h:747
PT_char_type(const POS &pos, Char_type char_type, const char *length, const CHARSET_INFO *charset, bool force_binary=false)
Definition: parse_tree_column_attrs.h:750
const char * length
Definition: parse_tree_column_attrs.h:743
const char * get_length() const override
Definition: parse_tree_column_attrs.h:764
PT_char_type(const POS &pos, Char_type char_type, const CHARSET_INFO *charset, bool force_binary=false)
Definition: parse_tree_column_attrs.h:758
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:761
const CHARSET_INFO * get_charset() const override
Definition: parse_tree_column_attrs.h:765
const CHARSET_INFO * charset
Definition: parse_tree_column_attrs.h:744
const bool force_binary
Definition: parse_tree_column_attrs.h:745
Node for the [CONSTRAINT [symbol]] CHECK '(' expr ')' column attribute.
Definition: parse_tree_column_attrs.h:263
void apply_alter_info_flags(ulonglong *flags) const override
Definition: parse_tree_column_attrs.h:280
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:295
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:264
bool add_check_constraints(Sql_check_constraint_spec_list *check_const_list) override
Definition: parse_tree_column_attrs.h:284
bool set_constraint_enforcement(bool enforced) override
Update the ENFORCED/NOT ENFORCED state of the CHECK constraint.
Definition: parse_tree_column_attrs.h:275
PT_check_constraint_column_attr(const POS &pos, LEX_STRING &name, Item *expr)
Definition: parse_tree_column_attrs.h:268
Sql_check_constraint_spec col_cc_spec
Definition: parse_tree_column_attrs.h:265
bool do_contextualize(Column_parse_context *pc) override
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_column_attrs.h:290
Node for the COLLATE <collation> column attribute.
Definition: parse_tree_column_attrs.h:344
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:361
bool apply_collation(Column_parse_context *pc, const CHARSET_INFO **to, bool *has_explicit_collation) const override
Definition: parse_tree_column_attrs.h:351
PT_collate_column_attr(const POS &pos, const CHARSET_INFO *collation)
Definition: parse_tree_column_attrs.h:346
const CHARSET_INFO *const m_collation
Definition: parse_tree_column_attrs.h:364
Base class for all column attributes in CREATE/ALTER TABLE
Definition: parse_tree_column_attrs.h:85
decltype(Alter_info::flags) alter_info_flags_t
Definition: parse_tree_column_attrs.h:113
virtual bool is_constraint_enforced() const
Check if constraint is enforced.
Definition: parse_tree_column_attrs.h:150
virtual bool set_constraint_enforcement(bool enforced)
Update the ENFORCED/NOT ENFORCED state of the CHECK constraint.
Definition: parse_tree_column_attrs.h:160
virtual void apply_alter_info_flags(ulonglong *) const
Definition: parse_tree_column_attrs.h:116
virtual void apply_srid_modifier(std::optional< gis::srid_t > *) const
Definition: parse_tree_column_attrs.h:121
virtual bool apply_collation(Column_parse_context *, const CHARSET_INFO **to, bool *has_explicit_collation) const
Definition: parse_tree_column_attrs.h:122
virtual void apply_gen_default_value(Value_generator **)
Definition: parse_tree_column_attrs.h:119
Attr_type
Definition: parse_tree_column_attrs.h:91
@ AT_CONSTRAINT_ENFORCEMENT_ATTR
Definition: parse_tree_column_attrs.h:102
@ AT_SECONDARY_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:96
@ AT_CHECK_CONSTRAINT_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:101
@ AT_DEFAULT_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:94
@ AT_UNIQUE_KEY_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:99
@ AT_COMMENT_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:103
@ AT_PRIMARY_KEY_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:100
@ AT_GENERATED_DEFAULT_VAL_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:95
@ AT_SERIAL_DEFAULT_VALUE_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:106
@ AT_ON_UPDATE_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:104
@ AT_NULL_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:98
@ AT_NOT_NULL_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:97
@ AT_AUTO_INCREMENT_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:105
@ AT_COLUMN_FORMAT_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:107
@ AT_COLUMN_VISIBILITY_ATTR
Definition: parse_tree_column_attrs.h:110
@ AT_STORAGE_MEDIA_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:108
@ AT_COLLATE_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:93
@ AT_SRID_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:109
@ AT_NONE
Definition: parse_tree_column_attrs.h:92
virtual Attr_type attr_type() const
Definition: parse_tree_column_attrs.h:132
PT_column_attr_base(const POS &pos)
Definition: parse_tree_column_attrs.h:87
virtual void apply_on_update_value(Item **) const
Definition: parse_tree_column_attrs.h:120
virtual void apply_type_flags(ulong *) const
Definition: parse_tree_column_attrs.h:115
virtual void apply_comment(LEX_CSTRING *) const
Definition: parse_tree_column_attrs.h:117
virtual bool add_check_constraints(Sql_check_constraint_spec_list *check_const_list)
Definition: parse_tree_column_attrs.h:128
virtual bool has_constraint_enforcement() const
Check for the [NOT] ENFORCED characteristic.
Definition: parse_tree_column_attrs.h:140
virtual void apply_default_value(Item **) const
Definition: parse_tree_column_attrs.h:118
Node for the COLUMN_FORMAT <DEFAULT|FIXED|DYNAMIC> column attribute.
Definition: parse_tree_column_attrs.h:490
bool do_contextualize(Column_parse_context *pc) override
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_column_attrs.h:504
PT_column_format_column_attr(const POS &pos, column_format_type format)
Definition: parse_tree_column_attrs.h:496
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:491
column_format_type format
Definition: parse_tree_column_attrs.h:493
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:500
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:511
Node for the VISIBLE|INVISIBLE column attribute.
Definition: parse_tree_column_attrs.h:605
PT_column_visibility_attr(const POS &pos, bool is_visible)
Definition: parse_tree_column_attrs.h:609
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:606
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:616
void apply_type_flags(unsigned long *type_flags) const override
Definition: parse_tree_column_attrs.h:611
const bool m_is_visible
Definition: parse_tree_column_attrs.h:621
Node for the COMMENT <comment> column attribute.
Definition: parse_tree_column_attrs.h:327
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:336
void apply_comment(LEX_CSTRING *to) const override
Definition: parse_tree_column_attrs.h:334
PT_comment_column_attr(const POS &pos, const LEX_CSTRING &comment)
Definition: parse_tree_column_attrs.h:331
const LEX_CSTRING comment
Definition: parse_tree_column_attrs.h:328
Node for the [NOT] ENFORCED column attribute.
Definition: parse_tree_column_attrs.h:305
bool has_constraint_enforcement() const override
Check for the [NOT] ENFORCED characteristic.
Definition: parse_tree_column_attrs.h:310
bool is_constraint_enforced() const override
Check if constraint is enforced.
Definition: parse_tree_column_attrs.h:312
PT_constraint_enforcement_attr(const POS &pos, bool enforced)
Definition: parse_tree_column_attrs.h:307
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:314
const bool m_enforced
Definition: parse_tree_column_attrs.h:319
Node for the DATE type.
Definition: parse_tree_column_attrs.h:826
PT_date_type(const POS &pos)
Definition: parse_tree_column_attrs.h:828
Node for the DEFAULT <expression> column attribute.
Definition: parse_tree_column_attrs.h:374
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:390
void apply_default_value(Item **value) const override
Definition: parse_tree_column_attrs.h:382
PT_default_column_attr(const POS &pos, Item *item)
Definition: parse_tree_column_attrs.h:380
bool do_contextualize(Column_parse_context *pc) override
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_column_attrs.h:383
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:394
Item * item
Definition: parse_tree_column_attrs.h:377
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:375
Definition: parse_tree_column_attrs.h:914
PT_enum_type_tmpl(const POS &pos, List< String > *interval_list, const CHARSET_INFO *charset, bool force_binary)
Definition: parse_tree_column_attrs.h:922
List< String > *const interval_list
Definition: parse_tree_column_attrs.h:915
const CHARSET_INFO * charset
Definition: parse_tree_column_attrs.h:916
const bool force_binary
Definition: parse_tree_column_attrs.h:917
List< String > * get_interval_list() const override
Definition: parse_tree_column_attrs.h:935
const CHARSET_INFO * get_charset() const override
Definition: parse_tree_column_attrs.h:931
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:932
std::remove_const< decltype(PT_type::type)>::type Parent_type
Definition: parse_tree_column_attrs.h:919
Base class for both generated and regular column definitions.
Definition: parse_tree_column_attrs.h:978
bool do_contextualize(Parse_context *pc) override
Definition: parse_tree_column_attrs.h:1009
bool contextualize_attrs(Column_parse_context *pc, Mem_root_array< PT_column_attr_base * > *attrs)
Definition: parse_tree_column_attrs.h:1048
LEX_CSTRING comment
Definition: parse_tree_column_attrs.h:992
enum_field_types type
Definition: parse_tree_column_attrs.h:983
decltype(Alter_info::flags) alter_info_flags_t
Definition: parse_tree_column_attrs.h:980
Value_generator * gcol_info
Definition: parse_tree_column_attrs.h:995
const CHARSET_INFO * charset
Definition: parse_tree_column_attrs.h:987
List< String > * interval_list
Definition: parse_tree_column_attrs.h:990
const char * dec
Definition: parse_tree_column_attrs.h:986
bool has_explicit_collation
Definition: parse_tree_column_attrs.h:988
Item * on_update_value
Definition: parse_tree_column_attrs.h:994
std::optional< gis::srid_t > m_srid
Definition: parse_tree_column_attrs.h:998
const char * length
Definition: parse_tree_column_attrs.h:985
Parse_tree_node super
Definition: parse_tree_column_attrs.h:979
bool is_overridden(Mem_root_array< PT_column_attr_base * > *attrs, PT_column_attr_base *cand)
Definition: parse_tree_column_attrs.h:1027
PT_type * type_node
Definition: parse_tree_column_attrs.h:1003
alter_info_flags_t alter_info_flags
Definition: parse_tree_column_attrs.h:991
Item * default_value
Definition: parse_tree_column_attrs.h:993
Value_generator * default_val_info
Holds the expression to generate default values.
Definition: parse_tree_column_attrs.h:997
PT_field_def_base(const POS &pos, PT_type *type_node)
Definition: parse_tree_column_attrs.h:1005
Sql_check_constraint_spec_list * check_const_spec_list
Definition: parse_tree_column_attrs.h:1000
ulong type_flags
Definition: parse_tree_column_attrs.h:984
uint uint_geom_type
Definition: parse_tree_column_attrs.h:989
Base class for regular (non-generated) column definition nodes.
Definition: parse_tree_column_attrs.h:1091
PT_field_def_base super
Definition: parse_tree_column_attrs.h:1092
Mem_root_array< PT_column_attr_base * > * opt_attrs
Definition: parse_tree_column_attrs.h:1094
bool do_contextualize(Parse_context *pc_arg) override
Definition: parse_tree_column_attrs.h:1101
PT_field_def(const POS &pos, PT_type *type_node_arg, Mem_root_array< PT_column_attr_base * > *opt_attrs)
Definition: parse_tree_column_attrs.h:1097
Node for the generated default value, column attribute.
Definition: parse_tree_column_attrs.h:564
Value_generator m_default_value_expression
Definition: parse_tree_column_attrs.h:597
void apply_gen_default_value(Value_generator **default_value_expression) override
Definition: parse_tree_column_attrs.h:574
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:565
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:592
PT_generated_default_val_column_attr(const POS &pos, Item *expr)
Definition: parse_tree_column_attrs.h:568
bool do_contextualize(Column_parse_context *pc) override
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_column_attrs.h:579
Base class for generated column definition nodes.
Definition: parse_tree_column_attrs.h:1116
Item * expr
Definition: parse_tree_column_attrs.h:1120
Mem_root_array< PT_column_attr_base * > * opt_attrs
Definition: parse_tree_column_attrs.h:1121
bool do_contextualize(Parse_context *pc_arg) override
Definition: parse_tree_column_attrs.h:1132
PT_field_def_base super
Definition: parse_tree_column_attrs.h:1117
PT_generated_field_def(const POS &pos, PT_type *type_node_arg, Item *expr, Virtual_or_stored virtual_or_stored, Mem_root_array< PT_column_attr_base * > *opt_attrs)
Definition: parse_tree_column_attrs.h:1124
const Virtual_or_stored virtual_or_stored
Definition: parse_tree_column_attrs.h:1119
Node for the JSON type.
Definition: parse_tree_column_attrs.h:967
PT_json_type(const POS &pos)
Definition: parse_tree_column_attrs.h:969
const CHARSET_INFO * get_charset() const override
Definition: parse_tree_column_attrs.h:970
Node for the NOT NULL column attribute.
Definition: parse_tree_column_attrs.h:186
PT_not_null_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:188
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:193
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:189
Node for the NULL column attribute.
Definition: parse_tree_column_attrs.h:170
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:178
PT_null_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:172
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:173
Node for numeric types.
Definition: parse_tree_column_attrs.h:659
const char * get_dec() const override
Definition: parse_tree_column_attrs.h:705
PT_numeric_type(const POS &pos, THD *thd, Numeric_type type_arg, const char *length, const char *dec, ulong options)
Definition: parse_tree_column_attrs.h:667
std::remove_const< decltype(PT_type::type)>::type Parent_type
Definition: parse_tree_column_attrs.h:664
const char * dec
Definition: parse_tree_column_attrs.h:661
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:701
const char * get_length() const override
Definition: parse_tree_column_attrs.h:704
PT_numeric_type(const POS &pos, THD *thd, Int_type type_arg, const char *length, ulong options)
Definition: parse_tree_column_attrs.h:686
ulong options
Definition: parse_tree_column_attrs.h:662
const char * length
Definition: parse_tree_column_attrs.h:660
Node for the UPDATE NOW[([<precision>])] column attribute.
Definition: parse_tree_column_attrs.h:402
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:424
PT_on_update_column_attr(const POS &pos, uint8 precision)
Definition: parse_tree_column_attrs.h:409
bool do_contextualize(Column_parse_context *pc) override
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_column_attrs.h:413
const uint8 precision
Definition: parse_tree_column_attrs.h:405
void apply_on_update_value(Item **value) const override
Definition: parse_tree_column_attrs.h:411
Item * item
Definition: parse_tree_column_attrs.h:406
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:403
Node for the PRIMARY [KEY] column attribute.
Definition: parse_tree_column_attrs.h:240
void apply_alter_info_flags(ulonglong *flags) const override
Definition: parse_tree_column_attrs.h:249
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:245
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:253
PT_primary_key_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:242
Node for the NOT SECONDARY column attribute.
Definition: parse_tree_column_attrs.h:201
PT_secondary_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:203
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:209
void apply_type_flags(unsigned long *type_flags) const override
Definition: parse_tree_column_attrs.h:205
Node for the SERIAL DEFAULT VALUE column attribute.
Definition: parse_tree_column_attrs.h:460
void apply_alter_info_flags(ulonglong *flags) const override
Definition: parse_tree_column_attrs.h:469
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:461
bool do_contextualize(Column_parse_context *pc) override
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_column_attrs.h:472
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:466
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:480
PT_serial_default_value_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:464
Definition: parse_tree_column_attrs.h:952
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:956
bool is_serial_type() const override
Definition: parse_tree_column_attrs.h:959
PT_serial_type(const POS &pos)
Definition: parse_tree_column_attrs.h:954
Node for spatial types.
Definition: parse_tree_column_attrs.h:899
const CHARSET_INFO * get_charset() const override
Definition: parse_tree_column_attrs.h:906
Field::geometry_type geo_type
Definition: parse_tree_column_attrs.h:900
PT_spacial_type(const POS &pos, Field::geometry_type geo_type)
Definition: parse_tree_column_attrs.h:903
uint get_uint_geom_type() const override
Definition: parse_tree_column_attrs.h:907
const char * get_length() const override
Definition: parse_tree_column_attrs.h:908
Node for the SRID column attribute.
Definition: parse_tree_column_attrs.h:547
PT_srid_column_attr(const POS &pos, gis::srid_t srid)
Definition: parse_tree_column_attrs.h:553
void apply_srid_modifier(std::optional< gis::srid_t > *srid) const override
Definition: parse_tree_column_attrs.h:556
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:560
gis::srid_t m_srid
Definition: parse_tree_column_attrs.h:550
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:548
Node for the STORAGE <DEFAULT|DISK|MEMORY> column attribute.
Definition: parse_tree_column_attrs.h:521
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:522
bool do_contextualize(Column_parse_context *pc) override
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_column_attrs.h:534
ha_storage_media media
Definition: parse_tree_column_attrs.h:524
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:530
PT_storage_media_column_attr(const POS &pos, ha_storage_media media)
Definition: parse_tree_column_attrs.h:527
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:541
Node for the TIME, TIMESTAMP and DATETIME types.
Definition: parse_tree_column_attrs.h:841
PT_time_type(const POS &pos, Time_type time_type, const char *dec)
Definition: parse_tree_column_attrs.h:847
const char * dec
Definition: parse_tree_column_attrs.h:842
const char * get_dec() const override
Definition: parse_tree_column_attrs.h:850
std::remove_const< decltype(PT_type::type)>::type Parent_type
Definition: parse_tree_column_attrs.h:844
Node for the TIMESTAMP type.
Definition: parse_tree_column_attrs.h:858
ulong type_flags
Definition: parse_tree_column_attrs.h:862
const char * dec
Definition: parse_tree_column_attrs.h:861
const char * get_dec() const override
Definition: parse_tree_column_attrs.h:868
bool do_contextualize(Parse_context *pc) override
Definition: parse_tree_column_attrs.h:871
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:869
PT_timestamp_type(const POS &pos, const char *dec)
Definition: parse_tree_column_attrs.h:865
PT_type super
Definition: parse_tree_column_attrs.h:859
Base class for all column type nodes.
Definition: parse_tree_column_attrs.h:631
virtual bool is_serial_type() const
Definition: parse_tree_column_attrs.h:646
virtual ulong get_type_flags() const
Definition: parse_tree_column_attrs.h:640
virtual const char * get_length() const
Definition: parse_tree_column_attrs.h:641
virtual const CHARSET_INFO * get_charset() const
Definition: parse_tree_column_attrs.h:643
virtual List< String > * get_interval_list() const
Definition: parse_tree_column_attrs.h:645
const enum_field_types type
Definition: parse_tree_column_attrs.h:633
virtual uint get_uint_geom_type() const
Definition: parse_tree_column_attrs.h:644
PT_type(const POS &pos, enum_field_types type)
Definition: parse_tree_column_attrs.h:636
virtual const char * get_dec() const
Definition: parse_tree_column_attrs.h:642
Node for the UNIQUE [KEY] column attribute.
Definition: parse_tree_column_attrs.h:217
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:230
void apply_alter_info_flags(ulonglong *flags) const override
Definition: parse_tree_column_attrs.h:226
PT_unique_key_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:219
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:222
Node for the YEAR type.
Definition: parse_tree_column_attrs.h:816
PT_year_type(const POS &pos)
Definition: parse_tree_column_attrs.h:818
Base class for parse tree nodes (excluding the Parse_tree_root hierarchy)
Definition: parse_tree_node_base.h:231
virtual bool contextualize(Context *pc) final
Definition: parse_tree_node_base.h:319
virtual bool do_contextualize(Column_parse_context *pc)
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_node_base.h:283
POS m_pos
Definition: parse_tree_node_base.h:244
This class represents a query block, aka a query specification, which is a query consisting of a SELE...
Definition: sql_lex.h:1167
Class to represent the check constraint specifications obtained from the SQL statement parse.
Definition: sql_check_constraint.h:43
Item * check_expr
Check constraint expression.
Definition: sql_check_constraint.h:80
bool is_enforced
Check constraint state (enforced/not enforced)
Definition: sql_check_constraint.h:86
LEX_STRING name
Name of the check constraint.
Definition: sql_check_constraint.h:77
@ SL_WARNING
Definition: sql_error.h:63
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:167
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
LEX * lex
Definition: sql_class.h:1001
void syntax_error_at(const POS &location)
Definition: sql_class.h:4493
System_variables variables
Definition: sql_lexer_thd.h:64
bool binlog_need_explicit_defaults_ts
The member is served for marking a query that CREATEs or ALTERs a table declared with a TIMESTAMP col...
Definition: sql_class.h:2664
MEM_ROOT * mem_root
Definition: sql_lexer_thd.h:40
Used for storing information associated with generated column, default values generated from expressi...
Definition: field.h:483
void set_field_stored(bool stored)
Definition: field.h:536
void set_field_type(enum_field_types fld_type)
Definition: field.h:519
Item * expr_item
Item representing the generation expression.
Definition: field.h:493
Mem_root_array< Sql_check_constraint_spec * > Sql_check_constraint_spec_list
Definition: dd_table.h:50
const char * ER_THD(const THD *thd, int mysql_errno)
Definition: derror.cc:104
column_format_type
Definition: field.h:190
This file contains the field type.
enum_field_types
Column types for MySQL Note: Keep include/mysql/components/services/bits/stored_program_bits....
Definition: field_types.h:55
@ MYSQL_TYPE_TIME2
Internal to MySQL.
Definition: field_types.h:75
@ MYSQL_TYPE_VARCHAR
Definition: field_types.h:71
@ MYSQL_TYPE_LONGLONG
Definition: field_types.h:64
@ MYSQL_TYPE_LONG_BLOB
Definition: field_types.h:85
@ MYSQL_TYPE_BLOB
Definition: field_types.h:86
@ MYSQL_TYPE_TINY
Definition: field_types.h:57
@ MYSQL_TYPE_SET
Definition: field_types.h:82
@ MYSQL_TYPE_JSON
Definition: field_types.h:79
@ MYSQL_TYPE_STRING
Definition: field_types.h:88
@ MYSQL_TYPE_ENUM
Definition: field_types.h:81
@ MYSQL_TYPE_TINY_BLOB
Definition: field_types.h:83
@ MYSQL_TYPE_BIT
Definition: field_types.h:72
@ MYSQL_TYPE_INVALID
Definition: field_types.h:77
@ MYSQL_TYPE_GEOMETRY
Definition: field_types.h:89
@ MYSQL_TYPE_MEDIUM_BLOB
Definition: field_types.h:84
@ MYSQL_TYPE_DATETIME2
Internal to MySQL.
Definition: field_types.h:74
@ MYSQL_TYPE_DATE
Definition: field_types.h:66
@ MYSQL_TYPE_TIMESTAMP2
Definition: field_types.h:73
@ MYSQL_TYPE_YEAR
Definition: field_types.h:69
bool merge_charset_and_collation(const CHARSET_INFO *charset, const CHARSET_INFO *collation, const CHARSET_INFO **to)
(end of group Runtime_Environment)
Definition: sql_parse.cc:7287
void my_error(int nr, myf MyFlags,...)
Fill in and print a previously registered error message.
Definition: my_error.cc:216
#define PRI_KEY_FLAG
Field is part of a primary key.
Definition: mysql_com.h:155
#define FIELD_FLAGS_COLUMN_FORMAT
Field column format, bit 24-25.
Definition: mysql_com.h:187
#define ZEROFILL_FLAG
Field is zerofill.
Definition: mysql_com.h:160
#define UNSIGNED_FLAG
Field is unsigned.
Definition: mysql_com.h:159
#define UNIQUE_FLAG
Intern: Used by sql_yacc.
Definition: mysql_com.h:173
#define AUTO_INCREMENT_FLAG
field is a autoincrement field
Definition: mysql_com.h:165
#define FIELD_FLAGS_COLUMN_FORMAT_MASK
Definition: mysql_com.h:188
#define NOT_NULL_FLAG
Field can't be NULL.
Definition: mysql_com.h:154
#define BINCMP_FLAG
Intern: Used by sql_yacc.
Definition: mysql_com.h:174
#define FIELD_IS_INVISIBLE
Field is explicitly marked as invisible by the user.
Definition: mysql_com.h:198
#define EXPLICIT_NULL_FLAG
Field is explicitly specified as \ NULL by the user.
Definition: mysql_com.h:190
#define FIELD_FLAGS_STORAGE_MEDIA_MASK
Definition: mysql_com.h:186
#define NOT_SECONDARY_FLAG
Field will not be loaded in secondary engine.
Definition: mysql_com.h:196
#define FIELD_FLAGS_STORAGE_MEDIA
Field storage media, bit 22-23.
Definition: mysql_com.h:185
static int flags[50]
Definition: hp_test1.cc:40
constexpr const LEX_CSTRING EMPTY_CSTR
Definition: lex_string.h:48
A better implementation of the UNIX ctype(3) library.
MYSQL_STRINGS_EXPORT CHARSET_INFO my_charset_bin
Definition: ctype-bin.cc:509
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
This file includes constants used by all storage engines.
ha_storage_media
Definition: my_base.h:116
Header for compiler-dependent features.
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
uint8_t uint8
Definition: my_inttypes.h:63
#define MYF(v)
Definition: my_inttypes.h:97
Common header for many mysys elements.
Common definition between mysql server & client.
const char * collation
Definition: audit_api_message_emit.cc:184
std::uint32_t srid_t
A spatial reference system ID (SRID).
Definition: srid.h:33
Definition: options.cc:57
Blob_type
Definition: parse_tree_column_attrs.h:768
Enum_type
Definition: parse_tree_column_attrs.h:911
Char_type
Definition: parse_tree_column_attrs.h:736
PT_enum_type_tmpl< Enum_type::ENUM > PT_enum_type
Node for the ENUM type.
Definition: parse_tree_column_attrs.h:943
PT_enum_type_tmpl< Enum_type::SET > PT_set_type
Node for the SET type.
Definition: parse_tree_column_attrs.h:950
Time_type
Definition: parse_tree_column_attrs.h:831
void move_cf_appliers(Parse_context *tddlpc, Column_parse_context *cpc)
Definition: parse_tree_helpers.cc:439
Int_type
Definition: parser_yystype.h:247
Numeric_type
Definition: parser_yystype.h:255
Virtual_or_stored
Definition: parser_yystype.h:245
void push_warning(THD *thd, Sql_condition::enum_severity_level severity, uint code, const char *message_text)
Push the warning to error list if there is still room in the list.
Definition: sql_error.cc:659
case opt name
Definition: sslopt-case.h:29
Definition: m_ctype.h:423
Parse context for column type attribute specific parse tree nodes.
Definition: parse_tree_column_attrs.h:73
const bool is_generated
Owner column is a generated one.
Definition: parse_tree_column_attrs.h:74
std::vector< CreateFieldApplier > cf_appliers
Definition: parse_tree_column_attrs.h:75
Column_parse_context(THD *thd_arg, Query_block *select_arg, bool is_generated)
Definition: parse_tree_column_attrs.h:76
bool binlog_need_explicit_defaults_ts
Definition: sql_lex.h:4394
Definition: mysql_lex_string.h:40
Definition: mysql_lex_string.h:35
Bison "location" class.
Definition: parse_location.h:43
Environment data for the contextualization phase.
Definition: parse_tree_node_base.h:420
Query_block * select
Current Query_block object.
Definition: parse_tree_node_base.h:423
THD *const thd
Current thread handler.
Definition: parse_tree_node_base.h:421
MEM_ROOT * mem_root
Current MEM_ROOT.
Definition: parse_tree_node_base.h:422