|
1 |
| -/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.282 2004/05/10 13:46:06 meskes Exp $ */ |
| 1 | +/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.283 2004/05/21 13:50:12 meskes Exp $ */ |
2 | 2 |
|
3 | 3 | /* Copyright comment */
|
4 | 4 | %{
|
@@ -714,7 +714,7 @@ stmt: AlterDatabaseSetStmt { output_statement($1, 0, connection); }
|
714 | 714 | {
|
715 | 715 | if (connection)
|
716 | 716 | mmerror(PARSE_ERROR, ET_ERROR, "no at option for deallocate statement.\n");
|
717 |
| - fprintf(yyout, "{ ECPGdeallocate(__LINE__, \"%s\");", $1); |
| 717 | + fprintf(yyout, "{ ECPGdeallocate(__LINE__, %d, %s);", compat, $1); |
718 | 718 | whenever_action(2);
|
719 | 719 | free($1);
|
720 | 720 | }
|
@@ -4249,27 +4249,17 @@ connection_target: database_name opt_server opt_port
|
4249 | 4249 |
|
4250 | 4250 | $$ = make3_str(make3_str(make_str("\""), $1, make_str(":")), $3, make3_str(make3_str($4, make_str("/"), $6), $7, make_str("\"")));
|
4251 | 4251 | }
|
4252 |
| - | StringConst |
| 4252 | + | Sconst |
4253 | 4253 | {
|
4254 | 4254 | if ($1[0] == '\"')
|
4255 | 4255 | $$ = $1;
|
4256 |
| - else if (strcmp($1, " ?") == 0) /* variable */ |
4257 |
| - { |
4258 |
| - enum ECPGttype type = argsinsert->variable->type->type; |
4259 |
| - |
4260 |
| - /* if array see what's inside */ |
4261 |
| - if (type == ECPGt_array) |
4262 |
| - type = argsinsert->variable->type->u.element->type; |
4263 |
| - |
4264 |
| - /* handle varchars */ |
4265 |
| - if (type == ECPGt_varchar) |
4266 |
| - $$ = make2_str(mm_strdup(argsinsert->variable->name), make_str(".arr")); |
4267 |
| - else |
4268 |
| - $$ = mm_strdup(argsinsert->variable->name); |
4269 |
| - } |
4270 | 4256 | else
|
4271 | 4257 | $$ = make3_str(make_str("\""), $1, make_str("\""));
|
4272 | 4258 | }
|
| 4259 | + | char_variable |
| 4260 | + { |
| 4261 | + $$ = $1; |
| 4262 | + } |
4273 | 4263 | ;
|
4274 | 4264 |
|
4275 | 4265 | db_prefix: ident cvariable
|
@@ -4365,26 +4355,32 @@ user_name: UserId
|
4365 | 4355 |
|
4366 | 4356 | char_variable: cvariable
|
4367 | 4357 | {
|
4368 |
| - /* check if we have a char variable */ |
| 4358 | + /* check if we have a string variable */ |
4369 | 4359 | struct variable *p = find_variable($1);
|
4370 | 4360 | enum ECPGttype type = p->type->type;
|
4371 | 4361 |
|
4372 |
| - /* if array see what's inside */ |
4373 |
| - if (type == ECPGt_array) |
4374 |
| - type = p->type->u.element->type; |
4375 |
| - |
4376 |
| - switch (type) |
4377 |
| - { |
4378 |
| - case ECPGt_char: |
4379 |
| - case ECPGt_unsigned_char: |
4380 |
| - $$ = $1; |
4381 |
| - break; |
4382 |
| - case ECPGt_varchar: |
4383 |
| - $$ = make2_str($1, make_str(".arr")); |
4384 |
| - break; |
4385 |
| - default: |
| 4362 | + /* If we have just one character this is not a string */ |
| 4363 | + if (atol(p->type->size) == 1) |
4386 | 4364 | mmerror(PARSE_ERROR, ET_ERROR, "invalid datatype");
|
4387 |
| - break; |
| 4365 | + else |
| 4366 | + { |
| 4367 | + /* if array see what's inside */ |
| 4368 | + if (type == ECPGt_array) |
| 4369 | + type = p->type->u.element->type; |
| 4370 | + |
| 4371 | + switch (type) |
| 4372 | + { |
| 4373 | + case ECPGt_char: |
| 4374 | + case ECPGt_unsigned_char: |
| 4375 | + $$ = $1; |
| 4376 | + break; |
| 4377 | + case ECPGt_varchar: |
| 4378 | + $$ = make2_str($1, make_str(".arr")); |
| 4379 | + break; |
| 4380 | + default: |
| 4381 | + mmerror(PARSE_ERROR, ET_ERROR, "invalid datatype"); |
| 4382 | + break; |
| 4383 | + } |
4388 | 4384 | }
|
4389 | 4385 | }
|
4390 | 4386 | ;
|
|
0 commit comments