MCPcopy Create free account
hub / github.com/MariaDB/server / show_create_view

Function show_create_view

sql/sql_show.cc:2752–2818  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2750
2751
2752static int show_create_view(THD *thd, TABLE_LIST *table, String *buff)
2753{
2754 my_bool compact_view_name= TRUE;
2755 my_bool foreign_db_mode= (thd->variables.sql_mode & (MODE_POSTGRESQL |
2756 MODE_ORACLE |
2757 MODE_MSSQL |
2758 MODE_DB2 |
2759 MODE_MAXDB |
2760 MODE_ANSI)) != 0;
2761
2762 if (!thd->db.str || cmp(&thd->db, &table->view_db))
2763 /*
2764 print compact view name if the view belongs to the current database
2765 */
2766 compact_view_name= table->compact_view_format= FALSE;
2767 else
2768 {
2769 /*
2770 Compact output format for view body can be used
2771 if this view only references table inside it's own db
2772 */
2773 TABLE_LIST *tbl;
2774 table->compact_view_format= TRUE;
2775 for (tbl= thd->lex->query_tables;
2776 tbl;
2777 tbl= tbl->next_global)
2778 {
2779 if (!tbl->is_derived() &&
2780 cmp(&table->view_db, tbl->view ? &tbl->view_db : &tbl->db))
2781 {
2782 table->compact_view_format= FALSE;
2783 break;
2784 }
2785 }
2786 }
2787
2788 buff->append(STRING_WITH_LEN("CREATE "));
2789 if (!foreign_db_mode)
2790 {
2791 view_store_options(thd, table, buff);
2792 }
2793 buff->append(STRING_WITH_LEN("VIEW "));
2794 if (!compact_view_name)
2795 {
2796 append_identifier(thd, buff, &table->view_db);
2797 buff->append('.');
2798 }
2799 append_identifier(thd, buff, &table->view_name);
2800 buff->append(STRING_WITH_LEN(" AS "));
2801
2802 /*
2803 We can't just use table->query, because our SQL_MODE may trigger
2804 a different syntax, like when ANSI_QUOTES is defined.
2805 */
2806 table->view->unit.print(buff, enum_query_type(QT_VIEW_INTERNAL |
2807 QT_ITEM_ORIGINAL_FUNC_NULLIF |
2808 QT_NO_WRAPPERS_FOR_TVC_IN_VIEW));
2809

Callers 1

Calls 7

view_store_optionsFunction · 0.85
enum_query_typeEnum · 0.85
is_derivedMethod · 0.80
cmpFunction · 0.70
append_identifierFunction · 0.70
appendMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected