/ MySQL Access Method opening routine. */ /
| 874 | /* MySQL Access Method opening routine. */ |
| 875 | /***********************************************************************/ |
| 876 | bool TDBMYSQL::OpenDB(PGLOBAL g) |
| 877 | { |
| 878 | if (Use == USE_OPEN) { |
| 879 | /*******************************************************************/ |
| 880 | /* Table already open, just replace it at its beginning. */ |
| 881 | /*******************************************************************/ |
| 882 | if (Myc.Rewind(g, (Mode == MODE_READX) ? Query->GetStr() : NULL) != RC_OK) |
| 883 | return true; |
| 884 | |
| 885 | N = -1; |
| 886 | return false; |
| 887 | } // endif use |
| 888 | |
| 889 | /*********************************************************************/ |
| 890 | /* Open a MySQL connection for this table. */ |
| 891 | /* Note: this may not be the proper way to do. Perhaps it is better */ |
| 892 | /* to test whether a connection is already open for this server */ |
| 893 | /* and if so to allocate just a new result set. But this only for */ |
| 894 | /* servers allowing concurency in getting results ??? */ |
| 895 | /*********************************************************************/ |
| 896 | if (!Myc.Connected()) { |
| 897 | if (Myc.Open(g, Host, Schema, User, Pwd, Port, csname)) |
| 898 | return true; |
| 899 | |
| 900 | } // endif Connected |
| 901 | |
| 902 | /*********************************************************************/ |
| 903 | /* Take care of DATE columns. */ |
| 904 | /*********************************************************************/ |
| 905 | for (PMYCOL colp = (PMYCOL)Columns; colp; colp = (PMYCOL)colp->Next) |
| 906 | if (colp->Buf_Type == TYPE_DATE) |
| 907 | // Format must match DATETIME MySQL type |
| 908 | ((DTVAL*)colp->GetValue())->SetFormat(g, "YYYY-MM-DD hh:mm:ss", 19); |
| 909 | |
| 910 | /*********************************************************************/ |
| 911 | /* Allocate whatever is used for getting results. */ |
| 912 | /*********************************************************************/ |
| 913 | if (Mode == MODE_READ || Mode == MODE_READX) { |
| 914 | MakeSelect(g, Mode == MODE_READX); |
| 915 | if (Mode == MODE_READ && !Query) |
| 916 | { |
| 917 | Myc.Close(); |
| 918 | return true; |
| 919 | } |
| 920 | m_Rc = (Mode == MODE_READ) |
| 921 | ? Myc.ExecSQL(g, Query->GetStr()) : RC_OK; |
| 922 | |
| 923 | #if 0 |
| 924 | if (!Myc.m_Res || !Myc.m_Fields) { |
| 925 | snprintf(g->Message, sizeof(g->Message), "%s result", (Myc.m_Res) ? "Void" : "No"); |
| 926 | Myc.Close(); |
| 927 | return true; |
| 928 | } // endif m_Res |
| 929 | #endif // 0 |
| 930 | |
| 931 | if (!m_Rc && Srcdef) |
| 932 | if (SetColumnRanks(g)) |
| 933 | return true; |
nothing calls this directly
no test coverage detected