mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
- Make user variable prefix recognized by IsArgJson and IsJson
modified: storage/connect/bsonudf.cpp modified: storage/connect/jsonudf.cpp - Stringify option is now a ; separated list of columns modified: storage/connect/json.cpp modified: storage/connect/json.h modified: storage/connect/mongo.h modified: storage/connect/tabbson.cpp modified: storage/connect/tabcmg.cpp modified: storage/connect/tabcmg.h modified: storage/connect/tabjmg.cpp modified: storage/connect/tabjmg.h modified: storage/connect/tabjson.cpp - PrepareColist not a static function anymore (+ typo) modified: storage/connect/taboccur.cpp - JDVC: Recognize schema (database) from a wrapper server modified: storage/connect/tabjdbc.cpp
This commit is contained in:
@@ -1889,24 +1889,31 @@ static int *GetIntArgPtr(PGLOBAL g, UDF_ARGS *args, uint& n)
|
|||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
int IsArgJson(UDF_ARGS *args, uint i)
|
int IsArgJson(UDF_ARGS *args, uint i)
|
||||||
{
|
{
|
||||||
int n = 0;
|
char *pat = args->attributes[i];
|
||||||
|
int n = 0;
|
||||||
|
|
||||||
|
if (*pat == '@') {
|
||||||
|
pat++;
|
||||||
|
|
||||||
|
if (*pat == '\'' || *pat == '"')
|
||||||
|
pat++;
|
||||||
|
|
||||||
|
} // endif pat
|
||||||
|
|
||||||
if (i >= args->arg_count || args->arg_type[i] != STRING_RESULT) {
|
if (i >= args->arg_count || args->arg_type[i] != STRING_RESULT) {
|
||||||
} else if (!strnicmp(args->attributes[i], "Bson_", 5) ||
|
} else if (!strnicmp(pat, "Bson_", 5) || !strnicmp(pat, "Json_", 5)) {
|
||||||
!strnicmp(args->attributes[i], "Json_", 5)) {
|
|
||||||
if (!args->args[i] || strchr("[{ \t\r\n", *args->args[i]))
|
if (!args->args[i] || strchr("[{ \t\r\n", *args->args[i]))
|
||||||
n = 1; // arg should be is a json item
|
n = 1; // arg should be is a json item
|
||||||
// else
|
// else
|
||||||
// n = 2; // A file name may have been returned
|
// n = 2; // A file name may have been returned
|
||||||
|
|
||||||
} else if (!strnicmp(args->attributes[i], "Bbin_", 5)) {
|
} else if (!strnicmp(pat, "Bbin_", 5)) {
|
||||||
if (args->lengths[i] == sizeof(BSON))
|
if (args->lengths[i] == sizeof(BSON))
|
||||||
n = 3; // arg is a binary json item
|
n = 3; // arg is a binary json item
|
||||||
// else
|
// else
|
||||||
// n = 2; // A file name may have been returned
|
// n = 2; // A file name may have been returned
|
||||||
|
|
||||||
} else if (!strnicmp(args->attributes[i], "Bfile_", 6) ||
|
} else if (!strnicmp(pat, "Bfile_", 6) || !strnicmp(pat, "Jfile_", 6)) {
|
||||||
!strnicmp(args->attributes[i], "Jfile_", 6)) {
|
|
||||||
n = 2; // arg is a json file name
|
n = 2; // arg is a json file name
|
||||||
#if 0
|
#if 0
|
||||||
} else if (args->lengths[i]) {
|
} else if (args->lengths[i]) {
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/*************** json CPP Declares Source Code File (.H) ***************/
|
/*************** json CPP Declares Source Code File (.H) ***************/
|
||||||
/* Name: json.cpp Version 1.5 */
|
/* Name: json.cpp Version 1.6 */
|
||||||
/* */
|
/* */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2020 */
|
/* (C) Copyright to the author Olivier BERTRAND 2014 - 2021 */
|
||||||
/* */
|
/* */
|
||||||
/* This file contains the JSON classes functions. */
|
/* This file contains the JSON classes functions. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
@@ -55,6 +55,7 @@ char *GetExceptionDesc(PGLOBAL g, unsigned int e);
|
|||||||
|
|
||||||
char *GetJsonNull(void);
|
char *GetJsonNull(void);
|
||||||
int GetDefaultPrec(void);
|
int GetDefaultPrec(void);
|
||||||
|
int PrepareColist(char*);
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* IsNum: check whether this string is all digits. */
|
/* IsNum: check whether this string is all digits. */
|
||||||
@@ -111,6 +112,27 @@ char* NextChr(PSZ s, char sep)
|
|||||||
return p2;
|
return p2;
|
||||||
} // end of NextChr
|
} // end of NextChr
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
/* Stringified: check that this column is in the stringified list. */
|
||||||
|
/***********************************************************************/
|
||||||
|
bool Stringified(PCSZ strfy, char *colname)
|
||||||
|
{
|
||||||
|
if (strfy) {
|
||||||
|
char *p, colist[512];
|
||||||
|
int n;
|
||||||
|
|
||||||
|
strncpy(colist, strfy, sizeof(colist) - 1);
|
||||||
|
n = PrepareColist(colist);
|
||||||
|
|
||||||
|
for (p = colist; n && p; p += (strlen(p) + 1), n--)
|
||||||
|
if (!stricmp(p, colname))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} // endif strfy
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} // end of Stringified
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Allocate a VAL structure, make sure common field and Nd are zeroed. */
|
/* Allocate a VAL structure, make sure common field and Nd are zeroed. */
|
||||||
|
@@ -67,6 +67,7 @@ PJSON ParseJson(PGLOBAL g, char* s, size_t n, int* prty = NULL, bool* b = NULL);
|
|||||||
PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty);
|
PSZ Serialize(PGLOBAL g, PJSON jsp, char *fn, int pretty);
|
||||||
DllExport bool IsNum(PSZ s);
|
DllExport bool IsNum(PSZ s);
|
||||||
bool IsArray(PSZ s);
|
bool IsArray(PSZ s);
|
||||||
|
bool Stringified(PCSZ strfy, char *colname);
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Class JDOC. The class for parsing and serializing json documents. */
|
/* Class JDOC. The class for parsing and serializing json documents. */
|
||||||
|
@@ -1524,22 +1524,31 @@ static int *GetIntArgPtr(PGLOBAL g, UDF_ARGS *args, uint& n)
|
|||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
int IsJson(UDF_ARGS *args, uint i, bool b)
|
int IsJson(UDF_ARGS *args, uint i, bool b)
|
||||||
{
|
{
|
||||||
int n = 0;
|
char *pat = args->attributes[i];
|
||||||
|
int n = 0;
|
||||||
|
|
||||||
|
if (*pat == '@') {
|
||||||
|
pat++;
|
||||||
|
|
||||||
|
if (*pat == '\'' || *pat == '"')
|
||||||
|
pat++;
|
||||||
|
|
||||||
|
} // endif pat
|
||||||
|
|
||||||
if (i >= args->arg_count || args->arg_type[i] != STRING_RESULT) {
|
if (i >= args->arg_count || args->arg_type[i] != STRING_RESULT) {
|
||||||
} else if (!strnicmp(args->attributes[i], "Json_", 5)) {
|
} else if (!strnicmp(pat, "Json_", 5)) {
|
||||||
if (!args->args[i] || strchr("[{ \t\r\n", *args->args[i]))
|
if (!args->args[i] || strchr("[{ \t\r\n", *args->args[i]))
|
||||||
n = 1; // arg should be is a json item
|
n = 1; // arg should be is a json item
|
||||||
else
|
else
|
||||||
n = 2; // A file name may have been returned
|
n = 2; // A file name may have been returned
|
||||||
|
|
||||||
} else if (!strnicmp(args->attributes[i], "Jbin_", 5)) {
|
} else if (!strnicmp(pat, "Jbin_", 5)) {
|
||||||
if (args->lengths[i] == sizeof(BSON))
|
if (args->lengths[i] == sizeof(BSON))
|
||||||
n = 3; // arg is a binary json item
|
n = 3; // arg is a binary json item
|
||||||
else
|
else
|
||||||
n = 2; // A file name may have been returned
|
n = 2; // A file name may have been returned
|
||||||
|
|
||||||
} else if (!strnicmp(args->attributes[i], "Jfile_", 6)) {
|
} else if (!strnicmp(pat, "Jfile_", 6)) {
|
||||||
n = 2; // arg is a json file name
|
n = 2; // arg is a json file name
|
||||||
} else if (b) {
|
} else if (b) {
|
||||||
char *sap;
|
char *sap;
|
||||||
|
@@ -82,7 +82,7 @@ protected:
|
|||||||
PSZ Wrapname; /* Java wrapper name */
|
PSZ Wrapname; /* Java wrapper name */
|
||||||
PCSZ Colist; /* Options list */
|
PCSZ Colist; /* Options list */
|
||||||
PCSZ Filter; /* Filtering query */
|
PCSZ Filter; /* Filtering query */
|
||||||
PCSZ Strfy; /* Stringify column */
|
PCSZ Strfy; /* The stringify columns */
|
||||||
int Base; /* The array index base */
|
int Base; /* The array index base */
|
||||||
int Version; /* The Java driver version */
|
int Version; /* The Java driver version */
|
||||||
bool Pipe; /* True is Colist is a pipeline */
|
bool Pipe; /* True is Colist is a pipeline */
|
||||||
|
@@ -53,6 +53,7 @@ USETEMP UseTemp(void);
|
|||||||
bool JsonAllPath(void);
|
bool JsonAllPath(void);
|
||||||
int GetDefaultDepth(void);
|
int GetDefaultDepth(void);
|
||||||
char *GetJsonNull(void);
|
char *GetJsonNull(void);
|
||||||
|
bool Stringified(PCSZ, char*);
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* BSONColumns: construct the result blocks containing the description */
|
/* BSONColumns: construct the result blocks containing the description */
|
||||||
@@ -436,7 +437,7 @@ bool BSONDISC::Find(PGLOBAL g, PBVAL jvp, PCSZ key, int j)
|
|||||||
jcol.Type = TYPE_UNKNOWN;
|
jcol.Type = TYPE_UNKNOWN;
|
||||||
jcol.Len = jcol.Scale = 0;
|
jcol.Len = jcol.Scale = 0;
|
||||||
jcol.Cbn = true;
|
jcol.Cbn = true;
|
||||||
} else if (j < lvl && !(strfy && !stricmp(strfy, colname))) {
|
} else if (j < lvl && !Stringified(strfy, colname)) {
|
||||||
if (!fmt[bf])
|
if (!fmt[bf])
|
||||||
strcat(fmt, colname);
|
strcat(fmt, colname);
|
||||||
|
|
||||||
@@ -507,7 +508,7 @@ bool BSONDISC::Find(PGLOBAL g, PBVAL jvp, PCSZ key, int j)
|
|||||||
} // endswitch Type
|
} // endswitch Type
|
||||||
|
|
||||||
} else if (lvl >= 0) {
|
} else if (lvl >= 0) {
|
||||||
if (strfy && !stricmp(strfy, colname)) {
|
if (Stringified(strfy, colname)) {
|
||||||
if (!fmt[bf])
|
if (!fmt[bf])
|
||||||
strcat(fmt, colname);
|
strcat(fmt, colname);
|
||||||
|
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
|
|
||||||
PQRYRES MGOColumns(PGLOBAL g, PCSZ db, PCSZ uri, PTOS topt, bool info);
|
PQRYRES MGOColumns(PGLOBAL g, PCSZ db, PCSZ uri, PTOS topt, bool info);
|
||||||
|
bool Stringified(PCSZ, char*);
|
||||||
|
|
||||||
/* -------------------------- Class CMGDISC -------------------------- */
|
/* -------------------------- Class CMGDISC -------------------------- */
|
||||||
|
|
||||||
@@ -397,7 +398,7 @@ MGOCOL::MGOCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i)
|
|||||||
: EXTCOL(cdp, tdbp, cprec, i, "MGO")
|
: EXTCOL(cdp, tdbp, cprec, i, "MGO")
|
||||||
{
|
{
|
||||||
Tmgp = (PTDBCMG)(tdbp->GetOrig() ? tdbp->GetOrig() : tdbp);
|
Tmgp = (PTDBCMG)(tdbp->GetOrig() ? tdbp->GetOrig() : tdbp);
|
||||||
Sgfy = (Tmgp->Strfy && !stricmp(Tmgp->Strfy, Name));
|
Sgfy = Stringified(Tmgp->Strfy, Name);
|
||||||
|
|
||||||
if ((Jpath = cdp->GetFmt())) {
|
if ((Jpath = cdp->GetFmt())) {
|
||||||
int n = strlen(Jpath) - 1;
|
int n = strlen(Jpath) - 1;
|
||||||
|
@@ -75,7 +75,7 @@ protected:
|
|||||||
CMgoConn *Cmgp; // Points to a C Mongo connection class
|
CMgoConn *Cmgp; // Points to a C Mongo connection class
|
||||||
CMGOPARM Pcg; // Parms passed to Cmgp
|
CMGOPARM Pcg; // Parms passed to Cmgp
|
||||||
const Item *Cnd; // The first condition
|
const Item *Cnd; // The first condition
|
||||||
PCSZ Strfy; // The stringified column
|
PCSZ Strfy; // The stringified columns
|
||||||
int Fpos; // The current row index
|
int Fpos; // The current row index
|
||||||
int N; // The current Rownum
|
int N; // The current Rownum
|
||||||
int B; // Array index base
|
int B; // Array index base
|
||||||
|
@@ -188,6 +188,9 @@ int JDBCDEF::ParseURL(PGLOBAL g, char *url, bool b)
|
|||||||
} else // host is a URL
|
} else // host is a URL
|
||||||
Url = PlugDup(g, server->host);
|
Url = PlugDup(g, server->host);
|
||||||
|
|
||||||
|
if (!Tabschema && server->db)
|
||||||
|
Tabschema = PlugDup(g, server->db);
|
||||||
|
|
||||||
if (!Username && server->username)
|
if (!Username && server->username)
|
||||||
Username = PlugDup(g, server->username);
|
Username = PlugDup(g, server->username);
|
||||||
|
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
#define nullptr 0
|
#define nullptr 0
|
||||||
|
|
||||||
PQRYRES MGOColumns(PGLOBAL g, PCSZ db, PCSZ uri, PTOS topt, bool info);
|
PQRYRES MGOColumns(PGLOBAL g, PCSZ db, PCSZ uri, PTOS topt, bool info);
|
||||||
|
bool Stringified(PCSZ, char*);
|
||||||
|
|
||||||
/* -------------------------- Class JMGDISC -------------------------- */
|
/* -------------------------- Class JMGDISC -------------------------- */
|
||||||
|
|
||||||
@@ -423,15 +424,19 @@ JMGCOL::JMGCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i)
|
|||||||
: EXTCOL(cdp, tdbp, cprec, i, "MGO")
|
: EXTCOL(cdp, tdbp, cprec, i, "MGO")
|
||||||
{
|
{
|
||||||
Tmgp = (PTDBJMG)(tdbp->GetOrig() ? tdbp->GetOrig() : tdbp);
|
Tmgp = (PTDBJMG)(tdbp->GetOrig() ? tdbp->GetOrig() : tdbp);
|
||||||
Sgfy = (Tmgp->Strfy && !stricmp(Tmgp->Strfy, Name));
|
Sgfy = Stringified(Tmgp->Strfy, Name);
|
||||||
|
|
||||||
if ((Jpath = cdp->GetFmt())) {
|
if ((Jpath = cdp->GetFmt())) {
|
||||||
int n = strlen(Jpath) - 1;
|
int n = strlen(Jpath);
|
||||||
|
|
||||||
if (Jpath[n] == '*') {
|
if (n && Jpath[n - 1] == '*') {
|
||||||
Jpath = PlugDup(g, cdp->GetFmt());
|
Jpath = PlugDup(g, cdp->GetFmt());
|
||||||
if (Jpath[n - 1] == '.') n--;
|
|
||||||
Jpath[n] = 0;
|
if (--n) {
|
||||||
|
if (Jpath[n - 1] == '.') n--;
|
||||||
|
Jpath[n] = 0;
|
||||||
|
} // endif n
|
||||||
|
|
||||||
Sgfy = true;
|
Sgfy = true;
|
||||||
} // endif Jpath
|
} // endif Jpath
|
||||||
|
|
||||||
|
@@ -83,7 +83,7 @@ protected:
|
|||||||
PCSZ Coll_name;
|
PCSZ Coll_name;
|
||||||
PCSZ Options; // The MongoDB options
|
PCSZ Options; // The MongoDB options
|
||||||
PCSZ Filter; // The filtering query
|
PCSZ Filter; // The filtering query
|
||||||
PCSZ Strfy; // The stringified column
|
PCSZ Strfy; // The stringified columns
|
||||||
PSZ Wrapname; // Java wrapper name
|
PSZ Wrapname; // Java wrapper name
|
||||||
int Fpos; // The current row index
|
int Fpos; // The current row index
|
||||||
int N; // The current Rownum
|
int N; // The current Rownum
|
||||||
|
@@ -58,6 +58,7 @@ USETEMP UseTemp(void);
|
|||||||
bool JsonAllPath(void);
|
bool JsonAllPath(void);
|
||||||
int GetDefaultDepth(void);
|
int GetDefaultDepth(void);
|
||||||
char *GetJsonNull(void);
|
char *GetJsonNull(void);
|
||||||
|
bool Stringified(PCSZ, char*);
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* JSONColumns: construct the result blocks containing the description */
|
/* JSONColumns: construct the result blocks containing the description */
|
||||||
@@ -447,7 +448,7 @@ bool JSONDISC::Find(PGLOBAL g, PJVAL jvp, PCSZ key, int j)
|
|||||||
jcol.Type = TYPE_UNKNOWN;
|
jcol.Type = TYPE_UNKNOWN;
|
||||||
jcol.Len = jcol.Scale = 0;
|
jcol.Len = jcol.Scale = 0;
|
||||||
jcol.Cbn = true;
|
jcol.Cbn = true;
|
||||||
} else if (j < lvl && !(strfy && !stricmp(strfy, colname))) {
|
} else if (j < lvl && !Stringified(strfy, colname)) {
|
||||||
if (!fmt[bf])
|
if (!fmt[bf])
|
||||||
strcat(fmt, colname);
|
strcat(fmt, colname);
|
||||||
|
|
||||||
@@ -517,7 +518,7 @@ bool JSONDISC::Find(PGLOBAL g, PJVAL jvp, PCSZ key, int j)
|
|||||||
} // endswitch Type
|
} // endswitch Type
|
||||||
|
|
||||||
} else if (lvl >= 0) {
|
} else if (lvl >= 0) {
|
||||||
if (strfy && !stricmp(strfy, colname)) {
|
if (Stringified(strfy, colname)) {
|
||||||
if (!fmt[bf])
|
if (!fmt[bf])
|
||||||
strcat(fmt, colname);
|
strcat(fmt, colname);
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
/************ TabOccur CPP Declares Source Code File (.CPP) ************/
|
/************ TabOccur CPP Declares Source Code File (.CPP) ************/
|
||||||
/* Name: TABOCCUR.CPP Version 1.2 */
|
/* Name: TABOCCUR.CPP Version 1.2 */
|
||||||
/* */
|
/* */
|
||||||
/* (C) Copyright to the author Olivier BERTRAND 2013 - 2017 */
|
/* (C) Copyright to the author Olivier BERTRAND 2013 - 2021 */
|
||||||
/* */
|
/* */
|
||||||
/* OCCUR: Table that provides a view of a source table where the */
|
/* OCCUR: Table that provides a view of a source table where the */
|
||||||
/* contain of several columns of the source table is placed in only */
|
/* contain of several columns of the source table is placed in only */
|
||||||
@@ -52,8 +52,8 @@
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Prepare and count columns in the column list. */
|
/* Prepare and count columns in the column list. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
static int PrepareColist(char *colist)
|
int PrepareColist(char *colist)
|
||||||
{
|
{
|
||||||
char *p, *pn;
|
char *p, *pn;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ static int PrepareColist(char *colist)
|
|||||||
} // endif p
|
} // endif p
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
} // end of PrepareColist
|
} // end of PrepareColist
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* OcrColumns: constructs the result blocks containing all the columns */
|
/* OcrColumns: constructs the result blocks containing all the columns */
|
||||||
@@ -79,7 +79,7 @@ static int PrepareColist(char *colist)
|
|||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
bool OcrColumns(PGLOBAL g, PQRYRES qrp, const char *col,
|
bool OcrColumns(PGLOBAL g, PQRYRES qrp, const char *col,
|
||||||
const char *ocr, const char *rank)
|
const char *ocr, const char *rank)
|
||||||
{
|
{
|
||||||
char *pn, *colist;
|
char *pn, *colist;
|
||||||
int i, k, m, n = 0, c = 0, j = qrp->Nblin;
|
int i, k, m, n = 0, c = 0, j = qrp->Nblin;
|
||||||
bool rk, b = false;
|
bool rk, b = false;
|
||||||
@@ -168,7 +168,7 @@ bool OcrColumns(PGLOBAL g, PQRYRES qrp, const char *col,
|
|||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
qrp->Nblin = j;
|
qrp->Nblin = j;
|
||||||
return false;
|
return false;
|
||||||
} // end of OcrColumns
|
} // end of OcrColumns
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
/* OcrSrcCols: constructs the result blocks containing all the columns */
|
/* OcrSrcCols: constructs the result blocks containing all the columns */
|
||||||
@@ -176,7 +176,7 @@ bool OcrColumns(PGLOBAL g, PQRYRES qrp, const char *col,
|
|||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
bool OcrSrcCols(PGLOBAL g, PQRYRES qrp, const char *col,
|
bool OcrSrcCols(PGLOBAL g, PQRYRES qrp, const char *col,
|
||||||
const char *ocr, const char *rank)
|
const char *ocr, const char *rank)
|
||||||
{
|
{
|
||||||
char *pn, *colist;
|
char *pn, *colist;
|
||||||
int i, k, m, n = 0, c = 0;
|
int i, k, m, n = 0, c = 0;
|
||||||
bool rk, b = false;
|
bool rk, b = false;
|
||||||
@@ -249,7 +249,7 @@ bool OcrSrcCols(PGLOBAL g, PQRYRES qrp, const char *col,
|
|||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
qrp->Nblin = i;
|
qrp->Nblin = i;
|
||||||
return false;
|
return false;
|
||||||
} // end of OcrSrcCols
|
} // end of OcrSrcCols
|
||||||
|
|
||||||
/* -------------- Implementation of the OCCUR classes ---------------- */
|
/* -------------- Implementation of the OCCUR classes ---------------- */
|
||||||
|
|
||||||
@@ -257,24 +257,24 @@ bool OcrSrcCols(PGLOBAL g, PQRYRES qrp, const char *col,
|
|||||||
/* DefineAM: define specific AM block values from OCCUR table. */
|
/* DefineAM: define specific AM block values from OCCUR table. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
bool OCCURDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
|
bool OCCURDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
|
||||||
{
|
{
|
||||||
Rcol = GetStringCatInfo(g, "RankCol", "");
|
Rcol = GetStringCatInfo(g, "RankCol", "");
|
||||||
Colist = GetStringCatInfo(g, "Colist", "");
|
Colist = GetStringCatInfo(g, "Colist", "");
|
||||||
Xcol = GetStringCatInfo(g, "OccurCol", Colist);
|
Xcol = GetStringCatInfo(g, "OccurCol", Colist);
|
||||||
return PRXDEF::DefineAM(g, am, poff);
|
return PRXDEF::DefineAM(g, am, poff);
|
||||||
} // end of DefineAM
|
} // end of DefineAM
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* GetTable: makes a new TDB of the proper type. */
|
/* GetTable: makes a new TDB of the proper type. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
PTDB OCCURDEF::GetTable(PGLOBAL g, MODE)
|
PTDB OCCURDEF::GetTable(PGLOBAL g, MODE)
|
||||||
{
|
{
|
||||||
if (Catfunc != FNC_COL)
|
if (Catfunc != FNC_COL)
|
||||||
return new(g) TDBOCCUR(this);
|
return new(g) TDBOCCUR(this);
|
||||||
else
|
else
|
||||||
return new(g) TDBTBC(this);
|
return new(g) TDBTBC(this);
|
||||||
|
|
||||||
} // end of GetTable
|
} // end of GetTable
|
||||||
|
|
||||||
/* ------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------- */
|
||||||
|
|
||||||
@@ -282,7 +282,7 @@ PTDB OCCURDEF::GetTable(PGLOBAL g, MODE)
|
|||||||
/* Implementation of the TDBOCCUR class. */
|
/* Implementation of the TDBOCCUR class. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
TDBOCCUR::TDBOCCUR(POCCURDEF tdp) : TDBPRX(tdp)
|
TDBOCCUR::TDBOCCUR(POCCURDEF tdp) : TDBPRX(tdp)
|
||||||
{
|
{
|
||||||
//Tdbp = NULL; // Source table (in TDBPRX)
|
//Tdbp = NULL; // Source table (in TDBPRX)
|
||||||
Tabname = tdp->Tablep->GetName(); // Name of source table
|
Tabname = tdp->Tablep->GetName(); // Name of source table
|
||||||
Colist = tdp->Colist; // List of source columns
|
Colist = tdp->Colist; // List of source columns
|
||||||
@@ -294,13 +294,13 @@ TDBOCCUR::TDBOCCUR(POCCURDEF tdp) : TDBPRX(tdp)
|
|||||||
N = 0; // The current table index
|
N = 0; // The current table index
|
||||||
M = 0; // The occurence rank
|
M = 0; // The occurence rank
|
||||||
RowFlag = 0; // 0: Ok, 1: Same, 2: Skip
|
RowFlag = 0; // 0: Ok, 1: Same, 2: Skip
|
||||||
} // end of TDBOCCUR constructor
|
} // end of TDBOCCUR constructor
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Allocate OCCUR/SRC column description block. */
|
/* Allocate OCCUR/SRC column description block. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
PCOL TDBOCCUR::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
|
PCOL TDBOCCUR::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
|
||||||
{
|
{
|
||||||
PCOL colp = NULL;
|
PCOL colp = NULL;
|
||||||
|
|
||||||
if (!stricmp(cdp->GetName(), Rcolumn)) {
|
if (!stricmp(cdp->GetName(), Rcolumn)) {
|
||||||
@@ -321,13 +321,13 @@ PCOL TDBOCCUR::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
|
|||||||
} // endif cprec
|
} // endif cprec
|
||||||
|
|
||||||
return colp;
|
return colp;
|
||||||
} // end of MakeCol
|
} // end of MakeCol
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Initializes the table. */
|
/* Initializes the table. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
bool TDBOCCUR::InitTable(PGLOBAL g)
|
bool TDBOCCUR::InitTable(PGLOBAL g)
|
||||||
{
|
{
|
||||||
if (!Tdbp)
|
if (!Tdbp)
|
||||||
// Get the table description block of this table
|
// Get the table description block of this table
|
||||||
if (!(Tdbp = GetSubTable(g, ((POCCURDEF)To_Def)->Tablep, TRUE)))
|
if (!(Tdbp = GetSubTable(g, ((POCCURDEF)To_Def)->Tablep, TRUE)))
|
||||||
@@ -338,13 +338,13 @@ bool TDBOCCUR::InitTable(PGLOBAL g)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} // end of InitTable
|
} // end of InitTable
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Allocate OCCUR column description block. */
|
/* Allocate OCCUR column description block. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
bool TDBOCCUR::MakeColumnList(PGLOBAL g)
|
bool TDBOCCUR::MakeColumnList(PGLOBAL g)
|
||||||
{
|
{
|
||||||
char *pn;
|
char *pn;
|
||||||
int i;
|
int i;
|
||||||
PCOL colp;
|
PCOL colp;
|
||||||
@@ -371,13 +371,13 @@ bool TDBOCCUR::MakeColumnList(PGLOBAL g)
|
|||||||
} // endfor i
|
} // endfor i
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} // end of MakeColumnList
|
} // end of MakeColumnList
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Allocate OCCUR column description block for a view. */
|
/* Allocate OCCUR column description block for a view. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
bool TDBOCCUR::ViewColumnList(PGLOBAL g)
|
bool TDBOCCUR::ViewColumnList(PGLOBAL g)
|
||||||
{
|
{
|
||||||
char *pn;
|
char *pn;
|
||||||
int i;
|
int i;
|
||||||
PCOL colp, cp;
|
PCOL colp, cp;
|
||||||
@@ -412,13 +412,13 @@ bool TDBOCCUR::ViewColumnList(PGLOBAL g)
|
|||||||
} // endif Col
|
} // endif Col
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} // end of ViewColumnList
|
} // end of ViewColumnList
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* OCCUR GetMaxSize: returns the maximum number of rows in the table. */
|
/* OCCUR GetMaxSize: returns the maximum number of rows in the table. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
int TDBOCCUR::GetMaxSize(PGLOBAL g)
|
int TDBOCCUR::GetMaxSize(PGLOBAL g)
|
||||||
{
|
{
|
||||||
if (MaxSize < 0) {
|
if (MaxSize < 0) {
|
||||||
if (!(Tdbp = GetSubTable(g, ((POCCURDEF)To_Def)->Tablep, TRUE)))
|
if (!(Tdbp = GetSubTable(g, ((POCCURDEF)To_Def)->Tablep, TRUE)))
|
||||||
return 0;
|
return 0;
|
||||||
@@ -427,22 +427,22 @@ int TDBOCCUR::GetMaxSize(PGLOBAL g)
|
|||||||
} // endif MaxSize
|
} // endif MaxSize
|
||||||
|
|
||||||
return MaxSize;
|
return MaxSize;
|
||||||
} // end of GetMaxSize
|
} // end of GetMaxSize
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* In this sample, ROWID will be the (virtual) row number, */
|
/* In this sample, ROWID will be the (virtual) row number, */
|
||||||
/* while ROWNUM will be the occurence rank in the multiple column. */
|
/* while ROWNUM will be the occurence rank in the multiple column. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
int TDBOCCUR::RowNumber(PGLOBAL, bool b)
|
int TDBOCCUR::RowNumber(PGLOBAL, bool b)
|
||||||
{
|
{
|
||||||
return (b) ? M : N;
|
return (b) ? M : N;
|
||||||
} // end of RowNumber
|
} // end of RowNumber
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* OCCUR Access Method opening routine. */
|
/* OCCUR Access Method opening routine. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
bool TDBOCCUR::OpenDB(PGLOBAL g)
|
bool TDBOCCUR::OpenDB(PGLOBAL g)
|
||||||
{
|
{
|
||||||
if (Use == USE_OPEN) {
|
if (Use == USE_OPEN) {
|
||||||
/*******************************************************************/
|
/*******************************************************************/
|
||||||
/* Table already open, just replace it at its beginning. */
|
/* Table already open, just replace it at its beginning. */
|
||||||
@@ -491,13 +491,13 @@ bool TDBOCCUR::OpenDB(PGLOBAL g)
|
|||||||
|
|
||||||
Use = USE_OPEN;
|
Use = USE_OPEN;
|
||||||
return ViewColumnList(g);
|
return ViewColumnList(g);
|
||||||
} // end of OpenDB
|
} // end of OpenDB
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* Data Base read routine for OCCUR access method. */
|
/* Data Base read routine for OCCUR access method. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
int TDBOCCUR::ReadDB(PGLOBAL g)
|
int TDBOCCUR::ReadDB(PGLOBAL g)
|
||||||
{
|
{
|
||||||
int rc = RC_OK;
|
int rc = RC_OK;
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
@@ -518,7 +518,7 @@ int TDBOCCUR::ReadDB(PGLOBAL g)
|
|||||||
|
|
||||||
N++;
|
N++;
|
||||||
return rc;
|
return rc;
|
||||||
} // end of ReadDB
|
} // end of ReadDB
|
||||||
|
|
||||||
// ------------------------ OCCURCOL functions ----------------------------
|
// ------------------------ OCCURCOL functions ----------------------------
|
||||||
|
|
||||||
@@ -527,17 +527,17 @@ int TDBOCCUR::ReadDB(PGLOBAL g)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
OCCURCOL::OCCURCOL(PCOLDEF cdp, PTDBOCCUR tdbp, int n)
|
OCCURCOL::OCCURCOL(PCOLDEF cdp, PTDBOCCUR tdbp, int n)
|
||||||
: COLBLK(cdp, tdbp, n)
|
: COLBLK(cdp, tdbp, n)
|
||||||
{
|
{
|
||||||
// Set additional OCCUR access method information for column.
|
// Set additional OCCUR access method information for column.
|
||||||
I = 0;
|
I = 0;
|
||||||
} // end of OCCURCOL constructor
|
} // end of OCCURCOL constructor
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* ReadColumn: what this routine does is to access the columns of */
|
/* ReadColumn: what this routine does is to access the columns of */
|
||||||
/* list, extract their value and convert it to buffer type. */
|
/* list, extract their value and convert it to buffer type. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
void OCCURCOL::ReadColumn(PGLOBAL g)
|
void OCCURCOL::ReadColumn(PGLOBAL g)
|
||||||
{
|
{
|
||||||
PTDBOCCUR tdbp = (PTDBOCCUR)To_Tdb;
|
PTDBOCCUR tdbp = (PTDBOCCUR)To_Tdb;
|
||||||
PCOL *col = tdbp->Col;
|
PCOL *col = tdbp->Col;
|
||||||
|
|
||||||
@@ -559,7 +559,7 @@ void OCCURCOL::ReadColumn(PGLOBAL g)
|
|||||||
// Set the OCCUR column value from the Ith source column value
|
// Set the OCCUR column value from the Ith source column value
|
||||||
Value->SetValue_pval(col[I++]->GetValue());
|
Value->SetValue_pval(col[I++]->GetValue());
|
||||||
tdbp->RowFlag = 1;
|
tdbp->RowFlag = 1;
|
||||||
} // end of ReadColumn
|
} // end of ReadColumn
|
||||||
|
|
||||||
|
|
||||||
// ------------------------ RANKCOL functions ---------------------------
|
// ------------------------ RANKCOL functions ---------------------------
|
||||||
@@ -569,7 +569,7 @@ void OCCURCOL::ReadColumn(PGLOBAL g)
|
|||||||
/* list, extract its name and set to it the rank column value. */
|
/* list, extract its name and set to it the rank column value. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
void RANKCOL::ReadColumn(PGLOBAL)
|
void RANKCOL::ReadColumn(PGLOBAL)
|
||||||
{
|
{
|
||||||
PTDBOCCUR tdbp = (PTDBOCCUR)To_Tdb;
|
PTDBOCCUR tdbp = (PTDBOCCUR)To_Tdb;
|
||||||
PCOL *col = tdbp->Col;
|
PCOL *col = tdbp->Col;
|
||||||
|
|
||||||
@@ -584,4 +584,4 @@ void RANKCOL::ReadColumn(PGLOBAL)
|
|||||||
|
|
||||||
} // endelse
|
} // endelse
|
||||||
|
|
||||||
} // end of ReadColumn
|
} // end of ReadColumn
|
||||||
|
Reference in New Issue
Block a user