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

Method GetMetaData

storage/connect/odbconn.cpp:1970–2088  ·  view source on GitHub ↗

/ GetMetaData: constructs the result blocks containing the */ description of all the columns of an SQL command. */ /

Source from the content-addressed store, hash-verified

1968/* description of all the columns of an SQL command. */
1969/**************************************************************************/
1970PQRYRES ODBConn::GetMetaData(PGLOBAL g, PCSZ dsn, PCSZ src)
1971 {
1972 static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_INT,
1973 TYPE_SHORT, TYPE_SHORT};
1974 static XFLD fldtyp[] = {FLD_NAME, FLD_TYPE, FLD_PREC,
1975 FLD_SCALE, FLD_NULL};
1976 static unsigned int length[] = {0, 6, 10, 6, 6};
1977 unsigned char cn[60];
1978 int qcol = 5;
1979 short nl, type, prec, nul, cns = (short)sizeof(cn);
1980 PQRYRES qrp = NULL;
1981 PCOLRES crp;
1982 USHORT i;
1983 SQLULEN n;
1984 SWORD ncol;
1985 RETCODE rc;
1986 HSTMT hstmt;
1987
1988 try {
1989 rc = SQLAllocStmt(m_hdbc, &hstmt);
1990
1991 if (!Check(rc))
1992 ThrowDBX(SQL_INVALID_HANDLE, "SQLAllocStmt");
1993
1994 OnSetOptions(hstmt);
1995
1996 do {
1997 rc = SQLPrepare(hstmt, (PUCHAR)src, SQL_NTS);
1998// rc = SQLExecDirect(hstmt, (PUCHAR)src, SQL_NTS);
1999 } while (rc == SQL_STILL_EXECUTING);
2000
2001 if (!Check(rc))
2002 ThrowDBX(rc, "SQLExecDirect", hstmt);
2003
2004 do {
2005 rc = SQLNumResultCols(hstmt, &ncol);
2006 } while (rc == SQL_STILL_EXECUTING);
2007
2008 if (!Check(rc))
2009 ThrowDBX(rc, "SQLNumResultCols", hstmt);
2010
2011 if (ncol) for (i = 1; i <= ncol; i++) {
2012 do {
2013 rc = SQLDescribeCol(hstmt, i, NULL, 0, &nl, NULL, NULL, NULL, NULL);
2014 } while (rc == SQL_STILL_EXECUTING);
2015
2016 if (!Check(rc))
2017 ThrowDBX(rc, "SQLDescribeCol", hstmt);
2018
2019 length[0] = MY_MAX(length[0], (UINT)nl);
2020 } // endfor i
2021
2022 } catch(DBX *x) {
2023 snprintf(g->Message, sizeof(g->Message), "%s: %s", x->m_Msg, x->GetErrorMessage(0));
2024 goto err;
2025 } // end try/catch
2026
2027 if (!ncol) {

Callers 1

ODBCSrcColsFunction · 0.45

Calls 5

PlgAllocResultFunction · 0.85
CloseFunction · 0.85
GetErrorMessageMethod · 0.80
CheckClass · 0.50
SetValueMethod · 0.45

Tested by

no test coverage detected