hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject [31/35] incubator-hawq git commit: SGA import. Now with files previously missing because of the .gitignore issue
Date Tue, 22 Sep 2015 19:14:34 GMT
http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/a485be47/src/backend/access/index/gperf.init
----------------------------------------------------------------------
diff --git a/src/backend/access/index/gperf.init b/src/backend/access/index/gperf.init
new file mode 100644
index 0000000..bc00f47
--- /dev/null
+++ b/src/backend/access/index/gperf.init
@@ -0,0 +1,4038 @@
+%{
+/* 
+   WARNING: DO NOT MODIFY THIS FILE: 
+   Generated by /Users/yjin/hawq_main/src/include/catalog/calico.pl version 55
+   on Mon Aug 24 22:07:54 2015
+
+ARGV: \-meta\ \/Users\/yjin\/hawq_main\/gpMgmt\/bin\/gppylib\/data\/2\.0\.json\ \-uniqdef\ uniqdef\.json\ \-basedef\ basedef\.json\ \-gperf\ gperf\.init\ \-infiles\ caql\.files
+
+*/
+
+/*-------------------------------------------------------------------------
+ *
+ * catquery.c
+ *	  general catalog table access methods (internal api)
+ *
+ * Copyright (c) 2011,2012,2013 Greenplum inc
+ *
+ *
+ *
+ *-------------------------------------------------------------------------
+ */
+#include "postgres.h"
+
+#include <math.h>
+#include <fcntl.h>
+#include <locale.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "access/genam.h"
+#include "access/heapam.h"
+#include "access/relscan.h"
+#include "access/transam.h"
+
+#include "catalog/caqlparse.h"
+#include "catalog/catalog.h"
+#include "catalog/catquery.h"
+#include "catalog/indexing.h"
+#include "catalog/pg_aggregate.h"
+#include "catalog/pg_amop.h"
+#include "catalog/pg_amproc.h"
+#include "catalog/pg_appendonly_alter_column.h"
+#include "catalog/pg_attrdef.h"
+#include "catalog/pg_auth_members.h"
+#include "catalog/pg_authid.h"
+#include "catalog/pg_autovacuum.h"
+#include "catalog/pg_cast.h"
+#include "catalog/pg_class.h"
+#include "catalog/pg_constraint.h"
+#include "catalog/pg_conversion.h"
+#include "catalog/pg_database.h"
+#include "catalog/pg_depend.h"
+#include "catalog/pg_description.h"
+#include "catalog/pg_extprotocol.h"
+#include "catalog/pg_exttable.h"
+#include "catalog/pg_filespace.h"
+#include "catalog/pg_filespace_entry.h"
+#include "catalog/pg_inherits.h"
+#include "catalog/pg_language.h"
+#include "catalog/pg_largeobject.h"
+#include "catalog/pg_listener.h"
+#include "catalog/pg_namespace.h"
+#include "catalog/pg_opclass.h"
+#include "catalog/pg_operator.h"
+#include "catalog/pg_partition.h"
+#include "catalog/pg_partition_rule.h"
+#include "catalog/pg_pltemplate.h"
+#include "catalog/pg_proc.h"
+#include "catalog/pg_resqueue.h"
+#include "catalog/pg_rewrite.h"
+#include "catalog/pg_shdepend.h"
+#include "catalog/pg_shdescription.h"
+#include "catalog/pg_statistic.h"
+#include "catalog/pg_tablespace.h"
+#include "catalog/pg_trigger.h"
+#include "catalog/pg_user_mapping.h"
+#include "catalog/pg_window.h"
+#include "catalog/pg_tidycat.h"
+
+#include "catalog/gp_configuration.h"
+#include "catalog/gp_configuration.h"
+#include "catalog/gp_segment_config.h"
+#include "catalog/gp_san_config.h"
+
+#include "catalog/gp_fastsequence.h"
+
+#include "catalog/gp_master_mirroring.h"
+#include "catalog/gp_persistent.h"
+#include "catalog/gp_global_sequence.h"
+#include "catalog/gp_id.h"
+#include "catalog/gp_version.h"
+#include "catalog/toasting.h"
+#include "catalog/gp_policy.h"
+
+#include "miscadmin.h"
+#include "storage/fd.h"
+#include "utils/fmgroids.h"
+#include "utils/relcache.h"
+#include "utils/lsyscache.h"
+#include "utils/syscache.h"
+
+#include "utils/acl.h"
+#include "utils/builtins.h"
+#include "utils/inval.h"
+
+#include "cdb/cdbpersistenttablespace.h"
+#include "cdb/cdbvars.h"
+
+
+
+
+
+/* ----------------------------------------------------------------
+ * cq_lookup()
+ * cq_lookup() defines a hash cookie for every cql() declaration.  The
+ * cookie associates the caql string with a "base query" function
+ * [caql_basic_fn_#()] that constructs the scan for the query.
+ * caql_switch() dispatches on the cookie to the base query function.
+ * ----------------------------------------------------------------
+*/
+
+#ifdef NOT_USED
+
+%}
+struct caql_hash_cookie
+{
+	const char *name;       /* caql string */
+	int uniqquery_code;     /* corresponding unique query */
+	int basequery_code;     /* corresponding base query */
+	int bDelete;            /* query performs DELETE */
+	int bCount;             /* SELECT COUNT(*) (or DELETE) */
+	int bUpdate;            /* SELECT ... FOR UPDATE */
+	int bInsert;            /* INSERT INTO  */
+	AttrNumber attnum;      /* column number (or 0 if no column specified) */
+};
+%%
+"SELECT 1", 1, 1, 0, 0, 0, 0, foo
+%%
+#endif /* NOT_USED */
+
+
+/* NOTE: caql_iud_switch locking removed */
+#define caql_iud_switch(pctx, isiud, oldtup, newtup, dontWait) 
+
+
+
+bool
+is_builtin_object(cqContext *pCtx, HeapTuple tuple)
+{
+	Oid result = InvalidOid;
+
+	if (!HeapTupleIsValid(tuple))
+		return true;
+
+	if (tuple->t_data->t_infomask & HEAP_HASOID)
+		result = HeapTupleGetOid(tuple);
+	else
+	{
+		switch(pCtx->cq_relationId)
+		{
+			case GpPolicyRelationId:
+				result = (Oid) ((FormData_gp_policy *) GETSTRUCT(tuple))->localoid;
+				break;
+			case FastSequenceRelationId:
+				result = (Oid) ((Form_gp_fastsequence) GETSTRUCT(tuple))->objid;
+				break;
+			case AggregateRelationId:
+				result = (Oid) ((Form_pg_aggregate) GETSTRUCT(tuple))->aggfnoid;
+				break;
+			case AccessMethodOperatorRelationId:
+				result = (Oid) ((Form_pg_amop) GETSTRUCT(tuple))->amopclaid;
+				break;
+			case AccessMethodProcedureRelationId:
+				result = (Oid) ((Form_pg_amproc) GETSTRUCT(tuple))->amopclaid;
+				break;
+			case AppendOnlyRelationId:
+				result = (Oid) ((Form_pg_appendonly) GETSTRUCT(tuple))->relid;
+				break;
+			case AttrDefaultRelationId:
+				result = (Oid) ((Form_pg_attrdef) GETSTRUCT(tuple))->adrelid;
+				break;
+			case AttributeRelationId:
+				result = (Oid) ((Form_pg_attribute) GETSTRUCT(tuple))->attrelid;
+				break;
+			case AttributeEncodingRelationId:
+				result = (Oid) ((Form_pg_attribute_encoding) GETSTRUCT(tuple))->attrelid;
+				break;
+			case AuthMemRelationId:
+				result = (Oid) ((Form_pg_auth_members) GETSTRUCT(tuple))->roleid;
+				break;
+			case AuthTimeConstraintRelationId:
+				result = (Oid) ((Form_pg_auth_time_constraint) GETSTRUCT(tuple))->authid;
+				break;
+			case DependRelationId:
+				result = (Oid) ((Form_pg_depend) GETSTRUCT(tuple))->objid;
+				break;
+			case DescriptionRelationId:
+				result = (Oid) ((Form_pg_description) GETSTRUCT(tuple))->objoid;
+				break;
+			case ExtTableRelationId:
+				result = (Oid) ((Form_pg_exttable) GETSTRUCT(tuple))->reloid;
+				break;
+			case FileSpaceEntryRelationId:
+				result = (Oid) ((Form_pg_filespace_entry) GETSTRUCT(tuple))->fsefsoid;
+				break;
+			case IndexRelationId:
+				result = (Oid) ((Form_pg_index) GETSTRUCT(tuple))->indexrelid;
+				break;
+			case InheritsRelationId:
+				result = (Oid) ((Form_pg_inherits) GETSTRUCT(tuple))->inhrelid;
+				break;
+			case PartitionEncodingRelationId:
+				result = (Oid) ((Form_pg_partition_encoding) GETSTRUCT(tuple))->parencoid;
+				break;
+			case PLTemplateRelationId:
+				{
+					char *name_str = pstrdup(NameStr(((Form_pg_pltemplate) GETSTRUCT(tuple))->tmplname));
+					if ((strcmp(name_str, "plpgsql") != 0) ||
+						(strcmp(name_str, "c") != 0) ||
+						(strcmp(name_str, "sql") != 0) ||
+						(strcmp(name_str, "internal") != 0))
+						result = InvalidOid;
+					break;
+				}
+			case TriggerRelationId:
+				result = (Oid) ((Form_pg_trigger) GETSTRUCT(tuple))->tgrelid;
+				break;
+			case RewriteRelationId:
+				result = (Oid) ((Form_pg_rewrite) GETSTRUCT(tuple))->ev_class;
+				break;
+			case ProcCallbackRelationId:
+				result = (Oid) ((Form_pg_proc_callback) GETSTRUCT(tuple))->profnoid;
+				break;
+			case SharedDependRelationId:
+				result = (Oid) ((Form_pg_shdepend) GETSTRUCT(tuple))->objid;
+				break;
+			case SharedDescriptionRelationId:
+				result = (Oid) ((Form_pg_shdescription) GETSTRUCT(tuple))->objoid;
+				break;
+			case StatLastOpRelationId:
+				result = (Oid) ((Form_pg_statlastop) GETSTRUCT(tuple))->objid;
+				break;
+			case StatLastShOpRelationId:
+				result = (Oid) ((Form_pg_statlastshop) GETSTRUCT(tuple))->objid;
+				break;
+			case StatisticRelationId:
+				result = (Oid) ((Form_pg_statistic) GETSTRUCT(tuple))->starelid;
+				break;
+			case TypeEncodingRelationId:
+				result = (Oid) ((Form_pg_type_encoding) GETSTRUCT(tuple))->typid;
+				break;
+			case WindowRelationId:
+				result = (Oid) ((Form_pg_window) GETSTRUCT(tuple))->winfnoid;
+				break;
+
+			default:
+				return false;
+		}
+	}
+	if (result > FirstNormalObjectId)
+		return false;
+
+	return true;
+}
+
+
+
+
+
+/* XXX XXX: temp fix for gp_distro reference in getoid_plus */
+typedef FormData_gp_policy *Form_gp_distribution_policy;
+
+/* ----------------------------------------------------------------
+ * caql_getoid_plus()
+ * Return an oid column from the first tuple and end the scan.
+ * Note: this works for regproc columns as well, but you should cast
+ * the output as RegProcedure.
+ * ----------------------------------------------------------------
+ */
+Oid caql_getoid_plus(cqContext *pCtx0, int *pFetchcount,
+					 bool *pbIsNull, cq_list *pcql)
+{
+	const char*				 caql_str = pcql->caqlStr;
+	const char*				 filenam  = pcql->filename;
+	int						 lineno	  = pcql->lineno;
+	struct caql_hash_cookie	*pchn	  = cq_lookup(caql_str, strlen(caql_str), pcql);
+	cqContext				*pCtx;
+	cqContext				 cqc;
+	HeapTuple				 tuple;
+	Relation				 rel;
+	Oid						 result	  = InvalidOid;
+
+	if (NULL == pchn)
+		elog(ERROR, "invalid caql string: %s\nfile: %s, line %d", 
+			 caql_str, filenam, lineno);
+
+	Assert(!pchn->bInsert); /* INSERT not allowed */
+
+	/* use the provided context, or provide a clean local ctx  */
+	if (pCtx0)
+		pCtx = pCtx0;
+	else
+		pCtx = cqclr(&cqc);
+
+	pCtx = caql_switch(pchn, pCtx, pcql);
+	/* NOTE: caql_switch frees the pcql */
+	rel  = pCtx->cq_heap_rel;
+
+	if (pFetchcount) *pFetchcount = 0;
+	if (pbIsNull) *pbIsNull = true;
+
+	/* use the SysCache */
+	if (pCtx->cq_usesyscache)
+	{
+		tuple = SearchSysCacheKeyArray(pCtx->cq_cacheId, 
+									   pCtx->cq_NumKeys, 
+									   pCtx->cq_cacheKeys);
+	}
+	else
+	{
+		tuple = systable_getnext(pCtx->cq_sysScan);
+	}
+
+	disable_catalog_check(pCtx, tuple);
+	if (HeapTupleIsValid(tuple))
+	{
+		if (pFetchcount) *pFetchcount = 1;
+		
+		/* if attnum not set, (InvalidAttrNumber == 0)
+		 * use tuple oid, else extract oid from column 
+		 * (includes ObjectIdAttributeNumber == -2) 
+		 */
+		if (pchn->attnum <= InvalidAttrNumber) 
+		{
+			if (pbIsNull) *pbIsNull = false;
+			result = HeapTupleGetOid(tuple);
+		}
+		else /* find oid column */
+		{
+			
+			switch(pCtx->cq_relationId)
+			{
+				
+				case GpPolicyRelationId: /* gp_distribution_policy */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* localoid */
+							result = (Oid) 
+								((Form_gp_distribution_policy) 
+								 GETSTRUCT(tuple))->localoid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end gp_distribution_policy */
+					break;
+				
+				case FastSequenceRelationId: /* gp_fastsequence */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* objid */
+							result = (Oid) 
+								((Form_gp_fastsequence) 
+								 GETSTRUCT(tuple))->objid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end gp_fastsequence */
+					break;
+				
+				case AggregateRelationId: /* pg_aggregate */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* aggfnoid */
+							result = (Oid) 
+								((Form_pg_aggregate) 
+								 GETSTRUCT(tuple))->aggfnoid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 2: /* aggtransfn */
+							result = (Oid) 
+								((Form_pg_aggregate) 
+								 GETSTRUCT(tuple))->aggtransfn;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 3: /* agginvtransfn */
+							result = (Oid) 
+								((Form_pg_aggregate) 
+								 GETSTRUCT(tuple))->agginvtransfn;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 4: /* aggprelimfn */
+							result = (Oid) 
+								((Form_pg_aggregate) 
+								 GETSTRUCT(tuple))->aggprelimfn;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 5: /* agginvprelimfn */
+							result = (Oid) 
+								((Form_pg_aggregate) 
+								 GETSTRUCT(tuple))->agginvprelimfn;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 6: /* aggfinalfn */
+							result = (Oid) 
+								((Form_pg_aggregate) 
+								 GETSTRUCT(tuple))->aggfinalfn;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 7: /* aggsortop */
+							result = (Oid) 
+								((Form_pg_aggregate) 
+								 GETSTRUCT(tuple))->aggsortop;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 8: /* aggtranstype */
+							result = (Oid) 
+								((Form_pg_aggregate) 
+								 GETSTRUCT(tuple))->aggtranstype;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_aggregate */
+					break;
+				
+				case AccessMethodRelationId: /* pg_am */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 12: /* aminsert */
+							result = (Oid) 
+								((Form_pg_am) 
+								 GETSTRUCT(tuple))->aminsert;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 13: /* ambeginscan */
+							result = (Oid) 
+								((Form_pg_am) 
+								 GETSTRUCT(tuple))->ambeginscan;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 14: /* amgettuple */
+							result = (Oid) 
+								((Form_pg_am) 
+								 GETSTRUCT(tuple))->amgettuple;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 15: /* amgetmulti */
+							result = (Oid) 
+								((Form_pg_am) 
+								 GETSTRUCT(tuple))->amgetmulti;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 16: /* amrescan */
+							result = (Oid) 
+								((Form_pg_am) 
+								 GETSTRUCT(tuple))->amrescan;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 17: /* amendscan */
+							result = (Oid) 
+								((Form_pg_am) 
+								 GETSTRUCT(tuple))->amendscan;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 18: /* ammarkpos */
+							result = (Oid) 
+								((Form_pg_am) 
+								 GETSTRUCT(tuple))->ammarkpos;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 19: /* amrestrpos */
+							result = (Oid) 
+								((Form_pg_am) 
+								 GETSTRUCT(tuple))->amrestrpos;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 20: /* ambuild */
+							result = (Oid) 
+								((Form_pg_am) 
+								 GETSTRUCT(tuple))->ambuild;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 21: /* ambulkdelete */
+							result = (Oid) 
+								((Form_pg_am) 
+								 GETSTRUCT(tuple))->ambulkdelete;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 22: /* amvacuumcleanup */
+							result = (Oid) 
+								((Form_pg_am) 
+								 GETSTRUCT(tuple))->amvacuumcleanup;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 23: /* amcostestimate */
+							result = (Oid) 
+								((Form_pg_am) 
+								 GETSTRUCT(tuple))->amcostestimate;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 24: /* amoptions */
+							result = (Oid) 
+								((Form_pg_am) 
+								 GETSTRUCT(tuple))->amoptions;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_am */
+					break;
+				
+				case AccessMethodOperatorRelationId: /* pg_amop */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* amopclaid */
+							result = (Oid) 
+								((Form_pg_amop) 
+								 GETSTRUCT(tuple))->amopclaid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 2: /* amopsubtype */
+							result = (Oid) 
+								((Form_pg_amop) 
+								 GETSTRUCT(tuple))->amopsubtype;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 5: /* amopopr */
+							result = (Oid) 
+								((Form_pg_amop) 
+								 GETSTRUCT(tuple))->amopopr;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_amop */
+					break;
+				
+				case AccessMethodProcedureRelationId: /* pg_amproc */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* amopclaid */
+							result = (Oid) 
+								((Form_pg_amproc) 
+								 GETSTRUCT(tuple))->amopclaid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 2: /* amprocsubtype */
+							result = (Oid) 
+								((Form_pg_amproc) 
+								 GETSTRUCT(tuple))->amprocsubtype;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 4: /* amproc */
+							result = (Oid) 
+								((Form_pg_amproc) 
+								 GETSTRUCT(tuple))->amproc;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_amproc */
+					break;
+				
+				case AppendOnlyRelationId: /* pg_appendonly */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* relid */
+							result = (Oid) 
+								((Form_pg_appendonly) 
+								 GETSTRUCT(tuple))->relid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 10: /* segrelid */
+						{
+							bool		isnull;
+							Datum		d = 
+								caql_getattr_internal(pCtx, tuple, 10, &isnull);
+						
+							if (!isnull)
+								result = DatumGetObjectId(d);
+						
+							if (pbIsNull) *pbIsNull = isnull;
+						}
+							break;
+						
+						case 11: /* segidxid */
+						{
+							bool		isnull;
+							Datum		d = 
+								caql_getattr_internal(pCtx, tuple, 11, &isnull);
+						
+							if (!isnull)
+								result = DatumGetObjectId(d);
+						
+							if (pbIsNull) *pbIsNull = isnull;
+						}
+							break;
+						
+						case 12: /* blkdirrelid */
+						{
+							bool		isnull;
+							Datum		d = 
+								caql_getattr_internal(pCtx, tuple, 12, &isnull);
+						
+							if (!isnull)
+								result = DatumGetObjectId(d);
+						
+							if (pbIsNull) *pbIsNull = isnull;
+						}
+							break;
+						
+						case 13: /* blkdiridxid */
+						{
+							bool		isnull;
+							Datum		d = 
+								caql_getattr_internal(pCtx, tuple, 13, &isnull);
+						
+							if (!isnull)
+								result = DatumGetObjectId(d);
+						
+							if (pbIsNull) *pbIsNull = isnull;
+						}
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_appendonly */
+					break;
+				
+				case AttrDefaultRelationId: /* pg_attrdef */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* adrelid */
+							result = (Oid) 
+								((Form_pg_attrdef) 
+								 GETSTRUCT(tuple))->adrelid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_attrdef */
+					break;
+				
+				case AttributeRelationId: /* pg_attribute */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* attrelid */
+							result = (Oid) 
+								((Form_pg_attribute) 
+								 GETSTRUCT(tuple))->attrelid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 3: /* atttypid */
+							result = (Oid) 
+								((Form_pg_attribute) 
+								 GETSTRUCT(tuple))->atttypid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_attribute */
+					break;
+				
+				case AttributeEncodingRelationId: /* pg_attribute_encoding */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* attrelid */
+							result = (Oid) 
+								((Form_pg_attribute_encoding) 
+								 GETSTRUCT(tuple))->attrelid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_attribute_encoding */
+					break;
+				
+				case AuthMemRelationId: /* pg_auth_members */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* roleid */
+							result = (Oid) 
+								((Form_pg_auth_members) 
+								 GETSTRUCT(tuple))->roleid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 2: /* member */
+							result = (Oid) 
+								((Form_pg_auth_members) 
+								 GETSTRUCT(tuple))->member;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 3: /* grantor */
+							result = (Oid) 
+								((Form_pg_auth_members) 
+								 GETSTRUCT(tuple))->grantor;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_auth_members */
+					break;
+				
+				case AuthTimeConstraintRelationId: /* pg_auth_time_constraint */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* authid */
+							result = (Oid) 
+								((Form_pg_auth_time_constraint) 
+								 GETSTRUCT(tuple))->authid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_auth_time_constraint */
+					break;
+				
+				case AuthIdRelationId: /* pg_authid */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 12: /* rolresqueue */
+						{
+							bool		isnull;
+							Datum		d = 
+								caql_getattr_internal(pCtx, tuple, 12, &isnull);
+						
+							if (!isnull)
+								result = DatumGetObjectId(d);
+						
+							if (pbIsNull) *pbIsNull = isnull;
+						}
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_authid */
+					break;
+				
+				case CastRelationId: /* pg_cast */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* castsource */
+							result = (Oid) 
+								((Form_pg_cast) 
+								 GETSTRUCT(tuple))->castsource;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 2: /* casttarget */
+							result = (Oid) 
+								((Form_pg_cast) 
+								 GETSTRUCT(tuple))->casttarget;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 3: /* castfunc */
+							result = (Oid) 
+								((Form_pg_cast) 
+								 GETSTRUCT(tuple))->castfunc;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_cast */
+					break;
+				
+				case RelationRelationId: /* pg_class */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 2: /* relnamespace */
+							result = (Oid) 
+								((Form_pg_class) 
+								 GETSTRUCT(tuple))->relnamespace;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 3: /* reltype */
+							result = (Oid) 
+								((Form_pg_class) 
+								 GETSTRUCT(tuple))->reltype;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 4: /* relowner */
+							result = (Oid) 
+								((Form_pg_class) 
+								 GETSTRUCT(tuple))->relowner;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 5: /* relam */
+							result = (Oid) 
+								((Form_pg_class) 
+								 GETSTRUCT(tuple))->relam;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 6: /* relfilenode */
+							result = (Oid) 
+								((Form_pg_class) 
+								 GETSTRUCT(tuple))->relfilenode;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 7: /* reltablespace */
+							result = (Oid) 
+								((Form_pg_class) 
+								 GETSTRUCT(tuple))->reltablespace;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 10: /* reltoastrelid */
+							result = (Oid) 
+								((Form_pg_class) 
+								 GETSTRUCT(tuple))->reltoastrelid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 11: /* reltoastidxid */
+							result = (Oid) 
+								((Form_pg_class) 
+								 GETSTRUCT(tuple))->reltoastidxid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 12: /* relaosegrelid */
+							result = (Oid) 
+								((Form_pg_class) 
+								 GETSTRUCT(tuple))->relaosegrelid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 13: /* relaosegidxid */
+							result = (Oid) 
+								((Form_pg_class) 
+								 GETSTRUCT(tuple))->relaosegidxid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_class */
+					break;
+				
+				case CompressionRelationId: /* pg_compression */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 2: /* compconstructor */
+							result = (Oid) 
+								((Form_pg_compression) 
+								 GETSTRUCT(tuple))->compconstructor;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 3: /* compdestructor */
+							result = (Oid) 
+								((Form_pg_compression) 
+								 GETSTRUCT(tuple))->compdestructor;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 4: /* compcompressor */
+							result = (Oid) 
+								((Form_pg_compression) 
+								 GETSTRUCT(tuple))->compcompressor;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 5: /* compdecompressor */
+							result = (Oid) 
+								((Form_pg_compression) 
+								 GETSTRUCT(tuple))->compdecompressor;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 6: /* compvalidator */
+							result = (Oid) 
+								((Form_pg_compression) 
+								 GETSTRUCT(tuple))->compvalidator;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 7: /* compowner */
+							result = (Oid) 
+								((Form_pg_compression) 
+								 GETSTRUCT(tuple))->compowner;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_compression */
+					break;
+				
+				case ConstraintRelationId: /* pg_constraint */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 2: /* connamespace */
+							result = (Oid) 
+								((Form_pg_constraint) 
+								 GETSTRUCT(tuple))->connamespace;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 6: /* conrelid */
+							result = (Oid) 
+								((Form_pg_constraint) 
+								 GETSTRUCT(tuple))->conrelid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 7: /* contypid */
+							result = (Oid) 
+								((Form_pg_constraint) 
+								 GETSTRUCT(tuple))->contypid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 8: /* confrelid */
+							result = (Oid) 
+								((Form_pg_constraint) 
+								 GETSTRUCT(tuple))->confrelid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_constraint */
+					break;
+				
+				case ConversionRelationId: /* pg_conversion */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 2: /* connamespace */
+							result = (Oid) 
+								((Form_pg_conversion) 
+								 GETSTRUCT(tuple))->connamespace;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 3: /* conowner */
+							result = (Oid) 
+								((Form_pg_conversion) 
+								 GETSTRUCT(tuple))->conowner;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 6: /* conproc */
+							result = (Oid) 
+								((Form_pg_conversion) 
+								 GETSTRUCT(tuple))->conproc;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_conversion */
+					break;
+				
+				case DatabaseRelationId: /* pg_database */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 2: /* datdba */
+							result = (Oid) 
+								((Form_pg_database) 
+								 GETSTRUCT(tuple))->datdba;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 7: /* datlastsysoid */
+							result = (Oid) 
+								((Form_pg_database) 
+								 GETSTRUCT(tuple))->datlastsysoid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 9: /* dattablespace */
+							result = (Oid) 
+								((Form_pg_database) 
+								 GETSTRUCT(tuple))->dattablespace;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 10: /* dat2tablespace */
+							result = (Oid) 
+								((Form_pg_database) 
+								 GETSTRUCT(tuple))->dat2tablespace;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_database */
+					break;
+				
+				case DependRelationId: /* pg_depend */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* classid */
+							result = (Oid) 
+								((Form_pg_depend) 
+								 GETSTRUCT(tuple))->classid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 2: /* objid */
+							result = (Oid) 
+								((Form_pg_depend) 
+								 GETSTRUCT(tuple))->objid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 4: /* refclassid */
+							result = (Oid) 
+								((Form_pg_depend) 
+								 GETSTRUCT(tuple))->refclassid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 5: /* refobjid */
+							result = (Oid) 
+								((Form_pg_depend) 
+								 GETSTRUCT(tuple))->refobjid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_depend */
+					break;
+				
+				case DescriptionRelationId: /* pg_description */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* objoid */
+							result = (Oid) 
+								((Form_pg_description) 
+								 GETSTRUCT(tuple))->objoid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 2: /* classoid */
+							result = (Oid) 
+								((Form_pg_description) 
+								 GETSTRUCT(tuple))->classoid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_description */
+					break;
+				
+				case ExtprotocolRelationId: /* pg_extprotocol */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 2: /* ptcreadfn */
+						{
+							bool		isnull;
+							Datum		d = 
+								caql_getattr_internal(pCtx, tuple, 2, &isnull);
+						
+							if (!isnull)
+								result = DatumGetObjectId(d);
+						
+							if (pbIsNull) *pbIsNull = isnull;
+						}
+							break;
+						
+						case 3: /* ptcwritefn */
+						{
+							bool		isnull;
+							Datum		d = 
+								caql_getattr_internal(pCtx, tuple, 3, &isnull);
+						
+							if (!isnull)
+								result = DatumGetObjectId(d);
+						
+							if (pbIsNull) *pbIsNull = isnull;
+						}
+							break;
+						
+						case 4: /* ptcvalidatorfn */
+						{
+							bool		isnull;
+							Datum		d = 
+								caql_getattr_internal(pCtx, tuple, 4, &isnull);
+						
+							if (!isnull)
+								result = DatumGetObjectId(d);
+						
+							if (pbIsNull) *pbIsNull = isnull;
+						}
+							break;
+						
+						case 5: /* ptcowner */
+						{
+							bool		isnull;
+							Datum		d = 
+								caql_getattr_internal(pCtx, tuple, 5, &isnull);
+						
+							if (!isnull)
+								result = DatumGetObjectId(d);
+						
+							if (pbIsNull) *pbIsNull = isnull;
+						}
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_extprotocol */
+					break;
+				
+				case ExtTableRelationId: /* pg_exttable */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* reloid */
+							result = (Oid) 
+								((Form_pg_exttable) 
+								 GETSTRUCT(tuple))->reloid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 8: /* fmterrtbl */
+						{
+							bool		isnull;
+							Datum		d = 
+								caql_getattr_internal(pCtx, tuple, 8, &isnull);
+						
+							if (!isnull)
+								result = DatumGetObjectId(d);
+						
+							if (pbIsNull) *pbIsNull = isnull;
+						}
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_exttable */
+					break;
+				
+				case FileSpaceRelationId: /* pg_filespace */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 2: /* fsowner */
+							result = (Oid) 
+								((Form_pg_filespace) 
+								 GETSTRUCT(tuple))->fsowner;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 3: /* fsfsys */
+							result = (Oid) 
+								((Form_pg_filespace) 
+								 GETSTRUCT(tuple))->fsfsys;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_filespace */
+					break;
+				
+				case FileSpaceEntryRelationId: /* pg_filespace_entry */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* fsefsoid */
+							result = (Oid) 
+								((Form_pg_filespace_entry) 
+								 GETSTRUCT(tuple))->fsefsoid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_filespace_entry */
+					break;
+				
+				case ForeignDataWrapperRelationId: /* pg_foreign_data_wrapper */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 2: /* fdwowner */
+							result = (Oid) 
+								((Form_pg_foreign_data_wrapper) 
+								 GETSTRUCT(tuple))->fdwowner;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 3: /* fdwvalidator */
+							result = (Oid) 
+								((Form_pg_foreign_data_wrapper) 
+								 GETSTRUCT(tuple))->fdwvalidator;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_foreign_data_wrapper */
+					break;
+				
+				case ForeignServerRelationId: /* pg_foreign_server */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 2: /* srvowner */
+							result = (Oid) 
+								((Form_pg_foreign_server) 
+								 GETSTRUCT(tuple))->srvowner;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 3: /* srvfdw */
+							result = (Oid) 
+								((Form_pg_foreign_server) 
+								 GETSTRUCT(tuple))->srvfdw;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_foreign_server */
+					break;
+				
+				case ForeignTableRelationId: /* pg_foreign_table */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* reloid */
+							result = (Oid) 
+								((Form_pg_foreign_table) 
+								 GETSTRUCT(tuple))->reloid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 2: /* server */
+							result = (Oid) 
+								((Form_pg_foreign_table) 
+								 GETSTRUCT(tuple))->server;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_foreign_table */
+					break;
+				
+				case IndexRelationId: /* pg_index */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* indexrelid */
+							result = (Oid) 
+								((Form_pg_index) 
+								 GETSTRUCT(tuple))->indexrelid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 2: /* indrelid */
+							result = (Oid) 
+								((Form_pg_index) 
+								 GETSTRUCT(tuple))->indrelid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_index */
+					break;
+				
+				case InheritsRelationId: /* pg_inherits */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* inhrelid */
+							result = (Oid) 
+								((Form_pg_inherits) 
+								 GETSTRUCT(tuple))->inhrelid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 2: /* inhparent */
+							result = (Oid) 
+								((Form_pg_inherits) 
+								 GETSTRUCT(tuple))->inhparent;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_inherits */
+					break;
+				
+				case LanguageRelationId: /* pg_language */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 4: /* lanplcallfoid */
+							result = (Oid) 
+								((Form_pg_language) 
+								 GETSTRUCT(tuple))->lanplcallfoid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 5: /* lanvalidator */
+							result = (Oid) 
+								((Form_pg_language) 
+								 GETSTRUCT(tuple))->lanvalidator;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_language */
+					break;
+				
+				case LargeObjectRelationId: /* pg_largeobject */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* loid */
+							result = (Oid) 
+								((Form_pg_largeobject) 
+								 GETSTRUCT(tuple))->loid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_largeobject */
+					break;
+				
+				case NamespaceRelationId: /* pg_namespace */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 2: /* nspowner */
+							result = (Oid) 
+								((Form_pg_namespace) 
+								 GETSTRUCT(tuple))->nspowner;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 4: /* nspdboid */
+						{
+							bool		isnull;
+							Datum		d = 
+								caql_getattr_internal(pCtx, tuple, 4, &isnull);
+						
+							if (!isnull)
+								result = DatumGetObjectId(d);
+						
+							if (pbIsNull) *pbIsNull = isnull;
+						}
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_namespace */
+					break;
+				
+				case OperatorClassRelationId: /* pg_opclass */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* opcamid */
+							result = (Oid) 
+								((Form_pg_opclass) 
+								 GETSTRUCT(tuple))->opcamid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 3: /* opcnamespace */
+							result = (Oid) 
+								((Form_pg_opclass) 
+								 GETSTRUCT(tuple))->opcnamespace;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 4: /* opcowner */
+							result = (Oid) 
+								((Form_pg_opclass) 
+								 GETSTRUCT(tuple))->opcowner;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 5: /* opcintype */
+							result = (Oid) 
+								((Form_pg_opclass) 
+								 GETSTRUCT(tuple))->opcintype;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 7: /* opckeytype */
+							result = (Oid) 
+								((Form_pg_opclass) 
+								 GETSTRUCT(tuple))->opckeytype;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_opclass */
+					break;
+				
+				case OperatorRelationId: /* pg_operator */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 2: /* oprnamespace */
+							result = (Oid) 
+								((Form_pg_operator) 
+								 GETSTRUCT(tuple))->oprnamespace;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 3: /* oprowner */
+							result = (Oid) 
+								((Form_pg_operator) 
+								 GETSTRUCT(tuple))->oprowner;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 6: /* oprleft */
+							result = (Oid) 
+								((Form_pg_operator) 
+								 GETSTRUCT(tuple))->oprleft;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 7: /* oprright */
+							result = (Oid) 
+								((Form_pg_operator) 
+								 GETSTRUCT(tuple))->oprright;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 8: /* oprresult */
+							result = (Oid) 
+								((Form_pg_operator) 
+								 GETSTRUCT(tuple))->oprresult;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 9: /* oprcom */
+							result = (Oid) 
+								((Form_pg_operator) 
+								 GETSTRUCT(tuple))->oprcom;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 10: /* oprnegate */
+							result = (Oid) 
+								((Form_pg_operator) 
+								 GETSTRUCT(tuple))->oprnegate;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 11: /* oprlsortop */
+							result = (Oid) 
+								((Form_pg_operator) 
+								 GETSTRUCT(tuple))->oprlsortop;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 12: /* oprrsortop */
+							result = (Oid) 
+								((Form_pg_operator) 
+								 GETSTRUCT(tuple))->oprrsortop;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 13: /* oprltcmpop */
+							result = (Oid) 
+								((Form_pg_operator) 
+								 GETSTRUCT(tuple))->oprltcmpop;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 14: /* oprgtcmpop */
+							result = (Oid) 
+								((Form_pg_operator) 
+								 GETSTRUCT(tuple))->oprgtcmpop;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 15: /* oprcode */
+							result = (Oid) 
+								((Form_pg_operator) 
+								 GETSTRUCT(tuple))->oprcode;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 16: /* oprrest */
+							result = (Oid) 
+								((Form_pg_operator) 
+								 GETSTRUCT(tuple))->oprrest;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 17: /* oprjoin */
+							result = (Oid) 
+								((Form_pg_operator) 
+								 GETSTRUCT(tuple))->oprjoin;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_operator */
+					break;
+				
+				case PartitionRelationId: /* pg_partition */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* parrelid */
+							result = (Oid) 
+								((Form_pg_partition) 
+								 GETSTRUCT(tuple))->parrelid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_partition */
+					break;
+				
+				case PartitionEncodingRelationId: /* pg_partition_encoding */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* parencoid */
+							result = (Oid) 
+								((Form_pg_partition_encoding) 
+								 GETSTRUCT(tuple))->parencoid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_partition_encoding */
+					break;
+				
+				case PartitionRuleRelationId: /* pg_partition_rule */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* paroid */
+							result = (Oid) 
+								((Form_pg_partition_rule) 
+								 GETSTRUCT(tuple))->paroid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 2: /* parchildrelid */
+							result = (Oid) 
+								((Form_pg_partition_rule) 
+								 GETSTRUCT(tuple))->parchildrelid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 3: /* parparentrule */
+							result = (Oid) 
+								((Form_pg_partition_rule) 
+								 GETSTRUCT(tuple))->parparentrule;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 14: /* partemplatespace */
+						{
+							bool		isnull;
+							Datum		d = 
+								caql_getattr_internal(pCtx, tuple, 14, &isnull);
+						
+							if (!isnull)
+								result = DatumGetObjectId(d);
+						
+							if (pbIsNull) *pbIsNull = isnull;
+						}
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_partition_rule */
+					break;
+				
+				case ProcedureRelationId: /* pg_proc */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 2: /* pronamespace */
+							result = (Oid) 
+								((Form_pg_proc) 
+								 GETSTRUCT(tuple))->pronamespace;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 3: /* proowner */
+							result = (Oid) 
+								((Form_pg_proc) 
+								 GETSTRUCT(tuple))->proowner;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 4: /* prolang */
+							result = (Oid) 
+								((Form_pg_proc) 
+								 GETSTRUCT(tuple))->prolang;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 11: /* prorettype */
+							result = (Oid) 
+								((Form_pg_proc) 
+								 GETSTRUCT(tuple))->prorettype;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_proc */
+					break;
+				
+				case ProcCallbackRelationId: /* pg_proc_callback */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* profnoid */
+							result = (Oid) 
+								((Form_pg_proc_callback) 
+								 GETSTRUCT(tuple))->profnoid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 2: /* procallback */
+							result = (Oid) 
+								((Form_pg_proc_callback) 
+								 GETSTRUCT(tuple))->procallback;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_proc_callback */
+					break;
+				
+				case ResQueueRelationId: /* pg_resqueue */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 2: /* rsq_parent */
+							result = (Oid) 
+								((Form_pg_resqueue) 
+								 GETSTRUCT(tuple))->rsq_parent;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_resqueue */
+					break;
+				
+				case ResQueueCapabilityRelationId: /* pg_resqueuecapability */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* resqueueid */
+							result = (Oid) 
+								((Form_pg_resqueuecapability) 
+								 GETSTRUCT(tuple))->resqueueid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_resqueuecapability */
+					break;
+				
+				case RewriteRelationId: /* pg_rewrite */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 2: /* ev_class */
+							result = (Oid) 
+								((Form_pg_rewrite) 
+								 GETSTRUCT(tuple))->ev_class;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_rewrite */
+					break;
+				
+				case SharedDependRelationId: /* pg_shdepend */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* dbid */
+							result = (Oid) 
+								((Form_pg_shdepend) 
+								 GETSTRUCT(tuple))->dbid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 2: /* classid */
+							result = (Oid) 
+								((Form_pg_shdepend) 
+								 GETSTRUCT(tuple))->classid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 3: /* objid */
+							result = (Oid) 
+								((Form_pg_shdepend) 
+								 GETSTRUCT(tuple))->objid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 4: /* refclassid */
+							result = (Oid) 
+								((Form_pg_shdepend) 
+								 GETSTRUCT(tuple))->refclassid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 5: /* refobjid */
+							result = (Oid) 
+								((Form_pg_shdepend) 
+								 GETSTRUCT(tuple))->refobjid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_shdepend */
+					break;
+				
+				case SharedDescriptionRelationId: /* pg_shdescription */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* objoid */
+							result = (Oid) 
+								((Form_pg_shdescription) 
+								 GETSTRUCT(tuple))->objoid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 2: /* classoid */
+							result = (Oid) 
+								((Form_pg_shdescription) 
+								 GETSTRUCT(tuple))->classoid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_shdescription */
+					break;
+				
+				case StatLastOpRelationId: /* pg_stat_last_operation */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* classid */
+							result = (Oid) 
+								((Form_pg_statlastop) 
+								 GETSTRUCT(tuple))->classid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 2: /* objid */
+							result = (Oid) 
+								((Form_pg_statlastop) 
+								 GETSTRUCT(tuple))->objid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 4: /* stasysid */
+							result = (Oid) 
+								((Form_pg_statlastop) 
+								 GETSTRUCT(tuple))->stasysid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_stat_last_operation */
+					break;
+				
+				case StatLastShOpRelationId: /* pg_stat_last_shoperation */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* classid */
+							result = (Oid) 
+								((Form_pg_statlastshop) 
+								 GETSTRUCT(tuple))->classid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 2: /* objid */
+							result = (Oid) 
+								((Form_pg_statlastshop) 
+								 GETSTRUCT(tuple))->objid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 4: /* stasysid */
+							result = (Oid) 
+								((Form_pg_statlastshop) 
+								 GETSTRUCT(tuple))->stasysid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_stat_last_shoperation */
+					break;
+				
+				case StatisticRelationId: /* pg_statistic */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* starelid */
+							result = (Oid) 
+								((Form_pg_statistic) 
+								 GETSTRUCT(tuple))->starelid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 10: /* staop1 */
+							result = (Oid) 
+								((Form_pg_statistic) 
+								 GETSTRUCT(tuple))->staop1;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 11: /* staop2 */
+							result = (Oid) 
+								((Form_pg_statistic) 
+								 GETSTRUCT(tuple))->staop2;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 12: /* staop3 */
+							result = (Oid) 
+								((Form_pg_statistic) 
+								 GETSTRUCT(tuple))->staop3;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 13: /* staop4 */
+							result = (Oid) 
+								((Form_pg_statistic) 
+								 GETSTRUCT(tuple))->staop4;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_statistic */
+					break;
+				
+				case TableSpaceRelationId: /* pg_tablespace */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 2: /* spcowner */
+							result = (Oid) 
+								((Form_pg_tablespace) 
+								 GETSTRUCT(tuple))->spcowner;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 7: /* spcfsoid */
+						{
+							bool		isnull;
+							Datum		d = 
+								caql_getattr_internal(pCtx, tuple, 7, &isnull);
+						
+							if (!isnull)
+								result = DatumGetObjectId(d);
+						
+							if (pbIsNull) *pbIsNull = isnull;
+						}
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_tablespace */
+					break;
+				
+				case TriggerRelationId: /* pg_trigger */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* tgrelid */
+							result = (Oid) 
+								((Form_pg_trigger) 
+								 GETSTRUCT(tuple))->tgrelid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 3: /* tgfoid */
+							result = (Oid) 
+								((Form_pg_trigger) 
+								 GETSTRUCT(tuple))->tgfoid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 8: /* tgconstrrelid */
+							result = (Oid) 
+								((Form_pg_trigger) 
+								 GETSTRUCT(tuple))->tgconstrrelid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_trigger */
+					break;
+				
+				case TypeRelationId: /* pg_type */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 2: /* typnamespace */
+							result = (Oid) 
+								((Form_pg_type) 
+								 GETSTRUCT(tuple))->typnamespace;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 3: /* typowner */
+							result = (Oid) 
+								((Form_pg_type) 
+								 GETSTRUCT(tuple))->typowner;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 9: /* typrelid */
+							result = (Oid) 
+								((Form_pg_type) 
+								 GETSTRUCT(tuple))->typrelid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 10: /* typelem */
+							result = (Oid) 
+								((Form_pg_type) 
+								 GETSTRUCT(tuple))->typelem;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 11: /* typinput */
+							result = (Oid) 
+								((Form_pg_type) 
+								 GETSTRUCT(tuple))->typinput;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 12: /* typoutput */
+							result = (Oid) 
+								((Form_pg_type) 
+								 GETSTRUCT(tuple))->typoutput;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 13: /* typreceive */
+							result = (Oid) 
+								((Form_pg_type) 
+								 GETSTRUCT(tuple))->typreceive;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 14: /* typsend */
+							result = (Oid) 
+								((Form_pg_type) 
+								 GETSTRUCT(tuple))->typsend;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 15: /* typanalyze */
+							result = (Oid) 
+								((Form_pg_type) 
+								 GETSTRUCT(tuple))->typanalyze;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 19: /* typbasetype */
+							result = (Oid) 
+								((Form_pg_type) 
+								 GETSTRUCT(tuple))->typbasetype;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_type */
+					break;
+				
+				case TypeEncodingRelationId: /* pg_type_encoding */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* typid */
+							result = (Oid) 
+								((Form_pg_type_encoding) 
+								 GETSTRUCT(tuple))->typid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_type_encoding */
+					break;
+				
+				case UserMappingRelationId: /* pg_user_mapping */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* umuser */
+							result = (Oid) 
+								((Form_pg_user_mapping) 
+								 GETSTRUCT(tuple))->umuser;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 2: /* umserver */
+							result = (Oid) 
+								((Form_pg_user_mapping) 
+								 GETSTRUCT(tuple))->umserver;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_user_mapping */
+					break;
+				
+				case WindowRelationId: /* pg_window */
+				{
+					switch(pchn->attnum)
+					{
+						
+						case 1: /* winfnoid */
+							result = (Oid) 
+								((Form_pg_window) 
+								 GETSTRUCT(tuple))->winfnoid;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 6: /* winfunc */
+							result = (Oid) 
+								((Form_pg_window) 
+								 GETSTRUCT(tuple))->winfunc;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 7: /* winprefunc */
+							result = (Oid) 
+								((Form_pg_window) 
+								 GETSTRUCT(tuple))->winprefunc;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 8: /* winpretype */
+							result = (Oid) 
+								((Form_pg_window) 
+								 GETSTRUCT(tuple))->winpretype;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+						
+						case 9: /* winfinfunc */
+							result = (Oid) 
+								((Form_pg_window) 
+								 GETSTRUCT(tuple))->winfinfunc;
+							if (pbIsNull) *pbIsNull = false;
+							break;
+				
+					  default:
+						elog(ERROR, "column not an oid: %s\nfile: %s, line %d", 
+							 caql_str, filenam, lineno);
+					}
+				} /* end pg_window */
+					break;
+			
+			  default:
+				elog(ERROR, "could not get column for relation: %s\nfile: %s, line %d", 
+					 caql_str, filenam, lineno);
+			}
+
+		}
+	} /* end HeapTupleIsValid */
+
+	if (pCtx->cq_usesyscache)
+	{  
+		if (HeapTupleIsValid(tuple))
+			ReleaseSysCache(tuple);
+	}
+	else
+	{	
+		if (pFetchcount && HeapTupleIsValid(tuple))
+		{				
+			if (HeapTupleIsValid(systable_getnext(pCtx->cq_sysScan)))
+			{
+				*pFetchcount = 2;	
+			}
+		}
+		systable_endscan(pCtx->cq_sysScan); 
+	}		
+	caql_heapclose(pCtx);
+
+	return (result);
+} /* end caql_getoid_plus */
+
+/* ----------------------------------------------------------------
+ * caql_getoid_only()
+ * Return the oid of the first tuple and end the scan
+ * If pbOnly is not NULL, return TRUE if a second tuple is not found,
+ * else return FALSE
+ * ----------------------------------------------------------------
+ */
+Oid caql_getoid_only(cqContext *pCtx0, bool *pbOnly, cq_list *pcql)
+{
+	const char*				 caql_str = pcql->caqlStr;
+	const char*				 filenam  = pcql->filename;
+	int						 lineno	  = pcql->lineno;
+	struct caql_hash_cookie	*pchn	  = cq_lookup(caql_str, strlen(caql_str), pcql);
+	cqContext				*pCtx;
+	cqContext				 cqc;
+	HeapTuple				 tuple;
+	Relation				 rel;
+	Oid						 result = InvalidOid;
+
+	if (NULL == pchn)
+		elog(ERROR, "invalid caql string: %s\nfile: %s, line %d", 
+			 caql_str, filenam, lineno);
+
+	Assert(!pchn->bInsert); /* INSERT not allowed */
+
+	/* use the provided context, or provide a clean local ctx  */
+	if (pCtx0)
+		pCtx = pCtx0;
+	else
+		pCtx = cqclr(&cqc);
+
+	pCtx = caql_switch(pchn, pCtx, pcql);
+	/* NOTE: caql_switch frees the pcql */
+	rel  = pCtx->cq_heap_rel;
+
+	if (pbOnly) *pbOnly = true;
+
+	/* use the SysCache */
+	if (pCtx->cq_usesyscache)
+	{
+		tuple = SearchSysCacheKeyArray(pCtx->cq_cacheId, 
+									   pCtx->cq_NumKeys, 
+									   pCtx->cq_cacheKeys);
+
+		disable_catalog_check(pCtx, tuple);
+
+		if (HeapTupleIsValid(tuple))
+		{
+			result = HeapTupleGetOid(tuple);
+			ReleaseSysCache(tuple);
+			/* only one */
+		}
+		caql_heapclose(pCtx);
+
+		return (result);
+	}
+
+	if (HeapTupleIsValid(tuple = systable_getnext(pCtx->cq_sysScan)))
+	{
+		disable_catalog_check(pCtx, tuple);
+
+		result = HeapTupleGetOid(tuple);
+
+		if (pbOnly)
+		{
+			*pbOnly = 
+				!(HeapTupleIsValid(tuple = 
+								   systable_getnext(pCtx->cq_sysScan)));
+		}
+	}
+	systable_endscan(pCtx->cq_sysScan); 
+	caql_heapclose(pCtx);
+	return (result);
+}
+
+/* ----------------------------------------------------------------
+ * caql_getcstring_plus()
+ * Return a cstring column from the first tuple and end the scan.
+ * ----------------------------------------------------------------
+ */
+char *caql_getcstring_plus(cqContext *pCtx0, int *pFetchcount,
+						   bool *pbIsNull, cq_list *pcql)
+{
+	const char*				 caql_str = pcql->caqlStr;
+	const char*				 filenam  = pcql->filename;
+	int						 lineno	  = pcql->lineno;
+	struct caql_hash_cookie	*pchn	  = cq_lookup(caql_str, strlen(caql_str), pcql);
+	cqContext				*pCtx;
+	cqContext				 cqc;
+	HeapTuple				 tuple;
+	Relation				 rel;
+	char					*result = NULL;
+
+	if (NULL == pchn)
+		elog(ERROR, "invalid caql string: %s\nfile: %s, line %d", 
+			 caql_str, filenam, lineno);
+
+	Assert(!pchn->bInsert); /* INSERT not allowed */
+
+	/* use the provided context, or provide a clean local ctx  */
+	if (pCtx0)
+		pCtx = pCtx0;
+	else
+		pCtx = cqclr(&cqc);
+
+	pCtx = caql_switch(pchn, pCtx, pcql);
+	/* NOTE: caql_switch frees the pcql */
+	rel  = pCtx->cq_heap_rel;
+
+	if (pFetchcount) *pFetchcount = 0;
+	if (pbIsNull) *pbIsNull = true;
+
+	/* use the SysCache */
+	if (pCtx->cq_usesyscache)
+	{
+		tuple = SearchSysCacheKeyArray(pCtx->cq_cacheId, 
+									   pCtx->cq_NumKeys, 
+									   pCtx->cq_cacheKeys);
+	}
+	else
+	{
+		tuple = systable_getnext(pCtx->cq_sysScan);
+	}
+
+	disable_catalog_check(pCtx, tuple);
+
+	if (HeapTupleIsValid(tuple))
+	{
+		if (pFetchcount) *pFetchcount = 1;
+		
+		switch(pCtx->cq_relationId)
+		{
+			
+			case GpSegmentConfigRelationId: /* gp_segment_configuration */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 5: /* hostname */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 5, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+					
+					case 6: /* address */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 6, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end gp_segment_configuration */
+				break;
+			
+			case AggregateRelationId: /* pg_aggregate */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 9: /* agginitval */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 9, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_aggregate */
+				break;
+			
+			case AccessMethodRelationId: /* pg_am */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 1: /* amname */
+						result = pstrdup(
+							NameStr(((Form_pg_am) 
+									 GETSTRUCT(tuple))->amname));
+						if (pbIsNull) *pbIsNull = false;
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_am */
+				break;
+			
+			case AppendOnlyRelationId: /* pg_appendonly */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 8: /* compresstype */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 8, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_appendonly */
+				break;
+			
+			case AttrDefaultRelationId: /* pg_attrdef */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 3: /* adbin */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 3, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+					
+					case 4: /* adsrc */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 4, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_attrdef */
+				break;
+			
+			case AttributeRelationId: /* pg_attribute */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 2: /* attname */
+						result = pstrdup(
+							NameStr(((Form_pg_attribute) 
+									 GETSTRUCT(tuple))->attname));
+						if (pbIsNull) *pbIsNull = false;
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_attribute */
+				break;
+			
+			case AttributeEncodingRelationId: /* pg_attribute_encoding */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 3: /* attoptions */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 3, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_attribute_encoding */
+				break;
+			
+			case AuthIdRelationId: /* pg_authid */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 1: /* rolname */
+						result = pstrdup(
+							NameStr(((Form_pg_authid) 
+									 GETSTRUCT(tuple))->rolname));
+						if (pbIsNull) *pbIsNull = false;
+						break;
+					
+					case 9: /* rolpassword */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 9, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+					
+					case 11: /* rolconfig */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 11, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_authid */
+				break;
+			
+			case RelationRelationId: /* pg_class */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 1: /* relname */
+						result = pstrdup(
+							NameStr(((Form_pg_class) 
+									 GETSTRUCT(tuple))->relname));
+						if (pbIsNull) *pbIsNull = false;
+						break;
+					
+					case 30: /* reloptions */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 30, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_class */
+				break;
+			
+			case CompressionRelationId: /* pg_compression */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 1: /* compname */
+						result = pstrdup(
+							NameStr(((Form_pg_compression) 
+									 GETSTRUCT(tuple))->compname));
+						if (pbIsNull) *pbIsNull = false;
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_compression */
+				break;
+			
+			case ConstraintRelationId: /* pg_constraint */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 1: /* conname */
+						result = pstrdup(
+							NameStr(((Form_pg_constraint) 
+									 GETSTRUCT(tuple))->conname));
+						if (pbIsNull) *pbIsNull = false;
+						break;
+					
+					case 14: /* conbin */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 14, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+					
+					case 15: /* consrc */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 15, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_constraint */
+				break;
+			
+			case ConversionRelationId: /* pg_conversion */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 1: /* conname */
+						result = pstrdup(
+							NameStr(((Form_pg_conversion) 
+									 GETSTRUCT(tuple))->conname));
+						if (pbIsNull) *pbIsNull = false;
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_conversion */
+				break;
+			
+			case DatabaseRelationId: /* pg_database */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 1: /* datname */
+						result = pstrdup(
+							NameStr(((Form_pg_database) 
+									 GETSTRUCT(tuple))->datname));
+						if (pbIsNull) *pbIsNull = false;
+						break;
+					
+					case 11: /* datconfig */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 11, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_database */
+				break;
+			
+			case DescriptionRelationId: /* pg_description */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 4: /* description */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 4, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_description */
+				break;
+			
+			case ExtprotocolRelationId: /* pg_extprotocol */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 1: /* ptcname */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 1, &isnull);
+					
+						if (!isnull)
+							result = pstrdup(
+								NameStr(*(DatumGetName(d))));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_extprotocol */
+				break;
+			
+			case ExtTableRelationId: /* pg_exttable */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 2: /* location */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 2, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+					
+					case 4: /* fmtopts */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 4, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+					
+					case 5: /* command */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 5, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_exttable */
+				break;
+			
+			case FileSpaceRelationId: /* pg_filespace */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 1: /* fsname */
+						result = pstrdup(
+							NameStr(((Form_pg_filespace) 
+									 GETSTRUCT(tuple))->fsname));
+						if (pbIsNull) *pbIsNull = false;
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_filespace */
+				break;
+			
+			case FileSpaceEntryRelationId: /* pg_filespace_entry */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 3: /* fselocation */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 3, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_filespace_entry */
+				break;
+			
+			case ForeignDataWrapperRelationId: /* pg_foreign_data_wrapper */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 1: /* fdwname */
+						result = pstrdup(
+							NameStr(((Form_pg_foreign_data_wrapper) 
+									 GETSTRUCT(tuple))->fdwname));
+						if (pbIsNull) *pbIsNull = false;
+						break;
+					
+					case 5: /* fdwoptions */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 5, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_foreign_data_wrapper */
+				break;
+			
+			case ForeignServerRelationId: /* pg_foreign_server */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 1: /* srvname */
+						result = pstrdup(
+							NameStr(((Form_pg_foreign_server) 
+									 GETSTRUCT(tuple))->srvname));
+						if (pbIsNull) *pbIsNull = false;
+						break;
+					
+					case 4: /* srvtype */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 4, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+					
+					case 5: /* srvversion */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 5, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+					
+					case 7: /* srvoptions */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 7, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_foreign_server */
+				break;
+			
+			case ForeignTableRelationId: /* pg_foreign_table */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 3: /* tbloptions */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 3, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_foreign_table */
+				break;
+			
+			case IndexRelationId: /* pg_index */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 10: /* indexprs */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 10, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+					
+					case 11: /* indpred */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 11, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_index */
+				break;
+			
+			case LanguageRelationId: /* pg_language */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 1: /* lanname */
+						result = pstrdup(
+							NameStr(((Form_pg_language) 
+									 GETSTRUCT(tuple))->lanname));
+						if (pbIsNull) *pbIsNull = false;
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_language */
+				break;
+			
+			case NamespaceRelationId: /* pg_namespace */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 1: /* nspname */
+						result = pstrdup(
+							NameStr(((Form_pg_namespace) 
+									 GETSTRUCT(tuple))->nspname));
+						if (pbIsNull) *pbIsNull = false;
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_namespace */
+				break;
+			
+			case OperatorClassRelationId: /* pg_opclass */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 2: /* opcname */
+						result = pstrdup(
+							NameStr(((Form_pg_opclass) 
+									 GETSTRUCT(tuple))->opcname));
+						if (pbIsNull) *pbIsNull = false;
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_opclass */
+				break;
+			
+			case OperatorRelationId: /* pg_operator */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 1: /* oprname */
+						result = pstrdup(
+							NameStr(((Form_pg_operator) 
+									 GETSTRUCT(tuple))->oprname));
+						if (pbIsNull) *pbIsNull = false;
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_operator */
+				break;
+			
+			case PartitionEncodingRelationId: /* pg_partition_encoding */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 3: /* parencattoptions */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 3, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_partition_encoding */
+				break;
+			
+			case PartitionRuleRelationId: /* pg_partition_rule */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 4: /* parname */
+						result = pstrdup(
+							NameStr(((Form_pg_partition_rule) 
+									 GETSTRUCT(tuple))->parname));
+						if (pbIsNull) *pbIsNull = false;
+						break;
+					
+					case 9: /* parrangestart */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 9, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+					
+					case 10: /* parrangeend */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 10, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+					
+					case 11: /* parrangeevery */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 11, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+					
+					case 12: /* parlistvalues */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 12, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+					
+					case 13: /* parreloptions */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 13, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_partition_rule */
+				break;
+			
+			case PLTemplateRelationId: /* pg_pltemplate */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 1: /* tmplname */
+						result = pstrdup(
+							NameStr(((Form_pg_pltemplate) 
+									 GETSTRUCT(tuple))->tmplname));
+						if (pbIsNull) *pbIsNull = false;
+						break;
+					
+					case 3: /* tmplhandler */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 3, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+					
+					case 4: /* tmplvalidator */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 4, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+					
+					case 5: /* tmpllibrary */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 5, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_pltemplate */
+				break;
+			
+			case ProcedureRelationId: /* pg_proc */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 1: /* proname */
+						result = pstrdup(
+							NameStr(((Form_pg_proc) 
+									 GETSTRUCT(tuple))->proname));
+						if (pbIsNull) *pbIsNull = false;
+						break;
+					
+					case 16: /* proargnames */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 16, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+					
+					case 17: /* prosrc */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 17, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+			
+				  default:
+					elog(ERROR, "column not a cstring: %s\nfile: %s, line %d", 
+						 caql_str, filenam, lineno);
+				}
+			} /* end pg_proc */
+				break;
+			
+			case ResQueueRelationId: /* pg_resqueue */
+			{
+				switch(pchn->attnum)
+				{
+					
+					case 1: /* rsqname */
+						result = pstrdup(
+							NameStr(((Form_pg_resqueue) 
+									 GETSTRUCT(tuple))->rsqname));
+						if (pbIsNull) *pbIsNull = false;
+						break;
+					
+					case 4: /* rsq_memory_limit_cluster */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 4, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+					
+					case 5: /* rsq_core_limit_cluster */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 5, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+					
+					case 7: /* rsq_allocation_policy */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 7, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+					
+						if (pbIsNull) *pbIsNull = isnull;
+					}
+						break;
+					
+					case 8: /* rsq_seg_resource_quota */
+					{
+						bool		isnull;
+						Datum		d = 
+							caql_getattr_internal(pCtx, tuple, 8, &isnull);
+					
+						if (!isnull)
+							result = DatumGetCString(
+								DirectFunctionCall1(textout, d));
+			

<TRUNCATED>


Mime
View raw message