mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +03:00
Another PGINDENT run that changes variable indenting and case label indenting. Also static variable indenting.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/catalog_utils.c,v 1.23 1997/09/07 04:44:42 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/catalog_utils.c,v 1.24 1997/09/08 02:25:15 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -52,9 +52,9 @@
|
||||
|
||||
struct
|
||||
{
|
||||
char *field;
|
||||
int code;
|
||||
} special_attr[] =
|
||||
char *field;
|
||||
int code;
|
||||
} special_attr[] =
|
||||
|
||||
{
|
||||
{
|
||||
@@ -94,7 +94,7 @@ struct
|
||||
|
||||
#define SPECIALS (sizeof(special_attr)/sizeof(*special_attr))
|
||||
|
||||
static char *attnum_type[SPECIALS] = {
|
||||
static char *attnum_type[SPECIALS] = {
|
||||
"tid",
|
||||
"oid",
|
||||
"xid",
|
||||
@@ -118,10 +118,10 @@ static char *attnum_type[SPECIALS] = {
|
||||
|
||||
typedef struct _InhPaths
|
||||
{
|
||||
int nsupers; /* number of superclasses */
|
||||
Oid self; /* this class */
|
||||
Oid *supervec; /* vector of superclasses */
|
||||
} InhPaths;
|
||||
int nsupers; /* number of superclasses */
|
||||
Oid self; /* this class */
|
||||
Oid *supervec; /* vector of superclasses */
|
||||
} InhPaths;
|
||||
|
||||
/*
|
||||
* This structure holds a list of possible functions or operators that
|
||||
@@ -129,16 +129,16 @@ typedef struct _InhPaths
|
||||
*/
|
||||
typedef struct _CandidateList
|
||||
{
|
||||
Oid *args;
|
||||
Oid *args;
|
||||
struct _CandidateList *next;
|
||||
} *CandidateList;
|
||||
} *CandidateList;
|
||||
|
||||
static Oid **argtype_inherit(int nargs, Oid * oid_array);
|
||||
static Oid **genxprod(InhPaths * arginh, int nargs);
|
||||
static int findsupers(Oid relid, Oid ** supervec);
|
||||
static bool check_typeid(Oid id);
|
||||
static char *instr1(TypeTupleForm tp, char *string, int typlen);
|
||||
static void op_error(char *op, Oid arg1, Oid arg2);
|
||||
static Oid **argtype_inherit(int nargs, Oid * oid_array);
|
||||
static Oid **genxprod(InhPaths * arginh, int nargs);
|
||||
static int findsupers(Oid relid, Oid ** supervec);
|
||||
static bool check_typeid(Oid id);
|
||||
static char *instr1(TypeTupleForm tp, char *string, int typlen);
|
||||
static void op_error(char *op, Oid arg1, Oid arg2);
|
||||
|
||||
/* check to see if a type id is valid,
|
||||
* returns true if it is. By using this call before calling
|
||||
@@ -146,7 +146,7 @@ static void op_error(char *op, Oid arg1, Oid arg2);
|
||||
* can be produced because the caller typically has more context of
|
||||
* what's going on - jolly
|
||||
*/
|
||||
static bool
|
||||
static bool
|
||||
check_typeid(Oid id)
|
||||
{
|
||||
return (SearchSysCacheTuple(TYPOID,
|
||||
@@ -159,7 +159,7 @@ check_typeid(Oid id)
|
||||
Type
|
||||
get_id_type(Oid id)
|
||||
{
|
||||
HeapTuple tup;
|
||||
HeapTuple tup;
|
||||
|
||||
if (!(tup = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(id),
|
||||
0, 0, 0)))
|
||||
@@ -171,11 +171,11 @@ get_id_type(Oid id)
|
||||
}
|
||||
|
||||
/* return a type name, given a typeid */
|
||||
char *
|
||||
char *
|
||||
get_id_typname(Oid id)
|
||||
{
|
||||
HeapTuple tup;
|
||||
TypeTupleForm typetuple;
|
||||
HeapTuple tup;
|
||||
TypeTupleForm typetuple;
|
||||
|
||||
if (!(tup = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(id),
|
||||
0, 0, 0)))
|
||||
@@ -191,7 +191,7 @@ get_id_typname(Oid id)
|
||||
Type
|
||||
type(char *s)
|
||||
{
|
||||
HeapTuple tup;
|
||||
HeapTuple tup;
|
||||
|
||||
if (s == NULL)
|
||||
{
|
||||
@@ -245,7 +245,7 @@ typeid(Type tp)
|
||||
int16
|
||||
tlen(Type t)
|
||||
{
|
||||
TypeTupleForm typ;
|
||||
TypeTupleForm typ;
|
||||
|
||||
typ = (TypeTupleForm) GETSTRUCT(t);
|
||||
return (typ->typlen);
|
||||
@@ -255,17 +255,17 @@ tlen(Type t)
|
||||
bool
|
||||
tbyval(Type t)
|
||||
{
|
||||
TypeTupleForm typ;
|
||||
TypeTupleForm typ;
|
||||
|
||||
typ = (TypeTupleForm) GETSTRUCT(t);
|
||||
return (typ->typbyval);
|
||||
}
|
||||
|
||||
/* given type (as type struct), return the name of type */
|
||||
char *
|
||||
char *
|
||||
tname(Type t)
|
||||
{
|
||||
TypeTupleForm typ;
|
||||
TypeTupleForm typ;
|
||||
|
||||
typ = (TypeTupleForm) GETSTRUCT(t);
|
||||
return (typ->typname).data;
|
||||
@@ -275,7 +275,7 @@ tname(Type t)
|
||||
int
|
||||
tbyvalue(Type t)
|
||||
{
|
||||
TypeTupleForm typ;
|
||||
TypeTupleForm typ;
|
||||
|
||||
typ = (TypeTupleForm) GETSTRUCT(t);
|
||||
return (typ->typbyval);
|
||||
@@ -285,7 +285,7 @@ tbyvalue(Type t)
|
||||
static char
|
||||
typetypetype(Type t)
|
||||
{
|
||||
TypeTupleForm typ;
|
||||
TypeTupleForm typ;
|
||||
|
||||
typ = (TypeTupleForm) GETSTRUCT(t);
|
||||
return (typ->typtype);
|
||||
@@ -310,15 +310,15 @@ binary_oper_get_candidates(char *opname,
|
||||
Oid rightTypeId,
|
||||
CandidateList * candidates)
|
||||
{
|
||||
CandidateList current_candidate;
|
||||
Relation pg_operator_desc;
|
||||
HeapScanDesc pg_operator_scan;
|
||||
HeapTuple tup;
|
||||
CandidateList current_candidate;
|
||||
Relation pg_operator_desc;
|
||||
HeapScanDesc pg_operator_scan;
|
||||
HeapTuple tup;
|
||||
OperatorTupleForm oper;
|
||||
Buffer buffer;
|
||||
int nkeys;
|
||||
int ncandidates = 0;
|
||||
ScanKeyData opKey[3];
|
||||
Buffer buffer;
|
||||
int nkeys;
|
||||
int ncandidates = 0;
|
||||
ScanKeyData opKey[3];
|
||||
|
||||
*candidates = NULL;
|
||||
|
||||
@@ -404,43 +404,43 @@ binary_oper_get_candidates(char *opname,
|
||||
* the all the candidates operate on the same data types after
|
||||
* promotion (int2, int4, float4 -> float8).
|
||||
*/
|
||||
static bool
|
||||
static bool
|
||||
equivalentOpersAfterPromotion(CandidateList candidates)
|
||||
{
|
||||
CandidateList result;
|
||||
CandidateList promotedCandidates = NULL;
|
||||
Oid leftarg,
|
||||
rightarg;
|
||||
CandidateList result;
|
||||
CandidateList promotedCandidates = NULL;
|
||||
Oid leftarg,
|
||||
rightarg;
|
||||
|
||||
for (result = candidates; result != NULL; result = result->next)
|
||||
{
|
||||
CandidateList c;
|
||||
CandidateList c;
|
||||
|
||||
c = (CandidateList) palloc(sizeof(*c));
|
||||
c->args = (Oid *) palloc(2 * sizeof(Oid));
|
||||
switch (result->args[0])
|
||||
{
|
||||
case FLOAT4OID:
|
||||
case INT4OID:
|
||||
case INT2OID:
|
||||
case CASHOID:
|
||||
c->args[0] = FLOAT8OID;
|
||||
break;
|
||||
default:
|
||||
c->args[0] = result->args[0];
|
||||
break;
|
||||
case FLOAT4OID:
|
||||
case INT4OID:
|
||||
case INT2OID:
|
||||
case CASHOID:
|
||||
c->args[0] = FLOAT8OID;
|
||||
break;
|
||||
default:
|
||||
c->args[0] = result->args[0];
|
||||
break;
|
||||
}
|
||||
switch (result->args[1])
|
||||
{
|
||||
case FLOAT4OID:
|
||||
case INT4OID:
|
||||
case INT2OID:
|
||||
case CASHOID:
|
||||
c->args[1] = FLOAT8OID;
|
||||
break;
|
||||
default:
|
||||
c->args[1] = result->args[1];
|
||||
break;
|
||||
case FLOAT4OID:
|
||||
case INT4OID:
|
||||
case INT2OID:
|
||||
case CASHOID:
|
||||
c->args[1] = FLOAT8OID;
|
||||
break;
|
||||
default:
|
||||
c->args[1] = result->args[1];
|
||||
break;
|
||||
}
|
||||
c->next = promotedCandidates;
|
||||
promotedCandidates = c;
|
||||
@@ -478,12 +478,12 @@ equivalentOpersAfterPromotion(CandidateList candidates)
|
||||
* given a choice of argument type pairs for a binary operator,
|
||||
* try to choose a default pair
|
||||
*/
|
||||
static CandidateList
|
||||
static CandidateList
|
||||
binary_oper_select_candidate(Oid arg1,
|
||||
Oid arg2,
|
||||
CandidateList candidates)
|
||||
{
|
||||
CandidateList result;
|
||||
CandidateList result;
|
||||
|
||||
/*
|
||||
* if both are "unknown", there is no way to select a candidate
|
||||
@@ -538,9 +538,9 @@ binary_oper_select_candidate(Oid arg1,
|
||||
Operator
|
||||
oper(char *op, Oid arg1, Oid arg2, bool noWarnings)
|
||||
{
|
||||
HeapTuple tup;
|
||||
CandidateList candidates;
|
||||
int ncandidates;
|
||||
HeapTuple tup;
|
||||
CandidateList candidates;
|
||||
int ncandidates;
|
||||
|
||||
if (!arg2)
|
||||
arg2 = arg1;
|
||||
@@ -596,8 +596,8 @@ oper(char *op, Oid arg1, Oid arg2, bool noWarnings)
|
||||
}
|
||||
else
|
||||
{
|
||||
Type tp1,
|
||||
tp2;
|
||||
Type tp1,
|
||||
tp2;
|
||||
|
||||
/* we chose none of them */
|
||||
tp1 = get_id_type(arg1);
|
||||
@@ -627,13 +627,13 @@ unary_oper_get_candidates(char *op,
|
||||
CandidateList * candidates,
|
||||
char rightleft)
|
||||
{
|
||||
CandidateList current_candidate;
|
||||
Relation pg_operator_desc;
|
||||
HeapScanDesc pg_operator_scan;
|
||||
HeapTuple tup;
|
||||
CandidateList current_candidate;
|
||||
Relation pg_operator_desc;
|
||||
HeapScanDesc pg_operator_scan;
|
||||
HeapTuple tup;
|
||||
OperatorTupleForm oper;
|
||||
Buffer buffer;
|
||||
int ncandidates = 0;
|
||||
Buffer buffer;
|
||||
int ncandidates = 0;
|
||||
|
||||
static ScanKeyData opKey[2] = {
|
||||
{0, Anum_pg_operator_oprname, NameEqualRegProcedure},
|
||||
@@ -697,9 +697,9 @@ unary_oper_get_candidates(char *op,
|
||||
Operator
|
||||
right_oper(char *op, Oid arg)
|
||||
{
|
||||
HeapTuple tup;
|
||||
CandidateList candidates;
|
||||
int ncandidates;
|
||||
HeapTuple tup;
|
||||
CandidateList candidates;
|
||||
int ncandidates;
|
||||
|
||||
/*
|
||||
* if (!OpCache) { init_op_cache(); }
|
||||
@@ -742,9 +742,9 @@ right_oper(char *op, Oid arg)
|
||||
Operator
|
||||
left_oper(char *op, Oid arg)
|
||||
{
|
||||
HeapTuple tup;
|
||||
CandidateList candidates;
|
||||
int ncandidates;
|
||||
HeapTuple tup;
|
||||
CandidateList candidates;
|
||||
int ncandidates;
|
||||
|
||||
/*
|
||||
* if (!OpCache) { init_op_cache(); }
|
||||
@@ -787,7 +787,7 @@ left_oper(char *op, Oid arg)
|
||||
int
|
||||
varattno(Relation rd, char *a)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < rd->rd_rel->relnatts; i++)
|
||||
{
|
||||
@@ -817,7 +817,7 @@ varattno(Relation rd, char *a)
|
||||
bool
|
||||
varisset(Relation rd, char *name)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
/* First check if this is a system attribute */
|
||||
for (i = 0; i < SPECIALS; i++)
|
||||
@@ -834,7 +834,7 @@ varisset(Relation rd, char *name)
|
||||
int
|
||||
nf_varattno(Relation rd, char *a)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < rd->rd_rel->relnatts; i++)
|
||||
{
|
||||
@@ -856,11 +856,11 @@ nf_varattno(Relation rd, char *a)
|
||||
/*-------------
|
||||
* given an attribute number and a relation, return its relation name
|
||||
*/
|
||||
char *
|
||||
char *
|
||||
getAttrName(Relation rd, int attrno)
|
||||
{
|
||||
char *name;
|
||||
int i;
|
||||
char *name;
|
||||
int i;
|
||||
|
||||
if (attrno < 0)
|
||||
{
|
||||
@@ -896,12 +896,12 @@ getAttrName(Relation rd, int attrno)
|
||||
/* Given a typename and value, returns the ascii form of the value */
|
||||
|
||||
#ifdef NOT_USED
|
||||
char *
|
||||
char *
|
||||
outstr(char *typename, /* Name of type of value */
|
||||
char *value) /* Could be of any type */
|
||||
{
|
||||
TypeTupleForm tp;
|
||||
Oid op;
|
||||
TypeTupleForm tp;
|
||||
Oid op;
|
||||
|
||||
tp = (TypeTupleForm) GETSTRUCT(type(typename));
|
||||
op = tp->typoutput;
|
||||
@@ -911,7 +911,7 @@ outstr(char *typename, /* Name of type of value */
|
||||
#endif
|
||||
|
||||
/* Given a Type and a string, return the internal form of that string */
|
||||
char *
|
||||
char *
|
||||
instr2(Type tp, char *string, int typlen)
|
||||
{
|
||||
return (instr1((TypeTupleForm) GETSTRUCT(tp), string, typlen));
|
||||
@@ -919,11 +919,11 @@ instr2(Type tp, char *string, int typlen)
|
||||
|
||||
/* Given a type structure and a string, returns the internal form of
|
||||
that string */
|
||||
static char *
|
||||
static char *
|
||||
instr1(TypeTupleForm tp, char *string, int typlen)
|
||||
{
|
||||
Oid op;
|
||||
Oid typelem;
|
||||
Oid op;
|
||||
Oid typelem;
|
||||
|
||||
op = tp->typinput;
|
||||
typelem = tp->typelem; /* XXX - used for array_in */
|
||||
@@ -937,8 +937,8 @@ instr1(TypeTupleForm tp, char *string, int typlen)
|
||||
Oid
|
||||
GetArrayElementType(Oid typearray)
|
||||
{
|
||||
HeapTuple type_tuple;
|
||||
TypeTupleForm type_struct_array;
|
||||
HeapTuple type_tuple;
|
||||
TypeTupleForm type_struct_array;
|
||||
|
||||
type_tuple = SearchSysCacheTuple(TYPOID,
|
||||
ObjectIdGetDatum(typearray),
|
||||
@@ -963,8 +963,8 @@ GetArrayElementType(Oid typearray)
|
||||
Oid
|
||||
funcid_get_rettype(Oid funcid)
|
||||
{
|
||||
HeapTuple func_tuple = NULL;
|
||||
Oid funcrettype = (Oid) 0;
|
||||
HeapTuple func_tuple = NULL;
|
||||
Oid funcrettype = (Oid) 0;
|
||||
|
||||
func_tuple = SearchSysCacheTuple(PROOID, ObjectIdGetDatum(funcid),
|
||||
0, 0, 0);
|
||||
@@ -982,21 +982,21 @@ funcid_get_rettype(Oid funcid)
|
||||
* get a list of all argument type vectors for which a function named
|
||||
* funcname taking nargs arguments exists
|
||||
*/
|
||||
static CandidateList
|
||||
static CandidateList
|
||||
func_get_candidates(char *funcname, int nargs)
|
||||
{
|
||||
Relation heapRelation;
|
||||
Relation idesc;
|
||||
ScanKeyData skey;
|
||||
HeapTuple tuple;
|
||||
IndexScanDesc sd;
|
||||
Relation heapRelation;
|
||||
Relation idesc;
|
||||
ScanKeyData skey;
|
||||
HeapTuple tuple;
|
||||
IndexScanDesc sd;
|
||||
RetrieveIndexResult indexRes;
|
||||
Buffer buffer;
|
||||
Form_pg_proc pgProcP;
|
||||
bool bufferUsed = FALSE;
|
||||
CandidateList candidates = NULL;
|
||||
CandidateList current_candidate;
|
||||
int i;
|
||||
Buffer buffer;
|
||||
Form_pg_proc pgProcP;
|
||||
bool bufferUsed = FALSE;
|
||||
CandidateList candidates = NULL;
|
||||
CandidateList current_candidate;
|
||||
int i;
|
||||
|
||||
heapRelation = heap_openr(ProcedureRelationName);
|
||||
ScanKeyEntryInitialize(&skey,
|
||||
@@ -1021,7 +1021,7 @@ func_get_candidates(char *funcname, int nargs)
|
||||
indexRes = index_getnext(sd, ForwardScanDirection);
|
||||
if (indexRes)
|
||||
{
|
||||
ItemPointer iptr;
|
||||
ItemPointer iptr;
|
||||
|
||||
iptr = &indexRes->heap_iptr;
|
||||
tuple = heap_fetch(heapRelation, NowTimeQual, iptr, &buffer);
|
||||
@@ -1060,11 +1060,11 @@ func_get_candidates(char *funcname, int nargs)
|
||||
/*
|
||||
* can input_typeids be coerced to func_typeids?
|
||||
*/
|
||||
static bool
|
||||
static bool
|
||||
can_coerce(int nargs, Oid * input_typeids, Oid * func_typeids)
|
||||
{
|
||||
int i;
|
||||
Type tp;
|
||||
int i;
|
||||
Type tp;
|
||||
|
||||
/*
|
||||
* right now, we only coerce "unknown", and we cannot coerce it to a
|
||||
@@ -1105,10 +1105,10 @@ match_argtypes(int nargs,
|
||||
CandidateList function_typeids,
|
||||
CandidateList * candidates) /* return value */
|
||||
{
|
||||
CandidateList current_candidate;
|
||||
CandidateList matching_candidate;
|
||||
Oid *current_typeids;
|
||||
int ncandidates = 0;
|
||||
CandidateList current_candidate;
|
||||
CandidateList matching_candidate;
|
||||
Oid *current_typeids;
|
||||
int ncandidates = 0;
|
||||
|
||||
*candidates = NULL;
|
||||
|
||||
@@ -1137,7 +1137,7 @@ match_argtypes(int nargs,
|
||||
* returns the selected argtype array if the conflict can be resolved,
|
||||
* otherwise returns NULL
|
||||
*/
|
||||
static Oid *
|
||||
static Oid *
|
||||
func_select_candidate(int nargs,
|
||||
Oid * input_typeids,
|
||||
CandidateList candidates)
|
||||
@@ -1155,12 +1155,12 @@ func_get_detail(char *funcname,
|
||||
bool * retset, /* return value */
|
||||
Oid ** true_typeids) /* return value */
|
||||
{
|
||||
Oid **input_typeid_vector;
|
||||
Oid *current_input_typeids;
|
||||
CandidateList function_typeids;
|
||||
CandidateList current_function_typeids;
|
||||
HeapTuple ftup;
|
||||
Form_pg_proc pform;
|
||||
Oid **input_typeid_vector;
|
||||
Oid *current_input_typeids;
|
||||
CandidateList function_typeids;
|
||||
CandidateList current_function_typeids;
|
||||
HeapTuple ftup;
|
||||
Form_pg_proc pform;
|
||||
|
||||
/*
|
||||
* attempt to find named function in the system catalogs with
|
||||
@@ -1191,7 +1191,7 @@ func_get_detail(char *funcname,
|
||||
|
||||
if (function_typeids != NULL)
|
||||
{
|
||||
int ncandidates = 0;
|
||||
int ncandidates = 0;
|
||||
|
||||
input_typeid_vector = argtype_inherit(nargs, oid_array);
|
||||
current_input_typeids = oid_array;
|
||||
@@ -1244,7 +1244,7 @@ func_get_detail(char *funcname,
|
||||
|
||||
if (!HeapTupleIsValid(ftup))
|
||||
{
|
||||
Type tp;
|
||||
Type tp;
|
||||
|
||||
if (nargs == 1)
|
||||
{
|
||||
@@ -1291,12 +1291,12 @@ func_get_detail(char *funcname,
|
||||
* not defined. There are lots of these (mostly builtins) in the
|
||||
* catalogs.
|
||||
*/
|
||||
static Oid **
|
||||
static Oid **
|
||||
argtype_inherit(int nargs, Oid * oid_array)
|
||||
{
|
||||
Oid relid;
|
||||
int i;
|
||||
InhPaths arginh[MAXFARGS];
|
||||
Oid relid;
|
||||
int i;
|
||||
InhPaths arginh[MAXFARGS];
|
||||
|
||||
for (i = 0; i < MAXFARGS; i++)
|
||||
{
|
||||
@@ -1327,31 +1327,31 @@ argtype_inherit(int nargs, Oid * oid_array)
|
||||
|
||||
typedef struct _SuperQE
|
||||
{
|
||||
Oid sqe_relid;
|
||||
} SuperQE;
|
||||
Oid sqe_relid;
|
||||
} SuperQE;
|
||||
|
||||
static int
|
||||
findsupers(Oid relid, Oid ** supervec)
|
||||
{
|
||||
Oid *relidvec;
|
||||
Relation inhrel;
|
||||
HeapScanDesc inhscan;
|
||||
ScanKeyData skey;
|
||||
HeapTuple inhtup;
|
||||
TupleDesc inhtupdesc;
|
||||
int nvisited;
|
||||
SuperQE *qentry,
|
||||
*vnode;
|
||||
Dllist *visited,
|
||||
*queue;
|
||||
Dlelem *qe,
|
||||
*elt;
|
||||
Oid *relidvec;
|
||||
Relation inhrel;
|
||||
HeapScanDesc inhscan;
|
||||
ScanKeyData skey;
|
||||
HeapTuple inhtup;
|
||||
TupleDesc inhtupdesc;
|
||||
int nvisited;
|
||||
SuperQE *qentry,
|
||||
*vnode;
|
||||
Dllist *visited,
|
||||
*queue;
|
||||
Dlelem *qe,
|
||||
*elt;
|
||||
|
||||
Relation rd;
|
||||
Buffer buf;
|
||||
Datum d;
|
||||
bool newrelid;
|
||||
char isNull;
|
||||
Relation rd;
|
||||
Buffer buf;
|
||||
Datum d;
|
||||
bool newrelid;
|
||||
char isNull;
|
||||
|
||||
nvisited = 0;
|
||||
queue = DLNewList();
|
||||
@@ -1451,16 +1451,16 @@ findsupers(Oid relid, Oid ** supervec)
|
||||
return (nvisited);
|
||||
}
|
||||
|
||||
static Oid **
|
||||
static Oid **
|
||||
genxprod(InhPaths * arginh, int nargs)
|
||||
{
|
||||
int nanswers;
|
||||
Oid **result,
|
||||
**iter;
|
||||
Oid *oneres;
|
||||
int i,
|
||||
j;
|
||||
int cur[MAXFARGS];
|
||||
int nanswers;
|
||||
Oid **result,
|
||||
**iter;
|
||||
Oid *oneres;
|
||||
int i,
|
||||
j;
|
||||
int cur[MAXFARGS];
|
||||
|
||||
nanswers = 1;
|
||||
for (i = 0; i < nargs; i++)
|
||||
@@ -1510,9 +1510,9 @@ genxprod(InhPaths * arginh, int nargs)
|
||||
Oid
|
||||
typeid_get_retinfunc(Oid type_id)
|
||||
{
|
||||
HeapTuple typeTuple;
|
||||
TypeTupleForm type;
|
||||
Oid infunc;
|
||||
HeapTuple typeTuple;
|
||||
TypeTupleForm type;
|
||||
Oid infunc;
|
||||
|
||||
typeTuple = SearchSysCacheTuple(TYPOID,
|
||||
ObjectIdGetDatum(type_id),
|
||||
@@ -1531,9 +1531,9 @@ typeid_get_retinfunc(Oid type_id)
|
||||
Oid
|
||||
typeid_get_retoutfunc(Oid type_id)
|
||||
{
|
||||
HeapTuple typeTuple;
|
||||
TypeTupleForm type;
|
||||
Oid outfunc;
|
||||
HeapTuple typeTuple;
|
||||
TypeTupleForm type;
|
||||
Oid outfunc;
|
||||
|
||||
typeTuple = SearchSysCacheTuple(TYPOID,
|
||||
ObjectIdGetDatum(type_id),
|
||||
@@ -1551,9 +1551,9 @@ typeid_get_retoutfunc(Oid type_id)
|
||||
Oid
|
||||
typeid_get_relid(Oid type_id)
|
||||
{
|
||||
HeapTuple typeTuple;
|
||||
TypeTupleForm type;
|
||||
Oid infunc;
|
||||
HeapTuple typeTuple;
|
||||
TypeTupleForm type;
|
||||
Oid infunc;
|
||||
|
||||
typeTuple = SearchSysCacheTuple(TYPOID,
|
||||
ObjectIdGetDatum(type_id),
|
||||
@@ -1569,7 +1569,7 @@ typeid_get_relid(Oid type_id)
|
||||
Oid
|
||||
get_typrelid(Type typ)
|
||||
{
|
||||
TypeTupleForm typtup;
|
||||
TypeTupleForm typtup;
|
||||
|
||||
typtup = (TypeTupleForm) GETSTRUCT(typ);
|
||||
|
||||
@@ -1579,8 +1579,8 @@ get_typrelid(Type typ)
|
||||
Oid
|
||||
get_typelem(Oid type_id)
|
||||
{
|
||||
HeapTuple typeTuple;
|
||||
TypeTupleForm type;
|
||||
HeapTuple typeTuple;
|
||||
TypeTupleForm type;
|
||||
|
||||
if (!(typeTuple = SearchSysCacheTuple(TYPOID,
|
||||
ObjectIdGetDatum(type_id),
|
||||
@@ -1597,9 +1597,9 @@ get_typelem(Oid type_id)
|
||||
char
|
||||
FindDelimiter(char *typename)
|
||||
{
|
||||
char delim;
|
||||
HeapTuple typeTuple;
|
||||
TypeTupleForm type;
|
||||
char delim;
|
||||
HeapTuple typeTuple;
|
||||
TypeTupleForm type;
|
||||
|
||||
|
||||
if (!(typeTuple = SearchSysCacheTuple(TYPNAME,
|
||||
@@ -1623,8 +1623,8 @@ FindDelimiter(char *typename)
|
||||
static void
|
||||
op_error(char *op, Oid arg1, Oid arg2)
|
||||
{
|
||||
Type tp1 = NULL,
|
||||
tp2 = NULL;
|
||||
Type tp1 = NULL,
|
||||
tp2 = NULL;
|
||||
|
||||
if (check_typeid(arg1))
|
||||
{
|
||||
@@ -1659,9 +1659,9 @@ op_error(char *op, Oid arg1, Oid arg2)
|
||||
void
|
||||
func_error(char *caller, char *funcname, int nargs, Oid * argtypes)
|
||||
{
|
||||
char p[(NAMEDATALEN + 2) * MAXFMGRARGS],
|
||||
*ptr;
|
||||
int i;
|
||||
char p[(NAMEDATALEN + 2) * MAXFMGRARGS],
|
||||
*ptr;
|
||||
int i;
|
||||
|
||||
ptr = p;
|
||||
*ptr = '\0';
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/dbcommands.c,v 1.7 1997/09/07 04:44:45 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/dbcommands.c,v 1.8 1997/09/08 02:25:16 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -39,14 +39,14 @@ static void
|
||||
check_permissions(char *command, char *dbname,
|
||||
Oid * dbIdP, Oid * userIdP);
|
||||
static HeapTuple get_pg_dbtup(char *command, char *dbname, Relation dbrel);
|
||||
static void stop_vacuum(char *dbname);
|
||||
static void stop_vacuum(char *dbname);
|
||||
|
||||
void
|
||||
createdb(char *dbname)
|
||||
{
|
||||
Oid db_id,
|
||||
user_id;
|
||||
char buf[512];
|
||||
Oid db_id,
|
||||
user_id;
|
||||
char buf[512];
|
||||
|
||||
/*
|
||||
* If this call returns, the database does not exist and we're allowed
|
||||
@@ -78,9 +78,9 @@ createdb(char *dbname)
|
||||
void
|
||||
destroydb(char *dbname)
|
||||
{
|
||||
Oid user_id,
|
||||
db_id;
|
||||
char buf[512];
|
||||
Oid user_id,
|
||||
db_id;
|
||||
char buf[512];
|
||||
|
||||
/*
|
||||
* If this call returns, the database exists and we're allowed to
|
||||
@@ -115,14 +115,14 @@ destroydb(char *dbname)
|
||||
DropBuffers(db_id);
|
||||
}
|
||||
|
||||
static HeapTuple
|
||||
static HeapTuple
|
||||
get_pg_dbtup(char *command, char *dbname, Relation dbrel)
|
||||
{
|
||||
HeapTuple dbtup;
|
||||
HeapTuple tup;
|
||||
Buffer buf;
|
||||
HeapScanDesc scan;
|
||||
ScanKeyData scanKey;
|
||||
HeapTuple dbtup;
|
||||
HeapTuple tup;
|
||||
Buffer buf;
|
||||
HeapScanDesc scan;
|
||||
ScanKeyData scanKey;
|
||||
|
||||
ScanKeyEntryInitialize(&scanKey, 0, Anum_pg_database_datname,
|
||||
NameEqualRegProcedure, NameGetDatum(dbname));
|
||||
@@ -164,14 +164,14 @@ check_permissions(char *command,
|
||||
Oid * dbIdP,
|
||||
Oid * userIdP)
|
||||
{
|
||||
Relation dbrel;
|
||||
HeapTuple dbtup,
|
||||
utup;
|
||||
Oid dbowner = (Oid) 0;
|
||||
char use_createdb;
|
||||
bool dbfound;
|
||||
bool use_super;
|
||||
char *userName;
|
||||
Relation dbrel;
|
||||
HeapTuple dbtup,
|
||||
utup;
|
||||
Oid dbowner = (Oid) 0;
|
||||
char use_createdb;
|
||||
bool dbfound;
|
||||
bool use_super;
|
||||
char *userName;
|
||||
|
||||
userName = GetPgUserName();
|
||||
utup = SearchSysCacheTuple(USENAME, PointerGetDatum(userName),
|
||||
@@ -268,9 +268,9 @@ check_permissions(char *command,
|
||||
static void
|
||||
stop_vacuum(char *dbname)
|
||||
{
|
||||
char filename[256];
|
||||
FILE *fp;
|
||||
int pid;
|
||||
char filename[256];
|
||||
FILE *fp;
|
||||
int pid;
|
||||
|
||||
sprintf(filename, "%s%cbase%c%s%c%s.vacuum", DataDir, SEP_CHAR, SEP_CHAR,
|
||||
dbname, SEP_CHAR, dbname);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.15 1997/09/07 04:44:47 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.16 1997/09/08 02:25:17 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -180,13 +180,13 @@ static ScanKeyword ScanKeywords[] = {
|
||||
{"zone", ZONE},
|
||||
};
|
||||
|
||||
ScanKeyword *
|
||||
ScanKeyword *
|
||||
ScanKeywordLookup(char *text)
|
||||
{
|
||||
ScanKeyword *low = &ScanKeywords[0];
|
||||
ScanKeyword *high = endof(ScanKeywords) - 1;
|
||||
ScanKeyword *middle;
|
||||
int difference;
|
||||
ScanKeyword *low = &ScanKeywords[0];
|
||||
ScanKeyword *high = endof(ScanKeywords) - 1;
|
||||
ScanKeyword *middle;
|
||||
int difference;
|
||||
|
||||
while (low <= high)
|
||||
{
|
||||
@@ -204,13 +204,13 @@ ScanKeywordLookup(char *text)
|
||||
}
|
||||
|
||||
#ifdef NOT_USED
|
||||
char *
|
||||
char *
|
||||
AtomValueGetString(int atomval)
|
||||
{
|
||||
ScanKeyword *low = &ScanKeywords[0];
|
||||
ScanKeyword *high = endof(ScanKeywords) - 1;
|
||||
int keyword_list_length = (high - low);
|
||||
int i;
|
||||
ScanKeyword *low = &ScanKeywords[0];
|
||||
ScanKeyword *high = endof(ScanKeywords) - 1;
|
||||
int keyword_list_length = (high - low);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < keyword_list_length; i++)
|
||||
if (ScanKeywords[i].value == atomval)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/parse_query.c,v 1.19 1997/09/07 04:44:48 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/parse_query.c,v 1.20 1997/09/08 02:25:18 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -42,18 +42,18 @@ static void
|
||||
checkTargetTypes(ParseState * pstate, char *target_colname,
|
||||
char *refname, char *colname);
|
||||
|
||||
Oid *param_type_info;
|
||||
int pfunc_num_args;
|
||||
Oid *param_type_info;
|
||||
int pfunc_num_args;
|
||||
|
||||
/* given refname, return a pointer to the range table entry */
|
||||
RangeTblEntry *
|
||||
RangeTblEntry *
|
||||
refnameRangeTableEntry(List * rtable, char *refname)
|
||||
{
|
||||
List *temp;
|
||||
List *temp;
|
||||
|
||||
foreach(temp, rtable)
|
||||
{
|
||||
RangeTblEntry *rte = lfirst(temp);
|
||||
RangeTblEntry *rte = lfirst(temp);
|
||||
|
||||
if (!strcmp(rte->refname, refname))
|
||||
return rte;
|
||||
@@ -65,13 +65,13 @@ refnameRangeTableEntry(List * rtable, char *refname)
|
||||
int
|
||||
refnameRangeTablePosn(List * rtable, char *refname)
|
||||
{
|
||||
int index;
|
||||
List *temp;
|
||||
int index;
|
||||
List *temp;
|
||||
|
||||
index = 1;
|
||||
foreach(temp, rtable)
|
||||
{
|
||||
RangeTblEntry *rte = lfirst(temp);
|
||||
RangeTblEntry *rte = lfirst(temp);
|
||||
|
||||
if (!strcmp(rte->refname, refname))
|
||||
return index;
|
||||
@@ -83,12 +83,12 @@ refnameRangeTablePosn(List * rtable, char *refname)
|
||||
/*
|
||||
* returns range entry if found, else NULL
|
||||
*/
|
||||
RangeTblEntry *
|
||||
RangeTblEntry *
|
||||
colnameRangeTableEntry(ParseState * pstate, char *colname)
|
||||
{
|
||||
List *et;
|
||||
List *rtable;
|
||||
RangeTblEntry *rte_result;
|
||||
List *et;
|
||||
List *rtable;
|
||||
RangeTblEntry *rte_result;
|
||||
|
||||
if (pstate->p_is_rule)
|
||||
rtable = lnext(lnext(pstate->p_rtable));
|
||||
@@ -98,7 +98,7 @@ colnameRangeTableEntry(ParseState * pstate, char *colname)
|
||||
rte_result = NULL;
|
||||
foreach(et, rtable)
|
||||
{
|
||||
RangeTblEntry *rte = lfirst(et);
|
||||
RangeTblEntry *rte = lfirst(et);
|
||||
|
||||
/* only entries on outer(non-function?) scope */
|
||||
if (!rte->inFromCl && rte != pstate->p_target_rangetblentry)
|
||||
@@ -123,15 +123,15 @@ colnameRangeTableEntry(ParseState * pstate, char *colname)
|
||||
* put new entry in pstate p_rtable structure, or return pointer
|
||||
* if pstate null
|
||||
*/
|
||||
RangeTblEntry *
|
||||
RangeTblEntry *
|
||||
addRangeTableEntry(ParseState * pstate,
|
||||
char *relname,
|
||||
char *refname,
|
||||
bool inh, bool inFromCl,
|
||||
TimeRange * timeRange)
|
||||
{
|
||||
Relation relation;
|
||||
RangeTblEntry *rte = makeNode(RangeTblEntry);
|
||||
Relation relation;
|
||||
RangeTblEntry *rte = makeNode(RangeTblEntry);
|
||||
|
||||
if (pstate != NULL &&
|
||||
refnameRangeTableEntry(pstate->p_rtable, refname) != NULL)
|
||||
@@ -179,18 +179,18 @@ addRangeTableEntry(ParseState * pstate,
|
||||
* makes a list of attributes
|
||||
* assumes reldesc caching works
|
||||
*/
|
||||
List *
|
||||
List *
|
||||
expandAll(ParseState * pstate, char *relname, char *refname, int *this_resno)
|
||||
{
|
||||
Relation rdesc;
|
||||
List *te_tail = NIL,
|
||||
*te_head = NIL;
|
||||
Var *varnode;
|
||||
int varattno,
|
||||
maxattrs;
|
||||
Oid type_id;
|
||||
int type_len;
|
||||
RangeTblEntry *rte;
|
||||
Relation rdesc;
|
||||
List *te_tail = NIL,
|
||||
*te_head = NIL;
|
||||
Var *varnode;
|
||||
int varattno,
|
||||
maxattrs;
|
||||
Oid type_id;
|
||||
int type_len;
|
||||
RangeTblEntry *rte;
|
||||
|
||||
rte = refnameRangeTableEntry(pstate->p_rtable, refname);
|
||||
if (rte == NULL)
|
||||
@@ -208,9 +208,9 @@ expandAll(ParseState * pstate, char *relname, char *refname, int *this_resno)
|
||||
|
||||
for (varattno = 0; varattno <= maxattrs - 1; varattno++)
|
||||
{
|
||||
char *attrname;
|
||||
char *resname = NULL;
|
||||
TargetEntry *te = makeNode(TargetEntry);
|
||||
char *attrname;
|
||||
char *resname = NULL;
|
||||
TargetEntry *te = makeNode(TargetEntry);
|
||||
|
||||
attrname = pstrdup((rdesc->rd_att->attrs[varattno]->attname).data);
|
||||
varnode = (Var *) make_var(pstate, refname, attrname, &type_id);
|
||||
@@ -248,58 +248,58 @@ makeTimeRange(char *datestring1,
|
||||
char *datestring2,
|
||||
int timecode) /* 0 = snapshot , 1 = timerange */
|
||||
{
|
||||
TimeQual qual = NULL;
|
||||
AbsoluteTime t1,
|
||||
t2;
|
||||
TimeQual qual = NULL;
|
||||
AbsoluteTime t1,
|
||||
t2;
|
||||
|
||||
switch (timecode)
|
||||
{
|
||||
case 0:
|
||||
if (datestring1 == NULL)
|
||||
{
|
||||
elog(WARN, "MakeTimeRange: bad snapshot arg");
|
||||
}
|
||||
t1 = nabstimein(datestring1);
|
||||
if (!AbsoluteTimeIsValid(t1))
|
||||
{
|
||||
elog(WARN, "bad snapshot time: \"%s\"",
|
||||
datestring1);
|
||||
}
|
||||
qual = TimeFormSnapshotTimeQual(t1);
|
||||
break;
|
||||
case 1:
|
||||
if (datestring1 == NULL)
|
||||
{
|
||||
t1 = NOSTART_ABSTIME;
|
||||
}
|
||||
else
|
||||
{
|
||||
case 0:
|
||||
if (datestring1 == NULL)
|
||||
{
|
||||
elog(WARN, "MakeTimeRange: bad snapshot arg");
|
||||
}
|
||||
t1 = nabstimein(datestring1);
|
||||
if (!AbsoluteTimeIsValid(t1))
|
||||
{
|
||||
elog(WARN,
|
||||
"bad range start time: \"%s\"",
|
||||
elog(WARN, "bad snapshot time: \"%s\"",
|
||||
datestring1);
|
||||
}
|
||||
}
|
||||
if (datestring2 == NULL)
|
||||
{
|
||||
t2 = NOEND_ABSTIME;
|
||||
}
|
||||
else
|
||||
{
|
||||
t2 = nabstimein(datestring2);
|
||||
if (!AbsoluteTimeIsValid(t2))
|
||||
qual = TimeFormSnapshotTimeQual(t1);
|
||||
break;
|
||||
case 1:
|
||||
if (datestring1 == NULL)
|
||||
{
|
||||
elog(WARN,
|
||||
"bad range end time: \"%s\"",
|
||||
datestring2);
|
||||
t1 = NOSTART_ABSTIME;
|
||||
}
|
||||
}
|
||||
qual = TimeFormRangedTimeQual(t1, t2);
|
||||
break;
|
||||
default:
|
||||
elog(WARN, "MakeTimeRange: internal parser error");
|
||||
else
|
||||
{
|
||||
t1 = nabstimein(datestring1);
|
||||
if (!AbsoluteTimeIsValid(t1))
|
||||
{
|
||||
elog(WARN,
|
||||
"bad range start time: \"%s\"",
|
||||
datestring1);
|
||||
}
|
||||
}
|
||||
if (datestring2 == NULL)
|
||||
{
|
||||
t2 = NOEND_ABSTIME;
|
||||
}
|
||||
else
|
||||
{
|
||||
t2 = nabstimein(datestring2);
|
||||
if (!AbsoluteTimeIsValid(t2))
|
||||
{
|
||||
elog(WARN,
|
||||
"bad range end time: \"%s\"",
|
||||
datestring2);
|
||||
}
|
||||
}
|
||||
qual = TimeFormRangedTimeQual(t1, t2);
|
||||
break;
|
||||
default:
|
||||
elog(WARN, "MakeTimeRange: internal parser error");
|
||||
}
|
||||
return qual;
|
||||
}
|
||||
@@ -319,16 +319,16 @@ disallow_setop(char *op, Type optype, Node * operand)
|
||||
}
|
||||
}
|
||||
|
||||
static Node *
|
||||
static Node *
|
||||
make_operand(char *opname,
|
||||
Node * tree,
|
||||
Oid orig_typeId,
|
||||
Oid true_typeId)
|
||||
{
|
||||
Node *result;
|
||||
Type true_type;
|
||||
Datum val;
|
||||
Oid infunc;
|
||||
Node *result;
|
||||
Type true_type;
|
||||
Datum val;
|
||||
Oid infunc;
|
||||
|
||||
if (tree != NULL)
|
||||
{
|
||||
@@ -337,7 +337,7 @@ make_operand(char *opname,
|
||||
disallow_setop(opname, true_type, result);
|
||||
if (true_typeId != orig_typeId)
|
||||
{ /* must coerce */
|
||||
Const *con = (Const *) result;
|
||||
Const *con = (Const *) result;
|
||||
|
||||
Assert(nodeTag(result) == T_Const);
|
||||
val = (Datum) textout((struct varlena *)
|
||||
@@ -358,7 +358,7 @@ make_operand(char *opname,
|
||||
}
|
||||
else
|
||||
{
|
||||
Const *con = makeNode(Const);
|
||||
Const *con = makeNode(Const);
|
||||
|
||||
con->consttype = true_typeId;
|
||||
con->constlen = 0;
|
||||
@@ -373,17 +373,17 @@ make_operand(char *opname,
|
||||
}
|
||||
|
||||
|
||||
Expr *
|
||||
Expr *
|
||||
make_op(char *opname, Node * ltree, Node * rtree)
|
||||
{
|
||||
Oid ltypeId,
|
||||
rtypeId;
|
||||
Operator temp;
|
||||
Oid ltypeId,
|
||||
rtypeId;
|
||||
Operator temp;
|
||||
OperatorTupleForm opform;
|
||||
Oper *newop;
|
||||
Node *left,
|
||||
*right;
|
||||
Expr *result;
|
||||
Oper *newop;
|
||||
Node *left,
|
||||
*right;
|
||||
Expr *result;
|
||||
|
||||
if (rtree == NULL)
|
||||
{
|
||||
@@ -409,10 +409,10 @@ make_op(char *opname, Node * ltree, Node * rtree)
|
||||
}
|
||||
else
|
||||
{
|
||||
char *outstr;
|
||||
Oid infunc,
|
||||
outfunc;
|
||||
Type newtype;
|
||||
char *outstr;
|
||||
Oid infunc,
|
||||
outfunc;
|
||||
Type newtype;
|
||||
|
||||
#define CONVERTABLE_TYPE(t) ( (t) == INT2OID || \
|
||||
(t) == INT4OID || \
|
||||
@@ -495,9 +495,9 @@ make_op(char *opname, Node * ltree, Node * rtree)
|
||||
Oid
|
||||
find_atttype(Oid relid, char *attrname)
|
||||
{
|
||||
int attid;
|
||||
Oid vartype;
|
||||
Relation rd;
|
||||
int attid;
|
||||
Oid vartype;
|
||||
Relation rd;
|
||||
|
||||
rd = heap_open(relid);
|
||||
if (!RelationIsValid(rd))
|
||||
@@ -524,15 +524,15 @@ find_atttype(Oid relid, char *attrname)
|
||||
}
|
||||
|
||||
|
||||
Var *
|
||||
Var *
|
||||
make_var(ParseState * pstate, char *refname, char *attrname, Oid * type_id)
|
||||
{
|
||||
Var *varnode;
|
||||
int vnum,
|
||||
attid;
|
||||
Oid vartypeid;
|
||||
Relation rd;
|
||||
RangeTblEntry *rte;
|
||||
Var *varnode;
|
||||
int vnum,
|
||||
attid;
|
||||
Oid vartypeid;
|
||||
Relation rd;
|
||||
RangeTblEntry *rte;
|
||||
|
||||
rte = refnameRangeTableEntry(pstate->p_rtable, refname);
|
||||
if (rte == NULL)
|
||||
@@ -567,18 +567,18 @@ make_var(ParseState * pstate, char *refname, char *attrname, Oid * type_id)
|
||||
*
|
||||
* indirection is a list of A_Indices
|
||||
*/
|
||||
ArrayRef *
|
||||
ArrayRef *
|
||||
make_array_ref(Node * expr,
|
||||
List * indirection)
|
||||
{
|
||||
Oid typearray;
|
||||
HeapTuple type_tuple;
|
||||
TypeTupleForm type_struct_array,
|
||||
type_struct_element;
|
||||
ArrayRef *aref;
|
||||
Oid reftype;
|
||||
List *upperIndexpr = NIL;
|
||||
List *lowerIndexpr = NIL;
|
||||
Oid typearray;
|
||||
HeapTuple type_tuple;
|
||||
TypeTupleForm type_struct_array,
|
||||
type_struct_element;
|
||||
ArrayRef *aref;
|
||||
Oid reftype;
|
||||
List *upperIndexpr = NIL;
|
||||
List *lowerIndexpr = NIL;
|
||||
|
||||
typearray = exprType(expr);
|
||||
|
||||
@@ -611,7 +611,7 @@ make_array_ref(Node * expr,
|
||||
|
||||
while (indirection != NIL)
|
||||
{
|
||||
A_Indices *ind = lfirst(indirection);
|
||||
A_Indices *ind = lfirst(indirection);
|
||||
|
||||
if (ind->lidx)
|
||||
{
|
||||
@@ -649,18 +649,18 @@ make_array_ref(Node * expr,
|
||||
return aref;
|
||||
}
|
||||
|
||||
ArrayRef *
|
||||
ArrayRef *
|
||||
make_array_set(Expr * target_expr,
|
||||
List * upperIndexpr,
|
||||
List * lowerIndexpr,
|
||||
Expr * expr)
|
||||
{
|
||||
Oid typearray;
|
||||
HeapTuple type_tuple;
|
||||
TypeTupleForm type_struct_array;
|
||||
TypeTupleForm type_struct_element;
|
||||
ArrayRef *aref;
|
||||
Oid reftype;
|
||||
Oid typearray;
|
||||
HeapTuple type_tuple;
|
||||
TypeTupleForm type_struct_array;
|
||||
TypeTupleForm type_struct_element;
|
||||
ArrayRef *aref;
|
||||
Oid reftype;
|
||||
|
||||
typearray = exprType((Node *) target_expr);
|
||||
|
||||
@@ -723,48 +723,49 @@ make_array_set(Expr * target_expr,
|
||||
*
|
||||
* eventually, produces a "const" lisp-struct as per nodedefs.cl
|
||||
*/
|
||||
Const *
|
||||
Const *
|
||||
make_const(Value * value)
|
||||
{
|
||||
Type tp;
|
||||
Datum val;
|
||||
Const *con;
|
||||
Type tp;
|
||||
Datum val;
|
||||
Const *con;
|
||||
|
||||
switch (nodeTag(value))
|
||||
{
|
||||
case T_Integer:
|
||||
tp = type("int4");
|
||||
val = Int32GetDatum(intVal(value));
|
||||
break;
|
||||
case T_Integer:
|
||||
tp = type("int4");
|
||||
val = Int32GetDatum(intVal(value));
|
||||
break;
|
||||
|
||||
case T_Float:
|
||||
{
|
||||
float64 dummy;
|
||||
case T_Float:
|
||||
{
|
||||
float64 dummy;
|
||||
|
||||
tp = type("float8");
|
||||
tp = type("float8");
|
||||
|
||||
dummy = (float64) palloc(sizeof(float64data));
|
||||
*dummy = floatVal(value);
|
||||
dummy = (float64) palloc(sizeof(float64data));
|
||||
*dummy = floatVal(value);
|
||||
|
||||
val = Float64GetDatum(dummy);
|
||||
}
|
||||
break;
|
||||
val = Float64GetDatum(dummy);
|
||||
}
|
||||
break;
|
||||
|
||||
case T_String:
|
||||
tp = type("unknown"); /* unknown for now, will be type coerced */
|
||||
val = PointerGetDatum(textin(strVal(value)));
|
||||
break;
|
||||
case T_String:
|
||||
tp = type("unknown"); /* unknown for now, will be type
|
||||
* coerced */
|
||||
val = PointerGetDatum(textin(strVal(value)));
|
||||
break;
|
||||
|
||||
case T_Null:
|
||||
default:
|
||||
{
|
||||
if (nodeTag(value) != T_Null)
|
||||
elog(NOTICE, "unknown type : %d\n", nodeTag(value));
|
||||
case T_Null:
|
||||
default:
|
||||
{
|
||||
if (nodeTag(value) != T_Null)
|
||||
elog(NOTICE, "unknown type : %d\n", nodeTag(value));
|
||||
|
||||
/* null const */
|
||||
con = makeConst(0, 0, (Datum) NULL, true, false, false, false);
|
||||
return con;
|
||||
}
|
||||
/* null const */
|
||||
con = makeConst(0, 0, (Datum) NULL, true, false, false, false);
|
||||
return con;
|
||||
}
|
||||
}
|
||||
|
||||
con = makeConst(typeid(tp),
|
||||
@@ -811,7 +812,7 @@ handleTargetColname(ParseState * pstate, char **resname,
|
||||
{
|
||||
if (pstate->p_insert_columns != NIL)
|
||||
{
|
||||
Ident *id = lfirst(pstate->p_insert_columns);
|
||||
Ident *id = lfirst(pstate->p_insert_columns);
|
||||
|
||||
*resname = id->name;
|
||||
pstate->p_insert_columns = lnext(pstate->p_insert_columns);
|
||||
@@ -831,12 +832,12 @@ static void
|
||||
checkTargetTypes(ParseState * pstate, char *target_colname,
|
||||
char *refname, char *colname)
|
||||
{
|
||||
Oid attrtype_id,
|
||||
attrtype_target;
|
||||
int resdomno_id,
|
||||
resdomno_target;
|
||||
Relation rd;
|
||||
RangeTblEntry *rte;
|
||||
Oid attrtype_id,
|
||||
attrtype_target;
|
||||
int resdomno_id,
|
||||
resdomno_target;
|
||||
Relation rd;
|
||||
RangeTblEntry *rte;
|
||||
|
||||
if (target_colname == NULL || colname == NULL)
|
||||
return;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.23 1997/09/07 04:44:50 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.24 1997/09/08 02:25:20 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -36,20 +36,20 @@
|
||||
#include "access/heapam.h"
|
||||
#include "optimizer/clauses.h"
|
||||
|
||||
void init_io(); /* from scan.l */
|
||||
void parser_init(Oid * typev, int nargs); /* from gram.y */
|
||||
int yyparse(); /* from gram.c */
|
||||
void init_io(); /* from scan.l */
|
||||
void parser_init(Oid * typev, int nargs); /* from gram.y */
|
||||
int yyparse(); /* from gram.c */
|
||||
|
||||
char *parseString; /* the char* which holds the string to be
|
||||
char *parseString; /* the char* which holds the string to be
|
||||
* parsed */
|
||||
char *parseCh; /* a pointer used during parsing to walk
|
||||
char *parseCh; /* a pointer used during parsing to walk
|
||||
* down ParseString */
|
||||
|
||||
List *parsetree = NIL;
|
||||
List *parsetree = NIL;
|
||||
|
||||
#ifdef SETS_FIXED
|
||||
static void fixupsets();
|
||||
static void define_sets();
|
||||
static void fixupsets();
|
||||
static void define_sets();
|
||||
|
||||
#endif
|
||||
/*
|
||||
@@ -57,14 +57,14 @@ static void define_sets();
|
||||
*
|
||||
* CALLER is responsible for free'ing the list returned
|
||||
*/
|
||||
QueryTreeList *
|
||||
QueryTreeList *
|
||||
parser(char *str, Oid * typev, int nargs)
|
||||
{
|
||||
QueryTreeList *queryList;
|
||||
int yyresult;
|
||||
QueryTreeList *queryList;
|
||||
int yyresult;
|
||||
|
||||
#if defined(FLEX_SCANNER)
|
||||
extern void DeleteBuffer(void);
|
||||
extern void DeleteBuffer(void);
|
||||
|
||||
#endif /* FLEX_SCANNER */
|
||||
|
||||
@@ -131,11 +131,11 @@ fixupsets(Query * parse)
|
||||
static void
|
||||
define_sets(Node * clause)
|
||||
{
|
||||
Oid setoid;
|
||||
Type t = type("oid");
|
||||
Oid typeoid = typeid(t);
|
||||
Size oidsize = tlen(t);
|
||||
bool oidbyval = tbyval(t);
|
||||
Oid setoid;
|
||||
Type t = type("oid");
|
||||
Oid typeoid = typeid(t);
|
||||
Size oidsize = tlen(t);
|
||||
bool oidbyval = tbyval(t);
|
||||
|
||||
if (clause == NULL)
|
||||
{
|
||||
@@ -170,7 +170,7 @@ define_sets(Node * clause)
|
||||
}
|
||||
else if (or_clause(clause))
|
||||
{
|
||||
List *temp;
|
||||
List *temp;
|
||||
|
||||
/* mapcan */
|
||||
foreach(temp, ((Expr *) clause)->args)
|
||||
@@ -180,7 +180,7 @@ define_sets(Node * clause)
|
||||
}
|
||||
else if (is_funcclause(clause))
|
||||
{
|
||||
List *temp;
|
||||
List *temp;
|
||||
|
||||
/* mapcan */
|
||||
foreach(temp, ((Expr *) clause)->args)
|
||||
@@ -209,33 +209,33 @@ define_sets(Node * clause)
|
||||
#define PSIZE(PTR) (*((int32 *)(PTR) - 1))
|
||||
*/
|
||||
|
||||
Node *
|
||||
Node *
|
||||
parser_typecast(Value * expr, TypeName * typename, int typlen)
|
||||
{
|
||||
/* check for passing non-ints */
|
||||
Const *adt;
|
||||
Datum lcp;
|
||||
Type tp;
|
||||
char type_string[16];
|
||||
int32 len;
|
||||
char *cp = NULL;
|
||||
char *const_string = NULL;
|
||||
bool string_palloced = false;
|
||||
Const *adt;
|
||||
Datum lcp;
|
||||
Type tp;
|
||||
char type_string[16];
|
||||
int32 len;
|
||||
char *cp = NULL;
|
||||
char *const_string = NULL;
|
||||
bool string_palloced = false;
|
||||
|
||||
switch (nodeTag(expr))
|
||||
{
|
||||
case T_String:
|
||||
const_string = DatumGetPointer(expr->val.str);
|
||||
break;
|
||||
case T_Integer:
|
||||
const_string = (char *) palloc(256);
|
||||
string_palloced = true;
|
||||
sprintf(const_string, "%d", expr->val.ival);
|
||||
break;
|
||||
default:
|
||||
elog(WARN,
|
||||
"parser_typecast: cannot cast this expression to type \"%s\"",
|
||||
typename->name);
|
||||
case T_String:
|
||||
const_string = DatumGetPointer(expr->val.str);
|
||||
break;
|
||||
case T_Integer:
|
||||
const_string = (char *) palloc(256);
|
||||
string_palloced = true;
|
||||
sprintf(const_string, "%d", expr->val.ival);
|
||||
break;
|
||||
default:
|
||||
elog(WARN,
|
||||
"parser_typecast: cannot cast this expression to type \"%s\"",
|
||||
typename->name);
|
||||
}
|
||||
|
||||
if (typename->arrayBounds != NIL)
|
||||
@@ -253,49 +253,49 @@ parser_typecast(Value * expr, TypeName * typename, int typlen)
|
||||
#if 0 /* fix me */
|
||||
switch (CInteger(lfirst(expr)))
|
||||
{
|
||||
case INT4OID: /* int4 */
|
||||
const_string = (char *) palloc(256);
|
||||
string_palloced = true;
|
||||
sprintf(const_string, "%d", ((Const *) lnext(expr))->constvalue);
|
||||
break;
|
||||
case INT4OID: /* int4 */
|
||||
const_string = (char *) palloc(256);
|
||||
string_palloced = true;
|
||||
sprintf(const_string, "%d", ((Const *) lnext(expr))->constvalue);
|
||||
break;
|
||||
|
||||
case NAMEOID: /* char16 */
|
||||
const_string = (char *) palloc(256);
|
||||
string_palloced = true;
|
||||
sprintf(const_string, "%s", ((Const *) lnext(expr))->constvalue);
|
||||
break;
|
||||
case NAMEOID: /* char16 */
|
||||
const_string = (char *) palloc(256);
|
||||
string_palloced = true;
|
||||
sprintf(const_string, "%s", ((Const *) lnext(expr))->constvalue);
|
||||
break;
|
||||
|
||||
case CHAROID: /* char */
|
||||
const_string = (char *) palloc(256);
|
||||
string_palloced = true;
|
||||
sprintf(const_string, "%c", ((Const) lnext(expr))->constvalue);
|
||||
break;
|
||||
case CHAROID: /* char */
|
||||
const_string = (char *) palloc(256);
|
||||
string_palloced = true;
|
||||
sprintf(const_string, "%c", ((Const) lnext(expr))->constvalue);
|
||||
break;
|
||||
|
||||
case FLOAT8OID: /* float8 */
|
||||
const_string = (char *) palloc(256);
|
||||
string_palloced = true;
|
||||
sprintf(const_string, "%f", ((Const) lnext(expr))->constvalue);
|
||||
break;
|
||||
case FLOAT8OID: /* float8 */
|
||||
const_string = (char *) palloc(256);
|
||||
string_palloced = true;
|
||||
sprintf(const_string, "%f", ((Const) lnext(expr))->constvalue);
|
||||
break;
|
||||
|
||||
case CASHOID: /* money */
|
||||
const_string = (char *) palloc(256);
|
||||
string_palloced = true;
|
||||
sprintf(const_string, "%d",
|
||||
(int) ((Const *) expr)->constvalue);
|
||||
break;
|
||||
case CASHOID: /* money */
|
||||
const_string = (char *) palloc(256);
|
||||
string_palloced = true;
|
||||
sprintf(const_string, "%d",
|
||||
(int) ((Const *) expr)->constvalue);
|
||||
break;
|
||||
|
||||
case TEXTOID: /* text */
|
||||
const_string = DatumGetPointer(((Const) lnext(expr))->constvalue);
|
||||
const_string = (char *) textout((struct varlena *) const_string);
|
||||
break;
|
||||
case TEXTOID: /* text */
|
||||
const_string = DatumGetPointer(((Const) lnext(expr))->constvalue);
|
||||
const_string = (char *) textout((struct varlena *) const_string);
|
||||
break;
|
||||
|
||||
case UNKNOWNOID: /* unknown */
|
||||
const_string = DatumGetPointer(((Const) lnext(expr))->constvalue);
|
||||
const_string = (char *) textout((struct varlena *) const_string);
|
||||
break;
|
||||
case UNKNOWNOID: /* unknown */
|
||||
const_string = DatumGetPointer(((Const) lnext(expr))->constvalue);
|
||||
const_string = (char *) textout((struct varlena *) const_string);
|
||||
break;
|
||||
|
||||
default:
|
||||
elog(WARN, "unknown type %d", CInteger(lfirst(expr)));
|
||||
default:
|
||||
elog(WARN, "unknown type %d", CInteger(lfirst(expr)));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -317,18 +317,18 @@ parser_typecast(Value * expr, TypeName * typename, int typlen)
|
||||
{
|
||||
switch (len)
|
||||
{
|
||||
case 1:
|
||||
lcp = Int8GetDatum(cp);
|
||||
break;
|
||||
case 2:
|
||||
lcp = Int16GetDatum(cp);
|
||||
break;
|
||||
case 4:
|
||||
lcp = Int32GetDatum(cp);
|
||||
break;
|
||||
default:
|
||||
lcp = PointerGetDatum(cp);
|
||||
break;
|
||||
case 1:
|
||||
lcp = Int8GetDatum(cp);
|
||||
break;
|
||||
case 2:
|
||||
lcp = Int16GetDatum(cp);
|
||||
break;
|
||||
case 4:
|
||||
lcp = Int32GetDatum(cp);
|
||||
break;
|
||||
default:
|
||||
lcp = PointerGetDatum(cp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,80 +346,80 @@ parser_typecast(Value * expr, TypeName * typename, int typlen)
|
||||
return (Node *) adt;
|
||||
}
|
||||
|
||||
Node *
|
||||
Node *
|
||||
parser_typecast2(Node * expr, Oid exprType, Type tp, int typlen)
|
||||
{
|
||||
/* check for passing non-ints */
|
||||
Const *adt;
|
||||
Datum lcp;
|
||||
int32 len = tlen(tp);
|
||||
char *cp = NULL;
|
||||
Const *adt;
|
||||
Datum lcp;
|
||||
int32 len = tlen(tp);
|
||||
char *cp = NULL;
|
||||
|
||||
char *const_string = NULL;
|
||||
bool string_palloced = false;
|
||||
char *const_string = NULL;
|
||||
bool string_palloced = false;
|
||||
|
||||
Assert(IsA(expr, Const));
|
||||
|
||||
switch (exprType)
|
||||
{
|
||||
case 0: /* NULL */
|
||||
break;
|
||||
case INT4OID: /* int4 */
|
||||
const_string = (char *) palloc(256);
|
||||
string_palloced = true;
|
||||
sprintf(const_string, "%d",
|
||||
(int) ((Const *) expr)->constvalue);
|
||||
break;
|
||||
case NAMEOID: /* char16 */
|
||||
const_string = (char *) palloc(256);
|
||||
string_palloced = true;
|
||||
sprintf(const_string, "%s",
|
||||
(char *) ((Const *) expr)->constvalue);
|
||||
break;
|
||||
case CHAROID: /* char */
|
||||
const_string = (char *) palloc(256);
|
||||
string_palloced = true;
|
||||
sprintf(const_string, "%c",
|
||||
(char) ((Const *) expr)->constvalue);
|
||||
break;
|
||||
case FLOAT4OID: /* float4 */
|
||||
{
|
||||
float32 floatVal =
|
||||
DatumGetFloat32(((Const *) expr)->constvalue);
|
||||
|
||||
case 0: /* NULL */
|
||||
break;
|
||||
case INT4OID: /* int4 */
|
||||
const_string = (char *) palloc(256);
|
||||
string_palloced = true;
|
||||
sprintf(const_string, "%f", *floatVal);
|
||||
sprintf(const_string, "%d",
|
||||
(int) ((Const *) expr)->constvalue);
|
||||
break;
|
||||
}
|
||||
case FLOAT8OID: /* float8 */
|
||||
{
|
||||
float64 floatVal =
|
||||
DatumGetFloat64(((Const *) expr)->constvalue);
|
||||
|
||||
case NAMEOID: /* char16 */
|
||||
const_string = (char *) palloc(256);
|
||||
string_palloced = true;
|
||||
sprintf(const_string, "%f", *floatVal);
|
||||
sprintf(const_string, "%s",
|
||||
(char *) ((Const *) expr)->constvalue);
|
||||
break;
|
||||
}
|
||||
case CASHOID: /* money */
|
||||
const_string = (char *) palloc(256);
|
||||
string_palloced = true;
|
||||
sprintf(const_string, "%d",
|
||||
(long) ((Const *) expr)->constvalue);
|
||||
break;
|
||||
case TEXTOID: /* text */
|
||||
const_string =
|
||||
DatumGetPointer(((Const *) expr)->constvalue);
|
||||
const_string = (char *) textout((struct varlena *) const_string);
|
||||
break;
|
||||
case UNKNOWNOID: /* unknown */
|
||||
const_string =
|
||||
DatumGetPointer(((Const *) expr)->constvalue);
|
||||
const_string = (char *) textout((struct varlena *) const_string);
|
||||
break;
|
||||
default:
|
||||
elog(WARN, "unknown type %u ", exprType);
|
||||
case CHAROID: /* char */
|
||||
const_string = (char *) palloc(256);
|
||||
string_palloced = true;
|
||||
sprintf(const_string, "%c",
|
||||
(char) ((Const *) expr)->constvalue);
|
||||
break;
|
||||
case FLOAT4OID: /* float4 */
|
||||
{
|
||||
float32 floatVal =
|
||||
DatumGetFloat32(((Const *) expr)->constvalue);
|
||||
|
||||
const_string = (char *) palloc(256);
|
||||
string_palloced = true;
|
||||
sprintf(const_string, "%f", *floatVal);
|
||||
break;
|
||||
}
|
||||
case FLOAT8OID: /* float8 */
|
||||
{
|
||||
float64 floatVal =
|
||||
DatumGetFloat64(((Const *) expr)->constvalue);
|
||||
|
||||
const_string = (char *) palloc(256);
|
||||
string_palloced = true;
|
||||
sprintf(const_string, "%f", *floatVal);
|
||||
break;
|
||||
}
|
||||
case CASHOID: /* money */
|
||||
const_string = (char *) palloc(256);
|
||||
string_palloced = true;
|
||||
sprintf(const_string, "%d",
|
||||
(long) ((Const *) expr)->constvalue);
|
||||
break;
|
||||
case TEXTOID: /* text */
|
||||
const_string =
|
||||
DatumGetPointer(((Const *) expr)->constvalue);
|
||||
const_string = (char *) textout((struct varlena *) const_string);
|
||||
break;
|
||||
case UNKNOWNOID: /* unknown */
|
||||
const_string =
|
||||
DatumGetPointer(((Const *) expr)->constvalue);
|
||||
const_string = (char *) textout((struct varlena *) const_string);
|
||||
break;
|
||||
default:
|
||||
elog(WARN, "unknown type %u ", exprType);
|
||||
}
|
||||
|
||||
if (!exprType)
|
||||
@@ -453,18 +453,18 @@ parser_typecast2(Node * expr, Oid exprType, Type tp, int typlen)
|
||||
{
|
||||
switch (len)
|
||||
{
|
||||
case 1:
|
||||
lcp = Int8GetDatum(cp);
|
||||
break;
|
||||
case 2:
|
||||
lcp = Int16GetDatum(cp);
|
||||
break;
|
||||
case 4:
|
||||
lcp = Int32GetDatum(cp);
|
||||
break;
|
||||
default:
|
||||
lcp = PointerGetDatum(cp);
|
||||
break;
|
||||
case 1:
|
||||
lcp = Int8GetDatum(cp);
|
||||
break;
|
||||
case 2:
|
||||
lcp = Int16GetDatum(cp);
|
||||
break;
|
||||
case 4:
|
||||
lcp = Int32GetDatum(cp);
|
||||
break;
|
||||
default:
|
||||
lcp = PointerGetDatum(cp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -485,15 +485,15 @@ parser_typecast2(Node * expr, Oid exprType, Type tp, int typlen)
|
||||
return ((Node *) adt);
|
||||
}
|
||||
|
||||
Aggreg *
|
||||
Aggreg *
|
||||
ParseAgg(char *aggname, Oid basetype, Node * target)
|
||||
{
|
||||
Oid fintype;
|
||||
Oid vartype;
|
||||
Oid xfn1;
|
||||
Oid fintype;
|
||||
Oid vartype;
|
||||
Oid xfn1;
|
||||
Form_pg_aggregate aggform;
|
||||
Aggreg *aggreg;
|
||||
HeapTuple theAggTuple;
|
||||
Aggreg *aggreg;
|
||||
HeapTuple theAggTuple;
|
||||
|
||||
theAggTuple = SearchSysCacheTuple(AGGNAME, PointerGetDatum(aggname),
|
||||
ObjectIdGetDatum(basetype),
|
||||
@@ -521,8 +521,8 @@ ParseAgg(char *aggname, Oid basetype, Node * target)
|
||||
|
||||
if (basetype != vartype)
|
||||
{
|
||||
Type tp1,
|
||||
tp2;
|
||||
Type tp1,
|
||||
tp2;
|
||||
|
||||
tp1 = get_id_type(basetype);
|
||||
tp2 = get_id_type(vartype);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/scansup.c,v 1.6 1997/09/07 04:44:51 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/scansup.c,v 1.7 1997/09/08 02:25:22 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,13 +38,13 @@
|
||||
* ----------------
|
||||
*/
|
||||
|
||||
char *
|
||||
char *
|
||||
scanstr(char *s)
|
||||
{
|
||||
static char newStr[MAX_PARSE_BUFFER];
|
||||
int len,
|
||||
i,
|
||||
j;
|
||||
static char newStr[MAX_PARSE_BUFFER];
|
||||
int len,
|
||||
i,
|
||||
j;
|
||||
|
||||
if (s == NULL || s[0] == '\0')
|
||||
return s;
|
||||
@@ -66,60 +66,60 @@ scanstr(char *s)
|
||||
i = i + 1;
|
||||
switch (s[i])
|
||||
{
|
||||
case '\\':
|
||||
newStr[j] = '\\';
|
||||
break;
|
||||
case 'b':
|
||||
newStr[j] = '\b';
|
||||
break;
|
||||
case 'f':
|
||||
newStr[j] = '\f';
|
||||
break;
|
||||
case 'n':
|
||||
newStr[j] = '\n';
|
||||
break;
|
||||
case 'r':
|
||||
newStr[j] = '\r';
|
||||
break;
|
||||
case 't':
|
||||
newStr[j] = '\t';
|
||||
break;
|
||||
case '"':
|
||||
newStr[j] = '"';
|
||||
break;
|
||||
case '\'':
|
||||
newStr[j] = '\'';
|
||||
break;
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
{
|
||||
char octal[4];
|
||||
int k;
|
||||
long octVal;
|
||||
|
||||
for (k = 0;
|
||||
s[i + k] >= '0' && s[i + k] <= '7' && k < 3;
|
||||
k++)
|
||||
octal[k] = s[i + k];
|
||||
i += k - 1;
|
||||
octal[3] = '\0';
|
||||
|
||||
octVal = strtol(octal, 0, 8);
|
||||
/* elog (NOTICE, "octal = %s octVal = %d, %od", octal, octVal, octVal);*/
|
||||
if (octVal <= 0377)
|
||||
case '\\':
|
||||
newStr[j] = '\\';
|
||||
break;
|
||||
case 'b':
|
||||
newStr[j] = '\b';
|
||||
break;
|
||||
case 'f':
|
||||
newStr[j] = '\f';
|
||||
break;
|
||||
case 'n':
|
||||
newStr[j] = '\n';
|
||||
break;
|
||||
case 'r':
|
||||
newStr[j] = '\r';
|
||||
break;
|
||||
case 't':
|
||||
newStr[j] = '\t';
|
||||
break;
|
||||
case '"':
|
||||
newStr[j] = '"';
|
||||
break;
|
||||
case '\'':
|
||||
newStr[j] = '\'';
|
||||
break;
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
{
|
||||
newStr[j] = ((char) octVal);
|
||||
break;
|
||||
char octal[4];
|
||||
int k;
|
||||
long octVal;
|
||||
|
||||
for (k = 0;
|
||||
s[i + k] >= '0' && s[i + k] <= '7' && k < 3;
|
||||
k++)
|
||||
octal[k] = s[i + k];
|
||||
i += k - 1;
|
||||
octal[3] = '\0';
|
||||
|
||||
octVal = strtol(octal, 0, 8);
|
||||
/* elog (NOTICE, "octal = %s octVal = %d, %od", octal, octVal, octVal);*/
|
||||
if (octVal <= 0377)
|
||||
{
|
||||
newStr[j] = ((char) octVal);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
default:
|
||||
newStr[j] = s[i];
|
||||
default:
|
||||
newStr[j] = s[i];
|
||||
} /* switch */
|
||||
} /* s[i] == '\\' */
|
||||
else
|
||||
|
||||
@@ -27,12 +27,12 @@
|
||||
* Can't get much more obvious than this. Might need to replace localtime()
|
||||
* on older systems...
|
||||
*/
|
||||
static char *
|
||||
static char *
|
||||
Sysfunc_system_date(void)
|
||||
{
|
||||
time_t cur_time_secs;
|
||||
struct tm *cur_time_expanded;
|
||||
static char buf[12]; /* Just for safety, y'understand... */
|
||||
time_t cur_time_secs;
|
||||
struct tm *cur_time_expanded;
|
||||
static char buf[12]; /* Just for safety, y'understand... */
|
||||
|
||||
time(&cur_time_secs);
|
||||
cur_time_expanded = localtime(&cur_time_secs);
|
||||
@@ -46,12 +46,12 @@ Sysfunc_system_date(void)
|
||||
return &buf[0];
|
||||
}
|
||||
|
||||
static char *
|
||||
static char *
|
||||
Sysfunc_system_time(void)
|
||||
{
|
||||
time_t cur_time_secs;
|
||||
struct tm *cur_time_expanded;
|
||||
static char buf[10]; /* Just for safety, y'understand... */
|
||||
time_t cur_time_secs;
|
||||
struct tm *cur_time_expanded;
|
||||
static char buf[10]; /* Just for safety, y'understand... */
|
||||
|
||||
time(&cur_time_secs);
|
||||
cur_time_expanded = localtime(&cur_time_secs);
|
||||
@@ -61,7 +61,7 @@ Sysfunc_system_time(void)
|
||||
return &buf[0];
|
||||
}
|
||||
|
||||
char *
|
||||
char *
|
||||
SystemFunctionHandler(char *funct)
|
||||
{
|
||||
if (!strcmp(funct, "SYS_DATE"))
|
||||
|
||||
Reference in New Issue
Block a user