MySQL 8.0.43
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 "m_ctype.h"
37#include "my_alloc.h"
38#include "my_base.h"
39#include "my_compiler.h"
40
41#include "my_inttypes.h"
42#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:
88
89 public:
90 enum Attr_type {
110 };
111
113
114 virtual void apply_type_flags(ulong *) const {}
115 virtual void apply_alter_info_flags(ulonglong *) const {}
116 virtual void apply_comment(LEX_CSTRING *) const {}
117 virtual void apply_default_value(Item **) const {}
119 virtual void apply_on_update_value(Item **) const {}
120 virtual void apply_srid_modifier(std::optional<gis::srid_t> *) const {}
122 const CHARSET_INFO **to [[maybe_unused]],
123 bool *has_explicit_collation
124 [[maybe_unused]]) const {
125 return false;
126 }
128 Sql_check_constraint_spec_list *check_const_list [[maybe_unused]]) {
129 return false;
130 }
131 virtual Attr_type attr_type() const { return AT_NONE; }
132
133 /**
134 Check for the [NOT] ENFORCED characteristic.
135
136 @returns true if the [NOT] ENFORCED follows the CHECK(...) clause,
137 false otherwise.
138 */
139 virtual bool has_constraint_enforcement() const { return false; }
140
141 /**
142 Check if constraint is enforced.
143 Method must be called only when has_constraint_enforcement() is true (i.e
144 when [NOT] ENFORCED follows the CHECK(...) clause).
145
146 @returns true if constraint is enforced.
147 false otherwise.
148 */
149 virtual bool is_constraint_enforced() const { return false; }
150
151 /**
152 Update the ENFORCED/NOT ENFORCED state of the CHECK constraint.
153
154 @param enforced true if ENFORCED, false if NOT ENFORCED.
155
156 @returns false if success, true if error (e.g. if [NOT] ENFORCED follows
157 something other than the CHECK clause.)
158 */
159 virtual bool set_constraint_enforcement(bool enforced [[maybe_unused]]) {
160 return true; // error
161 }
162};
163
164/**
165 Node for the @SQL{NULL} column attribute
166
167 @ingroup ptn_column_attrs
168*/
170 public:
171 void apply_type_flags(ulong *type_flags) const override {
172 *type_flags &= ~NOT_NULL_FLAG;
173 *type_flags |= EXPLICIT_NULL_FLAG;
174 }
175
176 enum Attr_type attr_type() const override { return AT_NULL_COLUMN_ATTR; }
177};
178
179/**
180 Node for the @SQL{NOT NULL} column attribute
181
182 @ingroup ptn_column_attrs
183*/
185 void apply_type_flags(ulong *type_flags) const override {
186 *type_flags |= NOT_NULL_FLAG;
187 }
188
189 enum Attr_type attr_type() const override { return AT_NOT_NULL_COLUMN_ATTR; }
190};
191
192/**
193 Node for the @SQL{NOT SECONDARY} column attribute
194
195 @ingroup ptn_column_attrs
196*/
198 public:
199 void apply_type_flags(unsigned long *type_flags) const override {
200 *type_flags |= NOT_SECONDARY_FLAG;
201 }
202
203 enum Attr_type attr_type() const override { return AT_SECONDARY_COLUMN_ATTR; }
204};
205
206/**
207 Node for the @SQL{UNIQUE [KEY]} column attribute
208
209 @ingroup ptn_column_attrs
210*/
212 public:
213 void apply_type_flags(ulong *type_flags) const override {
214 *type_flags |= UNIQUE_FLAG;
215 }
216
217 void apply_alter_info_flags(ulonglong *flags) const override {
219 }
220
221 enum Attr_type attr_type() const override {
223 }
224};
225
226/**
227 Node for the @SQL{PRIMARY [KEY]} column attribute
228
229 @ingroup ptn_column_attrs
230*/
232 public:
233 void apply_type_flags(ulong *type_flags) const override {
234 *type_flags |= PRI_KEY_FLAG | NOT_NULL_FLAG;
235 }
236
237 void apply_alter_info_flags(ulonglong *flags) const override {
239 }
240
241 enum Attr_type attr_type() const override {
243 }
244};
245
246/**
247 Node for the @SQL{[CONSTRAINT [symbol]] CHECK '(' expr ')'} column attribute.
248
249 @ingroup ptn_column_attrs
250*/
254
255 public:
258 col_cc_spec.check_expr = expr;
259 }
260
261 bool set_constraint_enforcement(bool enforced) override {
262 col_cc_spec.is_enforced = enforced;
263 return false;
264 }
265
266 void apply_alter_info_flags(ulonglong *flags) const override {
268 }
269
271 Sql_check_constraint_spec_list *check_const_list) override {
272 assert(check_const_list != nullptr);
273 return (check_const_list->push_back(&col_cc_spec));
274 }
275
277 return (super::contextualize(pc) ||
279 }
280
281 enum Attr_type attr_type() const override {
283 }
284};
285
286/**
287 Node for the @SQL{[NOT] ENFORCED} column attribute.
288
289 @ingroup ptn_column_attrs
290*/
292 public:
293 explicit PT_constraint_enforcement_attr(bool enforced)
294 : m_enforced(enforced) {}
295
296 bool has_constraint_enforcement() const override { return true; }
297
298 bool is_constraint_enforced() const override { return m_enforced; }
299
300 enum Attr_type attr_type() const override {
302 }
303
304 private:
305 const bool m_enforced;
306};
307
308/**
309 Node for the @SQL{COMMENT @<comment@>} column attribute
310
311 @ingroup ptn_column_attrs
312*/
315
316 public:
318 : comment(comment) {}
319
320 void apply_comment(LEX_CSTRING *to) const override { *to = comment; }
321
322 enum Attr_type attr_type() const override { return AT_COMMENT_COLUMN_ATTR; }
323};
324
325/**
326 Node for the @SQL{COLLATE @<collation@>} column attribute
327
328 @ingroup ptn_column_attrs
329*/
331 public:
333 : m_pos(pos), m_collation(collation) {
334 assert(m_collation != nullptr);
335 }
336
338 bool *has_explicit_collation) const override {
339 if (*has_explicit_collation) {
340 pc->thd->syntax_error_at(m_pos, ER_INVALID_MULTIPLE_CLAUSES, "COLLATE");
341 return true;
342 }
343 *has_explicit_collation = true;
345 }
346
347 enum Attr_type attr_type() const override { return AT_COLLATE_COLUMN_ATTR; }
348
349 private:
350 const POS m_pos;
352};
353
354// Specific to non-generated columns only:
355
356/**
357 Node for the @SQL{DEFAULT @<expression@>} column attribute
358
359 @ingroup ptn_not_gcol_attr
360*/
363
365
366 public:
368 void apply_default_value(Item **value) const override { *value = item; }
370 if (pc->is_generated) {
371 my_error(ER_WRONG_USAGE, MYF(0), "DEFAULT", "generated column");
372 return true;
373 }
374 return super::contextualize(pc) || item->itemize(pc, &item);
375 }
376 void apply_type_flags(ulong *type_flags) const override {
377 if (item->type() == Item::NULL_ITEM) *type_flags |= EXPLICIT_NULL_FLAG;
378 }
379
380 enum Attr_type attr_type() const override { return AT_DEFAULT_COLUMN_ATTR; }
381};
382
383/**
384 Node for the @SQL{UPDATE NOW[([@<precision@>])]} column attribute
385
386 @ingroup ptn_not_gcol_attr
387*/
390
393
394 public:
396 void apply_on_update_value(Item **value) const override { *value = item; }
397
399 if (pc->is_generated) {
400 my_error(ER_WRONG_USAGE, MYF(0), "ON UPDATE", "generated column");
401 return true;
402 }
403 if (super::contextualize(pc)) return true;
404
406 return item == nullptr;
407 }
408
409 enum Attr_type attr_type() const override { return AT_ON_UPDATE_COLUMN_ATTR; }
410};
411
412/**
413 Node for the @SQL{AUTO_INCREMENT} column attribute
414
415 @ingroup ptn_not_gcol_attr
416*/
419
420 public:
421 void apply_type_flags(ulong *type_flags) const override {
422 *type_flags |= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG;
423 }
425 if (pc->is_generated) {
426 my_error(ER_WRONG_USAGE, MYF(0), "AUTO_INCREMENT", "generated column");
427 return true;
428 }
429 return super::contextualize(pc);
430 }
431
432 enum Attr_type attr_type() const override {
434 }
435};
436
437/**
438 Node for the @SQL{SERIAL DEFAULT VALUE} column attribute
439
440 @ingroup ptn_not_gcol_attr
441*/
444
445 public:
446 void apply_type_flags(ulong *type_flags) const override {
448 }
449 void apply_alter_info_flags(ulonglong *flags) const override {
451 }
453 if (pc->is_generated) {
454 my_error(ER_WRONG_USAGE, MYF(0), "SERIAL DEFAULT VALUE",
455 "generated column");
456 return true;
457 }
458 return super::contextualize(pc);
459 }
460 enum Attr_type attr_type() const override {
462 }
463};
464
465/**
466 Node for the @SQL{COLUMN_FORMAT @<DEFAULT|FIXED|DYNAMIC@>} column attribute
467
468 @ingroup ptn_not_gcol_attr
469*/
472
474
475 public:
477 : format(format) {}
478
479 void apply_type_flags(ulong *type_flags) const override {
480 *type_flags &= ~(FIELD_FLAGS_COLUMN_FORMAT_MASK);
481 *type_flags |= format << FIELD_FLAGS_COLUMN_FORMAT;
482 }
484 if (pc->is_generated) {
485 my_error(ER_WRONG_USAGE, MYF(0), "COLUMN_FORMAT", "generated column");
486 return true;
487 }
488 return super::contextualize(pc);
489 }
490 enum Attr_type attr_type() const override {
492 }
493};
494
495/**
496 Node for the @SQL{STORAGE @<DEFAULT|DISK|MEMORY@>} column attribute
497
498 @ingroup ptn_not_gcol_attr
499*/
502
504
505 public:
507 : media(media) {}
508
509 void apply_type_flags(ulong *type_flags) const override {
510 *type_flags &= ~(FIELD_FLAGS_STORAGE_MEDIA_MASK);
511 *type_flags |= media << FIELD_FLAGS_STORAGE_MEDIA;
512 }
514 if (pc->is_generated) {
515 my_error(ER_WRONG_USAGE, MYF(0), "STORAGE", "generated column");
516 return true;
517 }
518 return super::contextualize(pc);
519 }
520 enum Attr_type attr_type() const override {
522 }
523};
524
525/// Node for the SRID column attribute
528
530
531 public:
532 explicit PT_srid_column_attr(gis::srid_t srid) : m_srid(srid) {}
533
534 void apply_srid_modifier(std::optional<gis::srid_t> *srid) const override {
535 *srid = m_srid;
536 }
537
538 enum Attr_type attr_type() const override { return AT_SRID_COLUMN_ATTR; }
539};
540
541/// Node for the generated default value, column attribute
544
545 public:
549 }
550
552 Value_generator **default_value_expression) override {
553 *default_value_expression = &m_default_value_expression;
554 }
555
557 // GC and default value expressions are mutually exclusive and thus only
558 // one is allowed to be present on the same column definition.
559 if (pc->is_generated) {
560 my_error(ER_WRONG_USAGE, MYF(0), "DEFAULT", "generated column");
561 return true;
562 }
563 Parse_context expr_pc(pc->thd, pc->select);
564 return super::contextualize(pc) ||
567 }
568
569 enum Attr_type attr_type() const override {
571 }
572
573 private:
575};
576
577/**
578 Node for the @SQL{VISIBLE|INVISIBLE} column attribute
579
580 @ingroup ptn_column_attrs
581*/
583 public:
584 explicit PT_column_visibility_attr(bool is_visible)
585 : m_is_visible(is_visible) {}
586 void apply_type_flags(unsigned long *type_flags) const override {
587 *type_flags &= ~FIELD_IS_INVISIBLE;
588 if (!m_is_visible) *type_flags |= FIELD_IS_INVISIBLE;
589 }
590
591 enum Attr_type attr_type() const override {
593 }
594
595 private:
596 const bool m_is_visible;
597};
598
599// Type nodes:
600
601/**
602 Base class for all column type nodes
603
604 @ingroup ptn_column_types
605*/
606class PT_type : public Parse_tree_node {
607 public:
609
610 protected:
612
613 public:
614 virtual ulong get_type_flags() const { return 0; }
615 virtual const char *get_length() const { return nullptr; }
616 virtual const char *get_dec() const { return nullptr; }
617 virtual const CHARSET_INFO *get_charset() const { return nullptr; }
618 virtual uint get_uint_geom_type() const { return 0; }
619 virtual List<String> *get_interval_list() const { return nullptr; }
620 virtual bool is_serial_type() const { return false; }
621};
622
623/**
624 Node for numeric types
625
626 Type list:
627 * NUMERIC, REAL, DOUBLE, DECIMAL and FIXED,
628 * INTEGER, INT, INT1, INT2, INT3, INT4, TINYINT, SMALLINT, MEDIUMINT and
629 BIGINT.
630
631 @ingroup ptn_column_types
632*/
633class PT_numeric_type : public PT_type {
634 const char *length;
635 const char *dec;
636 ulong options;
637
638 using Parent_type = std::remove_const<decltype(PT_type::type)>::type;
639
640 public:
641 PT_numeric_type(THD *thd, Numeric_type type_arg, const char *length,
642 const char *dec, ulong options)
643 : PT_type(static_cast<Parent_type>(type_arg)),
644 length(length),
645 dec(dec),
647 assert((options & ~(UNSIGNED_FLAG | ZEROFILL_FLAG)) == 0);
648
649 if (type_arg != Numeric_type::DECIMAL && dec != nullptr) {
651 ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT,
652 ER_THD(thd, ER_WARN_DEPRECATED_FLOAT_DIGITS));
653 }
654 if (options & UNSIGNED_FLAG) {
656 ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT,
657 ER_THD(thd, ER_WARN_DEPRECATED_FLOAT_UNSIGNED));
658 }
659 }
660 PT_numeric_type(THD *thd, Int_type type_arg, const char *length,
661 ulong options)
662 : PT_type(static_cast<enum_field_types>(type_arg)),
663 length(length),
664 dec(nullptr),
666 assert((options & ~(UNSIGNED_FLAG | ZEROFILL_FLAG)) == 0);
667
668 if (length != nullptr) {
670 ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT,
671 ER_THD(thd, ER_WARN_DEPRECATED_INTEGER_DISPLAY_WIDTH));
672 }
673 }
674
675 ulong get_type_flags() const override {
677 }
678 const char *get_length() const override { return length; }
679 const char *get_dec() const override { return dec; }
680};
681
682/**
683 Node for the BIT type
684
685 @ingroup ptn_column_types
686*/
687class PT_bit_type : public PT_type {
688 const char *length;
689
690 public:
692 explicit PT_bit_type(const char *length)
694
695 const char *get_length() const override { return length; }
696};
697
698/**
699 Node for the BOOL/BOOLEAN type
700
701 @ingroup ptn_column_types
702*/
703class PT_boolean_type : public PT_type {
704 public:
706 const char *get_length() const override { return "1"; }
707};
708
709enum class Char_type : ulong {
713};
714
715class PT_char_type : public PT_type {
716 const char *length;
718 const bool force_binary;
719
720 using Parent_type = std::remove_const<decltype(PT_type::type)>::type;
721
722 public:
723 PT_char_type(Char_type char_type, const char *length,
724 const CHARSET_INFO *charset, bool force_binary = false)
725 : PT_type(static_cast<Parent_type>(char_type)),
726 length(length),
729 assert(charset == nullptr || !force_binary);
730 }
732 bool force_binary = false)
733 : PT_char_type(char_type, "1", charset, force_binary) {}
734 ulong get_type_flags() const override {
735 return force_binary ? BINCMP_FLAG : 0;
736 }
737 const char *get_length() const override { return length; }
738 const CHARSET_INFO *get_charset() const override { return charset; }
739};
740
741enum class Blob_type {
745};
746
747/**
748 Node for BLOB types
749
750 Types: BLOB, TINYBLOB, MEDIUMBLOB, LONGBLOB, LONG, LONG VARBINARY,
751 LONG VARCHAR, TEXT, TINYTEXT, MEDIUMTEXT, LONGTEXT.
752
753 @ingroup ptn_column_types
754*/
755class PT_blob_type : public PT_type {
756 const char *length;
758 const bool force_binary;
759
760 using Parent_type = std::remove_const<decltype(PT_type::type)>::type;
761
762 public:
764 bool force_binary = false)
765 : PT_type(static_cast<Parent_type>(blob_type)),
769 assert(charset == nullptr || !force_binary);
770 }
771 explicit PT_blob_type(const char *length)
773 length(length),
775 force_binary(false) {}
776
777 ulong get_type_flags() const override {
778 return force_binary ? BINCMP_FLAG : 0;
779 }
780 const CHARSET_INFO *get_charset() const override { return charset; }
781 const char *get_length() const override { return length; }
782};
783
784/**
785 Node for the YEAR type
786
787 @ingroup ptn_column_types
788*/
789class PT_year_type : public PT_type {
790 public:
792};
793
794/**
795 Node for the DATE type
796
797 @ingroup ptn_column_types
798*/
799class PT_date_type : public PT_type {
800 public:
802};
803
804enum class Time_type : ulong {
807};
808
809/**
810 Node for the TIME, TIMESTAMP and DATETIME types
811
812 @ingroup ptn_column_types
813*/
814class PT_time_type : public PT_type {
815 const char *dec;
816
817 using Parent_type = std::remove_const<decltype(PT_type::type)>::type;
818
819 public:
820 PT_time_type(Time_type time_type, const char *dec)
821 : PT_type(static_cast<Parent_type>(time_type)), dec(dec) {}
822
823 const char *get_dec() const override { return dec; }
824};
825
826/**
827 Node for the TIMESTAMP type
828
829 @ingroup ptn_column_types
830*/
832 typedef PT_type super;
833
834 const char *dec;
836
837 public:
838 explicit PT_timestamp_type(const char *dec)
840
841 const char *get_dec() const override { return dec; }
842 ulong get_type_flags() const override { return type_flags; }
843
844 bool contextualize(Parse_context *pc) override {
845 if (super::contextualize(pc)) return true;
846 /*
847 TIMESTAMP fields are NOT NULL by default, unless the variable
848 explicit_defaults_for_timestamp is true.
849 */
850 if (!pc->thd->variables.explicit_defaults_for_timestamp)
852 /*
853 To flag the current statement as dependent for binary
854 logging on the session var. Extra copying to Lex is
855 done in case prepared stmt.
856 */
859
860 return false;
861 }
862};
863
864/**
865 Node for spatial types
866
867 Types: GEOMETRY, GEOMCOLLECTION/GEOMETRYCOLLECTION, POINT, MULTIPOINT,
868 LINESTRING, MULTILINESTRING, POLYGON, MULTIPOLYGON
869
870 @ingroup ptn_column_types
871*/
872class PT_spacial_type : public PT_type {
874
875 public:
878
879 const CHARSET_INFO *get_charset() const override { return &my_charset_bin; }
880 uint get_uint_geom_type() const override { return geo_type; }
881 const char *get_length() const override { return nullptr; }
882};
883
885
886template <Enum_type enum_type>
890 const bool force_binary;
891
892 using Parent_type = std::remove_const<decltype(PT_type::type)>::type;
893
894 public:
896 bool force_binary)
897 : PT_type(static_cast<Parent_type>(enum_type)),
901 assert(charset == nullptr || !force_binary);
902 }
903
904 const CHARSET_INFO *get_charset() const override { return charset; }
905 ulong get_type_flags() const override {
906 return force_binary ? BINCMP_FLAG : 0;
907 }
908 List<String> *get_interval_list() const override { return interval_list; }
909};
910
911/**
912 Node for the ENUM type
913
914 @ingroup ptn_column_types
915*/
917
918/**
919 Node for the SET type
920
921 @ingroup ptn_column_types
922*/
924
925class PT_serial_type : public PT_type {
926 public:
928
929 ulong get_type_flags() const override {
931 }
932 bool is_serial_type() const override { return true; }
933};
934
935/**
936 Node for the JSON type
937
938 @ingroup ptn_column_types
939*/
940class PT_json_type : public PT_type {
941 public:
943 const CHARSET_INFO *get_charset() const override { return &my_charset_bin; }
944};
945
946/**
947 Base class for both generated and regular column definitions
948
949 @ingroup ptn_create_table
950*/
954
955 public:
958 const char *length;
959 const char *dec;
969 /// Holds the expression to generate default values
971 std::optional<gis::srid_t> m_srid;
972 // List of column check constraint's specification.
974
975 protected:
977
979 : has_explicit_collation(false),
987
988 public:
989 bool contextualize(Parse_context *pc) override {
990 if (super::contextualize(pc) || type_node->contextualize(pc)) return true;
991
995 dec = type_node->get_dec();
1001 if (check_const_spec_list == nullptr) return true; // OOM
1002 return false;
1003 }
1004
1005 private:
1007 PT_column_attr_base *cand) {
1008 // skip de-duplicating these types. NONE is used for (secondary) engine
1009 // attributes, cf. make_column_engine_attribute and
1010 // make_column_secondary_engine_attribute
1011 switch (cand->attr_type()) {
1012 case PT_column_attr_base::AT_NONE: // engine attributes
1014 case PT_column_attr_base::AT_COLLATE_COLUMN_ATTR: // avoid test breaks
1015 return false;
1016 default:
1017 break;
1018 }
1019
1020 for (auto attr : *attrs) {
1021 if (attr->attr_type() == cand->attr_type()) return true;
1022 }
1023 return false;
1024 }
1025
1026 protected:
1029 if (attrs != nullptr) {
1030 if (attrs->size() > 1) {
1031 // Keep only last instance of most attributes that override any
1032 // preceding ones. This avoids contextualizing attributes that will
1033 // later be ignored anyway.
1034 Mem_root_array<PT_column_attr_base *> *unique_attrs = new (pc->mem_root)
1036 unique_attrs->reserve(attrs->size());
1037 for (long i = static_cast<long>(attrs->size()) - 1; i >= 0; i--) {
1038 if (is_overridden(unique_attrs, (*attrs)[i])) continue;
1039 unique_attrs->push_back((*attrs)[i]); // reversed order..
1040 }
1041 attrs->clear();
1042 // Reverse order again to get back original order. Needed for attributes
1043 // which are opposed, e.g. NOT NULL vs NULL.
1044 for (auto attr : *unique_attrs) attrs->push_front(attr);
1045 }
1046
1047 for (auto attr : *attrs) {
1048 if (attr->contextualize(pc)) return true;
1049 attr->apply_type_flags(&type_flags);
1050 attr->apply_alter_info_flags(&alter_info_flags);
1051 attr->apply_comment(&comment);
1052 attr->apply_default_value(&default_value);
1053 attr->apply_gen_default_value(&default_val_info);
1054 attr->apply_on_update_value(&on_update_value);
1055 attr->apply_srid_modifier(&m_srid);
1056 if (attr->apply_collation(pc, &charset, &has_explicit_collation))
1057 return true;
1058 if (attr->add_check_constraints(check_const_spec_list)) return true;
1059 }
1060 }
1061 return false;
1062 }
1063};
1064
1065/**
1066 Base class for regular (non-generated) column definition nodes
1067
1068 @ingroup ptn_create_table
1069*/
1072
1074
1075 public:
1076 PT_field_def(PT_type *type_node_arg,
1078 : super(type_node_arg), opt_attrs(opt_attrs) {}
1079
1080 bool contextualize(Parse_context *pc_arg) override {
1081 Column_parse_context pc(pc_arg->thd, pc_arg->select, false);
1083 return true;
1084
1085 move_cf_appliers(pc_arg, &pc);
1086 return false;
1087 }
1088};
1089
1090/**
1091 Base class for generated column definition nodes
1092
1093 @ingroup ptn_create_table
1094*/
1097
1101
1102 public:
1106 : super(type_node_arg),
1108 expr(expr),
1110
1111 bool contextualize(Parse_context *pc_arg) override {
1112 Column_parse_context pc(pc_arg->thd, pc_arg->select, true);
1114 expr->itemize(&pc, &expr))
1115 return true;
1116
1117 // column of type serial cannot be generated
1118 if (type_node->is_serial_type()) {
1119 my_error(ER_WRONG_USAGE, MYF(0), "SERIAL", "generated column");
1120 return true;
1121 }
1122
1124 if (gcol_info == nullptr) return true; // OOM
1129
1130 return false;
1131 }
1132};
1133
1135
1136#endif /* PARSE_TREE_COL_ATTRS_INCLUDED */
ulonglong flags
Definition: sql_alter.h:428
@ ADD_CHECK_CONSTRAINT
Set for add check constraint.
Definition: sql_alter.h:318
@ 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:228
geometry_type
Definition: field.h:718
Definition: item_timefunc.h:1155
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:853
virtual bool itemize(Parse_context *pc, Item **res)
The same as contextualize() but with additional parameter.
Definition: item.cc:631
@ NULL_ITEM
Definition: item.h:897
virtual enum Type type() const =0
Definition: sql_list.h:434
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:417
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:418
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:421
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:432
bool contextualize(Column_parse_context *pc) override
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_column_attrs.h:424
Node for the BIT type.
Definition: parse_tree_column_attrs.h:687
PT_bit_type(const char *length)
Definition: parse_tree_column_attrs.h:692
const char * get_length() const override
Definition: parse_tree_column_attrs.h:695
const char * length
Definition: parse_tree_column_attrs.h:688
PT_bit_type()
Definition: parse_tree_column_attrs.h:691
Node for BLOB types.
Definition: parse_tree_column_attrs.h:755
const CHARSET_INFO * charset
Definition: parse_tree_column_attrs.h:757
const char * length
Definition: parse_tree_column_attrs.h:756
PT_blob_type(const char *length)
Definition: parse_tree_column_attrs.h:771
const char * get_length() const override
Definition: parse_tree_column_attrs.h:781
const CHARSET_INFO * get_charset() const override
Definition: parse_tree_column_attrs.h:780
PT_blob_type(Blob_type blob_type, const CHARSET_INFO *charset, bool force_binary=false)
Definition: parse_tree_column_attrs.h:763
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:777
std::remove_const< decltype(PT_type::type)>::type Parent_type
Definition: parse_tree_column_attrs.h:760
const bool force_binary
Definition: parse_tree_column_attrs.h:758
Node for the BOOL/BOOLEAN type.
Definition: parse_tree_column_attrs.h:703
const char * get_length() const override
Definition: parse_tree_column_attrs.h:706
PT_boolean_type()
Definition: parse_tree_column_attrs.h:705
Definition: parse_tree_column_attrs.h:715
PT_char_type(Char_type char_type, const CHARSET_INFO *charset, bool force_binary=false)
Definition: parse_tree_column_attrs.h:731
std::remove_const< decltype(PT_type::type)>::type Parent_type
Definition: parse_tree_column_attrs.h:720
const char * length
Definition: parse_tree_column_attrs.h:716
const char * get_length() const override
Definition: parse_tree_column_attrs.h:737
PT_char_type(Char_type char_type, const char *length, const CHARSET_INFO *charset, bool force_binary=false)
Definition: parse_tree_column_attrs.h:723
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:734
const CHARSET_INFO * get_charset() const override
Definition: parse_tree_column_attrs.h:738
const CHARSET_INFO * charset
Definition: parse_tree_column_attrs.h:717
const bool force_binary
Definition: parse_tree_column_attrs.h:718
Node for the [CONSTRAINT [symbol]] CHECK '(' expr ')' column attribute.
Definition: parse_tree_column_attrs.h:251
bool contextualize(Column_parse_context *pc) override
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_column_attrs.h:276
void apply_alter_info_flags(ulonglong *flags) const override
Definition: parse_tree_column_attrs.h:266
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:281
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:252
bool add_check_constraints(Sql_check_constraint_spec_list *check_const_list) override
Definition: parse_tree_column_attrs.h:270
bool set_constraint_enforcement(bool enforced) override
Update the ENFORCED/NOT ENFORCED state of the CHECK constraint.
Definition: parse_tree_column_attrs.h:261
PT_check_constraint_column_attr(LEX_STRING &name, Item *expr)
Definition: parse_tree_column_attrs.h:256
Sql_check_constraint_spec col_cc_spec
Definition: parse_tree_column_attrs.h:253
Node for the COLLATE <collation> column attribute.
Definition: parse_tree_column_attrs.h:330
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:347
const POS m_pos
Definition: parse_tree_column_attrs.h:350
bool apply_collation(Column_parse_context *pc, const CHARSET_INFO **to, bool *has_explicit_collation) const override
Definition: parse_tree_column_attrs.h:337
PT_collate_column_attr(const POS &pos, const CHARSET_INFO *collation)
Definition: parse_tree_column_attrs.h:332
const CHARSET_INFO *const m_collation
Definition: parse_tree_column_attrs.h:351
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:112
virtual bool is_constraint_enforced() const
Check if constraint is enforced.
Definition: parse_tree_column_attrs.h:149
virtual bool set_constraint_enforcement(bool enforced)
Update the ENFORCED/NOT ENFORCED state of the CHECK constraint.
Definition: parse_tree_column_attrs.h:159
virtual void apply_alter_info_flags(ulonglong *) const
Definition: parse_tree_column_attrs.h:115
virtual void apply_srid_modifier(std::optional< gis::srid_t > *) const
Definition: parse_tree_column_attrs.h:120
virtual bool apply_collation(Column_parse_context *, const CHARSET_INFO **to, bool *has_explicit_collation) const
Definition: parse_tree_column_attrs.h:121
virtual void apply_gen_default_value(Value_generator **)
Definition: parse_tree_column_attrs.h:118
Attr_type
Definition: parse_tree_column_attrs.h:90
@ AT_CONSTRAINT_ENFORCEMENT_ATTR
Definition: parse_tree_column_attrs.h:101
@ AT_SECONDARY_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:95
@ AT_CHECK_CONSTRAINT_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:100
@ AT_DEFAULT_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:93
@ AT_UNIQUE_KEY_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:98
@ AT_COMMENT_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:102
@ AT_PRIMARY_KEY_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:99
@ AT_GENERATED_DEFAULT_VAL_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:94
@ AT_SERIAL_DEFAULT_VALUE_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:105
@ AT_ON_UPDATE_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:103
@ AT_NULL_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:97
@ AT_NOT_NULL_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:96
@ AT_AUTO_INCREMENT_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:104
@ AT_COLUMN_FORMAT_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:106
@ AT_COLUMN_VISIBILITY_ATTR
Definition: parse_tree_column_attrs.h:109
@ AT_STORAGE_MEDIA_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:107
@ AT_COLLATE_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:92
@ AT_SRID_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:108
@ AT_NONE
Definition: parse_tree_column_attrs.h:91
virtual Attr_type attr_type() const
Definition: parse_tree_column_attrs.h:131
virtual void apply_on_update_value(Item **) const
Definition: parse_tree_column_attrs.h:119
virtual void apply_type_flags(ulong *) const
Definition: parse_tree_column_attrs.h:114
virtual void apply_comment(LEX_CSTRING *) const
Definition: parse_tree_column_attrs.h:116
virtual bool add_check_constraints(Sql_check_constraint_spec_list *check_const_list)
Definition: parse_tree_column_attrs.h:127
PT_column_attr_base()=default
virtual bool has_constraint_enforcement() const
Check for the [NOT] ENFORCED characteristic.
Definition: parse_tree_column_attrs.h:139
virtual void apply_default_value(Item **) const
Definition: parse_tree_column_attrs.h:117
Node for the COLUMN_FORMAT <DEFAULT|FIXED|DYNAMIC> column attribute.
Definition: parse_tree_column_attrs.h:470
bool contextualize(Column_parse_context *pc) override
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_column_attrs.h:483
PT_column_format_column_attr(column_format_type format)
Definition: parse_tree_column_attrs.h:476
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:471
column_format_type format
Definition: parse_tree_column_attrs.h:473
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:479
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:490
Node for the VISIBLE|INVISIBLE column attribute.
Definition: parse_tree_column_attrs.h:582
PT_column_visibility_attr(bool is_visible)
Definition: parse_tree_column_attrs.h:584
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:591
void apply_type_flags(unsigned long *type_flags) const override
Definition: parse_tree_column_attrs.h:586
const bool m_is_visible
Definition: parse_tree_column_attrs.h:596
Node for the COMMENT <comment> column attribute.
Definition: parse_tree_column_attrs.h:313
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:322
void apply_comment(LEX_CSTRING *to) const override
Definition: parse_tree_column_attrs.h:320
PT_comment_column_attr(const LEX_CSTRING &comment)
Definition: parse_tree_column_attrs.h:317
const LEX_CSTRING comment
Definition: parse_tree_column_attrs.h:314
Node for the [NOT] ENFORCED column attribute.
Definition: parse_tree_column_attrs.h:291
bool has_constraint_enforcement() const override
Check for the [NOT] ENFORCED characteristic.
Definition: parse_tree_column_attrs.h:296
PT_constraint_enforcement_attr(bool enforced)
Definition: parse_tree_column_attrs.h:293
bool is_constraint_enforced() const override
Check if constraint is enforced.
Definition: parse_tree_column_attrs.h:298
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:300
const bool m_enforced
Definition: parse_tree_column_attrs.h:305
Node for the DATE type.
Definition: parse_tree_column_attrs.h:799
PT_date_type()
Definition: parse_tree_column_attrs.h:801
Node for the DEFAULT <expression> column attribute.
Definition: parse_tree_column_attrs.h:361
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:376
void apply_default_value(Item **value) const override
Definition: parse_tree_column_attrs.h:368
PT_default_column_attr(Item *item)
Definition: parse_tree_column_attrs.h:367
bool contextualize(Column_parse_context *pc) override
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_column_attrs.h:369
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:380
Item * item
Definition: parse_tree_column_attrs.h:364
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:362
Definition: parse_tree_column_attrs.h:887
List< String > *const interval_list
Definition: parse_tree_column_attrs.h:888
const CHARSET_INFO * charset
Definition: parse_tree_column_attrs.h:889
const bool force_binary
Definition: parse_tree_column_attrs.h:890
List< String > * get_interval_list() const override
Definition: parse_tree_column_attrs.h:908
const CHARSET_INFO * get_charset() const override
Definition: parse_tree_column_attrs.h:904
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:905
std::remove_const< decltype(PT_type::type)>::type Parent_type
Definition: parse_tree_column_attrs.h:892
PT_enum_type_tmpl(List< String > *interval_list, const CHARSET_INFO *charset, bool force_binary)
Definition: parse_tree_column_attrs.h:895
Base class for both generated and regular column definitions.
Definition: parse_tree_column_attrs.h:951
bool contextualize_attrs(Column_parse_context *pc, Mem_root_array< PT_column_attr_base * > *attrs)
Definition: parse_tree_column_attrs.h:1027
LEX_CSTRING comment
Definition: parse_tree_column_attrs.h:965
enum_field_types type
Definition: parse_tree_column_attrs.h:956
decltype(Alter_info::flags) alter_info_flags_t
Definition: parse_tree_column_attrs.h:953
Value_generator * gcol_info
Definition: parse_tree_column_attrs.h:968
const CHARSET_INFO * charset
Definition: parse_tree_column_attrs.h:960
List< String > * interval_list
Definition: parse_tree_column_attrs.h:963
const char * dec
Definition: parse_tree_column_attrs.h:959
bool has_explicit_collation
Definition: parse_tree_column_attrs.h:961
Item * on_update_value
Definition: parse_tree_column_attrs.h:967
std::optional< gis::srid_t > m_srid
Definition: parse_tree_column_attrs.h:971
const char * length
Definition: parse_tree_column_attrs.h:958
Parse_tree_node super
Definition: parse_tree_column_attrs.h:952
bool is_overridden(Mem_root_array< PT_column_attr_base * > *attrs, PT_column_attr_base *cand)
Definition: parse_tree_column_attrs.h:1006
PT_type * type_node
Definition: parse_tree_column_attrs.h:976
alter_info_flags_t alter_info_flags
Definition: parse_tree_column_attrs.h:964
Item * default_value
Definition: parse_tree_column_attrs.h:966
Value_generator * default_val_info
Holds the expression to generate default values.
Definition: parse_tree_column_attrs.h:970
bool contextualize(Parse_context *pc) override
Definition: parse_tree_column_attrs.h:989
Sql_check_constraint_spec_list * check_const_spec_list
Definition: parse_tree_column_attrs.h:973
ulong type_flags
Definition: parse_tree_column_attrs.h:957
PT_field_def_base(PT_type *type_node)
Definition: parse_tree_column_attrs.h:978
uint uint_geom_type
Definition: parse_tree_column_attrs.h:962
Base class for regular (non-generated) column definition nodes.
Definition: parse_tree_column_attrs.h:1070
PT_field_def_base super
Definition: parse_tree_column_attrs.h:1071
bool contextualize(Parse_context *pc_arg) override
Definition: parse_tree_column_attrs.h:1080
PT_field_def(PT_type *type_node_arg, Mem_root_array< PT_column_attr_base * > *opt_attrs)
Definition: parse_tree_column_attrs.h:1076
Mem_root_array< PT_column_attr_base * > * opt_attrs
Definition: parse_tree_column_attrs.h:1073
Node for the generated default value, column attribute.
Definition: parse_tree_column_attrs.h:542
Value_generator m_default_value_expression
Definition: parse_tree_column_attrs.h:574
void apply_gen_default_value(Value_generator **default_value_expression) override
Definition: parse_tree_column_attrs.h:551
PT_generated_default_val_column_attr(Item *expr)
Definition: parse_tree_column_attrs.h:546
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:543
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:569
bool contextualize(Column_parse_context *pc) override
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_column_attrs.h:556
Base class for generated column definition nodes.
Definition: parse_tree_column_attrs.h:1095
Item * expr
Definition: parse_tree_column_attrs.h:1099
Mem_root_array< PT_column_attr_base * > * opt_attrs
Definition: parse_tree_column_attrs.h:1100
PT_generated_field_def(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:1103
PT_field_def_base super
Definition: parse_tree_column_attrs.h:1096
const Virtual_or_stored virtual_or_stored
Definition: parse_tree_column_attrs.h:1098
bool contextualize(Parse_context *pc_arg) override
Definition: parse_tree_column_attrs.h:1111
Node for the JSON type.
Definition: parse_tree_column_attrs.h:940
PT_json_type()
Definition: parse_tree_column_attrs.h:942
const CHARSET_INFO * get_charset() const override
Definition: parse_tree_column_attrs.h:943
Node for the NOT NULL column attribute.
Definition: parse_tree_column_attrs.h:184
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:189
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:185
Node for the NULL column attribute.
Definition: parse_tree_column_attrs.h:169
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:176
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:171
Node for numeric types.
Definition: parse_tree_column_attrs.h:633
const char * get_dec() const override
Definition: parse_tree_column_attrs.h:679
PT_numeric_type(THD *thd, Numeric_type type_arg, const char *length, const char *dec, ulong options)
Definition: parse_tree_column_attrs.h:641
PT_numeric_type(THD *thd, Int_type type_arg, const char *length, ulong options)
Definition: parse_tree_column_attrs.h:660
std::remove_const< decltype(PT_type::type)>::type Parent_type
Definition: parse_tree_column_attrs.h:638
const char * dec
Definition: parse_tree_column_attrs.h:635
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:675
const char * get_length() const override
Definition: parse_tree_column_attrs.h:678
ulong options
Definition: parse_tree_column_attrs.h:636
const char * length
Definition: parse_tree_column_attrs.h:634
Node for the UPDATE NOW[([<precision>])] column attribute.
Definition: parse_tree_column_attrs.h:388
PT_on_update_column_attr(uint8 precision)
Definition: parse_tree_column_attrs.h:395
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:409
bool contextualize(Column_parse_context *pc) override
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_column_attrs.h:398
const uint8 precision
Definition: parse_tree_column_attrs.h:391
void apply_on_update_value(Item **value) const override
Definition: parse_tree_column_attrs.h:396
Item * item
Definition: parse_tree_column_attrs.h:392
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:389
Node for the PRIMARY [KEY] column attribute.
Definition: parse_tree_column_attrs.h:231
void apply_alter_info_flags(ulonglong *flags) const override
Definition: parse_tree_column_attrs.h:237
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:233
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:241
Node for the NOT SECONDARY column attribute.
Definition: parse_tree_column_attrs.h:197
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:203
void apply_type_flags(unsigned long *type_flags) const override
Definition: parse_tree_column_attrs.h:199
Node for the SERIAL DEFAULT VALUE column attribute.
Definition: parse_tree_column_attrs.h:442
void apply_alter_info_flags(ulonglong *flags) const override
Definition: parse_tree_column_attrs.h:449
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:443
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:446
bool contextualize(Column_parse_context *pc) override
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_column_attrs.h:452
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:460
Definition: parse_tree_column_attrs.h:925
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:929
PT_serial_type()
Definition: parse_tree_column_attrs.h:927
bool is_serial_type() const override
Definition: parse_tree_column_attrs.h:932
Node for spatial types.
Definition: parse_tree_column_attrs.h:872
const CHARSET_INFO * get_charset() const override
Definition: parse_tree_column_attrs.h:879
Field::geometry_type geo_type
Definition: parse_tree_column_attrs.h:873
uint get_uint_geom_type() const override
Definition: parse_tree_column_attrs.h:880
const char * get_length() const override
Definition: parse_tree_column_attrs.h:881
PT_spacial_type(Field::geometry_type geo_type)
Definition: parse_tree_column_attrs.h:876
Node for the SRID column attribute.
Definition: parse_tree_column_attrs.h:526
void apply_srid_modifier(std::optional< gis::srid_t > *srid) const override
Definition: parse_tree_column_attrs.h:534
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:538
PT_srid_column_attr(gis::srid_t srid)
Definition: parse_tree_column_attrs.h:532
gis::srid_t m_srid
Definition: parse_tree_column_attrs.h:529
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:527
Node for the STORAGE <DEFAULT|DISK|MEMORY> column attribute.
Definition: parse_tree_column_attrs.h:500
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:501
ha_storage_media media
Definition: parse_tree_column_attrs.h:503
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:509
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:520
bool contextualize(Column_parse_context *pc) override
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_column_attrs.h:513
PT_storage_media_column_attr(ha_storage_media media)
Definition: parse_tree_column_attrs.h:506
Node for the TIME, TIMESTAMP and DATETIME types.
Definition: parse_tree_column_attrs.h:814
const char * dec
Definition: parse_tree_column_attrs.h:815
const char * get_dec() const override
Definition: parse_tree_column_attrs.h:823
PT_time_type(Time_type time_type, const char *dec)
Definition: parse_tree_column_attrs.h:820
std::remove_const< decltype(PT_type::type)>::type Parent_type
Definition: parse_tree_column_attrs.h:817
Node for the TIMESTAMP type.
Definition: parse_tree_column_attrs.h:831
ulong type_flags
Definition: parse_tree_column_attrs.h:835
PT_timestamp_type(const char *dec)
Definition: parse_tree_column_attrs.h:838
const char * dec
Definition: parse_tree_column_attrs.h:834
const char * get_dec() const override
Definition: parse_tree_column_attrs.h:841
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:842
bool contextualize(Parse_context *pc) override
Definition: parse_tree_column_attrs.h:844
PT_type super
Definition: parse_tree_column_attrs.h:832
Base class for all column type nodes.
Definition: parse_tree_column_attrs.h:606
virtual bool is_serial_type() const
Definition: parse_tree_column_attrs.h:620
virtual ulong get_type_flags() const
Definition: parse_tree_column_attrs.h:614
virtual const char * get_length() const
Definition: parse_tree_column_attrs.h:615
virtual const CHARSET_INFO * get_charset() const
Definition: parse_tree_column_attrs.h:617
virtual List< String > * get_interval_list() const
Definition: parse_tree_column_attrs.h:619
const enum_field_types type
Definition: parse_tree_column_attrs.h:608
virtual uint get_uint_geom_type() const
Definition: parse_tree_column_attrs.h:618
virtual const char * get_dec() const
Definition: parse_tree_column_attrs.h:616
PT_type(enum_field_types type)
Definition: parse_tree_column_attrs.h:611
Node for the UNIQUE [KEY] column attribute.
Definition: parse_tree_column_attrs.h:211
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:221
void apply_alter_info_flags(ulonglong *flags) const override
Definition: parse_tree_column_attrs.h:217
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:213
Node for the YEAR type.
Definition: parse_tree_column_attrs.h:789
PT_year_type()
Definition: parse_tree_column_attrs.h:791
Base class for parse tree nodes (excluding the Parse_tree_root hierarchy)
Definition: parse_tree_node_base.h:139
virtual bool contextualize(Column_parse_context *pc)
Do all context-sensitive things and mark the node as contextualized.
Definition: parse_tree_node_base.h:187
This class represents a query block, aka a query specification, which is a query consisting of a SELE...
Definition: sql_lex.h:1160
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:168
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
void syntax_error_at(const YYLTYPE &location)
Definition: sql_class.h:4418
LEX * lex
Definition: sql_class.h:981
System_variables variables
Definition: sql_lexer_thd.h:62
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:2592
MEM_ROOT * mem_root
Definition: sql_lexer_thd.h:38
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:49
const char * ER_THD(const THD *thd, int mysql_errno)
Definition: derror.cc:103
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:222
This file contains the field type.
enum_field_types
Column types for MySQL.
Definition: field_types.h:53
@ MYSQL_TYPE_TIME2
Internal to MySQL.
Definition: field_types.h:73
@ MYSQL_TYPE_VARCHAR
Definition: field_types.h:69
@ MYSQL_TYPE_LONGLONG
Definition: field_types.h:62
@ MYSQL_TYPE_LONG_BLOB
Definition: field_types.h:83
@ MYSQL_TYPE_BLOB
Definition: field_types.h:84
@ MYSQL_TYPE_TINY
Definition: field_types.h:55
@ MYSQL_TYPE_SET
Definition: field_types.h:80
@ MYSQL_TYPE_JSON
Definition: field_types.h:77
@ MYSQL_TYPE_STRING
Definition: field_types.h:86
@ MYSQL_TYPE_ENUM
Definition: field_types.h:79
@ MYSQL_TYPE_TINY_BLOB
Definition: field_types.h:81
@ MYSQL_TYPE_BIT
Definition: field_types.h:70
@ MYSQL_TYPE_GEOMETRY
Definition: field_types.h:87
@ MYSQL_TYPE_MEDIUM_BLOB
Definition: field_types.h:82
@ MYSQL_TYPE_DATETIME2
Internal to MySQL.
Definition: field_types.h:72
@ MYSQL_TYPE_DATE
Definition: field_types.h:64
@ MYSQL_TYPE_TIMESTAMP2
Definition: field_types.h:71
@ MYSQL_TYPE_YEAR
Definition: field_types.h:67
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:7264
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_PLUGIN_IMPORT CHARSET_INFO my_charset_bin
Definition: ctype-bin.cc:511
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:115
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:49
Blob_type
Definition: parse_tree_column_attrs.h:741
Enum_type
Definition: parse_tree_column_attrs.h:884
Char_type
Definition: parse_tree_column_attrs.h:709
PT_enum_type_tmpl< Enum_type::ENUM > PT_enum_type
Node for the ENUM type.
Definition: parse_tree_column_attrs.h:916
PT_enum_type_tmpl< Enum_type::SET > PT_set_type
Node for the SET type.
Definition: parse_tree_column_attrs.h:923
Time_type
Definition: parse_tree_column_attrs.h:804
void move_cf_appliers(Parse_context *tddlpc, Column_parse_context *cpc)
Definition: parse_tree_helpers.cc:437
Int_type
Definition: parser_yystype.h:246
Numeric_type
Definition: parser_yystype.h:254
Virtual_or_stored
Definition: parser_yystype.h:244
column_format_type
Definition: field.h:190
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:654
case opt name
Definition: sslopt-case.h:33
Definition: m_ctype.h:385
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:4217
Definition: mysql_lex_string.h:40
Definition: mysql_lex_string.h:35
Environment data for the contextualization phase.
Definition: parse_tree_node_base.h:121
Query_block * select
Current Query_block object.
Definition: parse_tree_node_base.h:124
THD *const thd
Current thread handler.
Definition: parse_tree_node_base.h:122
MEM_ROOT * mem_root
Current MEM_ROOT.
Definition: parse_tree_node_base.h:123
Bison "location" class.
Definition: parse_location.h:43
unsigned int uint
Definition: uca9-dump.cc:75