MySQL 9.7.0
Source Code Documentation
parse_tree_column_attrs.h
Go to the documentation of this file.
1/* Copyright (c) 2016, 2026, 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"
62#include "sql/sql_parse.h"
64
65class String;
66
67/**
68 Parse context for column type attribute specific parse tree nodes.
69
70 For internal use in the contextualization code.
71
72 @ingroup ptn_column_attrs ptn_gcol_attrs
73*/
75 const bool is_generated; ///< Owner column is a generated one.
76 std::vector<CreateFieldApplier> cf_appliers;
77 Column_parse_context(THD *thd_arg, Query_block *select_arg, bool is_generated)
78 : Parse_context(thd_arg, select_arg), is_generated(is_generated) {}
79};
80
81/**
82 Base class for all column attributes in @SQL{CREATE/ALTER TABLE}
83
84 @ingroup ptn_column_attrs ptn_gcol_attrs
85*/
86class PT_column_attr_base : public Parse_tree_node_tmpl<Column_parse_context> {
87 protected:
88 explicit PT_column_attr_base(const POS &pos)
90
91 public:
92 enum Attr_type {
113 };
114
116
117 virtual void apply_type_flags(ulong *) const {}
118 virtual void apply_alter_info_flags(ulonglong *) const {}
119 virtual void apply_comment(LEX_CSTRING *) const {}
120 virtual void apply_default_value(Item **) const {}
122 virtual void apply_mask(LEX_CSTRING *) {}
123 virtual void apply_on_update_value(Item **) const {}
124 virtual void apply_srid_modifier(std::optional<gis::srid_t> *) const {}
126 const CHARSET_INFO **to [[maybe_unused]],
127 bool *has_explicit_collation
128 [[maybe_unused]]) const {
129 return false;
130 }
132 Sql_check_constraint_spec_list *check_const_list [[maybe_unused]]) {
133 return false;
134 }
135 virtual Attr_type attr_type() const { return AT_NONE; }
136
137 /**
138 Check for the [NOT] ENFORCED characteristic.
139
140 @returns true if the [NOT] ENFORCED follows the CHECK(...) clause,
141 false otherwise.
142 */
143 virtual bool has_constraint_enforcement() const { return false; }
144
145 /**
146 Check if constraint is enforced.
147 Method must be called only when has_constraint_enforcement() is true (i.e
148 when [NOT] ENFORCED follows the CHECK(...) clause).
149
150 @returns true if constraint is enforced.
151 false otherwise.
152 */
153 virtual bool is_constraint_enforced() const { return false; }
154
155 /**
156 Update the ENFORCED/NOT ENFORCED state of the CHECK constraint.
157
158 @param enforced true if ENFORCED, false if NOT ENFORCED.
159
160 @returns false if success, true if error (e.g. if [NOT] ENFORCED follows
161 something other than the CHECK clause.)
162 */
163 virtual bool set_constraint_enforcement(bool enforced [[maybe_unused]]) {
164 return true; // error
165 }
166};
167
168/**
169 Node for the @SQL{NULL} column attribute
170
171 @ingroup ptn_column_attrs
172*/
174 public:
175 explicit PT_null_column_attr(const POS &pos) : PT_column_attr_base(pos) {}
176 void apply_type_flags(ulong *type_flags) const override {
177 *type_flags &= ~NOT_NULL_FLAG;
178 *type_flags |= EXPLICIT_NULL_FLAG;
179 }
180
181 enum Attr_type attr_type() const override { return AT_NULL_COLUMN_ATTR; }
182};
183
184/**
185 Node for the @SQL{NOT NULL} column attribute
186
187 @ingroup ptn_column_attrs
188*/
190 public:
191 explicit PT_not_null_column_attr(const POS &pos) : PT_column_attr_base(pos) {}
192 void apply_type_flags(ulong *type_flags) const override {
193 *type_flags |= NOT_NULL_FLAG;
194 }
195
196 enum Attr_type attr_type() const override { return AT_NOT_NULL_COLUMN_ATTR; }
197};
198
199/**
200 Node for the @SQL{NOT SECONDARY} column attribute
201
202 @ingroup ptn_column_attrs
203*/
205 public:
206 explicit PT_secondary_column_attr(const POS &pos)
207 : PT_column_attr_base(pos) {}
208 void apply_type_flags(unsigned long *type_flags) const override {
209 *type_flags |= NOT_SECONDARY_FLAG;
210 }
211
212 enum Attr_type attr_type() const override { return AT_SECONDARY_COLUMN_ATTR; }
213};
214
215/**
216 Node for the @SQL{UNIQUE [KEY]} column attribute
217
218 @ingroup ptn_column_attrs
219*/
221 public:
222 explicit PT_unique_key_column_attr(const POS &pos)
223 : PT_column_attr_base(pos) {}
224
225 void apply_type_flags(ulong *type_flags) const override {
226 *type_flags |= UNIQUE_FLAG;
227 }
228
229 void apply_alter_info_flags(ulonglong *flags) const override {
231 }
232
233 enum Attr_type attr_type() const override {
235 }
236};
237
238/**
239 Node for the @SQL{PRIMARY [KEY]} column attribute
240
241 @ingroup ptn_column_attrs
242*/
244 public:
245 explicit PT_primary_key_column_attr(const POS &pos)
246 : PT_column_attr_base(pos) {}
247
248 void apply_type_flags(ulong *type_flags) const override {
249 *type_flags |= PRI_KEY_FLAG | NOT_NULL_FLAG;
250 }
251
252 void apply_alter_info_flags(ulonglong *flags) const override {
254 }
255
256 enum Attr_type attr_type() const override {
258 }
259};
260
261/**
262 Node for the @SQL{[CONSTRAINT [symbol]] CHECK '(' expr ')'} column attribute.
263
264 @ingroup ptn_column_attrs
265*/
269
270 public:
272 Item *expr)
273 : super(pos) {
275 col_cc_spec.check_expr = expr;
276 }
277
278 bool set_constraint_enforcement(bool enforced) override {
279 col_cc_spec.is_enforced = enforced;
280 return false;
281 }
282
283 void apply_alter_info_flags(ulonglong *flags) const override {
285 }
286
288 Sql_check_constraint_spec_list *check_const_list) override {
289 assert(check_const_list != nullptr);
290 return (check_const_list->push_back(&col_cc_spec));
291 }
292
294 return (super::do_contextualize(pc) ||
296 }
297
298 enum Attr_type attr_type() const override {
300 }
301};
302
303/**
304 Node for the @SQL{[NOT] ENFORCED} column attribute.
305
306 @ingroup ptn_column_attrs
307*/
309 public:
310 explicit PT_constraint_enforcement_attr(const POS &pos, bool enforced)
311 : PT_column_attr_base(pos), m_enforced(enforced) {}
312
313 bool has_constraint_enforcement() const override { return true; }
314
315 bool is_constraint_enforced() const override { return m_enforced; }
316
317 enum Attr_type attr_type() const override {
319 }
320
321 private:
322 const bool m_enforced;
323};
324
325/**
326 Node for the @SQL{COMMENT @<comment@>} column attribute
327
328 @ingroup ptn_column_attrs
329*/
332
333 public:
334 explicit PT_comment_column_attr(const POS &pos, const LEX_CSTRING &comment)
336
337 void apply_comment(LEX_CSTRING *to) const override { *to = comment; }
338
339 enum Attr_type attr_type() const override { return AT_COMMENT_COLUMN_ATTR; }
340};
341
342/**
343 Node for the @SQL{COLLATE @<collation@>} column attribute
344
345 @ingroup ptn_column_attrs
346*/
348 public:
351 assert(m_collation != nullptr);
352 }
353
355 bool *has_explicit_collation) const override {
356 if (*has_explicit_collation) {
357 pc->thd->syntax_error_at(m_pos, ER_INVALID_MULTIPLE_CLAUSES, "COLLATE");
358 return true;
359 }
360 *has_explicit_collation = true;
362 }
363
364 enum Attr_type attr_type() const override { return AT_COLLATE_COLUMN_ATTR; }
365
366 private:
368};
369
370// Specific to non-generated columns only:
371
372/**
373 Node for the @SQL{DEFAULT @<expression@>} column attribute
374
375 @ingroup ptn_not_gcol_attr
376*/
379
381
382 public:
383 explicit PT_default_column_attr(const POS &pos, Item *item)
384 : super(pos), item(item) {}
385 void apply_default_value(Item **value) const override { *value = item; }
387 if (pc->is_generated) {
388 my_error(ER_WRONG_USAGE, MYF(0), "DEFAULT", "generated column");
389 return true;
390 }
391 return super::do_contextualize(pc) || item->itemize(pc, &item);
392 }
393 void apply_type_flags(ulong *type_flags) const override {
394 if (item->type() == Item::NULL_ITEM) *type_flags |= EXPLICIT_NULL_FLAG;
395 }
396
397 enum Attr_type attr_type() const override { return AT_DEFAULT_COLUMN_ATTR; }
398};
399
400/**
401 Node for the @SQL{UPDATE NOW[([@<precision@>])]} column attribute
402
403 @ingroup ptn_not_gcol_attr
404*/
407
409 Item *item = nullptr;
410
411 public:
413 : super(pos), precision(precision) {}
414 void apply_on_update_value(Item **value) const override { *value = item; }
415
417 if (pc->is_generated) {
418 my_error(ER_WRONG_USAGE, MYF(0), "ON UPDATE", "generated column");
419 return true;
420 }
421 if (super::do_contextualize(pc)) return true;
422
424 return item == nullptr;
425 }
426
427 enum Attr_type attr_type() const override { return AT_ON_UPDATE_COLUMN_ATTR; }
428};
429
430/**
431 Node for the @SQL{AUTO_INCREMENT} column attribute
432
433 @ingroup ptn_not_gcol_attr
434*/
437
438 public:
440 : PT_column_attr_base(pos) {}
441
442 void apply_type_flags(ulong *type_flags) const override {
443 *type_flags |= AUTO_INCREMENT_FLAG | NOT_NULL_FLAG;
444 }
446 if (pc->is_generated) {
447 my_error(ER_WRONG_USAGE, MYF(0), "AUTO_INCREMENT", "generated column");
448 return true;
449 }
450 return super::do_contextualize(pc);
451 }
452
453 enum Attr_type attr_type() const override {
455 }
456};
457
458/**
459 Node for the @SQL{SERIAL DEFAULT VALUE} column attribute
460
461 @ingroup ptn_not_gcol_attr
462*/
465
466 public:
467 explicit PT_serial_default_value_column_attr(const POS &pos) : super(pos) {}
468
469 void apply_type_flags(ulong *type_flags) const override {
471 }
472 void apply_alter_info_flags(ulonglong *flags) const override {
474 }
476 if (pc->is_generated) {
477 my_error(ER_WRONG_USAGE, MYF(0), "SERIAL DEFAULT VALUE",
478 "generated column");
479 return true;
480 }
481 return super::do_contextualize(pc);
482 }
483 enum Attr_type attr_type() const override {
485 }
486};
487
488/**
489 Node for the @SQL{COLUMN_FORMAT @<DEFAULT|FIXED|DYNAMIC@>} column attribute
490
491 @ingroup ptn_not_gcol_attr
492*/
495
497
498 public:
501 : super(pos), format(format) {}
502
503 void apply_type_flags(ulong *type_flags) const override {
504 *type_flags &= ~(FIELD_FLAGS_COLUMN_FORMAT_MASK);
505 *type_flags |= format << FIELD_FLAGS_COLUMN_FORMAT;
506 }
508 if (pc->is_generated) {
509 my_error(ER_WRONG_USAGE, MYF(0), "COLUMN_FORMAT", "generated column");
510 return true;
511 }
512 return super::do_contextualize(pc);
513 }
514 enum Attr_type attr_type() const override {
516 }
517};
518
519/**
520 Node for the @SQL{STORAGE @<DEFAULT|DISK|MEMORY@>} column attribute
521
522 @ingroup ptn_not_gcol_attr
523*/
526
528
529 public:
531 : super(pos), media(media) {}
532
533 void apply_type_flags(ulong *type_flags) const override {
534 *type_flags &= ~(FIELD_FLAGS_STORAGE_MEDIA_MASK);
535 *type_flags |= media << FIELD_FLAGS_STORAGE_MEDIA;
536 }
538 if (pc->is_generated) {
539 my_error(ER_WRONG_USAGE, MYF(0), "STORAGE", "generated column");
540 return true;
541 }
542 return super::do_contextualize(pc);
543 }
544 enum Attr_type attr_type() const override {
546 }
547};
548
549/// Node for the SRID column attribute
552
554
555 public:
556 explicit PT_srid_column_attr(const POS &pos, gis::srid_t srid)
557 : super(pos), m_srid(srid) {}
558
559 void apply_srid_modifier(std::optional<gis::srid_t> *srid) const override {
560 *srid = m_srid;
561 }
562
563 enum Attr_type attr_type() const override { return AT_SRID_COLUMN_ATTR; }
564};
565
566/// Node for the generated default value, column attribute
569
570 public:
572 : super(pos) {
575 }
576
578 Value_generator **default_value_expression) override {
579 *default_value_expression = &m_default_value_expression;
580 }
581
583 // GC and default value expressions are mutually exclusive and thus only
584 // one is allowed to be present on the same column definition.
585 if (pc->is_generated) {
586 my_error(ER_WRONG_USAGE, MYF(0), "DEFAULT", "generated column");
587 return true;
588 }
589 Parse_context expr_pc(pc->thd, pc->select);
590 return super::do_contextualize(pc) ||
593 }
594
595 enum Attr_type attr_type() const override {
597 }
598
599 private:
601};
602
603/// Node for the masking policy, column attribute
606
607 public:
609 : super{pos}, m_policy_name{policy_name} {}
610
612 return super::do_contextualize(pc) ||
614 }
615
616 void apply_mask(LEX_CSTRING *masking_policy_name) override {
617 *masking_policy_name = m_policy_name;
618 }
619
620 enum Attr_type attr_type() const override {
622 }
623
624 private:
626};
627
628/**
629 Node for the @SQL{VISIBLE|INVISIBLE} column attribute
630
631 @ingroup ptn_column_attrs
632*/
635
636 public:
637 explicit PT_column_visibility_attr(const POS &pos, bool is_visible)
638 : super(pos), m_is_visible(is_visible) {}
639 void apply_type_flags(unsigned long *type_flags) const override {
640 *type_flags &= ~FIELD_IS_INVISIBLE;
641 if (!m_is_visible) *type_flags |= FIELD_IS_INVISIBLE;
642 }
643
644 enum Attr_type attr_type() const override {
646 }
647
648 private:
649 const bool m_is_visible;
650};
651
652// Type nodes:
653
654/**
655 Base class for all column type nodes
656
657 @ingroup ptn_column_types
658*/
659class PT_type : public Parse_tree_node {
660 public:
662
663 protected:
664 explicit PT_type(const POS &pos, enum_field_types type)
665 : Parse_tree_node(pos), type(type) {}
666
667 public:
668 virtual ulong get_type_flags() const { return 0; }
669 virtual const char *get_length() const { return nullptr; }
670 virtual const char *get_dec() const { return nullptr; }
671 virtual const CHARSET_INFO *get_charset() const { return nullptr; }
672 virtual uint get_uint_geom_type() const { return 0; }
673 virtual List<String> *get_interval_list() const { return nullptr; }
674 virtual bool is_serial_type() const { return false; }
675};
676
677/**
678 Node for numeric types
679
680 Type list:
681 * NUMERIC, REAL, DOUBLE, DECIMAL and FIXED,
682 * INTEGER, INT, INT1, INT2, INT3, INT4, TINYINT, SMALLINT, MEDIUMINT and
683 BIGINT.
684
685 @ingroup ptn_column_types
686*/
687class PT_numeric_type : public PT_type {
688 const char *length;
689 const char *dec;
690 ulong options;
691
692 using Parent_type = std::remove_const<decltype(PT_type::type)>::type;
693
694 public:
695 PT_numeric_type(const POS &pos, THD *thd, Numeric_type type_arg,
696 const char *length, const char *dec, ulong options)
697 : PT_type(pos, static_cast<Parent_type>(type_arg)),
698 length(length),
699 dec(dec),
701 assert((options & ~(UNSIGNED_FLAG | ZEROFILL_FLAG)) == 0);
702
703 if (type_arg != Numeric_type::DECIMAL && dec != nullptr) {
705 ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT,
706 ER_THD(thd, ER_WARN_DEPRECATED_FLOAT_DIGITS));
707 }
708 if (options & UNSIGNED_FLAG) {
710 ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT,
711 ER_THD(thd, ER_WARN_DEPRECATED_FLOAT_UNSIGNED));
712 }
713 }
714 PT_numeric_type(const POS &pos, THD *thd, Int_type type_arg,
715 const char *length, ulong options)
716 : PT_type(pos, static_cast<enum_field_types>(type_arg)),
717 length(length),
718 dec(nullptr),
720 assert((options & ~(UNSIGNED_FLAG | ZEROFILL_FLAG)) == 0);
721
722 if (length != nullptr) {
724 ER_WARN_DEPRECATED_SYNTAX_NO_REPLACEMENT,
725 ER_THD(thd, ER_WARN_DEPRECATED_INTEGER_DISPLAY_WIDTH));
726 }
727 }
728
729 ulong get_type_flags() const override {
731 }
732 const char *get_length() const override { return length; }
733 const char *get_dec() const override { return dec; }
734};
735
736/**
737 Node for the BIT type
738
739 @ingroup ptn_column_types
740*/
741class PT_bit_type : public PT_type {
742 const char *length;
743
744 public:
745 explicit PT_bit_type(const POS &pos)
746 : PT_type(pos, MYSQL_TYPE_BIT), length("1") {}
747 explicit PT_bit_type(const POS &pos, const char *length)
749
750 const char *get_length() const override { return length; }
751};
752
753/**
754 Node for the BOOL/BOOLEAN type
755
756 @ingroup ptn_column_types
757*/
758class PT_boolean_type : public PT_type {
759 public:
760 explicit PT_boolean_type(const POS &pos) : PT_type(pos, MYSQL_TYPE_TINY) {}
761 const char *get_length() const override { return "1"; }
762};
763
764enum class Char_type : ulong {
768};
769
770class PT_char_type : public PT_type {
771 const char *length;
773 const bool force_binary;
774
775 using Parent_type = std::remove_const<decltype(PT_type::type)>::type;
776
777 public:
778 PT_char_type(const POS &pos, Char_type char_type, const char *length,
779 const CHARSET_INFO *charset, bool force_binary = false)
780 : PT_type(pos, static_cast<Parent_type>(char_type)),
781 length(length),
784 assert(charset == nullptr || !force_binary);
785 }
786 PT_char_type(const POS &pos, Char_type char_type, const CHARSET_INFO *charset,
787 bool force_binary = false)
788 : PT_char_type(pos, char_type, "1", charset, force_binary) {}
789 ulong get_type_flags() const override {
790 return force_binary ? BINCMP_FLAG : 0;
791 }
792 const char *get_length() const override { return length; }
793 const CHARSET_INFO *get_charset() const override { return charset; }
794};
795
796class PT_vector_type : public PT_type {
798
799 public:
800 PT_vector_type(const POS &pos, const char *length)
801 : PT_type(pos, MYSQL_TYPE_VECTOR) {
802 const char *length_arg = length == nullptr ? "2048" : length;
803 uint vector_length = atoi(length_arg) * sizeof(float);
804 sprintf(vector_length_buffer, "%u", vector_length);
805 }
806
807 const char *get_length() const override { return vector_length_buffer; }
808 const CHARSET_INFO *get_charset() const override { return &my_charset_bin; }
809};
810
811enum class Blob_type {
815};
816
817/**
818 Node for BLOB types
819
820 Types: BLOB, TINYBLOB, MEDIUMBLOB, LONGBLOB, LONG, LONG VARBINARY,
821 LONG VARCHAR, TEXT, TINYTEXT, MEDIUMTEXT, LONGTEXT.
822
823 @ingroup ptn_column_types
824*/
825class PT_blob_type : public PT_type {
826 const char *length;
828 const bool force_binary;
829
830 using Parent_type = std::remove_const<decltype(PT_type::type)>::type;
831
832 public:
833 PT_blob_type(const POS &pos, Blob_type blob_type, const CHARSET_INFO *charset,
834 bool force_binary = false)
835 : PT_type(pos, static_cast<Parent_type>(blob_type)),
839 assert(charset == nullptr || !force_binary);
840 }
841 explicit PT_blob_type(const POS &pos, const char *length)
842 : PT_type(pos, MYSQL_TYPE_BLOB),
843 length(length),
845 force_binary(false) {}
846
847 ulong get_type_flags() const override {
848 return force_binary ? BINCMP_FLAG : 0;
849 }
850 const CHARSET_INFO *get_charset() const override { return charset; }
851 const char *get_length() const override { return length; }
852};
853
854/**
855 Node for the YEAR type
856
857 @ingroup ptn_column_types
858*/
859class PT_year_type : public PT_type {
860 public:
861 explicit PT_year_type(const POS &pos) : PT_type(pos, MYSQL_TYPE_YEAR) {}
862};
863
864/**
865 Node for the DATE type
866
867 @ingroup ptn_column_types
868*/
869class PT_date_type : public PT_type {
870 public:
871 explicit PT_date_type(const POS &pos) : PT_type(pos, MYSQL_TYPE_DATE) {}
872};
873
874enum class Time_type : ulong {
877};
878
879/**
880 Node for the TIME, TIMESTAMP and DATETIME types
881
882 @ingroup ptn_column_types
883*/
884class PT_time_type : public PT_type {
885 const char *dec;
886
887 using Parent_type = std::remove_const<decltype(PT_type::type)>::type;
888
889 public:
890 PT_time_type(const POS &pos, Time_type time_type, const char *dec)
891 : PT_type(pos, static_cast<Parent_type>(time_type)), dec(dec) {}
892
893 const char *get_dec() const override { return dec; }
894};
895
896/**
897 Node for the TIMESTAMP type
898
899 @ingroup ptn_column_types
900*/
902 typedef PT_type super;
903
904 const char *dec;
906
907 public:
908 explicit PT_timestamp_type(const POS &pos, const char *dec)
910
911 const char *get_dec() const override { return dec; }
912 ulong get_type_flags() const override { return type_flags; }
913
914 bool do_contextualize(Parse_context *pc) override {
915 if (super::do_contextualize(pc)) return true;
916 /*
917 TIMESTAMP fields are NOT NULL by default, unless the variable
918 explicit_defaults_for_timestamp is true.
919 */
920 if (!pc->thd->variables.explicit_defaults_for_timestamp)
922 /*
923 To flag the current statement as dependent for binary
924 logging on the session var. Extra copying to Lex is
925 done in case prepared stmt.
926 */
929
930 return false;
931 }
932};
933
934/**
935 Node for spatial types
936
937 Types: GEOMETRY, GEOMCOLLECTION/GEOMETRYCOLLECTION, POINT, MULTIPOINT,
938 LINESTRING, MULTILINESTRING, POLYGON, MULTIPOLYGON
939
940 @ingroup ptn_column_types
941*/
942class PT_spacial_type : public PT_type {
944
945 public:
948
949 const CHARSET_INFO *get_charset() const override { return &my_charset_bin; }
950 uint get_uint_geom_type() const override { return geo_type; }
951 const char *get_length() const override { return nullptr; }
952};
953
955
956template <Enum_type enum_type>
960 const bool force_binary;
961
962 using Parent_type = std::remove_const<decltype(PT_type::type)>::type;
963
964 public:
966 const CHARSET_INFO *charset, bool force_binary)
967 : PT_type(pos, static_cast<Parent_type>(enum_type)),
971 assert(charset == nullptr || !force_binary);
972 }
973
974 const CHARSET_INFO *get_charset() const override { return charset; }
975 ulong get_type_flags() const override {
976 return force_binary ? BINCMP_FLAG : 0;
977 }
978 List<String> *get_interval_list() const override { return interval_list; }
979};
980
981/**
982 Node for the ENUM type
983
984 @ingroup ptn_column_types
985*/
987
988/**
989 Node for the SET type
990
991 @ingroup ptn_column_types
992*/
994
995class PT_serial_type : public PT_type {
996 public:
997 explicit PT_serial_type(const POS &pos) : PT_type(pos, MYSQL_TYPE_LONGLONG) {}
998
999 ulong get_type_flags() const override {
1001 }
1002 bool is_serial_type() const override { return true; }
1003};
1004
1005/**
1006 Node for the JSON type
1007
1008 @ingroup ptn_column_types
1009*/
1010class PT_json_type : public PT_type {
1011 public:
1012 explicit PT_json_type(const POS &pos) : PT_type(pos, MYSQL_TYPE_JSON) {}
1013 const CHARSET_INFO *get_charset() const override { return &my_charset_bin; }
1014};
1015
1016/**
1017 Base class for both generated and regular column definitions
1018
1019 @ingroup ptn_create_table
1020*/
1024
1025 public:
1027 ulong type_flags = 0;
1028 const char *length = nullptr;
1029 const char *dec = nullptr;
1030 const CHARSET_INFO *charset = nullptr;
1039 /// Holds the expression to generate default values
1042 std::optional<gis::srid_t> m_srid{};
1043 // List of column check constraint's specification.
1045
1046 protected:
1048
1050 : super(pos), type_node(type_node) {}
1051
1052 public:
1053 bool do_contextualize(Parse_context *pc) override {
1055 return true;
1056
1057 type = type_node->type;
1060 dec = type_node->get_dec();
1066 if (check_const_spec_list == nullptr) return true; // OOM
1067 return false;
1068 }
1069
1070 private:
1072 PT_column_attr_base *cand) {
1073 // skip de-duplicating these types. NONE is used for (secondary) engine
1074 // attributes, cf. make_column_engine_attribute and
1075 // make_column_secondary_engine_attribute
1076 switch (cand->attr_type()) {
1077 case PT_column_attr_base::AT_NONE: // engine attributes
1079 case PT_column_attr_base::AT_COLLATE_COLUMN_ATTR: // avoid test breaks
1080 return false;
1081 default:
1082 break;
1083 }
1084
1085 for (auto attr : *attrs) {
1086 if (attr->attr_type() == cand->attr_type()) return true;
1087 }
1088 return false;
1089 }
1090
1091 protected:
1094 if (attrs != nullptr) {
1095 if (attrs->size() > 1) {
1096 // Keep only last instance of most attributes that override any
1097 // preceding ones. This avoids contextualizing attributes that will
1098 // later be ignored anyway.
1099 Mem_root_array<PT_column_attr_base *> *unique_attrs = new (pc->mem_root)
1101 unique_attrs->reserve(attrs->size());
1102 for (long i = static_cast<long>(attrs->size()) - 1; i >= 0; i--) {
1103 if (is_overridden(unique_attrs, (*attrs)[i])) continue;
1104 unique_attrs->push_back((*attrs)[i]); // reversed order..
1105 }
1106 attrs->clear();
1107 // Reverse order again to get back original order. Needed for attributes
1108 // which are opposed, e.g. NOT NULL vs NULL.
1109 for (auto attr : *unique_attrs) attrs->push_front(attr);
1110 }
1111
1112 for (auto attr : *attrs) {
1113 if (attr->contextualize(pc)) return true;
1114 attr->apply_type_flags(&type_flags);
1115 attr->apply_alter_info_flags(&alter_info_flags);
1116 attr->apply_comment(&comment);
1117 attr->apply_default_value(&default_value);
1118 attr->apply_gen_default_value(&default_val_info);
1119 attr->apply_mask(&masking_policy);
1120 attr->apply_on_update_value(&on_update_value);
1121 attr->apply_srid_modifier(&m_srid);
1122 if (attr->apply_collation(pc, &charset, &has_explicit_collation))
1123 return true;
1124 if (attr->add_check_constraints(check_const_spec_list)) return true;
1125 }
1126 }
1127 return false;
1128 }
1129};
1130
1131/**
1132 Base class for regular (non-generated) column definition nodes
1133
1134 @ingroup ptn_create_table
1135*/
1138
1140
1141 public:
1142 PT_field_def(const POS &pos, PT_type *type_node_arg,
1144 : super(pos, type_node_arg), opt_attrs(opt_attrs) {}
1145
1146 bool do_contextualize(Parse_context *pc_arg) override {
1147 Column_parse_context pc(pc_arg->thd, pc_arg->select, false);
1149 return true;
1150
1151 move_cf_appliers(pc_arg, &pc);
1152 return false;
1153 }
1154};
1155
1156/**
1157 Base class for generated column definition nodes
1158
1159 @ingroup ptn_create_table
1160*/
1163
1167
1168 public:
1169 PT_generated_field_def(const POS &pos, PT_type *type_node_arg, Item *expr,
1172 : super(pos, type_node_arg),
1174 expr(expr),
1176
1177 bool do_contextualize(Parse_context *pc_arg) override {
1178 Column_parse_context pc(pc_arg->thd, pc_arg->select, true);
1180 expr->itemize(&pc, &expr))
1181 return true;
1182
1183 // column of type serial cannot be generated
1184 if (type_node->is_serial_type()) {
1185 my_error(ER_WRONG_USAGE, MYF(0), "SERIAL", "generated column");
1186 return true;
1187 }
1188
1190 if (gcol_info == nullptr) return true; // OOM
1195
1196 return false;
1197 }
1198};
1199
1201
1202#endif /* PARSE_TREE_COL_ATTRS_INCLUDED */
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:247
ulonglong flags
Definition: sql_alter.h:440
@ ADD_CHECK_CONSTRAINT
Set for add check constraint.
Definition: sql_alter.h:324
@ 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:234
geometry_type
Definition: field.h:716
Definition: item_timefunc.h:1117
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:929
@ NULL_ITEM
A NULL value.
Definition: item.h:975
virtual bool itemize(Parse_context *pc, Item **res) final
The same as contextualize() but with additional parameter.
Definition: item.h:1249
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:435
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:436
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:442
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:453
PT_auto_increment_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:439
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:445
Node for the BIT type.
Definition: parse_tree_column_attrs.h:741
PT_bit_type(const POS &pos)
Definition: parse_tree_column_attrs.h:745
const char * get_length() const override
Definition: parse_tree_column_attrs.h:750
const char * length
Definition: parse_tree_column_attrs.h:742
PT_bit_type(const POS &pos, const char *length)
Definition: parse_tree_column_attrs.h:747
Node for BLOB types.
Definition: parse_tree_column_attrs.h:825
const CHARSET_INFO * charset
Definition: parse_tree_column_attrs.h:827
PT_blob_type(const POS &pos, Blob_type blob_type, const CHARSET_INFO *charset, bool force_binary=false)
Definition: parse_tree_column_attrs.h:833
const char * length
Definition: parse_tree_column_attrs.h:826
PT_blob_type(const POS &pos, const char *length)
Definition: parse_tree_column_attrs.h:841
const char * get_length() const override
Definition: parse_tree_column_attrs.h:851
const CHARSET_INFO * get_charset() const override
Definition: parse_tree_column_attrs.h:850
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:847
std::remove_const< decltype(PT_type::type)>::type Parent_type
Definition: parse_tree_column_attrs.h:830
const bool force_binary
Definition: parse_tree_column_attrs.h:828
Node for the BOOL/BOOLEAN type.
Definition: parse_tree_column_attrs.h:758
const char * get_length() const override
Definition: parse_tree_column_attrs.h:761
PT_boolean_type(const POS &pos)
Definition: parse_tree_column_attrs.h:760
Definition: parse_tree_column_attrs.h:770
std::remove_const< decltype(PT_type::type)>::type Parent_type
Definition: parse_tree_column_attrs.h:775
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:778
const char * length
Definition: parse_tree_column_attrs.h:771
const char * get_length() const override
Definition: parse_tree_column_attrs.h:792
PT_char_type(const POS &pos, Char_type char_type, const CHARSET_INFO *charset, bool force_binary=false)
Definition: parse_tree_column_attrs.h:786
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:789
const CHARSET_INFO * get_charset() const override
Definition: parse_tree_column_attrs.h:793
const CHARSET_INFO * charset
Definition: parse_tree_column_attrs.h:772
const bool force_binary
Definition: parse_tree_column_attrs.h:773
Node for the [CONSTRAINT [symbol]] CHECK '(' expr ')' column attribute.
Definition: parse_tree_column_attrs.h:266
void apply_alter_info_flags(ulonglong *flags) const override
Definition: parse_tree_column_attrs.h:283
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:298
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:267
bool add_check_constraints(Sql_check_constraint_spec_list *check_const_list) override
Definition: parse_tree_column_attrs.h:287
bool set_constraint_enforcement(bool enforced) override
Update the ENFORCED/NOT ENFORCED state of the CHECK constraint.
Definition: parse_tree_column_attrs.h:278
PT_check_constraint_column_attr(const POS &pos, LEX_STRING &name, Item *expr)
Definition: parse_tree_column_attrs.h:271
Sql_check_constraint_spec col_cc_spec
Definition: parse_tree_column_attrs.h:268
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:293
Node for the COLLATE <collation> column attribute.
Definition: parse_tree_column_attrs.h:347
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:364
bool apply_collation(Column_parse_context *pc, const CHARSET_INFO **to, bool *has_explicit_collation) const override
Definition: parse_tree_column_attrs.h:354
PT_collate_column_attr(const POS &pos, const CHARSET_INFO *collation)
Definition: parse_tree_column_attrs.h:349
const CHARSET_INFO *const m_collation
Definition: parse_tree_column_attrs.h:367
Base class for all column attributes in CREATE/ALTER TABLE
Definition: parse_tree_column_attrs.h:86
decltype(Alter_info::flags) alter_info_flags_t
Definition: parse_tree_column_attrs.h:115
virtual bool is_constraint_enforced() const
Check if constraint is enforced.
Definition: parse_tree_column_attrs.h:153
virtual bool set_constraint_enforcement(bool enforced)
Update the ENFORCED/NOT ENFORCED state of the CHECK constraint.
Definition: parse_tree_column_attrs.h:163
virtual void apply_alter_info_flags(ulonglong *) const
Definition: parse_tree_column_attrs.h:118
virtual void apply_srid_modifier(std::optional< gis::srid_t > *) const
Definition: parse_tree_column_attrs.h:124
virtual bool apply_collation(Column_parse_context *, const CHARSET_INFO **to, bool *has_explicit_collation) const
Definition: parse_tree_column_attrs.h:125
virtual void apply_gen_default_value(Value_generator **)
Definition: parse_tree_column_attrs.h:121
Attr_type
Definition: parse_tree_column_attrs.h:92
@ AT_CONSTRAINT_ENFORCEMENT_ATTR
Definition: parse_tree_column_attrs.h:103
@ AT_SECONDARY_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:97
@ AT_CHECK_CONSTRAINT_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:102
@ AT_DEFAULT_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:95
@ AT_MASKING_POLICY_NAME_ATTR
Definition: parse_tree_column_attrs.h:112
@ AT_UNIQUE_KEY_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:100
@ AT_COMMENT_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:104
@ AT_PRIMARY_KEY_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:101
@ AT_GENERATED_DEFAULT_VAL_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:96
@ AT_SERIAL_DEFAULT_VALUE_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:107
@ AT_ON_UPDATE_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:105
@ AT_NULL_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:99
@ AT_NOT_NULL_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:98
@ AT_AUTO_INCREMENT_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:106
@ AT_COLUMN_FORMAT_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:108
@ AT_COLUMN_VISIBILITY_ATTR
Definition: parse_tree_column_attrs.h:111
@ AT_STORAGE_MEDIA_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:109
@ AT_COLLATE_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:94
@ AT_SRID_COLUMN_ATTR
Definition: parse_tree_column_attrs.h:110
@ AT_NONE
Definition: parse_tree_column_attrs.h:93
virtual Attr_type attr_type() const
Definition: parse_tree_column_attrs.h:135
PT_column_attr_base(const POS &pos)
Definition: parse_tree_column_attrs.h:88
virtual void apply_on_update_value(Item **) const
Definition: parse_tree_column_attrs.h:123
virtual void apply_type_flags(ulong *) const
Definition: parse_tree_column_attrs.h:117
virtual void apply_comment(LEX_CSTRING *) const
Definition: parse_tree_column_attrs.h:119
virtual void apply_mask(LEX_CSTRING *)
Definition: parse_tree_column_attrs.h:122
virtual bool add_check_constraints(Sql_check_constraint_spec_list *check_const_list)
Definition: parse_tree_column_attrs.h:131
virtual bool has_constraint_enforcement() const
Check for the [NOT] ENFORCED characteristic.
Definition: parse_tree_column_attrs.h:143
virtual void apply_default_value(Item **) const
Definition: parse_tree_column_attrs.h:120
Node for the COLUMN_FORMAT <DEFAULT|FIXED|DYNAMIC> column attribute.
Definition: parse_tree_column_attrs.h:493
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:507
PT_column_format_column_attr(const POS &pos, column_format_type format)
Definition: parse_tree_column_attrs.h:499
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:494
column_format_type format
Definition: parse_tree_column_attrs.h:496
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:503
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:514
Node for the VISIBLE|INVISIBLE column attribute.
Definition: parse_tree_column_attrs.h:633
PT_column_visibility_attr(const POS &pos, bool is_visible)
Definition: parse_tree_column_attrs.h:637
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:634
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:644
void apply_type_flags(unsigned long *type_flags) const override
Definition: parse_tree_column_attrs.h:639
const bool m_is_visible
Definition: parse_tree_column_attrs.h:649
Node for the COMMENT <comment> column attribute.
Definition: parse_tree_column_attrs.h:330
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:339
void apply_comment(LEX_CSTRING *to) const override
Definition: parse_tree_column_attrs.h:337
PT_comment_column_attr(const POS &pos, const LEX_CSTRING &comment)
Definition: parse_tree_column_attrs.h:334
const LEX_CSTRING comment
Definition: parse_tree_column_attrs.h:331
Node for the [NOT] ENFORCED column attribute.
Definition: parse_tree_column_attrs.h:308
bool has_constraint_enforcement() const override
Check for the [NOT] ENFORCED characteristic.
Definition: parse_tree_column_attrs.h:313
bool is_constraint_enforced() const override
Check if constraint is enforced.
Definition: parse_tree_column_attrs.h:315
PT_constraint_enforcement_attr(const POS &pos, bool enforced)
Definition: parse_tree_column_attrs.h:310
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:317
const bool m_enforced
Definition: parse_tree_column_attrs.h:322
Node for the DATE type.
Definition: parse_tree_column_attrs.h:869
PT_date_type(const POS &pos)
Definition: parse_tree_column_attrs.h:871
Node for the DEFAULT <expression> column attribute.
Definition: parse_tree_column_attrs.h:377
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:393
void apply_default_value(Item **value) const override
Definition: parse_tree_column_attrs.h:385
PT_default_column_attr(const POS &pos, Item *item)
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:386
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:397
Item * item
Definition: parse_tree_column_attrs.h:380
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:378
Definition: parse_tree_column_attrs.h:957
PT_enum_type_tmpl(const POS &pos, List< String > *interval_list, const CHARSET_INFO *charset, bool force_binary)
Definition: parse_tree_column_attrs.h:965
List< String > *const interval_list
Definition: parse_tree_column_attrs.h:958
const CHARSET_INFO * charset
Definition: parse_tree_column_attrs.h:959
const bool force_binary
Definition: parse_tree_column_attrs.h:960
List< String > * get_interval_list() const override
Definition: parse_tree_column_attrs.h:978
const CHARSET_INFO * get_charset() const override
Definition: parse_tree_column_attrs.h:974
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:975
std::remove_const< decltype(PT_type::type)>::type Parent_type
Definition: parse_tree_column_attrs.h:962
Base class for both generated and regular column definitions.
Definition: parse_tree_column_attrs.h:1021
bool do_contextualize(Parse_context *pc) override
Definition: parse_tree_column_attrs.h:1053
bool contextualize_attrs(Column_parse_context *pc, Mem_root_array< PT_column_attr_base * > *attrs)
Definition: parse_tree_column_attrs.h:1092
LEX_CSTRING comment
Definition: parse_tree_column_attrs.h:1035
enum_field_types type
Definition: parse_tree_column_attrs.h:1026
decltype(Alter_info::flags) alter_info_flags_t
Definition: parse_tree_column_attrs.h:1023
Value_generator * gcol_info
Definition: parse_tree_column_attrs.h:1038
const CHARSET_INFO * charset
Definition: parse_tree_column_attrs.h:1030
LEX_CSTRING masking_policy
Definition: parse_tree_column_attrs.h:1041
List< String > * interval_list
Definition: parse_tree_column_attrs.h:1033
const char * dec
Definition: parse_tree_column_attrs.h:1029
bool has_explicit_collation
Definition: parse_tree_column_attrs.h:1031
Item * on_update_value
Definition: parse_tree_column_attrs.h:1037
std::optional< gis::srid_t > m_srid
Definition: parse_tree_column_attrs.h:1042
const char * length
Definition: parse_tree_column_attrs.h:1028
Parse_tree_node super
Definition: parse_tree_column_attrs.h:1022
bool is_overridden(Mem_root_array< PT_column_attr_base * > *attrs, PT_column_attr_base *cand)
Definition: parse_tree_column_attrs.h:1071
PT_type * type_node
Definition: parse_tree_column_attrs.h:1047
alter_info_flags_t alter_info_flags
Definition: parse_tree_column_attrs.h:1034
Item * default_value
Definition: parse_tree_column_attrs.h:1036
Value_generator * default_val_info
Holds the expression to generate default values.
Definition: parse_tree_column_attrs.h:1040
PT_field_def_base(const POS &pos, PT_type *type_node)
Definition: parse_tree_column_attrs.h:1049
Sql_check_constraint_spec_list * check_const_spec_list
Definition: parse_tree_column_attrs.h:1044
ulong type_flags
Definition: parse_tree_column_attrs.h:1027
uint uint_geom_type
Definition: parse_tree_column_attrs.h:1032
Base class for regular (non-generated) column definition nodes.
Definition: parse_tree_column_attrs.h:1136
PT_field_def_base super
Definition: parse_tree_column_attrs.h:1137
Mem_root_array< PT_column_attr_base * > * opt_attrs
Definition: parse_tree_column_attrs.h:1139
bool do_contextualize(Parse_context *pc_arg) override
Definition: parse_tree_column_attrs.h:1146
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:1142
Node for the generated default value, column attribute.
Definition: parse_tree_column_attrs.h:567
Value_generator m_default_value_expression
Definition: parse_tree_column_attrs.h:600
void apply_gen_default_value(Value_generator **default_value_expression) override
Definition: parse_tree_column_attrs.h:577
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:568
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:595
PT_generated_default_val_column_attr(const POS &pos, Item *expr)
Definition: parse_tree_column_attrs.h:571
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:582
Base class for generated column definition nodes.
Definition: parse_tree_column_attrs.h:1161
Item * expr
Definition: parse_tree_column_attrs.h:1165
Mem_root_array< PT_column_attr_base * > * opt_attrs
Definition: parse_tree_column_attrs.h:1166
bool do_contextualize(Parse_context *pc_arg) override
Definition: parse_tree_column_attrs.h:1177
PT_field_def_base super
Definition: parse_tree_column_attrs.h:1162
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:1169
const Virtual_or_stored virtual_or_stored
Definition: parse_tree_column_attrs.h:1164
Node for the JSON type.
Definition: parse_tree_column_attrs.h:1010
PT_json_type(const POS &pos)
Definition: parse_tree_column_attrs.h:1012
const CHARSET_INFO * get_charset() const override
Definition: parse_tree_column_attrs.h:1013
Node for the masking policy, column attribute.
Definition: parse_tree_column_attrs.h:604
LEX_CSTRING m_policy_name
Definition: parse_tree_column_attrs.h:625
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:620
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:605
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:611
PT_masking_policy_name_column_attr(const POS &pos, LEX_CSTRING policy_name)
Definition: parse_tree_column_attrs.h:608
void apply_mask(LEX_CSTRING *masking_policy_name) override
Definition: parse_tree_column_attrs.h:616
Node for the NOT NULL column attribute.
Definition: parse_tree_column_attrs.h:189
PT_not_null_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:191
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:196
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:192
Node for the NULL column attribute.
Definition: parse_tree_column_attrs.h:173
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:181
PT_null_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:175
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:176
Node for numeric types.
Definition: parse_tree_column_attrs.h:687
const char * get_dec() const override
Definition: parse_tree_column_attrs.h:733
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:695
std::remove_const< decltype(PT_type::type)>::type Parent_type
Definition: parse_tree_column_attrs.h:692
const char * dec
Definition: parse_tree_column_attrs.h:689
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:729
const char * get_length() const override
Definition: parse_tree_column_attrs.h:732
PT_numeric_type(const POS &pos, THD *thd, Int_type type_arg, const char *length, ulong options)
Definition: parse_tree_column_attrs.h:714
ulong options
Definition: parse_tree_column_attrs.h:690
const char * length
Definition: parse_tree_column_attrs.h:688
Node for the UPDATE NOW[([<precision>])] column attribute.
Definition: parse_tree_column_attrs.h:405
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:427
PT_on_update_column_attr(const POS &pos, uint8 precision)
Definition: parse_tree_column_attrs.h:412
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:416
const uint8 precision
Definition: parse_tree_column_attrs.h:408
void apply_on_update_value(Item **value) const override
Definition: parse_tree_column_attrs.h:414
Item * item
Definition: parse_tree_column_attrs.h:409
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:406
Node for the PRIMARY [KEY] column attribute.
Definition: parse_tree_column_attrs.h:243
void apply_alter_info_flags(ulonglong *flags) const override
Definition: parse_tree_column_attrs.h:252
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:248
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:256
PT_primary_key_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:245
Node for the NOT SECONDARY column attribute.
Definition: parse_tree_column_attrs.h:204
PT_secondary_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:206
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:212
void apply_type_flags(unsigned long *type_flags) const override
Definition: parse_tree_column_attrs.h:208
Node for the SERIAL DEFAULT VALUE column attribute.
Definition: parse_tree_column_attrs.h:463
void apply_alter_info_flags(ulonglong *flags) const override
Definition: parse_tree_column_attrs.h:472
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:464
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:475
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:469
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:483
PT_serial_default_value_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:467
Definition: parse_tree_column_attrs.h:995
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:999
bool is_serial_type() const override
Definition: parse_tree_column_attrs.h:1002
PT_serial_type(const POS &pos)
Definition: parse_tree_column_attrs.h:997
Node for spatial types.
Definition: parse_tree_column_attrs.h:942
const CHARSET_INFO * get_charset() const override
Definition: parse_tree_column_attrs.h:949
Field::geometry_type geo_type
Definition: parse_tree_column_attrs.h:943
PT_spacial_type(const POS &pos, Field::geometry_type geo_type)
Definition: parse_tree_column_attrs.h:946
uint get_uint_geom_type() const override
Definition: parse_tree_column_attrs.h:950
const char * get_length() const override
Definition: parse_tree_column_attrs.h:951
Node for the SRID column attribute.
Definition: parse_tree_column_attrs.h:550
PT_srid_column_attr(const POS &pos, gis::srid_t srid)
Definition: parse_tree_column_attrs.h:556
void apply_srid_modifier(std::optional< gis::srid_t > *srid) const override
Definition: parse_tree_column_attrs.h:559
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:563
gis::srid_t m_srid
Definition: parse_tree_column_attrs.h:553
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:551
Node for the STORAGE <DEFAULT|DISK|MEMORY> column attribute.
Definition: parse_tree_column_attrs.h:524
PT_column_attr_base super
Definition: parse_tree_column_attrs.h:525
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:537
ha_storage_media media
Definition: parse_tree_column_attrs.h:527
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:533
PT_storage_media_column_attr(const POS &pos, ha_storage_media media)
Definition: parse_tree_column_attrs.h:530
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:544
Node for the TIME, TIMESTAMP and DATETIME types.
Definition: parse_tree_column_attrs.h:884
PT_time_type(const POS &pos, Time_type time_type, const char *dec)
Definition: parse_tree_column_attrs.h:890
const char * dec
Definition: parse_tree_column_attrs.h:885
const char * get_dec() const override
Definition: parse_tree_column_attrs.h:893
std::remove_const< decltype(PT_type::type)>::type Parent_type
Definition: parse_tree_column_attrs.h:887
Node for the TIMESTAMP type.
Definition: parse_tree_column_attrs.h:901
ulong type_flags
Definition: parse_tree_column_attrs.h:905
const char * dec
Definition: parse_tree_column_attrs.h:904
const char * get_dec() const override
Definition: parse_tree_column_attrs.h:911
bool do_contextualize(Parse_context *pc) override
Definition: parse_tree_column_attrs.h:914
ulong get_type_flags() const override
Definition: parse_tree_column_attrs.h:912
PT_timestamp_type(const POS &pos, const char *dec)
Definition: parse_tree_column_attrs.h:908
PT_type super
Definition: parse_tree_column_attrs.h:902
Base class for all column type nodes.
Definition: parse_tree_column_attrs.h:659
virtual bool is_serial_type() const
Definition: parse_tree_column_attrs.h:674
virtual ulong get_type_flags() const
Definition: parse_tree_column_attrs.h:668
virtual const char * get_length() const
Definition: parse_tree_column_attrs.h:669
virtual const CHARSET_INFO * get_charset() const
Definition: parse_tree_column_attrs.h:671
virtual List< String > * get_interval_list() const
Definition: parse_tree_column_attrs.h:673
const enum_field_types type
Definition: parse_tree_column_attrs.h:661
virtual uint get_uint_geom_type() const
Definition: parse_tree_column_attrs.h:672
PT_type(const POS &pos, enum_field_types type)
Definition: parse_tree_column_attrs.h:664
virtual const char * get_dec() const
Definition: parse_tree_column_attrs.h:670
Node for the UNIQUE [KEY] column attribute.
Definition: parse_tree_column_attrs.h:220
enum Attr_type attr_type() const override
Definition: parse_tree_column_attrs.h:233
void apply_alter_info_flags(ulonglong *flags) const override
Definition: parse_tree_column_attrs.h:229
PT_unique_key_column_attr(const POS &pos)
Definition: parse_tree_column_attrs.h:222
void apply_type_flags(ulong *type_flags) const override
Definition: parse_tree_column_attrs.h:225
Definition: parse_tree_column_attrs.h:796
char vector_length_buffer[33]
Definition: parse_tree_column_attrs.h:797
PT_vector_type(const POS &pos, const char *length)
Definition: parse_tree_column_attrs.h:800
const char * get_length() const override
Definition: parse_tree_column_attrs.h:807
const CHARSET_INFO * get_charset() const override
Definition: parse_tree_column_attrs.h:808
Node for the YEAR type.
Definition: parse_tree_column_attrs.h:859
PT_year_type(const POS &pos)
Definition: parse_tree_column_attrs.h:861
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:66
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:1006
void syntax_error_at(const POS &location)
Definition: sql_class.h:4557
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:2685
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:481
void set_field_stored(bool stored)
Definition: field.h:534
void set_field_type(enum_field_types fld_type)
Definition: field.h:517
Item * expr_item
Item representing the generation expression.
Definition: field.h:491
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:7397
void my_error(int nr, myf MyFlags,...)
Fill in and print a previously registered error message.
Definition: my_error.cc:217
#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:49
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:811
Enum_type
Definition: parse_tree_column_attrs.h:954
Char_type
Definition: parse_tree_column_attrs.h:764
PT_enum_type_tmpl< Enum_type::ENUM > PT_enum_type
Node for the ENUM type.
Definition: parse_tree_column_attrs.h:986
PT_enum_type_tmpl< Enum_type::SET > PT_set_type
Node for the SET type.
Definition: parse_tree_column_attrs.h:993
Time_type
Definition: parse_tree_column_attrs.h:874
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
@ enum_type
ENUM, stored in the backend data as long long.
Definition: row_proxy.h:47
column_format_type
Definition: field.h:188
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:704
bool check_masking_policy_name(LEX_CSTRING name)
Check if the name is valid for a masking policy name or a masking policy argument name.
Definition: sql_masking_policy.cc:324
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:74
const bool is_generated
Owner column is a generated one.
Definition: parse_tree_column_attrs.h:75
std::vector< CreateFieldApplier > cf_appliers
Definition: parse_tree_column_attrs.h:76
Column_parse_context(THD *thd_arg, Query_block *select_arg, bool is_generated)
Definition: parse_tree_column_attrs.h:77
bool binlog_need_explicit_defaults_ts
Definition: sql_lex.h:4651
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