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

Method OpenDB

storage/connect/tabodbc.cpp:533–665  ·  view source on GitHub ↗

/ ODBC Access Method opening routine. */ New method now that this routine is called recursively (last table */ first in reverse order): index blocks are immediately linked to */ join block of next table if it exists or else are discarted. */ /

Source from the content-addressed store, hash-verified

531/* join block of next table if it exists or else are discarted. */
532/***********************************************************************/
533bool TDBODBC::OpenDB(PGLOBAL g)
534{
535 bool rc = true;
536
537 if (trace(1))
538 htrc("ODBC OpenDB: tdbp=%p tdb=R%d use=%dmode=%d\n",
539 this, Tdb_No, Use, Mode);
540
541 if (Use == USE_OPEN) {
542 /*******************************************************************/
543 /* Table already open, just replace it at its beginning. */
544 /*******************************************************************/
545 if (Memory == 1) {
546 if ((Qrp = Ocp->AllocateResult(g)))
547 Memory = 2; // Must be filled
548 else
549 Memory = 0; // Allocation failed, don't use it
550
551 } else if (Memory == 2)
552 Memory = 3; // Ok to use memory result
553
554 if (Memory < 3) {
555 // Method will depend on cursor type
556 if (Query && (Rbuf = Ocp->Rewind(Query->GetStr(), (PODBCCOL)Columns)) < 0) {
557 if (Mode != MODE_READX) {
558 Ocp->Close();
559 return true;
560 } else {
561 Rbuf = 0;
562 }
563 }
564 } else {
565 Rbuf = Qrp->Nblin;
566 }
567
568 CurNum = 0;
569 Fpos = 0;
570 Curpos = 1;
571 return false;
572 } // endif use
573
574 /*********************************************************************/
575 /* Open an ODBC connection for this table. */
576 /* Note: this may not be the proper way to do. Perhaps it is better */
577 /* to test whether a connection is already open for this datasource */
578 /* and if so to allocate just a new result set. But this only for */
579 /* drivers allowing concurency in getting results ??? */
580 /*********************************************************************/
581 if (!Ocp)
582 Ocp = new(g) ODBConn(g, this);
583 else if (Ocp->IsOpen())
584 Ocp->Close();
585
586 if (Ocp->Open(Connect, &Ops, Options) < 1)
587 return true;
588 else if (Quoted)
589 Quote = Ocp->GetQuoteChar();
590

Callers

nothing calls this directly

Calls 15

PlugDupFunction · 0.85
IsOpenMethod · 0.80
InitValueMethod · 0.80
IsSpecialMethod · 0.80
AllocateBuffersMethod · 0.80
ExecDirectSQLMethod · 0.80
htrcFunction · 0.70
AllocateResultMethod · 0.45
RewindMethod · 0.45
CloseMethod · 0.45
OpenMethod · 0.45
GetQuoteCharMethod · 0.45

Tested by

no test coverage detected