%option prefix="boot_yy"
-D [0-9]
id [-A-Za-z0-9_]+
sid \"([^\"])*\"
-arrayid [A-Za-z0-9_]+\[{D}*\]
%%
"NOT" { return XNOT; }
"NULL" { return XNULL; }
-{arrayid} {
- yylval.str = MapArrayTypeName(yytext);
- return ID;
- }
{id} {
yylval.str = scanstr(yytext);
return ID;
MemoryContextAllocZero(TopMemoryContext, ATTRIBUTE_FIXED_PART_SIZE);
}
-/*
- * MapArrayTypeName
- *
- * Given a type name, produce the corresponding array type name by prepending
- * '_' and truncating as needed to fit in NAMEDATALEN-1 bytes. This is only
- * used in bootstrap mode, so we can get away with assuming that the input is
- * ASCII and we don't need multibyte-aware truncation.
- *
- * The given string normally ends with '[]' or '[digits]'; we discard that.
- *
- * The result is a palloc'd string.
- */
-char *
-MapArrayTypeName(const char *s)
-{
- int i,
- j;
- char newStr[NAMEDATALEN];
-
- newStr[0] = '_';
- j = 1;
- for (i = 0; i < NAMEDATALEN - 2 && s[i] != '['; i++, j++)
- newStr[j] = s[i];
-
- newStr[j] = '\0';
-
- return pstrdup(newStr);
-}
-
-
/*
* index_register() -- record an index that has been set up for building
* later.
{
$atttype = $RENAME_ATTTYPE{$atttype};
}
- if ($attname =~ /(.*)\[.*\]/) # array attribute
+
+ # If the C name ends with '[]' or '[digits]', we have
+ # an array type, so we discard that from the name and
+ # prepend '_' to the type.
+ if ($attname =~ /(\w+)\[\d*\]/)
{
$attname = $1;
- $atttype .= '[]';
+ $atttype = '_' . $atttype;
}
$column{type} = $atttype;
# Replace OID synonyms with OIDs per the appropriate lookup rule.
#
- # If the column type is oidvector or oid[], we have to replace
+ # If the column type is oidvector or _oid, we have to replace
# each element of the array as per the lookup rule.
if ($column->{lookup})
{
\%bki_values, @lookupnames);
$bki_values{$attname} = join(' ', @lookupoids);
}
- elsif ($atttype eq 'oid[]')
+ elsif ($atttype eq '_oid')
{
if ($bki_values{$attname} ne '_null_')
{
$row->{attname} = $attname;
- # Adjust type name for arrays: foo[] becomes _foo, so we can look it up in
- # pg_type
- $atttype = '_' . $1 if $atttype =~ /(.+)\[\]$/;
-
# Copy the type data from pg_type, and add some type-dependent items
my $type = $types{$atttype};
extern void InsertOneValue(char *value, int i);
extern void InsertOneNull(int i);
-extern char *MapArrayTypeName(const char *s);
-
extern void index_register(Oid heap, Oid ind, IndexInfo *indexInfo);
extern void build_indices(void);