[SQL] system view corrupted, i get "unexpected right parenthesis" for many system tables.

2006-01-09 Thread David Ford
i encountered this when trying to do a pg_dumpall in preparation for moving from 8.0 to 8.1.Jaymale ~ # pg_dump -U postgres -d administration > psql-dbs.jan2006.dumppg_dump: SQL command failedpg_dump: Error message from server: ERROR:  unexpected right parenthesis
pg_dump: The command was: SELECT tableoid, oid, nspname, (select usename from pg_user where nspowner = usesysid) as usename, nspacl FROM pg_namespaceadministration=# \dtERROR:  unexpected right parenthesis
administration=# \dERROR:  unexpected right parenthesisadministration=# select * from pg_tables;ERROR:  unexpected right parenthesisnarrowing it down to:(normal output below, broke follows)
postgres=# \d pg_user;* QUERY **SELECT c.oid,  n.nspname,  c.relnameFROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespaceWHERE c.relname
 ~ '^pg_user$'  AND pg_catalog.pg_table_is_visible(c.oid)ORDER BY 2, 3;*** QUERY **SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules,relhasoids , reltablespace
FROM pg_catalog.pg_class WHERE oid = '10320'*** QUERY **SELECT a.attname,  pg_catalog.format_type(a.atttypid, a.atttypmod),  (SELECT substring(pg_catalog.pg_get_expr(
d.adbin, d.adrelid) for 128)   FROM pg_catalog.pg_attrdef d   WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum AND a.atthasdef),  a.attnotnull, a.attnumFROM pg_catalog.pg_attribute aWHERE a.attrelid
 = '10320' AND a.attnum > 0 AND NOT a.attisdroppedORDER BY a.attnum*** QUERY **SELECT pg_catalog.pg_get_viewdef('10320'::pg_catalog.oid, true)**
* QUERY **SELECT r.rulename, trim(trailing ';' from pg_catalog.pg_get_ruledef(r.oid, true))FROM pg_catalog.pg_rewrite rWHERE r.ev_class = '10320' AND r.rulename != '_RETURN' ORDER BY 1
** View "pg_catalog.pg_user"   Column    |  Type   | Modifiers-+-+--- usename | name    | usesysid    | oid | usecreatedb | boolean |
 usesuper    | boolean | usecatupd   | boolean | passwd  | text    | valuntil    | abstime | useconfig   | text[]  |View definition: SELECT pg_shadow.usename, pg_shadow.usesysid, pg_shadow.usecreatedb, pg_shadow.usesuper, pg_shadow.usecatupd, ''::text AS passwd, pg_shadow.valuntil, pg_shadow.useconfig
   FROM pg_shadow;+broken one:administration-# \d pg_user;* QUERY **SELECT c.oid,  n.nspname,  c.relname
FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespaceWHERE pg_catalog.pg_table_is_visible(c.oid)  AND c.relname ~ '^pg_user$'ORDER BY 2, 3;**
* QUERY **SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules,relhasoids , reltablespaceFROM pg_catalog.pg_class WHERE oid = '16762'*** QUERY **
SELECT a.attname,  pg_catalog.format_type(a.atttypid, a.atttypmod),  (SELECT substring(d.adsrc for 128) FROM pg_catalog.pg_attrdef d   WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum AND a.atthasdef),
  a.attnotnull, a.attnumFROM pg_catalog.pg_attribute aWHERE a.attrelid = '16762' AND a.attnum > 0 AND NOT a.attisdroppedORDER BY a.attnum*** QUERY **SELECT pg_catalog.pg_get_viewdef('16762'::pg_catalog.oid, true)
**ERROR:  unexpected right parenthesisthe view rule for this is:++administration=# select ev_action from pg_rewrite where oid=16764;
[...]({QUERY :commandType 1 :querySource 0 :canSetTag true :utilityStmt <> :resultRelation 0 :into <> :hasAggs false :hasSubLinks false :rtable ({RTE :alias {ALIAS :aliasname *OLD* :colnames <>} :eref {ALIAS :aliasname *OLD* :colnames ("usename" "usesysid" "usecreatedb" "usesuper" "usecatupd" "passwd" "valuntil" "useconfig")} :rtekind 0 :relid 16762 :inh false :inFromCl false :requiredPerms 0 :checkAsUser 1} {RTE :alias {ALIAS :aliasname *NEW* :colnames <>} :eref {ALIAS :aliasname *NEW* :colnames ("usename" "usesysid" "usecreatedb" "usesuper" "usecatupd" "passwd" "valuntil" "useconfig")} :rtekind 0 :relid 16762 :inh false :inFromCl false :requiredPerms 0 :checkAsUser 1} {RTE :alias <> :eref {ALIAS :aliasname pg_shadow :colnames ("usename" "usesysid" "usecreatedb" "usesuper" "usecatupd" "passwd" "valuntil" "useconfig")} :rtekind 0 :relid 1260 :inh true :inFromCl true :requiredPerms 2 :checkAsUser 1}) :jointree {FROMEXPR :fromlist ({RANGETBLREF :rtindex 3}) :quals <>} :rowMarks <> :targetList ({TARGETENTRY :resdom {RESDOM :resno 1 :restype 19 :restypmod -1 :resname usename :ressortgroupref 0 :resorigtbl 1260 :resorigcol 1 :resjunk false} :expr {VAR :varno 3 :varattno 1 :vartype 19 :vartypmod -1 :varlevelsup 0 :varnoold 3 :varoattno 1}} {TARGETENTRY :resdom {RESDOM :resno 2 :restype 23 :restypmod -1 :resname usesy

Re: [SQL] system view corrupted, i get "unexpected right parenthesis" for many system tables.

2006-01-09 Thread David Ford
you are correct and we've gone down that road.  i build my db with 8.0.1, and i've upgraded through to 8.0.5 as time went by and i never noticed an issue with it until i went to bump to 8.1 today.i've tried with and without the hier patch and neither seems to work.  i have a few options left to try but i might be reduced to stitching together COPYs and system tables from an older backup.
On 1/9/06, Tom Lane <[EMAIL PROTECTED]> wrote:
David Ford <[EMAIL PROTECTED]> writes:> i encountered this when trying to do a pg_dumpall in preparation for moving> from 8.0 to 8.1.Would it be too far off to guess that you're running Gentoo?  This looks
like ye olde problem with that hierarchical-queries patch that they pushon people.  Either adding or removing the patch breaks your database :-(.Since your rewrite rule looks standard, I'm guessing that you rebuilt
and added the patch at some point after initially building your database.Reconfigure 8.0 the way you originally built it and you should be OK ...unless you have views that you created after changing ...
regards, tom lane-- Gay/Firefighter/EMT/Geek in 06451, USAIt's the ideals of Linux and Open Source that are amazing, it embodies what WE want, not what is marketed
Once you lose the greatest of all things, it's the memories you cherish for all time.  He was the best, I could have been better.


Re: [SQL] system view corrupted, i get "unexpected right parenthesis" for many system tables.

2006-01-09 Thread David Ford
that's ok, i found a working solution with 8.0.5 +pg-hier (8.0.1 wouldn't work + or -pg-hier), so i got things dumped, upgraded, and running.  thank you to you and the guys on #postgresql very much for your assistance :)
davidOn 1/9/06, Tom Lane <[EMAIL PROTECTED]> wrote:
David Ford <[EMAIL PROTECTED]> writes:> i've tried with and without the hier patch and neither seems to work.I was afraid of that: you've got some views created with the patch
installed and some with it not installed.> i have a few options left to try but i might be reduced to stitching together> COPYs and system tables from an older backup.It should be possible to manually correct the bogus entries.  Basically
what the patch does is add a field to the QUERY structure, whose name Iforget but comparing working and non-working ev_action strings shouldexpose it.  (It's probably near the end of the string.)  If you delete
the field (text ":fieldname <> ") from the non-working ev_action stringsyou should be able to get to a state where all the views will dump in anon-hier build.regards, tom lane
-- Gay/Firefighter/EMT/Geek in 06451, USAIt's the ideals of Linux and Open Source that are amazing, it embodies what WE want, not what is marketedOnce you lose the greatest of all things, it's the memories you cherish for all time.  He was the best, I could have been better.