MySQL 8.1.0
Source Code Documentation
parse_tree_column_attrs.h
Go to the documentation of this file.
1/* Copyright (c) 2016, 2023, 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 also distributed 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 included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef PARSE_TREE_COL_ATTRS_INCLUDED
24#define PARSE_TREE_COL_ATTRS_INCLUDED
25
26#include <assert.h>
27#include <sys/types.h> // ulong, uint. TODO: replace with cstdint
28
29#include <optional>
30#include <type_traits>
31#include <vector>
32
33#include "field_types.h"
34#include "lex_string.h"
35#include "my_alloc.h"
36#include "my_base.h"
37#include "my_compiler.h"
38
39#include "my_inttypes.h"
40#include "my_sys.h"
42#include "mysql_com.h"
43#include "mysqld_error.h"
44#include "sql/derror.h"
45#include "sql/field.h"
46#include "sql/gis/srid.h"
47#include "sql/item.h"
48#include "sql/item_timefunc.h"
49#include "sql/mem_root_array.h"
50#include "sql/parse_location.h"
51#include "sql/parse_tree_helpers.h" // move_cf_appliers
53#include "sql/parser_yystype.h"
54#include "sql/sql_alter.h"
55#include "sql/sql_check_constraint.h" // Sql_check_constraint_spec
56#include "sql/sql_class.h"
57#include "sql/sql_error.h"
58#include "sql/sql_lex.h"
59#include "sql/sql_list.h"
60#include "sql/sql_parse.h"
62
63class String;
64
65/**
66 Parse context for column type attribute specific parse tree nodes.
67
68 For internal use in the contextualization code.
69
70 @ingroup ptn_column_attrs ptn_gcol_attrs
71*/
73 const bool is_generated; ///< Owner column is a generated one.
74 std::vector<CreateFieldApplier> cf_appliers;
75 Column_parse_context(THD *thd_arg, Query_block *select_arg, bool is_generated)
76 : Parse_context(thd_arg, select_arg), is_generated(is_generated) {}
77};
78
79/**
80 Base class for all column attributes in @SQL{CREATE/ALTER TABLE}
81
82 @ingroup ptn_column_attrs ptn_gcol_attrs
83*/
84class PT_column_attr_base : public Parse_tree_node_tmpl<Column_parse_context> {
85 protected:
86 explicit PT_column_attr_base(const POS &pos)
88
89 public:
91
92 virtual void apply_type_flags(ulong *) const {}
93 virtual void apply_alter_info_flags(ulonglong *) const {}
94 virtual void apply_comment(LEX_CSTRING *) const {}
95 virtual void apply_default_value(Item **) const {}
97 virtual void apply_on_update_value(Item **) const {}
98 virtual void apply_srid_modifier(std::optional<gis::srid_t> *) const {}
100 const CHARSET_INFO **to [[maybe_unused]],
101 bool *has_explicit_collation
102 [[maybe_unused]]) const {
103 return false;
104 }
106 Sql_check_constraint_spec_list *check_const_list [[maybe_unused]]) {
107 return false;
108 }
109
110 /**
111 Check for the [NOT] ENFORCED characteristic.
112
113 @returns true if the [NOT] ENFORCED follows the CHECK(...) clause,
114 false otherwise.
115 */
116 virtual bool has_constraint_enforcement() const { return false; }
117
118 /**
119 Check if constraint is enforced.
120 Method must be called only when has_constraint_enforcement() is true (i.e
121 when [NOT] ENFORCED follows the CHECK(...) clause).
122
123 @returns true if constraint is enforced.
124 false otherwise.
125 */
126 virtual bool is_constraint_enforced() const { return false; }
127
128 /**
129 Update the ENFORCED/NOT ENFORCED state of the CHECK constraint.
130
131 @param enforced true if ENFORCED, false if NOT ENFORCED.
132
133 @returns false if success, true if error (e.g. if [NOT] ENFORCED follows
134 something other than the CHECK clause.)
135 */
136 virtual bool set_constraint_enforcement(bool enforced [[maybe_unused]]) {
137 return true; // error
138 }
139};
140
141/**
142 Node for the @SQL{NULL} column attribute
143
144 @ingroup ptn_column_attrs
145*/
147 public:
148 explicit PT_null_column_attr(const POS &pos) : PT_column_attr_base(pos) {}
149 void apply_type_flags(ulong *type_flags) const override {
150 *type_flags &= ~NOT_NULL_FLAG;
151 *type_flags |= EXPLICIT_NULL_FLAG;
152 }
153};
154
155/**
156 Node for the @SQL{NOT NULL} column attribute
157
158 @ingroup ptn_column_attrs
159*/
161 public:
162 explicit PT_not_null_column_attr(const POS &pos) : PT_column_attr_base(pos) {}
163 void apply_type_flags(ulong *type_flags) const override {
164 *type_flags |= NOT_NULL_FLAG;
165 }
166};
167
168/**
169 Node for the @SQL{NOT SECONDARY} column attribute
170
171 @ingroup ptn_column_attrs
172*/
174 public:
175 explicit PT_secondary_column_attr(const POS &pos)
176 : PT_column_attr_base(pos) {}
177 void apply_type_flags(unsigned long *type_flags) const override {
178 *type_flags |= NOT_SECONDARY_FLAG;
179 }
180};
181
182/**
183 Node for the @SQL{UNIQUE [KEY]} column attribute
184
185 @ingroup ptn_column_attrs
186*/
188 public:
189 explicit PT_unique_key_column_attr(const POS &pos)
190 : PT_column_attr_base(pos) {}
191
192 void apply_type_flags(ulong *type_flags) const override {
193 *type_flags |= UNIQUE_FLAG;
194 }
195
196 void apply_alter_info_flags(ulonglong *flags) const override {
198 }
199};
200
201/**
202 Node for the @SQL{PRIMARY [KEY]} column attribute
203
204 @ingroup ptn_column_attrs
205*/
207 public:
208 explicit PT_primary_key_column_attr(const POS &pos)
209 : PT_column_attr_base(pos) {}
210
211 void apply_type_flags(ulong *type_flags) const override {
212 *type_flags |= PRI_KEY_FLAG | NOT_NULL_FLAG;
213 }
214
215 void apply_alter_info_flags(ulonglong *flags) const override {
217 }
218};
219
220/**
221 Node for the @SQL{[CONSTRAINT [symbol]] CHECK '(' expr ')'} column attribute.
222
223 @ingroup ptn_column_attrs
224*/
228
229 public:
231 Item *expr)
232 : super(pos) {
234 col_cc_spec.check_expr = expr;
235 }
236
237 bool set_constraint_enforcement(bool enforced) override {
238 col_cc_spec.is_enforced = enforced;
239 return false;
240 }
241
242 void apply_alter_info_flags(ulonglong *flags) const override {
244 }
245
247 Sql_check_constraint_spec_list *check_const_list) override {
248 assert(check_const_list != nullptr);
249 return (check_const_list->push_back(&col_cc_spec));
250 }
251
253 return (super::do_contextualize(pc) ||
255 }
256};
257
258/**
259 Node for the @SQL{[NOT] ENFORCED} column attribute.
260
261 @ingroup ptn_column_attrs
262*/
264 public:
265 explicit PT_constraint_enforcement_attr(const POS &pos, bool enforced)
266 : PT_column_attr_base(pos), m_enforced(enforced) {}
267
268 bool has_constraint_enforcement() const override { return true; }
269
270 bool is_constraint_enforced() const override { return m_enforced; }
271
272 private:
273 const bool m_enforced;
274};
275
276/**
277 Node for the @SQL{COMMENT @<comment@>} column attribute
278
279 @ingroup ptn_column_attrs
280*/
283
284 public:
285 explicit PT_comment_column_attr(const POS &pos, const LEX_CSTRING &comment)
287
288 void apply_comment(LEX_CSTRING *to) const override { *to = comment; }
289};
290
291/**
292 Node for the @SQL{COLLATE @<collation@>} column attribute
293
294 @ingroup ptn_column_attrs
295*/
297 public:
300 assert(m_collation != nullptr);
301 }
302
304 bool *has_explicit_collation) const override {
305 if (*has_explicit_collation) {
306 pc->thd->syntax_error_at(m_pos, ER_INVALID_MULTIPLE_CLAUSES, "COLLATE");
307 return true;
308 }
309 *has_explicit_collation = true;
311 }
312
313 private:
315};
316
317// Specific to non-generated columns only:
318
319/**
320 Node for the @SQL{DEFAULT @<expression@>} column attribute
321
322 @ingroup ptn_not_gcol_attr
323*/
326
328
329 public:
330 explicit PT_default_column_attr(const POS &pos, Item *item)
331 : super(pos), item(item) {}
332 void apply_default_value(Item **value) const override { *value = item; }
333
335 if (pc->is_generated) {
336 my_error(ER_WRONG_USAGE, MYF(0), "DEFAULT", "generated column");
337 return true;
338 }
339 return super::do_contextualize(pc) || item->itemize(pc, &item);
340 }
341 void apply_type_flags(ulong *type_flags) const override {
342 if (item->type() == Item::NULL_ITEM) *type_flags |= EXPLICIT_NULL_FLAG;
343 }
344};
345
346/**
347 Node for the @SQL{UPDATE NOW[([@<precision@>])]} column attribute
348
349 @ingroup ptn_not_gcol_attr
350*/
353
355 Item *item = nullptr;
356
357 public:
359 : super(pos), precision(precision) {}
360 void apply_on_update_value(Item **value) const override { *value = item; }
361
363 if (pc->is_generated) {
364 my_error(ER_WRONG_USAGE, MYF(0), "ON UPDATE", "generated column");
365 return true;
366 }
367 if (super::do_contextualize(pc)) return true;
368
370 return item == nullptr;
371 }
372};
373
374/**
375 Node for the @SQL{AUTO_INCREMENT} column attribute
376
377 @ingroup ptn_not_gcol_attr
378*/
381
382 public:
384 : PT_column_attr_base(pos) {}
385
386 void apply_type_flags(ulong *type_flags) const override {
387 *type_flags |= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG;
388 }
390 if (pc->is_generated) {
391 my_error(ER_WRONG_USAGE, MYF(0), "AUTO_INCREMENT", "generated column");
392 return true;
393 }
394 return super::do_contextualize(pc);
395 }
396};
397
398/**
399 Node for the @SQL{SERIAL DEFAULT VALUE} column attribute
400
401 @ingroup ptn_not_gcol_attr
402*/
405
406 public:
407 explicit PT_serial_default_value_column_attr(const POS &pos) : super(pos) {}
408
409 void apply_type_flags(ulong *type_flags) const override {
411 }
412 void apply_alter_info_flags(ulonglong *flags) const override {
414 }
416 if (pc->is_generated) {
417 my_error(ER_WRONG_USAGE, MYF(0), "SERIAL DEFAULT VALUE",
418 "generated column");
419 return true;
420 }
421 return super::do_contextualize(pc);
422 }
423};
424
425/**
426 Node for the @SQL{COLUMN_FORMAT @<DEFAULT|FIXED|DYNAMIC@>} column attribute
427
428 @ingroup ptn_not_gcol_attr
429*/
432
434
435 public:
438 : super(pos), format(format) {}
439
440 void apply_type_flags(ulong *type_flags) const override {
441 *type_flags &= ~(FIELD_FLAGS_COLUMN_FORMAT_MASK);
442 *type_flags |= format << FIELD_FLAGS_COLUMN_FORMAT;
443 }
445 if (pc->is_generated) {
446 my_error(ER_WRONG_USAGE, MYF(0), "COLUMN_FORMAT", "generated column");
447 return true;
448 }
449 return super::do_contextualize(pc);
450 }
451};
452
453/**
454 Node for the @SQL{STORAGE @<DEFAULT|DISK|MEMORY@>} column attribute
455
456 @ingroup ptn_not_gcol_attr
457*/
460
462
463 public:
465 : super(pos), media(media) {}
466
467 void apply_type_flags(ulong *type_flags) const override {
468 *type_flags &= ~(FIELD_FLAGS_STORAGE_MEDIA_MASK);
469 *type_flags |= media << FIELD_FLAGS_STORAGE_MEDIA;
470 }
472 if (pc->is_generated) {
473 my_error(ER_WRONG_USAGE, MYF(0), "STORAGE", "generated column");
474 return true;
475 }
476 return super::do_contextualize(pc);
477 }
478};
479
480/// Node for the SRID column attribute
483
485
486 public:
487 explicit PT_srid_column_attr(const POS &pos, gis::srid_t srid)
488 : super(pos), m_srid(srid) {}
489
490 void apply_srid_modifier(std::optional<gis::srid_t> *srid) const override {
491 *srid = m_srid;
492 }
493};
494
495/// Node for the generated default value, column attribute
498
499 public:
501 : super(pos) {
504 }
505
507 Value_generator **default_value_expression) override {
508 *default_value_expression = &m_default_value_expression;
509 }
510
512 // GC and default value expressions are mutually exclusive and thus only
513 // one is allowed to be present on the same column definition.
514 if (pc->is_generated) {
515 my_error(ER_WRONG_USAGE, MYF(0), "DEFAULT", "generated column");
516 return true;
517 }
518 Parse_context expr_pc(pc->thd, pc->select);
519 return super::do_contextualize(pc) ||
522 }
523
524 private:
526};
527
528/**
529 Node for the @SQL{VISIBLE|INVISIBLE} column attribute
530
531 @ingroup ptn_column_attrs
532*/
535
536 public:
537 explicit PT_column_visibility_attr(const POS &pos, bool is_visible)
538 : super(pos), m_is_visible(is_visible) {}
539 void apply_type_flags(unsigned long *type_flags) const override {
540 *type_flags &= ~FIELD_IS_INVISIBLE;
541 if (!m_is_visible) *type_flags |= FIELD_IS_INVISIBLE;
542 }
543
544 private:
545 const bool m_is_visible;
546};
547
548// Type nodes:
549
550/**
551 Base class for all column type nodes
552
553 @ingroup ptn_column_types
554*/
555class PT_type : public Parse_tree_node {
556 public:
558
559 protected:
560 explicit PT_type(const POS &pos, enum_field_types type)
561 : Parse_tree_node(pos), type(type) {}
562
563 public:
564 virtual ulong get_type_flags() const { return 0; }
565 virtual const char *get_length() const { return nullptr; }
566 virtual const char *get_dec() const { return nullptr; }
567 virtual const CHARSET_INFO *get_charset() const { return nullptr; }
568 virtual uint get_uint_geom_type() const { return 0; }
569 virtual List<String> *get_interval_list() const { return nullptr; }
570 virtual bool is_serial_type() const { return false; }
571};
572
573/**
574 Node for numeric types
575
576 Type list:
577 * NUMERIC, REAL, DOUBLE, DECIMAL and FIXED,
578 * INTEGER, INT, INT1, INT2, INT3, INT4, TINYINT, SMALLINT, MEDIUMINT and
579 BIGINT.
580
581 @ingroup ptn_column_types
582*/
583class PT_numeric_type : public PT_type {
584 const char *length;
585 const char *dec;
586 ulong options;
587
588 using Parent_type = std::remove_const<decltype(PT_type::type)>::type;
589
590 public:
591 PT_numeric_type(const POS &pos, THD *thd, Numeric_type type_arg,
592 const char *length, const char *dec, ulong options)
593 : PT_type(pos, static_cast<Parent_type>(type_arg)),
594 length(length),
595 dec(dec),
597 assert((options & ~(UNSIGNED_FLAG | ZEROFILL_FLAG)) == 0);
598
599 if (type_arg != Numeric_type::DECIMAL && dec != nullptr) {
601 ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT,
602 ER_THD(thd, ER_WARN_DEPRECATED_FLOAT_DIGITS));
603 }
604 if (options & UNSIGNED_FLAG) {
606 ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT,
607 ER_THD(thd, ER_WARN_DEPRECATED_FLOAT_UNSIGNED));
608 }
609 }
610 PT_numeric_type(const POS &pos, THD *thd, Int_type type_arg,
611 const char *length, ulong options)
612 : PT_type(pos, static_cast<enum_field_types>(type_arg)),
613 length(length),
614 dec(nullptr),
616 assert((options & ~(UNSIGNED_FLAG | ZEROFILL_FLAG)) == 0);
617
618 if (length != nullptr) {
620 ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT,
621 ER_THD(thd, ER_WARN_DEPRECATED_INTEGER_DISPLAY_WIDTH));
622 }
623 }
624
625 ulong get_type_flags() const override {
627 }
628 const char *get_length() const override { return length; }
629 const char *get_dec() const override { return dec; }
630};
631
632/**
633 Node for the BIT type
634
635 @ingroup ptn_column_types
636*/
637class PT_bit_type : public PT_type {
638 const char *length;
639
640 public:
641 explicit PT_bit_type(const POS &pos)
642 : PT_type(pos, MYSQL_TYPE_BIT), length("1") {}
643 explicit PT_bit_type(const POS &pos, const char *length)
645
646 const char *get_length() const override { return length; }
647};
648
649/**
650 Node for the BOOL/BOOLEAN type
651
652 @ingroup ptn_column_types
653*/
654class PT_boolean_type : public PT_type {
655 public:
656 explicit PT_boolean_type(const POS &pos) : PT_type(pos, MYSQL_TYPE_TINY) {}
657 const char *get_length() const override { return "1"; }
658};
659
660enum class Char_type : ulong {
664};
665
666class PT_char_type : public PT_type {
667 const char *length;
669 const bool force_binary;
670
671 using Parent_type = std::remove_const<decltype(PT_type::type)>::type;
672
673 public:
674 PT_char_type(const POS &pos, Char_type char_type, const char *length,
675 const CHARSET_INFO *charset, bool force_binary = false)
676 : PT_type(pos, static_cast<Parent_type>(char_type)),
677 length(length),
680 assert(charset == nullptr || !force_binary);
681 }
682 PT_char_type(const POS &pos, Char_type char_type, const CHARSET_INFO *charset,
683 bool force_binary = false)
684 : PT_char_type(pos, char_type, "1", charset, force_binary) {}
685 ulong get_type_flags() const override {
686 return force_binary ? BINCMP_FLAG : 0;
687 }
688 const char *get_length() const override { return length; }
689 const CHARSET_INFO *get_charset() const override { return charset; }
690};
691
692enum class Blob_type {
696};
697
698/**
699 Node for BLOB types
700
701 Types: BLOB, TINYBLOB, MEDIUMBLOB, LONGBLOB, LONG, LONG VARBINARY,
702 LONG VARCHAR, TEXT, TINYTEXT, MEDIUMTEXT, LONGTEXT.
703
704 @ingroup ptn_column_types
705*/
706class PT_blob_type : public PT_type {
707 const char *length;
709 const bool force_binary;
710
711 using Parent_type = std::remove_const<decltype(PT_type::type)>::type;
712
713 public:
714 PT_blob_type(const POS &pos, Blob_type blob_type, const CHARSET_INFO *charset,
715 bool force_binary = false)
716 : PT_type(pos, static_cast<Parent_type>(blob_type)),
720 assert(charset == nullptr || !force_binary);
721 }
722 explicit PT_blob_type(const POS &pos, const char *length)
723 : PT_type(pos, MYSQL_TYPE_BLOB),
724 length(length),
726 force_binary(false) {}
727
728 ulong get_type_flags() const override {
729 return force_binary ? BINCMP_FLAG : 0;
730 }
731 const CHARSET_INFO *get_charset() const override { return charset; }
732 const char *get_length() const override { return length; }
733};
734
735/**
736 Node for the YEAR type
737
738 @ingroup ptn_column_types
739*/
740class PT_year_type : public PT_type {
741 public:
742 explicit PT_year_type(const POS &pos) : PT_type(pos, MYSQL_TYPE_YEAR) {}
743};
744
745/**
746 Node for the DATE type
747
748 @ingroup ptn_column_types
749*/
750class PT_date_type : public PT_type {
751 public:
752 explicit PT_date_type(const POS &pos) : PT_type(pos, MYSQL_TYPE_DATE) {}
753};
754
755enum class Time_type : ulong {
758};
759
760/**
761 Node for the TIME, TIMESTAMP and DATETIME types
762
763 @ingroup ptn_column_types
764*/
765class PT_time_type : public PT_type {
766 const char *dec;
767
768 using Parent_type = std::remove_const<decltype(PT_type::type)>::type;
769
770 public:
771 PT_time_type(const POS &pos, Time_type time_type, const char *dec)
772 : PT_type(pos, static_cast<Parent_type>(time_type)), dec(dec) {}
773
774 const char *get_dec() const override { return dec; }
775};
776
777/**
778 Node for the TIMESTAMP type
779
780 @ingroup ptn_column_types
781*/
783 typedef PT_type super;
784
785 const char *dec;
787
788 public:
789 explicit PT_timestamp_type(const POS &pos, const char *dec)
791
792 const char *get_dec() const override { return dec; }
793 ulong get_type_flags() const override { return type_flags; }
794
795 bool do_contextualize(Parse_context *pc) override {
796 if (super::do_contextualize(pc)) return true;
797 /*
798 TIMESTAMP fields are NOT NULL by default, unless the variable
799 explicit_defaults_for_timestamp is true.
800 */
801 if (!pc->thd->variables.explicit_defaults_for_timestamp)
803 /*
804 To flag the current statement as dependent for binary
805 logging on the session var. Extra copying to Lex is
806 done in case prepared stmt.
807 */
810
811 return false;
812 }
813};
814
815/**
816 Node for spatial types
817
818 Types: GEOMETRY, GEOMCOLLECTION/GEOMETRYCOLLECTION, POINT, MULTIPOINT,
819 LINESTRING, MULTILINESTRING, POLYGON, MULTIPOLYGON
820
821 @ingroup ptn_column_types
822*/
823class PT_spacial_type : public PT_type {
825
826 public:
829
830 const CHARSET_INFO *get_charset() const override { return &my_charset_bin; }
831 uint get_uint_geom_type() const override { return geo_type; }
832 const char *get_length() const override { return nullptr; }
833};
834
836
837template <Enum_type enum_type>
841 const bool force_binary;
842
843 using Parent_type = std::remove_const<decltype(PT_type::type)>::type;
844
845 public:
847 const CHARSET_INFO *charset, bool force_binary)
848 : PT_type(pos, static_cast<Parent_type>(enum_type)),
852 assert(charset == nullptr || !force_binary);
853 }
854
855 const CHARSET_INFO *get_charset() const override { return charset; }
856 ulong get_type_flags() const override {
857 return force_binary ? BINCMP_FLAG : 0;
858 }
859 List<String> *get_interval_list() const override { return interval_list; }
860};
861
862/**
863 Node for the ENUM type
864
865 @ingroup ptn_column_types
866*/
868
869/**
870 Node for the SET type
871
872 @ingroup ptn_column_types
873*/
875
876class PT_serial_type : public PT_type {
877 public:
878 explicit PT_serial_type(const POS &pos) : PT_type(pos, MYSQL_TYPE_LONGLONG) {}
879
880 ulong get_type_flags() const override {
882 }
883 bool is_serial_type() const override { return true; }
884};
885
886/**
887 Node for the JSON type
888
889 @ingroup ptn_column_types
890*/
891class PT_json_type : public PT_type {
892 public:
893 explicit PT_json_type(const POS &pos) : PT_type(pos, MYSQL_TYPE_JSON) {}
894 const CHARSET_INFO *get_charset() const override { return &my_charset_bin; }
895};
896
897/**
898 Base class for both generated and regular column definitions
899
900 @ingroup ptn_create_table
901*/
905
906 public:
908 ulong type_flags = 0;
909 const char *length = nullptr;
910 const char *dec = nullptr;
911 const CHARSET_INFO *charset = nullptr;
917 Item *default_value = nullptr;
920 /// Holds the expression to generate default values
922 std::optional<gis::srid_t> m_srid{};
923 // List of column check constraint's specification.
925
926 protected:
928
929 explicit PT_field_def_base(const POS &pos, PT_type *type_node)
930 : super(pos), type_node(type_node) {}
931
932 public:
933 bool do_contextualize(Parse_context *pc) override {
935 return true;
936
940 dec = type_node->get_dec();
946 if (check_const_spec_list == nullptr) return true; // OOM
947 return false;
948 }
949
950 protected:
951 template <class T>
953 Mem_root_array<T *> *attrs) {
954 if (attrs != nullptr) {
955 for (auto attr : *attrs) {
956 if (attr->contextualize(pc)) return true;
957 attr->apply_type_flags(&type_flags);
958 attr->apply_alter_info_flags(&alter_info_flags);
959 attr->apply_comment(&comment);
960 attr->apply_default_value(&default_value);
961 attr->apply_gen_default_value(&default_val_info);
962 attr->apply_on_update_value(&on_update_value);
963 attr->apply_srid_modifier(&m_srid);
964 if (attr->apply_collation(pc, &charset, &has_explicit_collation))
965 return true;
966 if (attr->add_check_constraints(check_const_spec_list)) return true;
967 }
968 }
969 return false;
970 }
971};
972
973/**
974 Base class for regular (non-generated) column definition nodes
975
976 @ingroup ptn_create_table
977*/
980
982
983 public:
984 PT_field_def(const POS &pos, PT_type *type_node_arg,
986 : super(pos, type_node_arg), opt_attrs(opt_attrs) {}
987
988 bool do_contextualize(Parse_context *pc_arg) override {
989 Column_parse_context pc(pc_arg->thd, pc_arg->select, false);
991 return true;
992
993 move_cf_appliers(pc_arg, &pc);
994 return false;
995 }
996};
997
998/**
999 Base class for generated column definition nodes
1000
1001 @ingroup ptn_create_table
1002*/
1005
1009
1010 public:
1011 PT_generated_field_def(const POS &pos, PT_type *type_node_arg, Item *expr,
1014 : super(pos, type_node_arg),
1016 expr(expr),
1018
1019 bool do_contextualize(Parse_context *pc_arg) override {
1020 Column_parse_context pc(pc_arg->thd, pc_arg->select, true);
1022 expr->itemize(&pc, &expr))
1023 return true;
1024
1025 // column of type serial cannot be generated
1026 if (type_node->is_serial_type()) {
1027 my_error(ER_WRONG_USAGE, MYF(0), "SERIAL", "generated column");
1028 return true;
1029 }
1030
1032 if (gcol_info == nullptr) return true; // OOM
1037
1038 return false;
1039 }
1040};
1041
1043
1044#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:1180
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:853
@ NULL_ITEM
Definition: item.h:897
virtual bool itemize(Parse_context *pc, Item **res) final
The same as contextualize() but with additional parameter.
Definition: item.h:1175
virtual enum Type type() const =0
Definition: sql_list.h:433
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:185
Node for the AUTO_INCREMENT column attribute.
Definition: parse_tree_column_attrs.h:379
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:380
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:386
PT_auto_increment_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:383
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:389
Node for the BIT type.
Definition: parse_tree_column_attrs.h:637
PT_bit_type(const POS &pos)
Definition: parse_tree_column_attrs.h:641
const char * get_length() const override
Definition: parse_tree_column_attrs.h:646
const char * length
Definition: parse_tree_column_attrs.h:638
PT_bit_type(const POS &pos, const char *length)
Definition: parse_tree_column_attrs.h:643
Node for BLOB types.
Definition: parse_tree_column_attrs.h:706
const CHARSET_INFO * charset
Definition: parse_tree_column_attrs.h:708
PT_blob_type(const POS &pos, Blob_type blob_type, const CHARSET_INFO *charset, bool force_binary=false)
Definition: parse_tree_column_attrs.h:714
const char * length
Definition: parse_tree_column_attrs.h:707
PT_blob_type(const POS &pos, const char *length)
Definition: parse_tree_column_attrs.h:722
const char * get_length() const override
Definition: parse_tree_column_attrs.h:732
const CHARSET_INFO * get_charset() const override
Definition: parse_tree_column_attrs.h:731
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:728
std::remove_const< decltype(PT_type::type)>::type Parent_type
Definition: parse_tree_column_attrs.h:711
const bool force_binary
Definition: parse_tree_column_attrs.h:709
Node for the BOOL/BOOLEAN type.
Definition: parse_tree_column_attrs.h:654
const char * get_length() const override
Definition: parse_tree_column_attrs.h:657
PT_boolean_type(const POS &pos)
Definition: parse_tree_column_attrs.h:656
Definition: parse_tree_column_attrs.h:666
std::remove_const< decltype(PT_type::type)>::type Parent_type
Definition: parse_tree_column_attrs.h:671
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:674
const char * length
Definition: parse_tree_column_attrs.h:667
const char * get_length() const override
Definition: parse_tree_column_attrs.h:688
PT_char_type(const POS &pos, Char_type char_type, const CHARSET_INFO *charset, bool force_binary=false)
Definition: parse_tree_column_attrs.h:682
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:685
const CHARSET_INFO * get_charset() const override
Definition: parse_tree_column_attrs.h:689
const CHARSET_INFO * charset
Definition: parse_tree_column_attrs.h:668
const bool force_binary
Definition: parse_tree_column_attrs.h:669
Node for the [CONSTRAINT [symbol]] CHECK '(' expr ')' column attribute.
Definition: parse_tree_column_attrs.h:225
void apply_alter_info_flags(ulonglong *flags) const override
Definition: parse_tree_column_attrs.h:242
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:226
bool add_check_constraints(Sql_check_constraint_spec_list *check_const_list) override
Definition: parse_tree_column_attrs.h:246
bool set_constraint_enforcement(bool enforced) override
Update the ENFORCED/NOT ENFORCED state of the CHECK constraint.
Definition: parse_tree_column_attrs.h:237
PT_check_constraint_column_attr(const POS &pos, LEX_STRING &name, Item *expr)
Definition: parse_tree_column_attrs.h:230
Sql_check_constraint_spec col_cc_spec
Definition: parse_tree_column_attrs.h:227
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:252
Node for the COLLATE <collation> column attribute.
Definition: parse_tree_column_attrs.h:296
bool apply_collation(Column_parse_context *pc, const CHARSET_INFO **to, bool *has_explicit_collation) const override
Definition: parse_tree_column_attrs.h:303
PT_collate_column_attr(const POS &pos, const CHARSET_INFO *collation)
Definition: parse_tree_column_attrs.h:298
const CHARSET_INFO *const m_collation
Definition: parse_tree_column_attrs.h:314
Base class for all column attributes in CREATE/ALTER TABLE
Definition: parse_tree_column_attrs.h:84
decltype(Alter_info::flags) alter_info_flags_t
Definition: parse_tree_column_attrs.h:90
virtual bool is_constraint_enforced() const
Check if constraint is enforced.
Definition: parse_tree_column_attrs.h:126
virtual bool set_constraint_enforcement(bool enforced)
Update the ENFORCED/NOT ENFORCED state of the CHECK constraint.
Definition: parse_tree_column_attrs.h:136
virtual void apply_alter_info_flags(ulonglong *) const
Definition: parse_tree_column_attrs.h:93
virtual void apply_srid_modifier(std::optional< gis::srid_t > *) const
Definition: parse_tree_column_attrs.h:98
virtual bool apply_collation(Column_parse_context *, const CHARSET_INFO **to, bool *has_explicit_collation) const
Definition: parse_tree_column_attrs.h:99
virtual void apply_gen_default_value(Value_generator **)
Definition: parse_tree_column_attrs.h:96
PT_column_attr_base(const POS &pos)
Definition: parse_tree_column_attrs.h:86
virtual void apply_on_update_value(Item **) const
Definition: parse_tree_column_attrs.h:97
virtual void apply_type_flags(ulong *) const
Definition: parse_tree_column_attrs.h:92
virtual void apply_comment(LEX_CSTRING *) const
Definition: parse_tree_column_attrs.h:94
virtual bool add_check_constraints(Sql_check_constraint_spec_list *check_const_list)
Definition: parse_tree_column_attrs.h:105
virtual bool has_constraint_enforcement() const
Check for the [NOT] ENFORCED characteristic.
Definition: parse_tree_column_attrs.h:116
virtual void apply_default_value(Item **) const
Definition: parse_tree_column_attrs.h:95
Node for the COLUMN_FORMAT <DEFAULT|FIXED|DYNAMIC> column attribute.
Definition: parse_tree_column_attrs.h:430
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:444
PT_column_format_column_attr(const POS &pos, column_format_type format)
Definition: parse_tree_column_attrs.h:436
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:431
column_format_type format
Definition: parse_tree_column_attrs.h:433
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:440
Node for the VISIBLE|INVISIBLE column attribute.
Definition: parse_tree_column_attrs.h:533
PT_column_visibility_attr(const POS &pos, bool is_visible)
Definition: parse_tree_column_attrs.h:537
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:534
void apply_type_flags(unsigned long *type_flags) const override
Definition: parse_tree_column_attrs.h:539
const bool m_is_visible
Definition: parse_tree_column_attrs.h:545
Node for the COMMENT <comment> column attribute.
Definition: parse_tree_column_attrs.h:281
void apply_comment(LEX_CSTRING *to) const override
Definition: parse_tree_column_attrs.h:288
PT_comment_column_attr(const POS &pos, const LEX_CSTRING &comment)
Definition: parse_tree_column_attrs.h:285
const LEX_CSTRING comment
Definition: parse_tree_column_attrs.h:282
Node for the [NOT] ENFORCED column attribute.
Definition: parse_tree_column_attrs.h:263
bool has_constraint_enforcement() const override
Check for the [NOT] ENFORCED characteristic.
Definition: parse_tree_column_attrs.h:268
bool is_constraint_enforced() const override
Check if constraint is enforced.
Definition: parse_tree_column_attrs.h:270
PT_constraint_enforcement_attr(const POS &pos, bool enforced)
Definition: parse_tree_column_attrs.h:265
const bool m_enforced
Definition: parse_tree_column_attrs.h:273
Node for the DATE type.
Definition: parse_tree_column_attrs.h:750
PT_date_type(const POS &pos)
Definition: parse_tree_column_attrs.h:752
Node for the DEFAULT <expression> column attribute.
Definition: parse_tree_column_attrs.h:324
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:341
void apply_default_value(Item **value) const override
Definition: parse_tree_column_attrs.h:332
PT_default_column_attr(const POS &pos, Item *item)
Definition: parse_tree_column_attrs.h:330
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:334
Item * item
Definition: parse_tree_column_attrs.h:327
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:325
Definition: parse_tree_column_attrs.h:838
PT_enum_type_tmpl(const POS &pos, List< String > *interval_list, const CHARSET_INFO *charset, bool force_binary)
Definition: parse_tree_column_attrs.h:846
List< String > *const interval_list
Definition: parse_tree_column_attrs.h:839
const CHARSET_INFO * charset
Definition: parse_tree_column_attrs.h:840
const bool force_binary
Definition: parse_tree_column_attrs.h:841
List< String > * get_interval_list() const override
Definition: parse_tree_column_attrs.h:859
const CHARSET_INFO * get_charset() const override
Definition: parse_tree_column_attrs.h:855
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:856
std::remove_const< decltype(PT_type::type)>::type Parent_type
Definition: parse_tree_column_attrs.h:843
Base class for both generated and regular column definitions.
Definition: parse_tree_column_attrs.h:902
bool do_contextualize(Parse_context *pc) override
Definition: parse_tree_column_attrs.h:933
bool contextualize_attrs(Column_parse_context *pc, Mem_root_array< T * > *attrs)
Definition: parse_tree_column_attrs.h:952
LEX_CSTRING comment
Definition: parse_tree_column_attrs.h:916
enum_field_types type
Definition: parse_tree_column_attrs.h:907
decltype(Alter_info::flags) alter_info_flags_t
Definition: parse_tree_column_attrs.h:904
Value_generator * gcol_info
Definition: parse_tree_column_attrs.h:919
const CHARSET_INFO * charset
Definition: parse_tree_column_attrs.h:911
List< String > * interval_list
Definition: parse_tree_column_attrs.h:914
const char * dec
Definition: parse_tree_column_attrs.h:910
bool has_explicit_collation
Definition: parse_tree_column_attrs.h:912
Item * on_update_value
Definition: parse_tree_column_attrs.h:918
std::optional< gis::srid_t > m_srid
Definition: parse_tree_column_attrs.h:922
const char * length
Definition: parse_tree_column_attrs.h:909
Parse_tree_node super
Definition: parse_tree_column_attrs.h:903
PT_type * type_node
Definition: parse_tree_column_attrs.h:927
alter_info_flags_t alter_info_flags
Definition: parse_tree_column_attrs.h:915
Item * default_value
Definition: parse_tree_column_attrs.h:917
Value_generator * default_val_info
Holds the expression to generate default values.
Definition: parse_tree_column_attrs.h:921
PT_field_def_base(const POS &pos, PT_type *type_node)
Definition: parse_tree_column_attrs.h:929
Sql_check_constraint_spec_list * check_const_spec_list
Definition: parse_tree_column_attrs.h:924
ulong type_flags
Definition: parse_tree_column_attrs.h:908
uint uint_geom_type
Definition: parse_tree_column_attrs.h:913
Base class for regular (non-generated) column definition nodes.
Definition: parse_tree_column_attrs.h:978
PT_field_def_base super
Definition: parse_tree_column_attrs.h:979
Mem_root_array< PT_column_attr_base * > * opt_attrs
Definition: parse_tree_column_attrs.h:981
bool do_contextualize(Parse_context *pc_arg) override
Definition: parse_tree_column_attrs.h:988
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:984
Node for the generated default value, column attribute.
Definition: parse_tree_column_attrs.h:496
Value_generator m_default_value_expression
Definition: parse_tree_column_attrs.h:525
void apply_gen_default_value(Value_generator **default_value_expression) override
Definition: parse_tree_column_attrs.h:506
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:497
PT_generated_default_val_column_attr(const POS &pos, Item *expr)
Definition: parse_tree_column_attrs.h:500
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:511
Base class for generated column definition nodes.
Definition: parse_tree_column_attrs.h:1003
Item * expr
Definition: parse_tree_column_attrs.h:1007
Mem_root_array< PT_column_attr_base * > * opt_attrs
Definition: parse_tree_column_attrs.h:1008
bool do_contextualize(Parse_context *pc_arg) override
Definition: parse_tree_column_attrs.h:1019
PT_field_def_base super
Definition: parse_tree_column_attrs.h:1004
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:1011
const Virtual_or_stored virtual_or_stored
Definition: parse_tree_column_attrs.h:1006
Node for the JSON type.
Definition: parse_tree_column_attrs.h:891
PT_json_type(const POS &pos)
Definition: parse_tree_column_attrs.h:893
const CHARSET_INFO * get_charset() const override
Definition: parse_tree_column_attrs.h:894
Node for the NOT NULL column attribute.
Definition: parse_tree_column_attrs.h:160
PT_not_null_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:162
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:163
Node for the NULL column attribute.
Definition: parse_tree_column_attrs.h:146
PT_null_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:148
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:149
Node for numeric types.
Definition: parse_tree_column_attrs.h:583
const char * get_dec() const override
Definition: parse_tree_column_attrs.h:629
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:591
std::remove_const< decltype(PT_type::type)>::type Parent_type
Definition: parse_tree_column_attrs.h:588
const char * dec
Definition: parse_tree_column_attrs.h:585
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:625
const char * get_length() const override
Definition: parse_tree_column_attrs.h:628
PT_numeric_type(const POS &pos, THD *thd, Int_type type_arg, const char *length, ulong options)
Definition: parse_tree_column_attrs.h:610
ulong options
Definition: parse_tree_column_attrs.h:586
const char * length
Definition: parse_tree_column_attrs.h:584
Node for the UPDATE NOW[([<precision>])] column attribute.
Definition: parse_tree_column_attrs.h:351
PT_on_update_column_attr(const POS &pos, uint8 precision)
Definition: parse_tree_column_attrs.h:358
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:362
const uint8 precision
Definition: parse_tree_column_attrs.h:354
void apply_on_update_value(Item **value) const override
Definition: parse_tree_column_attrs.h:360
Item * item
Definition: parse_tree_column_attrs.h:355
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:352
Node for the PRIMARY [KEY] column attribute.
Definition: parse_tree_column_attrs.h:206
void apply_alter_info_flags(ulonglong *flags) const override
Definition: parse_tree_column_attrs.h:215
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:211
PT_primary_key_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:208
Node for the NOT SECONDARY column attribute.
Definition: parse_tree_column_attrs.h:173
PT_secondary_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:175
void apply_type_flags(unsigned long *type_flags) const override
Definition: parse_tree_column_attrs.h:177
Node for the SERIAL DEFAULT VALUE column attribute.
Definition: parse_tree_column_attrs.h:403
void apply_alter_info_flags(ulonglong *flags) const override
Definition: parse_tree_column_attrs.h:412
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:404
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:415
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:409
PT_serial_default_value_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:407
Definition: parse_tree_column_attrs.h:876
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:880
bool is_serial_type() const override
Definition: parse_tree_column_attrs.h:883
PT_serial_type(const POS &pos)
Definition: parse_tree_column_attrs.h:878
Node for spatial types.
Definition: parse_tree_column_attrs.h:823
const CHARSET_INFO * get_charset() const override
Definition: parse_tree_column_attrs.h:830
Field::geometry_type geo_type
Definition: parse_tree_column_attrs.h:824
PT_spacial_type(const POS &pos, Field::geometry_type geo_type)
Definition: parse_tree_column_attrs.h:827
uint get_uint_geom_type() const override
Definition: parse_tree_column_attrs.h:831
const char * get_length() const override
Definition: parse_tree_column_attrs.h:832
Node for the SRID column attribute.
Definition: parse_tree_column_attrs.h:481
PT_srid_column_attr(const POS &pos, gis::srid_t srid)
Definition: parse_tree_column_attrs.h:487
void apply_srid_modifier(std::optional< gis::srid_t > *srid) const override
Definition: parse_tree_column_attrs.h:490
gis::srid_t m_srid
Definition: parse_tree_column_attrs.h:484
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:482
Node for the STORAGE <DEFAULT|DISK|MEMORY> column attribute.
Definition: parse_tree_column_attrs.h:458
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:459
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:471
ha_storage_media media
Definition: parse_tree_column_attrs.h:461
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:467
PT_storage_media_column_attr(const POS &pos, ha_storage_media media)
Definition: parse_tree_column_attrs.h:464
Node for the TIME, TIMESTAMP and DATETIME types.
Definition: parse_tree_column_attrs.h:765
PT_time_type(const POS &pos, Time_type time_type, const char *dec)
Definition: parse_tree_column_attrs.h:771
const char * dec
Definition: parse_tree_column_attrs.h:766
const char * get_dec() const override
Definition: parse_tree_column_attrs.h:774
std::remove_const< decltype(PT_type::type)>::type Parent_type
Definition: parse_tree_column_attrs.h:768
Node for the TIMESTAMP type.
Definition: parse_tree_column_attrs.h:782
ulong type_flags
Definition: parse_tree_column_attrs.h:786
const char * dec
Definition: parse_tree_column_attrs.h:785
const char * get_dec() const override
Definition: parse_tree_column_attrs.h:792
bool do_contextualize(Parse_context *pc) override
Definition: parse_tree_column_attrs.h:795
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:793
PT_timestamp_type(const POS &pos, const char *dec)
Definition: parse_tree_column_attrs.h:789
PT_type super
Definition: parse_tree_column_attrs.h:783
Base class for all column type nodes.
Definition: parse_tree_column_attrs.h:555
virtual bool is_serial_type() const
Definition: parse_tree_column_attrs.h:570
virtual ulong get_type_flags() const
Definition: parse_tree_column_attrs.h:564
virtual const char * get_length() const
Definition: parse_tree_column_attrs.h:565
virtual const CHARSET_INFO * get_charset() const
Definition: parse_tree_column_attrs.h:567
virtual List< String > * get_interval_list() const
Definition: parse_tree_column_attrs.h:569
const enum_field_types type
Definition: parse_tree_column_attrs.h:557
virtual uint get_uint_geom_type() const
Definition: parse_tree_column_attrs.h:568
PT_type(const POS &pos, enum_field_types type)
Definition: parse_tree_column_attrs.h:560
virtual const char * get_dec() const
Definition: parse_tree_column_attrs.h:566
Node for the UNIQUE [KEY] column attribute.
Definition: parse_tree_column_attrs.h:187
void apply_alter_info_flags(ulonglong *flags) const override
Definition: parse_tree_column_attrs.h:196
PT_unique_key_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:189
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:192
Node for the YEAR type.
Definition: parse_tree_column_attrs.h:740
PT_year_type(const POS &pos)
Definition: parse_tree_column_attrs.h:742
Base class for parse tree nodes (excluding the Parse_tree_root hierarchy)
Definition: parse_tree_node_base.h:229
virtual bool contextualize(Context *pc) final
Definition: parse_tree_node_base.h:317
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:281
POS m_pos
Definition: parse_tree_node_base.h:242
This class represents a query block, aka a query specification, which is a query consisting of a SELE...
Definition: sql_lex.h:1162
Class to represent the check constraint specifications obtained from the SQL statement parse.
Definition: sql_check_constraint.h:42
Item * check_expr
Check constraint expression.
Definition: sql_check_constraint.h:79
bool is_enforced
Check constraint state (enforced/not enforced)
Definition: sql_check_constraint.h:85
LEX_STRING name
Name of the check constraint.
Definition: sql_check_constraint.h:76
@ SL_WARNING
Definition: sql_error.h:62
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:166
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:33
LEX * lex
Definition: sql_class.h:990
void syntax_error_at(const POS &location)
Definition: sql_class.h:4412
System_variables variables
Definition: sql_lexer_thd.h:61
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:2588
MEM_ROOT * mem_root
Definition: sql_lexer_thd.h:37
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:221
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:54
@ MYSQL_TYPE_TIME2
Internal to MySQL.
Definition: field_types.h:74
@ MYSQL_TYPE_VARCHAR
Definition: field_types.h:70
@ MYSQL_TYPE_LONGLONG
Definition: field_types.h:63
@ MYSQL_TYPE_LONG_BLOB
Definition: field_types.h:84
@ MYSQL_TYPE_BLOB
Definition: field_types.h:85
@ MYSQL_TYPE_TINY
Definition: field_types.h:56
@ MYSQL_TYPE_SET
Definition: field_types.h:81
@ MYSQL_TYPE_JSON
Definition: field_types.h:78
@ MYSQL_TYPE_STRING
Definition: field_types.h:87
@ MYSQL_TYPE_ENUM
Definition: field_types.h:80
@ MYSQL_TYPE_TINY_BLOB
Definition: field_types.h:82
@ MYSQL_TYPE_BIT
Definition: field_types.h:71
@ MYSQL_TYPE_INVALID
Definition: field_types.h:76
@ MYSQL_TYPE_GEOMETRY
Definition: field_types.h:88
@ MYSQL_TYPE_MEDIUM_BLOB
Definition: field_types.h:83
@ MYSQL_TYPE_DATETIME2
Internal to MySQL.
Definition: field_types.h:73
@ MYSQL_TYPE_DATE
Definition: field_types.h:65
@ MYSQL_TYPE_TIMESTAMP2
Definition: field_types.h:72
@ MYSQL_TYPE_YEAR
Definition: field_types.h:68
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:7328
void my_error(int nr, myf MyFlags,...)
Fill in and print a previously registered error message.
Definition: my_error.cc:215
#define PRI_KEY_FLAG
Field is part of a primary key.
Definition: mysql_com.h:154
#define FIELD_FLAGS_COLUMN_FORMAT
Field column format, bit 24-25.
Definition: mysql_com.h:186
#define ZEROFILL_FLAG
Field is zerofill.
Definition: mysql_com.h:159
#define UNSIGNED_FLAG
Field is unsigned.
Definition: mysql_com.h:158
#define UNIQUE_FLAG
Intern: Used by sql_yacc.
Definition: mysql_com.h:172
#define AUTO_INCREMENT_FLAG
field is a autoincrement field
Definition: mysql_com.h:164
#define FIELD_FLAGS_COLUMN_FORMAT_MASK
Definition: mysql_com.h:187
#define NOT_NULL_FLAG
Field can't be NULL.
Definition: mysql_com.h:153
#define BINCMP_FLAG
Intern: Used by sql_yacc.
Definition: mysql_com.h:173
#define FIELD_IS_INVISIBLE
Field is explicitly marked as invisible by the user.
Definition: mysql_com.h:197
#define EXPLICIT_NULL_FLAG
Field is explicitly specified as \ NULL by the user.
Definition: mysql_com.h:189
#define FIELD_FLAGS_STORAGE_MEDIA_MASK
Definition: mysql_com.h:185
#define NOT_SECONDARY_FLAG
Field will not be loaded in secondary engine.
Definition: mysql_com.h:195
#define FIELD_FLAGS_STORAGE_MEDIA
Field storage media, bit 22-23.
Definition: mysql_com.h:184
static int flags[50]
Definition: hp_test1.cc:39
constexpr const LEX_CSTRING EMPTY_CSTR
Definition: lex_string.h:47
A better implementation of the UNIX ctype(3) library.
MYSQL_STRINGS_EXPORT CHARSET_INFO my_charset_bin
Definition: ctype-bin.cc:508
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:114
Header for compiler-dependent features.
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:55
uint8_t uint8
Definition: my_inttypes.h:62
#define MYF(v)
Definition: my_inttypes.h:96
Common header for many mysys elements.
Common definition between mysql server & client.
const char * collation
Definition: audit_api_message_emit.cc:183
std::uint32_t srid_t
A spatial reference system ID (SRID).
Definition: srid.h:32
Definition: options.cc:56
Blob_type
Definition: parse_tree_column_attrs.h:692
Enum_type
Definition: parse_tree_column_attrs.h:835
Char_type
Definition: parse_tree_column_attrs.h:660
PT_enum_type_tmpl< Enum_type::ENUM > PT_enum_type
Node for the ENUM type.
Definition: parse_tree_column_attrs.h:867
PT_enum_type_tmpl< Enum_type::SET > PT_set_type
Node for the SET type.
Definition: parse_tree_column_attrs.h:874
Time_type
Definition: parse_tree_column_attrs.h:755
void move_cf_appliers(Parse_context *tddlpc, Column_parse_context *cpc)
Definition: parse_tree_helpers.cc:438
Int_type
Definition: parser_yystype.h:245
Numeric_type
Definition: parser_yystype.h:253
Virtual_or_stored
Definition: parser_yystype.h:243
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:652
case opt name
Definition: sslopt-case.h:32
Definition: m_ctype.h:422
Parse context for column type attribute specific parse tree nodes.
Definition: parse_tree_column_attrs.h:72
const bool is_generated
Owner column is a generated one.
Definition: parse_tree_column_attrs.h:73
std::vector< CreateFieldApplier > cf_appliers
Definition: parse_tree_column_attrs.h:74
Column_parse_context(THD *thd_arg, Query_block *select_arg, bool is_generated)
Definition: parse_tree_column_attrs.h:75
bool binlog_need_explicit_defaults_ts
Definition: sql_lex.h:4170
Definition: mysql_lex_string.h:39
Definition: mysql_lex_string.h:34
Bison "location" class.
Definition: parse_location.h:42
Environment data for the contextualization phase.
Definition: parse_tree_node_base.h:418
Query_block * select
Current Query_block object.
Definition: parse_tree_node_base.h:421
THD *const thd
Current thread handler.
Definition: parse_tree_node_base.h:419
MEM_ROOT * mem_root
Current MEM_ROOT.
Definition: parse_tree_node_base.h:420