*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.95 2004/01/10 23:28:44 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.96 2004/01/23 02:13:11 neilc Exp $
*
*-------------------------------------------------------------------------
*/
#include "optimizer/plancat.h"
#include "optimizer/prep.h"
#include "parser/gramparse.h"
+#include "parser/parse_clause.h"
#include "parser/parse_coerce.h"
#include "parser/parse_expr.h"
#include "parser/parse_oper.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
-#include "utils/guc.h"
#include "utils/inval.h"
#include "utils/lsyscache.h"
#include "utils/relcache.h"
if (parentHasOids)
descriptor->tdhasoid = true;
else
- {
- switch (stmt->hasoids)
- {
- case MUST_HAVE_OIDS:
- descriptor->tdhasoid = true;
- break;
-
- case MUST_NOT_HAVE_OIDS:
- descriptor->tdhasoid = false;
- break;
-
- case DEFAULT_OIDS:
- descriptor->tdhasoid = default_with_oids;
- break;
- }
- }
+ descriptor->tdhasoid = interpretOidsOption(stmt->hasoids);
if (old_constraints != NIL)
{
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.296 2004/01/14 23:01:55 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.297 2004/01/23 02:13:12 neilc Exp $
*
*-------------------------------------------------------------------------
*/
static FromExpr *makeFromExpr(List *fromlist, Node *quals);
static bool check_parameter_resolution_walker(Node *node,
check_parameter_resolution_context *context);
+static char *makeObjectName(char *name1, char *name2, char *typename);
/*
* from the truncated characters. Currently it seems best to keep it simple,
* so that the generated names are easily predictable by a person.
*/
-char *
+static char *
makeObjectName(char *name1, char *name2, char *typename)
{
char *name;
cxt.stmtType = "CREATE TABLE";
cxt.relation = stmt->relation;
cxt.inhRelations = stmt->inhRelations;
- cxt.hasoids = stmt->hasoids;
cxt.relOid = InvalidOid;
cxt.columns = NIL;
cxt.ckconstraints = NIL;
cxt.blist = NIL;
cxt.alist = NIL;
cxt.pkey = NULL;
+ cxt.hasoids = interpretOidsOption(stmt->hasoids);
/*
* Run through each primary element in the table creation clause.
if (stmt->intoColNames)
applyColumnNames(qry->targetList, stmt->intoColNames);
- switch (stmt->intoHasOids)
- {
- case MUST_HAVE_OIDS:
- qry->intoHasOids = true;
- break;
-
- case MUST_NOT_HAVE_OIDS:
- qry->intoHasOids = false;
- break;
-
- case DEFAULT_OIDS:
- qry->intoHasOids = default_with_oids;
- break;
- }
+ qry->intoHasOids = interpretOidsOption(stmt->intoHasOids);
/* mark column origins */
markTargetListOrigins(pstate, qry->targetList);
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/parse_clause.c,v 1.126 2004/01/14 23:01:55 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_clause.c,v 1.127 2004/01/23 02:13:12 neilc Exp $
*
*-------------------------------------------------------------------------
*/
case INH_DEFAULT:
return SQL_inheritance;
}
- elog(ERROR, "bogus InhOption value");
+ elog(ERROR, "bogus InhOption value: %d", inhOpt);
+ return false; /* keep compiler quiet */
+}
+
+/*
+ * Given an enum that indicates whether WITH / WITHOUT OIDS was
+ * specified by the user, return true iff the specified table/result
+ * set should be created with OIDs. This needs to be done after
+ * parsing the query string because the return value can depend upon
+ * the default_with_oids GUC var.
+ */
+bool
+interpretOidsOption(ContainsOids opt)
+{
+ switch (opt)
+ {
+ case MUST_HAVE_OIDS:
+ return true;
+
+ case MUST_NOT_HAVE_OIDS:
+ return false;
+
+ case DEFAULT_OIDS:
+ return default_with_oids;
+ }
+
+ elog(ERROR, "bogus ContainsOids value: %d", opt);
return false; /* keep compiler quiet */
}
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/parser/analyze.h,v 1.24 2003/11/29 22:41:09 pgsql Exp $
+ * $PostgreSQL: pgsql/src/include/parser/analyze.h,v 1.25 2004/01/23 02:13:12 neilc Exp $
*
*-------------------------------------------------------------------------
*/
extern void CheckSelectForUpdate(Query *qry);
-/* This was exported to allow ADD CONSTRAINT to make use of it */
-extern char *makeObjectName(char *name1, char *name2, char *typename);
-
#endif /* ANALYZE_H */
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/parser/parse_clause.h,v 1.39 2004/01/14 23:01:55 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/parser/parse_clause.h,v 1.40 2004/01/23 02:13:12 neilc Exp $
*
*-------------------------------------------------------------------------
*/
extern int setTargetTable(ParseState *pstate, RangeVar *relation,
bool inh, bool alsoSource, AclMode requiredPerms);
extern bool interpretInhOption(InhOption inhOpt);
+extern bool interpretOidsOption(ContainsOids opt);
extern Node *transformWhereClause(ParseState *pstate, Node *clause,
const char *constructName);