head 1.65; access; symbols Version_2_1:1.48 Version_2:1.30 C_Demo_1:1.8; locks; strict; comment @ * @; 1.65 date 92.06.28.03.48.22; author mao; state Exp; branches; next 1.64; 1.64 date 92.06.26.02.56.02; author joey; state Exp; branches; next 1.63; 1.63 date 92.03.05.23.32.22; author clarsen; state Exp; branches; next 1.62; 1.62 date 92.02.25.15.32.05; author clarsen; state Exp; branches; next 1.61; 1.61 date 92.02.12.13.29.19; author olson; state Exp; branches; next 1.60; 1.60 date 91.11.18.22.42.29; author hong; state Exp; branches; next 1.59; 1.59 date 91.11.11.23.00.32; author hong; state Exp; branches; next 1.58; 1.58 date 91.10.25.02.21.02; author joey; state Exp; branches; next 1.57; 1.57 date 91.09.08.16.22.10; author glass; state Exp; branches; next 1.56; 1.56 date 91.08.18.02.08.10; author caetta; state Exp; branches; next 1.55; 1.55 date 91.05.05.19.46.07; author mao; state Exp; branches; next 1.54; 1.54 date 91.05.01.11.27.11; author cimarron; state Exp; branches; next 1.53; 1.53 date 91.04.24.12.19.54; author hong; state Exp; branches; next 1.52; 1.52 date 91.03.26.18.57.31; author kemnitz; state Exp; branches; next 1.51; 1.51 date 91.03.21.20.09.55; author kemnitz; state Exp; branches; next 1.50; 1.50 date 91.03.17.18.58.36; author mao; state Exp; branches; next 1.49; 1.49 date 91.03.16.17.28.50; author sp; state Exp; branches; next 1.48; 1.48 date 91.03.08.19.49.15; author kemnitz; state Exp; branches; next 1.47; 1.47 date 91.03.08.15.56.29; author kemnitz; state Exp; branches; next 1.46; 1.46 date 91.03.07.23.25.52; author kemnitz; state Exp; branches; next 1.45; 1.45 date 91.03.07.00.11.46; author kemnitz; state Exp; branches; next 1.44; 1.44 date 91.03.06.16.24.54; author kemnitz; state Exp; branches; next 1.43; 1.43 date 91.02.28.10.51.51; author cimarron; state Exp; branches; next 1.42; 1.42 date 91.02.12.11.46.27; author cimarron; state Exp; branches; next 1.41; 1.41 date 91.02.10.18.23.43; author cimarron; state Exp; branches; next 1.40; 1.40 date 91.02.05.19.09.35; author kemnitz; state Exp; branches; next 1.39; 1.39 date 91.02.04.15.19.26; author kemnitz; state Exp; branches; next 1.38; 1.38 date 91.01.14.10.52.41; author mao; state Exp; branches; next 1.37; 1.37 date 90.10.24.21.37.27; author cimarron; state Exp; branches; next 1.36; 1.36 date 90.10.24.20.47.31; author kemnitz; state Exp; branches; next 1.35; 1.35 date 90.10.22.16.24.53; author goh; state Exp; branches; next 1.34; 1.34 date 90.10.22.10.18.33; author goh; state Exp; branches; next 1.33; 1.33 date 90.08.18.14.16.22; author cimarron; state Exp; branches; next 1.32; 1.32 date 90.08.14.16.20.23; author cimarron; state Exp; branches; next 1.31; 1.31 date 90.08.07.14.16.15; author ong; state Exp; branches; next 1.30; 1.30 date 90.07.09.12.56.51; author ong; state Version_2; branches; next 1.29; 1.29 date 90.06.02.14.46.16; author cimarron; state Exp; branches; next 1.28; 1.28 date 90.05.01.15.05.35; author mao; state Exp; branches; next 1.27; 1.27 date 90.04.17.15.41.41; author goh; state Exp; branches; next 1.26; 1.26 date 90.04.13.11.25.09; author goh; state Exp; branches; next 1.25; 1.25 date 90.03.31.19.01.55; author cimarron; state Exp; branches; next 1.24; 1.24 date 90.01.30.23.42.42; author sp; state Exp; branches; next 1.23; 1.23 date 90.01.30.16.00.25; author goh; state Exp; branches; next 1.22; 1.22 date 89.12.22.14.23.29; author goh; state Exp; branches; next 1.21; 1.21 date 89.10.12.14.52.30; author hirohama; state Exp; branches; next 1.20; 1.20 date 89.10.11.15.20.14; author hirohama; state Exp; branches; next 1.19; 1.19 date 89.10.09.18.36.02; author hirohama; state Exp; branches; next 1.18; 1.18 date 89.10.06.15.58.12; author sp; state Exp; branches; next 1.17; 1.17 date 89.10.01.15.17.20; author ong; state Exp; branches; next 1.16; 1.16 date 89.09.25.10.32.08; author hirohama; state Exp; branches; next 1.15; 1.15 date 89.09.20.22.42.25; author hirohama; state Exp; branches; next 1.14; 1.14 date 89.09.20.22.25.47; author hirohama; state Exp; branches; next 1.13; 1.13 date 89.09.15.18.15.25; author hirohama; state Exp; branches; next 1.12; 1.12 date 89.09.15.18.11.42; author hirohama; state Exp; branches; next 1.11; 1.11 date 89.09.15.17.35.19; author hirohama; state Exp; branches; next 1.10; 1.10 date 89.09.10.17.13.47; author hirohama; state Exp; branches; next 1.9; 1.9 date 89.09.05.22.47.27; author hirohama; state Exp; branches; next 1.8; 1.8 date 89.09.05.16.53.52; author mao; state C_Demo_1; branches; next 1.7; 1.7 date 89.09.01.12.12.19; author hirohama; state Exp; branches; next 1.6; 1.6 date 89.08.30.12.53.05; author hirohama; state Exp; branches; next 1.5; 1.5 date 89.08.29.15.17.16; author hirohama; state Exp; branches; next 1.4; 1.4 date 89.08.22.20.38.31; author hirohama; state Exp; branches; next 1.3; 1.3 date 89.08.11.15.15.41; author hirohama; state Exp; branches; next 1.2; 1.2 date 89.08.10.11.51.48; author hirohama; state Exp; branches; next 1.1; 1.1 date 89.07.24.16.33.14; author goh; state Exp; branches; next ; desc @misc stuff, in funky state right now @ 1.65 log @rearrange parse, plan to support postquel function invocations @ text @/* ---------------------------------------------------------------- * FILE * utility.c * * DESCRIPTION * Contains functions which control the execution of the * POSTGRES utility commands. At one time acted as an * interface between the Lisp and C systems. * * INTERFACE ROUTINES * * NOTES * * IDENTIFICATION * $Header: /private/mao/postgres/src/tcop/RCS/utility.c,v 1.64 1992/06/26 02:56:02 joey Exp $ * ---------------------------------------------------------------- */ #include "tmp/postgres.h" RcsId("$Header: /private/mao/postgres/src/tcop/RCS/utility.c,v 1.64 1992/06/26 02:56:02 joey Exp $"); /* ---------------- * FILE INCLUDE ORDER GUIDELINES * * 1) tcopdebug.h * 2) various support files ("everything else") * 3) node files * 4) catalog/ files * 5) execdefs.h and execmisc.h, if necessary. * 6) extern files come last. * ---------------- */ #include "tcop/tcopdebug.h" #include "parser/parse.h" #include "parser/parsetree.h" #include "utils/log.h" #include "nodes/pg_lisp.h" #include "tcop/dest.h" #include "tmp/globals.h" /* ---------------- * CHECK_IF_ABORTED() is used to avoid doing unnecessary * processing within an aborted transaction block. * ---------------- */ #define CHECK_IF_ABORTED() \ if (IsAbortedTransactionBlockState()) { \ elog(NOTICE, "(transaction aborted): %s", \ "queries ignored until END"); \ commandTag = "*ABORT STATE*"; \ break; \ } \ /* ---------------- * general utility function invoker * ---------------- */ void ProcessUtility(command, args, commandString, dest) int command; /* "tag" */ LispValue args; char *commandString; CommandDest dest; { String commandTag = NULL; switch (command) { /* ******************************** * transactions * ******************************** */ case BEGIN_TRANS: commandTag = "BEGIN"; CHECK_IF_ABORTED(); BeginTransactionBlock(); break; case END_TRANS: commandTag = "END"; EndTransactionBlock(); break; case ABORT_TRANS: commandTag = "ABORT"; UserAbortTransactionBlock(); break; /* ******************************** * portal manipulation * ******************************** */ case CLOSE: commandTag = "CLOSE"; CHECK_IF_ABORTED(); PerformPortalClose((null(CAR(args))) ? NULL : CString(CAR(args)), dest); break; case FETCH: commandTag = "FETCH"; CHECK_IF_ABORTED(); { String portalName = NULL; bool forward; int count; if (!null(CAR(args))) { portalName = CString(CAR(args)); } forward = (bool)(CAtom(CADR(args)) == FORWARD); count = 0; if (!lispAtomp(CADDR(args))) { count = CInteger(CADDR(args)); if (count < 0) { elog(WARN, "Fetch: specify nonnegative count"); } if (count == 0) { break; } } PerformPortalFetch(portalName, forward, count, commandTag, dest); } break; case MOVE: commandTag = "MOVE"; CHECK_IF_ABORTED(); elog(NOTICE, "MOVE: currently unimplemented"); break; /* ******************************** * relation and attribute manipulation * ******************************** */ case CREATE: commandTag = "CREATE"; CHECK_IF_ABORTED(); DefineRelation(CString(CAR(args)), /* relation name */ CADR(args), /* parameters */ CDR(CDR(args))); /* schema */ break; case DESTROY: commandTag = "DESTROY"; CHECK_IF_ABORTED(); { LispValue relationName; foreach (relationName, args) { RemoveRelation(CString(CAR(relationName))); } } break; case PURGE: commandTag = "PURGE"; CHECK_IF_ABORTED(); { List tags; String beforeString = NULL; /* absolute time string */ String afterString = NULL; /* relative time string */ tags = CAR(CADR(args)); switch (length(tags)) { case 1: break; case 2: if (CInteger(CAR(tags)) == BEFORE) { beforeString = CString(CADR(tags)); } else { afterString = CString(CADR(tags)); } break; case 3: beforeString = CString(CADR(tags)); afterString = CString(CADR(tags)); break; } RelationPurge(CString(CAR(args)), beforeString, afterString); } break; case COPY: commandTag = "COPY"; CHECK_IF_ABORTED(); { String relationName; String fileName; String mapName = NULL; bool isBinary; bool noNulls; bool isFrom; bool pipe; relationName = CString(CAAR(args)); isBinary = (bool)!null(CADR(CAR(args))); noNulls = (bool)!null(CADDR(CAR(args))); /* * discard '("relname" [BINARY] [NONULLS]) */ args = CDR(args); isFrom = (bool)(CAtom(CAAR(args)) == FROM); fileName = CString(CADR(CAR(args))); /* Free up file descriptors - going to do a read... */ closeOneVfd(); if (isFrom && !strcmp(fileName, "stdin")) { pipe = true; } else if (!isFrom && !strcmp(fileName, "stdout")) { pipe = true; } /* * Insist on a full pathname */ else if (*fileName == '/') { pipe = false; } else { elog(WARN, "COPY: full pathname required for filename"); } /* * discard '(FROM/TO "filename") */ args = CDR(args); if (pipe && IsUnderPostmaster) dest = CopyEnd; DoCopy(relationName, isBinary, isFrom, pipe, fileName); } break; case ADD_ATTR: commandTag = "ADD"; CHECK_IF_ABORTED(); PerformAddAttribute(CString(CAR(args)), CDR(args)); break; /* * schema */ case RENAME: commandTag = "RENAME"; CHECK_IF_ABORTED(); { int len; len = length(args); /* * skip unused "RELATION" or "ATTRIBUTE" tag */ args = CDR(args); /* ---------------- * XXX using len == 3 to tell the difference * between "rename rel to newrel" and * "rename att in rel to newatt" will not * work soon because "rename type/operator/rule" * stuff is being added. - cim 10/24/90 * ---------------- */ if (len == 3) { /* ---------------- * rename relation * * Note: we also rename the "type" tuple * corresponding to the relation. * ---------------- */ renamerel(CString(CAR(args)), /* old name */ CString(CADR(args))); /* new name */ TypeRename(CString(CAR(args)), /* old name */ CString(CADR(args))); /* new name */ } else { /* ---------------- * rename attribute * ---------------- */ renameatt(CString(CAR(args)), /* relname */ CString(CADR(args)), /* old att name */ CString(CADDR(args))); /* new att name */ } } break; /* ******************************** * object creation / destruction * ******************************** */ case DEFINE: commandTag = "DEFINE"; CHECK_IF_ABORTED(); switch(LISPVALUE_INTEGER(CAR(args))) { case INDEX: /* XXX no support for ARCHIVE indices, yet */ args = CDR(args); /* skip "INDEX" token */ DefineIndex(CString(CAR(args)), /* relation name */ CString(CADR(args)), /* index name */ CString(CADDR(args)), /* am name */ CADDR(CDR(args)), /* parameters */ CADDR(CDR(CDR(args))), /* with */ CADDR(CDR(CDR(CDR(args))))); /* where */ break; case OPERATOR: DefineOperator( CString(CADR(args)), /* operator name */ CDR(CDR(args))); /* rest */ break; case AGGREGATE: DefineAggregate( CString(CADR(args)),/*aggregate name */ CDR(CDR(args))); /* rest */ break; case FUNCTION: DefineFunction(CDR(args), dest); /* everything */ break; case RULE: elog(WARN, "Sorry, the old rule system is not supported any more (yet!)"); break; case REWRITE: DefineQueryRewrite ( CDR( CDR (args ))) ; break; case P_TUPLE: prs2DefineTupleRule(args, commandString); break; case P_TYPE: DefineType (CString(CADR(args)), /* type name */ CDR(CDR(args))); /* rest */ break; case VIEW: DefineView (CString(CADR(args)), /* view name */ CDR(CDR(args)) ); /* retrieve parsetree */ break; default: elog(WARN, "unknown object type in define statement"); } /* switch for define statements */ break; case REMOVE: commandTag = "REMOVE"; CHECK_IF_ABORTED(); switch(CInteger(CAR(args))) { case FUNCTION: RemoveFunction(CString(CADR(args))); break; case AGGREGATE: RemoveAggregate(CString(CADR(args))); break; case INDEX: RemoveIndex(CString(CADR(args))); break; case OPERATOR: { String type2 = NULL; args = CADR(args); if (length(args) == 3) { type2 = CString(CADR(CDR(args))); } RemoveOperator(CString(CAR(args)), CString(CADR(args)), type2); } break; case P_TUPLE: prs2RemoveTupleRule(CString(CADR(args))); break; case REWRITE: RemoveRewriteRule(CString(CADR(args))); break; case P_TYPE: RemoveType(CString(CADR(args))); break; case VIEW: RemoveView(CString(CADR(args))); break; } break; case FORWARD: commandTag = "VERSION"; CHECK_IF_ABORTED(); CreateVersion(CString(CAR(args)), CADR(args)); break; case BACKWARD: commandTag = "VERSION"; CHECK_IF_ABORTED(); #ifdef NOTYET CreateBackwardDelta( CString(CAR(args)), CString(CADR(args))); break; #endif case CREATEDB: commandTag = "CREATEDB"; CHECK_IF_ABORTED(); { char *dbname; dbname = CString(CAR(args)); createdb(dbname); } break; case DESTROYDB: commandTag = "DESTROYDB"; CHECK_IF_ABORTED(); { char *dbname; dbname = CString(CAR(args)); destroydb(dbname); } break; /* Query-level asynchronous notification */ case NOTIFY: commandTag = "NOTIFY"; CHECK_IF_ABORTED(); { char *relname; relname = CString(rt_relname(nth(CInteger(CAR(args))-1, CAR(CDR(args))))); Async_Notify(relname); } break; case LISTEN: commandTag = "LISTEN"; CHECK_IF_ABORTED(); { extern int MasterPid; char *relname; relname = CString(CAR(args)); Async_Listen(relname,MasterPid); } break; /* ******************************** * dynamic loader * ******************************** */ case LOAD: commandTag = "LOAD"; CHECK_IF_ABORTED(); { FILE *fp, *fopen(); char *filename; filename = CString(CAR(args)); if (*filename != '/') { elog(WARN, "Use full pathname for LOAD command."); } closeAllVfds(); if ((fp = fopen(filename, "r")) == NULL) { elog(WARN, "LOAD: could not open file %s", filename); } fclose(fp); load_file(filename); } break; case VACUUM: commandTag = "VACUUM"; CHECK_IF_ABORTED(); vacuum(); break; /* ******************************** * default * ******************************** */ default: elog(WARN, "ProcessUtility: command #%d unsupported", command); break; } /* ---------------- * tell fe/be or whatever that we're done. * ---------------- */ EndCommand(commandTag, dest); } @ 1.64 log @remove #ifdef PRE_JMH stuff @ text @d15 1 a15 1 * $Header: /private/joey/pg/src/tcop/RCS/utility.c,v 1.63 1992/03/05 23:32:22 clarsen Exp joey $ d21 1 a21 1 RcsId("$Header: /private/joey/pg/src/tcop/RCS/utility.c,v 1.63 1992/03/05 23:32:22 clarsen Exp joey $"); d342 1 a342 1 DefineFunction(CDR(args)); /* everything */ @ 1.63 log @notify @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.62 92/02/25 15:32:05 clarsen Exp Locker: clarsen $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.62 92/02/25 15:32:05 clarsen Exp Locker: clarsen $"); a340 7 #ifdef PRE_JMH case C_FUNCTION: DefineFunction( CString(CADR(args)), /* function name */ CDR(CDR(args))); /* rest */ break; #endif a343 11 #ifdef PRE_JMH case P_FUNCTION: DefinePFunction(CString(CADR(args)), /* function name */ CString(CADDR(args)), /* relation name */ CString(nth(3,args))); /* query string */ break; case POSTQUEL: DefineRealPFunction(CDR(args)); break; #endif @ 1.62 log @async portals. @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.61 92/02/12 13:29:19 olson Exp Locker: clarsen $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.61 92/02/12 13:29:19 olson Exp Locker: clarsen $"); d37 1 d468 2 a469 1 relname = CString(CAR(args)); @ 1.61 log @support partial index definition @ text @d15 1 a15 1 * $Header: src/tcop/RCS/utility.c,v 1.60 91/11/18 22:42:29 hong Exp Locker: olson $ d21 1 a21 1 RcsId("$Header: src/tcop/RCS/utility.c,v 1.60 91/11/18 22:42:29 hong Exp Locker: olson $"); d458 22 @ 1.60 log @sequent cc does not allow dash in #ifdef @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.59 91/11/11 23:00:32 hong Exp $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.59 91/11/11 23:00:32 hong Exp $"); d326 2 a327 1 CADDR(CDR(CDR(args)))); /* with */ @ 1.59 log @for prototyping @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.58 91/10/25 02:21:02 joey Exp Locker: hong $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.58 91/10/25 02:21:02 joey Exp Locker: hong $"); d339 1 a339 1 #ifdef PRE-JMH d350 1 a350 1 #ifdef PRE-JMH @ 1.58 log @modifications to support new function definition syntax @ text @d15 1 a15 1 * $Header: /users/joey/pg/src/tcop/RCS/utility.c,v 1.57 1991/09/08 16:22:10 glass Exp joey $ d21 1 a21 1 RcsId("$Header: /users/joey/pg/src/tcop/RCS/utility.c,v 1.57 1991/09/08 16:22:10 glass Exp joey $"); a35 1 #include "tcop/dest.h" d40 1 @ 1.57 log @initial postquel function checkin @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.56 91/08/18 02:08:10 caetta Exp Locker: glass $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.56 91/08/18 02:08:10 caetta Exp Locker: glass $"); d338 2 d342 6 a347 2 CString(CADR(args)), /* function name */ CDR(CDR(args))); /* rest */ d349 2 d359 2 @ 1.56 log @aggregate definitions... @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.55 91/05/05 19:46:07 mao Exp $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.55 91/05/05 19:46:07 mao Exp $"); d348 4 a351 1 case RULE: @ 1.55 log @'vacuum' is now a postquel command @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.54 91/05/01 11:27:11 cimarron Exp Locker: cimarron $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.54 91/05/01 11:27:11 cimarron Exp Locker: cimarron $"); d333 5 d378 3 @ 1.54 log @transaction system now distinguished between user aborts and internal aborts @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.53 91/04/24 12:19:54 hong Exp Locker: kemnitz $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.53 91/04/24 12:19:54 hong Exp Locker: kemnitz $"); d136 1 a136 1 elog(NOTICE, "MOVE: curently unimplemented"); d465 6 d476 1 a476 1 elog(WARN, "ProcessUtility: command #%d unsupport", command); @ 1.53 log @fixed a problem with the copy command: no need to free all file descriptors one is enough. @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.52 91/03/26 18:57:31 kemnitz Exp Locker: hong $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.52 91/03/26 18:57:31 kemnitz Exp Locker: hong $"); d89 1 a89 3 CHECK_IF_ABORTED(); AbortTransactionBlock(); @ 1.52 log @made a cosmetic change to COPY so it will barf if there's not a full pathname to the copy file. @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.51 91/03/21 20:09:55 kemnitz Exp Locker: kemnitz $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.51 91/03/21 20:09:55 kemnitz Exp Locker: kemnitz $"); d222 1 a222 1 closeAllVfds(); @ 1.51 log @close file descriptors before executing open. @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.50 91/03/17 18:58:36 mao Exp $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.50 91/03/17 18:58:36 mao Exp $"); d219 1 d226 1 a226 1 pipe = true; d230 1 a230 1 pipe = true; d232 6 a237 1 else d239 1 a239 1 pipe = false; d241 4 @ 1.50 log @don't pass strings when you mean to pass nodes. @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.49 91/03/16 17:28:50 sp Exp Locker: mao $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.49 91/03/16 17:28:50 sp Exp Locker: mao $"); d218 4 @ 1.49 log @Remove view added.... @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.48 91/03/08 19:49:15 kemnitz Exp $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.48 91/03/08 19:49:15 kemnitz Exp $"); d396 1 a396 2 CreateVersion(CString(CAR(args)), /* version name */ CString(CADR(args))); /* base name */ @ 1.48 log @New copy command protocols. @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.47 91/03/08 15:56:29 kemnitz Exp $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.47 91/03/08 15:56:29 kemnitz Exp $"); d385 3 @ 1.47 log @Frees up filedescs before running LOAD command. @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.46 91/03/07 23:25:52 kemnitz Exp $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.46 91/03/07 23:25:52 kemnitz Exp $"); d42 2 d236 2 @ 1.46 log @Changed "input/output" to "stdin/stdout" @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.45 91/03/07 00:11:46 kemnitz Exp Locker: kemnitz $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.45 91/03/07 00:11:46 kemnitz Exp Locker: kemnitz $"); d435 4 a438 1 } else if ((fp = fopen(filename, "r")) == NULL) { d446 1 a446 1 @ 1.45 log @Added some cheap hacks to support copy to output and copy from input. @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.44 91/03/06 16:24:54 kemnitz Exp $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.44 91/03/06 16:24:54 kemnitz Exp $"); d217 1 a217 1 if (isFrom && !strcmp(fileName, "input")) d221 1 a221 1 else if (!isFrom && !strcmp(fileName, "output")) @ 1.44 log @New copy command support. @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.43 91/02/28 10:51:51 cimarron Exp Locker: kemnitz $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.43 91/02/28 10:51:51 cimarron Exp Locker: kemnitz $"); d204 2 a205 1 d216 14 d235 1 a235 1 DoCopy(relationName, isBinary, isFrom, 0, fileName); @ 1.43 log @fixed arguments to PreformPortalFetch @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.42 91/02/12 11:46:27 cimarron Exp Locker: cimarron $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.42 91/02/12 11:46:27 cimarron Exp Locker: cimarron $"); d219 2 a220 11 if (!null(CDR(CAR(args)))) { mapName = CString(CADR(CAR(args))); } /* * discard '(USING ["mapName"]) */ args = CDR(args); PerformRelationFilter(relationName, isBinary, noNulls, isFrom, fileName, mapName, args); @ 1.42 log @added communication destination to portal functions @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.41 91/02/10 18:23:43 cimarron Exp Locker: cimarron $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.41 91/02/10 18:23:43 cimarron Exp Locker: cimarron $"); d128 1 a128 1 PerformPortalFetch(portalName, forward, count, dest); @ 1.41 log @reorganization of libpq routines to provide PQexec and PQfn functionality from both the front end applications and the postgres backend. @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.40 91/02/05 19:09:35 kemnitz Exp Locker: cimarron $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.40 91/02/05 19:09:35 kemnitz Exp Locker: cimarron $"); d69 3 a71 2 /* * transactions d73 1 a73 1 case BEGIN_TRANS: d80 1 a80 1 case END_TRANS: d85 1 a85 1 case ABORT_TRANS: d92 3 a94 2 /* * portal manipulation d96 1 a96 1 case CLOSE: d100 2 a101 2 PerformPortalClose((null(CAR(args))) ? NULL : CString(CAR(args))); d104 1 a104 1 case FETCH: d128 1 a128 1 PerformPortalFetch(portalName, forward, count); d132 1 a132 1 case MOVE: d136 1 a136 1 elog(NOTICE, "MOVE: unimplemented in Version 1"); d139 3 a141 2 /* * relation and attribute manipulation d143 1 a143 2 case CREATE: d152 1 a152 1 case DESTROY: d164 1 a164 1 case PURGE: d175 1 a175 1 case 1: d177 1 a177 1 case 2: d184 1 a184 1 case 3: d193 1 a193 1 case COPY: d233 1 a233 1 case ADD_ATTR: d236 1 a236 1 d243 1 a243 1 case RENAME: d288 3 a290 2 /* * object creation d292 1 a292 1 case DEFINE: d295 1 a295 1 d297 1 a297 1 case INDEX: /* XXX no support for ARCHIVE indices, yet */ d305 2 a306 2 break; case OPERATOR: d308 1 a308 1 CString(CADR(args)), /* operator name */ d310 2 a311 2 break; case C_FUNCTION: d316 1 a316 1 case P_FUNCTION: d321 1 a321 1 case RULE: d323 1 a323 1 "Sorry, the old rule system is not supported any more (yet!)"); d325 1 a325 1 case REWRITE: d328 1 a328 1 case P_TUPLE: d331 1 a331 1 case P_TYPE: d335 1 a335 1 case VIEW: d339 1 a339 1 default: d344 1 a344 4 /* * object destruction */ case REMOVE: d347 1 a347 1 d349 1 a349 1 case FUNCTION: d352 1 a352 1 case INDEX: d355 1 a355 1 case OPERATOR: d367 1 a367 1 case P_TUPLE: d370 1 a370 1 case REWRITE: d373 1 a373 1 case P_TYPE: d378 2 a379 2 case FORWARD: d382 1 a382 1 d386 2 a387 1 case BACKWARD: d392 1 a392 1 CString(CADR(args))); d395 3 a397 6 /* * Exec the dynamic loader. */ case LOAD: commandTag = "LOAD"; d400 3 a402 15 FILE *fp, *fopen(); char *filename; filename = CString(CAR(args)); if (*filename != '/') { elog(WARN, "Use full pathname for LOAD command."); } else if ((fp = fopen(filename, "r")) == NULL) { elog(WARN, "LOAD: file %s does not exist", filename); } fclose(fp); load_file(filename); d405 2 a406 2 case CREATEDB: commandTag = "CREATEDB"; d409 3 a411 3 char *dbname; dbname = CString(CAR(args)); createdb(dbname); d414 7 a420 2 case DESTROYDB: commandTag = "DESTROYDB"; d423 12 a434 3 char *dbname; dbname = CString(CAR(args)); destroydb(dbname); d437 6 a442 2 /* default */ default: @ 1.40 log @Added new stuff for createdb and destroydb. @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.39 91/02/04 15:19:26 kemnitz Exp Locker: kemnitz $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.39 91/02/04 15:19:26 kemnitz Exp Locker: kemnitz $"); d36 1 d60 1 a60 1 ProcessUtility(command, args, commandString) d64 1 d443 5 a447 1 EndCommand(commandTag); @ 1.39 log @Added stubs for createdb and destroydb @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.38 91/01/14 10:52:41 mao Exp Locker: kemnitz $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.38 91/01/14 10:52:41 mao Exp Locker: kemnitz $"); d423 1 a423 1 elog(NOTICE, "createdb %s detected", dbname); d432 1 a432 1 elog(NOTICE, "destroydb %s detected", dbname); @ 1.38 log @tag handling botch fixed for purge @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.37 90/10/24 21:37:27 cimarron Exp Locker: mao $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.37 90/10/24 21:37:27 cimarron Exp Locker: mao $"); d400 2 d408 6 d415 18 @ 1.37 log @added fix for rename relation not renaming associated type @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.36 90/10/24 20:47:31 kemnitz Exp Locker: cimarron $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.36 90/10/24 20:47:31 kemnitz Exp Locker: cimarron $"); d169 1 a169 1 tags = CADR(args); d174 2 a175 2 if (CInteger(CAR(CAR(tags))) == BEFORE) { beforeString = CString(CADR(CAR(tags))); d177 1 a177 1 afterString = CString(CADR(CAR(tags))); d181 2 a182 2 beforeString = CString(CADR(CAR(tags))); afterString = CString(CADR(CADR(tags))); @ 1.36 log @Added support for "load " @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.35 90/10/22 16:24:53 goh Exp Locker: kemnitz $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.35 90/10/22 16:24:53 goh Exp Locker: kemnitz $"); a244 1 d249 18 d268 12 a279 7 args = CDR(args); if (len == 3) { /* relation */ renamerel(CString(CAR(args)), CString(CADR(args))); } else { /* attribute */ renamerel(CString(CAR(args)), CString(CADR(args)), CString(CADDR(args))); } d281 1 @ 1.35 log @added a new remove target for "remove rewrite rule" @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.34 90/10/22 10:18:33 goh Exp $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.34 90/10/22 10:18:33 goh Exp $"); d369 17 @ 1.34 log @hooks for "backward" versions @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.34 90/10/18 19:00:21 goh Exp $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.34 90/10/18 19:00:21 goh Exp $"); d342 1 a342 1 case RULE: d344 3 @ 1.33 log @rearranged #includes to eliminate tcop/tcop.h and executor/executor.h @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.32 90/08/14 16:20:23 cimarron Exp Locker: cimarron $ d21 1 a21 1 RcsId("$Header$"); d351 1 a351 1 case NEWVERSION: d358 8 a365 1 @ 1.32 log @added pathnames to header includes @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.31 90/08/07 14:16:15 ong Exp Locker: cimarron $ d19 1 a19 1 #include "tcop/tcop.h" d21 19 a39 1 RcsId("$Header: RCS/utility.c,v 1.31 90/08/07 14:16:15 ong Exp Locker: cimarron $"); @ 1.31 log @added hooks for versioning. @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.30 90/07/09 12:56:51 ong Exp $ d19 1 a19 1 #include "tcop.h" d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.30 90/07/09 12:56:51 ong Exp $"); @ 1.30 log @added define p function @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.29 90/06/02 14:46:16 cimarron Exp Locker: ong $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.29 90/06/02 14:46:16 cimarron Exp Locker: ong $"); d331 8 @ 1.29 log @added some stuff to help ProcessUtility cope with executing within the aborted transaction block state. @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.28 90/05/01 15:05:35 mao Exp $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.28 90/05/01 15:05:35 mao Exp $"); d265 1 a265 1 case FUNCTION: d269 5 @ 1.28 log @purge utility seg faulted trying to read through a nil pointer. fixed. @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.27 90/04/17 15:41:41 goh Exp $ d21 1 a21 1 RcsId("$Header: RCS/utility.c,v 1.27 90/04/17 15:41:41 goh Exp $"); d24 13 d54 2 d66 2 d76 2 d84 2 d112 1 a112 1 elog(WARN, "MOVE: unimplemented in Version 1"); d114 3 d123 2 d132 2 d144 2 d173 2 d213 2 a214 1 d223 2 d248 2 a249 1 d298 2 a299 1 @ 1.27 log @merged with cim's 1.25 change (why was it necessary ?) @ text @d15 1 a15 1 * $Header: RCS/utility.c,v 1.25 90/03/31 19:01:55 cimarron Exp $ a19 1 RcsId("$Header: RCS/utility.c,v 1.25 90/03/31 19:01:55 cimarron Exp $"); d21 2 d123 1 a123 1 case 0: d125 1 a125 1 case 1: d132 1 a132 1 case 2: @ 1.26 log @grr, why does my code keep getting nuked. Put define view and define query rewrite back @ text @d1 5 a5 4 /* * utility.c -- * * DESCRIPTION d7 10 a16 3 * POSTGRES utility commands. Acts as an interface between * the Lisp and C systems. * d19 2 a20 1 #include "c.h" d22 3 a24 15 RcsId("$Header: RCS/utility.c,v 1.24 90/01/30 23:42:42 sp Exp $"); #include "creatinh.h" #include "defrem.h" #include "pg_lisp.h" /* lisp-compat package */ #include "xcxt.h" /* for {Start,Commit,Abort}TransactionBlock */ #include "parse.h" /* y.tab.h, created by yacc'ing gram.y */ #include "log.h" /* error logging */ #include "command.h" /* * general utility function invoker * d28 3 a30 3 int command; /* "tag" */ LispValue args; char *commandString; d40 1 a40 1 StartTransactionBlock(); d42 1 d45 1 a45 1 CommitTransactionBlock(); d47 1 d61 1 d87 1 d95 1 d238 1 a238 1 DefineQueryRewrite ( CDR (args )) ; @ 1.25 log @*** empty log message *** @ text @d1 4 a4 5 /* ---------------------------------------------------------------- * FILE * utility.c * * DESCRIPTION d6 3 a8 10 * POSTGRES utility commands. At one time acted as an * interface between the Lisp and C systems. * * INTERFACE ROUTINES * * NOTES * * IDENTIFICATION * $Header$ * ---------------------------------------------------------------- d11 1 a11 2 #include "tcop.h" RcsId("$Header$"); d13 15 a27 3 /* ---------------- * general utility function invoker * ---------------- d31 3 a33 3 int command; /* "tag" */ LispValue args; char *commandString; d43 1 a43 1 BeginTransactionBlock(); a44 1 d47 1 a47 1 EndTransactionBlock(); a48 1 a61 1 a86 1 a93 1 d236 1 a236 2 elog(WARN,"PRS2-query rewrite disabled for the time being"); /* DefineQueryRewrite ( CDR (args )) ; */ a245 2 elog(WARN,"views disabled for the time being"); #ifdef NOT_YET a247 1 #endif NOT_YET @ 1.24 log @a) ProcessUtility takes the command string as its third argument and b)changed the calls to the rule Define/Remove routines. @ text @d1 5 a5 4 /* * utility.c -- * * DESCRIPTION d7 10 a16 3 * POSTGRES utility commands. Acts as an interface between * the Lisp and C systems. * d19 2 a20 1 #include "c.h" d22 3 a24 15 RcsId("$Header: RCS/utility.c,v 1.22 89/12/22 14:23:29 goh Exp Locker: goh $"); #include "creatinh.h" #include "defrem.h" #include "pg_lisp.h" /* lisp-compat package */ #include "xcxt.h" /* for {Start,Commit,Abort}TransactionBlock */ #include "parse.h" /* y.tab.h, created by yacc'ing gram.y */ #include "log.h" /* error logging */ #include "command.h" /* * general utility function invoker * d28 3 a30 3 int command; /* "tag" */ LispValue args; char *commandString; d40 1 a40 1 StartTransactionBlock(); d42 1 d45 1 a45 1 CommitTransactionBlock(); d47 1 d61 1 d87 1 d95 1 @ 1.23 log @changed TUPLE to P_TUPLE ... to disambiguate with stuff in tuples.c @ text @d30 1 a30 1 ProcessUtility(command, args) d33 1 d232 2 a233 2 DefineRule(CString(CADR(args)), /* rule name */ CADDR(args)); /* parsed rule query */ d236 2 a237 1 DefineQueryRewrite ( CDR (args )) ; d240 1 a240 1 /* XXX - Spyros, can you add your stuff here */ d247 2 d251 1 d284 1 a284 1 RemoveRule(CString(CADR(args))); @ 1.22 log @added define rewrite and define tuple rules for the new rules system (PRS2) @ text @d13 1 a13 1 RcsId("$Header: RCS/utility.c,v 1.21 89/10/12 14:52:30 hirohama Exp $"); d237 1 a237 1 case TUPLE: @ 1.21 log @DefineRelation now takes string as first argument @ text @d13 1 a13 1 RcsId("$Header: RCS/utility.c,v 1.20 89/10/11 15:20:14 hirohama Exp Locker: hirohama $"); d34 29 a62 29 String commandTag = NULL; switch (command) { /* * transactions */ case BEGIN_TRANS: commandTag = "BEGIN"; StartTransactionBlock(); break; case END_TRANS: commandTag = "END"; CommitTransactionBlock(); break; case ABORT_TRANS: commandTag = "ABORT"; AbortTransactionBlock(); break; /* * portal manipulation */ case CLOSE: commandTag = "CLOSE"; PerformPortalClose((null(CAR(args))) ? NULL : CString(CAR(args))); break; case FETCH: commandTag = "FETCH"; d64 14 a77 6 String portalName = NULL; bool forward; int count; if (!null(CAR(args))) { portalName = CString(CAR(args)); d79 2 a80 11 forward = (bool)(CAtom(CADR(args)) == FORWARD); count = 0; if (!lispAtomp(CADDR(args))) { count = CInteger(CADDR(args)); if (count < 0) { elog(WARN, "Fetch: specify nonnegative count"); } if (count == 0) { break; } d82 2 a83 1 PerformPortalFetch(portalName, forward, count); d85 17 a101 17 break; case MOVE: commandTag = "MOVE"; elog(WARN, "MOVE: unimplemented in Version 1"); /* * relation and attribute manipulation */ case CREATE: commandTag = "CREATE"; DefineRelation(CString(CAR(args)), /* relation name */ CADR(args), /* parameters */ CDR(CDR(args))); /* schema */ break; case DESTROY: commandTag = "DESTROY"; d103 4 a106 4 LispValue relationName; foreach (relationName, args) { RemoveRelation(CString(CAR(relationName))); } d108 4 a111 4 break; case PURGE: commandTag = "PURGE"; d113 7 a119 22 List tags; String beforeString = NULL; /* absolute time string */ String afterString = NULL; /* relative time string */ tags = CADR(args); switch (length(tags)) { case 0: break; case 1: if (CInteger(CAR(CAR(tags))) == BEFORE) { beforeString = CString(CADR(CAR(tags))); } else { afterString = CString(CADR(CAR(tags))); } break; case 2: beforeString = CString(CADR(CAR(tags))); afterString = CString(CADR(CADR(tags))); break; } RelationPurge(CString(CAR(args)), beforeString, afterString); } d121 5 a125 28 case COPY: commandTag = "COPY"; { String relationName; String fileName; String mapName = NULL; bool isBinary; bool noNulls; bool isFrom; relationName = CString(CAAR(args)); isBinary = (bool)!null(CADR(CAR(args))); noNulls = (bool)!null(CADDR(CAR(args))); /* * discard '("relname" [BINARY] [NONULLS]) */ args = CDR(args); isFrom = (bool)(CAtom(CAAR(args)) == FROM); fileName = CString(CADR(CAR(args))); /* * discard '(FROM/TO "filename") */ args = CDR(args); if (!null(CDR(CAR(args)))) { mapName = CString(CADR(CAR(args))); a126 8 /* * discard '(USING ["mapName"]) */ args = CDR(args); PerformRelationFilter(relationName, isBinary, noNulls, isFrom, fileName, mapName, args); } d128 3 a130 5 case ADD_ATTR: commandTag = "ADD"; PerformAddAttribute(CString(CAR(args)), CDR(args)); d132 7 a138 6 /* * schema */ case RENAME: commandTag = "RENAME"; d140 53 a192 6 int len; len = length(args); /* * skip unused "RELATION" or "ATTRIBUTE" tag d194 3 a196 3 args = CDR(args); if (len == 3) { /* relation */ renamerel(CString(CAR(args)), CString(CADR(args))); d198 2 a199 2 renamerel(CString(CAR(args)), CString(CADR(args)), CString(CADDR(args))); d201 18 a218 1 } d220 4 a223 38 /* * object creation */ case DEFINE: commandTag = "DEFINE"; switch(LISPVALUE_INTEGER(CAR(args))) { case INDEX: /* XXX no support for ARCHIVE indices, yet */ args = CDR(args); /* skip "INDEX" token */ DefineIndex(CString(CAR(args)), /* relation name */ CString(CADR(args)), /* index name */ CString(CADDR(args)), /* am name */ CADDR(CDR(args)), /* parameters */ CADDR(CDR(CDR(args)))); /* with */ break; case OPERATOR: DefineOperator( CString(CADR(args)), /* operator name */ CDR(CDR(args))); /* rest */ break; case FUNCTION: DefineFunction( CString(CADR(args)), /* function name */ CDR(CDR(args))); /* rest */ break; case RULE: DefineRule(CString(CADR(args)), /* rule name */ CADDR(args)); /* parsed rule query */ break; case P_TYPE: DefineType( CString(CADR(args)), /* type name */ CDR(CDR(args))); /* rest */ break; } d225 48 a272 24 /* * object destruction */ case REMOVE: commandTag = "REMOVE"; switch(CInteger(CAR(args))) { case FUNCTION: RemoveFunction(CString(CADR(args))); break; case INDEX: RemoveIndex(CString(CADR(args))); break; case OPERATOR: { String type2 = NULL; args = CADR(args); if (length(args) == 3) { type2 = CString(CADR(CDR(args))); } RemoveOperator(CString(CAR(args)), CString(CADR(args)), type2); d274 10 a283 14 break; case RULE: RemoveRule(CString(CADR(args))); break; case P_TYPE: RemoveType(CString(CADR(args))); break; } break; /* default */ default: elog(WARN, "ProcessUtility: command #%d unsupport", command); break; d285 10 a295 2 EndCommand(commandTag); } @ 1.20 log @added ADD @ text @d13 1 a13 1 RcsId("$Header: RCS/utility.c,v 1.19 89/10/09 18:36:02 hirohama Exp Locker: hirohama $"); d95 1 a95 1 DefineRelation(CAR(args), /* relation name */ @ 1.19 log @parser output checking moved to parsev.c @ text @d13 1 a13 1 RcsId("$Header: RCS/utility.c,v 1.18 89/10/06 15:58:12 sp Exp Locker: hirohama $"); a174 2 /* domain list */ #if 0 d177 2 a178 8 #ifndef PERFECTPARSER AssertArg(consp(args) && lispStringp(CAR(args))); AssertArg(consp(CDR(args)) && lispStringp(CADR(args))); AssertArg(null(CDR(CDR(args)))); #endif addattribute(CString(CAR(args)), relation_add_attribute (CAR (args), /* relation name */ CDR (args)); d180 1 a180 1 #endif @ 1.18 log @DefineRule works now.... @ text @d13 1 a13 1 RcsId("$Header: RCS/utility.c,v 1.17 89/10/01 15:17:20 ong Exp Locker: ong $"); a14 1 #include "command.h" a19 2 extern int PG_INTERACTIVE; d23 2 a41 3 #ifndef PERFECTPARSER AssertArg(null(args)); #endif a45 3 #ifndef PERFECTPARSER AssertArg(null(args)); #endif a49 3 #ifndef PERFECTPARSER AssertArg(null(args)); #endif a57 5 #ifndef PERFECTPARSER AssertArg(consp(args)); AssertArg(null(CDR(args))); AssertArg(null(CAR(args)) || lispStringp(CAR(args))); #endif d67 1 a67 9 #ifndef PERFECTPARSER AssertArg(consp(args)); AssertArg(consp(CDR(args))); AssertArg(lispAtomp(CADR(args))); AssertArg(CAtom(CADR(args)) == FORWARD || CAtom(CADR(args)) == BACKWARD); AssertArg(consp(CDR(CDR(args)))); AssertArg(lispIntegerp(CADDR(args)) || lispAtomp(CADDR(args))); AssertArg(null(CDR(CDR(CDR(args))))); #endif a68 3 #ifndef PERFECTPARSER AssertArg(lispStringp(CAR(args))); #endif d73 1 a73 5 if (lispAtomp(CADDR(args))) { #ifndef PERFECTPARSER AssertArg(CAtom(CADDR(args)) == ALL); #endif } else { a104 4 #ifndef PERFECTPARSER AssertArg(listp(relationName)); AssertArg(lispStringp(CAR(relationName))); #endif d116 1 a116 4 #ifndef PERFECTPARSER AssertArg(listp(args)); AssertArg(length(args) == 2); #endif a121 4 #ifndef PERFECTPARSER AssertArg(lispIntegerp(CAR(CAR(tags)))); AssertArg(lispStringp(CADR(CAR(tags)))); #endif a125 3 #ifndef PERFECTPARSER AssertArg(CInteger(CAR(CAR(tags))) == AFTER); #endif a128 8 #ifndef PERFECTPARSER AssertArg(lispIntegerp(CAR(CAR(tags)))); AssertArg(CInteger(CAR(CAR(tags))) == BEFORE); AssertArg(lispStringp(CADR(CAR(tags)))); AssertArg(lispIntegerp(CAR(CADR(tags)))); AssertArg(CInteger(CAR(CADR(tags))) == AFTER); AssertArg(lispStringp(CADR(CADR(tags)))); #endif a131 4 default: #ifndef PERFECTPARSER AssertArg(false); #endif a136 1 /* tags/date alist */ d143 2 a144 2 bool isBinary = false; bool noNulls = false; a146 5 #ifndef PERFECTPARSER AssertArg(length(args) >= 3); AssertArg(length(CAR(args)) == 3); AssertArg(lispStringp(CAAR(args))); #endif d148 2 a149 14 if (!null(CADR(CAR(args)))) { #ifndef PERFECTPARSER AssertArg(lispIntegerp(CADR(CAR(args)))); AssertArg(CInteger(CADR(CAR(args))) == BINARY); #endif isBinary = true; } if (!null(CADDR(CAR(args)))) { #ifndef PERFECTPARSER AssertArg(lispIntegerp(CADDR(CAR(args)))); AssertArg(CInteger(CADDR(CAR(args))) == NONULLS); #endif noNulls = true; } d155 1 a155 13 #ifndef PERFECTPARSER AssertArg(length(CAR(args)) == 2); AssertArg(lispAtomp(CAAR(args))); AssertArg(lispStringp(CADR(CAR(args)))); #endif if (CAtom(CAAR(args)) == FROM) { isFrom = true; } else { #ifndef PERFECTPARSER AssertArg(CAtom(CAAR(args)) == TO); #endif isFrom = false; } a161 7 #ifndef PERFECTPARSER AssertArg(length(CAR(args)) >= 1); /* * Note: * CAAR(args) is not checked to verify it is a USING int. */ #endif a162 4 #ifndef PERFECTPARSER AssertArg(length(CAR(args)) == 2); AssertArg(lispStringp(CADR(CAR(args)))); #endif d169 1 a169 5 #ifndef PERFECTPARSER /* * Check the format of args (the domain list) here */ #endif d198 1 a198 8 #ifndef PERFECTPARSER AssertArg(len == 3 || len == 4); AssertArg(lispStringp(CADR(args))); AssertArg(lispStringp(CADDR(args))); if (len == 4) { AssertArg(lispStringp(CADDR(CDR(args)))); } #endif d211 4 a214 1 /* object creation */ d217 1 a217 6 #ifndef PERFECTPARSER /* * Index is an integer; Type, etc. are atoms?!? */ AssertArg(atom(CAR(args)) || integerp(CAR(args))); #endif d221 1 a221 10 #ifndef PERFECTPARSER AssertArg(listp(args)); AssertArg(lispStringp(CAR(args))); AssertArg(listp(CDR(args))); AssertArg(lispStringp(CADR(args))); AssertArg(listp(CDR(CDR(args)))); AssertArg(lispStringp(CADDR(args))); AssertArg(listp(CDR(CDR(CDR(args))))); AssertArg(listp(CDR(CDR(CDR(CDR(args)))))); #endif a228 6 args = CDR(args); /* skip "OPERATOR" token */ #ifndef PERFECTPARSER AssertArg(listp(args)); AssertArg(lispStringp(CAR(args))); AssertArg(listp(CDR(args))); #endif d230 2 a231 2 CString(CAR(args)), /* operator name */ CDR(args)); /* rest */ a233 6 args = CDR(args); /* skip "FUNCTION" token */ #ifndef PERFECTPARSER AssertArg(listp(args)); AssertArg(lispStringp(CAR(args))); AssertArg(listp(CDR(args))); #endif d235 2 a236 2 CString(CAR(args)), /* function name */ CDR(args)); /* rest */ a237 1 a238 3 AssertArg(listp(args)); AssertArg(lispStringp(CADR(args))); AssertArg(listp(CADDR(args))); a243 6 args = CDR(args); /* skip "TYPE" token */ #ifndef PERFECTPARSER AssertArg(listp(args)); AssertArg(lispStringp(CAR(args))); AssertArg(listp(CDR(args))); #endif d245 2 a246 2 CString(CAR(args)), /* type name */ CDR(args)); /* rest */ a247 4 default: elog(WARN, "unknown DEFINE parse type %d", CInteger(CAR(args))); break; d256 1 a256 3 #ifndef PERFECTPARSER AssertArg(consp(args)); #endif a258 3 #ifndef PERFECTPARSER AssertArg(lispStringp(CADR(args))); #endif a261 3 #ifndef PERFECTPARSER AssertArg(lispStringp(CADR(args))); #endif d266 2 a267 6 int argCount; String type2; #ifndef PERFECTPARSER AssertArg(consp(CADR(args))); AssertArg(null(CDR(CDR(args)))); #endif d269 1 a269 11 argCount = length(args); #ifndef PERFECTPARSER AssertArg(lispStringp(CAR(args))); AssertArg(2 <= argCount && argCount <= 3); AssertArg(lispStringp(CADR(args))); if (argCount == 3) { AssertArg(lispStringp(CADR(CDR(args)))); } #endif type2 = NULL; if (argCount == 3) { a276 4 #ifndef PERFECTPARSER AssertArg(length(args) == 2); AssertArg(lispStringp(CADR(args))); #endif a279 4 #ifndef PERFECTPARSER AssertArg(length(args) == 2); AssertArg(lispStringp(CADR(args))); #endif a281 3 default: elog(WARN, "unknown REMOVE parse type %d", CInteger(CAR(args))); @ 1.17 log @enabled define rule and corrected the args passed to rule_define() @ text @d13 1 a13 1 RcsId("$Header: RCS/utility.c,v 1.16 89/09/25 10:32:08 hirohama Exp Locker: ong $"); d371 5 a375 2 rule_define(CADR(args), /* rule name */ CADR(CDR(args))); /* parsed rule query */ @ 1.16 log @fixed BEGIN, END, ABORT parser checking @ text @d13 1 a13 1 RcsId("$Header: RCS/utility.c,v 1.15 89/09/20 22:42:25 hirohama Exp Locker: hirohama $"); d371 2 a372 6 elog(WARN, "InvokeUtility: DEFINE RULE now unsupported"); #if 0 rule_define(CAR(args), /* rule name */ CADR(args)); /* parsed rule query */ #endif @ 1.15 log @missing break for REMOVE case (sp) @ text @d13 1 a13 1 RcsId("$Header: RCS/utility.c,v 1.14 89/09/20 22:25:47 hirohama Exp Locker: hirohama $"); d44 1 a44 1 AssertArg(consp(args) && null(CDR(args))); d51 1 a51 1 AssertArg(consp(args) && null(CDR(args))); d58 1 a58 1 AssertArg(consp(args) && null(CDR(args))); @ 1.14 log @REMOVE RULE by Spyros @ text @d13 1 a13 1 RcsId("$Header: RCS/utility.c,v 1.13 89/09/15 18:15:25 hirohama Exp Locker: hirohama $"); d462 1 @ 1.13 log @removed trailing garbage after ProcessUtility function @ text @d13 1 a13 1 RcsId("$Header: RCS/utility.c,v 1.12 89/09/15 18:11:42 hirohama Exp Locker: hirohama $"); d297 1 a297 3 #ifndef PERFECTPARSER AssertArg(listp(args)); #endif a322 1 AssertArg(listp(args)); d445 3 a447 4 elog(DEBUG, "InvokeUtility: REMOVE RULE now unsupported"); #if 0 rule_remove(CDR(args)); d449 1 d453 1 @ 1.12 log @remove the "PORTAL" utility--this is not POSTQUEL, probably was for debugging @ text @d13 1 a13 1 RcsId("$Header: RCS/utility.c,v 1.11 89/09/15 17:35:19 hirohama Exp Locker: hirohama $"); a472 54 /* * rename utility function invoker * */ #if 0 int rename_utility_invoke (object_type_name,args) LispValue object_type_name,args ; { switch (object_type_name) { case 0/*RELATION*/: relation_rename (CAR (args) /* old relation name */ ,CADR (args)); break; /* new relation name */ case 1/*ATTRIBUTE*/: attribute_rename (CAR (args) /* relation name */ ,CADR (args) /* old attribute name */ ,CADDR (args)); break; /* new attribute name */ default: elog(WARN,"unknown RENAME request"); break; } } #endif /* * POSTGRES utility commands follow * */ /* * relation and attribute manipulation functions * */ #if 0 relation_purge (relation_name,date_tags) LispValue relation_name,date_tags ; { /*RelationPurge (relation_name,cdr (assoc (BEFORE,date_tags)) || 0, CDR (assoc (AFTER,date_tags)) || 0)*/ utility_end ("PURGE"); } #endif @ 1.11 log @added PURGE @ text @d13 1 a13 1 RcsId("$Header: RCS/utility.c,v 1.10 89/09/10 17:13:47 hirohama Exp Locker: hirohama $"); d464 1 a464 14 break; #if 0 /* portal retrieve */ /* XXX Can this be generalized to more than a single retrieve? */ /* Should it? */ case PORTAL: commandTag = "PORTAL"; /* check validity */ portal_retrieve (CAR (args), /* portal name */ CADR (args), /* command */ CADDR (args)); break; #endif @ 1.10 log @added support for COPY @ text @d13 1 a13 1 RcsId("$Header: RCS/utility.c,v 1.9 89/09/05 22:47:27 hirohama Exp Locker: hirohama $"); a143 1 #if 0 d146 45 a190 2 relation_purge (CAR(args), /* relation name */ CADR(args)); a193 1 #endif @ 1.9 log @same as -r1.7 @ text @d13 1 a13 1 RcsId("$Header: RCS/utility.c,v 1.7 89/09/01 12:12:19 hirohama Exp $"); d144 1 a144 1 #if 0 d152 1 d155 78 a232 7 relation_transform (CAR(CARargs), CADR(CAR(args)), nth (2,nth (0,args)) ,nth (0,nth (1,args)) ,nth (1,nth (1,args)) ,nth (1,nth (2,args)) ,nthcdr (3,args)); d236 1 a236 1 a496 21 } #endif #if 0 LispValue relation_transform (relation_name,format,nonulls, direction,file_name,map_relation,domain_list) LispValue relation_name,format,nonulls,direction, file_name,map_relation,domain_list ; { char *error_string = "relation-transform: ERROR: "; int natts = length (domain_list); bool isbinary = (null(format) ? false : true ); bool isnonulls = (equal (nonulls,NONULLS) ? true : false ); bool isfrom = (equal(direction,TO) ? false : true ); bool map_relation_name = (map_relation ? true : false); /* LispValue fixed_domain_list = relation_transform_fix_domains (domain_list); LispValue domain_number = vectori_long (0); */ @ 1.8 log @Working version of C-only demo @ text @d13 1 a13 1 RcsId("$Header: RCS/utility.c,v 1.6 89/08/30 12:53:05 hirohama Exp $"); d19 1 d38 3 a40 2 #if 0 /* transactions */ d43 4 a46 5 if ( null (args) ) { start_transaction_block (); } else { cons (command,args); } d50 4 a53 5 if ( null (args) ) { commit_transaction_block (); } else { cons (command,args); }; d57 4 a60 5 if ( null (args) ) { abort_transaction_block (); } else { cons (command,args); } a61 1 #endif d118 1 a118 9 elog(WARN, "MOVE: unimplemented"); #if 0 portal_move (CAR (args), ((CInteger(CADR(args)) == FORWARD) ? true : false ), /* forward ? */ CInteger(CADDR (args))); /* ntups to scan -1 means "ALL" */ break; #endif d167 6 d176 4 a179 2 /* schema */ d182 25 a206 1 rename_utility_invoke (CAR (args),cdr (args)); a207 1 #endif d261 1 a261 1 elog(DEBUG, d340 1 d367 1 a367 1 cons (command,args); @ 1.7 log @added {BEGIN,END,ABORT} TRANSACTION and RENAME @ text @d13 1 a13 1 RcsId("$Header: RCS/utility.c,v 1.6 89/08/30 12:53:05 hirohama Exp Locker: hirohama $"); a18 1 #include "xcxt.h" /* for {Start,Commit,Abort}TransactionBlock */ d37 2 a38 3 /* * transactions */ d41 5 a45 4 #ifndef PERFECTPARSER AssertArg(consp(args) && null(CDR(args))); #endif StartTransactionBlock(); d49 5 a53 4 #ifndef PERFECTPARSER AssertArg(consp(args) && null(CDR(args))); #endif CommitTransactionBlock(); d57 6 a62 2 #ifndef PERFECTPARSER AssertArg(consp(args) && null(CDR(args))); a63 2 AbortTransactionBlock(); break; d120 9 a128 1 elog(WARN, "MOVE: unimplemented in Version 1"); a176 6 #ifndef PERFECTPARSER AssertArg(consp(args) && lispStringp(CAR(args))); AssertArg(consp(CDR(args)) && lispStringp(CADR(args))); AssertArg(null(CDR(CDR(args)))); #endif addattribute(CString(CAR(args)), d180 2 a181 4 #endif /* * schema */ d184 2 a185 4 { int len; #ifndef PERFECTPARSER AssertArg(listp(args)); a186 21 len = length(args); #ifndef PERFECTPARSER AssertArg(len == 3 || len == 4); AssertArg(lispStringp(CADR(args))); AssertArg(lispStringp(CADDR(args))); if (len == 4) { AssertArg(lispStringp(CADDR(CDR(args)))); } #endif /* * skip unused "RELATION" or "ATTRIBUTE" tag */ args = CDR(args); if (len == 3) { /* relation */ renamerel(CString(CAR(args)), CString(CADR(args))); } else { /* attribute */ renamerel(CString(CAR(args)), CString(CADR(args)), CString(CADDR(args))); } } break; d240 1 a240 1 elog(WARN, a318 1 break; d345 1 a345 1 elog(WARN, "ProcessUtility: command #%d unsupport", command); @ 1.6 log @added FETCH @ text @d13 1 a13 1 RcsId("$Header: RCS/utility.c,v 1.5 89/08/29 15:17:16 hirohama Exp Locker: hirohama $"); d19 1 d38 3 a40 2 #if 0 /* transactions */ d43 4 a46 5 if ( null (args) ) { start_transaction_block (); } else { cons (command,args); } d50 4 a53 5 if ( null (args) ) { commit_transaction_block (); } else { cons (command,args); }; d57 4 a60 5 if ( null (args) ) { abort_transaction_block (); } else { cons (command,args); } a61 1 #endif d118 1 a118 9 elog(WARN, "MOVE: unimplemented"); #if 0 portal_move (CAR (args), ((CInteger(CADR(args)) == FORWARD) ? true : false ), /* forward ? */ CInteger(CADDR (args))); /* ntups to scan -1 means "ALL" */ break; #endif d167 6 d176 4 a179 2 /* schema */ d182 25 a206 1 rename_utility_invoke (CAR (args),cdr (args)); a207 1 #endif d261 1 a261 1 elog(DEBUG, d340 1 d367 1 a367 1 cons (command,args); @ 1.5 log @now calls EndCommand CLOSE now supported @ text @d13 1 a13 1 RcsId("$Header: RCS/utility.c,v 1.4 89/08/22 20:38:31 hirohama Exp Locker: hirohama $"); d80 37 a116 6 #if 0 portal_fetch(CString(CAR(args)), /* portal name */ ((CInteger(CADR(args)) == FORWARD) ? true : false ), /* forward ? */ CInteger(CADDR (args))); /* ntups to scan -1 means "ALL" */ a117 1 #endif @ 1.4 log @DEFINE and REMOVE now processed @ text @a0 1 d13 1 a13 1 RcsId("$Header$"); d15 1 a24 7 /* * Note: * XXX most of the (pgerror *WARN* ...) calls below indicate an * non-fatal internal error. The rest of the system should work fine. * */ a25 17 * general utility execution completion code * */ LispValue utility_end (name) LispValue name ; { #if 0 declare (special (PG_INTERACTIVE)); /* XXX unless interactive? why not always? */ if (!PG_INTERACTIVE) { endportal(name); } #endif } /* d29 2 a30 2 LispValue utility_invoke (command, args) d34 2 d40 1 d48 1 d56 1 d64 4 a67 2 #if 0 /* portal manipulation */ d69 8 a76 9 { LispValue portal_name; foreach (portal_name, args) { if (! lispStringp(portal_name)) elog(WARN,"portal list not strings"); else portal_close (CString(portal_name)); } } d79 2 a80 1 d87 1 a87 1 d89 3 d104 1 d111 1 d126 1 d133 1 d146 1 d153 1 d159 1 d240 1 d305 1 d318 2 @ 1.3 log @added simple DESTROY (no inheritance yet) @ text @d3 1 a3 2 * FILE * utility.l a10 5 /* require ("nodeDefs"); require ("parsetree"); require ("pgmacs"); */ d12 4 d17 2 a18 1 #include "pg_lisp.h" a19 3 /* temporary stuff */ #define declare(x) /* x */ a22 2 #include "pg_lisp.h" /* lisp-compat package */ #include "c.h" /* generic defns, needed for bools here */ d40 1 a42 1 #if 0 d60 1 a60 1 /* transactions */ d62 6 a67 7 if ( null (args) ) { start_transaction_block (); } else { cons (command,args); } break; d69 6 a74 7 if ( null (args) ) { commit_transaction_block (); } else { cons (command,args); }; break; d76 6 a81 6 if ( null (args) ) { abort_transaction_block (); } else { cons (command,args); } break; d84 1 a84 1 /* portal manipulation */ d86 10 a95 11 { LispValue portal_name; foreach (portal_name, args) { if (! lispStringp(portal_name)) elog(WARN,"portal list not strings"); else portal_close (CString(portal_name)); } } break; d98 1 a98 1 portal_fetch (CString(CAR (args)), /* portal name */ d100 1 a100 1 true : false ), /* forward ? */ d103 1 a103 1 break; d106 6 a111 6 portal_move (CAR (args), ((CInteger(CADR(args)) == FORWARD) ? true : false ), /* forward ? */ CInteger(CADDR (args))); /* ntups to scan -1 means "ALL" */ break; d114 3 a116 3 /* * relation and attribute manipulation */ d138 3 a140 3 relation_purge (CAR(args), /* relation name */ CADR(args)); break; d142 1 a142 2 /* tags/date alist */ d144 8 a151 10 /* relation_transform (CAR(CARargs), CADR(CAR(args)), nth (2,nth (0,args)) ,nth (0,nth (1,args)) ,nth (1,nth (1,args)) ,nth (1,nth (2,args)) ,nthcdr (3,args)); */ break; d153 1 a153 1 /* domain list */ d156 3 a158 3 relation_add_attribute (CAR (args), /* relation name */ CDR (args)); break; d160 1 a160 2 /* schema */ d162 2 a163 2 rename_utility_invoke (CAR (args),cdr (args)); break; d165 1 a165 3 #if 0 /* object creation */ d167 25 a191 7 switch(CInteger(CAR(args))) { case INDEX: index_define(CString(CAR(args)), /* relation name */ CADR(args), /* index name */ CADDR (args), /* am name */ cadddr (args), /* parameters */ caddddr (args)); d194 9 a202 4 operator_define (CAR (args) /* operator name */ ,cdr (args)); /* remaining arguments */ d205 9 a213 4 function_define (CAR (args) /* function name */ ,cdr (args)); /* remaining arguments */ d215 1 d217 6 a222 2 rule_define (CAR(args), /* rule name */ CADR(args)); d224 1 a224 1 /* rule command parses */ d226 9 a234 1 type_define (CAR (args),CDR (args)); d236 4 d241 1 a241 4 break; #endif #if 0 /* object destruction */ d243 3 d247 2 a248 16 switch(CInteger(CAR(args))) { case FUNCTION: function_remove(CDR(args)); break; case INDEX: index_remove(CDR(args)); case OPERATOR: operator_remove(CDR(args)); case RULE: rule_remove(CDR(args)); case P_TYPE: type_remove(CDR(args)); default: elog(WARN,"parser generates unknown remove request"); } break; d250 42 d293 17 a309 3 /* portal retrieve */ /* XXX Can this be generalized to more than a single retrieve? */ /* Should it? */ d311 6 a316 7 /* check validity */ portal_retrieve (CAR (args), /* portal name */ CADR (args), /* command */ CADDR (args)); break; /* default */ d318 1 d320 3 a322 3 cons (command,args); break; } @ 1.2 log @everything defined away except for CREATE for now @ text @d17 2 d22 1 a23 2 #define declare(x) /* x */ #define foreach(x,y) for(x=y;x!=LispNil;x=CDR(x)) d129 1 a129 1 CDR(CDR(args))); d131 14 a144 2 /* schema */ a145 8 case DESTROY: { LispValue relation_name; foreach (relation_name, args) { relation_remove (relation_name); } break; } @ 1.1 log @Initial revision @ text @d46 6 a51 1 unless (PG_INTERACTIVE,endportal (name)); d59 3 a61 2 utility_invoke (command,args) LispValue command,args ; d63 2 a64 2 switch (command) { d89 2 a90 1 d120 1 a120 2 /* relation and attribute manipulation */ d122 3 d126 4 a129 4 relation_define (CAR (args), /* relation name */ CADR (args), /* parameters */ CDDR (args)); break; d132 1 a132 1 d172 2 a173 1 d175 1 a175 1 d177 10 a186 14 switch(CInteger(CAR(args))) { case INDEX: index_define (CString(CAR(args)), /* relation name */ CADR (args) /* index name */ ,CADDR (args) /* am name */ ,cadddr (args) /* parameters */ ,caddddr (args)); break; case OPERATOR: operator_define (CAR (args) d189 4 a192 6 break; /* remaining arguments */ case FUNCTION: function_define (CAR (args) d195 11 a205 16 break; /* remaining arguments */ case RULE: rule_define (CAR(args), /* rule name */ CADR(args)); break; /* rule command parses */ case P_TYPE: type_define (CAR (args),CDR (args)); break; } d207 2 a208 1 d215 1 d228 2 a229 1 a232 1 d241 1 d253 1 a253 1 d282 1 a282 1 d292 1 a292 1 d300 2 a301 1 d321 1 @