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